Skip to content

Commit c46d511

Browse files
authored
Explicitly set boundary for multipart/form-data
1 parent a73dfd4 commit c46d511

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

openapi_python_client/templates/endpoint_module.py.jinja

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@ def _get_kwargs(
5151
{% set destination = "_" + body.body_type + "_body" %}
5252
{{ body_to_kwarg(body, destination) | indent(8) }}
5353
_kwargs["{{ body.body_type.value }}"] = {{ destination }}
54+
{% if body.content_type == "multipart/form-data" %}
55+
headers["Content-Type"] = "multipart/form-data; boundary=+++"
56+
{% else %}
5457
headers["Content-Type"] = "{{ body.content_type }}"
58+
{% endif %}
59+
5560
{% endfor %}
5661
{% elif endpoint.bodies | length == 1 %}
5762
{% set body = endpoint.bodies[0] %}
5863
{{ body_to_kwarg(body, "_body") | indent(4) }}
5964
_kwargs["{{ body.body_type.value }}"] = _body
60-
{% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #}
65+
{% if body.content_type == "multipart/form-data" %}
66+
headers["Content-Type"] = "multipart/form-data; boundary=+++"
67+
{% else %}
6168
headers["Content-Type"] = "{{ body.content_type }}"
6269
{% endif %}
6370
{% endif %}

0 commit comments

Comments
 (0)