Package com.networknt.schema
Class SchemaValidatorsConfig
- java.lang.Object
-
- com.networknt.schema.SchemaValidatorsConfig
-
public class SchemaValidatorsConfig extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALL_KEYWORD_WALK_LISTENER_KEY
-
Constructor Summary
Constructors Constructor Description SchemaValidatorsConfig()
-
Method Summary
-
-
-
Field Detail
-
ALL_KEYWORD_WALK_LISTENER_KEY
public static final String ALL_KEYWORD_WALK_LISTENER_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
isTypeLoose
public boolean isTypeLoose()
-
setTypeLoose
public void setTypeLoose(boolean typeLoose)
-
setFailFast
public void setFailFast(boolean failFast)
When enabled,JsonValidator.validate(JsonNode, JsonNode, String)
orJsonValidator.validate(JsonNode)
doesn't return anySet
<ValidationMessage
>, instead aJsonSchemaException
is thrown as soon as a validation errors is discovered.- Parameters:
failFast
- boolean
-
isFailFast
public boolean isFailFast()
-
setApplyDefaultsStrategy
public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
-
getApplyDefaultsStrategy
public ApplyDefaultsStrategy getApplyDefaultsStrategy()
-
isHandleNullableField
public boolean isHandleNullableField()
-
setHandleNullableField
public void setHandleNullableField(boolean handleNullableField)
-
isEcma262Validator
public boolean isEcma262Validator()
-
setEcma262Validator
public void setEcma262Validator(boolean ecma262Validator)
-
isJavaSemantics
public boolean isJavaSemantics()
-
setJavaSemantics
public void setJavaSemantics(boolean javaSemantics)
-
addKeywordWalkListener
public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
-
addKeywordWalkListener
public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)
-
addKeywordWalkListeners
public void addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)
-
addKeywordWalkListeners
public void addKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)
-
addPropertyWalkListeners
public void addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)
-
addPropertyWalkListener
public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
-
addItemWalkListener
public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
-
addItemWalkListeners
public void addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)
-
getPropertyWalkListeners
public List<JsonSchemaWalkListener> getPropertyWalkListeners()
-
getKeywordWalkListenersMap
public Map<String,List<JsonSchemaWalkListener>> getKeywordWalkListenersMap()
-
getArrayItemWalkListeners
public List<JsonSchemaWalkListener> getArrayItemWalkListeners()
-
getCollectorContext
public CollectorContext getCollectorContext()
-
setCollectorContext
public void setCollectorContext(CollectorContext collectorContext)
-
isLosslessNarrowing
public boolean isLosslessNarrowing()
-
setLosslessNarrowing
public void setLosslessNarrowing(boolean losslessNarrowing)
-
isOpenAPI3StyleDiscriminators
public boolean isOpenAPI3StyleDiscriminators()
Indicates whether OpenAPI 3 style discriminators should be supported- Returns:
- true in case discriminators are enabled
- Since:
- 1.0.51
-
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
-
setLoadCollectors
public void setLoadCollectors(boolean loadCollectors)
-
doLoadCollectors
public boolean doLoadCollectors()
-
-