Class Schema

java.lang.Object
io.micronaut.jsonschema.model.Schema

@Internal public final class Schema extends Object
A JSON schema.
  • Field Details

    • TRUE

      public static final Schema TRUE
      A true schema is a schema that would be valid for any instance. This is also equivalent to just an empty schema, as it has no restrictions then.
    • FALSE

      public static final Schema FALSE
      A false schema is a schema that would be invalid for any instance. This is also equivalent to not true.
    • THIS_SCHEMA_REF

      public static final String THIS_SCHEMA_REF
      See Also:
    • DEF_SCHEMA_REF_PREFIX

      public static final String DEF_SCHEMA_REF_PREFIX
      See Also:
    • ONE_OF_SCHEMA_REF_PREFIX

      public static final String ONE_OF_SCHEMA_REF_PREFIX
      See Also:
  • Constructor Details

    • Schema

      public Schema()
  • Method Details

    • getTitle

      public String getTitle()
    • setTitle

      public Schema setTitle(String title)
    • hasTitle

      public boolean hasTitle()
    • getDescription

      public String getDescription()
    • setDescription

      public Schema setDescription(String description)
    • hasDescription

      public boolean hasDescription()
    • getType

      public List<Schema.Type> getType()
    • setType

      public Schema setType(List<Schema.Type> type)
    • addType

      public Schema addType(Schema.Type type)
    • hasType

      public boolean hasType()
    • getFormat

      public String getFormat()
    • setFormat

      public Schema setFormat(String format)
    • getConstValue

      public Object getConstValue()
    • setConstValue

      public Schema setConstValue(Object constValue)
    • hasConstValue

      public boolean hasConstValue()
    • getEnumValues

      public List<Object> getEnumValues()
    • setEnumValues

      public Schema setEnumValues(List<Object> enumValues)
    • isEnum

      public boolean isEnum()
    • getItems

      public Schema getItems()
    • setItems

      public Schema setItems(Schema items)
    • getProperties

      public Map<String,Schema> getProperties()
    • setProperties

      public Schema setProperties(Map<String,Schema> properties)
    • putProperty

      public Schema putProperty(String name, Schema property)
    • hasProperties

      public boolean hasProperties()
    • getDefaultValue

      public Object getDefaultValue()
    • setDefaultValue

      public Schema setDefaultValue(Object defaultValue)
    • hasDefaultValue

      public boolean hasDefaultValue()
    • isNullable

      public Boolean isNullable()
    • setNullable

      public Schema setNullable(boolean nullable)
    • isDeprecated

      public Boolean isDeprecated()
    • setDeprecated

      public Schema setDeprecated(boolean deprecated)
    • isReadOnly

      public Boolean isReadOnly()
    • setReadOnly

      public Schema setReadOnly(boolean readOnly)
    • isWriteOnly

      public Boolean isWriteOnly()
    • setWriteOnly

      public Schema setWriteOnly(boolean writeOnly)
    • getExamples

      public List<Object> getExamples()
    • setExamples

      public Schema setExamples(List<Object> examples)
    • getMultipleOf

      public Object getMultipleOf()
    • setMultipleOf

      public Schema setMultipleOf(Object multipleOf)
    • getMaximum

      public Object getMaximum()
    • setMaximum

      public Schema setMaximum(Object maximum)
    • getMinimum

      public Object getMinimum()
    • setMinimum

      public Schema setMinimum(Object minimum)
    • getExclusiveMaximum

      public Object getExclusiveMaximum()
    • setExclusiveMaximum

      public Schema setExclusiveMaximum(Object exclusiveMaximum)
    • getExclusiveMinimum

      public Object getExclusiveMinimum()
    • setExclusiveMinimum

      public Schema setExclusiveMinimum(Object exclusiveMinimum)
    • getMaxLength

      public Integer getMaxLength()
    • setMaxLength

      public Schema setMaxLength(Integer maxLength)
    • getMinLength

      public Integer getMinLength()
    • setMinLength

      public Schema setMinLength(Integer minLength)
    • getPattern

      public String getPattern()
    • setPattern

      public Schema setPattern(String pattern)
    • getMaxItems

      public Integer getMaxItems()
    • setMaxItems

      public Schema setMaxItems(Integer maxItems)
    • getMinItems

      public Integer getMinItems()
    • setMinItems

      public Schema setMinItems(Integer minItems)
    • isUniqueItems

      public Boolean isUniqueItems()
    • setUniqueItems

      public Schema setUniqueItems(boolean uniqueItems)
    • getMaxContains

      public Integer getMaxContains()
    • setMaxContains

      public Schema setMaxContains(Integer maxContains)
    • getMinContains

      public Integer getMinContains()
    • setMinContains

      public Schema setMinContains(Integer minContains)
    • getContains

      public Schema getContains()
    • setContains

      public Schema setContains(Schema contains)
    • getRequired

      public List<String> getRequired()
    • setRequired

      public Schema setRequired(List<String> required)
    • addRequired

      public Schema addRequired(String requiredProperty)
    • hasRequired

      public boolean hasRequired()
    • getAdditionalProperties

      public Schema getAdditionalProperties()
    • setAdditionalProperties

      public Schema setAdditionalProperties(Schema additionalProperties)
    • hasAdditionalProperties

      public boolean hasAdditionalProperties()
    • getOneOf

      public List<Schema> getOneOf()
    • setOneOf

      public Schema setOneOf(List<Schema> oneOf)
    • addOneOf

      public Schema addOneOf(Schema one)
    • hasOneOf

      public boolean hasOneOf()
    • getAllOf

      public List<Schema> getAllOf()
    • setAllOf

      public Schema setAllOf(List<Schema> allOf)
    • addAllOf

      public Schema addAllOf(Schema one)
    • hasAllOf

      public boolean hasAllOf()
    • mergeAllOf

      public void mergeAllOf()
    • getAnyOf

      public List<Schema> getAnyOf()
    • setAnyOf

      public Schema setAnyOf(List<Schema> anyOf)
    • addAnyOf

      public Schema addAnyOf(Schema one)
    • hasAnyOf

      public boolean hasAnyOf()
    • get$schema

      public String get$schema()
    • set$schema

      public Schema set$schema(String $schema)
    • get$id

      public String get$id()
    • set$id

      public Schema set$id(String $id)
    • get$ref

      public String get$ref()
    • set$ref

      public Schema set$ref(String $ref)
    • has$ref

      public boolean has$ref()
    • get$defs

      public Map<String,Schema> get$defs()
    • set$defs

      public Schema set$defs(Map<String,Schema> $defs)
    • put$def

      public Schema put$def(String key, Schema $def)
    • has$defs

      public boolean has$defs()
    • getDiscriminator

      public Schema.SchemaDiscriminator getDiscriminator()
    • setDiscriminator

      public void setDiscriminator(Schema.SchemaDiscriminator discriminator)
    • hasDiscriminator

      public boolean hasDiscriminator()
    • string

      public static Schema string()
    • number

      public static Schema number()
    • integer

      public static Schema integer()
    • object

      public static Schema object()
    • array

      public static Schema array()
    • bool

      public static Schema bool()
    • reference

      public static Schema reference(String id)
    • getNot

      public Schema getNot()
    • setNot

      public Schema setNot(Schema not)
    • merge

      public Schema merge(Schema other)
      Merges the properties of the current schema with those of another schema. This method combines various attributes such as `$schema`, `$id`, `$ref`, discriminator, $defs, titles, types, constraints, and validation rules (e.g., `allOf`, `anyOf`, `oneOf`) from the provided schema into the current schema. If a property exists in both schemas, the value from the provided schema (`other`) is merged or replaces the existing value in the current schema based on the type of the property. In cases where collections are involved, unique values are added. The method is mainly used for merging the schemas inside an `allOf` into one.
      Parameters:
      other - the schema to merge with the current schema
      Returns:
      the current schema with merged properties