Class JsonSchema

java.lang.Object
org.apache.juneau.bean.jsonschema.JsonSchema
Direct Known Subclasses:
JsonSchemaProperty, JsonSchemaRef

@Bean(typeName="schema") public class JsonSchema extends Object
Represents a top-level schema object bean in the JSON-Schema core specification.

This implementation follows the JSON Schema Draft 2020-12 specification.

Example:

// Create a simple schema for a person object JsonSchema schema = new JsonSchema() .setIdUri("https://example.com/person.schema.json") .setSchemaVersionUri("https://json-schema.org/draft/2020-12/schema") .setTitle("Person") .setDescription("A person object") .setType(JsonType.OBJECT) .addProperties( new JsonSchemaProperty("firstName", JsonType.STRING) .setMinLength(1) .setMaxLength(50), new JsonSchemaProperty("lastName", JsonType.STRING) .setMinLength(1) .setMaxLength(50), new JsonSchemaProperty("age", JsonType.INTEGER) .setMinimum(0) .setExclusiveMaximum(150) ) .addRequired("firstName", "lastName"); // Serialize to JSON Schema String json = JsonSerializer.DEFAULT_SORTED.serialize(schema);

Output:

{ "$id": "https://example.com/person.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Person", "description": "A person object", "type": "object", "properties": { "firstName": { "type": "string", "minLength": 1, "maxLength": 50 }, "lastName": { "type": "string", "minLength": 1, "maxLength": 50 }, "age": { "type": "integer", "minimum": 0, "exclusiveMaximum": 150 } }, "required": ["firstName", "lastName"] }

Key Features:
  • Draft 2020-12 Support: Includes all properties from the latest JSON Schema specification
  • Backward Compatibility: Deprecated Draft 04 properties (like id and definitions) are still supported
  • Fluent API: All setter methods return this for method chaining
  • Type Safety: Uses enums and typed collections for validation
  • Serialization: Can be serialized to any format supported by Juneau (JSON, XML, HTML, etc.)
Common Use Cases:

1. Simple Type Constraints:

// String with length constraints JsonSchema schema = new JsonSchema() .setType(JsonType.STRING) .setMinLength(5) .setMaxLength(100) .setPattern("^[A-Za-z]+$");

2. Numeric Ranges:

// Number between 0 and 100 (exclusive) JsonSchema schema = new JsonSchema() .setType(JsonType.NUMBER) .setExclusiveMinimum(0) .setExclusiveMaximum(100) .setMultipleOf(0.5);

3. Enumerations:

// Status field with allowed values JsonSchema schema = new JsonSchema() .setType(JsonType.STRING) .addEnum("pending", "active", "completed");

4. Arrays:

// Array of strings with constraints JsonSchema schema = new JsonSchema() .setType(JsonType.ARRAY) .setItems(new JsonSchema().setType(JsonType.STRING)) .setMinItems(1) .setMaxItems(10) .setUniqueItems(true);

5. Conditional Schemas (Draft 07+):

// Different validation based on country JsonSchema schema = new JsonSchema() .setType(JsonType.OBJECT) .addProperties( new JsonSchemaProperty("country", JsonType.STRING), new JsonSchemaProperty("postalCode", JsonType.STRING) ) .setIf(new JsonSchema() .addProperties(new JsonSchemaProperty("country").setConst("USA")) ) .setThen(new JsonSchema() .addProperties(new JsonSchemaProperty("postalCode").setPattern("^[0-9]{5}$")) );

6. Reusable Definitions:

// Schema with reusable components using $defs JsonSchema schema = new JsonSchema() .setType(JsonType.OBJECT) .addDef("address", new JsonSchema() .setType(JsonType.OBJECT) .addProperties( new JsonSchemaProperty("street", JsonType.STRING), new JsonSchemaProperty("city", JsonType.STRING) ) ) .addProperties( new JsonSchemaProperty("billingAddress") .setRef("#/$defs/address"), new JsonSchemaProperty("shippingAddress") .setRef("#/$defs/address") );

Migration from Draft 04:
See Also:
  • Constructor Details

    • JsonSchema

      public JsonSchema()
      Default constructor.
  • Method Details

    • getName

      Bean property getter: name.

      This is an internal property used for tracking property names and is not part of the JSON Schema specification.

      Returns:
      The value of the name property on this bean, or null if it is not set.
    • setName

      Bean property setter: name.

      This is an internal property used for tracking property names and is not part of the JSON Schema specification.

      Parameters:
      name - The new value for the name property on this bean.
      Returns:
      This object.
    • getIdUri

      @Beanp("$id") public URI getIdUri()
      Bean property getter: $id.

      This is the Draft 2020-12 property for schema identification.

      Returns:
      The value of the $id property on this bean, or null if it is not set.
    • setIdUri

      @Beanp("$id") public JsonSchema setIdUri(Object idUri)
      Bean property setter: $id.

      This is the Draft 2020-12 property for schema identification.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      idUri - The new value for the $id property on this bean.
      Returns:
      This object.
    • getId

      @Deprecated public URI getId()
      Deprecated.
      Use getIdUri() instead.
      Bean property getter: id.

      Deprecated: Use getIdUri() instead. This property is retained for Draft 04 backward compatibility.

      Returns:
      The value of the id property on this bean, or null if it is not set.
    • setId

      Deprecated.
      Use setIdUri(Object) instead.
      Bean property setter: id.

      Deprecated: Use setIdUri(Object) instead. This property is retained for Draft 04 backward compatibility.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      id - The new value for the id property on this bean.
      Returns:
      This object.
    • getSchemaVersionUri

      @Beanp("$schema") public URI getSchemaVersionUri()
      Bean property getter: $schema.
      Returns:
      The value of the $schema property on this bean, or null if it is not set.
    • setSchemaVersionUri

      @Beanp("$schema") public JsonSchema setSchemaVersionUri(Object schemaVersion)
      Bean property setter: $schema.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      schemaVersion - The new value for the schemaVersion property on this bean.
      Returns:
      This object.
    • getTitle

      public String getTitle()
      Bean property getter: title.
      Returns:
      The value of the title property, or null if it is not set.
    • setTitle

      public JsonSchema setTitle(String title)
      Bean property setter: title.
      Parameters:
      title - The new value for the title property on this bean.
      Returns:
      This object.
    • getDescription

      Bean property getter: description.
      Returns:
      The value of the description property, or null if it is not set.
    • setDescription

      public JsonSchema setDescription(String description)
      Bean property setter: description.
      Parameters:
      description - The new value for the description property on this bean.
      Returns:
      This object.
    • getType

      Bean property getter: type.
      Returns:
      The value of the type property on this bean, or null if it is not set. Can be either a JsonType or JsonTypeArray depending on what value was used to set it.
    • getTypeAsJsonType

      Bean property getter: type.

      Convenience method for returning the type property when it is a JsonType value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonTypeArray.
    • getTypeAsJsonTypeArray

      Bean property getter: type.

      Convenience method for returning the type property when it is a JsonTypeArray value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonType.
    • setType

      public JsonSchema setType(Object type)
      Bean property setter: type.
      Parameters:
      type - The new value for the type property on this bean. This object must be of type JsonType or JsonTypeArray.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If invalid object type passed in.
    • addTypes

      public JsonSchema addTypes(JsonType... types)
      Bean property appender: type.
      Parameters:
      types - The list of items to append to the type property on this bean.
      Returns:
      This object.
    • getDefinitions

      Bean property getter: definitions.

      Deprecated: Use getDefs() for Draft 2020-12 compliance. This property is retained for Draft 04 backward compatibility.

      Returns:
      The value of the definitions property on this bean, or null if it is not set.
    • setDefinitions

      Bean property setter: definitions.
      Parameters:
      definitions - The new value for the definitions property on this bean.
      Returns:
      This object.
    • addDefinition

      public JsonSchema addDefinition(String name, JsonSchema definition)
      Bean property appender: definitions.
      Parameters:
      name - The key in the definitions map entry.
      definition - The value in the definitions map entry.
      Returns:
      This object.
    • getProperties

      Bean property getter: properties.
      Returns:
      The value of the properties property on this bean, or null if it is not set.
    • getProperty

      public JsonSchema getProperty(String name)
      Returns the property with the specified name.

      This is equivalent to calling getProperty(name, false).

      Parameters:
      name - The property name.
      Returns:
      The property with the specified name, or null if no property is specified.
    • getProperty

      public JsonSchema getProperty(String name, boolean resolve)
      Returns the property with the specified name.

      If resolve is true, the property object will automatically be resolved by calling resolve(). Therefore, getProperty(name, true) is equivalent to calling getProperty(name).resolve(), except it's safe from a potential NullPointerException.

      Parameters:
      name - The property name.
      resolve - If true, calls resolve() on object before returning.
      Returns:
      The property with the specified name, or null if no property is specified.
    • setProperties

      Bean property setter: properties.
      Parameters:
      properties - The new value for the properties property on this bean.
      Returns:
      This object.
    • addProperties

      public JsonSchema addProperties(JsonSchema... properties)
      Bean property appender: properties.

      Properties must have their name property set on them when using this method.

      Parameters:
      properties - The list of items to append to the properties property on this bean.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If property is found without a set name property.
    • getPatternProperties

      Bean property getter: patternProperties.
      Returns:
      The value of the patternProperties property on this bean, or null if it is not set.
    • setPatternProperties

      public JsonSchema setPatternProperties(Map<String,JsonSchema> patternProperties)
      Bean property setter: patternProperties.
      Parameters:
      patternProperties - The new value for the patternProperties property on this bean.
      Returns:
      This object.
    • addPatternProperties

      Bean property appender: patternProperties.

      Properties must have their name property set to the pattern string when using this method.

      Parameters:
      properties - The list of items to append to the patternProperties property on this bean.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If property is found without a set name property.
    • getDependencies

      Bean property getter: dependencies.
      Returns:
      The value of the dependencies property on this bean, or null if it is not set.
    • setDependencies

      Bean property setter: dependencies.
      Parameters:
      dependencies - The new value for the dependencies property on this bean.
      Returns:
      This object.
    • addDependency

      public JsonSchema addDependency(String name, JsonSchema dependency)
      Bean property appender: dependencies.
      Parameters:
      name - The key of the entry in the dependencies map.
      dependency - The value of the entry in the dependencies map.
      Returns:
      This object.
    • getItems

      Bean property getter: items.
      Returns:
      The value of the items property on this bean, or null if it is not set. Can be either a JsonSchema or JsonSchemaArray depending on what value was used to set it.
    • getItemsAsSchema

      Bean property getter: items.

      Convenience method for returning the items property when it is a JsonSchema value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonSchemaArray.
    • getItemsAsSchemaArray

      Bean property getter: items.

      Convenience method for returning the items property when it is a JsonSchemaArray value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonSchema.
    • setItems

      public JsonSchema setItems(Object items)
      Bean property setter: items.
      Parameters:
      items - The new value for the items property on this bean. This object must be of type JsonSchema or JsonSchemaArray.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If invalid object type passed in.
    • addItems

      public JsonSchema addItems(JsonSchema... items)
      Bean property appender: items.
      Parameters:
      items - The list of items to append to the items property on this bean.
      Returns:
      This object.
    • getMultipleOf

      Bean property getter: multipleOf.
      Returns:
      The value of the multipleOf property on this bean, or null if it is not set.
    • setMultipleOf

      public JsonSchema setMultipleOf(Number multipleOf)
      Bean property setter: multipleOf.
      Parameters:
      multipleOf - The new value for the multipleOf property on this bean.
      Returns:
      This object.
    • getMaximum

      public Number getMaximum()
      Bean property getter: maximum.
      Returns:
      The value of the maximum property on this bean, or null if it is not set.
    • setMaximum

      public JsonSchema setMaximum(Number maximum)
      Bean property setter: maximum.
      Parameters:
      maximum - The new value for the maximum property on this bean.
      Returns:
      This object.
    • getExclusiveMaximum

      Bean property getter: exclusiveMaximum.

      In Draft 06+, this is a numeric value representing the exclusive upper bound. In Draft 04, this was a boolean flag. This implementation uses the Draft 06+ semantics.

      Returns:
      The value of the exclusiveMaximum property on this bean, or null if it is not set.
    • setExclusiveMaximum

      public JsonSchema setExclusiveMaximum(Number exclusiveMaximum)
      Bean property setter: exclusiveMaximum.

      In Draft 06+, this is a numeric value representing the exclusive upper bound. In Draft 04, this was a boolean flag. This implementation uses the Draft 06+ semantics.

      Parameters:
      exclusiveMaximum - The new value for the exclusiveMaximum property on this bean.
      Returns:
      This object.
    • getMinimum

      public Number getMinimum()
      Bean property getter: minimum.
      Returns:
      The value of the minimum property on this bean, or null if it is not set.
    • setMinimum

      public JsonSchema setMinimum(Number minimum)
      Bean property setter: minimum.
      Parameters:
      minimum - The new value for the minimum property on this bean.
      Returns:
      This object.
    • getExclusiveMinimum

      Bean property getter: exclusiveMinimum.

      In Draft 06+, this is a numeric value representing the exclusive lower bound. In Draft 04, this was a boolean flag. This implementation uses the Draft 06+ semantics.

      Returns:
      The value of the exclusiveMinimum property on this bean, or null if it is not set.
    • setExclusiveMinimum

      public JsonSchema setExclusiveMinimum(Number exclusiveMinimum)
      Bean property setter: exclusiveMinimum.

      In Draft 06+, this is a numeric value representing the exclusive lower bound. In Draft 04, this was a boolean flag. This implementation uses the Draft 06+ semantics.

      Parameters:
      exclusiveMinimum - The new value for the exclusiveMinimum property on this bean.
      Returns:
      This object.
    • getMaxLength

      Bean property getter: maxLength.
      Returns:
      The value of the maxLength property on this bean, or null if it is not set.
    • setMaxLength

      public JsonSchema setMaxLength(Integer maxLength)
      Bean property setter: maxLength.
      Parameters:
      maxLength - The new value for the maxLength property on this bean.
      Returns:
      This object.
    • getMinLength

      Bean property getter: minLength.
      Returns:
      The value of the minLength property on this bean, or null if it is not set.
    • setMinLength

      public JsonSchema setMinLength(Integer minLength)
      Bean property setter: minLength.
      Parameters:
      minLength - The new value for the minLength property on this bean.
      Returns:
      This object.
    • getPattern

      public String getPattern()
      Bean property getter: pattern.
      Returns:
      The value of the pattern property on this bean, or null if it is not set.
    • setPattern

      public JsonSchema setPattern(String pattern)
      Bean property setter: pattern.
      Parameters:
      pattern - The new value for the pattern property on this bean.
      Returns:
      This object.
    • getAdditionalItems

      Bean property getter: additionalItems.
      Returns:
      The value of the additionalItems property on this bean, or null if it is not set. Can be either a Boolean or JsonSchemaArray depending on what value was used to set it.
    • getAdditionalItemsAsBoolean

      Bean property getter: additionalItems.

      Convenience method for returning the additionalItems property when it is a Boolean value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonSchemaArray.
    • getAdditionalItemsAsSchemaArray

      Bean property getter: additionalItems.

      Convenience method for returning the additionalItems property when it is a JsonSchemaArray value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a Boolean.
    • setAdditionalItems

      public JsonSchema setAdditionalItems(Object additionalItems)
      Bean property setter: additionalItems.
      Parameters:
      additionalItems - The new value for the additionalItems property on this bean. This object must be of type Boolean or JsonSchemaArray.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If invalid object type passed in.
    • addAdditionalItems

      public JsonSchema addAdditionalItems(JsonSchema... additionalItems)
      Bean property appender: additionalItems.
      Parameters:
      additionalItems - The list of items to append to the additionalItems property on this bean.
      Returns:
      This object.
    • getMaxItems

      public Integer getMaxItems()
      Bean property getter: maxItems.
      Returns:
      The value of the maxItems property on this bean, or null if it is not set.
    • setMaxItems

      public JsonSchema setMaxItems(Integer maxItems)
      Bean property setter: maxItems.
      Parameters:
      maxItems - The new value for the maxItems property on this bean.
      Returns:
      This object.
    • getMinItems

      public Integer getMinItems()
      Bean property getter: minItems.
      Returns:
      The value of the minItems property on this bean, or null if it is not set.
    • setMinItems

      public JsonSchema setMinItems(Integer minItems)
      Bean property setter: minItems.
      Parameters:
      minItems - The new value for the minItems property on this bean.
      Returns:
      This object.
    • getUniqueItems

      Bean property getter: uniqueItems.
      Returns:
      The value of the uniqueItems property on this bean, or null if it is not set.
    • setUniqueItems

      public JsonSchema setUniqueItems(Boolean uniqueItems)
      Bean property setter: uniqueItems.
      Parameters:
      uniqueItems - The new value for the uniqueItems property on this bean.
      Returns:
      This object.
    • getMaxProperties

      Bean property getter: maxProperties.
      Returns:
      The value of the maxProperties property on this bean, or null if it is not set.
    • setMaxProperties

      public JsonSchema setMaxProperties(Integer maxProperties)
      Bean property setter: maxProperties.
      Parameters:
      maxProperties - The new value for the maxProperties property on this bean.
      Returns:
      This object.
    • getMinProperties

      Bean property getter: minProperties.
      Returns:
      The value of the minProperties property on this bean, or null if it is not set.
    • setMinProperties

      public JsonSchema setMinProperties(Integer minProperties)
      Bean property setter: minProperties.
      Parameters:
      minProperties - The new value for the minProperties property on this bean.
      Returns:
      This object.
    • getRequired

      public List<String> getRequired()
      Bean property getter: required.
      Returns:
      The value of the required property on this bean, or null if it is not set.
    • setRequired

      public JsonSchema setRequired(List<String> required)
      Bean property setter: required.
      Parameters:
      required - The new value for the required property on this bean.
      Returns:
      This object.
    • addRequired

      public JsonSchema addRequired(List<String> required)
      Bean property appender: required.
      Parameters:
      required - The list of items to append to the required property on this bean.
      Returns:
      This object.
    • addRequired

      public JsonSchema addRequired(String... required)
      Bean property appender: required.
      Parameters:
      required - The list of items to append to the required property on this bean.
      Returns:
      This object.
    • addRequired

      public JsonSchema addRequired(JsonSchemaProperty... properties)
      Bean property appender: required.
      Parameters:
      properties - The list of items to append to the required property on this bean.
      Returns:
      This object.
    • getAdditionalProperties

      Bean property getter: additionalProperties.
      Returns:
      The value of the additionalProperties property on this bean, or null if it is not set. Can be either a Boolean or JsonSchemaArray depending on what value was used to set it.
    • getAdditionalPropertiesAsBoolean

      Bean property getter: additionalProperties.

      Convenience method for returning the additionalProperties property when it is a Boolean value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a JsonSchema.
    • getAdditionalPropertiesAsSchema

      Bean property getter: additionalProperties.

      Convenience method for returning the additionalProperties property when it is a JsonSchema value.

      Returns:
      The currently set value, or null if the property is not set, or is set as a Boolean.
    • setAdditionalProperties

      Bean property setter: additionalProperties.
      Parameters:
      additionalProperties - The new value for the additionalProperties property on this bean. This object must be of type Boolean or JsonSchema.
      Returns:
      This object.
      Throws:
      BeanRuntimeException - If invalid object type passed in.
    • getEnum

      public List<Object> getEnum()
      Bean property getter: enum.
      Returns:
      The value of the enum property on this bean, or null if it is not set.
    • setEnum

      public JsonSchema setEnum(List<Object> _enum)
      Bean property setter: enum.
      Parameters:
      _enum - The new value for the enum property on this bean.
      Returns:
      This object.
    • addEnum

      public JsonSchema addEnum(Object... _enum)
      Bean property appender: enum.
      Parameters:
      _enum - The list of items to append to the enum property on this bean.
      Returns:
      This object.
    • getAllOf

      Bean property getter: allOf.
      Returns:
      The value of the allOf property on this bean, or null if it is not set.
    • setAllOf

      Bean property setter: allOf.
      Parameters:
      allOf - The new value for the allOf property on this bean.
      Returns:
      This object.
    • addAllOf

      public JsonSchema addAllOf(JsonSchema... allOf)
      Bean property appender: allOf.
      Parameters:
      allOf - The list of items to append to the allOf property on this bean.
      Returns:
      This object.
    • getAnyOf

      Bean property getter: anyOf.
      Returns:
      The value of the anyOf property on this bean, or null if it is not set.
    • setAnyOf

      Bean property setter: anyOf.
      Parameters:
      anyOf - The new value of the anyOf property on this bean.
      Returns:
      This object.
    • addAnyOf

      public JsonSchema addAnyOf(JsonSchema... anyOf)
      Bean property appender: anyOf.
      Parameters:
      anyOf - The list of items to append to the anyOf property on this bean.
      Returns:
      This object.
    • getOneOf

      Bean property getter: oneOf.
      Returns:
      The value of the oneOf property on this bean, or null if it is not set.
    • setOneOf

      Bean property setter: oneOf.
      Parameters:
      oneOf - The new value for the oneOf property on this bean.
      Returns:
      This object.
    • addOneOf

      public JsonSchema addOneOf(JsonSchema... oneOf)
      Bean property appender: oneOf.
      Parameters:
      oneOf - The list of items to append to the oneOf property on this bean.
      Returns:
      This object.
    • getNot

      public JsonSchema getNot()
      Bean property getter: not.
      Returns:
      The value of the not property on this bean, or null if it is not set.
    • setNot

      Bean property setter: not.
      Parameters:
      not - The new value for the not property on this bean.
      Returns:
      This object.
    • getConst

      public Object getConst()
      Bean property getter: const.

      This property was added in Draft 06.

      Returns:
      The value of the const property on this bean, or null if it is not set.
    • setConst

      public JsonSchema setConst(Object _const)
      Bean property setter: const.

      This property was added in Draft 06.

      Parameters:
      _const - The new value for the const property on this bean.
      Returns:
      This object.
    • getExamples

      public List<Object> getExamples()
      Bean property getter: examples.

      This property was added in Draft 06.

      Returns:
      The value of the examples property on this bean, or null if it is not set.
    • setExamples

      public JsonSchema setExamples(List<Object> examples)
      Bean property setter: examples.

      This property was added in Draft 06.

      Parameters:
      examples - The new value for the examples property on this bean.
      Returns:
      This object.
    • addExamples

      public JsonSchema addExamples(Object... examples)
      Bean property appender: examples.
      Parameters:
      examples - The list of items to append to the examples property on this bean.
      Returns:
      This object.
    • getIf

      @Beanp("if") public JsonSchema getIf()
      Bean property getter: if.

      This property was added in Draft 07 for conditional schema application.

      Returns:
      The value of the if property on this bean, or null if it is not set.
    • setIf

      @Beanp("if") public JsonSchema setIf(JsonSchema _if)
      Bean property setter: if.

      This property was added in Draft 07 for conditional schema application.

      Parameters:
      _if - The new value for the if property on this bean.
      Returns:
      This object.
    • getThen

      @Beanp("then") public JsonSchema getThen()
      Bean property getter: then.

      This property was added in Draft 07 for conditional schema application.

      Returns:
      The value of the then property on this bean, or null if it is not set.
    • setThen

      @Beanp("then") public JsonSchema setThen(JsonSchema _then)
      Bean property setter: then.

      This property was added in Draft 07 for conditional schema application.

      Parameters:
      _then - The new value for the then property on this bean.
      Returns:
      This object.
    • getElse

      @Beanp("else") public JsonSchema getElse()
      Bean property getter: else.

      This property was added in Draft 07 for conditional schema application.

      Returns:
      The value of the else property on this bean, or null if it is not set.
    • setElse

      @Beanp("else") public JsonSchema setElse(JsonSchema _else)
      Bean property setter: else.

      This property was added in Draft 07 for conditional schema application.

      Parameters:
      _else - The new value for the else property on this bean.
      Returns:
      This object.
    • getReadOnly

      public Boolean getReadOnly()
      Bean property getter: readOnly.

      This property was added in Draft 07.

      Returns:
      The value of the readOnly property on this bean, or null if it is not set.
    • setReadOnly

      public JsonSchema setReadOnly(Boolean readOnly)
      Bean property setter: readOnly.

      This property was added in Draft 07.

      Parameters:
      readOnly - The new value for the readOnly property on this bean.
      Returns:
      This object.
    • getWriteOnly

      Bean property getter: writeOnly.

      This property was added in Draft 07.

      Returns:
      The value of the writeOnly property on this bean, or null if it is not set.
    • setWriteOnly

      public JsonSchema setWriteOnly(Boolean writeOnly)
      Bean property setter: writeOnly.

      This property was added in Draft 07.

      Parameters:
      writeOnly - The new value for the writeOnly property on this bean.
      Returns:
      This object.
    • getContentMediaType

      Bean property getter: contentMediaType.

      This property was added in Draft 07.

      Returns:
      The value of the contentMediaType property on this bean, or null if it is not set.
    • setContentMediaType

      public JsonSchema setContentMediaType(String contentMediaType)
      Bean property setter: contentMediaType.

      This property was added in Draft 07.

      Parameters:
      contentMediaType - The new value for the contentMediaType property on this bean.
      Returns:
      This object.
    • getContentEncoding

      Bean property getter: contentEncoding.

      This property was added in Draft 07.

      Returns:
      The value of the contentEncoding property on this bean, or null if it is not set.
    • setContentEncoding

      public JsonSchema setContentEncoding(String contentEncoding)
      Bean property setter: contentEncoding.

      This property was added in Draft 07.

      Parameters:
      contentEncoding - The new value for the contentEncoding property on this bean.
      Returns:
      This object.
    • getDefs

      @Beanp("$defs") public Map<String,JsonSchema> getDefs()
      Bean property getter: $defs.

      This is the Draft 2020-12 replacement for definitions. Both properties are supported for backward compatibility.

      Returns:
      The value of the $defs property on this bean, or null if it is not set.
    • setDefs

      @Beanp("$defs") public JsonSchema setDefs(Map<String,JsonSchema> defs)
      Bean property setter: $defs.

      This is the Draft 2020-12 replacement for definitions. Both properties are supported for backward compatibility.

      Parameters:
      defs - The new value for the $defs property on this bean.
      Returns:
      This object.
    • addDef

      public JsonSchema addDef(String name, JsonSchema def)
      Bean property appender: $defs.
      Parameters:
      name - The key in the defs map entry.
      def - The value in the defs map entry.
      Returns:
      This object.
    • getPrefixItems

      Bean property getter: prefixItems.

      This property was added in Draft 2020-12 for tuple validation.

      Returns:
      The value of the prefixItems property on this bean, or null if it is not set.
    • setPrefixItems

      Bean property setter: prefixItems.

      This property was added in Draft 2020-12 for tuple validation.

      Parameters:
      prefixItems - The new value for the prefixItems property on this bean.
      Returns:
      This object.
    • addPrefixItems

      public JsonSchema addPrefixItems(JsonSchema... prefixItems)
      Bean property appender: prefixItems.
      Parameters:
      prefixItems - The list of items to append to the prefixItems property on this bean.
      Returns:
      This object.
    • getUnevaluatedItems

      Bean property getter: unevaluatedItems.

      This property was added in Draft 2019-09.

      Returns:
      The value of the unevaluatedItems property on this bean, or null if it is not set.
    • setUnevaluatedItems

      public JsonSchema setUnevaluatedItems(JsonSchema unevaluatedItems)
      Bean property setter: unevaluatedItems.

      This property was added in Draft 2019-09.

      Parameters:
      unevaluatedItems - The new value for the unevaluatedItems property on this bean.
      Returns:
      This object.
    • getUnevaluatedProperties

      Bean property getter: unevaluatedProperties.

      This property was added in Draft 2019-09.

      Returns:
      The value of the unevaluatedProperties property on this bean, or null if it is not set.
    • setUnevaluatedProperties

      public JsonSchema setUnevaluatedProperties(JsonSchema unevaluatedProperties)
      Bean property setter: unevaluatedProperties.

      This property was added in Draft 2019-09.

      Parameters:
      unevaluatedProperties - The new value for the unevaluatedProperties property on this bean.
      Returns:
      This object.
    • getDependentSchemas

      Bean property getter: dependentSchemas.

      This property was added in Draft 2019-09 as a replacement for the schema form of dependencies.

      Returns:
      The value of the dependentSchemas property on this bean, or null if it is not set.
    • setDependentSchemas

      public JsonSchema setDependentSchemas(Map<String,JsonSchema> dependentSchemas)
      Bean property setter: dependentSchemas.

      This property was added in Draft 2019-09 as a replacement for the schema form of dependencies.

      Parameters:
      dependentSchemas - The new value for the dependentSchemas property on this bean.
      Returns:
      This object.
    • addDependentSchema

      Bean property appender: dependentSchemas.
      Parameters:
      name - The key of the entry in the dependentSchemas map.
      schema - The value of the entry in the dependentSchemas map.
      Returns:
      This object.
    • getDependentRequired

      Bean property getter: dependentRequired.

      This property was added in Draft 2019-09 as a replacement for the array form of dependencies.

      Returns:
      The value of the dependentRequired property on this bean, or null if it is not set.
    • setDependentRequired

      public JsonSchema setDependentRequired(Map<String,List<String>> dependentRequired)
      Bean property setter: dependentRequired.

      This property was added in Draft 2019-09 as a replacement for the array form of dependencies.

      Parameters:
      dependentRequired - The new value for the dependentRequired property on this bean.
      Returns:
      This object.
    • addDependentRequired

      public JsonSchema addDependentRequired(String name, List<String> required)
      Bean property appender: dependentRequired.
      Parameters:
      name - The key of the entry in the dependentRequired map.
      required - The value of the entry in the dependentRequired map.
      Returns:
      This object.
    • getRef

      @Beanp("$ref") public URI getRef()
      Bean property getter: $ref.
      Returns:
      The value of the $ref property on this bean, or null if it is not set.
    • setRef

      @Beanp("$ref") public JsonSchema setRef(Object ref)
      Bean property setter: $ref.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      ref - The new value for the $ref property on this bean.
      Returns:
      This object.
    • setMaster

      protected void setMaster(JsonSchema master)
      Sets the master schema for this schema and all child schema objects.

      All child elements in a schema should point to a single "master" schema in order to locate registered JsonSchemaMap objects for resolving external schemas.

      Parameters:
      master - The master schema to associate on this and all children. Can be null.
    • resolve

      public JsonSchema resolve()
      Resolve schema if reference.

      If this schema is a reference to another schema (has its $ref property set), this method will retrieve the referenced schema from the schema map registered with this schema.

      If this schema is not a reference, or no schema map is registered with this schema, this method is a no-op and simply returns this object.

      Returns:
      The referenced schema, or null.
    • setSchemaMap

      Associates a schema map with this schema for resolving other schemas identified through $ref properties.
      Parameters:
      schemaMap - The schema map to associate with this schema. Can be null.
      Returns:
      This object.
    • toString

      public String toString()
      Overrides:
      toString in class Object