Add your description here
Project description
fastapi-header-versions
This package adds versioning by Accept-header into FastAPI
Defining app and routes
from enum import StrEnum
import fastapi
from fast_version import VersionedRouter, InlineVersionedRouter, init_fastapi_versioning
class AppType(StrEnum):
some_name: "some.name"
some_name2: "some.name2"
decorate_router = VersionedRouter()
inline_router = InlineVersionedRouter()
@decorate_router.get("/test/")
@decorate_router.set_api_version((1, 0), app_names={AppType.some_name, AppType.some_name2})
async def test_get() -> dict:
return {"version": (1, 0)}
@inline_router.get("/test/", (2, 0), app_names=AppType.some_name)
async def test_get_v2() -> dict:
return {"version": (2, 0)}
app = fastapi.FastAPI()
app.include_router(inline_router)
init_fastapi_versioning(app=app)
Query Examples
# call 1.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=1.0'
# call 2.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=2.0'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_header_versions-0.2.0.tar.gz.
File metadata
- Download URL: fastapi_header_versions-0.2.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.28
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e6694279a75a7eb96448c09c56414a5aad619f942a054fe78bcc2e0fd8f2de2
|
|
| MD5 |
2db6e84f20dfa9742a507d33a17a181c
|
|
| BLAKE2b-256 |
05e52651ec76ad5fffd60f1a20541f7b50da7d6ef2f74c8dc943bfee454a19c5
|
File details
Details for the file fastapi_header_versions-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_header_versions-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.28
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5043373e82c735d9aa10103762c938ffc751f0b1ae1de478549a358931e1b6
|
|
| MD5 |
2e2aedfe9821c9aaa162adf968750372
|
|
| BLAKE2b-256 |
4ee6d28e3a81c97fb99d0e17aad16d54ab5ba087f594038a6d0bbcf0ef1d0c78
|