Unnecessary Union for Same-Type Sequence Members #1205
Replies: 1 comment
-
|
This has been fixed - duplicate types in Union are now correctly deduplicated. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Here's an example FastAPI app:
Using
datamodel-codegenwith the--use-generic-container-typesoption on the response from the app's/openapi.jsonendpoint produces the following schema:Besides the Pydantic v1 problem of unenforced field constraints on a generic, I also noticed that the coordinates field has the repetitive generic type of
Sequence[Union[float, float]]; I believe that justSequence[float]would suffice. A possible improvement would be to detect when there is only one possible type and omit the Union.Details
fastapi 0.95.0
datamodel-codegen 0.17.1
Beta Was this translation helpful? Give feedback.
All reactions