Annotation Type ApiResponse


  • @Target({METHOD,TYPE})
    @Retention(RUNTIME)
    @Repeatable(ApiResponses.class)
    public @interface ApiResponse

    Describes a response code and description for an API method, for documentation purposes.

    Multiple annotations can be added to cover multiple response types.

    See Also:
    ApiResponses
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String code
      The HTTP status code of the response.
      java.lang.String message
      A short description of the response.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String[] contentType
      The content type for this code, if different from the default
      java.lang.String example
      An example return value
      java.lang.Class<?> response
      The type of the response body.
      ResponseHeader[] responseHeaders
      A list of possible headers provided alongside the response.
    • Element Detail

      • code

        java.lang.String code
        The HTTP status code of the response. This is a String to allow values such as "2XX" to cover all 200-299 codes.
        Returns:
        The code
      • message

        java.lang.String message
        A short description of the response. CommonMark syntax MAY be used for rich text representation.
        Returns:
        The description
      • responseHeaders

        ResponseHeader[] responseHeaders
        A list of possible headers provided alongside the response.
        Returns:
        a list of response headers.
        Default:
        {}
      • response

        java.lang.Class<?> response
        The type of the response body.
        Returns:
        The type
        Default:
        io.muserver.rest.ApiResponseObj.DEFAULT.class
      • contentType

        java.lang.String[] contentType
        The content type for this code, if different from the default
        Returns:
        A content type such as text/plain
        Default:
        {}
      • example

        java.lang.String example
        An example return value
        Returns:
        An example value
        Default:
        ""