Fastapi versioning package with accept header
Project description
FastAPI versioning library
This package adds versioning by Accept-header into FastAPI
Quickstart:
Installation
$ pip install fast-version
Defining app and routes
import fastapi
from fast_version import VersionedAPIRouter, init_fastapi_versioning
VERSION_HEADER: str = "application/vnd.some.name+json"
ROUTER_OBJ = VersionedAPIRouter()
@ROUTER_OBJ.get("/test/")
async def test_get() -> dict:
return {"version": (1, 0)}
@ROUTER_OBJ.get("/test/")
@ROUTER_OBJ.set_api_version((2, 0))
async def test_get_v2() -> dict:
return {"version": (2, 0)}
app = fastapi.FastAPI()
app.include_router(ROUTER_OBJ)
init_fastapi_versioning(app=app, vendor_media_type=VERSION_HEADER)
Query Examples
# call 1.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=1.0'
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json'
curl -X 'GET' 'https://test.ru/test/'
# call 2.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=2.0'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fast_version-1.2.0.tar.gz
(4.9 kB
view details)
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 fast_version-1.2.0.tar.gz.
File metadata
- Download URL: fast_version-1.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c14d6b72053ce56bb4079a620bfa195334aa8a93d3b042d0dbb68f27208ab8d
|
|
| MD5 |
92f36159b622456f50cb965fe1e3cb28
|
|
| BLAKE2b-256 |
a5363c82c79ddcd0da025a1671ad5c3f30b7b2c51fcd51150617b3f2933d4756
|
File details
Details for the file fast_version-1.2.0-py3-none-any.whl.
File metadata
- Download URL: fast_version-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42ac2807252b9e5815cc71ce046700a60f9c9315fabb558a713df28e788f6c72
|
|
| MD5 |
264832d85b259923aaa8be944f97c492
|
|
| BLAKE2b-256 |
8127c495513f51687c7682f501c147ec1c8f32f4299d02fd693f372d6b8511d8
|