Name | fastapi-views JSON |
Version |
1.1.0
JSON |
| download |
home_page | None |
Summary | FastAPI Class Views and utilities |
upload_time | 2025-02-12 09:37:51 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
asyncio
fastapi
views
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# fastapi-views




[](https://github.com/charliermarsh/ruff)
[](https://docs.pydantic.dev/latest/contributing/#badges)
[](https://github.com/PyCQA/bandit)



*FastAPI Class Views and utilities*
---
Documentation: https://asynq-io.github.io/fastapi-views/
Repository: https://github.com/asynq-io/fastapi-views
---
## Installation
```shell
pip install fastapi-views
```
## Usage
```python
from typing import ClassVar, Optional
from uuid import UUID
from fastapi import FastAPI
from pydantic import BaseModel
from fastapi_views import ViewRouter, configure_app
from fastapi_views.views.viewsets import AsyncAPIViewSet
class UpdateItemSchema(BaseModel):
name: str
price: int
class ItemSchema(BaseModel):
id: UUID
name: str
price: int
class MyViewSet(AsyncAPIViewSet):
api_component_name = "Item"
response_schema = ItemSchema
items: ClassVar[dict[UUID, ItemSchema]] = {}
async def list(self) -> list[ItemSchema]:
return list(self.items.values())
async def create(self, item: ItemSchema) -> ItemSchema:
self.items[item.id] = item
return item
async def retrieve(self, id: UUID) -> Optional[ItemSchema]:
return self.items.get(id)
async def update(self, id: UUID, item: UpdateItemSchema) -> ItemSchema:
self.items[id] = ItemSchema(id=id, name=item.name, price=item.price)
return self.items[id]
async def destroy(self, id: UUID) -> None:
self.items.pop(id, None)
router = ViewRouter(prefix="/items")
router.register_view(MyViewSet)
app = FastAPI(title="My API")
app.include_router(router)
configure_app(app)
```
## Features
- Class Based Views
- APIViews
- ViewSets
- Both async and sync function support
- No dependencies on ORM
- OpenAPI operation id simplification
- 'Smart' and fast serialization using Pydantic v2
- Http Problem Details implementation (both models & exception classes)
- Automatic prometheus metrics exporter
- Optional Opentelemetry instrumentation with `correlation_id` in error responses
- CLI for generating OpenAPI documentation file
- Pagination types & schemas
Raw data
{
"_id": null,
"home_page": null,
"name": "fastapi-views",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "asyncio, fastapi, views",
"author": null,
"author_email": "RaRhAeu <rarha_eu@protonmail.com>",
"download_url": "https://files.pythonhosted.org/packages/50/ac/6aa26ff2e1cc9687b2b8b3df6fd531b1fb71a9ec9b5282c8fa245cb81e3b/fastapi_views-1.1.0.tar.gz",
"platform": null,
"description": "# fastapi-views\n\n\n\n\n\n[](https://github.com/charliermarsh/ruff)\n[](https://docs.pydantic.dev/latest/contributing/#badges)\n[](https://github.com/PyCQA/bandit)\n\n\n\n\n*FastAPI Class Views and utilities*\n\n---\nDocumentation: https://asynq-io.github.io/fastapi-views/\n\nRepository: https://github.com/asynq-io/fastapi-views\n\n---\n\n## Installation\n\n```shell\npip install fastapi-views\n```\n\n## Usage\n\n```python\nfrom typing import ClassVar, Optional\nfrom uuid import UUID\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\nfrom fastapi_views import ViewRouter, configure_app\nfrom fastapi_views.views.viewsets import AsyncAPIViewSet\n\n\nclass UpdateItemSchema(BaseModel):\n name: str\n price: int\n\n\nclass ItemSchema(BaseModel):\n id: UUID\n name: str\n price: int\n\n\nclass MyViewSet(AsyncAPIViewSet):\n api_component_name = \"Item\"\n response_schema = ItemSchema\n items: ClassVar[dict[UUID, ItemSchema]] = {}\n\n async def list(self) -> list[ItemSchema]:\n return list(self.items.values())\n\n async def create(self, item: ItemSchema) -> ItemSchema:\n self.items[item.id] = item\n return item\n\n async def retrieve(self, id: UUID) -> Optional[ItemSchema]:\n return self.items.get(id)\n\n async def update(self, id: UUID, item: UpdateItemSchema) -> ItemSchema:\n self.items[id] = ItemSchema(id=id, name=item.name, price=item.price)\n return self.items[id]\n\n async def destroy(self, id: UUID) -> None:\n self.items.pop(id, None)\n\n\nrouter = ViewRouter(prefix=\"/items\")\nrouter.register_view(MyViewSet)\n\napp = FastAPI(title=\"My API\")\napp.include_router(router)\n\nconfigure_app(app)\n```\n\n## Features\n\n- Class Based Views\n - APIViews\n - ViewSets\n- Both async and sync function support\n- No dependencies on ORM\n- OpenAPI operation id simplification\n- 'Smart' and fast serialization using Pydantic v2\n- Http Problem Details implementation (both models & exception classes)\n- Automatic prometheus metrics exporter\n- Optional Opentelemetry instrumentation with `correlation_id` in error responses\n- CLI for generating OpenAPI documentation file\n- Pagination types & schemas\n",
"bugtrack_url": null,
"license": null,
"summary": "FastAPI Class Views and utilities",
"version": "1.1.0",
"project_urls": {
"Documentation": "https://github.com/asynq-io/fastapi-views#readme",
"Issues": "https://github.com/asynq-io/fastapi-views/issues",
"Source": "https://github.com/asynq-io/fastapi-views"
},
"split_keywords": [
"asyncio",
" fastapi",
" views"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fdf6de122766c6dc972336a9945508c1e579e3271a78c036ba334fc96c14bd4c",
"md5": "9cc141e22cbee1f3e8a71cadf46a9fb4",
"sha256": "46157682ce48b25abced86350f503703aeee603f1233b652ef79616d9c72e3dd"
},
"downloads": -1,
"filename": "fastapi_views-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9cc141e22cbee1f3e8a71cadf46a9fb4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 27752,
"upload_time": "2025-02-12T09:37:50",
"upload_time_iso_8601": "2025-02-12T09:37:50.193255Z",
"url": "https://files.pythonhosted.org/packages/fd/f6/de122766c6dc972336a9945508c1e579e3271a78c036ba334fc96c14bd4c/fastapi_views-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "50ac6aa26ff2e1cc9687b2b8b3df6fd531b1fb71a9ec9b5282c8fa245cb81e3b",
"md5": "0c36d13fb631c674413cb1b96c70b048",
"sha256": "15525c2204d7e6b466ec1c010e888f4309d348388243816436f24f33c6a9164a"
},
"downloads": -1,
"filename": "fastapi_views-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0c36d13fb631c674413cb1b96c70b048",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 25521,
"upload_time": "2025-02-12T09:37:51",
"upload_time_iso_8601": "2025-02-12T09:37:51.375632Z",
"url": "https://files.pythonhosted.org/packages/50/ac/6aa26ff2e1cc9687b2b8b3df6fd531b1fb71a9ec9b5282c8fa245cb81e3b/fastapi_views-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-12 09:37:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "asynq-io",
"github_project": "fastapi-views#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "fastapi-views"
}