I have a POST endpoint which receives a @ModelAttribute parameter. Everything is working ok, but the swagger documentation fails to have the descriptions, examples, etc.
I am using java 11, springboot 2.5.4 and springfox-boot-starter 3.0.0
Here is my code:
@Api
@RestController
@RequestMapping("/foo")
@Validated
public class MyRest {
@PostMapping(value = "/{id}/bar", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ApiOperation(value = "Do nothing", notes = "This endpoint does nothing")
public ResponseEntity<String> search(
@ModelAttribute MyModelRequest request,
@ApiParam(value = "Folder ID", required = true)
@PathVariable String id) {
// some business code
return new ResponseEntity<>("lorem ipsum", HttpStatus.OK);
}
}
MyModelRequest
@ApiModel
@Data
public class MyModelRequest {
@ApiParam(name = "fileName", value = "The name of the image to be stored in database")
@ApiModelProperty(value = "name model description", example = "summer picture", required = true)
private String name;
@DecimalMin("0.00")
@DecimalMax("100.00")
@ApiParam(name = "accuracy", value = "The required accuracy")
@ApiModelProperty(value = "Minimum required accuracy", example = "95.15", required = false)
private BigDecimal accuracy;
@ApiParam(name = "marginTop", value = "Top margin of the image")
@ApiModelProperty(value = "Separation between top item and the image", example = "300", required = false)
private Integer marginTop;
@ApiParam(name = "image")
@ApiModelProperty(value = "The image to be stored", example = "vacations.png", required = true)
private MultipartFile image;
}
And this is the generated swagger doc
UPDATE: I noticed that if I change the consumes = { MediaType.MULTIPART_FORM_DATA_VALUE } for consumes = { MediaType.APPLICATION_JSON_VALUE } or remove the whole "consumes" parameter from the endpoint, the documentation shows up correctly, however, doing this will make the fileupload fail.
