Forum Discussion

Stoplight's avatar
Stoplight
Community Manager
10 months ago

Multiple files upload in Multipart request body

Originally posted by user Thien to the Stoplight Community on 06/19/2023 at 04:16 ET.

Hello everyone,

I have an API that receives a multipart/form-data request body.
In the multipart, the client can input multiple files.

In the OpenAPI yaml file, I described the request body of the API like this to show that the client can upload multiple files in the multipart body:

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: array
                  items:
                    type: string
                    format: binary

But when I come to Stoplight, it only shows an input to enter text (image 1).
With the same OpenAPI yaml file, SwaggerUI show the option to upload multiple files (image 2).

Only when I change the OpenAPI yaml file to only allow upload 1 file,
then Stoplight shows the option to upload single file (image 3).

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: string
                  format: binary

Is there any other configurations that I am missing that tells Stoplight to display an option to upload multiple files?

I tried searching through discord and on the internet but was not able to find additional information.

Thank you.