FastAPI versioning
Project description
fastapi_vers
API versioning concept for FastAPI
pip install fastapi_vers
from fastapi import FastAPI
from fastapi_vers import API
api = API(
"0.3",
app_kwds={
"all": {"title": "Versioned API", "version": "0.0"},
"0.1": {"version": "0.1"},
"0.2": {"version": "0.2"},
}
)
@api.app.get("/")
async def root():
return "Hello World!"
@api.app.get("/foo")
@api.version(["0.1-0.2"])
async def foo():
return "This endpoint available only for 0.1, 0.2 api versions"
@api.app.get("/bar")
@api.version(["0.1-latest"])
async def bar():
return "This endpoint available for 0.1, 0.2, 0.3 api versions"
app = FastAPI()
app.mount("/api", api.get_versioned_app())
"""
http://localhost:8000/api/latest
http://localhost:8000/api/0.1/foo
http://localhost:8000/api/0.2/foo
http://localhost:8000/api/0.1/bar
http://localhost:8000/api/0.2/bar
http://localhost:8000/api/0.3/bar
"""
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
fastapi_vers-0.3.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_vers-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9340cac6f197f60ed6458c2c453223e55ebf460a2fd3cdb620bca47c888f009 |
|
MD5 | 2f06b1c65b4701bf53dcfa601d40471a |
|
BLAKE2b-256 | 1517873a10a68f6459d9562c51b1cd6ea4c670cdb8530403fc4e4e1469b42115 |