Annotation Type OpenAPIResponse


@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 Elements
    Modifier and Type
    Required Element
    Description
    int
    the http status code of this response
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The description of the return value.
    The concrete type that that this endpoint returns.
  • Element Details

    • responseCode

      int responseCode
      the http status code of this response
    • description

      String description
      The description of the return value. By default uses the @return javadoc of the method as the description
      Default:
      ""
    • type

      Class<?> type
      The 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