Reputation: 195
I wrote the piece of code below:
@PostMapping(path = "/process", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get process with given ID", produces = MediaType.APPLICATION_JSON_VALUE,
response = ProcessType.class)
public ResponseEntity<ProcessType> createProcessType(
@RequestBody
@DTO(ProcessTypeDto.class) ProcessType processType
) {
log.info("POST called on /process");
ProcessType processTypeResult;
...
...
}
which works great. But my problem is with swagger. I made a custom annotation @DTO
which automatically maps one class to another. But, swagger sees my ProcessType
request body and shows examples in the UI of that class rather than ProcessTypeDto
. If I delete what swagger shows and POST ProcessTypeDto
the code works I would just like swagger to show ProcessTypeDto
as the default example for this endpoint as it would break codegen.
Is there a way to manually specify what request body I would like from swaggers POV overriding what my@Requestbody
is?
Upvotes: 1
Views: 9401
Reputation: 1663
looks like you are not lucky so far, it will be released in version 2.0
here is what you are lookin for https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations#requestbody
or at least you can start using a release candidate https://mvnrepository.com/artifact/io.swagger/swagger-core
Upvotes: 2