Currently I am working on my API documentation and I decided to implement it with ReDoc. My API built using Spring Boot..and for the documentation I am using SWAGGER. Everything is fine, but I am unable to annotate my Controller to show the 'response samples' part on the right in the ReDoc documentation. I have tried adding examples in the DTOs like:
@JsonIgnoreProperties(ignoreUnknown = true)
public class DocumentResponse {
@ApiModelProperty(notes = "XML reuslt", name = "xmlResult", example = "asdasd", dataType = "java.lang.String")
private String xmlResult;
This is how my controller looks like:
@Api(tags = {"Document"})
@RestController
@CrossOrigin("")
@RequestMapping("/doc")
public class DocumentController {
@PostMapping(value = "/doc-create", consumes = {"application/json"})
@ApiOperation(value = "docCreate", notes = "Create Document", response = DocumentResponse.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Document success!", response = DocumentResponse.class),
@ApiResponse(code = 201, message = "Document created!", response = DocumentResponse.class),
@ApiResponse(code = 401, message = "Unauthorized!", response = DocumentResponse.class),
@ApiResponse(code = 403, message = "Forbidden!", response = DocumentResponse.class),
@ApiResponse(code = 404, message = "Not found!", response = DocumentResponse.class)})
public @ResponseBody DocumentResponse docCreate(@RequestBody DocumentRequest request) {
return null;
}
}
Finally solved by adding this to the controller @PostMapping
:
produces = {"application/json"}