Class ResponseInfo

java.lang.Object
org.apache.juneau.dto.swagger.SwaggerElement
org.apache.juneau.dto.swagger.ResponseInfo

@Bean(properties="description,schema,headers,examples,*") public class ResponseInfo extends SwaggerElement
Describes a single response from an API Operation.
Example:

// Construct using SwaggerBuilder. ResponseInfo info = responseInfo("A complex object array response") .schema( schemaInfo .type("array") .items( items() .set("$ref", "#/definitions/VeryComplexType") ) ); // Serialize using JsonSerializer. String json = JsonSerializer.DEFAULT.toString(info); // Or just use toString() which does the same as above. json = info.toString();

// Output { "description": "A complex object array response", "schema": { "type": "array", "items": { "$ref": "#/definitions/VeryComplexType" } } }

See Also:
  • Constructor Details

  • Method Details

    • copy

      public ResponseInfo copy()
      Make a deep copy of this object.
      Returns:
      A deep copy of this object.
    • copyFrom

      Copies any non-null fields from the specified object to this object.
      Parameters:
      r - The object to copy fields from.
      Can be null.
      Returns:
      This object.
    • getDescription

      Bean property getter: description.

      A short description of the response.

      Returns:
      The property value, or null if it is not set.
    • setDescription

      Bean property setter: description.

      A short description of the response.

      Parameters:
      value - The new value for this property.
      GFM syntax can be used for rich text representation.
      Property value is required.
      Returns:
      This object.
    • getExamples

      Bean property getter: examples.

      An example of the response message.

      Returns:
      The property value, or null if it is not set.
    • setExamples

      Bean property setter: examples.

      An example of the response message.

      Parameters:
      value - The new value for this property.
      Keys must be MIME-type strings.
      Can be null to unset the property.
      Returns:
      This object.
    • addExample

      public ResponseInfo addExample(String mimeType, Object example)
      Bean property appender: examples.

      Adds a single value to the examples property.

      Parameters:
      mimeType - The mime-type string.
      example - The example.
      Returns:
      This object.
    • getHeaders

      Bean property getter: headers.

      A list of headers that are sent with the response.

      Returns:
      The property value, or null if it is not set.
    • setHeaders

      Bean property setter: headers.

      A list of headers that are sent with the response.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • addHeader

      public ResponseInfo addHeader(String name, HeaderInfo header)
      Bean property appender: headers.
      Parameters:
      name - The header name.
      header - The header descriptions
      Returns:
      This object.
    • getHeader

      public HeaderInfo getHeader(String name)
      Returns the header information with the specified name.
      Parameters:
      name - The header name.
      Returns:
      The header info, or null if not found.
    • getSchema

      Bean property getter: schema.

      A definition of the response structure.

      Returns:
      The property value, or null if it is not set.
    • setSchema

      Bean property setter: schema.

      A definition of the response structure.

      Parameters:
      value - The new value for this property.
      It can be a primitive, an array or an object.
      Can be null to unset the property.
      Returns:
      This object.
    • get

      public <T> T get(String property, Class<T> type)
      Description copied from class: SwaggerElement
      Generic property getter.

      Can be used to retrieve non-standard Swagger fields such as "$ref".

      Overrides:
      get in class SwaggerElement
      Type Parameters:
      T - The datatype to cast the value to.
      Parameters:
      property - The property name to retrieve.
      type - The datatype to cast the value to.
      Returns:
      The property value, or null if the property does not exist or is not set.
    • set

      public ResponseInfo set(String property, Object value)
      Description copied from class: SwaggerElement
      Generic property setter.

      Can be used to set non-standard Swagger fields such as "$ref".

      Overrides:
      set in class SwaggerElement
      Parameters:
      property - The property name to set.
      value - The new value for the property.
      Returns:
      This object.
    • keySet

      public Set<String> keySet()
      Description copied from class: SwaggerElement
      Returns all the keys on this element.
      Overrides:
      keySet in class SwaggerElement
      Returns:
      All the keys on this element.
      Never null.
    • resolveRefs

      public ResponseInfo resolveRefs(Swagger swagger, Deque<String> refStack, int maxDepth)
      Resolves any "$ref" attributes in this element.
      Parameters:
      swagger - The swagger document containing the definitions.
      refStack - Keeps track of previously-visited references so that we don't cause recursive loops.
      maxDepth - The maximum depth to resolve references.
      After that level is reached, $ref references will be left alone.
      Useful if you have very complex models and you don't want your swagger page to be overly-complex.
      Returns:
      This object with references resolved.
      May or may not be the same object.