我使用 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 generated:
But I was expecting a UI similar to this:
一次性选择文件夹中的所有图片比一次选择一张更方便,例如:
<input type="file" name="img" multiple="multiple"/>
springfox-swagger2 支持这个吗?如果是这样,我需要做出哪些改变?
Update:正如 @Helen 所指出的,现在 Swagger 3.26.0 和 OpenAPI 3 支持这一点,并且应该在 Springfox 3 的下一个版本中提供支持
春狐2:不幸的是答案是no.
Springfox Swagger2 不支持这一点,因为 Swagger 尚不支持它:https://github.com/springfox/springfox/issues/1072 https://github.com/springfox/springfox/issues/1072
相关 Swagger 问题:
https://github.com/swagger-api/swagger-ui/issues/4600 https://github.com/swagger-api/swagger-ui/issues/4600(3.26.0 中已修复)
https://github.com/OAI/OpenAPI-Specification/issues/254 https://github.com/OAI/OpenAPI-Specification/issues/254
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)