public class SchemaValidatorsConfig extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ALL_KEYWORD_WALK_LISTENER_KEY |
Constructor and Description |
---|
SchemaValidatorsConfig() |
Modifier and Type | Method and Description |
---|---|
void |
addItemWalkListener(JsonSchemaWalkListener itemWalkListener) |
void |
addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners) |
void |
addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener) |
void |
addKeywordWalkListener(String keyword,
JsonSchemaWalkListener keywordWalkListener) |
void |
addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners) |
void |
addKeywordWalkListeners(String keyword,
List<JsonSchemaWalkListener> keywordWalkListeners) |
void |
addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener) |
void |
addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners) |
void |
addUriTranslator(URITranslator uriTranslator) |
boolean |
doLoadCollectors() |
ApplyDefaultsStrategy |
getApplyDefaultsStrategy() |
List<JsonSchemaWalkListener> |
getArrayItemWalkListeners() |
CollectorContext |
getCollectorContext() |
Map<String,List<JsonSchemaWalkListener>> |
getKeywordWalkListenersMap() |
PathType |
getPathType()
Get the approach used to generate paths in messages, logs and errors.
|
List<JsonSchemaWalkListener> |
getPropertyWalkListeners() |
Map<String,String> |
getUriMappings()
Deprecated.
Use
getUriTranslator() instead |
URITranslator.CompositeURITranslator |
getUriTranslator() |
boolean |
isEcma262Validator() |
boolean |
isFailFast() |
boolean |
isHandleNullableField() |
boolean |
isJavaSemantics() |
boolean |
isLosslessNarrowing() |
boolean |
isOpenAPI3StyleDiscriminators()
Indicates whether OpenAPI 3 style discriminators should be supported
|
boolean |
isResetCollectorContext() |
boolean |
isStrict(String keyword)
Answers whether a keyword's validators may relax their analysis.
|
boolean |
isTypeLoose() |
boolean |
isWriteMode() |
void |
setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) |
void |
setCollectorContext(CollectorContext collectorContext) |
void |
setEcma262Validator(boolean ecma262Validator) |
void |
setFailFast(boolean failFast)
When enabled,
JsonValidator.validate(JsonNode, JsonNode, String) or
JsonValidator.validate(JsonNode) doesn't return any
Set <ValidationMessage >, instead a
JsonSchemaException is thrown as soon as a validation errors is
discovered. |
void |
setHandleNullableField(boolean handleNullableField) |
void |
setJavaSemantics(boolean javaSemantics) |
void |
setLoadCollectors(boolean loadCollectors) |
void |
setLosslessNarrowing(boolean losslessNarrowing) |
void |
setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
When enabled, the validation of
anyOf and allOf 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 |
setResetCollectorContext(boolean resetCollectorContext) |
void |
setStrict(String keyword,
boolean strict)
Alters the strictness of validations for a specific keyword.
|
void |
setTypeLoose(boolean typeLoose) |
void |
setUriMappings(Map<String,String> uriMappings)
Deprecated.
Use
addUriTranslator() instead |
void |
setWriteMode(boolean writeMode)
When set to true considers that schema is used to write data then ReadOnlyValidator is activated.
|
public static final String ALL_KEYWORD_WALK_LISTENER_KEY
public boolean isTypeLoose()
public void setTypeLoose(boolean typeLoose)
public void setFailFast(boolean failFast)
JsonValidator.validate(JsonNode, JsonNode, String)
or
JsonValidator.validate(JsonNode)
doesn't return any
Set
<ValidationMessage
>, instead a
JsonSchemaException
is thrown as soon as a validation errors is
discovered.failFast
- booleanpublic boolean isFailFast()
public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
public ApplyDefaultsStrategy getApplyDefaultsStrategy()
public URITranslator.CompositeURITranslator getUriTranslator()
public void addUriTranslator(URITranslator uriTranslator)
@Deprecated public Map<String,String> getUriMappings()
getUriTranslator()
instead@Deprecated public void setUriMappings(Map<String,String> uriMappings)
addUriTranslator()
insteaduriMappings
- Map of public, normally internet accessible schema URLspublic boolean isHandleNullableField()
public void setHandleNullableField(boolean handleNullableField)
public boolean isEcma262Validator()
public void setEcma262Validator(boolean ecma262Validator)
public boolean isJavaSemantics()
public void setJavaSemantics(boolean javaSemantics)
public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)
public void addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)
public void addKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)
public void addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)
public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
public void addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)
public List<JsonSchemaWalkListener> getPropertyWalkListeners()
public Map<String,List<JsonSchemaWalkListener>> getKeywordWalkListenersMap()
public List<JsonSchemaWalkListener> getArrayItemWalkListeners()
public CollectorContext getCollectorContext()
public void setCollectorContext(CollectorContext collectorContext)
public boolean isLosslessNarrowing()
public void setLosslessNarrowing(boolean losslessNarrowing)
public boolean isOpenAPI3StyleDiscriminators()
public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
anyOf
and allOf
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:
oneOf
the spec is unfortunately very vague. Whether
oneOf
semantics should be affected by discriminators or not is
not even 100% clear within the members of the OAS steering committee.
Therefore oneOf
at the moment ignores discriminatorsanyOf
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 the
anyOf
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.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 matchesopenAPI3StyleDiscriminators
- whether or not discriminators should be
used. Defaults to false
public void setLoadCollectors(boolean loadCollectors)
public boolean doLoadCollectors()
public boolean isResetCollectorContext()
public void setResetCollectorContext(boolean resetCollectorContext)
public boolean isWriteMode()
public void setWriteMode(boolean writeMode)
writeMode
- true if schema is used to write datapublic void setPathType(PathType pathType)
pathType
- The path generation approach.public PathType getPathType()
public boolean isStrict(String keyword)
Each validator has its own understanding of what is permissive and strict. Consult the keyword's documentation for details.
keyword
- the keyword to adjust (not null)public void setStrict(String keyword, boolean strict)
keyword
- The keyword to adjust (not null)strict
- Whether to perform strict validationsCopyright © 2023. All rights reserved.