Skip to main content

didactic-fastapi

PyPI Python License CI Docs

didactic-fastapi adapts dx.Model classes for FastAPI request validation, response validation, and OpenAPI generation. It adds the didactic.fastapi module and uses didactic-pydantic at the framework boundary.

Install

pip install didactic-fastapi

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

Use a Didactic response model

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


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


app = FastAPI()
register_validation_handler(app)


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

as_response(User) returns a cached pydantic.BaseModel subclass that mirrors User. FastAPI uses that class for validation and OpenAPI generation.

Adapter behavior

Function Behavior
as_response(model) returns the generated Pydantic class for a response model
as_request(model) returns the same adapter under a request-oriented name
register_validation_handler(app) converts dx.ValidationError raised in a route into a FastAPI-style 422 response

Models with dx.indexed_by fields retain their cross-field validation. Their known index cases also appear as conditional constraints in the generated OpenAPI schema.

Documentation

See the FastAPI guide for request models, response models, error handling, and integration limits.

License

Released under the MIT License.

Metadata

Release files for didactic-fastapi 0.17.5

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.17.5
File Size Uploaded
didactic_fastapi-0.17.5.tar.gz 3.4 kB Details

Built distribution (wheel)

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

Total release size: 7.7 kB

Release files / didactic_fastapi-0.17.5.tar.gz

Download URL didactic_fastapi-0.17.5.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1a949b890f1af17f252afa7c57a1bc0d56cddad248cd9aa2d761063492049706
BLAKE2b-256 checksum
How to use checksums
13419c2c9325e419cf181a87d232cd0c052a3da461659ad526db663f5a9e0641
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 Oct 9, 2026.

Transparency log

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

Download URL didactic_fastapi-0.17.5-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ff4e9ea5cdfd1a8bf4c9ab120ad0808085f6050e297f81dc7988d31aa420768
BLAKE2b-256 checksum
How to use checksums
1b397297ff8cc11093e2cacb1b733d25a27d9ac3caee61ca9194a1f1c45003c2
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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.18.0

2 release files

0.17.6

2 release files

This release

0.17.5 This release

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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