Skip to content

Commit 9b301b2

Browse files
author
Constantinos Symeonides
committed
refactor: Avoid breaking change
1 parent 57c42a8 commit 9b301b2

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def _get_kwargs(
1212
*,
1313
client: Client,
14-
multipart_body: BodyUploadFileTestsUploadPost,
14+
multipart_data: BodyUploadFileTestsUploadPost,
1515
keep_alive: Union[Unset, bool] = UNSET,
1616
) -> Dict[str, Any]:
1717
url = "{}/tests/upload".format(client.base_url)
@@ -22,14 +22,14 @@ def _get_kwargs(
2222
if keep_alive is not UNSET:
2323
headers["keep-alive"] = keep_alive
2424

25-
multipart_multipart_body = multipart_body.to_multipart()
25+
multipart_multipart_data = multipart_data.to_multipart()
2626

2727
return {
2828
"url": url,
2929
"headers": headers,
3030
"cookies": cookies,
3131
"timeout": client.get_timeout(),
32-
"files": multipart_multipart_body,
32+
"files": multipart_multipart_data,
3333
}
3434

3535

@@ -57,12 +57,12 @@ def _build_response(*, response: httpx.Response) -> Response[Union[HTTPValidatio
5757
def sync_detailed(
5858
*,
5959
client: Client,
60-
multipart_body: BodyUploadFileTestsUploadPost,
60+
multipart_data: BodyUploadFileTestsUploadPost,
6161
keep_alive: Union[Unset, bool] = UNSET,
6262
) -> Response[Union[HTTPValidationError, None]]:
6363
kwargs = _get_kwargs(
6464
client=client,
65-
multipart_body=multipart_body,
65+
multipart_data=multipart_data,
6666
keep_alive=keep_alive,
6767
)
6868

@@ -76,27 +76,27 @@ def sync_detailed(
7676
def sync(
7777
*,
7878
client: Client,
79-
multipart_body: BodyUploadFileTestsUploadPost,
79+
multipart_data: BodyUploadFileTestsUploadPost,
8080
keep_alive: Union[Unset, bool] = UNSET,
8181
) -> Optional[Union[HTTPValidationError, None]]:
8282
"""Upload a file"""
8383

8484
return sync_detailed(
8585
client=client,
86-
multipart_body=multipart_body,
86+
multipart_data=multipart_data,
8787
keep_alive=keep_alive,
8888
).parsed
8989

9090

9191
async def asyncio_detailed(
9292
*,
9393
client: Client,
94-
multipart_body: BodyUploadFileTestsUploadPost,
94+
multipart_data: BodyUploadFileTestsUploadPost,
9595
keep_alive: Union[Unset, bool] = UNSET,
9696
) -> Response[Union[HTTPValidationError, None]]:
9797
kwargs = _get_kwargs(
9898
client=client,
99-
multipart_body=multipart_body,
99+
multipart_data=multipart_data,
100100
keep_alive=keep_alive,
101101
)
102102

@@ -109,15 +109,15 @@ async def asyncio_detailed(
109109
async def asyncio(
110110
*,
111111
client: Client,
112-
multipart_body: BodyUploadFileTestsUploadPost,
112+
multipart_data: BodyUploadFileTestsUploadPost,
113113
keep_alive: Union[Unset, bool] = UNSET,
114114
) -> Optional[Union[HTTPValidationError, None]]:
115115
"""Upload a file"""
116116

117117
return (
118118
await asyncio_detailed(
119119
client=client,
120-
multipart_body=multipart_body,
120+
multipart_data=multipart_data,
121121
keep_alive=keep_alive,
122122
)
123123
).parsed

openapi_python_client/parser/openapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def parse_multipart_body(
116116
multipart_body = body_content.get("multipart/form-data")
117117
if multipart_body is not None and multipart_body.media_type_schema is not None:
118118
prop, schemas = property_from_data(
119-
name="multipart_body",
119+
name="multipart_data",
120120
required=True,
121121
data=multipart_body.media_type_schema,
122122
schemas=schemas,

openapi_python_client/templates/endpoint_macros.py.jinja

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ form_data: {{ endpoint.form_body_class.name }},
101101
{% endif %}
102102
{# Multipart data if any #}
103103
{% if endpoint.multipart_body %}
104-
multipart_body: {{ endpoint.multipart_body.get_type_string() }},
104+
multipart_data: {{ endpoint.multipart_body.get_type_string() }},
105105
{% endif %}
106106
{# JSON body if any #}
107107
{% if endpoint.json_body %}
@@ -130,7 +130,7 @@ client=client,
130130
form_data=form_data,
131131
{% endif %}
132132
{% if endpoint.multipart_body %}
133-
multipart_body=multipart_body,
133+
multipart_data=multipart_data,
134134
{% endif %}
135135
{% if endpoint.json_body %}
136136
json_body=json_body,

openapi_python_client/templates/property_templates/list_property.py.jinja

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ for {{ inner_source }} in {{ source }}:
4242

4343
{% macro transform(property, source, destination, declare_type=True, stringify=False) %}
4444
{% set inner_property = property.inner_property %}
45-
{% set type_string = property.get_type_string(json=True) %}
4645
{% if stringify %}
4746
{% set type_string = "Union[Unset, Tuple[None, str, str]]" %}
47+
{% else %}
48+
{% set type_string = property.get_type_string(json=True) %}
4849
{% endif %}
4950
{% if property.required %}
5051
{% if property.nullable %}

openapi_python_client/templates/property_templates/model_property.py.jinja

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
{% macro transform(property, source, destination, declare_type=True, stringify=False, transform_method="to_dict") %}
1414
{% set transformed = source + "." + transform_method + "()" %}
15-
{% set type_string = property.get_type_string(json=True) %}
1615
{% if stringify %}
1716
{% set transformed = "(None, json.dumps(" + transformed + "), 'application/json')" %}
1817
{% set type_string = "Union[Unset, Tuple[None, str, str]]" %}
18+
{% else %}
19+
{% set type_string = property.get_type_string(json=True) %}
1920
{% endif %}
2021
{% if property.required %}
2122
{% if property.nullable %}

0 commit comments

Comments
 (0)