Jump to solution
Verify

The Fix

pip install fastapi==0.128.4

Based on closed fastapi/fastapi issue #14247 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -207,11 +207,31 @@ def get_definitions( None if separate_input_output_schemas else "validation" ) - flat_models = get_flat_models_from_fields(fields, known_models=set()) - flat_model_fields = [ - ModelField(field_info=FieldInfo(annotation=model), name=model.__name__)
repro.py
from enum import StrEnum from fastapi import FastAPI from pydantic import BaseModel, Field class MessageEventType(StrEnum): alpha = "alpha" beta = "beta" class MessageEvent(BaseModel): event_type: MessageEventType = Field(default=MessageEventType.alpha) output: str class MessageOutput(BaseModel): body: str = "" events: list[MessageEvent] class Message(BaseModel): id: str input: str output: MessageOutput app = FastAPI(title="Minimal FastAPI App", version="1.0.0") @app.post("/messages", response_model=Message) async def create_message(input_message: str) -> Message: return Message( input=input_message, output=MessageOutput(body=f"Processed: {input_message}"), ) if __name__ == "__main__": openapi_spec = app.openapi() for c in list(openapi_spec.get("components", {}).get("schemas", {}).keys()): print(c)
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install fastapi==0.128.4\nWhen NOT to use: Do not apply this fix if you rely on the previous schema naming convention for compatibility.\n\n

Why This Fix Works in Production

  • Trigger: Component name regression in OpenAPI spec for v0.119.0
  • Mechanism: Fixes the separation of schemas with nested models that was introduced in FastAPI version 0.119.0, addressing the issue where schema names were incorrectly suffixed.
  • Why the fix works: Fixes the separation of schemas with nested models that was introduced in FastAPI version 0.119.0, addressing the issue where schema names were incorrectly suffixed. (first fixed release: 0.128.4).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.13.1 in real deployments (not just unit tests).
  • Production symptom (often without a traceback): Component name regression in OpenAPI spec for v0.119.0

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“It should be fixed in https://github.com/fastapi/fastapi/pull/14246, just relased in FastAPI 0.120.2. :tada:”
@tiangolo · 2025-10-29 · confirmation · source

Failure Signature (Search String)

  • Component name regression in OpenAPI spec for v0.119.0
  • openapi_spec = app.openapi()
Copy-friendly signature
signature.txt
Failure Signature ----------------- Component name regression in OpenAPI spec for v0.119.0 openapi_spec = app.openapi()

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Component name regression in OpenAPI spec for v0.119.0 openapi_spec = app.openapi()

Minimal Reproduction

repro.py
from enum import StrEnum from fastapi import FastAPI from pydantic import BaseModel, Field class MessageEventType(StrEnum): alpha = "alpha" beta = "beta" class MessageEvent(BaseModel): event_type: MessageEventType = Field(default=MessageEventType.alpha) output: str class MessageOutput(BaseModel): body: str = "" events: list[MessageEvent] class Message(BaseModel): id: str input: str output: MessageOutput app = FastAPI(title="Minimal FastAPI App", version="1.0.0") @app.post("/messages", response_model=Message) async def create_message(input_message: str) -> Message: return Message( input=input_message, output=MessageOutput(body=f"Processed: {input_message}"), ) if __name__ == "__main__": openapi_spec = app.openapi() for c in list(openapi_spec.get("components", {}).get("schemas", {}).keys()): print(c)

Environment

  • Python: 3.13.1

What Broke

Users experienced unexpected schema name changes in OpenAPI spec, leading to confusion and potential integration issues.

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install fastapi==0.128.4

When NOT to use: Do not apply this fix if you rely on the previous schema naming convention for compatibility.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/fastapi/fastapi/pull/14246

First fixed release: 0.128.4

Last verified: 2026-02-08. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not apply this fix if you rely on the previous schema naming convention for compatibility.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
0.128.4 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.