Skip to content

Commit 25f758c

Browse files
committed
Handle when _parse<property> is given UNSET
1 parent 7223731 commit 25f758c

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

end_to_end_tests/golden-record/my_test_api_client/models/a_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def from_dict(d: Dict[str, Any]) -> "AModel":
7575
an_enum_value = AnEnum(d["an_enum_value"])
7676

7777
def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.date]:
78+
data = None if isinstance(data, Unset) else data
7879
a_camel_date_time: Union[datetime.datetime, datetime.date]
7980
try:
8081
a_camel_date_time = isoparse(data)

end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def to_dict(self) -> Dict[str, Any]:
3636
@staticmethod
3737
def from_dict(d: Dict[str, Any]) -> "ModelWithUnionProperty":
3838
def _parse_a_property(data: Any) -> Union[Unset, AnEnum, AnIntEnum]:
39+
data = None if isinstance(data, Unset) else data
3940
a_property: Union[Unset, AnEnum, AnIntEnum]
4041
try:
4142
a_property = UNSET

openapi_python_client/templates/property_templates/union_property.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% macro construct(property, source, initial_value=None) %}
22
def _parse_{{ property.python_name }}(data: Any) -> {{ property.get_type_string() }}:
3+
data = None if isinstance(data, Unset) else data
34
{{ property.python_name }}: {{ property.get_type_string() }}
45
{% for inner_property in property.inner_properties %}
56
{% if inner_property.template and not loop.last %}

0 commit comments

Comments
 (0)