Title: feat: add literal_enums setting to produce Literal[...] instead of enum classes. by emosenkis · Pull Request #1114 · openapi-generators/openapi-python-client · GitHub
Open Graph Title: feat: add literal_enums setting to produce Literal[...] instead of enum classes. by emosenkis · Pull Request #1114 · openapi-generators/openapi-python-client
X Title: feat: add literal_enums setting to produce Literal[...] instead of enum classes. by emosenkis · Pull Request #1114 · openapi-generators/openapi-python-client
Description: While attempting to generate a client for https://api.railz.ai/swagger/v2, I ran into duplicate enum values. I tried using the fixes from #725 and #1095 but neither was sufficient because while some duplicates result from case insensitivity, others result from characters (e.g. +) that are stripped when generating the Python name for the value. Allowing enums to be implemented as Literals provides a good alternative that should result in more readable code when an API defines enums that really are a collection of possible values not amenable to representation as a Python enum. This solution works for me and if you're amenable to the idea, I can add tests, etc. to get it ready for merging. Down the line, I can imagine allowing more configuration options, such as using literal enums only for int enums, only for enums with duplicate values, or only for enums that match a regex but I don't know if you're interested in allowing that sort of granular configuration of generated types.
Open Graph Description: While attempting to generate a client for https://api.railz.ai/swagger/v2, I ran into duplicate enum values. I tried using the fixes from #725 and #1095 but neither was sufficient because while som...
X Description: While attempting to generate a client for https://api.railz.ai/swagger/v2, I ran into duplicate enum values. I tried using the fixes from #725 and #1095 but neither was sufficient because while som...
Opengraph URL: https://github.com/openapi-generators/openapi-python-client/pull/1114
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:d12a49b6-83ad-41ae-e5c8-3230214b8c27 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 994C:344520:16275A:1E772C:69810902 |
| html-safe-nonce | ac6594fb0bd835c79bae90869b780d55c14c16c75b7a0c063b849f6490281b11 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTRDOjM0NDUyMDoxNjI3NUE6MUU3NzJDOjY5ODEwOTAyIiwidmlzaXRvcl9pZCI6IjgzNjMwOTQyMjA5OTQ1Nzg2OTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3a1bf78bb7dd36fd8875d63949d014166df2ac88a3034eac9b8d8ca8faa40ebc |
| hovercard-subject-tag | pull_request:2050041102 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/openapi-generators/openapi-python-client/pull/1114/checks |
| twitter:image | https://avatars.githubusercontent.com/u/1794126?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1794126?s=400&v=4 |
| og:image:alt | While attempting to generate a client for https://api.railz.ai/swagger/v2, I ran into duplicate enum values. I tried using the fixes from #725 and #1095 but neither was sufficient because while som... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 39fe8101494cbb823c09b619b68c80cd4d05ab7279997038dbe06bb91608abe1 |
| turbo-cache-control | no-preview |
| go-import | github.com/openapi-generators/openapi-python-client git https://github.com/openapi-generators/openapi-python-client.git |
| octolytics-dimension-user_id | 84925606 |
| octolytics-dimension-user_login | openapi-generators |
| octolytics-dimension-repository_id | 240776275 |
| octolytics-dimension-repository_nwo | openapi-generators/openapi-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 240776275 |
| octolytics-dimension-repository_network_root_nwo | openapi-generators/openapi-python-client |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d5b34a4e4898b066c629879feb4b184bc471d6a7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width