Skip to content

[BUG][Python] file upload seems broken #2118

@rienafairefr

Description

@rienafairefr

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? latest master
  • Have you search for related issues/PRs?
Description

When using a multipart/form-data request body like the example in the spec

requestBody:
  content:
    multipart/form-data:
      schema:
        properties:
                # The property name 'file' will be used for all files.
          file:
            type: array
            items:
              type: string
              format: binary

the ApiClient tries to 'sanitize_for_serializationthe(fileName, fileContent, fileMIME)` tuple that is describing the file data, so we get a string with that tuple, instead of the actual tuple, being sent to urllib3, and the API doesn't identify the content of the file correctly (it believes the serialized tuple is the content of the file...)

Suggest a fix

I seem to be able to upload a file or multiple files by adding the files tuples after the 'sanitization', but I need more testing before a PR can be sent

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions