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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

didactic_fastapi-0.10.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

didactic_fastapi-0.10.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file didactic_fastapi-0.10.0.tar.gz.

File metadata

  • Download URL: didactic_fastapi-0.10.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for didactic_fastapi-0.10.0.tar.gz
Algorithm Hash digest
SHA256 c0423264979b9248040f83362295ec2c2b6a3568972023df2c590f87a7e8755f
MD5 2511d0d952dfecce971f3ddf0507a519
BLAKE2b-256 a9d4aef0ec771511ce1811696ad2f2177009ed23dd6c91618fb8b4e8c47a8d0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for didactic_fastapi-0.10.0.tar.gz:

Publisher: release.yml on panproto/didactic

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

File details

Details for the file didactic_fastapi-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for didactic_fastapi-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b7626a4f3018ef7bbe204ec734b7920e026e7c88375f261eee2f1693e310b4f
MD5 e4923ac80f0257200449feeecd5f729d
BLAKE2b-256 ccabf770935893fe729d977eee3902e02ce1fe9c97900eac3a8355bf5a69900d

See more details on using hashes here.

Provenance

The following attestation bundles were made for didactic_fastapi-0.10.0-py3-none-any.whl:

Publisher: release.yml on panproto/didactic

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

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

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