Skip to main content

rn-forge-fastapi

Documentation · Changelog · Source · All pykit packages

FastAPI adapters over rn-forge-web.

rn-forge-web settles the wire — the problem body, the cursor codec, the ETag semantics, the idempotency reuse rule, the readiness aggregate, the 401/403 boundary. This package is the FastAPI-shaped plumbing that puts those decisions into an application: exception-handler registration, Depends factories, a router factory and an OpenAPI repair. It makes no wire decision of its own.

Module What it adapts
problem register_problem_handlers(app) — every error the app produces, including FastAPI's own 404/405/422, as application/problem+json
openapi FastApiApp.openapi() repairs the cached document — adds ProblemDetail and the problem responses it can actually produce, accuracy only; operation_id — the shared operationId convention
dependencies page_params, require_idempotency_key, require_if_match
health health_router(checks=...) — /healthz and /readyz
auth auth_router and SessionMiddleware — the /auth routes, login sessions and CSRF protection over rn-forge-auth; bearer_auth, basic_auth, current_principal, requires, requires_permission, PolicyGuard — Security dependencies; rate limiting; auth.redis — the Redis CSRF store and rate limiter (redis extra)
sse sse_response(events) — an EventSourceResponse that rejects forged frame fields, sends a retry frame first and ends a failed stream with one problem frame (sse extra)
app FastApiApp(config) — a FastAPI subclass with the standard adapters installed

Where it sits

rn-forge-fastapi depends on rn-forge-web, rn-forge-auth and FastAPI; it never imports rn_forge.django, rn_forge.cli or rn_forge.tooling; task lint proves it.

The import path

This package is rn_forge.fastapi; the framework is fastapi. The two do not collide: from fastapi import APIRouter always resolves to the framework, unless a process puts src/rn_forge/ itself on sys.path.

Installation

Require the packages by version range:

dependencies = [
  "rn-forge-fastapi>=0.4,<0.5",
  "rn-forge-web>=0.3,<0.4",
]

Application code imports rn_forge.web directly (wire models, pagination, problem types, the auth contract), and this package does not re-export it. Declare rn-forge-web as well, so the import is not an undeclared transitive dependency.

Extras: oidc (JWKS bearer auth and OIDC login, rn-forge-auth[oidc]), redis (the Redis stores and rn_forge.fastapi.auth.redis), transfer (rn-forge-data and python-multipart, for rn_forge.fastapi.transfer), sse (sse-starlette, for rn_forge.fastapi.sse) and testing (assertpy, httpx and pytest).

Minimum example

from rn_forge.fastapi import FastApiApp

app = FastApiApp(title="Orders")

The app serves /healthz and /readyz and renders every error as a problem body; the quickstart adds pagination and readiness checks.

What this package deliberately does not ship

  • Settings, infrastructure, or application policy. FastApiApp wires the standard adapters from an explicit AppConfig; applications still construct their settings, clients, authenticators, stores and product routes.
  • A dependency-injection container, a settings facade, any store. FastAPI's Depends is the DI framework; configuration arrives as function arguments; an AsyncIdempotencyStore is SQL- or Redis-backed and belongs to the application.
  • A tracing middleware. Tracing is W3C Trace Context through OpenTelemetry's own FastAPIInstrumentor, not a house middleware — FastApiApp calls it by default (AppConfig.tracing). The current trace id reaches a 500 the same way it reaches any other response: render_problem reads it from the active span, and ServerErrorMiddleware sits inside the instrumentation's span, not outside it.
  • A token verifier. The auth binding takes any rn_forge.auth.Authenticator; verifying a JWT against a JWKS is that authenticator's job. For OIDC that authenticator already exists — rn_forge.auth.oidc.OidcAuthenticator, via this package's oidc extra — and is shared with rn-forge-django so both stacks accept the same tokens. Nothing here wraps it; pass it to bearer_auth.

Dependencies

rn-forge-web — every module adapts one of its primitives.

rn-forge-commons — declared directly: problem uses its AppLogger.

rn-forge-auth — a base dependency: the auth package is built on its login flows, Principal, Requirement and authenticator contracts. Its OIDC adapter comes with this package's oidc extra, and its Redis stores with the redis extra, which also installs the client for auth.redis.

fastapi (>=0.141.1) — a hard dependency, not an extra. It is used as documented, not abstracted away — an application keeps APIRouter, Depends, Header and response_model exactly as FastAPI defines them. pydantic (2.13 resolved) and starlette arrive with it; the rn_forge.web.WireModel configuration uses validate_by_name/serialize_by_alias, which need pydantic ≥ 2.11.

Not wrapped: FastAPI's HTTPBearer/HTTPBasic are used with auto_error=False — kept for the securitySchemes entry they put in the schema, stripped of their own 401 body and non-RFC-6750 challenge.

OpenAPI across stacks

Wire behaviour and operationId are identical to the Django stack; the rest of the document text is not. Page[T] keeps pydantic's own name, Page_UserOut_.

An operation outside the six CRUD verbs is a custom method, spelled POST /orders/{orderId}:cancel and named ordersCancel (see rn-forge-web's api-conventions.md §9). Spelled as a plain path segment it still gets a mechanical name and wants an explicit operation_id=.

operationId must be unique across the document. drf-spectacular warns and appends a numeral on a collision; FastAPI does neither, so two routes ending in the same literal segment collide silently here.

Documentation

task docs:build builds the combined site and every package site. The wiring guide is the page an application is written from.

Metadata

Release files for rn-forge-fastapi 0.5.1

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

Source distribution (sdist)

Source distribution for rn-forge-fastapi 0.5.1
File Size Uploaded Provenance Actions
rn_forge_fastapi-0.5.1.tar.gz 52.0 kB With provenance Details for rn_forge_fastapi-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rn-forge-fastapi 0.5.1
File Interpreter ABI Platform Actions
rn_forge_fastapi-0.5.1-py3-none-any.whl Python 3 none any Details for rn_forge_fastapi-0.5.1-py3-none-any.whl

Total release size: 116.1 kB

Release files / rn_forge_fastapi-0.5.1.tar.gz

Download URL rn_forge_fastapi-0.5.1.tar.gz
Size 52.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f0d1cf9ea3b13fc8db812080dd9bcb5104dd8b120f0a0672967baba8d1153ae8
BLAKE2b-256 checksum
How to use checksums
2ad169cc7ec0d9fa4e48d0e63ce87b3c98e5ba32a938fdd7f9c5e3ef1b623c69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 Nov 19, 2026.

Transparency log

Release files / rn_forge_fastapi-0.5.1-py3-none-any.whl

Download URL rn_forge_fastapi-0.5.1-py3-none-any.whl
Size 64.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52aefcd47009c55e38c03cec645dd4b51325b063aa973e312a119a2e5acd7078
BLAKE2b-256 checksum
How to use checksums
072e9ce2fc10bb4b092a629a3c3765128b0e2f0ddc96350d76569653a21a27b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 Nov 19, 2026.

Transparency log

Security for rn-forge-fastapi 0.5.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rn_forge_fastapi-0.5.1.tar.gz

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 Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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