@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Repeatable(OpenAPIResponses.class)
public @interface OpenAPIResponse
Specify endpoint response status code/description/type.
When not specified the default 2xx openAPI generation is based on the javadoc of the method.
Will not override the default 2xx generated openapi unless status code is 2xx
@Post("/post")
@OpenAPIReturns(responseCode = "200", description = "from annotaion")
@OpenAPIReturns(responseCode = "201")
@OpenAPIReturns(responseCode = "500", description = "Some other Error", type=ErrorResponse.class)
ResponseModel endpoint() {}
Can also be placed on a class to add to every method in the controller.
@OpenAPIResponse(
responseCode = "403",
description = "Insufficient rights to this resource."
)
public class MyController {
...
}
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionint
the http status code of this response -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe description of the return value.Class
<?> The concrete type that that this endpoint returns.
-
Element Details
-
responseCode
int responseCodethe http status code of this response -
description
String descriptionThe description of the return value. By default uses the @return javadoc of the method as the description- Default:
""
-
type
Class<?> typeThe concrete type that that this endpoint returns. If status code is a 2xx code it will default to the return type of the method- Default:
java.lang.Void.class
-