我正在尝试在我的一个项目中使用springfox。
我有以下控制器:
@RestController
public class FooController {
@Autowired
public FooController(){}
@PostMapping(value = "foo/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation(value = "Daa", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<byte[]> saveImage(@RequestParam("image") MultipartFile image) throws IOException
{
//...
}
}
我的配置没有什么特别之处:
return new Docket(DocumentationType.OAS_30)
.forCodeGeneration(true)
.groupName("foo-service")
.select()
.paths(PathSelectors.ant("/foo/**")
.build();
我想springfox只会用 multipart/form-data
as请求内容类型,但这会导致以下结果:
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "string",
"format": "binary"
}
},
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
},
"multipart/form-data": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
我还注意到,每个控制器Map application/json
设置,即使它不需要。我怎样才能摆脱它?
暂无答案!
目前还没有任何答案,快来回答吧!