Class Items


public class Items extends SwaggerElement
A limited subset of JSON-Schema's items object.

The Items Object is a limited subset of JSON-Schema's items object for Swagger 2.0. It is used by parameter definitions that are not located in "body" to describe the type of items in an array. This is particularly useful for query parameters, path parameters, and header parameters that accept arrays.

Swagger Specification:

The Items Object supports the following fields from JSON Schema:

  • type (string, REQUIRED) - The data type. Values: "string", "number", "integer", "boolean", "array"
  • format (string) - The format modifier (e.g., "int32", "int64", "float", "double", "date", "date-time")
  • items (Items) - Required if type is "array". Describes the type of items in the array
  • collectionFormat (string) - How multiple values are formatted. Values: "csv", "ssv", "tsv", "pipes", "multi"
  • default (any) - The default value
  • maximum (number), exclusiveMaximum (boolean), minimum (number), exclusiveMinimum (boolean) - Numeric constraints
  • maxLength (integer), minLength (integer), pattern (string) - String constraints
  • maxItems (integer), minItems (integer), uniqueItems (boolean) - Array constraints
  • enum (array) - Possible values for this item
  • multipleOf (number) - Must be a multiple of this value
Example:

// Construct using SwaggerBuilder. Items items = items("string").minLength(2); // Serialize using JsonSerializer. String json = Json.from(items); // Or just use toString() which does the same as above. json = items.toString();

// Output { "type": "string", "minLength": 2 }

See Also:
  • Constructor Details

    • Items

      public Items()
      Default constructor.
    • Items

      public Items(Items copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The object to copy.
  • Method Details

    • copy

      public Items copy()
      Make a deep copy of this object.
      Returns:
      A deep copy of this object.
    • strict

      public Items strict()
      Description copied from class: SwaggerElement
      Sets strict mode on this bean.
      Overrides:
      strict in class SwaggerElement
      Returns:
      This object.
    • strict

      public Items strict(Object value)
      Sets strict mode on this bean.
      Overrides:
      strict in class SwaggerElement
      Parameters:
      value - The new value for this property.
      Non-boolean values will be converted to boolean using Boolean.valueOf(value.toString()).
      Can be null (interpreted as false).
      Returns:
      This object.
    • getCollectionFormat

      Bean property getter: collectionFormat.

      Determines the format of the array if type array is used.

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

      Bean property setter: collectionFormat.

      Determines the format of the array if type array is used.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "csv" (default) - comma separated values foo,bar.
      • "ssv" - space separated values foo bar.
      • "tsv" - tab separated values foo\tbar.
      • "pipes" - pipe separated values foo|bar.

      Can be null to unset the property.
      Returns:
      This object.
    • getDefault

      public Object getDefault()
      Bean property getter: default.

      Declares the value of the item that the server will use if none is provided.

      Notes:
      • "default" has no meaning for required items.
      • Unlike JSON Schema this value MUST conform to the defined type for the data type.
      Returns:
      The property value, or null if it is not set.
    • setDefault

      public Items setDefault(Object value)
      Bean property setter: default.

      Declares the value of the item that the server will use if none is provided.

      Notes:
      • "default" has no meaning for required items.
      • Unlike JSON Schema this value MUST conform to the defined type for the data type.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getEnum

      public Set<Object> getEnum()
      Bean property getter: enum.
      Returns:
      The property value, or null if it is not set.
    • setEnum

      public Items setEnum(Collection<Object> value)
      Bean property setter: enum.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • setEnum

      public Items setEnum(Object... value)
      Bean property setter: enum.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • addEnum

      public Items addEnum(Object... value)
      Bean property fluent setter: enum.
      Parameters:
      value - The new value for this property.
      String values can be JSON arrays.
      Returns:
      This object.
    • getExclusiveMaximum

      Bean property getter: exclusiveMaximum.
      Returns:
      The property value, or null if it is not set.
    • setExclusiveMaximum

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

      Bean property getter: exclusiveMinimum.
      Returns:
      The property value, or null if it is not set.
    • setExclusiveMinimum

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

      public String getFormat()
      Bean property getter: format.

      The extending format for the previously mentioned type.

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

      public Items setFormat(String value)
      Bean property setter: format.

      The extending format for the previously mentioned type.

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

      public Items getItems()
      Bean property getter: items.

      Describes the type of items in the array.

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

      public Items setItems(Items value)
      Bean property setter: items.

      Describes the type of items in the array.

      Parameters:
      value - The new value for this property.
      Property value is required if type is "array".
      Can be null to unset the property.
      Returns:
      This object.
    • getMaximum

      public Number getMaximum()
      Bean property getter: maximum.
      Returns:
      The property value, or null if it is not set.
    • setMaximum

      public Items setMaximum(Number value)
      Bean property setter: maximum.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMaxItems

      public Integer getMaxItems()
      Bean property getter: maxItems.
      Returns:
      The property value, or null if it is not set.
    • setMaxItems

      public Items setMaxItems(Integer value)
      Bean property setter: maxItems.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMaxLength

      Bean property getter: maxLength.
      Returns:
      The property value, or null if it is not set.
    • setMaxLength

      public Items setMaxLength(Integer value)
      Bean property setter: maxLength.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMinimum

      public Number getMinimum()
      Bean property getter: minimum.
      Returns:
      The property value, or null if it is not set.
    • setMinimum

      public Items setMinimum(Number value)
      Bean property setter: minimum.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMinItems

      public Integer getMinItems()
      Bean property getter: minItems.
      Returns:
      The property value, or null if it is not set.
    • setMinItems

      public Items setMinItems(Integer value)
      Bean property setter: minItems.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMinLength

      Bean property getter: minLength.
      Returns:
      The property value, or null if it is not set.
    • setMinLength

      public Items setMinLength(Integer value)
      Bean property setter: minLength.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getMultipleOf

      Bean property getter: multipleOf.
      Returns:
      The property value, or null if it is not set.
    • setMultipleOf

      public Items setMultipleOf(Number value)
      Bean property setter: multipleOf.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getPattern

      public String getPattern()
      Bean property getter: pattern.
      Returns:
      The property value, or null if it is not set.
    • setPattern

      public Items setPattern(String value)
      Bean property setter: pattern.
      Parameters:
      value - The new value for this property.
      This string SHOULD be a valid regular expression.
      Can be null to unset the property.
      Returns:
      This object.
    • getRef

      @Beanp("$ref") public String getRef()
      Bean property getter: $ref.
      Returns:
      The property value, or null if it is not set.
    • setRef

      @Beanp("$ref") public Items setRef(String value)
      Bean property setter: $ref.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getType

      public String getType()
      Bean property getter: type.

      The internal type of the array.

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

      public Items setType(String value)
      Bean property setter: type.

      The internal type of the array.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "string"
      • "number"
      • "integer"
      • "boolean"
      • "array"

      Property value is required.
      Can be null to unset the property.
      Returns:
      This object.
    • getUniqueItems

      Bean property getter: uniqueItems.
      Returns:
      The property value, or null if it is not set.
    • setUniqueItems

      public Items setUniqueItems(Boolean value)
      Bean property setter: uniqueItems.
      Parameters:
      value - The new value for this property.
      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 Items 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. Must not be null.
      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 Items 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.