3

I use Spring Boot and integrated swagger-ui (springfox-swagger2) and I want to be able to choose to upload multiple files at once. Unfortunately the Swagger UI doesn't appear to allow this, at least not give my controller method.

My controller method signature:

@ApiOperation(
    value = "batch upload goods cover image", 
    notes = "batch upload goods cover image",
    response = UploadCoverResultDTO.class,
    responseContainer = "List"
)
public Result<?> uploadGoodsCover(@ApiParam(value = "Image array", allowMultiple = true,
  required = true) @RequestPart("image") MultipartFile[] files) throws IOException {

Swagger UI generated: enter image description here

But I was expecting a UI similar to this: enter image description here

It's more convenient to choose all pictures in a folder in one go rather than choose one at a time e.g.:

<input type="file" name="img" multiple="multiple"/> 

Does springfox-swagger2 support this? If so, what changes do I need to make?

xlm
  • 6,854
  • 14
  • 53
  • 55
zhuguowei
  • 8,401
  • 16
  • 70
  • 106
  • I don't think swagger-ui knows how to support this use case. You might ask in their Google group or create an issue in that repository – Dilip Krishnan Nov 27 '15 at 13:54

1 Answers1

3

Update: as pointed out by @Helen, this is now supported in Swagger 3.26.0 with OpenAPI 3 and should be in the next release of Springfox 3

Springfox 2: unfortunately the answer is no.

Springfox Swagger2 does not support this because it's not yet supported by Swagger: https://github.com/springfox/springfox/issues/1072

Relevant Swagger issues:
https://github.com/swagger-api/swagger-ui/issues/4600 (fixed in 3.26.0)
https://github.com/OAI/OpenAPI-Specification/issues/254

xlm
  • 6,854
  • 14
  • 53
  • 55
  • 1
    Swagger UI 3.26.0 now supports uploading file arrays - provided that the API definition is in the OpenAPI 3.0 format. Recent snapshot version of Springfox (3.0.0-SNAPSHOT) can generate OpenAPI 3.0 definitions. – Helen Jun 05 '20 at 21:22
  • here, it works: https://stackoverflow.com/questions/63275134/springfox-swagger-ui-3-0-0-does-not-bring-up-swagger-ui-html-page/65879120#65879120 – Thang Le Jan 25 '21 at 04:50