@ApiOperation
has an attribute response
to which we can pass the Response type. In @ApiResponse
also we have an attribute response
to which we can pass the Response type. So What is the exact difference between them?
@ApiOperation- This annotation is used to describe the exposed REST API. It describes an operation or typically a HTTP method against a specific path.
Annotation Type ApiResponse. Describes a possible response of an operation. This can be used to describe possible success and error codes from your REST API call.
You must specify the success response in @ApiOperation
while you can specify ALL possible response objects in @ApiResponse
.
@ApiResponse
is used wrapped inside @ApiResponses
and generally used to specify error codes and exceptional cases like Resource Not Found
or Bad Request
etc. You can also specify success
response, but it is not mandatory to do so, as the success response is anyway mentioned in @ApiOperation
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With