You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I want to create an API endpoint that returns nested JSON with recursive models using Pydantic.
Calling /menu returns JSON with nested items.
The OpenAPI docs currently don’t reflect the recursion properly in Swagger UI.
I am using FastAPI 0.121.3, Pydantic 2.11.1, Python 3.11.
How can I make the OpenAPI schema fully support recursive models and ensure Swagger UI displays the nested structure correctly?
Operating System
Windows
Operating System Details
No response
FastAPI Version
FastAPI Version: 0.121.3
Pydantic Version
Pydantic Version: 2.11.1
Python Version
Python Version: 3.11
Additional Context
I tried update_forward_refs() but Pydantic v2 recommends model_rebuild().
Would like an example that works with OpenAPI docs out of the box.
Beta Was this translation helpful? Give feedback.
All reactions