TL;DR Fix

1. What’s happening?

You upgraded FastAPI (often alongside Pydantic) and production breaks in one of these ways:

Impact: this can be an outage, a client-breaking contract change, or a correctness/security issue.

2. Why this breaks

This hub clusters upgrade regressions at the FastAPI ↔ Pydantic boundary (OpenAPI generation + request parsing).

FastAPI constructs OpenAPI by walking your route/dependency graph and asking Pydantic for schema pieces. With Pydantic v2, schema data often flows through TypeAdapter and core_schema. If FastAPI code paths don’t handle a new schema shape (computed fields, tagged unions, custom schemas, security dependencies), you can get missing metadata, schema drift, or crashes.

3. Am I affected?

If you match any row below, assume you’re affected until you verify.

Symptom Trigger Introduced First fixed release
Swagger UI “Authorize” missing / security schemes absent Top-level app dependencies include OpenIdConnect/OAuth2 (a SecurityBase) 0.120.3 (reported regression) 0.128.2 (PR 14266)
OAuth2 security schemes duplicated OAuth2 dependencies attached at router/route level Unknown 0.128.0 (PR 14459)
OpenAPI crashes on mixed computed-field routes Some response models use Pydantic @computed_field, others don’t Unknown 0.128.1 (PR 14453)
Computed fields missing when separate_input_output_schemas=False You set FastAPI(..., separate_input_output_schemas=False) Unknown 0.128.2 (PR 13207)
OpenAPI component names change unexpectedly Clients/codegen assume stable component names 0.119.0 (reported regression) 0.128.0 (PR 14246)
OpenAPI generation fails with arbitrary_types_allowed=True + custom schema Custom types + WithJsonSchema/TypeAdapter + arbitrary types Since 0.119.0 (reported) 0.128.1 (PR 14482)
Discriminated unions break in Annotated[..., Body(...)] Tagged unions + discriminator in request bodies Unknown 0.128.1 (PR 14512)
Custom validators in Annotated don’t run as expected Validators like AfterValidator inside Annotated Unknown 0.128.1 (PR 13442)
Form parsing regressions Parsing forms into models or mixed form/body inputs Unknown 0.128.0 (PR 13537)
allow_inf_nan=False not enforced Numeric query/body params rely on NaN/Inf rejection Unknown 0.128.1 (PR 11867)

4. How to fix

Recommended fix: upgrade to a release that includes the upstream fixes.

pip install -U "fastapi==0.128.2"

Show the diff

Representative upstream changes (semantic impact > line count):

A) SecurityBase dependencies included for OpenAPI security schemes (PR 14266):

@@ -248,6 +248,14 @@ def get_dependant(
    endpoint_signature = get_typed_signature(call)
    signature_params = endpoint_signature.parameters
+    if isinstance(call, SecurityBase):
+        use_scopes: List[str] = []
+        if isinstance(call, (OAuth2, OpenIdConnect)):

B) Computed fields handled explicitly during schema generation (PR 14453 / PR 13207):

+def _has_computed_fields(field: ModelField) -> bool:
+    computed_fields = field._type_adapter.core_schema.get("schema", {}).get(
+        "computed_fields", []

C) Form parsing: track body field aliases (PR 13537):

@@ -902,8 +902,9 @@ async def process_fn(
        if value is not None:
            values[field.alias] = value
+    field_aliases = {field.alias for field in body_fields}
     for key, value in received_body.items():
-        if key not in values:

5. How to verify the fix

Expected: openapi_ok True.

python3 -c "import fastapi; print('FastAPI', fastapi.__version__)"
curl -fsS http://YOUR_APP_HOST:8000/openapi.json >/tmp/openapi.json
python3 -c "import json; s=json.load(open('/tmp/openapi.json')); print('openapi_ok', bool(s.get('components',{}).get('schemas')))"

6. When NOT to use this fix

7. Prevention

Related failure patterns:

SEO + schema output

Alternative question-style titles (for FAQ schema):

Meta description (155 chars): FastAPI upgrade broke OpenAPI or validation? Runbook to identify affected versions, apply safe fixes, and verify in prod.

Internal link suggestions (existing pages): /hub/pydantic/, /hub/requests/, /hub/urllib3/, /hub/celery/, /best-practices/fastapi/

FAQPage JSON-LD is embedded in the page header.

Trust signals

Source links

Evidence: related fixes in this hub

Curated list (cluster evidence). If you’re debugging a specific symptom, start with the linked fix page.