diff --git a/openapi_python_client/parser/properties/enum_property.py b/openapi_python_client/parser/properties/enum_property.py index 0e095e455..fca4fc881 100644 --- a/openapi_python_client/parser/properties/enum_property.py +++ b/openapi_python_client/parser/properties/enum_property.py @@ -52,7 +52,7 @@ def values_from_list(values: List[ValueType]) -> Dict[str, ValueType]: else: output[f"VALUE_{value}"] = value continue - if value[0].isalpha(): + if value and value[0].isalpha(): key = value.upper() else: key = f"VALUE_{i}" diff --git a/tests/test_parser/test_properties/test_init.py b/tests/test_parser/test_properties/test_init.py index 03515ea63..024a6e15e 100644 --- a/tests/test_parser/test_properties/test_init.py +++ b/tests/test_parser/test_properties/test_init.py @@ -516,7 +516,7 @@ def test_get_imports(self, mocker): def test_values_from_list(self): from openapi_python_client.parser.properties import EnumProperty - data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces"] + data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces", ""] result = EnumProperty.values_from_list(data) @@ -528,6 +528,7 @@ def test_values_from_list(self): "VALUE_4": 4, "VALUE_NEGATIVE_3": -3, "A_THING_WITH_SPACES": "a Thing WIth spaces", + "VALUE_7": "", } def test_values_from_list_duplicate(self):