Skip to content

Commit d579025

Browse files
committed
Check if property is optional in union property template
1 parent deb2d0a commit d579025

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

openapi_python_client/templates/property_templates/union_property.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ def _parse_{{ property.python_name }}(data: Dict[str, Any]) -> {{ property.get_t
1818
{% endif %}
1919
{% endfor %}
2020

21+
{% if not property.nullable %}
2122
{{ property.python_name }} = _parse_{{ property.python_name }}({{ source }})
23+
{% else %}
24+
{{ property.python_name }} = None
25+
if {{ source }} is not None:
26+
{{ property.python_name }} = _parse_{{ property.python_name }}({{ source }})
27+
{% endif %}
28+
2229
{% endmacro %}
2330

2431
{% macro transform(property, source, destination) %}

0 commit comments

Comments
 (0)