openapi-generators / openapi-python-client

Generate modern Python clients from OpenAPI
MIT License
1.19k stars 189 forks source link

Add literals alongside enums #1016

Open theorm opened 3 months ago

theorm commented 3 months ago

Generating literal types alongside string and int Enums. We really need it in our code so have this in our custom templates. I thought there are others who would like to have it in the default template.

dbanty commented 2 months ago

Are you using literals instead of enums? Is there a particular limitation of enums that makes that necessary? Trying to understand if this should be an option in config (to generate literals instead) or if it makes sense to completely replace enums with literals 🤔

theorm commented 2 months ago

We are using literals instead of enums in a public library with a lot of choice parameters where having enums would mean a lot of typing for the user and generally more noise in the code. There are still many developers out there who prefer to use enums instead of literals, so making it configurable would be a much better option!