Skip to main content

didactic-fastapi

FastAPI integration for dx.Model types.

PyPI Python License CI Docs

Contributes didactic.fastapi to the namespace package.

Install

pip install didactic-fastapi

The package depends on didactic, didactic-pydantic, and fastapi>=0.115.

Quickstart

import didactic.api as dx
from fastapi import FastAPI
from didactic.fastapi import as_response, register_validation_handler


class User(dx.Model):
    id: str
    email: str


app = FastAPI()
register_validation_handler(app)


@app.get("/users/{uid}", response_model=as_response(User))
def get_user(uid: str) -> User:
    return User(id=uid, email="ada@example.org")

as_response(model) returns a pydantic.BaseModel subclass mirroring the input dx.Model. FastAPI uses the result for response validation and OpenAPI generation. The conversion is cached per input class.

as_request(model) is a synonym; use whichever name reads naturally in your route signatures.

register_validation_handler(app) installs an exception handler so that dx.ValidationError raised inside a route surfaces as a 422 response shaped like FastAPI's own validation errors.

Documentation

See Guides > FastAPI for the full integration guide and caveats.

License

Released under the MIT License.

Metadata

Release files for didactic-fastapi 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for didactic-fastapi 0.12.0
File Size Uploaded
didactic_fastapi-0.12.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for didactic-fastapi 0.12.0
File Interpreter ABI Platform
didactic_fastapi-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / didactic_fastapi-0.12.0.tar.gz

Download URL didactic_fastapi-0.12.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1f67a4d1311209d1032a8e121b63c67b5dee8baeae68e2554b0bc5436a4679f7
BLAKE2b-256 checksum
How to use checksums
8134aac63792881e76d9c3aa77bc6bc00b00ff9522e2cefba6993531d0b22bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / didactic_fastapi-0.12.0-py3-none-any.whl

Download URL didactic_fastapi-0.12.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d5c231d3afb84a8e96e10edab71e5eae6dabea3364c25643f29d1be4f8f5c6f
BLAKE2b-256 checksum
How to use checksums
82ea176c9e6c3cec6162baf8146d1b6f3f80d5a6fa5ffca86f3177b80978e547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page