Name | fastapi-views JSON |
Version |
1.0.5
JSON |
| download |
home_page | None |
Summary | FastAPI Class Views and utilities |
upload_time | 2024-12-11 10:34:34 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Apache-2.0 |
keywords |
asyncio
fastapi
views
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# fastapi-views
![Tests](https://github.com/asynq-io/fastapi-views/workflows/Tests/badge.svg)
![Build](https://github.com/asynq-io/fastapi-views/workflows/Publish/badge.svg)
![License](https://img.shields.io/github/license/asynq-io/fastapi-views)
![Mypy](https://img.shields.io/badge/mypy-checked-blue)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
![Python](https://img.shields.io/pypi/pyversions/fastapi-views)
![Format](https://img.shields.io/pypi/format/fastapi-views)
![PyPi](https://img.shields.io/pypi/v/fastapi-views)
*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/67/87/8e6e41372a3a73ff1d6f648497003e726410e40ce07c14cf28c290f426e4/fastapi_views-1.0.5.tar.gz",
"platform": null,
"description": "# fastapi-views\n\n![Tests](https://github.com/asynq-io/fastapi-views/workflows/Tests/badge.svg)\n![Build](https://github.com/asynq-io/fastapi-views/workflows/Publish/badge.svg)\n![License](https://img.shields.io/github/license/asynq-io/fastapi-views)\n![Mypy](https://img.shields.io/badge/mypy-checked-blue)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n![Python](https://img.shields.io/pypi/pyversions/fastapi-views)\n![Format](https://img.shields.io/pypi/format/fastapi-views)\n![PyPi](https://img.shields.io/pypi/v/fastapi-views)\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": "Apache-2.0",
"summary": "FastAPI Class Views and utilities",
"version": "1.0.5",
"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": "",
"digests": {
"blake2b_256": "3cc0f1825d484229995ed6164ca58100d1a68dcb481a534ad9ba8b4278d9d2eb",
"md5": "74257b73cf2f27be3f2f7de7099089d4",
"sha256": "5bac67dd9df4bbfa3e5d41b014515ae9eca8fd4946fd4c5443ad29860b6d743d"
},
"downloads": -1,
"filename": "fastapi_views-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "74257b73cf2f27be3f2f7de7099089d4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21405,
"upload_time": "2024-12-11T10:34:32",
"upload_time_iso_8601": "2024-12-11T10:34:32.322121Z",
"url": "https://files.pythonhosted.org/packages/3c/c0/f1825d484229995ed6164ca58100d1a68dcb481a534ad9ba8b4278d9d2eb/fastapi_views-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "67878e6e41372a3a73ff1d6f648497003e726410e40ce07c14cf28c290f426e4",
"md5": "9b4253cc64143e43f7106eb6046e208f",
"sha256": "4d215d8229cf4d12ae4d18dbda6ceced7761a11844f51aea86fa7132c4750549"
},
"downloads": -1,
"filename": "fastapi_views-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "9b4253cc64143e43f7106eb6046e208f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 78141,
"upload_time": "2024-12-11T10:34:34",
"upload_time_iso_8601": "2024-12-11T10:34:34.656992Z",
"url": "https://files.pythonhosted.org/packages/67/87/8e6e41372a3a73ff1d6f648497003e726410e40ce07c14cf28c290f426e4/fastapi_views-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 10:34:34",
"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"
}