Skip to content

Upload multiple files with multipart/form-data request #4276

@fsaintma

Description

@fsaintma
Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? OpenApi 3.0
Which Swagger-UI version? 3.11.0
How did you install Swagger-UI? Hosted on my local machine
Which browser & version? Chrome Version 63.0.3239.108
Which operating system? Linux Ubuntu

Demonstration API definition

 /testmultipart:
    post:
      summary: Send multipart request.
      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
      responses:
        '200':
          description: The request has been sended.

Expected Behavior

I try to test a POST multipart/form-data request with swagger-UI and multiple files. I read the OpenAPI specification documentation with File Upload considerations : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#considerations-for-file-uploads

I also give you a corresponding example of curl command:

curl  -X POST -H "Content-Type: multipart/form-data"  -F "file1=@file1" -F "file2=@file2" "http://localhost/testmultipart"

I suppose that when I "Try it out" my request swagger UI must show me multiple "File Upload" widgets.

Current Behavior

Actually Swagger UI propose in request body the following example value model with application/json schema :

{
  "file": [
    "string"
  ]
}

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