Skip to content

Commit 48f894d

Browse files
Use uppercase enum keys.
In one of our examples, we have an enumeration for US state abbreviations, which includes Indiana. This results in an entry of the form: ```py in = "IN", ``` which fails to compile because `in` is a reserved word. The easiest fix I can imagine is to use upper case.
1 parent 8d1d695 commit 48f894d

File tree

1 file changed

+1
-1
lines changed
  • src/openapi_python_generator/language_converters/python/templates

1 file changed

+1
-1
lines changed

src/openapi_python_generator/language_converters/python/templates/enum.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ class {{ name }}(str, Enum):
44
{% for enumItem in enum %}
55

66
{% if enumItem is string %}
7-
{{ enumItem.lower() }} = '{{ enumItem }}'{% else %}
7+
{{ enumItem.upper() }} = '{{ enumItem }}'{% else %}
88
value_{{ enumItem }} = {{ enumItem }}{% endif %}
99
{% endfor %}

0 commit comments

Comments
 (0)