Skip to content

Commit 6ab135f

Browse files
author
Constantinos Symeonides
committed
feat: Support non-file fields in Multipart requests
1 parent 40e1552 commit 6ab135f

19 files changed

+234
-28
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,24 @@ def _get_kwargs(
130130
params.update(json_required_model_prop)
131131
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
132132

133-
return {
133+
data: Dict[str, Any] = {}
134+
files: Dict[str, Any] = {}
135+
136+
kwargs = {
134137
"url": url,
135138
"headers": headers,
136139
"cookies": cookies,
137140
"timeout": client.get_timeout(),
138141
"params": params,
139142
}
140143

144+
if data:
145+
kwargs["data"] = data
146+
if files:
147+
kwargs["files"] = files
148+
149+
return kwargs
150+
141151

142152
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
143153
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _parse_response(*, response: httpx.Response) -> Optional[List[bool]]:
2737
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _parse_response(*, response: httpx.Response) -> Optional[List[float]]:
2737
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _parse_response(*, response: httpx.Response) -> Optional[List[int]]:
2737
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _parse_response(*, response: httpx.Response) -> Optional[List[str]]:
2737
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,24 @@ def _get_kwargs(
3838
}
3939
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
4040

41-
return {
41+
data: Dict[str, Any] = {}
42+
files: Dict[str, Any] = {}
43+
44+
kwargs = {
4245
"url": url,
4346
"headers": headers,
4447
"cookies": cookies,
4548
"timeout": client.get_timeout(),
4649
"params": params,
4750
}
4851

52+
if data:
53+
kwargs["data"] = data
54+
if files:
55+
kwargs["files"] = files
56+
57+
return kwargs
58+
4959

5060
def _parse_response(*, response: httpx.Response) -> Optional[Union[List[AModel], HTTPValidationError]]:
5161
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@ def _get_kwargs(
2525
}
2626
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2727

28-
return {
28+
data: Dict[str, Any] = {}
29+
files: Dict[str, Any] = {}
30+
31+
kwargs = {
2932
"url": url,
3033
"headers": headers,
3134
"cookies": cookies,
3235
"timeout": client.get_timeout(),
3336
"params": params,
3437
}
3538

39+
if data:
40+
kwargs["data"] = data
41+
if files:
42+
kwargs["files"] = files
43+
44+
return kwargs
45+
3646

3747
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
3848
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@ def _get_kwargs(
2020

2121
json_json_body = json_body.to_dict()
2222

23-
return {
23+
data: Dict[str, Any] = {}
24+
files: Dict[str, Any] = {}
25+
26+
kwargs = {
2427
"url": url,
2528
"headers": headers,
2629
"cookies": cookies,
2730
"timeout": client.get_timeout(),
2831
"json": json_json_body,
2932
}
3033

34+
if data:
35+
kwargs["data"] = data
36+
if files:
37+
kwargs["files"] = files
38+
39+
return kwargs
40+
3141

3242
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
3343
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _build_response(*, response: httpx.Response) -> Response[None]:
2737
return Response(

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ def _get_kwargs(
1616
headers: Dict[str, Any] = client.get_headers()
1717
cookies: Dict[str, Any] = client.get_cookies()
1818

19-
return {
19+
data: Dict[str, Any] = {}
20+
files: Dict[str, Any] = {}
21+
22+
kwargs = {
2023
"url": url,
2124
"headers": headers,
2225
"cookies": cookies,
2326
"timeout": client.get_timeout(),
2427
}
2528

29+
if data:
30+
kwargs["data"] = data
31+
if files:
32+
kwargs["files"] = files
33+
34+
return kwargs
35+
2636

2737
def _parse_response(*, response: httpx.Response) -> Optional[File]:
2838
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,24 @@ def _get_kwargs(
2626
}
2727
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2828

29-
return {
29+
data: Dict[str, Any] = {}
30+
files: Dict[str, Any] = {}
31+
32+
kwargs = {
3033
"url": url,
3134
"headers": headers,
3235
"cookies": cookies,
3336
"timeout": client.get_timeout(),
3437
"params": params,
3538
}
3639

40+
if data:
41+
kwargs["data"] = data
42+
if files:
43+
kwargs["files"] = files
44+
45+
return kwargs
46+
3747

3848
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
3949
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@ def _get_kwargs(
2020

2121
json_json_body = json_body.to_dict()
2222

23-
return {
23+
data: Dict[str, Any] = {}
24+
files: Dict[str, Any] = {}
25+
26+
kwargs = {
2427
"url": url,
2528
"headers": headers,
2629
"cookies": cookies,
2730
"timeout": client.get_timeout(),
2831
"json": json_json_body,
2932
}
3033

34+
if data:
35+
kwargs["data"] = data
36+
if files:
37+
kwargs["files"] = files
38+
39+
return kwargs
40+
3141

3242
def _parse_response(*, response: httpx.Response) -> Optional[TestInlineObjectsResponse_200]:
3343
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ def _get_kwargs(
1818

1919
cookies["MyToken"] = my_token
2020

21-
return {
21+
data: Dict[str, Any] = {}
22+
files: Dict[str, Any] = {}
23+
24+
kwargs = {
2225
"url": url,
2326
"headers": headers,
2427
"cookies": cookies,
2528
"timeout": client.get_timeout(),
2629
}
2730

31+
if data:
32+
kwargs["data"] = data
33+
if files:
34+
kwargs["files"] = files
35+
36+
return kwargs
37+
2838

2939
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, None]]:
3040
if response.status_code == 200:

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ def _get_kwargs(
1515
headers: Dict[str, Any] = client.get_headers()
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

18-
return {
18+
data: Dict[str, Any] = {}
19+
files: Dict[str, Any] = {}
20+
21+
kwargs = {
1922
"url": url,
2023
"headers": headers,
2124
"cookies": cookies,
2225
"timeout": client.get_timeout(),
2326
}
2427

28+
if data:
29+
kwargs["data"] = data
30+
if files:
31+
kwargs["files"] = files
32+
33+
return kwargs
34+
2535

2636
def _build_response(*, response: httpx.Response) -> Response[None]:
2737
return Response(

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

+19-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,31 @@ def _get_kwargs(
2222
if keep_alive is not UNSET:
2323
headers["keep-alive"] = keep_alive
2424

25-
return {
25+
data: Dict[str, Any] = {}
26+
files: Dict[str, Any] = {}
27+
28+
non_files: Dict[str, Any] = {}
29+
for key, value in multipart_data.to_dict().items():
30+
if type(value) is tuple:
31+
files[key] = value
32+
else:
33+
non_files[key] = value
34+
data.update(non_files)
35+
36+
kwargs = {
2637
"url": url,
2738
"headers": headers,
2839
"cookies": cookies,
2940
"timeout": client.get_timeout(),
30-
"files": multipart_data.to_dict(),
3141
}
3242

43+
if data:
44+
kwargs["data"] = data
45+
if files:
46+
kwargs["files"] = files
47+
48+
return kwargs
49+
3350

3451
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
3552
if response.status_code == 200:

0 commit comments

Comments
 (0)