FastAPI Class Views and utilities
Project description
fastapi-views
FastAPI Class Views and utilities
Version: 0.0.4
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.0.4.tar.gz
(18.2 kB
view details)
Built Distribution
File details
Details for the file fastapi_views-0.0.4.tar.gz
.
File metadata
- Download URL: fastapi_views-0.0.4.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f4d096d572b24513d3e53acdf691a660e995f7af5b0458b0ee9d809f013f842 |
|
MD5 | e8176947db7bd2ca70ebebfce29bb664 |
|
BLAKE2b-256 | 44f7be932b5e04fa5c94b1c65fe3f9151518651b793f431296a7cfee815740ec |
File details
Details for the file fastapi_views-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: fastapi_views-0.0.4-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7d18f67620643507b87018203fcbacc405f57e392f1b5b392b7a2e8976625d |
|
MD5 | e68ca4be94def5d43a891f7ce37bff16 |
|
BLAKE2b-256 | 3acc45c422ca79f026e5688b2b351965cabf2d9fbc83ad9c7f5feb97fd474949 |