用springfox swagger支持动态键

时间:2018-11-08 17:40:45

标签: java spring-boot swagger openapi springfox

@ApiOperation(value = "Sample API")
@ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "string", name = "x",, required = false, paramType = "form", allowMultiple = true),
            @ApiImplicitParam(dataType = "__file", name = "y", , required = false, paramType = "form", allowMultiple = true)
})
@PostMapping(value = "/{upload}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity upload(HttpServletRequest request) {

    //process request

}

使用Spring Fox Swagger(2.9.2)以上版本无法达到等效的CURL

curl -X POST \
  http://localhost:8080/upload \
  -H 'Accept: application/json' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'x1=@path\1.txt' \
  -F 'x2=@path\2.txt' \
  -F x3=val3    \
  -F x4=val4

需要对等效于控制器的动态密钥提供支持,该控制器可以同时接受Map<String,String>Map<String,MultipartFile>

在Springfox swagger中添加Open API 3支持之前,是不可能的吗?

0 个答案:

没有答案