Skip to main content

API versioning, dispatch, docs, and actuator for FastAPI

Project description

csrd-versioning

API versioning, dispatch, docs, and actuator for FastAPI.

Package: csrd.versioning · Import: from csrd.versioning import compose_versioned_apps, configure_versioned_api

What's included

  • Version dispatch — raw ASGI middleware for version-aware routing (streaming/SSE safe)
  • Swagger UI — custom docs with version picker, dark mode, SRI hashes, plugin system
  • Actuator — Spring Boot-style management endpoints (health, info, env)
  • Exception handlers — structured APIErrorResponse JSON for HTTP and validation errors
  • Dependency wiring — auto path-param injection, bearer guard opt-out

Installation

uv pip install "csrd-versioning @ git+ssh://git@github.com/csrd-api/fastapi-common.git#subdirectory=packages/versioning"

Quick start

from enum import Enum
from fastapi import FastAPI
from csrd.versioning import compose_versioned_apps, VersionedApiConfig, VersionedAppComposeConfig

class Versions(Enum):
    Unversioned = "Unversioned"
    V1 = "2025-06-20"

unv = FastAPI()
v1 = FastAPI()

app = compose_versioned_apps(
    {Versions.Unversioned: unv, Versions.V1: v1},
    config=VersionedAppComposeConfig(
        api=VersionedApiConfig(prefix="api"),
    ),
)

Security notes

  • /actuator/env: The ShowValues.ALWAYS setting exposes environment variable values. Use ShowValues.NEVER (default) in production to redact sensitive data.
  • CORS: Add CORSMiddleware before calling configure_versioned_api. The version dispatch middleware must be the outermost middleware. Example:
app = FastAPI()
app.add_middleware(CORSMiddleware, allow_origins=["https://app.example.com"], ...)
configure_versioned_api(app, version_mapping, ...)

Dependencies

  • csrd-models, csrd-context (Tier 1 packages — csrd-versioning is Tier 3)
  • For JWT auth, use csrd-auth alongside this package

Project details


Release history Release notifications | RSS feed

This version

0.5.1

Download files

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

Source Distribution

csrd_versioning-0.5.1.tar.gz (74.6 kB view details)

Uploaded Source

Built Distribution

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

csrd_versioning-0.5.1-py3-none-any.whl (84.9 kB view details)

Uploaded Python 3

File details

Details for the file csrd_versioning-0.5.1.tar.gz.

File metadata

  • Download URL: csrd_versioning-0.5.1.tar.gz
  • Upload date:
  • Size: 74.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for csrd_versioning-0.5.1.tar.gz
Algorithm Hash digest
SHA256 36eef0913f35093b52abd636337f5d0257d6786a05bfd65dce7348c31aa6b67f
MD5 79822de0114667ee1448a47783ea7b39
BLAKE2b-256 3a29037e2f4cd91bcb43068a3d153c7131258bd14ae6349d1daba98a5893f7ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for csrd_versioning-0.5.1.tar.gz:

Publisher: release.yml on csrd-api/fastapi-common

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

File details

Details for the file csrd_versioning-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for csrd_versioning-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2344fcc8448a99f25b25e0b899d9de4780b18dad0658accb0bbd40df00b6bd2f
MD5 7ed7f9db0f05fb0903dbe2fb351683d6
BLAKE2b-256 492b0f5a1d7d693ddfaf5f3a1e9f8b6044e1a5bfa594de119269f8a79261738f

See more details on using hashes here.

Provenance

The following attestation bundles were made for csrd_versioning-0.5.1-py3-none-any.whl:

Publisher: release.yml on csrd-api/fastapi-common

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