Skip to content

Fix indentation in unions with refs #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def httpx_request(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Response[Union[None, HTTPValidationError]]:

Expand Down Expand Up @@ -75,6 +76,16 @@ def httpx_request(
else:
json_union_prop = union_prop

json_union_prop_with_ref: Union[Unset, float, AnEnum]
if isinstance(union_prop_with_ref, Unset):
json_union_prop_with_ref = UNSET
elif isinstance(union_prop_with_ref, float):
json_union_prop_with_ref = union_prop_with_ref
else:
json_union_prop_with_ref = UNSET
if not isinstance(union_prop_with_ref, Unset):
json_union_prop_with_ref = union_prop_with_ref

json_enum_prop: Union[Unset, AnEnum] = UNSET
if not isinstance(enum_prop, Unset):
json_enum_prop = enum_prop
Expand All @@ -96,6 +107,8 @@ def httpx_request(
params["list_prop"] = json_list_prop
if union_prop is not UNSET:
params["union_prop"] = json_union_prop
if union_prop_with_ref is not UNSET:
params["union_prop_with_ref"] = json_union_prop_with_ref
if enum_prop is not UNSET:
params["enum_prop"] = json_enum_prop

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def _get_kwargs(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Dict[str, Any]:
url = "{}/tests/defaults".format(client.base_url)
Expand Down Expand Up @@ -51,6 +52,16 @@ def _get_kwargs(
else:
json_union_prop = union_prop

json_union_prop_with_ref: Union[Unset, float, AnEnum]
if isinstance(union_prop_with_ref, Unset):
json_union_prop_with_ref = UNSET
elif isinstance(union_prop_with_ref, float):
json_union_prop_with_ref = union_prop_with_ref
else:
json_union_prop_with_ref = UNSET
if not isinstance(union_prop_with_ref, Unset):
json_union_prop_with_ref = union_prop_with_ref

json_enum_prop: Union[Unset, AnEnum] = UNSET
if not isinstance(enum_prop, Unset):
json_enum_prop = enum_prop
Expand All @@ -72,6 +83,8 @@ def _get_kwargs(
params["list_prop"] = json_list_prop
if union_prop is not UNSET:
params["union_prop"] = json_union_prop
if union_prop_with_ref is not UNSET:
params["union_prop_with_ref"] = json_union_prop_with_ref
if enum_prop is not UNSET:
params["enum_prop"] = json_enum_prop

Expand Down Expand Up @@ -116,6 +129,7 @@ def sync_detailed(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Response[Union[None, HTTPValidationError]]:
kwargs = _get_kwargs(
Expand All @@ -128,6 +142,7 @@ def sync_detailed(
boolean_prop=boolean_prop,
list_prop=list_prop,
union_prop=union_prop,
union_prop_with_ref=union_prop_with_ref,
enum_prop=enum_prop,
)

Expand All @@ -149,6 +164,7 @@ def sync(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Optional[Union[None, HTTPValidationError]]:
""" """
Expand All @@ -163,6 +179,7 @@ def sync(
boolean_prop=boolean_prop,
list_prop=list_prop,
union_prop=union_prop,
union_prop_with_ref=union_prop_with_ref,
enum_prop=enum_prop,
).parsed

Expand All @@ -178,6 +195,7 @@ async def asyncio_detailed(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Response[Union[None, HTTPValidationError]]:
kwargs = _get_kwargs(
Expand All @@ -190,6 +208,7 @@ async def asyncio_detailed(
boolean_prop=boolean_prop,
list_prop=list_prop,
union_prop=union_prop,
union_prop_with_ref=union_prop_with_ref,
enum_prop=enum_prop,
)

Expand All @@ -210,6 +229,7 @@ async def asyncio(
boolean_prop: Union[Unset, bool] = False,
list_prop: Union[Unset, List[AnEnum]] = UNSET,
union_prop: Union[Unset, float, str] = "not a float",
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
enum_prop: Union[Unset, AnEnum] = UNSET,
) -> Optional[Union[None, HTTPValidationError]]:
""" """
Expand All @@ -225,6 +245,7 @@ async def asyncio(
boolean_prop=boolean_prop,
list_prop=list_prop,
union_prop=union_prop,
union_prop_with_ref=union_prop_with_ref,
enum_prop=enum_prop,
)
).parsed
17 changes: 17 additions & 0 deletions end_to_end_tests/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,23 @@
"name": "union_prop",
"in": "query"
},
{
"required": false,
"schema": {
"title": "Union Prop With Ref",
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/components/schemas/AnEnum"
}
],
"default": 0.6
},
"name": "union_prop_with_ref",
"in": "query"
},
{
"required": false,
"schema": {
Expand Down