Skip to content

Support non-file fields in Multipart requests #351

Closed
@csymeonides-mf

Description

@csymeonides-mf

Is your feature request related to a problem? Please describe.

Given this schema for a POST request:

{
  "requestBody": {
    "content": {
      "multipart/form-data": {
        "schema": {
          "type": "object",
          "properties": {
            "file": {
              "type": "string",
              "format": "binary"
            },
            "options": {
              "type": "string",
              "default": "{}"
            }
          }
        }
      }
    }
  }
}

the generated code will call httpx.post(files=dict(file=file, options=options)) which causes a server-side pydantic validation error (options should be of type str).

Describe the solution you'd like

The correct invocation would be httpx.post(data=dict(options=options), files=dict(file=file)) (see relevant page from httpx docs)

Describe alternatives you've considered

Some sort of server-side workaround, but it might be somewhat ugly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions