turner-townsend / flask-pydantic-spec

An Flask OpenAPI library using Pydantic
Apache License 2.0
99 stars 19 forks source link

[FEAT] Support Enum names in Open API #67

Closed EricWebsmith closed 8 months ago

EricWebsmith commented 8 months ago

Describe the bug In our project, we need to export both enum name and values to the frontend using Open API. We find other Open API generators have already provide solutions to this. We hope flask-pydantic-spec can support that as well.

Reference: here

cgearing commented 8 months ago

Thanks for the comment! The actual spec of an item is generated by Pydantic (either V1 or V2) so if the OpenAPI document is missing data, it might be because Pydantic doesn't generate that.

Have you got an example of what's missing and if it's in Pydantic when getting the schema for a model with an Enum value?

EricWebsmith commented 8 months ago

Thanks, I changed the pydantic code and our problem is solved.

The function dealing with this is GenerateJsonSchema.literal_schema. I just changed this one.