代码拉取完成,页面将自动刷新
如上图所示,JavaBean (包含一个 MultipartFile[] file 属性) 作为参数时,不能正确识别 MediaType 为 multipart/form-data
springboot 2.2.7.RELEASE
springdoc-openapi-ui 1.6.9
knife4j-openapi3-spring-boot-starter 4.0.0
knife4j 效果图 (正确识别需要放开注释部分)
swagger 效果图
github issue : https://github.com/xiaoymin/swagger-bootstrap-ui/issues/538
在OpenAPI3里面确实我复测了一下,有这个问题,但是是因为那个array没解析出来(目前版本的ui确实存在问题)
不过我后来升级了springdoc的版本1.6.14(后面Knife4j的版本会迭代到这个),解析出来的OpenAPI规范却不太一样。。
第一种情况是加注解描述的,代码如下:
@Operation(summary = "附件上传",description = "附近上传-xxx",requestBody = @RequestBody(content = {
@Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE,schema = @Schema(type = "object"),
schemaProperties = {
@SchemaProperty(name = "file",array = @ArraySchema(schema = @Schema(type = "string",format = "binary",requiredMode = Schema.RequiredMode.REQUIRED))),
@SchemaProperty(name = "module",schema = @Schema(type = "string",required = true)),
@SchemaProperty(name = "bizNo",schema = @Schema(type = "string",required = true)),
@SchemaProperty(name = "bizType",schema = @Schema(type = "integer",required = true))
})
}))
@PostMapping(value = "/module/upload1",consumes = MediaType.MULTIPART_FORM_DATA_VALUE,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> fileModule1(FileRequestVo fileRequestVo){
return ResponseEntity.ok(RandomUtil.randomString(23));
}
解析的规范:
第二种情况,不加任何注释,代码:
@PostMapping(value = "/module/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> fileModule(FileRequestVo fileRequestVo){
return ResponseEntity.ok(RandomUtil.randomString(23));
}
解析得到的规范:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
我只能先以这个版本为准了
登录 后才可以发表评论