FastAPI Class Views and utilities
Project description
fastapi-views
FastAPI Class Views and utilities
Version: 0.2.0
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-0.2.0.tar.gz
(19.3 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_views-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec79d52708ec1f3824f9e632641dfd11f55685bc488db5b68cedccac2f5d6d13 |
|
MD5 | 49e109329e25bdefe98c915bdd081ac1 |
|
BLAKE2b-256 | 8a0b8ad83a02fa7b9af3a7e3736b483584af4ec4749924f0ec71e3d4a92f5af2 |