Skip to content

Commit 800bf60

Browse files
authored
fix: null in openapi enums breaks client generation BNCH-32257 (#95)
1 parent 6c40881 commit 800bf60

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

openapi_python_client/parser/properties/enum_property.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def values_from_list(values: List[ValueType]) -> Dict[str, ValueType]:
5050
else:
5151
output[f"VALUE_{value}"] = value
5252
continue
53-
if value[0].isalpha():
53+
if value is None:
54+
continue
55+
if value and value[0].isalpha():
5456
key = value.upper()
5557
else:
5658
key = f"VALUE_{i}"

tests/test_parser/test_properties/test_init.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def test_get_imports(self, mocker):
456456
def test_values_from_list(self):
457457
from openapi_python_client.parser.properties import EnumProperty
458458

459-
data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces"]
459+
data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces", "", None]
460460

461461
result = EnumProperty.values_from_list(data)
462462

@@ -468,6 +468,7 @@ def test_values_from_list(self):
468468
"VALUE_4": 4,
469469
"VALUE_NEGATIVE_3": -3,
470470
"A_THING_WITH_SPACES": "a Thing WIth spaces",
471+
"VALUE_7": "",
471472
}
472473

473474
def test_values_from_list_duplicate(self):

0 commit comments

Comments
 (0)