Class SchemaInfo

java.lang.Object
org.apache.juneau.dto.openapi3.OpenApiElement
org.apache.juneau.dto.openapi3.SchemaInfo

@Bean(properties="format,title,description,default,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,maxProperties,minProperties,required,enum,type,items,allOf,anyOf,oneOf,properties,additionalProperties,not,discriminator,readOnly,writeOnly,nullable,deprecated,xml,externalDocs,example,$ref,*") public class SchemaInfo extends OpenApiElement
The Schema Object allows the definition of input and output data types.

These types can be objects, but also primitives and arrays. This object is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it. On top of this subset, there are extensions provided by this specification to allow for more complete documentation.

Further information about the properties can be found in JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here.

Example:

// Construct using SwaggerBuilder. SchemaInfo x = schemaInfo() .type("string") .title("foo") // Serialize using JsonSerializer. String json = JsonSerializer.DEFAULT.toString(x); // Or just use toString() which does the same as above. String json = x.toString();

// Output { "type": "string", "title": "foo" }

  • Constructor Details

    • SchemaInfo

      public SchemaInfo()
      Default constructor.
    • SchemaInfo

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

    • copy

      public SchemaInfo copy()
      Make a deep copy of this object.
      Returns:
      A deep copy of this object.
    • getFormat

      public String getFormat()
      Bean property getter: format.
      Returns:
      The property value, or null if it is not set.
    • setFormat

      public SchemaInfo setFormat(String value)
      Bean property setter: format.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Formats defined by the OAS include:
      • "int32"
      • "int64"
      • "float"
      • "double"
      • "byte"
      • "binary"
      • "date"
      • "date-time"
      • "password"
      Returns:
      This object
    • getTitle

      public String getTitle()
      Bean property getter: title.
      Returns:
      The property value, or null if it is not set.
    • setTitle

      public SchemaInfo setTitle(String value)
      Bean property setter: title.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getDescription

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

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

      public Object getDefault()
      Bean property getter: default.

      Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.

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

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

      Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.

      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

      Bean property setter: multipleOf.
      Parameters:
      value - The new value for this property.
      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 SchemaInfo 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
    • 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
    • getMinimum

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

      public SchemaInfo 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
    • 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
    • getMaxLength

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

      Bean property setter: maxLength.
      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

      Bean property setter: minLength.
      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 SchemaInfo setPattern(String value)
      Bean property setter: pattern.

      This string SHOULD be a valid regular expression.

      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 SchemaInfo 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
    • getMinItems

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

      public SchemaInfo 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
    • getUniqueItems

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

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

      public Boolean getNullable()
      Bean property getter: uniqueItems.
      Returns:
      The property value, or null if it is not set.
    • setNullable

      public SchemaInfo setNullable(Boolean value)
      Bean property setter: nullable.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getMaxProperties

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

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

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

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

      public List<String> getRequired()
      Bean property getter: required.

      The list of required properties.

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

      Bean property setter: required.

      The list of required properties.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "http"
      • "https"
      • "ws"
      • "wss"

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

      public SchemaInfo addRequired(String... values)
      Parameters:
      values - The new value for this property.
      Valid types:
      • Collection<String>
      • String - JSON array representation of Collection<String>
        Example:

        schemes("['scheme1','scheme2']");

      • String - Individual values
        Example:

        schemes("scheme1, "scheme2");

      Returns:
      This object
    • getEnum

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

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

      public SchemaInfo addEnum(Object... values)
      Adds one or more values to the enum property.
      Parameters:
      values - The values to add to this property.
      Valid types:
      • Object
      • Collection<Object>
      • String - JSON array representation of Collection<Object>
        Example:

        _enum("['foo','bar']");

      • String - Individual values
        Example:

        _enum("foo", "bar");


      Ignored if null.
      Returns:
      This object
    • getType

      public String getType()
      Bean property getter: type.
      Returns:
      The property value, or null if it is not set.
    • setType

      public SchemaInfo setType(String value)
      Bean property setter: type.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Possible values include:
      • "object"
      • "string"
      • "number"
      • "integer"
      • "boolean"
      • "array"
      • "file"
      Returns:
      This object
    • getItems

      public Items getItems()
      Bean property getter: items.
      Returns:
      The property value, or null if it is not set.
    • setItems

      public SchemaInfo setItems(Items value)
      Bean property setter: items.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getAllOf

      public List<Object> getAllOf()
      Bean property getter: allOf.
      Returns:
      The property value, or null if it is not set.
    • setAllOf

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

      public SchemaInfo addAllOf(Object... values)
      Adds one or more values to the allOf property.
      Parameters:
      values - The values to add to this property.
      Valid types:
      • Object
      • Collection<Object>
      • String - JSON array representation of Collection<Object>
        Example:

        allOf("['foo','bar']");

      • String - Individual values
        Example:

        allOf("foo", "bar");


      Ignored if null.
      Returns:
      This object
    • getAnyOf

      public List<Object> getAnyOf()
      Bean property getter: allOf.
      Returns:
      The property value, or null if it is not set.
    • setAnyOf

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

      public SchemaInfo addAnyOf(Object... values)
      Adds one or more values to the allOf property.
      Parameters:
      values - The values to add to this property.
      Valid types:
      • Object
      • Collection<Object>
      • String - JSON array representation of Collection<Object>
        Example:

        allOf("['foo','bar']");

      • String - Individual values
        Example:

        allOf("foo", "bar");


      Ignored if null.
      Returns:
      This object
    • getOneOf

      public List<Object> getOneOf()
      Bean property getter: allOf.
      Returns:
      The property value, or null if it is not set.
    • setOneOf

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

      public SchemaInfo addOneOf(Object... values)
      Adds one or more values to the allOf property.
      Parameters:
      values - The values to add to this property.
      Valid types:
      • Object
      • Collection<Object>
      • String - JSON array representation of Collection<Object>
        Example:

        allOf("['foo','bar']");

      • String - Individual values
        Example:

        allOf("foo", "bar");


      Ignored if null.
      Returns:
      This object
    • getProperties

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

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

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

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

      public SchemaInfo getNot()
      Bean property getter: not.
      Returns:
      The property value, or null if it is not set.
    • setNot

      public SchemaInfo setNot(SchemaInfo value)
      Bean property setter: not.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getDiscriminator

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

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

      public Boolean getReadOnly()
      Bean property getter: readOnly.
      Returns:
      The property value, or null if it is not set.
    • setReadOnly

      public SchemaInfo setReadOnly(Boolean value)
      Bean property setter: readOnly.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getWriteOnly

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

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

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

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

      public Xml getXml()
      Bean property getter: xml.
      Returns:
      The property value, or null if it is not set.
    • setXml

      public SchemaInfo setXml(Xml value)
      Bean property setter: xml.
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • getExternalDocs

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

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

      public Object getExample()
      Bean property getter: example.
      Returns:
      The property value, or null if it is not set.
    • setExample

      public SchemaInfo setExample(Object value)
      Bean property setter: example.
      Parameters:
      value - The new value for this property.
      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 SchemaInfo setRef(Object value)
      Bean property setter: $ref.
      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: OpenApiElement
      Generic property getter.

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

      Overrides:
      get in class OpenApiElement
      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 SchemaInfo set(String property, Object value)
      Description copied from class: OpenApiElement
      Generic property setter.

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

      Overrides:
      set in class OpenApiElement
      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: OpenApiElement
      Returns all the keys on this element.
      Overrides:
      keySet in class OpenApiElement
      Returns:
      All the keys on this element.
      Never null.
    • resolveRefs

      public SchemaInfo 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.