Name | fast-version JSON |
Version |
1.4.0
JSON |
| download |
home_page | None |
Summary | Fastapi versioning package with accept header |
upload_time | 2024-11-27 09:41:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4,>=3.10 |
license | MIT |
keywords |
accept-header
fastapi
versioning
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
FastAPI versioning library
==
[![Test Coverage](https://codecov.io/gh/community-of-python/fast-version/branch/main/graph/badge.svg)](https://codecov.io/gh/community-of-python/fast-version)
[![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)
[![Supported versions](https://img.shields.io/pypi/pyversions/fast-version.svg)](https://pypi.python.org/pypi/fast-version)
[![downloads](https://img.shields.io/pypi/dm/fast-version.svg)](https://pypistats.org/packages/fast-version)
[![GitHub stars](https://img.shields.io/github/stars/community-of-python/fast-version)](https://github.com/community-of-python/fast-version/stargazers)
<img src="./logo.svg" width="250" />
This package adds versioning by Accept-header into FastAPI
## Quickstart:
### Installation
```shell
$ pip install fast-version
```
### Defining app and routes
```python
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
```bash
# 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'
```
Raw data
{
"_id": null,
"home_page": null,
"name": "fast-version",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": null,
"keywords": "accept-header, fastapi, versioning",
"author": null,
"author_email": "Artur Shiriev <me@shiriev.ru>",
"download_url": "https://files.pythonhosted.org/packages/78/f3/c6ea550bc1da50b03f3b728f14706c4ccd978da4161f9bda2a6dfcfdc902/fast_version-1.4.0.tar.gz",
"platform": null,
"description": "FastAPI versioning library\n==\n[![Test Coverage](https://codecov.io/gh/community-of-python/fast-version/branch/main/graph/badge.svg)](https://codecov.io/gh/community-of-python/fast-version)\n[![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)\n[![Supported versions](https://img.shields.io/pypi/pyversions/fast-version.svg)](https://pypi.python.org/pypi/fast-version)\n[![downloads](https://img.shields.io/pypi/dm/fast-version.svg)](https://pypistats.org/packages/fast-version)\n[![GitHub stars](https://img.shields.io/github/stars/community-of-python/fast-version)](https://github.com/community-of-python/fast-version/stargazers)\n\n<img src=\"./logo.svg\" width=\"250\" />\n\nThis package adds versioning by Accept-header into FastAPI\n\n## Quickstart:\n\n### Installation\n\n```shell\n$ pip install fast-version\n```\n\n### Defining app and routes\n```python\nimport fastapi\n\nfrom fast_version import VersionedAPIRouter, init_fastapi_versioning\n\n\nVERSION_HEADER: str = \"application/vnd.some.name+json\"\nROUTER_OBJ = VersionedAPIRouter()\n\n\n@ROUTER_OBJ.get(\"/test/\")\nasync def test_get() -> dict:\n return {\"version\": (1, 0)}\n\n\n@ROUTER_OBJ.get(\"/test/\")\n@ROUTER_OBJ.set_api_version((2, 0))\nasync def test_get_v2() -> dict:\n return {\"version\": (2, 0)}\n\n\napp = fastapi.FastAPI()\napp.include_router(ROUTER_OBJ)\ninit_fastapi_versioning(app=app, vendor_media_type=VERSION_HEADER)\n```\n\n### Query Examples\n```bash\n# call 1.0 version\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=1.0'\n\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json'\n\ncurl -X 'GET' 'https://test.ru/test/'\n\n# call 2.0 version\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=2.0'\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Fastapi versioning package with accept header",
"version": "1.4.0",
"project_urls": {
"repository": "https://github.com/modern-python/fast-version"
},
"split_keywords": [
"accept-header",
" fastapi",
" versioning"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "1462c7e9e9c08f0c94c7af2bb30d035d75230f82ca0a440cc35876303020e2eb",
"md5": "0870865903083f519674d821e94f60f7",
"sha256": "df1c7d1b6d14bfd4a7558987e5553c4da00205cf3e525b9757ae4e199691e5f9"
},
"downloads": -1,
"filename": "fast_version-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0870865903083f519674d821e94f60f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 6026,
"upload_time": "2024-11-27T09:41:29",
"upload_time_iso_8601": "2024-11-27T09:41:29.092303Z",
"url": "https://files.pythonhosted.org/packages/14/62/c7e9e9c08f0c94c7af2bb30d035d75230f82ca0a440cc35876303020e2eb/fast_version-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "78f3c6ea550bc1da50b03f3b728f14706c4ccd978da4161f9bda2a6dfcfdc902",
"md5": "9bb91eb5ebe793318d686022478a7097",
"sha256": "3a5e6971ccc7847ca1392236d2f5e87b8ab072bbdab24452b0b816d8ac0def33"
},
"downloads": -1,
"filename": "fast_version-1.4.0.tar.gz",
"has_sig": false,
"md5_digest": "9bb91eb5ebe793318d686022478a7097",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 7711,
"upload_time": "2024-11-27T09:41:30",
"upload_time_iso_8601": "2024-11-27T09:41:30.510536Z",
"url": "https://files.pythonhosted.org/packages/78/f3/c6ea550bc1da50b03f3b728f14706c4ccd978da4161f9bda2a6dfcfdc902/fast_version-1.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-27 09:41:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "modern-python",
"github_project": "fast-version",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fast-version"
}