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
Is your feature request related to a problem? Please describe.
Currently anything provided in a schema is assumed to be an object with properties. This means if an Enum is declared in schemas to be shared across endpoints (as is the case in the latest FastAPI/Pydantic), you get an empty dataclass as your enum instead of an actual Enum.
Describe the solution you'd like
Declaring an Enum in a schema should work exactly the same as declaring an Enum in-line for an endpoint. The output should be an Enum in the generated client.
Additional context
A simple way to see the problem is to regenerate the golden-master for end to end tests with the latest FastAPI/Pydantic.
The text was updated successfully, but these errors were encountered:
This is going to be a decent amount of work. Currently the components/schemas section of the OpenAPI document is parsed by Models.build which assumes that everything inside it will become a dataclass. Conversely, Enums are registered globally whenever an Enum property is created. This is a pretty icky way of doing things anyway.
Better, I think, will be to more properly have a "schemas" dictionary of name -> Property (which I think needs a new name?). Then Model should become a type of property like everything else, just one that will eventually be represented like a dataclass.
Processing "components/schemas" should register properties (probably just Enum/Model but I think any Schema is allowed here) in the dictionary. That dictionary should then be passed into EndpointCollection.from_data (the thing that parses "paths") so that any inline enums or objects can properly be registered into the same collection (functionally, not globally).
When that's done, we can loop back through and sort out the schemas/references that need to be generated into Enums/dataclasses.
Is your feature request related to a problem? Please describe.
Currently anything provided in a schema is assumed to be an object with properties. This means if an Enum is declared in schemas to be shared across endpoints (as is the case in the latest FastAPI/Pydantic), you get an empty dataclass as your enum instead of an actual Enum.
Describe the solution you'd like
Declaring an Enum in a schema should work exactly the same as declaring an Enum in-line for an endpoint. The output should be an Enum in the generated client.
Additional context
A simple way to see the problem is to regenerate the golden-master for end to end tests with the latest FastAPI/Pydantic.
The text was updated successfully, but these errors were encountered: