8000 Support array of format: binary items in multipart/form-data request bodies · Issue #1255 · openapi-generators/openapi-python-client · GitHub
[go: up one dir, main page]

Skip to content

Support array of format: binary items in multipart/form-data request bodies #1255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
b-morgenthaler opened this issue May 20, 2025 · 0 comments

Comments

@b-morgenthaler
Copy link
b-morgenthaler commented May 20, 2025

Describe the bug
When an OpenAPI 3.0 schema defines a property as an array of binaries inside a multipart/form-data requestBody, the generator currently treats it as a JSON body and emits a single body parameter. As a result:

  • The generated sync_detailed(...) signature has only:
def sync_detailed(
    *,
    client: Client,
    body: UploadFilesPostBody,
    hash_: str,
) -> Response[Any]:
    …
  • Internally body.files (a list of File objects with payload: BinaryIO) is passed to json=…, causing serialization errors.

OpenAPI Spec File

paths:
  /upload_files:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                hash_:
                  type: string
                files:
                  type: array
                  items:
                    type: string
                    format: binary
      responses:
        '200':
          description: OK

What actually happens

  • The generator emits a single body: UploadFilesPostBody parameter.
  • When calling sync_detailed(..., body=…), httpx is invoked with json=… and fails on BinaryIO because it isn’t valid JSON.

Desktop:

  • OS: Windows 10
  • Python Version: cPython 3.12.8
  • openapi-python-client version 0.24.3

Additional context
None - if anything is needed, please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0