GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Skip setting 'Content-Type' on file upload, when multiple bodies are supported · Issue #947 · openapi-generators/openapi-python-client

Skip setting 'Content-Type' on file upload, when multiple bodies are supported #947

New issue
Copy link
New issue
Copy link
Open
Open
Skip setting 'Content-Type' on file upload, when multiple bodies are supported#947
Copy link

Description

@kgutwin
kgutwin
opened on Jan 23, 2024
Issue body actions

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

openapi-python-client/openapi_python_client/templates/endpoint_module.py.jinja

Lines 48 to 63 in 660941d

{% if endpoint.bodies | length > 1 %}
{% for body in endpoint.bodies %}
if isinstance(body, {{body.prop.get_type_string() }}):
{% set destination = "_" + body.body_type + "_body" %}
{{ body_to_kwarg(body, destination) | indent(8) }}
_kwargs["{{ body.body_type.value }}"] = {{ destination }}
headers["Content-Type"] = "{{ body.content_type }}"
{% 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 #}
headers["Content-Type"] = "{{ body.content_type }}"
{% endif %}
{% endif %}

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.

Activity

  1. sda-mikerochefort
    added 2 commits that reference this issue on Nov 7, 2026

    fix: Let httpx2 choose the multipart/form-data boundary (openapi-gene…

    4d6baa7

    Release 0.30.0 (openapi-generators#1510)

    46a4340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.