@Target(value=METHOD) @Retention(value=RUNTIME) public @interface ApiResponse
This can be used to describe possible success and error codes from your REST API call.
You may or may not use this to describe the return type of the operation (normally a
successful code), but the successful response should be described as well using the
ApiOperation
.
This annotation can be applied at method or class level; class level annotations will be parsed only if an @ApiResponse annotation with the same code is not defined at method level or in thrown Exception
If your API has uses a different response class for these responses, you can describe them here by associating a response class with a response code. Note, Swagger does not allow multiple response types for a single response code.
This annotation is not used directly and will not be parsed by Swagger. It should be used
within the ApiResponses
.
ApiOperation
,
ApiResponses
Modifier and Type | Required Element and Description |
---|---|
int |
code
The HTTP status code of the response.
|
String |
message
Human-readable message to accompany the response.
|
Modifier and Type | Optional Element and Description |
---|---|
Example |
examples
Examples for the response.
|
String |
reference
Specifies a reference to the response type.
|
Class<?> |
response
Optional response class to describe the payload of the message.
|
String |
responseContainer
Declares a container wrapping the response.
|
ResponseHeader[] |
responseHeaders
A list of possible headers provided alongside the response.
|
public abstract int code
The value should be one of the formal HTTP Status Code Definitions.
public abstract String message
public abstract Class<?> response
Corresponds to the `schema` field of the response message object.
public abstract String reference
public abstract ResponseHeader[] responseHeaders
public abstract String responseContainer
Valid values are "List", "Set" or "Map". Any other value will be ignored.
public abstract Example examples
Copyright © 2019. All Rights Reserved.