@Target(value=METHOD)
@Retention(value=RUNTIME)
@Inherited
public @interface APIResponseSchema
@APIResponse
and that typically could not be determined by
scanning the resource method alone.
The following annotation usages are equivalent to the OpenAPI annotation scanner runtime.
@APIResponse(content = { @Content(schema = @Schema(implementation = MyResponseObject.class)) }) @APIResponseSchema(MyResponseObject.class)
When this annotation is applied to a method the response is added to the responses
defined in the corresponding OpenAPI operation with a default response code and description
that correspond to the method's HTTP method annotation and return type. Any media types that
apply to the resource method from either a method-level or class-level @Produces
annotation will result in those media types applying to the OpenAPI response model.
If not specified, default responseCode and responseDescription values shall be determined
according to the responseCode
and responseDescription
documentation.
@GET @Path("{id}") @APIResponseSchema(value = MyResponseObject.class, responseDescription = "Success", responseCode = "200") public Response getById(@PathParam("{id}") long id) { MyResponseObject entity = service.load(id); return Response.status(200).entity(entity).build(); }
APIResponse
,
"https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responseObject"Modifier and Type | Required Element and Description |
---|---|
java.lang.Class<?> |
value
Provides a Java class as implementation for this schema.
|
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
responseCode
The HTTP response code, or 'default', for the supplied response.
|
java.lang.String |
responseDescription
A short description of the response.
|
public abstract java.lang.Class<?> value
public abstract java.lang.String responseDescription
If no value is specified, the default value will set to the description given by the
HTTP/1.1 documentation
for the responseCode
in use.
public abstract java.lang.String responseCode
If no value is specified, a default shall be determined using REST conventions as follows:
void
and the HTTP method is @POST
,
the code will be 201
.
void
the method does not list a JAX-RS
AsyncResponse
parameter, the code will be 204
.
200
.