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 details)
Built Distribution
File details
Details for the file fastapi_vers-0.3.0.tar.gz
.
File metadata
- Download URL: fastapi_vers-0.3.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1208253c8e3a5de428277f9f8c9f84cac61a8f5f5b20cb7e27bf0253b75fe468 |
|
MD5 | 25b35ab23b76fcec68b79928ca61024e |
|
BLAKE2b-256 | e7016d73a71eeedb191845ab64cf82dc7b2ba861f28af01d7df00a5b79e54955 |
File details
Details for the file fastapi_vers-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: fastapi_vers-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9340cac6f197f60ed6458c2c453223e55ebf460a2fd3cdb620bca47c888f009 |
|
MD5 | 2f06b1c65b4701bf53dcfa601d40471a |
|
BLAKE2b-256 | 1517873a10a68f6459d9562c51b1cd6ea4c670cdb8530403fc4e4e1469b42115 |