FastAPI Class Views and utilities
Project description
fastapi-views
FastAPI Class Views and utilities
Version: 1.0.0-beta.1
Documentation: https://performancemedia.github.io/fastapi-views/
Repository: https://github.com/performancemedia/fastapi-views
Installation
pip install fastapi-views
Usage
from typing import Optional
from uuid import UUID
from fastapi_views import Serializer, ViewRouter
from fastapi_views.views.viewsets import AsyncAPIViewSet
class ItemSchema(Serializer):
id: UUID
name: str
price: int
items = {}
class MyViewSet(AsyncAPIViewSet):
api_component_name = "Item"
serializer = ItemSchema
async def list(self):
return list(items.values())
async def create(self, item: ItemSchema) -> ItemSchema:
items[item.id] = item
return item
async def retrieve(self, id: UUID) -> Optional[ItemSchema]:
return items.get(id)
async def update(self, item: ItemSchema):
items[item.id] = item
async def destroy(self, id: UUID) -> None:
items.pop(id, None)
router = ViewRouter(prefix="/items")
router.register_view(MyViewSet)
# in app.py
# app.include_router(router)
Features
- Class Based Views
- APIViews
- GenericViews
- ViewSets
- Both async and sync function support
- No dependencies on ORM
- Openapi id simplification
- 'Smart' and fast serialization using orjson
- Http Problem Details implementation
- Automatic prometheus metrics exporter
- Pluggable healthcheck helper
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_views-1.0.0b1.tar.gz
(18.5 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_views-1.0.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9537bb58b29c2fe24f7a9327d4f585c735ae304277539d8b7c37a81e0addd351 |
|
MD5 | 6d04aa38009c2094bf9ad3f273b98674 |
|
BLAKE2b-256 | 1c2875735726a7f41198f29422744e49211cf7cbdd5225213e7277782a091faf |