Having parametrized class in swagger annotations

113 views Asked by At

From my spring rest service, I am returning response as -

return new ResponseEntity<ExampleOutputData>(exampleService.exampleServiceCall(inputData), responseHeaders, HttpStatus.ACCEPTED);

And I am mentioning response in annotaion as -

 @ApiResponses(value = { 
            @ApiResponse(code = 202, message = "Success", response = ResponseEntity.class)}) 

And I am getting yaml doc response as -

  responses:
    202:
      description: "Success"
      schema:
        $ref: "#/definitions/ResponseEntity"

My question is how do I mention ExampleOutputData in the response as actually my response is ResponseEntity<ExampleOutputData>

Or is it not required and the current implementation and swagger definition is perfect?

1

There are 1 answers

0
haihui On BEST ANSWER

In order to have ExampleOutputData in the response you should simply change ResponseEntity.class to ExampleOutputData.class:

@ApiResponses(value = {@ApiResponse(code = 202, message = "Success", response = ExampleOutputData.class)})

See documentation here.