Skip to main content

Class-based views for the FastAPI

Project description

logo

Downloads Downloads Coverage Status 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.8.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cbfa-0.0.8.tar.gz
Algorithm Hash digest
SHA256 84fc88fc07bde46ac9b9ada2677606354c1e629e4d41c7080191d3019dc6f2e4
MD5 8987eabffe45f709f1ae1ea98e6c1981
BLAKE2b-256 20953da4add7a29c06244a1b29c5e1b50bc0b9304d96dc32934b16fba35a1db3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbfa-0.0.8.tar.gz:

Publisher: release.yml on pomponchik/cbfa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

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

File hashes

Hashes for cbfa-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 92d3f18c72456b44f571cf873a5f90df8a8479f1c6a0b00401d562c984953c19
MD5 f3acfc1107216c3e3895ee5a3e7346ac
BLAKE2b-256 b75526c44046388b6ea6931952a4d516038af43a08f3a6d5ebf66fa42761ec01

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbfa-0.0.8-py3-none-any.whl:

Publisher: release.yml on pomponchik/cbfa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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