Class SchemaValidatorsConfig
- java.lang.Object
-
- com.networknt.schema.SchemaValidatorsConfig
-
- Direct Known Subclasses:
SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig
public class SchemaValidatorsConfig extends java.lang.Object
Configuration for validators.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchemaValidatorsConfig.Builder
Builder forSchemaValidatorsConfig
.static class
SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig
SchemaValidatorsConfig
that throws on mutators or deprecated methods.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALL_KEYWORD_WALK_LISTENER_KEY
private ApplyDefaultsStrategy
applyDefaultsStrategy
The strategy the walker uses to sets nodes that are missing or NullNode to the default value, if any, and mutate the input json.private boolean
cacheRefs
Controls if schemas loaded from refs will be cached and reused for subsequent runs.static int
DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH
private boolean
discriminatorKeywordEnabled
When set to true, support for discriminators is enabled for validations of oneOf, anyOf and allOf as described on GitHub.private java.lang.String
errorMessageKeyword
When set to true, "messages" provided in schema are used for forming validation errors else default messages are usedprivate ExecutionContextCustomizer
executionContextCustomizer
private boolean
failFast
When set to true, validator process is stop immediately when a very first validation error is discovered.private java.lang.Boolean
formatAssertionsEnabled
Since Draft 2019-09 format assertions are not enabled by default.private WalkListenerRunner
itemWalkListenerRunner
private java.util.List<JsonSchemaWalkListener>
itemWalkListeners
private boolean
javaSemantics
When set to true, use Java-specific semantics rather than native JavaScript semanticsprivate WalkListenerRunner
keywordWalkListenerRunner
private java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>>
keywordWalkListenersMap
private boolean
loadCollectors
Deprecated.private java.util.Locale
locale
The Locale to consider when loading validation messages from the default resource bundle.private boolean
losslessNarrowing
When set to true, can interpret round doubles as integersprivate MessageSource
messageSource
The message source to use for generating localised messages.private boolean
nullableKeywordEnabled
When a field is set as nullable in the OpenAPI specification, the schema validator validates that it is nullable however continues with validation against the nullable fieldprivate PathType
pathType
The approach used to generate paths in reported messages, logs and errors.private boolean
preloadJsonSchema
Controls if the schema will automatically be preloaded.private int
preloadJsonSchemaRefMaxNestingDepth
Controls the max depth of the evaluation path to preload when preloading refs.private WalkListenerRunner
propertyWalkListenerRunner
private java.util.List<JsonSchemaWalkListener>
propertyWalkListeners
private java.lang.Boolean
readOnly
When set to true assumes that schema is used to validate incoming data from an API.private RegularExpressionFactory
regularExpressionFactory
Used to createRegularExpression
.private JsonSchemaIdValidator
schemaIdValidator
Used to validate the acceptable $id values.private java.util.Map<java.lang.String,java.lang.Boolean>
strictness
Contains a mapping of how strict a keyword's validators should be.private boolean
typeLoose
when validate type, if TYPE_LOOSE = true, will try to convert string to different types to match the type defined in schema.private java.lang.Boolean
writeOnly
When set to true assumes that schema is used to to validate outgoing data from an API.
-
Constructor Summary
Constructors Constructor Description SchemaValidatorsConfig()
Deprecated.SchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, java.lang.String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, java.lang.Boolean formatAssertionsEnabled, boolean nullableKeywordEnabled, java.util.List<JsonSchemaWalkListener> itemWalkListeners, boolean javaSemantics, java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>> keywordWalkListenersMap, java.util.Locale locale, boolean losslessNarrowing, MessageSource messageSource, boolean discriminatorKeywordEnabled, PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, java.util.List<JsonSchemaWalkListener> propertyWalkListeners, java.lang.Boolean readOnly, RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, java.util.Map<java.lang.String,java.lang.Boolean> strictness, boolean typeLoose, java.lang.Boolean writeOnly)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
void
addItemWalkListeners(java.util.List<JsonSchemaWalkListener> itemWalkListeners)
void
addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
void
addKeywordWalkListener(java.lang.String keyword, JsonSchemaWalkListener keywordWalkListener)
void
addKeywordWalkListeners(java.lang.String keyword, java.util.List<JsonSchemaWalkListener> keywordWalkListeners)
void
addKeywordWalkListeners(java.util.List<JsonSchemaWalkListener> keywordWalkListeners)
void
addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
void
addPropertyWalkListeners(java.util.List<JsonSchemaWalkListener> propertyWalkListeners)
static SchemaValidatorsConfig.Builder
builder()
static SchemaValidatorsConfig.Builder
builder(SchemaValidatorsConfig config)
SchemaValidatorsConfig
disableUnevaluatedAnalysis()
Deprecated.SchemaValidatorsConfig
disableUnevaluatedItems()
Deprecated.SchemaValidatorsConfig
disableUnevaluatedProperties()
Deprecated.boolean
doLoadCollectors()
Deprecated.SchemaValidatorsConfig
enableUnevaluatedAnalysis()
Deprecated.SchemaValidatorsConfig
enableUnevaluatedItems()
Deprecated.SchemaValidatorsConfig
enableUnevaluatedProperties()
Deprecated.ApplyDefaultsStrategy
getApplyDefaultsStrategy()
java.util.List<JsonSchemaWalkListener>
getArrayItemWalkListeners()
java.lang.String
getErrorMessageKeyword()
ExecutionContextCustomizer
getExecutionContextCustomizer()
java.lang.Boolean
getFormatAssertionsEnabled()
Gets the format assertion enabled flag.(package private) WalkListenerRunner
getItemWalkListenerRunner()
(package private) WalkListenerRunner
getKeywordWalkListenerRunner()
java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>>
getKeywordWalkListenersMap()
java.util.Locale
getLocale()
Get the locale to consider when generating localised messages (default is the JVM default).MessageSource
getMessageSource()
Get the message source to use for generating localised messages.PathType
getPathType()
Get the approach used to generate paths in messages, logs and errors.int
getPreloadJsonSchemaRefMaxNestingDepth()
Gets the max depth of the evaluation path to preload when preloading refs.(package private) WalkListenerRunner
getPropertyWalkListenerRunner()
java.util.List<JsonSchemaWalkListener>
getPropertyWalkListeners()
RegularExpressionFactory
getRegularExpressionFactory()
Gets the regular expression factory.JsonSchemaIdValidator
getSchemaIdValidator()
Gets the schema id validator to validate $id.boolean
isCacheRefs()
Gets if schemas loaded from refs will be cached and reused for subsequent runs.boolean
isCustomMessageSupported()
Deprecated.boolean
isDiscriminatorKeywordEnabled()
Gets if the discriminator keyword is enabled.boolean
isEcma262Validator()
Gets whether to use a ECMA-262 compliant regular expression validator.boolean
isFailFast()
boolean
isHandleNullableField()
Deprecated.boolean
isJavaSemantics()
boolean
isLosslessNarrowing()
boolean
isNullableKeywordEnabled()
Gets if the nullable keyword is enabled.boolean
isOpenAPI3StyleDiscriminators()
Deprecated.boolean
isPreloadJsonSchema()
Gets if the schema should be preloaded.boolean
isReadOnly()
boolean
isStrict(java.lang.String keyword)
Answers whether a keyword's validators may relax their analysis.boolean
isStrict(java.lang.String keyword, java.lang.Boolean defaultValue)
Determines if the validator should perform strict checking.boolean
isTypeLoose()
boolean
isUnevaluatedItemsAnalysisDisabled()
Deprecated.boolean
isUnevaluatedItemsAnalysisEnabled()
Deprecated.boolean
isUnevaluatedPropertiesAnalysisDisabled()
Deprecated.boolean
isUnevaluatedPropertiesAnalysisEnabled()
Deprecated.boolean
isWriteMode()
Deprecated.boolean
isWriteOnly()
void
setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
void
setCacheRefs(boolean cacheRefs)
Sets if schemas loaded from refs will be cached and reused for subsequent runs.void
setCustomMessageSupported(boolean customMessageSupported)
Deprecated.void
setEcma262Validator(boolean ecma262Validator)
Sets whether to use a ECMA-262 compliant regular expression validator.void
setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
void
setFailFast(boolean failFast)
When enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)
doesn't return anySet
<ValidationMessage
>, instead aJsonSchemaException
is thrown as soon as a validation errors is discovered.void
setFormatAssertionsEnabled(java.lang.Boolean formatAssertionsEnabled)
Deprecated.void
setHandleNullableField(boolean handleNullableField)
void
setJavaSemantics(boolean javaSemantics)
void
setLoadCollectors(boolean loadCollectors)
Deprecated.void
setLocale(java.util.Locale locale)
Deprecated.void
setLosslessNarrowing(boolean losslessNarrowing)
void
setMessageSource(MessageSource messageSource)
Set the message source to use for generating localised messages.void
setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
When enabled, the validation ofanyOf
andallOf
in polymorphism will respect OpenAPI 3 style discriminators as described in the OpenAPI 3.0.3 spec.void
setPathType(PathType pathType)
Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).void
setPreloadJsonSchema(boolean preloadJsonSchema)
Sets if the schema should be preloaded.void
setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)
Sets the max depth of the evaluation path to preload when preloading refs.void
setReadOnly(boolean readOnly)
void
setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Sets the regular expression factory.void
setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Sets the schema id validator to validate $id.void
setStrict(java.lang.String keyword, boolean strict)
Alters the strictness of validations for a specific keyword.void
setTypeLoose(boolean typeLoose)
void
setWriteOnly(boolean writeOnly)
-
-
-
Field Detail
-
ALL_KEYWORD_WALK_LISTENER_KEY
public static final java.lang.String ALL_KEYWORD_WALK_LISTENER_KEY
- See Also:
- Constant Field Values
-
DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH
public static final int DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH
- See Also:
- Constant Field Values
-
applyDefaultsStrategy
private ApplyDefaultsStrategy applyDefaultsStrategy
The strategy the walker uses to sets nodes that are missing or NullNode to the default value, if any, and mutate the input json.
-
cacheRefs
private boolean cacheRefs
Controls if schemas loaded from refs will be cached and reused for subsequent runs.
-
errorMessageKeyword
private java.lang.String errorMessageKeyword
When set to true, "messages" provided in schema are used for forming validation errors else default messages are used
-
executionContextCustomizer
private ExecutionContextCustomizer executionContextCustomizer
-
failFast
private boolean failFast
When set to true, validator process is stop immediately when a very first validation error is discovered.
-
formatAssertionsEnabled
private java.lang.Boolean formatAssertionsEnabled
Since Draft 2019-09 format assertions are not enabled by default.
-
nullableKeywordEnabled
private boolean nullableKeywordEnabled
When a field is set as nullable in the OpenAPI specification, the schema validator validates that it is nullable however continues with validation against the nullable fieldIf handleNullableField is set to true && incoming field is nullable && value is field: null --> succeed If handleNullableField is set to false && incoming field is nullable && value is field: null --> it is up to the type validator using the SchemaValidator to handle it.
-
itemWalkListenerRunner
private final WalkListenerRunner itemWalkListenerRunner
-
itemWalkListeners
private final java.util.List<JsonSchemaWalkListener> itemWalkListeners
-
javaSemantics
private boolean javaSemantics
When set to true, use Java-specific semantics rather than native JavaScript semantics
-
keywordWalkListenerRunner
private final WalkListenerRunner keywordWalkListenerRunner
-
keywordWalkListenersMap
private final java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>> keywordWalkListenersMap
-
locale
private java.util.Locale locale
The Locale to consider when loading validation messages from the default resource bundle.
-
losslessNarrowing
private boolean losslessNarrowing
When set to true, can interpret round doubles as integers
-
messageSource
private MessageSource messageSource
The message source to use for generating localised messages.
-
discriminatorKeywordEnabled
private boolean discriminatorKeywordEnabled
When set to true, support for discriminators is enabled for validations of oneOf, anyOf and allOf as described on GitHub.
-
pathType
private PathType pathType
The approach used to generate paths in reported messages, logs and errors. Default is the legacy "JSONPath-like" approach.
-
preloadJsonSchema
private boolean preloadJsonSchema
Controls if the schema will automatically be preloaded.
-
preloadJsonSchemaRefMaxNestingDepth
private int preloadJsonSchemaRefMaxNestingDepth
Controls the max depth of the evaluation path to preload when preloading refs.
-
propertyWalkListenerRunner
private final WalkListenerRunner propertyWalkListenerRunner
-
propertyWalkListeners
private final java.util.List<JsonSchemaWalkListener> propertyWalkListeners
-
readOnly
private java.lang.Boolean readOnly
When set to true assumes that schema is used to validate incoming data from an API.
-
regularExpressionFactory
private RegularExpressionFactory regularExpressionFactory
Used to createRegularExpression
.
-
schemaIdValidator
private JsonSchemaIdValidator schemaIdValidator
Used to validate the acceptable $id values.
-
strictness
private final java.util.Map<java.lang.String,java.lang.Boolean> strictness
Contains a mapping of how strict a keyword's validators should be. Defaults to true.Each validator has its own understanding of what constitutes strict and permissive.
-
typeLoose
private boolean typeLoose
when validate type, if TYPE_LOOSE = true, will try to convert string to different types to match the type defined in schema.
-
writeOnly
private java.lang.Boolean writeOnly
When set to true assumes that schema is used to to validate outgoing data from an API.
-
loadCollectors
@Deprecated private boolean loadCollectors
Deprecated.
-
-
Constructor Detail
-
SchemaValidatorsConfig
@Deprecated public SchemaValidatorsConfig()
Deprecated.Constructor to create an instance.This is deprecated in favor of using the builder
builder()
to create an instance. Migration note: The builder has different defaults from the constructor.SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .pathType(PathType.LEGACY) .errorMessageKeyword("message") .nullableKeywordEnabled(true) .build();
- customMessageSupported (errorMessageKeyword): change from message to null
- pathType: changed from PathType.LEGACY to PathType.JSON_POINTER.
- handleNullableField (nullableKeywordEnabled): changed from true to false
-
SchemaValidatorsConfig
SchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, java.lang.String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, java.lang.Boolean formatAssertionsEnabled, boolean nullableKeywordEnabled, java.util.List<JsonSchemaWalkListener> itemWalkListeners, boolean javaSemantics, java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>> keywordWalkListenersMap, java.util.Locale locale, boolean losslessNarrowing, MessageSource messageSource, boolean discriminatorKeywordEnabled, PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, java.util.List<JsonSchemaWalkListener> propertyWalkListeners, java.lang.Boolean readOnly, RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, java.util.Map<java.lang.String,java.lang.Boolean> strictness, boolean typeLoose, java.lang.Boolean writeOnly)
-
-
Method Detail
-
addItemWalkListener
public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
-
addItemWalkListeners
public void addItemWalkListeners(java.util.List<JsonSchemaWalkListener> itemWalkListeners)
-
addKeywordWalkListener
public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
-
addKeywordWalkListener
public void addKeywordWalkListener(java.lang.String keyword, JsonSchemaWalkListener keywordWalkListener)
-
addKeywordWalkListeners
public void addKeywordWalkListeners(java.util.List<JsonSchemaWalkListener> keywordWalkListeners)
-
addKeywordWalkListeners
public void addKeywordWalkListeners(java.lang.String keyword, java.util.List<JsonSchemaWalkListener> keywordWalkListeners)
-
addPropertyWalkListener
public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
-
addPropertyWalkListeners
public void addPropertyWalkListeners(java.util.List<JsonSchemaWalkListener> propertyWalkListeners)
-
getApplyDefaultsStrategy
public ApplyDefaultsStrategy getApplyDefaultsStrategy()
-
getArrayItemWalkListeners
public java.util.List<JsonSchemaWalkListener> getArrayItemWalkListeners()
-
getExecutionContextCustomizer
public ExecutionContextCustomizer getExecutionContextCustomizer()
-
getFormatAssertionsEnabled
public java.lang.Boolean getFormatAssertionsEnabled()
Gets the format assertion enabled flag.This defaults to null meaning that it will follow the defaults of the specification.
Since draft 2019-09 this will default to false unless enabled by using the $vocabulary keyword.
- Returns:
- the format assertions enabled flag
-
getItemWalkListenerRunner
WalkListenerRunner getItemWalkListenerRunner()
-
getKeywordWalkListenerRunner
WalkListenerRunner getKeywordWalkListenerRunner()
-
getKeywordWalkListenersMap
public java.util.Map<java.lang.String,java.util.List<JsonSchemaWalkListener>> getKeywordWalkListenersMap()
-
getLocale
public java.util.Locale getLocale()
Get the locale to consider when generating localised messages (default is the JVM default).This locale is on a schema basis and will be used as the default locale for
ExecutionConfig
.- Returns:
- The locale.
-
getMessageSource
public MessageSource getMessageSource()
Get the message source to use for generating localised messages.- Returns:
- the message source
-
getPathType
public PathType getPathType()
Get the approach used to generate paths in messages, logs and errors.- Returns:
- The path generation approach.
-
getPreloadJsonSchemaRefMaxNestingDepth
public int getPreloadJsonSchemaRefMaxNestingDepth()
Gets the max depth of the evaluation path to preload when preloading refs.- Returns:
- the max depth to preload
-
getPropertyWalkListenerRunner
WalkListenerRunner getPropertyWalkListenerRunner()
-
getPropertyWalkListeners
public java.util.List<JsonSchemaWalkListener> getPropertyWalkListeners()
-
getRegularExpressionFactory
public RegularExpressionFactory getRegularExpressionFactory()
Gets the regular expression factory.This defaults to the JDKRegularExpressionFactory and the implementations require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Returns:
- the factory
-
getSchemaIdValidator
public JsonSchemaIdValidator getSchemaIdValidator()
Gets the schema id validator to validate $id.- Returns:
- the validator
-
isCacheRefs
public boolean isCacheRefs()
Gets if schemas loaded from refs will be cached and reused for subsequent runs.- Returns:
- true if schemas loaded from refs should be cached
-
isCustomMessageSupported
@Deprecated public boolean isCustomMessageSupported()
Deprecated.
-
getErrorMessageKeyword
public java.lang.String getErrorMessageKeyword()
-
isEcma262Validator
public boolean isEcma262Validator()
Gets whether to use a ECMA-262 compliant regular expression validator.This defaults to the false and setting true require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Returns:
- true if ECMA-262 compliant
-
isFailFast
public boolean isFailFast()
-
isHandleNullableField
@Deprecated public boolean isHandleNullableField()
Deprecated.Deprecated use {isNullableKeywordEnabled()
instead.- Returns:
- true if the nullable keyword is enabled
-
isNullableKeywordEnabled
public boolean isNullableKeywordEnabled()
Gets if the nullable keyword is enabled.- Returns:
- true if the nullable keyword is enabled
-
isJavaSemantics
public boolean isJavaSemantics()
-
isLosslessNarrowing
public boolean isLosslessNarrowing()
-
isOpenAPI3StyleDiscriminators
@Deprecated public boolean isOpenAPI3StyleDiscriminators()
Deprecated.Indicates whether OpenAPI 3 style discriminators should be supportedDeprecated use {
isDiscriminatorKeywordEnabled()
instead.- Returns:
- true in case discriminators are enabled
- Since:
- 1.0.51
-
isDiscriminatorKeywordEnabled
public boolean isDiscriminatorKeywordEnabled()
Gets if the discriminator keyword is enabled.- Returns:
- true if the discriminator keyword is enabled
-
isPreloadJsonSchema
public boolean isPreloadJsonSchema()
Gets if the schema should be preloaded.- Returns:
- true if it should be preloaded
-
isReadOnly
public boolean isReadOnly()
-
isStrict
public boolean isStrict(java.lang.String keyword)
Answers whether a keyword's validators may relax their analysis. The default is to perform strict checking. One must explicitly allow a validator to be more permissive.Each validator has its own understanding of what is permissive and strict. Consult the keyword's documentation for details.
- Parameters:
keyword
- the keyword to adjust (not null)- Returns:
- Whether to perform a strict validation.
-
isStrict
public boolean isStrict(java.lang.String keyword, java.lang.Boolean defaultValue)
Determines if the validator should perform strict checking.- Parameters:
keyword
- the keyworddefaultValue
- the default value- Returns:
- whether to perform a strict validation
-
isTypeLoose
public boolean isTypeLoose()
- Returns:
- true if type loose is used.
-
isWriteOnly
public boolean isWriteOnly()
-
setApplyDefaultsStrategy
public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
-
setCacheRefs
public void setCacheRefs(boolean cacheRefs)
Sets if schemas loaded from refs will be cached and reused for subsequent runs.Note that setting this to false will affect performance as refs will need to be repeatedly resolved for each evaluation run. It may be needed to be set to false if there are multiple nested applicators like anyOf, oneOf and allOf as that will consume a lot of memory to cache all the permutations.
- Parameters:
cacheRefs
- true to cache
-
setCustomMessageSupported
@Deprecated public void setCustomMessageSupported(boolean customMessageSupported)
Deprecated.Sets whether custom error messages in the schema are used.This is deprecated in favor of setting the error message keyword to use.
- Parameters:
customMessageSupported
- true to use message as the error message keyword
-
setEcma262Validator
public void setEcma262Validator(boolean ecma262Validator)
Sets whether to use a ECMA-262 compliant regular expression validator.This defaults to the false and setting true require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Parameters:
ecma262Validator
- true if ECMA-262 compliant
-
setExecutionContextCustomizer
public void setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
-
setFailFast
public void setFailFast(boolean failFast)
When enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)
doesn't return anySet
<ValidationMessage
>, instead aJsonSchemaException
is thrown as soon as a validation errors is discovered.- Parameters:
failFast
- boolean
-
setFormatAssertionsEnabled
@Deprecated public void setFormatAssertionsEnabled(java.lang.Boolean formatAssertionsEnabled)
Deprecated.Sets the format assertion enabled flag.This is deprecated. Either set this using the builder SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build() or this should be set via executionContext.getExecutionConfig().setFormatAssertionsEnabled(true).
- Parameters:
formatAssertionsEnabled
- the format assertions enabled flag
-
setHandleNullableField
public void setHandleNullableField(boolean handleNullableField)
-
setJavaSemantics
public void setJavaSemantics(boolean javaSemantics)
-
setLocale
@Deprecated public void setLocale(java.util.Locale locale)
Deprecated.Set the locale to consider when generating localised messages.Note that this locale is set on a schema basis. To configure the schema on a per execution basis use
ExecutionConfig.setLocale(Locale)
.This is deprecated. Either set this using the builder SchemaValidatorsConfig.builder().locale(locale).build() or this should be set via executionContext.getExecutionConfig().setLocale(locale).
- Parameters:
locale
- The locale.
-
setLosslessNarrowing
public void setLosslessNarrowing(boolean losslessNarrowing)
-
setMessageSource
public void setMessageSource(MessageSource messageSource)
Set the message source to use for generating localised messages.- Parameters:
messageSource
- the message source
-
setOpenAPI3StyleDiscriminators
public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
When enabled, the validation ofanyOf
andallOf
in polymorphism will respect OpenAPI 3 style discriminators as described in the OpenAPI 3.0.3 spec. The presence of a discriminator configuration on the schema will lead to the following changes in the behavior:- for
oneOf
the spec is unfortunately very vague. WhetheroneOf
semantics should be affected by discriminators or not is not even 100% clear within the members of the OAS steering committee. ThereforeoneOf
at the moment ignores discriminators - for
anyOf
the validation will choose one of the candidate schemas for validation based on the discriminator property value and will pass validation when this specific schema passes. This is in particular useful when the payload could match multiple candidates in theanyOf
list and could lead to ambiguity. Example: type B has all mandatory properties of A and adds more mandatory ones. Whether the payload is an A or B is determined via the discriminator property name. A payload indicating it is an instance of B then requires passing the validation of B and passing the validation of A would not be sufficient anymore. - for
allOf
use cases with discriminators defined on the copied-in parent type, it is possible to automatically validate against a subtype. Example: some schema specifies that there is a field of type A. A carries a discriminator field and B inherits from A. Then B is automatically a candidate for validation as well and will be chosen in case the discriminator property matches
- Parameters:
openAPI3StyleDiscriminators
- whether or not discriminators should be used. Defaults tofalse
- Since:
- 1.0.51
- for
-
setPathType
public void setPathType(PathType pathType)
Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).- Parameters:
pathType
- The path generation approach.
-
setPreloadJsonSchema
public void setPreloadJsonSchema(boolean preloadJsonSchema)
Sets if the schema should be preloaded.- Parameters:
preloadJsonSchema
- true to preload
-
setPreloadJsonSchemaRefMaxNestingDepth
public void setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)
Sets the max depth of the evaluation path to preload when preloading refs.- Parameters:
preloadJsonSchemaRefMaxNestingDepth
- the max depth to preload
-
setReadOnly
public void setReadOnly(boolean readOnly)
-
setRegularExpressionFactory
public void setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Sets the regular expression factory.This defaults to the JDKRegularExpressionFactory and the implementations require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Parameters:
regularExpressionFactory
- the factory- See Also:
JDKRegularExpressionFactory
,ECMAScriptRegularExpressionFactory
-
setSchemaIdValidator
public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Sets the schema id validator to validate $id.- Parameters:
schemaIdValidator
- the validator
-
setStrict
public void setStrict(java.lang.String keyword, boolean strict)
Alters the strictness of validations for a specific keyword. When set to true, instructs the keyword's validators to perform strict validation. Otherwise, a validator may perform a more permissive check.- Parameters:
keyword
- The keyword to adjust (not null)strict
- Whether to perform strict validations
-
setTypeLoose
public void setTypeLoose(boolean typeLoose)
-
setWriteOnly
public void setWriteOnly(boolean writeOnly)
-
builder
public static SchemaValidatorsConfig.Builder builder()
-
builder
public static SchemaValidatorsConfig.Builder builder(SchemaValidatorsConfig config)
-
isWriteMode
@Deprecated public boolean isWriteMode()
Deprecated.UseisReadOnly
orisWriteOnly
- Returns:
- true if schema is used to write data
-
setLoadCollectors
@Deprecated public void setLoadCollectors(boolean loadCollectors)
Deprecated.Sets if collectors are to be loaded.This is deprecated in favor of the caller calling
CollectorContext.loadCollectors()
manually.- Parameters:
loadCollectors
- to load collectors
-
doLoadCollectors
@Deprecated public boolean doLoadCollectors()
Deprecated.Gets if collectors are to be loaded.- Returns:
- if collectors are to be loader
-
disableUnevaluatedAnalysis
@Deprecated public SchemaValidatorsConfig disableUnevaluatedAnalysis()
Deprecated.
-
disableUnevaluatedItems
@Deprecated public SchemaValidatorsConfig disableUnevaluatedItems()
Deprecated.
-
disableUnevaluatedProperties
@Deprecated public SchemaValidatorsConfig disableUnevaluatedProperties()
Deprecated.
-
enableUnevaluatedAnalysis
@Deprecated public SchemaValidatorsConfig enableUnevaluatedAnalysis()
Deprecated.
-
enableUnevaluatedItems
@Deprecated public SchemaValidatorsConfig enableUnevaluatedItems()
Deprecated.
-
enableUnevaluatedProperties
@Deprecated public SchemaValidatorsConfig enableUnevaluatedProperties()
Deprecated.
-
isUnevaluatedItemsAnalysisDisabled
@Deprecated public boolean isUnevaluatedItemsAnalysisDisabled()
Deprecated.
-
isUnevaluatedItemsAnalysisEnabled
@Deprecated public boolean isUnevaluatedItemsAnalysisEnabled()
Deprecated.
-
isUnevaluatedPropertiesAnalysisDisabled
@Deprecated public boolean isUnevaluatedPropertiesAnalysisDisabled()
Deprecated.
-
isUnevaluatedPropertiesAnalysisEnabled
@Deprecated public boolean isUnevaluatedPropertiesAnalysisEnabled()
Deprecated.
-
-