Upload multiple files in swaggerUI

Currently my swagger is handling single file upload successfully. But I want to change it to accept multiple files but i can’t figure out a way how .

This is the working code:

  Path.parameter(:file, :formData, :file, "Browse File", required: true) 

Thanks!

2 Likes

It looks like the swagger 2.0 spec allows for multiple form-data file parameters:
https://swagger.io/docs/specification/2-0/file-upload/

Multiple Upload

You can have several named file parameters, each defined individually:

  parameters:
    - in: formData
      name: upfile1
      type: file
      required: true
    - in: formData
      name: upfile2
      type: file
      required: false
    - in: formData
      name: upfile3
      type: file
      required: false

However, uploading an arbitrary number of files (an array of files) is not supported. There is an open feature request at https://github.com/OAI/OpenAPI-Specification/issues/254. For now, you can use a binary string array as a workaround for uploading an arbitrary number of files:

Hi @mbuhot,

Is it possible in Swagger 3.0. If yes, how could implement it from phoenix?

Thanks

Looks like it is available in OpenAPI 3.0 specification, but the swagger-ui part is still unimplemented.

You can check out OpenApiSpex project if you are looking to target OpenAPI 3.0.

1 Like