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 @Nullable String getTitle()
    • setTitle

      public Schema setTitle(@Nullable String title)
    • hasTitle

      public boolean hasTitle()
    • getDescription

      public @Nullable String getDescription()
    • setDescription

      public Schema setDescription(@Nullable String description)
    • hasDescription

      public boolean hasDescription()
    • getType

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

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

      public Schema addType(Schema.Type type)
    • hasType

      public boolean hasType()
    • getFormat

      public @Nullable String getFormat()
    • setFormat

      public Schema setFormat(@Nullable String format)
    • getExtendedType

      public @Nullable Object getExtendedType()
      Returns:
      Provider-specific type metadata, or null when none was supplied
    • setExtendedType

      public Schema setExtendedType(@Nullable Object extendedType)
      Set provider-specific type metadata used for source-specific Java type mapping.
      Parameters:
      extendedType - The provider-specific type metadata
      Returns:
      This schema
    • hasExtendedType

      public boolean hasExtendedType()
      Returns:
      Whether provider-specific type metadata is available
    • getSqlPrecision

      public @Nullable Integer getSqlPrecision()
      Returns:
      The provider-reported SQL precision, or null when not applicable
    • setSqlPrecision

      public Schema setSqlPrecision(@Nullable Integer sqlPrecision)
      Parameters:
      sqlPrecision - The provider-reported SQL precision
      Returns:
      This schema
    • getSqlScale

      @Nullable public @Nullable Integer getSqlScale()
      Returns:
      The provider-reported SQL scale, or null when not applicable
    • setSqlScale

      public Schema setSqlScale(@Nullable Integer sqlScale)
      Parameters:
      sqlScale - The provider-reported SQL scale
      Returns:
      This schema
    • getConstValue

      public @Nullable Object getConstValue()
    • setConstValue

      public Schema setConstValue(@Nullable Object constValue)
    • hasConstValue

      public boolean hasConstValue()
    • getEnumValues

      public @Nullable List<Object> getEnumValues()
    • setEnumValues

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

      public boolean isEnum()
    • getItems

      public @Nullable Schema getItems()
    • setItems

      public Schema setItems(@Nullable Schema items)
    • getProperties

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

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

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

      public boolean hasProperties()
    • getDefaultValue

      public @Nullable Object getDefaultValue()
    • setDefaultValue

      public Schema setDefaultValue(@Nullable Object defaultValue)
    • hasDefaultValue

      public boolean hasDefaultValue()
    • isNullable

      public @Nullable Boolean isNullable()
    • setNullable

      public Schema setNullable(boolean nullable)
    • isDeprecated

      public @Nullable Boolean isDeprecated()
    • setDeprecated

      public Schema setDeprecated(boolean deprecated)
    • isReadOnly

      public @Nullable Boolean isReadOnly()
    • setReadOnly

      public Schema setReadOnly(boolean readOnly)
    • isWriteOnly

      public @Nullable Boolean isWriteOnly()
    • setWriteOnly

      public Schema setWriteOnly(boolean writeOnly)
    • getExamples

      public @Nullable List<Object> getExamples()
    • setExamples

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

      public @Nullable Object getMultipleOf()
    • setMultipleOf

      public Schema setMultipleOf(@Nullable Object multipleOf)
    • getMaximum

      public @Nullable Object getMaximum()
    • setMaximum

      public Schema setMaximum(@Nullable Object maximum)
    • getMinimum

      public @Nullable Object getMinimum()
    • setMinimum

      public Schema setMinimum(@Nullable Object minimum)
    • getExclusiveMaximum

      public @Nullable Object getExclusiveMaximum()
    • setExclusiveMaximum

      public Schema setExclusiveMaximum(@Nullable Object exclusiveMaximum)
    • getExclusiveMinimum

      public @Nullable Object getExclusiveMinimum()
    • setExclusiveMinimum

      public Schema setExclusiveMinimum(@Nullable Object exclusiveMinimum)
    • getMaxLength

      public @Nullable Integer getMaxLength()
    • setMaxLength

      public Schema setMaxLength(@Nullable Integer maxLength)
    • getMinLength

      public @Nullable Integer getMinLength()
    • setMinLength

      public Schema setMinLength(@Nullable Integer minLength)
    • getPattern

      public @Nullable String getPattern()
    • setPattern

      public Schema setPattern(@Nullable String pattern)
    • getMaxItems

      public @Nullable Integer getMaxItems()
    • setMaxItems

      public Schema setMaxItems(@Nullable Integer maxItems)
    • getMinItems

      public @Nullable Integer getMinItems()
    • setMinItems

      public Schema setMinItems(@Nullable Integer minItems)
    • isUniqueItems

      public @Nullable Boolean isUniqueItems()
    • setUniqueItems

      public Schema setUniqueItems(boolean uniqueItems)
    • getMaxContains

      public @Nullable Integer getMaxContains()
    • setMaxContains

      public Schema setMaxContains(@Nullable Integer maxContains)
    • getMinContains

      public @Nullable Integer getMinContains()
    • setMinContains

      public Schema setMinContains(@Nullable Integer minContains)
    • getContains

      public @Nullable Schema getContains()
    • setContains

      public Schema setContains(@Nullable Schema contains)
    • getRequired

      public @Nullable List<String> getRequired()
    • setRequired

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

      public Schema addRequired(String requiredProperty)
    • hasRequired

      public boolean hasRequired()
    • getAdditionalProperties

      public @Nullable Schema getAdditionalProperties()
    • setAdditionalProperties

      public Schema setAdditionalProperties(@Nullable Schema additionalProperties)
    • hasAdditionalProperties

      public boolean hasAdditionalProperties()
    • getOneOf

      public @Nullable List<Schema> getOneOf()
    • setOneOf

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

      public Schema addOneOf(Schema one)
    • hasOneOf

      public boolean hasOneOf()
    • getAllOf

      public @Nullable List<Schema> getAllOf()
    • setAllOf

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

      public Schema addAllOf(Schema one)
    • hasAllOf

      public boolean hasAllOf()
    • mergeAllOf

      public void mergeAllOf()
    • getAnyOf

      public @Nullable List<Schema> getAnyOf()
    • setAnyOf

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

      public Schema addAnyOf(Schema one)
    • hasAnyOf

      public boolean hasAnyOf()
    • get$schema

      public @Nullable String get$schema()
    • set$schema

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

      public @Nullable String get$id()
    • set$id

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

      public @Nullable String get$ref()
    • set$ref

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

      public boolean has$ref()
    • get$defs

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

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

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

      public boolean has$defs()
    • getDiscriminator

      public @Nullable Schema.SchemaDiscriminator getDiscriminator()
    • setDiscriminator

      public void setDiscriminator(@Nullable 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 @Nullable Schema getNot()
    • setNot

      public Schema setNot(@Nullable Schema not)
    • merge

      public Schema merge(@Nullable 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