springfox-swagger2 UI是否支持一次选择多个文件?

时间:2015-11-26 07:57:07

标签: file-upload swagger swagger-ui springfox

我使用Spring Boot和集成的swagger-ui(springfox-swagger2),我希望能够选择一次上传多个文件。不幸的是,Swagger UI似乎不允许这样做,至少不会给我的控制器方法。

我的控制器方法签名:

@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: enter image description here

但我期待的UI与此类似: enter image description here

一次选择文件夹中的所有图片比一次选择一张图片更方便,例如:

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

springfox-swagger2是否支持此功能?如果是这样,我需要做出哪些改变?

1 个答案:

答案 0 :(得分:1)

很遗憾,答案是

Springfox Swagger2不支持此功能,因为Swagger尚不支持:https://github.com/springfox/springfox/issues/1072

相关的Swagger问题:
https://github.com/swagger-api/swagger-ui/issues/4600
https://github.com/OAI/OpenAPI-Specification/issues/254