Class JsonSchema
java.lang.Object
com.fasterxml.jackson.module.jsonSchema.jakarta.JsonSchema
- Direct Known Subclasses:
HyperSchema, SimpleTypeSchema, UnionTypeSchema
The type wraps the json schema specification at :
Json JsonSchema
Draft
JSON (JavaScript Object Notation) JsonSchema defines the media type "application/schema+json", a JSON based format for defining the structure of JSON data. JSON JsonSchema provides a contract for what JSON data is required for a given application and how to interact with it. JSON JsonSchema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.
JSON (JavaScript Object Notation) JsonSchema is a JSON media type for defining the structure of JSON data. JSON JsonSchema provides a contract for what JSON data is required for a given application and how to interact with it. JSON JsonSchema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.An example JSON JsonSchema provided by the JsonSchema draft:
{
"name":"Product",
"properties":{
"id":{
"type":"number",
"description":"Product identifier",
"required":true
},
"name":{
"description":"Name of the product",
"type":"string",
"required":true
},
"price":{
"required":true,
"type": "number",
"minimum":0,
"required":true
},
"tags":{
"type":"array",
"items":{
"type":"string"
}
}
},
"links":[
{
"rel":"full",
"href":"{id}"
},
{
"rel":"comments",
"href":"comments/?id={id}"
}
]
}
- Author:
- jphelan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_equals(JsonSchema that) protected static <T> booleanarraysEqual(T[] arr1, T[] arr2) Attempt to return this JsonSchema as anAnySchemaAttempt to return this JsonSchema as anArraySchemaAttempt to return this JsonSchema as aBooleanSchemaDeprecated.Since 2.7Attempt to return this JsonSchema as aContainerTypeSchemaAttempt to return this JsonSchema as anIntegerSchemaAttempt to return this JsonSchema as aNullSchemaAttempt to return this JsonSchema as aNumberSchemaAttempt to return this JsonSchema as anObjectSchemaAttempt to return this JsonSchema as aSimpleTypeSchemaAttempt to return this JsonSchema as aStringSchemaAttempt to return this JsonSchema as anUnionTypeSchemaDeprecated.Since 2.7Attempt to return this JsonSchema as aValueTypeSchemavoidenrichWithBeanProperty(com.fasterxml.jackson.databind.BeanProperty beanProperty) Override this to add information specific to the property of bean For example, bean validation annotations could be used to specify value constraints in the schemabooleanprotected static booleanA utility method allowing to easily chain calls to equals() on members without taking any risk regarding the ternary operator precedence.get$ref()getId()abstract com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypesgetType()booleandetermine if this JsonSchema is anAnySchema.booleandetermine if this JsonSchema is anArraySchema.booleandetermine if this JsonSchema is anBooleanSchema.booleandetermine if this JsonSchema is anContainerTypeSchema.booleandetermine if this JsonSchema is anIntegerSchema.booleandetermine if this JsonSchema is anNullSchema.booleandetermine if this JsonSchema is anNumberSchema.booleandetermine if this JsonSchema is anObjectSchema.booleandetermine if this JsonSchema is anSimpleTypeSchema.booleandetermine if this JsonSchema is anStringSchema.booleandetermine if this JsonSchema is anUnionTypeSchema.booleandetermine if this JsonSchema is anValueTypeSchema.static JsonSchemaminimalForFormat(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes format) Create a schema which verifies only that an object is of the given format.voidvoidset$schema(String $schema) voidsetDescription(String description) voidsetDisallow(JsonSchema[] disallow) voidsetExtends(JsonSchema[] extendsextends) voidvoidsetReadonly(Boolean readonly) voidsetRequired(Boolean required)
-
Constructor Details
-
JsonSchema
protected JsonSchema()
-
-
Method Details
-
asAnySchema
-
asArraySchema
Attempt to return this JsonSchema as anArraySchema- Returns:
- this as an ArraySchema if possible, or null otherwise
-
asBooleanSchema
Attempt to return this JsonSchema as aBooleanSchema- Returns:
- this as a BooleanSchema if possible, or null otherwise
-
asContainerSchema
Deprecated.Since 2.7 -
asContainerTypeSchema
Attempt to return this JsonSchema as aContainerTypeSchema- Returns:
- this as an ContainerTypeSchema if possible, or null otherwise
- Since:
- 2.7
-
asIntegerSchema
Attempt to return this JsonSchema as anIntegerSchema- Returns:
- this as an IntegerSchema if possible, or null otherwise
-
asNullSchema
Attempt to return this JsonSchema as aNullSchema- Returns:
- this as a NullSchema if possible, or null otherwise
-
asNumberSchema
Attempt to return this JsonSchema as aNumberSchema- Returns:
- this as a NumberSchema if possible, or null otherwise
-
asObjectSchema
Attempt to return this JsonSchema as anObjectSchema- Returns:
- this as an ObjectSchema if possible, or null otherwise
-
asSimpleTypeSchema
Attempt to return this JsonSchema as aSimpleTypeSchema- Returns:
- this as a SimpleTypeSchema if possible, or null otherwise
-
asStringSchema
Attempt to return this JsonSchema as aStringSchema- Returns:
- this as a StringSchema if possible, or null otherwise
-
asUnionTypeSchema
Attempt to return this JsonSchema as anUnionTypeSchema- Returns:
- this as a UnionTypeSchema if possible, or null otherwise
-
asValueSchemaSchema
Deprecated.Since 2.7 -
asValueTypeSchema
Attempt to return this JsonSchema as aValueTypeSchema- Returns:
- this as a ValueTypeSchema if possible, or null otherwise
- Since:
- 2.7
-
getId
-
get$ref
-
get$schema
-
getDisallow
-
getExtends
-
getRequired
-
getReadonly
-
getDescription
-
getType
public abstract com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes getType() -
isAnySchema
public boolean isAnySchema()determine if this JsonSchema is anAnySchema.- Returns:
- true if this JsonSchema is an AnySchema, false otherwise
-
isArraySchema
public boolean isArraySchema()determine if this JsonSchema is anArraySchema.- Returns:
- true if this JsonSchema is an ArraySchema, false otherwise
-
isBooleanSchema
public boolean isBooleanSchema()determine if this JsonSchema is anBooleanSchema.- Returns:
- true if this JsonSchema is an BooleanSchema, false otherwise
-
isContainerTypeSchema
public boolean isContainerTypeSchema()determine if this JsonSchema is anContainerTypeSchema.- Returns:
- true if this JsonSchema is an ContainerTypeSchema, false otherwise
-
isIntegerSchema
public boolean isIntegerSchema()determine if this JsonSchema is anIntegerSchema.- Returns:
- true if this JsonSchema is an IntegerSchema, false otherwise
-
isNullSchema
public boolean isNullSchema()determine if this JsonSchema is anNullSchema.- Returns:
- true if this JsonSchema is an NullSchema, false otherwise
-
isNumberSchema
public boolean isNumberSchema()determine if this JsonSchema is anNumberSchema.- Returns:
- true if this JsonSchema is an NumberSchema, false otherwise
-
isObjectSchema
public boolean isObjectSchema()determine if this JsonSchema is anObjectSchema.- Returns:
- true if this JsonSchema is an ObjectSchema, false otherwise
-
isSimpleTypeSchema
public boolean isSimpleTypeSchema()determine if this JsonSchema is anSimpleTypeSchema.- Returns:
- true if this JsonSchema is an SimpleTypeSchema, false otherwise
-
isStringSchema
public boolean isStringSchema()determine if this JsonSchema is anStringSchema.- Returns:
- true if this JsonSchema is an StringSchema, false otherwise
-
isUnionTypeSchema
public boolean isUnionTypeSchema()determine if this JsonSchema is anUnionTypeSchema.- Returns:
- true if this JsonSchema is an UnionTypeSchema, false otherwise
-
isValueTypeSchema
public boolean isValueTypeSchema()determine if this JsonSchema is anValueTypeSchema.- Returns:
- true if this JsonSchema is an ValueTypeSchema, false otherwise
-
set$ref
-
set$schema
-
setDisallow
-
setExtends
-
setId
-
setRequired
-
setReadonly
-
setDescription
-
enrichWithBeanProperty
public void enrichWithBeanProperty(com.fasterxml.jackson.databind.BeanProperty beanProperty) Override this to add information specific to the property of bean For example, bean validation annotations could be used to specify value constraints in the schema- Parameters:
beanProperty-
-
minimalForFormat
public static JsonSchema minimalForFormat(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes format) Create a schema which verifies only that an object is of the given format.- Parameters:
format- the format to expect- Returns:
- the schema verifying the given format
-
equals
-
_equals
-
equals
-
arraysEqual
protected static <T> boolean arraysEqual(T[] arr1, T[] arr2)
-