Package io.micronaut.jsonschema.model
Class Schema
java.lang.Object
io.micronaut.jsonschema.model.Schema
A JSON schema.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Discriminator defines a property that can be used to distinguish between schemas that are defined as subtypes in code.static enum
The 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 Schema
array()
static Schema
bool()
get$defs()
get$id()
get$ref()
getAllOf()
getAnyOf()
getItems()
getNot()
getOneOf()
getTitle()
getType()
boolean
has$defs()
boolean
has$ref()
boolean
boolean
hasAllOf()
boolean
hasAnyOf()
boolean
boolean
boolean
boolean
boolean
hasOneOf()
boolean
boolean
boolean
hasTitle()
boolean
hasType()
static Schema
integer()
boolean
isEnum()
Merges the properties of the current schema with those of another schema.void
static Schema
number()
static Schema
object()
putProperty
(String name, Schema property) static Schema
set$schema
(String $schema) setAdditionalProperties
(Schema additionalProperties) setConstValue
(Object constValue) setContains
(Schema contains) setDefaultValue
(Object defaultValue) setDeprecated
(boolean deprecated) setDescription
(String description) void
setDiscriminator
(Schema.SchemaDiscriminator discriminator) setEnumValues
(List<Object> enumValues) setExamples
(List<Object> examples) setExclusiveMaximum
(Object exclusiveMaximum) setExclusiveMinimum
(Object exclusiveMinimum) setMaxContains
(Integer maxContains) setMaximum
(Object maximum) setMaxItems
(Integer maxItems) setMaxLength
(Integer maxLength) setMinContains
(Integer minContains) setMinimum
(Object minimum) setMinItems
(Integer minItems) setMinLength
(Integer minLength) setMultipleOf
(Object multipleOf) setNullable
(boolean nullable) setPattern
(String pattern) setProperties
(Map<String, Schema> properties) setReadOnly
(boolean readOnly) setRequired
(List<String> required) setType
(List<Schema.Type> type) setUniqueItems
(boolean uniqueItems) setWriteOnly
(boolean writeOnly) static Schema
string()
-
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
-
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
-