Skip to content

Commit c0431c7

Browse files
authored
Add a test for union properties with refs in API (#245)
1 parent d0c60f5 commit c0431c7

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def httpx_request(
4848
boolean_prop: Union[Unset, bool] = False,
4949
list_prop: Union[Unset, List[AnEnum]] = UNSET,
5050
union_prop: Union[Unset, float, str] = "not a float",
51+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
5152
enum_prop: Union[Unset, AnEnum] = UNSET,
5253
) -> Response[Union[None, HTTPValidationError]]:
5354

@@ -75,6 +76,16 @@ def httpx_request(
7576
else:
7677
json_union_prop = union_prop
7778

79+
json_union_prop_with_ref: Union[Unset, float, AnEnum]
80+
if isinstance(union_prop_with_ref, Unset):
81+
json_union_prop_with_ref = UNSET
82+
elif isinstance(union_prop_with_ref, float):
83+
json_union_prop_with_ref = union_prop_with_ref
84+
else:
85+
json_union_prop_with_ref = UNSET
86+
if not isinstance(union_prop_with_ref, Unset):
87+
json_union_prop_with_ref = union_prop_with_ref
88+
7889
json_enum_prop: Union[Unset, AnEnum] = UNSET
7990
if not isinstance(enum_prop, Unset):
8091
json_enum_prop = enum_prop
@@ -96,6 +107,8 @@ def httpx_request(
96107
params["list_prop"] = json_list_prop
97108
if union_prop is not UNSET:
98109
params["union_prop"] = json_union_prop
110+
if union_prop_with_ref is not UNSET:
111+
params["union_prop_with_ref"] = json_union_prop_with_ref
99112
if enum_prop is not UNSET:
100113
params["enum_prop"] = json_enum_prop
101114

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

+21
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def _get_kwargs(
2121
boolean_prop: Union[Unset, bool] = False,
2222
list_prop: Union[Unset, List[AnEnum]] = UNSET,
2323
union_prop: Union[Unset, float, str] = "not a float",
24+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
2425
enum_prop: Union[Unset, AnEnum] = UNSET,
2526
) -> Dict[str, Any]:
2627
url = "{}/tests/defaults".format(client.base_url)
@@ -51,6 +52,16 @@ def _get_kwargs(
5152
else:
5253
json_union_prop = union_prop
5354

55+
json_union_prop_with_ref: Union[Unset, float, AnEnum]
56+
if isinstance(union_prop_with_ref, Unset):
57+
json_union_prop_with_ref = UNSET
58+
elif isinstance(union_prop_with_ref, float):
59+
json_union_prop_with_ref = union_prop_with_ref
60+
else:
61+
json_union_prop_with_ref = UNSET
62+
if not isinstance(union_prop_with_ref, Unset):
63+
json_union_prop_with_ref = union_prop_with_ref
64+
5465
json_enum_prop: Union[Unset, AnEnum] = UNSET
5566
if not isinstance(enum_prop, Unset):
5667
json_enum_prop = enum_prop
@@ -72,6 +83,8 @@ def _get_kwargs(
7283
params["list_prop"] = json_list_prop
7384
if union_prop is not UNSET:
7485
params["union_prop"] = json_union_prop
86+
if union_prop_with_ref is not UNSET:
87+
params["union_prop_with_ref"] = json_union_prop_with_ref
7588
if enum_prop is not UNSET:
7689
params["enum_prop"] = json_enum_prop
7790

@@ -116,6 +129,7 @@ def sync_detailed(
116129
boolean_prop: Union[Unset, bool] = False,
117130
list_prop: Union[Unset, List[AnEnum]] = UNSET,
118131
union_prop: Union[Unset, float, str] = "not a float",
132+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
119133
enum_prop: Union[Unset, AnEnum] = UNSET,
120134
) -> Response[Union[None, HTTPValidationError]]:
121135
kwargs = _get_kwargs(
@@ -128,6 +142,7 @@ def sync_detailed(
128142
boolean_prop=boolean_prop,
129143
list_prop=list_prop,
130144
union_prop=union_prop,
145+
union_prop_with_ref=union_prop_with_ref,
131146
enum_prop=enum_prop,
132147
)
133148

@@ -149,6 +164,7 @@ def sync(
149164
boolean_prop: Union[Unset, bool] = False,
150165
list_prop: Union[Unset, List[AnEnum]] = UNSET,
151166
union_prop: Union[Unset, float, str] = "not a float",
167+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
152168
enum_prop: Union[Unset, AnEnum] = UNSET,
153169
) -> Optional[Union[None, HTTPValidationError]]:
154170
""" """
@@ -163,6 +179,7 @@ def sync(
163179
boolean_prop=boolean_prop,
164180
list_prop=list_prop,
165181
union_prop=union_prop,
182+
union_prop_with_ref=union_prop_with_ref,
166183
enum_prop=enum_prop,
167184
).parsed
168185

@@ -178,6 +195,7 @@ async def asyncio_detailed(
178195
boolean_prop: Union[Unset, bool] = False,
179196
list_prop: Union[Unset, List[AnEnum]] = UNSET,
180197
union_prop: Union[Unset, float, str] = "not a float",
198+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
181199
enum_prop: Union[Unset, AnEnum] = UNSET,
182200
) -> Response[Union[None, HTTPValidationError]]:
183201
kwargs = _get_kwargs(
@@ -190,6 +208,7 @@ async def asyncio_detailed(
190208
boolean_prop=boolean_prop,
191209
list_prop=list_prop,
192210
union_prop=union_prop,
211+
union_prop_with_ref=union_prop_with_ref,
193212
enum_prop=enum_prop,
194213
)
195214

@@ -210,6 +229,7 @@ async def asyncio(
210229
boolean_prop: Union[Unset, bool] = False,
211230
list_prop: Union[Unset, List[AnEnum]] = UNSET,
212231
union_prop: Union[Unset, float, str] = "not a float",
232+
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
213233
enum_prop: Union[Unset, AnEnum] = UNSET,
214234
) -> Optional[Union[None, HTTPValidationError]]:
215235
""" """
@@ -225,6 +245,7 @@ async def asyncio(
225245
boolean_prop=boolean_prop,
226246
list_prop=list_prop,
227247
union_prop=union_prop,
248+
union_prop_with_ref=union_prop_with_ref,
228249
enum_prop=enum_prop,
229250
)
230251
).parsed

end_to_end_tests/openapi.json

+17
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,23 @@
372372
"name": "union_prop",
373373
"in": "query"
374374
},
375+
{
376+
"required": false,
377+
"schema": {
378+
"title": "Union Prop With Ref",
379+
"anyOf": [
380+
{
381+
"type": "number"
382+
},
383+
{
384+
"$ref": "#/components/schemas/AnEnum"
385+
}
386+
],
387+
"default": 0.6
388+
},
389+
"name": "union_prop_with_ref",
390+
"in": "query"
391+
},
375392
{
376393
"required": false,
377394
"schema": {

0 commit comments

Comments
 (0)