I’m using Springfox swagger-ui (2.8.0). I’m unable to display request body model in Swagger UI as the datatype of request body is not specified in method definition. Request body object is mapped to the required object class using object mapper inside the method.
Example:
@ApiOperation(value = "API to get records", response = ResponseVO.class)
@PostMapping(value = "/getRecords")
public ResponseVO getRecords(@RequestBody Object requestObj) throws Exception {
CustomerRecordsRequestVO customerRecordsRequestVO = new ObjectMapper().convertValue(requestObj,
RequestVO.class);
................
}
In the above example @RequestBody data type is generic (Object) which is mapped to RequestVO class inside the method which is not picked up by swagger. Please help.
I tried using @ApiImplicitParams but still the request body looks empty (“{}”) in Swagger-ui.
@ApiImplicitParams(@ApiImplicitParam(name = "requestObj", dataType = "RequestVO"))
Tanviya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.