我使用的是Spring Boot和集成的swagger-ui(springfox-swagger2),我希望能够选择一次上传多个文件。不幸的是,Swagger UI 似乎不允许这样做,至少不提供我的 Controller 方法。
我的 Controller 方法签名:
@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 {
一次选择文件夹中的所有图片比一次选择一张更方便例如:
<input type="file" name="img" multiple="multiple"/>
springfox-swagger2 支持吗?如果是这样,我需要进行哪些更改?
最佳答案
更新:正如@Helen 所指出的,现在 Swagger 3.26.0 和 OpenAPI 3 支持这一点,并且应该在下一个版本的 Springfox 3 中支持
Springfox 2:不幸的是,答案是否。
Springfox Swagger2 不支持这个,因为 Swagger 还不支持它:https://github.com/springfox/springfox/issues/1072
相关Swagger问题:
https://github.com/swagger-api/swagger-ui/issues/4600 (在 3.26.0 中修复)
https://github.com/OAI/OpenAPI-Specification/issues/254
关于file-upload - springfox-swagger2 UI 是否支持一次选择多个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33933219/