Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asynq-io/fastapi-views
FastAPI Class Views and utilities
https://github.com/asynq-io/fastapi-views
api asyncio fastapi python rest
Last synced: about 2 months ago
JSON representation
FastAPI Class Views and utilities
- Host: GitHub
- URL: https://github.com/asynq-io/fastapi-views
- Owner: asynq-io
- License: apache-2.0
- Created: 2024-07-16T13:00:06.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-09-30T03:39:36.000Z (3 months ago)
- Last Synced: 2024-10-03T10:47:26.641Z (3 months ago)
- Topics: api, asyncio, fastapi, python, rest
- Language: Python
- Homepage: https://asynq-io.github.io/fastapi-views/
- Size: 975 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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)
![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)
![Mypy](https://img.shields.io/badge/mypy-checked-blue)
![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)*FastAPI Class Views and utilities*
---
Version: 0.3.2Documentation: 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 Optional
from uuid import UUIDfrom fastapi_views import Serializer, ViewRouter
from fastapi_views.views.viewsets import AsyncAPIViewSetclass ItemSchema(Serializer):
id: UUID
name: str
price: intitems = {}
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 itemasync def retrieve(self, id: UUID) -> Optional[ItemSchema]:
return items.get(id)async def update(self, item: ItemSchema):
items[item.id] = itemasync 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