Skip to main content

Class-based views for the FastAPI

Project description

logo

Downloads Downloads codecov Hits-of-Code Tests Python versions PyPI version Checked with mypy Ruff

A bit of dummy patching for FastAPI, class-based handlers. So far without self support.

Install it:

$ pip install cbfa

And use:

from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
from cbfa import ClassBased


app = FastAPI()
wrapper = ClassBased(app)

class Item(BaseModel):
    name: str
    price: float
    is_offer: Optional[bool] = None

@wrapper('/item')
class Item:
    def get(item_id: int, q: Optional[str] = None):
        return {"item_id": item_id, "q": q}

    def post(item_id: int, item: Item):
        return {"item_name": item.name, "item_id": item_id}

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

cbfa-0.0.6.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

cbfa-0.0.6-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cbfa-0.0.6.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for cbfa-0.0.6.tar.gz
Algorithm Hash digest
SHA256 8e83830c5c4643e89abff7c016208350a73d445a656292c7ff68b207e19e0d03
MD5 f03996f745ca8bce06662a95b93971c6
BLAKE2b-256 8a6052a1aeb44190e83cfcb5fe39a01ca2c26a2345cf1fcdbb026c570b791bf6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbfa-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for cbfa-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 57acc96ffbc305eae3b002792c6890a7c4938ddeefab7ebceee3a0c125cbcc50
MD5 5a8bcb6872bfd0312d1ae70b533eee78
BLAKE2b-256 deea9dc9dd664bf7a1d1ab5da950cc03011425485bf8cb7dde63b79415d448a1

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