Class JsonSchema
- Author:
- Pavel Bodiachevskii
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription@Nullable JsonSchemaThe value of "additionalItems" MUST be a valid JSON Schema.@Nullable JsonSchemaThe value of "additionalProperties" MUST be a valid JSON Schema.@Nullable List<JsonSchema> This keyword's value MUST be a non-empty array.@Nullable List<JsonSchema> This keyword's value MUST be a non-empty array.@Nullable ObjectThe value of this keyword MAY be of any type, including null.@Nullable JsonSchemaThe value of this keyword MUST be a valid JSON Schema.@Nullable ObjectThere are no restrictions placed on the value of this keyword.@Nullable Object[CREF1] - This keyword may be split into two, with the variation that uses an array of property names rather than a subschema getting a new name.@Nullable StringThe value of these keyword MUST be a string.@Nullable JsonSchemaThis keyword's value MUST be a valid JSON Schema.The value of this keyword MUST be an array.The value of this keyword MUST be an array.@Nullable BigDecimalThe value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.@Nullable BigDecimalThe value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.@Nullable StringThe "format" keyword functions as both an annotation (Section 3.3) and as an assertion (Section 3.2).@Nullable StringJSON Schema ID.@Nullable JsonSchemaThis keyword's value MUST be a valid JSON Schema.@Nullable ObjectThe value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas.@Nullable BigDecimalThe value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.@Nullable @Min(value=0L,message="The value of \"maxItems\" MUST be a non-negative integer.") IntegerThe value of this keyword MUST be a non-negative integer.@Nullable @Min(value=0L,message="The value of \"maxLength\" MUST be a non-negative integer.") IntegerThe value of this keyword MUST be a non-negative integer.@Nullable @Min(value=0L,message="The value of \"maxProperties\" MUST be a non-negative integer.") IntegerThe value of this keyword MUST be a non-negative integer.@Nullable BigDecimalThe value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.@Nullable IntegerThe value of this keyword MUST be a non-negative integer.@Nullable @Min(value=0L,message="The value of \"minLength\" MUST be a non-negative integer.") IntegerThe value of this keyword MUST be a non-negative integer.@Nullable @Min(value=0L,message="The value of \"minProperties\" MUST be a non-negative integer.") IntegerThe value of this keyword MUST be a non-negative integer.@Nullable @Min(value=1L,message="The value of \"multipleOf\" MUST be a number, strictly greater than 0.") NumberThe value of "multipleOf" MUST be a number, strictly greater than 0.@Nullable JsonSchemaThis keyword's value MUST be a valid JSON Schema.@Nullable List<JsonSchema> This keyword's value MUST be a non-empty array.@Nullable StringThe value of this keyword MUST be a string.@Nullable Map<String, JsonSchema> The value of "patternProperties" MUST be an object.The value of "properties" MUST be an object.@Nullable JsonSchemaThe value of "propertyNames" MUST be a valid JSON Schema.@Nullable BooleanThe value of this keyword MUST be a boolean.The value of this keyword MUST be an array.@Nullable StringJSON Schema to use for validation.@Nullable JsonSchemaThis keyword's value MUST be a valid JSON Schema.@Nullable StringThe value of these keyword MUST be a string.@Nullable ObjectThe value of this keyword MUST be either a string or an array.@Nullable BooleanThe value of this keyword MUST be a boolean.@Nullable BooleanThe value of this keyword MUST be a boolean. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
id
JSON Schema ID.format: uri-reference
-
schema
@Nullable @JsonPropertyDescription("JSON Schema to use for validation.") public @Nullable String schemaJSON Schema to use for validation.format: uri
-
type
The value of this keyword MUST be either a string or an array.If it is an array, elements of the array MUST be strings and MUST be unique.
String values MUST be one of the six primitive types:
- null
- boolean
- object
- array
- number
- string
or "integer" which matches any number with a zero fractional part.
An instance validates if and only if the instance is in any of the sets listed for this keyword.
- See Also:
-
enumValue
@Nullable @JsonPropertyDescription("JSON Schema enum values.") public @Nullable List<Object> enumValueThe value of this keyword MUST be an array.This array SHOULD have at least one element. Elements in the array SHOULD be unique.
An instance validates successfully against this keyword if its value is equal to one of the elements in this keyword's array value.
Elements in the array might be of any value, including null.- See Also:
-
constValue
The value of this keyword MAY be of any type, including null.An instance validates successfully against this keyword if its value is equal to the value of the keyword.
- See Also:
-
multipleOf
@Nullable @Min(value=1L, message="The value of \"multipleOf\" MUST be a number, strictly greater than 0.") public @Nullable @Min(value=1L,message="The value of \"multipleOf\" MUST be a number, strictly greater than 0.") Number multipleOfThe value of "multipleOf" MUST be a number, strictly greater than 0.A numeric instance is valid only if division by this keyword's value results in an integer.
- See Also:
-
maximum
The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".
- See Also:
-
exclusiveMaximum
The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.
If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".- See Also:
-
minimum
The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.
If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".- See Also:
-
exclusiveMinimum
The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.
If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".- See Also:
-
maxLength
@Nullable @Min(value=0L, message="The value of \"maxLength\" MUST be a non-negative integer.") public @Nullable @Min(value=0L,message="The value of \"maxLength\" MUST be a non-negative integer.") Integer maxLengthThe value of this keyword MUST be a non-negative integer.A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].
- See Also:
-
minLength
@Nullable @Min(value=0L, message="The value of \"minLength\" MUST be a non-negative integer.") public @Nullable @Min(value=0L,message="The value of \"minLength\" MUST be a non-negative integer.") Integer minLengthThe value of this keyword MUST be a non-negative integer.A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].
Omitting this keyword has the same behavior as a value of 0.
- See Also:
-
pattern
The value of this keyword MUST be a string.This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect.
A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.
- See Also:
-
items
The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas.This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.
If "items" is a schema, validation succeeds if all elements in the array successfully validate against that schema.
If "items" is an array of schemas, validation succeeds if each element of the instance validates against the schema at the same position, if any.
Omitting this keyword has the same behavior as an empty schema.
- See Also:
-
additionalItems
The value of "additionalItems" MUST be a valid JSON Schema.This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.
If "items" is an array of schemas, validation succeeds if every instance element at a position greater than the size of "items" validates against "additionalItems".
Otherwise, "additionalItems" MUST be ignored, as the "items" schema (possibly the default value of an empty schema) is applied to all elements.
Omitting this keyword has the same behavior as an empty schema.
- See Also:
-
maxItems
@Nullable @Min(value=0L, message="The value of \"maxItems\" MUST be a non-negative integer.") public @Nullable @Min(value=0L,message="The value of \"maxItems\" MUST be a non-negative integer.") Integer maxItemsThe value of this keyword MUST be a non-negative integer.An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.
- See Also:
-
minItems
The value of this keyword MUST be a non-negative integer.An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.
Omitting this keyword has the same behavior as a value of 0.
- See Also:
-
uniqueItems
The value of this keyword MUST be a boolean.If this keyword has boolean value false, the instance validates successfully.
If it has boolean value true, the instance validates successfully if all of its elements are unique.
Omitting this keyword has the same behavior as a value of false.
- See Also:
-
contains
The value of this keyword MUST be a valid JSON Schema.
An array instance is valid against "contains" if at least one of its elements is valid against the given schema.- See Also:
-
maxProperties
@Nullable @Min(value=0L, message="The value of \"maxProperties\" MUST be a non-negative integer.") public @Nullable @Min(value=0L,message="The value of \"maxProperties\" MUST be a non-negative integer.") Integer maxPropertiesThe value of this keyword MUST be a non-negative integer.An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.
- See Also:
-
minProperties
@Nullable @Min(value=0L, message="The value of \"minProperties\" MUST be a non-negative integer.") public @Nullable @Min(value=0L,message="The value of \"minProperties\" MUST be a non-negative integer.") Integer minPropertiesThe value of this keyword MUST be a non-negative integer.An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.
Omitting this keyword has the same behavior as a value of 0.
- See Also:
-
required
The value of this keyword MUST be an array. Elements of this array, if any, MUST be strings, and MUST be unique.An object instance is valid against this keyword if every item in the array is the name of a property in the instance.
Omitting this keyword has the same behavior as an empty array.
- See Also:
-
properties
The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.
Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema.
Omitting this keyword has the same behavior as an empty object.
- See Also:
-
patternProperties
The value of "patternProperties" MUST be an object.Each property name of this object SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect.
Each property value of this object MUST be a valid JSON Schema.
This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation of the primitive instance type against this keyword always succeeds.
Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.
Omitting this keyword has the same behavior as an empty object.
- See Also:
-
additionalProperties
The value of "additionalProperties" MUST be a valid JSON Schema.This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.
Validation with "additionalProperties" applies only to the child values of instance names that do not match any names in "properties", and do not match any regular expression in "patternProperties".
For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema.
Omitting this keyword has the same behavior as an empty schema.
- See Also:
-
dependencies
[CREF1] - This keyword may be split into two, with the variation that uses an array of property names rather than a subschema getting a new name. The dual behavior is confusing and relatively difficult to implement. In the previous draft, we proposed dropping the keyword altogether, or dropping one of its forms, but we received feedback in support of keeping it. See issues #442 and #528 at https://github.com/json-schema-org/json-schema-spec/issues for further discussion. Further feedback is encouraged.
This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST be an array or a valid JSON Schema.
If the dependency value is a subschema, and the dependency key is a property in the instance, the entire instance must validate against the dependency value.
If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST be unique.
If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.
Omitting this keyword has the same behavior as an empty object.
- See Also:
-
propertyNames
The value of "propertyNames" MUST be a valid JSON Schema.If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema.
Note the property name that the schema is testing will always be a string.
Omitting this keyword has the same behavior as an empty schema.
- See Also:
-
ifValue
This keyword's value MUST be a valid JSON Schema.This validation outcome of this keyword's subschema has no direct effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated.
Instances that successfully validate against this keyword's subschema MUST also be valid against the subschema value of the "then" keyword, if present.
Instances that fail to validate against this keyword's subschema MUST also be valid against the subschema value of the "else" keyword, if present.
If annotations (Section 3.3) are being collected, they are collected from this keyword's subschema in the usual way, including when the keyword is present without either "then" or "else".
-
thenValue
This keyword's value MUST be a valid JSON Schema.When "if" is present, and the instance successfully validates against its subschema, then valiation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.
This keyword has no effect when "if" is absent, or when the instance fails to validate against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.
-
elseValue
This keyword's value MUST be a valid JSON Schema.When "if" is present, and the instance fails to validate against its subschema, then valiation succeeds against this keyword if the instance successfully validates against this keyword's subschema.
This keyword has no effect when "if" is absent, or when the instance successfully validates against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.
-
allOf
This keyword's value MUST be a non-empty array.Each item of the array MUST be a valid JSON Schema.
An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
- See Also:
-
anyOf
This keyword's value MUST be a non-empty array.Each item of the array MUST be a valid JSON Schema.
An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value.
- See Also:
-
oneOf
This keyword's value MUST be a non-empty array.Each item of the array MUST be a valid JSON Schema.
An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.
- See Also:
-
not
This keyword's value MUST be a valid JSON Schema.An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.
- See Also:
-
format
The "format" keyword functions as both an annotation (Section 3.3) and as an assertion (Section 3.2).While no special effort is required to implement it as an annotation conveying semantic meaning, implementing validation is non-trivial.
- See Also:
-
title
The value of these keyword MUST be a string.This keywords can be used to decorate a user interface with information about the data produced by this user interface.
A title will preferably be short
- See Also:
-
description
The value of these keyword MUST be a string.This keywords can be used to decorate a user interface with information about the data produced by this user interface.
A description will provide explanation about the purpose of the instance described by this schema.
- See Also:
-
defaultValue
There are no restrictions placed on the value of this keyword. When multiple occurrences of this keyword are applicable to a single sub-instance, implementations SHOULD remove duplicates.This keyword can be used to supply a default JSON value associated with a particular schema.
It is RECOMMENDED that a default value be valid against the associated schema.
- See Also:
-
readOnly
The value of this keyword MUST be a boolean.When multiple occurrences of this keyword are applicable to a single sub-instance, the resulting value MUST be true if any occurrence specifies a true value, and MUST be false otherwise.
If "readOnly" has a value of boolean true, it indicates that the value of the instance is managed exclusively by the owning authority, and attempts by an application to modify the value of this property are expected to be ignored or rejected by that owning authority.
An instance document that is marked as "readOnly for the entire document MAY be ignored if sent to the owning authority, or MAY result in an error, at the authority's discretion.
For example, "readOnly" would be used to mark a database-generated serial number as read-only, while "writeOnly" would be used to mark a password input field.
This keyword can be used to assist in user interface instance generation. In particular, an application MAY choose to use a widget that hides input values as they are typed for write-only fields.
Omitting this keyword has the same behavior as values of false.
- See Also:
-
writeOnly
The value of this keyword MUST be a boolean.When multiple occurrences of this keyword are applicable to a single sub-instance, the resulting value MUST be true if any occurrence specifies a true value, and MUST be false otherwise.
If "writeOnly" has a value of boolean true, it indicates that the value is never present when the instance is retrieved from the owning authority. It can be present when sent to the owning authority to update or create the document (or the resource it represents), but it will not be included in any updated or newly created version of the instance.
An instance document that is marked as "writeOnly" for the entire document MAY be returned as a blank document of some sort, or MAY produce an error upon retrieval, or have the retrieval request ignored, at the authority's discretion.
This keyword can be used to assist in user interface instance generation. In particular, an application MAY choose to use a widget that hides input values as they are typed for write-only fields.
Omitting this keyword has the same behavior as values of false.
- See Also:
-
examples
The value of this keyword MUST be an array.There are no restrictions placed on the values within the array.
When multiple occurrences of this keyword are applicable to a single sub-instance, implementations MUST provide a flat array of all values rather than an array of arrays.
This keyword can be used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage.
It is RECOMMENDED that these values be valid against the associated schema.
Implementations MAY use the value(s) of "default", if present, as an additional example.
If "examples" is absent, "default" MAY still be used in this manner.
- See Also:
-
-
Constructor Details
-
JsonSchema
public JsonSchema()
-