Skip to content

Commit d40491e

Browse files
committed
fix: Don't manually set multipart/form-data content-type
1 parent 7903fcb commit d40491e

19 files changed

+20
-21
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: JsonLikeBody,
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",

end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_kwargs(
2020
PostBodiesMultipleFilesBody,
2121
],
2222
) -> Dict[str, Any]:
23-
headers = {}
23+
headers: Dict[str, Any] = {}
2424

2525
_kwargs: Dict[str, Any] = {
2626
"method": "post",

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _get_kwargs(
1919
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
2020
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
2121
) -> Dict[str, Any]:
22-
headers = {}
22+
headers: Dict[str, Any] = {}
2323
if not isinstance(boolean_header, Unset):
2424
headers["Boolean-Header"] = "true" if boolean_header else "false"
2525

end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def _get_kwargs(
1616
*,
1717
body: PostNamingPropertyConflictWithImportBody,
1818
) -> Dict[str, Any]:
19-
headers = {}
19+
headers: Dict[str, Any] = {}
2020

2121
_kwargs: Dict[str, Any] = {
2222
"method": "post",

end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def _get_kwargs(
1616
header_param: Union[Unset, str] = UNSET,
1717
cookie_param: Union[Unset, str] = UNSET,
1818
) -> Dict[str, Any]:
19-
headers = {}
19+
headers: Dict[str, Any] = {}
2020
if not isinstance(header_param, Unset):
2121
headers["header param"] = header_param
2222

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _get_kwargs(
1515
param_header: Union[Unset, str] = UNSET,
1616
param_cookie: Union[Unset, str] = UNSET,
1717
) -> Dict[str, Any]:
18-
headers = {}
18+
headers: Dict[str, Any] = {}
1919
if not isinstance(param_header, Unset):
2020
headers["param"] = param_header
2121

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_kwargs(
1414
*,
1515
body: AModel,
1616
) -> Dict[str, Any]:
17-
headers = {}
17+
headers: Dict[str, Any] = {}
1818

1919
_kwargs: Dict[str, Any] = {
2020
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_kwargs(
1414
*,
1515
body: AModel,
1616
) -> Dict[str, Any]:
17-
headers = {}
17+
headers: Dict[str, Any] = {}
1818

1919
_kwargs: Dict[str, Any] = {
2020
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: File,
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: AFormData,
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: PostFormDataInlineBody,
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: str,
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_kwargs(
1414
*,
1515
body: TestInlineObjectsBody,
1616
) -> Dict[str, Any]:
17-
headers = {}
17+
headers: Dict[str, Any] = {}
1818

1919
_kwargs: Dict[str, Any] = {
2020
"method": "post",

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_kwargs(
1414
*,
1515
body: BodyUploadFileTestsUploadPost,
1616
) -> Dict[str, Any]:
17-
headers = {}
17+
headers: Dict[str, Any] = {}
1818

1919
_kwargs: Dict[str, Any] = {
2020
"method": "post",
@@ -24,7 +24,6 @@ def _get_kwargs(
2424
_body = body.to_multipart()
2525

2626
_kwargs["files"] = _body
27-
headers["Content-Type"] = "multipart/form-data"
2827

2928
_kwargs["headers"] = headers
3029
return _kwargs

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_kwargs(
1313
*,
1414
body: List[File],
1515
) -> Dict[str, Any]:
16-
headers = {}
16+
headers: Dict[str, Any] = {}
1717

1818
_kwargs: Dict[str, Any] = {
1919
"method": "post",
@@ -27,7 +27,6 @@ def _get_kwargs(
2727
_body.append(body_item)
2828

2929
_kwargs["files"] = _body
30-
headers["Content-Type"] = "multipart/form-data"
3130

3231
_kwargs["headers"] = headers
3332
return _kwargs

integration-tests/integration_tests/api/body/post_body_multipart.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _get_kwargs(
1515
*,
1616
body: PostBodyMultipartBody,
1717
) -> Dict[str, Any]:
18-
headers = {}
18+
headers: Dict[str, Any] = {}
1919

2020
_kwargs: Dict[str, Any] = {
2121
"method": "post",
@@ -25,7 +25,6 @@ def _get_kwargs(
2525
_body = body.to_multipart()
2626

2727
_kwargs["files"] = _body
28-
headers["Content-Type"] = "multipart/form-data"
2928

3029
_kwargs["headers"] = headers
3130
return _kwargs

integration-tests/integration_tests/api/parameters/post_parameters_header.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _get_kwargs(
1717
number_header: float,
1818
integer_header: int,
1919
) -> Dict[str, Any]:
20-
headers = {}
20+
headers: Dict[str, Any] = {}
2121
headers["Boolean-Header"] = "true" if boolean_header else "false"
2222

2323
headers["String-Header"] = string_header

openapi_python_client/templates/endpoint_macros.py.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{% macro header_params(endpoint) %}
55
{% if endpoint.header_parameters or endpoint.bodies | length > 0 %}
6-
headers = {}
6+
headers: Dict[str, Any] = {}
77
{% if endpoint.header_parameters %}
88
{% for parameter in endpoint.header_parameters.values() %}
99
{% import "property_templates/" + parameter.template as param_template %}

openapi_python_client/templates/endpoint_module.py.jinja

+2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def _get_kwargs(
5757
{% set body = endpoint.bodies[0] %}
5858
{{ body_to_kwarg(body, "_body") | indent(4) }}
5959
_kwargs["{{ body.body_type.value }}"] = _body
60+
{% if body.content_type != "multipart/form-data" %} {# Need httpx to set the boundary automatically #}
6061
headers["Content-Type"] = "{{ body.content_type }}"
62+
{% endif %}
6163
{% endif %}
6264

6365
{% if endpoint.header_parameters or endpoint.bodies | length > 0 %}

0 commit comments

Comments
 (0)