Adding the issue here for completeness, although most of the conversation is in the GitHub Discussion.
Discussed in #14177
Originally posted by walsha2 October 12, 2025
First Check
Commit to Help
Example Code
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)
Description
Issue Summary
Take the minimal example provided above, run with fastapi==0.118.3 and it will produce:
HTTPValidationError
Message
MessageEvent
MessageEventType
MessageOutput
ValidationError
Now run the same code with fastapi==0.119.0 and it will produce:
HTTPValidationError
Message
MessageEvent
MessageEventType
MessageOutput-Input
MessageOutput-Output
ValidationError
Note how MessageOutput is now suffixed unnecessarily as: MessageOutput-Input and MessageOutput-Output. This seems unexpected considering the changes made between v0.118.3 and v0.119.0
Minor Tweak
One minor tweak to the example and this issue goes away. Remove the enum from MessageEvent:
class MessageEvent(BaseModel):
output: str
Run again and the issue is no longer there.
HTTPValidationError
Message
MessageEvent
MessageOutput
ValidationError
TLDR
Why does the presence of an enum value on MessageEvent create a bifurcated OpenAPI schema definition for MessageOutput and why does this issue only start happening in fastapi==0.119.0?
Operating System
macOS
Operating System Details
15.6.1 (24G90)
FastAPI Version
0.119.0
Pydantic Version
2.12.0
Python Version
Python 3.13.1
Additional Context
No response
Adding the issue here for completeness, although most of the conversation is in the GitHub Discussion.
Discussed in #14177
Originally posted by walsha2 October 12, 2025
First Check
Commit to Help
Example Code
Description
Issue Summary
Take the minimal example provided above, run with
fastapi==0.118.3and it will produce:Now run the same code with
fastapi==0.119.0and it will produce:Note how
MessageOutputis now suffixed unnecessarily as:MessageOutput-InputandMessageOutput-Output. This seems unexpected considering the changes made betweenv0.118.3andv0.119.0Minor Tweak
One minor tweak to the example and this issue goes away. Remove the enum from
MessageEvent:Run again and the issue is no longer there.
TLDR
Why does the presence of an enum value on
MessageEventcreate a bifurcated OpenAPI schema definition forMessageOutputand why does this issue only start happening infastapi==0.119.0?Operating System
macOS
Operating System Details
15.6.1 (24G90)
FastAPI Version
0.119.0
Pydantic Version
2.12.0
Python Version
Python 3.13.1
Additional Context
No response