Skip to content

Commit a045cf3

Browse files
Fix remaining tests
1 parent c11de57 commit a045cf3

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/defaults_tests_defaults_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ def httpx_request(
9292
if isinstance(union_prop, Unset):
9393
json_union_prop = UNSET
9494
elif union_prop is None:
95-
json_union_prop: Union[Unset, None, float, str] = None
95+
json_union_prop = None
9696
else:
9797
json_union_prop = union_prop
9898

9999
json_union_prop_with_ref: Union[Unset, None, float, AnEnum]
100100
if isinstance(union_prop_with_ref, Unset):
101101
json_union_prop_with_ref = UNSET
102102
elif union_prop_with_ref is None:
103-
json_union_prop_with_ref: Union[Unset, None, float, AnEnum] = None
103+
json_union_prop_with_ref = None
104104
elif isinstance(union_prop_with_ref, AnEnum):
105105
json_union_prop_with_ref = UNSET
106106
if not isinstance(union_prop_with_ref, Unset):

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/get_user_list.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def httpx_request(
5353

5454
json_an_enum_value.append(an_enum_value_item)
5555

56-
if some_date is None:
57-
json_some_date: Union[datetime.date, datetime.datetime] = None
5856
if isinstance(some_date, datetime.date):
5957
json_some_date = some_date.isoformat()
6058
else:

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def _get_kwargs(
6868
if isinstance(union_prop, Unset):
6969
json_union_prop = UNSET
7070
elif union_prop is None:
71-
json_union_prop: Union[Unset, None, float, str] = None
71+
json_union_prop = None
7272
else:
7373
json_union_prop = union_prop
7474

7575
json_union_prop_with_ref: Union[Unset, None, float, AnEnum]
7676
if isinstance(union_prop_with_ref, Unset):
7777
json_union_prop_with_ref = UNSET
7878
elif union_prop_with_ref is None:
79-
json_union_prop_with_ref: Union[Unset, None, float, AnEnum] = None
79+
json_union_prop_with_ref = None
8080
elif isinstance(union_prop_with_ref, AnEnum):
8181
json_union_prop_with_ref = UNSET
8282
if not isinstance(union_prop_with_ref, Unset):

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def _get_kwargs(
2626

2727
json_an_enum_value.append(an_enum_value_item)
2828

29-
if some_date is None:
30-
json_some_date: Union[datetime.date, datetime.datetime] = None
3129
if isinstance(some_date, datetime.date):
3230
json_some_date = some_date.isoformat()
3331
else:

openapi_python_client/templates/property_templates/union_property.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ def _parse_{{ property.python_name }}(data: Any) -> {{ property.get_type_string(
2525
{% endmacro %}
2626

2727
{% macro transform(property, source, destination, declare_type=True, query_parameter=False) %}
28-
{% if not property.required %}
28+
{% if not property.required or property.nullable %}
2929
{{ destination }}{% if declare_type %}: {{ property.get_type_string(query_parameter=query_parameter) }}{% endif %}
3030

3131
if isinstance({{ source }}, Unset):
3232
{{ destination }} = UNSET
3333
{% endif %}
34-
{% if property.nullable or query_parameter %}
34+
{% if property.nullable or (query_parameter and not property.required) %}
3535
{% if property.required %}
3636
if {{ source }} is None:
3737
{% else %}{# There's an if UNSET statement before this #}
3838
elif {{ source }} is None:
3939
{% endif %}
40-
{{ destination }}{% if declare_type %}: {{ property.get_type_string(query_parameter=query_parameter) }}{% endif %} = None
40+
{{ destination }} = None
4141
{% endif %}
4242
{% for inner_property in property.inner_properties_with_template() %}
4343
{% if loop.first and property.required and not property.nullable %}{# No if UNSET or if None statement before this #}

0 commit comments

Comments
 (0)