How to change automatic documentation generation schema name for Generic Pydantic datatypes? #11129
Unanswered
not-sekiun
asked this question in
Questions
Replies: 1 comment
-
Another part of this same issue is that when you expand each generic model schema, the schema reference to the generic var doesn't seem to propogate properly (the generic var isn't named) The work around I am looking to use for now is pinning the openAPI schema version which produces the correct UI in Swagger (the former picture) though it is outdated It is unclear to me if this is an issue with Swagger/OpenAPI or FastAPI needs to update its schema generation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Running the above example code leads to the following generation of schema names at /openapi.json. Only the relevant fields are present, everything else is omitted.
As you can see the generation of schema names for the GenericModel type takes the form of GenericModel__datatype__. I do not like this formatting, especially when it shows up in the swagger UI or redocs pages. I know that I can manually edit the openapi.json file and replace the names by retrieving its dictionary from app() but this can be tedious and ugly especially as the app grows lager, is there a better way to specify the automatic name generation format?
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.104.1
Pydantic Version
2.5.3
Python Version
Python 3.12.0
Additional Context
Schemas look like this on swagger UI
Beta Was this translation helpful? Give feedback.
All reactions