Skip to content

Commit c92cb71

Browse files
committed
Support empty strings in enums
1 parent 72cb706 commit c92cb71

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

openapi_python_client/parser/properties/enum_property.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def values_from_list(values: List[ValueType]) -> Dict[str, ValueType]:
5252
else:
5353
output[f"VALUE_{value}"] = value
5454
continue
55-
if value[0].isalpha():
55+
if value and value[0].isalpha():
5656
key = value.upper()
5757
else:
5858
key = f"VALUE_{i}"

tests/test_parser/test_properties/test_init.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def test_get_imports(self, mocker):
516516
def test_values_from_list(self):
517517
from openapi_python_client.parser.properties import EnumProperty
518518

519-
data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces"]
519+
data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces", ""]
520520

521521
result = EnumProperty.values_from_list(data)
522522

@@ -528,6 +528,7 @@ def test_values_from_list(self):
528528
"VALUE_4": 4,
529529
"VALUE_NEGATIVE_3": -3,
530530
"A_THING_WITH_SPACES": "a Thing WIth spaces",
531+
"VALUE_7": "",
531532
}
532533

533534
def test_values_from_list_duplicate(self):

0 commit comments

Comments
 (0)