Annotation Type ApiResponse


  • @Target(METHOD)
    @Retention(RUNTIME)
    public @interface 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 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.

    See Also:
    ApiOperation, ApiResponses
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      int code
      The HTTP status code of the response.
      String message
      Human-readable message to accompany the response.
      • message

        String message
        Human-readable message to accompany the response.
      • response

        Class<?> response
        Optional response class to describe the payload of the message.

        Corresponds to the `schema` field of the response message object.

        Default:
        java.lang.Void.class
      • reference

        String reference
        Specifies a reference to the response type. The specified reference can be either local or remote and will be used as-is, and will override any specified response() class.
        Default:
        ""
      • responseHeaders

        ResponseHeader[] responseHeaders
        A list of possible headers provided alongside the response.
        Returns:
        a list of response headers.
        Default:
        {@io.swagger.annotations.ResponseHeader(name="", response=java.lang.Void.class)}
      • responseContainer

        String responseContainer
        Declares a container wrapping the response.

        Valid values are "List", "Set" or "Map". Any other value will be ignored.

        Default:
        ""
      • examples

        Example examples
        Examples for the response.
        Returns:
        Since:
        1.5.20
        Default:
        @io.swagger.annotations.Example({@io.swagger.annotations.ExampleProperty(value="", mediaType="")})