Skip to content
Open
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
9 changes: 8 additions & 1 deletion openapi_python_client/templates/endpoint_module.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ def _get_kwargs(
{% set destination = "_" + body.body_type + "_body" %}
{{ body_to_kwarg(body, destination) | indent(8) }}
_kwargs["{{ body.body_type.value }}"] = {{ destination }}
{% if body.content_type == "multipart/form-data" %}
headers["Content-Type"] = "multipart/form-data; boundary=+++"
{% else %}
headers["Content-Type"] = "{{ body.content_type }}"
{% endif %}

{% endfor %}
{% elif endpoint.bodies | length == 1 %}
{% set body = endpoint.bodies[0] %}
{{ body_to_kwarg(body, "_body") | indent(4) }}
_kwargs["{{ body.body_type.value }}"] = _body
{% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #}
{% if body.content_type == "multipart/form-data" %}
headers["Content-Type"] = "multipart/form-data; boundary=+++"
{% else %}
headers["Content-Type"] = "{{ body.content_type }}"
{% endif %}
{% endif %}
Expand Down