Class Schema
java.lang.Object
io.micronaut.jsonschema.model.Schema
A JSON schema.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordDiscriminator defines a property that can be used to distinguish between schemas that are defined as subtypes in code.static enumThe type of schema exactly matching a primitive JSON type. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRequired(String requiredProperty) addType(Schema.Type type) static Schemaarray()static Schemabool()get$defs()@Nullable Stringget$id()@Nullable Stringget$ref()@Nullable String@Nullable SchemagetAllOf()getAnyOf()@Nullable Object@Nullable Schema@Nullable Object@Nullable String@Nullable Schema.SchemaDiscriminator@Nullable Object@Nullable Object@Nullable Object@Nullable String@Nullable SchemagetItems()@Nullable Integer@Nullable Object@Nullable Integer@Nullable Integer@Nullable Integer@Nullable Object@Nullable Integer@Nullable Integer@Nullable Object@Nullable SchemagetNot()getOneOf()@Nullable String@Nullable Integer@Nullable Integer@Nullable StringgetTitle()@Nullable List<Schema.Type> getType()booleanhas$defs()booleanhas$ref()booleanbooleanhasAllOf()booleanhasAnyOf()booleanbooleanbooleanbooleanbooleanbooleanhasOneOf()booleanbooleanbooleanhasTitle()booleanhasType()static Schemainteger()@Nullable BooleanbooleanisEnum()@Nullable Boolean@Nullable Boolean@Nullable Boolean@Nullable BooleanMerges the properties of the current schema with those of another schema.voidstatic Schemanumber()static Schemaobject()putProperty(String name, Schema property) static Schemaset$schema(@Nullable String $schema) setAdditionalProperties(@Nullable Schema additionalProperties) setConstValue(@Nullable Object constValue) setContains(@Nullable Schema contains) setDefaultValue(@Nullable Object defaultValue) setDeprecated(boolean deprecated) setDescription(@Nullable String description) voidsetDiscriminator(@Nullable Schema.SchemaDiscriminator discriminator) setEnumValues(@Nullable List<Object> enumValues) setExamples(@Nullable List<Object> examples) setExclusiveMaximum(@Nullable Object exclusiveMaximum) setExclusiveMinimum(@Nullable Object exclusiveMinimum) setExtendedType(@Nullable Object extendedType) Set provider-specific type metadata used for source-specific Java type mapping.setMaxContains(@Nullable Integer maxContains) setMaximum(@Nullable Object maximum) setMaxItems(@Nullable Integer maxItems) setMaxLength(@Nullable Integer maxLength) setMinContains(@Nullable Integer minContains) setMinimum(@Nullable Object minimum) setMinItems(@Nullable Integer minItems) setMinLength(@Nullable Integer minLength) setMultipleOf(@Nullable Object multipleOf) setNullable(boolean nullable) setPattern(@Nullable String pattern) setProperties(@Nullable Map<String, Schema> properties) setReadOnly(boolean readOnly) setRequired(@Nullable List<String> required) setSqlPrecision(@Nullable Integer sqlPrecision) setSqlScale(@Nullable Integer sqlScale) setType(@Nullable List<Schema.Type> type) setUniqueItems(boolean uniqueItems) setWriteOnly(boolean writeOnly) static Schemastring()
-
Field Details
-
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
A false schema is a schema that would be invalid for any instance. This is also equivalent to not true. -
THIS_SCHEMA_REF
- See Also:
-
DEF_SCHEMA_REF_PREFIX
- See Also:
-
ONE_OF_SCHEMA_REF_PREFIX
- See Also:
-
-
Constructor Details
-
Schema
public Schema()
-
-
Method Details
-
getTitle
-
setTitle
-
hasTitle
public boolean hasTitle() -
getDescription
-
setDescription
-
hasDescription
public boolean hasDescription() -
getType
-
setType
-
addType
-
hasType
public boolean hasType() -
getFormat
-
setFormat
-
getExtendedType
- Returns:
- Provider-specific type metadata, or
nullwhen none was supplied
-
setExtendedType
-
hasExtendedType
public boolean hasExtendedType()- Returns:
- Whether provider-specific type metadata is available
-
getSqlPrecision
- Returns:
- The provider-reported SQL precision, or
nullwhen not applicable
-
setSqlPrecision
-
getSqlScale
- Returns:
- The provider-reported SQL scale, or
nullwhen not applicable
-
setSqlScale
-
getConstValue
-
setConstValue
-
hasConstValue
public boolean hasConstValue() -
getEnumValues
-
setEnumValues
-
isEnum
public boolean isEnum() -
getItems
-
setItems
-
getProperties
-
setProperties
-
putProperty
-
hasProperties
public boolean hasProperties() -
getDefaultValue
-
setDefaultValue
-
hasDefaultValue
public boolean hasDefaultValue() -
isNullable
-
setNullable
-
isDeprecated
-
setDeprecated
-
isReadOnly
-
setReadOnly
-
isWriteOnly
-
setWriteOnly
-
getExamples
-
setExamples
-
getMultipleOf
-
setMultipleOf
-
getMaximum
-
setMaximum
-
getMinimum
-
setMinimum
-
getExclusiveMaximum
-
setExclusiveMaximum
-
getExclusiveMinimum
-
setExclusiveMinimum
-
getMaxLength
-
setMaxLength
-
getMinLength
-
setMinLength
-
getPattern
-
setPattern
-
getMaxItems
-
setMaxItems
-
getMinItems
-
setMinItems
-
isUniqueItems
-
setUniqueItems
-
getMaxContains
-
setMaxContains
-
getMinContains
-
setMinContains
-
getContains
-
setContains
-
getRequired
-
setRequired
-
addRequired
-
hasRequired
public boolean hasRequired() -
getAdditionalProperties
-
setAdditionalProperties
-
hasAdditionalProperties
public boolean hasAdditionalProperties() -
getOneOf
-
setOneOf
-
addOneOf
-
hasOneOf
public boolean hasOneOf() -
getAllOf
-
setAllOf
-
addAllOf
-
hasAllOf
public boolean hasAllOf() -
mergeAllOf
public void mergeAllOf() -
getAnyOf
-
setAnyOf
-
addAnyOf
-
hasAnyOf
public boolean hasAnyOf() -
get$schema
-
set$schema
-
get$id
-
set$id
-
get$ref
-
set$ref
-
has$ref
public boolean has$ref() -
get$defs
-
set$defs
-
put$def
-
has$defs
public boolean has$defs() -
getDiscriminator
-
setDiscriminator
-
hasDiscriminator
public boolean hasDiscriminator() -
string
-
number
-
integer
-
object
-
array
-
bool
-
reference
-
getNot
-
setNot
-
merge
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
-