FastAPI Class Views and utilities
Project description
fastapi-views
FastAPI Class Views and utilities
Version: 0.3.1
Documentation: https://asynq-io.github.io/fastapi-views/
Repository: https://github.com/asynq-io/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.3.1.tar.gz
(19.8 kB
view details)
Built Distribution
File details
Details for the file fastapi_views-0.3.1.tar.gz
.
File metadata
- Download URL: fastapi_views-0.3.1.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c26cd4253bb0f986fc99d01fac43a388682b29f84f04cf3ab883a5a38b105b |
|
MD5 | 190cc38a6842e0b137064408259645b0 |
|
BLAKE2b-256 | eedad01836a8cd7fbc4e53ca1b1663b58a741d0497d0c1ee0154db99b4abc9ed |
File details
Details for the file fastapi_views-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: fastapi_views-0.3.1-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917eadfd8faad1580c483e05f7c28a953bfe42882164b17081aac1e0b13a48e8 |
|
MD5 | 9e70fb662be08a274b233490b70aacb8 |
|
BLAKE2b-256 | 585f51d732956226d40d8fc075fd209d488ec86412a9b63d7beb329904114fc2 |