Skip to main content

FastAPI Class Views and utilities

Project description

fastapi-views

CI Build License Python Format PyPi Mypy Code Style security: bandit

FastAPI Class Views and utilities


Version: 0.0.6

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


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.6.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

fastapi_views-0.0.6-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_views-0.0.6.tar.gz.

File metadata

  • Download URL: fastapi_views-0.0.6.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for fastapi_views-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ce83e66e16117810871561332422a73ba79087750e683eee8e257ea3063bcb74
MD5 c6af7d42c186bb152a2abf3bf46fde71
BLAKE2b-256 d416f4741effe2cf1718f36172d40deeaaf641231255675d8502b9f100c8fdc7

See more details on using hashes here.

File details

Details for the file fastapi_views-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_views-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 19c77368835ab834b9ce611b8e25a13c8d72473dcfa164ada58b93128761407f
MD5 c73d0e744192d9451225fcd97f7eea55
BLAKE2b-256 b9e9cc8d626c373e4a968b6314f28ed9d8edd13ea69651b4eea5f1b72ad1043f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page