FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support empty strings in enums by ramnes · Pull Request #358 · openapi-generators/openapi-python-client · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_parser/test_properties/test_init.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):
Expand Down

Back | FazBrowse Home | New Git URL