Does springfox-swagger2 UI support choosing multiple files at once?

主宰稳场 提交于 2020-06-16 08:31:33

问题


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:

But I was expecting a UI similar to this:

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?


回答1:


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



来源:https://stackoverflow.com/questions/33933219/does-springfox-swagger2-ui-support-choosing-multiple-files-at-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!