openapi-python-client
openapi-python-client copied to clipboard
Skip setting 'Content-Type' on file upload, when multiple bodies are supported
Describe the bug Form-style submissions to endpoints that support multiple different content types are missing the necessary "boundary" attribute on the Content-Type header.
POST https://.../items HTTP/1.1
Host: ...
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
User-Agent: python-httpx/0.25.2
Authorization: Bearer ...
Content-Type: multipart/form-data
Transfer-Encoding: chunked
Cause https://github.com/openapi-generators/openapi-python-client/blob/660941dfe23a39ea9a22dd724e1db54afb130d08/openapi_python_client/templates/endpoint_module.py.jinja#L48-L63
In the template above, lines 60-62 have an "if content-type is not multipart/form-data" condition since httpx sets content type and multipart form boundary properly when files are provided. The same condition needs to be applied around line 54, which occurs when multiple body types are supported.