From e9669af662ad6065a5f3a4eccc17807a52ac41cf Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 21 Sep 2025 10:04:03 +0800 Subject: [PATCH 01/74] Refactor to remove ErrorMessageType --- .../networknt/schema/BaseJsonValidator.java | 21 +--- .../networknt/schema/ContainsValidator.java | 2 +- .../schema/CustomErrorMessageType.java | 35 ------ .../networknt/schema/DynamicRefValidator.java | 8 +- .../networknt/schema/ErrorMessageType.java | 38 ------ .../com/networknt/schema/FormatKeyword.java | 10 +- .../com/networknt/schema/FormatValidator.java | 9 +- .../com/networknt/schema/ItemsValidator.java | 2 +- .../java/com/networknt/schema/JsonSchema.java | 17 +-- .../MessageSourceValidationMessage.java | 4 +- .../schema/MinMaxContainsValidator.java | 2 +- .../schema/RecursiveRefValidator.java | 10 +- .../com/networknt/schema/RefValidator.java | 8 +- .../networknt/schema/UnionTypeValidator.java | 2 +- .../networknt/schema/ValidationMessage.java | 89 ++++++------- .../networknt/schema/ValidatorTypeCode.java | 118 ++++++++---------- .../format/BaseFormatJsonValidator.java | 5 +- .../schema/output/OutputUnitData.java | 6 +- .../schema/AbstractJsonSchemaTest.java | 10 +- .../schema/CustomMetaSchemaTest.java | 4 +- .../schema/DiscriminatorValidatorTest.java | 20 +-- .../schema/ExclusiveMinimumValidatorTest.java | 2 +- .../com/networknt/schema/Issue426Test.java | 2 +- .../com/networknt/schema/MessageTest.java | 4 +- .../schema/MultipleOfValidatorTest.java | 10 +- .../networknt/schema/OneOfValidatorTest.java | 10 +- .../networknt/schema/TypeValidatorTest.java | 4 +- .../schema/UnevaluatedItemsValidatorTest.java | 8 +- .../UnevaluatedPropertiesValidatorTest.java | 8 +- .../com/networknt/schema/VocabularyTest.java | 4 +- .../networknt/schema/oas/OpenApi30Test.java | 4 +- .../networknt/schema/oas/OpenApi31Test.java | 14 +-- .../networknt/schema/utils/JsonNodesTest.java | 8 +- 33 files changed, 186 insertions(+), 312 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/CustomErrorMessageType.java delete mode 100644 src/main/java/com/networknt/schema/ErrorMessageType.java diff --git a/src/main/java/com/networknt/schema/BaseJsonValidator.java b/src/main/java/com/networknt/schema/BaseJsonValidator.java index c1313ff44..88a5d536b 100644 --- a/src/main/java/com/networknt/schema/BaseJsonValidator.java +++ b/src/main/java/com/networknt/schema/BaseJsonValidator.java @@ -41,16 +41,8 @@ public abstract class BaseJsonValidator implements JsonValidator { protected final JsonNodePath evaluationPath; protected final JsonSchema evaluationParentSchema; - // Pending removal - protected final ErrorMessageType errorMessageType; - public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidatorTypeCode validatorType, ValidationContext validationContext) { - this(schemaLocation, evaluationPath, schemaNode, parentSchema, validatorType, validatorType, validationContext); - } - - public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ErrorMessageType errorMessageType, Keyword keyword, + JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { this.validationContext = validationContext; this.schemaNode = schemaNode; @@ -64,8 +56,6 @@ public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } else { this.errorMessage = null; } - - this.errorMessageType = errorMessageType; this.evaluationPath = evaluationPath; this.evaluationParentSchema = null; } @@ -75,7 +65,6 @@ public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP * * @param schemaNode the schema node * @param validationContext the validation context - * @param errorMessageType the error message type * @param keyword the keyword * @param parentSchema the parent schema * @param schemaLocation the schema location @@ -88,7 +77,6 @@ protected BaseJsonValidator( JsonNode schemaNode, ValidationContext validationContext, /* Below from ValidationMessageHandler */ - ErrorMessageType errorMessageType, Keyword keyword, JsonSchema parentSchema, SchemaLocation schemaLocation, @@ -103,7 +91,6 @@ protected BaseJsonValidator( this.schemaLocation = schemaLocation; this.errorMessage = errorMessage; - this.errorMessageType = errorMessageType; this.evaluationPath = evaluationPath; this.evaluationParentSchema = evaluationParentSchema; } @@ -233,9 +220,9 @@ protected MessageSourceValidationMessage.Builder message() { if (failFast) { throw new FailFastAssertionException(message); } - }).code(this.errorMessageType.getErrorCode()).schemaNode(this.schemaNode).schemaLocation(this.schemaLocation) - .evaluationPath(this.evaluationPath).type(this.keyword != null ? this.keyword.getValue() : null) - .messageKey(this.errorMessageType.getErrorCodeValue()); + }).schemaNode(this.schemaNode).schemaLocation(this.schemaLocation) + .evaluationPath(this.evaluationPath).keyword(this.keyword != null ? this.keyword.getValue() : null) + .messageKey(this.getKeyword()); } /** diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/ContainsValidator.java index a5f971454..af0183849 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/ContainsValidator.java @@ -194,7 +194,7 @@ private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode } executionContext.addError(message().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) .locale(locale).failFast(failFast).arguments(String.valueOf(bounds), this.schema.getSchemaNode().toString()) - .code(validatorTypeCode.getErrorCode()).type(validatorTypeCode.getValue()).build()); + .keyword(validatorTypeCode.getValue()).build()); } /** diff --git a/src/main/java/com/networknt/schema/CustomErrorMessageType.java b/src/main/java/com/networknt/schema/CustomErrorMessageType.java deleted file mode 100644 index ef08734ec..000000000 --- a/src/main/java/com/networknt/schema/CustomErrorMessageType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema; - -public class CustomErrorMessageType implements ErrorMessageType { - private final String errorCode; - - private CustomErrorMessageType(String errorCode) { - this.errorCode = errorCode; - } - - public static ErrorMessageType of(String errorCode) { - return new CustomErrorMessageType(errorCode); - } - - @Override - public String getErrorCode() { - return errorCode; - } - -} \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/DynamicRefValidator.java b/src/main/java/com/networknt/schema/DynamicRefValidator.java index 1cf2d0632..1517df949 100644 --- a/src/main/java/com/networknt/schema/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/DynamicRefValidator.java @@ -94,8 +94,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.DYNAMIC_REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -111,8 +111,8 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.DYNAMIC_REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/ErrorMessageType.java b/src/main/java/com/networknt/schema/ErrorMessageType.java deleted file mode 100644 index 72b0acbd0..000000000 --- a/src/main/java/com/networknt/schema/ErrorMessageType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema; - -public interface ErrorMessageType { - /** - * Your error code. Please ensure global uniqueness. Builtin error codes are sequential numbers. - *

- * Customer error codes could have a prefix to denote the namespace of your custom keywords and errors. - * - * @return error code - */ - String getErrorCode(); - - /** - * Get the text representation of the error code. - * - * @return The error code value. - */ - default String getErrorCodeValue() { - return getErrorCode(); - } - -} diff --git a/src/main/java/com/networknt/schema/FormatKeyword.java b/src/main/java/com/networknt/schema/FormatKeyword.java index cb2031ffb..44d780526 100644 --- a/src/main/java/com/networknt/schema/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/FormatKeyword.java @@ -27,21 +27,19 @@ */ public class FormatKeyword implements Keyword { private final String value; - private final ErrorMessageType errorMessageType; private final Map formats; public FormatKeyword(Map formats) { this(ValidatorTypeCode.FORMAT, formats); } - public FormatKeyword(ValidatorTypeCode type, Map formats) { - this(type.getValue(), type, formats); + public FormatKeyword(Keyword type, Map formats) { + this(type.getValue(), formats); } - public FormatKeyword(String value, ErrorMessageType errorMessageType, Map formats) { + public FormatKeyword(String value, Map formats) { this.value = value; this.formats = formats; - this.errorMessageType = errorMessageType; } Collection getFormats() { @@ -56,7 +54,7 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev format = this.formats.get(formatName); } return new FormatValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, format, - errorMessageType, this); + this); } @Override diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/FormatValidator.java index 4725786f0..a71b5072b 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/FormatValidator.java @@ -34,16 +34,11 @@ public class FormatValidator extends BaseFormatJsonValidator implements JsonVali public FormatValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext, Format format, - ErrorMessageType errorMessageType, Keyword keyword) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, errorMessageType, keyword, validationContext); + Keyword keyword) { + super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); this.format = format; } - public FormatValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext, Format format, ValidatorTypeCode type) { - this(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, format, type, type); - } - /** * Gets the annotation value. * diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/ItemsValidator.java index 0cf913cd4..1099a354f 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/ItemsValidator.java @@ -176,7 +176,7 @@ private boolean doValidate(ExecutionContext executionContext, int i, JsonNode no } else { // no additional item allowed, return error executionContext.addError(message().instanceNode(rootNode).instanceLocation(instanceLocation) - .type("additionalItems") + .keyword("additionalItems") .messageKey("additionalItems") .evaluationPath(this.additionalItemsEvaluationPath) .schemaLocation(this.additionalItemsSchemaLocation) diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index 69626417f..c10556f87 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -185,7 +185,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc if (!validator.validate(id, rootSchema, schemaLocation, result, validationContext)) { SchemaLocation idSchemaLocation = schemaLocation.append(validationContext.getMetaSchema().getIdKeyword()); ValidationMessage validationMessage = ValidationMessage.builder() - .code(ValidatorTypeCode.ID.getValue()).type(ValidatorTypeCode.ID.getValue()) + .messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) .arguments(id, validationContext.getMetaSchema().getIdKeyword(), idSchemaLocation) .schemaLocation(idSchemaLocation) @@ -269,8 +269,6 @@ private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLoc * @param suppressSubSchemaRetrieval to suppress sub schema retrieval * @param schemaNode the schema node * @param validationContext the validation context - * @param errorMessageType the error message type - * @param keyword the keyword * @param parentSchema the parent schema * @param schemaLocation the schema location * @param evaluationPath the evaluation path @@ -289,8 +287,6 @@ protected JsonSchema( JsonNode schemaNode, ValidationContext validationContext, /* Below from ValidationMessageHandler */ - ErrorMessageType errorMessageType, - Keyword keyword, JsonSchema parentSchema, SchemaLocation schemaLocation, JsonNodePath evaluationPath, @@ -350,8 +346,7 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref schemaNode, validationContext, /* Below from ValidationMessageHandler */ - /*errorMessageType*/ null, - /*keyword*/ null, parentSchema, schemaLocation, evaluationPath, + parentSchema, schemaLocation, evaluationPath, evaluationParentSchema, /* errorMessage */ null); } @@ -384,8 +379,6 @@ public JsonSchema withConfig(SchemaValidatorsConfig config) { schemaNode, validationContext, /* Below from ValidationMessageHandler */ - /* errorMessageType */ null, - /* keyword */ null, parentSchema, schemaLocation, evaluationPath, @@ -516,7 +509,7 @@ public JsonSchema getSubSchema(JsonNodePath fragment) { } if (found == null) { ValidationMessage validationMessage = ValidationMessage.builder() - .type(ValidatorTypeCode.REF.getValue()).code("internal.unresolvedRef") + .keyword(ValidatorTypeCode.REF.getValue()).messageKey("internal.unresolvedRef") .message("{0}: Reference {1} cannot be resolved") .instanceLocation(schemaLocation.getFragment()) .schemaLocation(schemaLocation) @@ -634,8 +627,8 @@ private List read(JsonNode schemaNode) { if ("$recursiveAnchor".equals(pname)) { if (!nodeToUse.isBoolean()) { - ValidationMessage validationMessage = ValidationMessage.builder().type("$recursiveAnchor") - .code("internal.invalidRecursiveAnchor") + ValidationMessage validationMessage = ValidationMessage.builder().keyword("$recursiveAnchor") + .messageKey("internal.invalidRecursiveAnchor") .message( "{0}: The value of a $recursiveAnchor must be a Boolean literal but is {1}") .instanceLocation(path) diff --git a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java b/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java index 1871236a2..880ed6877 100644 --- a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java +++ b/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java @@ -63,8 +63,8 @@ public ValidationMessage build() { String messagePattern = null; if (this.errorMessage != null) { messagePattern = this.errorMessage.get(""); - if (this.property != null) { - String specificMessagePattern = this.errorMessage.get(this.property); + if (this.details != null && this.details.get("property") != null) { + String specificMessagePattern = this.errorMessage.get(this.details.get("property")); if (specificMessagePattern != null) { messagePattern = specificMessagePattern; } diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java index 3cbcc476e..3985b57de 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java @@ -65,7 +65,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .instanceLocation(instanceLocation) .messageKey(analysis.getMessageKey()).locale(executionContext.getExecutionConfig().getLocale()) .failFast(executionContext.isFailFast()) - .type(analysis.getMessageKey()) + .keyword(analysis.getMessageKey()) .arguments(parentSchema.getSchemaNode().toString()).build()) .forEach(executionContext::addError); } diff --git a/src/main/java/com/networknt/schema/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/RecursiveRefValidator.java index 31688aa2f..87cd5f21e 100644 --- a/src/main/java/com/networknt/schema/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/RecursiveRefValidator.java @@ -36,7 +36,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat String refValue = schemaNode.asText(); if (!"#".equals(refValue)) { ValidationMessage validationMessage = message() - .type(ValidatorTypeCode.RECURSIVE_REF.getValue()).code("internal.invalidRecursiveRef") + .keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()).messageKey("internal.invalidRecursiveRef") .message("{0}: The value of a $recursiveRef must be '#' but is '{1}'").instanceLocation(schemaLocation.getFragment()) .instanceNode(this.schemaNode) .evaluationPath(evaluationPath).arguments(refValue).build(); @@ -89,8 +89,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.RECURSIVE_REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -106,8 +106,8 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.RECURSIVE_REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/RefValidator.java b/src/main/java/com/networknt/schema/RefValidator.java index c173f8140..8530de4d1 100644 --- a/src/main/java/com/networknt/schema/RefValidator.java +++ b/src/main/java/com/networknt/schema/RefValidator.java @@ -178,8 +178,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -195,8 +195,8 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().type(ValidatorTypeCode.REF.getValue()) - .code("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) + .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index 2a271b258..4a02268c1 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -96,7 +96,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!valid) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) - .type("type") + .keyword("type") .locale(executionContext.getExecutionConfig().getLocale()) .failFast(executionContext.isFailFast()).arguments(nodeType.toString(), error) .build()); diff --git a/src/main/java/com/networknt/schema/ValidationMessage.java b/src/main/java/com/networknt/schema/ValidationMessage.java index 013d8e257..454570db3 100644 --- a/src/main/java/com/networknt/schema/ValidationMessage.java +++ b/src/main/java/com/networknt/schema/ValidationMessage.java @@ -29,6 +29,7 @@ import java.text.MessageFormat; import java.util.Arrays; +import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; @@ -44,15 +45,13 @@ "messageKey", "arguments", "details" }) @JsonInclude(Include.NON_NULL) public class ValidationMessage { - private final String type; - private final String code; + private final String keyword; @JsonSerialize(using = ToStringSerializer.class) private final JsonNodePath evaluationPath; @JsonSerialize(using = ToStringSerializer.class) private final SchemaLocation schemaLocation; @JsonSerialize(using = ToStringSerializer.class) private final JsonNodePath instanceLocation; - private final String property; private final Object[] arguments; private final String messageKey; private final Supplier messageSupplier; @@ -60,16 +59,14 @@ public class ValidationMessage { private final JsonNode instanceNode; private final JsonNode schemaNode; - ValidationMessage(String type, String code, JsonNodePath evaluationPath, SchemaLocation schemaLocation, - JsonNodePath instanceLocation, String property, Object[] arguments, Map details, + ValidationMessage(String keyword, JsonNodePath evaluationPath, SchemaLocation schemaLocation, + JsonNodePath instanceLocation, Object[] arguments, Map details, String messageKey, Supplier messageSupplier, JsonNode instanceNode, JsonNode schemaNode) { super(); - this.type = type; - this.code = code; + this.keyword = keyword; this.instanceLocation = instanceLocation; this.schemaLocation = schemaLocation; this.evaluationPath = evaluationPath; - this.property = property; this.arguments = arguments; this.details = details; this.messageKey = messageKey; @@ -78,10 +75,6 @@ public class ValidationMessage { this.schemaNode = schemaNode; } - public String getCode() { - return code; - } - /** * The instance location is the location of the JSON value within the root * instance being validated. @@ -147,7 +140,17 @@ public JsonNode getSchemaNode() { * @return the property name */ public String getProperty() { - return property; + if (details == null) { + return null; + } + return (String) getDetails().get("property"); + } + + public Integer getIndex() { + if (details == null) { + return null; + } + return (Integer) getDetails().get("index"); } public Object[] getArguments() { @@ -209,8 +212,7 @@ public boolean equals(Object o) { ValidationMessage that = (ValidationMessage) o; - if (type != null ? !type.equals(that.type) : that.type != null) return false; - if (code != null ? !code.equals(that.code) : that.code != null) return false; + if (keyword != null ? !keyword.equals(that.keyword) : that.keyword != null) return false; if (instanceLocation != null ? !instanceLocation.equals(that.instanceLocation) : that.instanceLocation != null) return false; if (evaluationPath != null ? !evaluationPath.equals(that.evaluationPath) : that.evaluationPath != null) return false; if (details != null ? !details.equals(that.details) : that.details != null) return false; @@ -220,8 +222,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (code != null ? code.hashCode() : 0); + int result = keyword != null ? keyword.hashCode() : 0; result = 31 * result + (instanceLocation != null ? instanceLocation.hashCode() : 0); result = 31 * result + (evaluationPath != null ? evaluationPath.hashCode() : 0); result = 31 * result + (details != null ? details.hashCode() : 0); @@ -230,8 +231,8 @@ public int hashCode() { return result; } - public String getType() { - return type; + public String getKeyword() { + return keyword; } public static Builder builder() { @@ -248,12 +249,10 @@ public Builder self() { public static abstract class BuilderSupport { public abstract S self(); - protected String type; - protected String code; + protected String keyword; protected JsonNodePath evaluationPath; protected SchemaLocation schemaLocation; protected JsonNodePath instanceLocation; - protected String property; protected Object[] arguments; protected Map details; protected MessageFormat format; @@ -264,16 +263,28 @@ public static abstract class BuilderSupport { protected JsonNode instanceNode; protected JsonNode schemaNode; - public S type(String type) { - this.type = type; + public S keyword(String keyword) { + this.keyword = keyword; return self(); } - public S code(String code) { - this.code = code; + public S property(String properties) { + if (this.details == null) { + this.details = new HashMap<>(); + } + this.details.put("property", properties); + return self(); + } + + public S index(Integer index) { + if (this.details == null) { + this.details = new HashMap<>(); + } + this.details.put("index", index); return self(); } + /** * The instance location is the location of the JSON value within the root * instance being validated. @@ -313,11 +324,6 @@ public S evaluationPath(JsonNodePath evaluationPath) { return self(); } - public S property(String property) { - this.property = property; - return self(); - } - public S arguments(Object... arguments) { this.arguments = arguments; return self(); @@ -333,11 +339,6 @@ public S format(MessageFormat format) { return self(); } - @Deprecated - public S customMessage(String message) { - return message(message); - } - /** * Explicitly sets the message pattern to be used. *

@@ -396,8 +397,8 @@ public ValidationMessage build() { return formatter.format(getMessageArguments()); }); } - return new ValidationMessage(type, code, evaluationPath, schemaLocation, instanceLocation, - property, arguments, details, messageKey, messageSupplier, this.instanceNode, this.schemaNode); + return new ValidationMessage(keyword, evaluationPath, schemaLocation, instanceLocation, + arguments, details, messageKey, messageSupplier, this.instanceNode, this.schemaNode); } protected Object[] getMessageArguments() { @@ -409,12 +410,8 @@ protected Object[] getMessageArguments() { return objs; } - protected String getType() { - return type; - } - - protected String getCode() { - return code; + protected String getKeyword() { + return keyword; } protected JsonNodePath getEvaluationPath() { @@ -429,10 +426,6 @@ protected JsonNodePath getInstanceLocation() { return instanceLocation; } - protected String getProperty() { - return property; - } - protected Object[] getArguments() { return arguments; } diff --git a/src/main/java/com/networknt/schema/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/ValidatorTypeCode.java index 458efc762..691f0fc9b 100644 --- a/src/main/java/com/networknt/schema/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/ValidatorTypeCode.java @@ -57,62 +57,62 @@ EnumSet getVersions() { } } -public enum ValidatorTypeCode implements Keyword, ErrorMessageType { - ADDITIONAL_PROPERTIES("additionalProperties", "1001", AdditionalPropertiesValidator::new, VersionCode.MaxV7), - ALL_OF("allOf", "1002", AllOfValidator::new, VersionCode.MaxV7), - ANY_OF("anyOf", "1003", AnyOfValidator::new, VersionCode.MaxV7), - CONST("const", "1042", ConstValidator::new, VersionCode.MinV6MaxV7), - CONTAINS("contains", "1043", ContainsValidator::new, VersionCode.MinV6MaxV7), - CONTENT_ENCODING("contentEncoding", "1052", ContentEncodingValidator::new, VersionCode.V7), - CONTENT_MEDIA_TYPE("contentMediaType", "1053", ContentMediaTypeValidator::new, VersionCode.V7), - DEPENDENCIES("dependencies", "1007", DependenciesValidator::new, VersionCode.AllVersions), - DEPENDENT_REQUIRED("dependentRequired", "1045", DependentRequired::new, VersionCode.None), - DEPENDENT_SCHEMAS("dependentSchemas", "1046", DependentSchemas::new, VersionCode.None), - DISCRIMINATOR("discriminator", "2001", DiscriminatorValidator::new, VersionCode.None), - DYNAMIC_REF("$dynamicRef", "1051", DynamicRefValidator::new, VersionCode.None), - ENUM("enum", "1008", EnumValidator::new, VersionCode.MaxV7), - EXCLUSIVE_MAXIMUM("exclusiveMaximum", "1038", ExclusiveMaximumValidator::new, VersionCode.MinV6MaxV7), - EXCLUSIVE_MINIMUM("exclusiveMinimum", "1039", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), - FALSE("false", "1041", FalseValidator::new, VersionCode.MinV6), - FORMAT("format", "1009", null, VersionCode.MaxV7) { +public enum ValidatorTypeCode implements Keyword { + ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, VersionCode.MaxV7), + ALL_OF("allOf", AllOfValidator::new, VersionCode.MaxV7), + ANY_OF("anyOf", AnyOfValidator::new, VersionCode.MaxV7), + CONST("const", ConstValidator::new, VersionCode.MinV6MaxV7), + CONTAINS("contains", ContainsValidator::new, VersionCode.MinV6MaxV7), + CONTENT_ENCODING("contentEncoding", ContentEncodingValidator::new, VersionCode.V7), + CONTENT_MEDIA_TYPE("contentMediaType", ContentMediaTypeValidator::new, VersionCode.V7), + DEPENDENCIES("dependencies", DependenciesValidator::new, VersionCode.AllVersions), + DEPENDENT_REQUIRED("dependentRequired", DependentRequired::new, VersionCode.None), + DEPENDENT_SCHEMAS("dependentSchemas", DependentSchemas::new, VersionCode.None), + DISCRIMINATOR("discriminator", DiscriminatorValidator::new, VersionCode.None), + DYNAMIC_REF("$dynamicRef", DynamicRefValidator::new, VersionCode.None), + ENUM("enum", EnumValidator::new, VersionCode.MaxV7), + EXCLUSIVE_MAXIMUM("exclusiveMaximum", ExclusiveMaximumValidator::new, VersionCode.MinV6MaxV7), + EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), + FALSE("false", FalseValidator::new, VersionCode.MinV6), + FORMAT("format", null, VersionCode.MaxV7) { @Override public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, - ID("id", "1036", null, VersionCode.AllVersions), - IF_THEN_ELSE("if", "1037", IfValidator::new, VersionCode.V7), - ITEMS_202012("items", "1010", ItemsValidator202012::new, VersionCode.None), - ITEMS("items", "1010", ItemsValidator::new, VersionCode.MaxV7), - MAX_CONTAINS("maxContains", "1006", MinMaxContainsValidator::new, VersionCode.None), - MAX_ITEMS("maxItems", "1012", MaxItemsValidator::new, VersionCode.MaxV7), - MAX_LENGTH("maxLength", "1013", MaxLengthValidator::new, VersionCode.MaxV7), - MAX_PROPERTIES("maxProperties", "1014", MaxPropertiesValidator::new, VersionCode.MaxV7), - MAXIMUM("maximum", "1011", MaximumValidator::new, VersionCode.MaxV7), - MIN_CONTAINS("minContains", "1049", MinMaxContainsValidator::new, VersionCode.None), - MIN_ITEMS("minItems", "1016", MinItemsValidator::new, VersionCode.MaxV7), - MIN_LENGTH("minLength", "1017", MinLengthValidator::new, VersionCode.MaxV7), - MIN_PROPERTIES("minProperties", "1018", MinPropertiesValidator::new, VersionCode.MaxV7), - MINIMUM("minimum", "1015", MinimumValidator::new, VersionCode.MaxV7), - MULTIPLE_OF("multipleOf", "1019", MultipleOfValidator::new, VersionCode.MaxV7), - NOT_ALLOWED("notAllowed", "1033", NotAllowedValidator::new, VersionCode.AllVersions), - NOT("not", "1020", NotValidator::new, VersionCode.MaxV7), - ONE_OF("oneOf", "1022", OneOfValidator::new, VersionCode.MaxV7), - PATTERN_PROPERTIES("patternProperties", "1024", PatternPropertiesValidator::new, VersionCode.MaxV7), - PATTERN("pattern", "1023", PatternValidator::new, VersionCode.MaxV7), - PREFIX_ITEMS("prefixItems", "1048", PrefixItemsValidator::new, VersionCode.None), - PROPERTIES("properties", "1025", PropertiesValidator::new, VersionCode.MaxV7), - PROPERTYNAMES("propertyNames", "1044", PropertyNamesValidator::new, VersionCode.MinV6MaxV7), - READ_ONLY("readOnly", "1032", ReadOnlyValidator::new, VersionCode.V7), - RECURSIVE_REF("$recursiveRef", "1050", RecursiveRefValidator::new, VersionCode.None), - REF("$ref", "1026", RefValidator::new, VersionCode.MaxV7), - REQUIRED("required", "1028", RequiredValidator::new, VersionCode.MaxV7), - TRUE("true", "1040", TrueValidator::new, VersionCode.MinV6), - TYPE("type", "1029", TypeValidator::new, VersionCode.MaxV7), - UNEVALUATED_ITEMS("unevaluatedItems", "1021", UnevaluatedItemsValidator::new, VersionCode.None), - UNEVALUATED_PROPERTIES("unevaluatedProperties","1047",UnevaluatedPropertiesValidator::new,VersionCode.None), - UNION_TYPE("unionType", "1030", UnionTypeValidator::new, VersionCode.None), - UNIQUE_ITEMS("uniqueItems", "1031", UniqueItemsValidator::new, VersionCode.MaxV7), - WRITE_ONLY("writeOnly", "1027", WriteOnlyValidator::new, VersionCode.V7), + ID("id", null, VersionCode.AllVersions), + IF_THEN_ELSE("if", IfValidator::new, VersionCode.V7), + ITEMS_202012("items", ItemsValidator202012::new, VersionCode.None), + ITEMS("items", ItemsValidator::new, VersionCode.MaxV7), + MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, VersionCode.None), + MAX_ITEMS("maxItems", MaxItemsValidator::new, VersionCode.MaxV7), + MAX_LENGTH("maxLength", MaxLengthValidator::new, VersionCode.MaxV7), + MAX_PROPERTIES("maxProperties", MaxPropertiesValidator::new, VersionCode.MaxV7), + MAXIMUM("maximum", MaximumValidator::new, VersionCode.MaxV7), + MIN_CONTAINS("minContains", MinMaxContainsValidator::new, VersionCode.None), + MIN_ITEMS("minItems", MinItemsValidator::new, VersionCode.MaxV7), + MIN_LENGTH("minLength", MinLengthValidator::new, VersionCode.MaxV7), + MIN_PROPERTIES("minProperties", MinPropertiesValidator::new, VersionCode.MaxV7), + MINIMUM("minimum", MinimumValidator::new, VersionCode.MaxV7), + MULTIPLE_OF("multipleOf", MultipleOfValidator::new, VersionCode.MaxV7), + NOT_ALLOWED("notAllowed", NotAllowedValidator::new, VersionCode.AllVersions), + NOT("not", NotValidator::new, VersionCode.MaxV7), + ONE_OF("oneOf", OneOfValidator::new, VersionCode.MaxV7), + PATTERN_PROPERTIES("patternProperties", PatternPropertiesValidator::new, VersionCode.MaxV7), + PATTERN("pattern", PatternValidator::new, VersionCode.MaxV7), + PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, VersionCode.None), + PROPERTIES("properties", PropertiesValidator::new, VersionCode.MaxV7), + PROPERTYNAMES("propertyNames", PropertyNamesValidator::new, VersionCode.MinV6MaxV7), + READ_ONLY("readOnly", ReadOnlyValidator::new, VersionCode.V7), + RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, VersionCode.None), + REF("$ref", RefValidator::new, VersionCode.MaxV7), + REQUIRED("required", RequiredValidator::new, VersionCode.MaxV7), + TRUE("true", TrueValidator::new, VersionCode.MinV6), + TYPE("type", TypeValidator::new, VersionCode.MaxV7), + UNEVALUATED_ITEMS("unevaluatedItems", UnevaluatedItemsValidator::new, VersionCode.None), + UNEVALUATED_PROPERTIES("unevaluatedProperties",UnevaluatedPropertiesValidator::new,VersionCode.None), + UNION_TYPE("unionType", UnionTypeValidator::new, VersionCode.None), + UNIQUE_ITEMS("uniqueItems", UniqueItemsValidator::new, VersionCode.MaxV7), + WRITE_ONLY("writeOnly", WriteOnlyValidator::new, VersionCode.V7), ; private static final Map CONSTANTS = new HashMap<>(); @@ -124,13 +124,11 @@ public enum ValidatorTypeCode implements Keyword, ErrorMessageType { } private final String value; - private final String errorCode; private final ValidatorFactory validatorFactory; private final VersionCode versionCode; - ValidatorTypeCode(String value, String errorCode, ValidatorFactory validatorFactory, VersionCode versionCode) { + ValidatorTypeCode(String value, ValidatorFactory validatorFactory, VersionCode versionCode) { this.value = value; - this.errorCode = errorCode; this.validatorFactory = validatorFactory; this.versionCode = versionCode; } @@ -173,17 +171,7 @@ public String getValue() { return this.value; } - @Override - public String getErrorCode() { - return this.errorCode; - } - public VersionCode getVersionCode() { return this.versionCode; } - - @Override - public String getErrorCodeValue() { - return getValue(); - } } diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index cda3a3be7..94813221a 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.BaseJsonValidator; -import com.networknt.schema.ErrorMessageType; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; @@ -17,9 +16,9 @@ public abstract class BaseFormatJsonValidator extends BaseJsonValidator { protected final boolean assertionsEnabled; public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ErrorMessageType errorMessageType, Keyword keyword, + JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, errorMessageType, keyword, validationContext); + super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); VersionFlag dialect = this.validationContext.getMetaSchema().getSpecification(); if (dialect == null || dialect.getVersionFlagValue() < VersionFlag.V201909.getVersionFlagValue()) { assertionsEnabled = true; diff --git a/src/main/java/com/networknt/schema/output/OutputUnitData.java b/src/main/java/com/networknt/schema/output/OutputUnitData.java index 0f195f6e6..9398d4f53 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitData.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitData.java @@ -88,9 +88,9 @@ public static OutputUnitData from(List validationMessages, Ex assertionSchemaLocation, assertion.getInstanceLocation()); valid.put(key, false); Map errorMap = errors.computeIfAbsent(key, k -> new LinkedHashMap<>()); - Object value = errorMap.get(assertion.getType()); + Object value = errorMap.get(assertion.getKeyword()); if (value == null) { - errorMap.put(assertion.getType(), assertionMapper.apply(assertion)); + errorMap.put(assertion.getKeyword(), assertionMapper.apply(assertion)); } else { // Existing error, make it into a list if (value instanceof List) { @@ -99,7 +99,7 @@ public static OutputUnitData from(List validationMessages, Ex List values = new ArrayList<>(); values.add(value.toString()); values.add(assertionMapper.apply(assertion)); - errorMap.put(assertion.getType(), values); + errorMap.put(assertion.getKeyword(), values); } } } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index aab62c27c..8d226fabb 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -22,8 +22,7 @@ abstract class AbstractJsonSchemaTest { private static final String SCHEMA = "$schema"; private static final SpecVersion.VersionFlag DEFAULT_VERSION_FLAG = SpecVersion.VersionFlag.V202012; - private static final String ASSERT_MSG_ERROR_CODE = "Validation result should contain {0} error code"; - private static final String ASSERT_MSG_TYPE = "Validation result should contain {0} type"; + private static final String ASSERT_MSG_KEYWORD = "Validation result should contain {0} keyword"; protected List validate(String dataPath) { JsonNode dataNode = getJsonNodeFromPath(dataPath); @@ -34,11 +33,8 @@ protected void assertValidatorType(String filename, ValidatorTypeCode validatorT List validationMessages = validate(getDataTestFolder() + filename); assertTrue( - validationMessages.stream().anyMatch(vm -> validatorTypeCode.getErrorCode().equals(vm.getCode())), - () -> MessageFormat.format(ASSERT_MSG_ERROR_CODE, validatorTypeCode.getErrorCode())); - assertTrue( - validationMessages.stream().anyMatch(vm -> validatorTypeCode.getValue().equals(vm.getType())), - () -> MessageFormat.format(ASSERT_MSG_TYPE, validatorTypeCode.getValue())); + validationMessages.stream().anyMatch(vm -> validatorTypeCode.getValue().equals(vm.getKeyword())), + () -> MessageFormat.format(ASSERT_MSG_KEYWORD, validatorTypeCode.getValue())); } protected abstract String getDataTestFolder(); diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 6e616893b..11a8e4a8b 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -64,10 +64,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode throw new IllegalArgumentException("value not found in enum. value: " + value + " enum: " + enumValues); } String valueName = enumNames.get(idx); - ValidationMessage validationMessage = ValidationMessage.builder().type(keyword) + ValidationMessage validationMessage = ValidationMessage.builder().keyword(keyword) .schemaNode(node) .instanceNode(node) - .code("tests.example.enumNames").message("{0}: enumName is {1}").instanceLocation(instanceLocation) + .messageKey("tests.example.enumNames").message("{0}: enumName is {1}").instanceLocation(instanceLocation) .arguments(valueName).build(); executionContext.addError(validationMessage); } diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 0133260b8..0327d44f9 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -431,8 +431,8 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); } @@ -527,8 +527,8 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); } @@ -627,8 +627,8 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); } @@ -680,9 +680,9 @@ void oneOfMissingDiscriminatorValue() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); - assertEquals("required", list.get(2).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); + assertEquals("required", list.get(2).getKeyword()); } /** @@ -775,6 +775,6 @@ void anyOfMissingDiscriminatorValue() { JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); - assertEquals("required", list.get(0).getType()); + assertEquals("required", list.get(0).getKeyword()); } } diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 3d75bc16f..332661c53 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -50,7 +50,7 @@ void draftV4ShouldHaveExclusiveMinimum() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals(1, messages.stream().filter(m -> "minimum".equals(m.getType())).count()); + assertEquals(1, messages.stream().filter(m -> "minimum".equals(m.getKeyword())).count()); messages = schema.validate(validData, InputFormat.JSON); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index c7dd2f547..7775a4804 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -35,7 +35,7 @@ void shouldWorkV7() throws Exception { final JsonNode message = schema.schemaNode.get("message"); for(ValidationMessage error : errors) { //validating custom message - Assertions.assertEquals(message.get(error.getType()).asText(), error.getMessage()); + Assertions.assertEquals(message.get(error.getKeyword()).asText(), error.getMessage()); } } } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 424322867..f278c78ca 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -29,14 +29,12 @@ */ class MessageTest { static class EqualsValidator extends BaseJsonValidator { - private static final ErrorMessageType ERROR_MESSAGE_TYPE = () -> "equals"; - private final String value; EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ERROR_MESSAGE_TYPE, keyword, validationContext); + super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); this.value = schemaNode.textValue(); } diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index cc50aeb30..4f6fb2c36 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -54,7 +54,7 @@ void test() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); - assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getType())).count()); + assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); messages = schema.validate(validData, InputFormat.JSON); assertEquals(0, messages.size()); @@ -71,20 +71,20 @@ void testTypeLoose() { // Without type loose this has 2 type and 1 multipleOf errors List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); - assertEquals(2, messages.stream().filter(m -> "type".equals(m.getType())).count()); - assertEquals(1, messages.stream().filter(m -> "multipleOf".equals(m.getType())).count()); + assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); + assertEquals(1, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); // 2 type errors messages = schema.validate(validTypeLooseInputData, InputFormat.JSON); assertEquals(2, messages.size()); - assertEquals(2, messages.stream().filter(m -> "type".equals(m.getType())).count()); + assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); // With type loose this has 3 multipleOf errors SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); JsonSchema typeLoose = factory.getSchema(schemaData, config); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); - assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getType())).count()); + assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); // No errors messages = typeLoose.validate(validTypeLooseInputData, InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 774d35f2e..1b41cb86b 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -68,7 +68,7 @@ void oneOfMultiple() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", assertions.get(0).getType()); + assertEquals("oneOf", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); assertEquals("$: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", @@ -109,20 +109,20 @@ void oneOfZero() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", assertions.get(0).getType()); + assertEquals("oneOf", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); assertEquals("$: must be valid to one and only one schema, but 0 are valid", assertions.get(0).getMessage()); - assertEquals("additionalProperties", assertions.get(1).getType()); + assertEquals("additionalProperties", assertions.get(1).getKeyword()); assertEquals("$", assertions.get(1).getInstanceLocation().toString()); assertEquals("$.oneOf[0].additionalProperties", assertions.get(1).getEvaluationPath().toString()); - assertEquals("type", assertions.get(2).getType()); + assertEquals("type", assertions.get(2).getKeyword()); assertEquals("$.test", assertions.get(2).getInstanceLocation().toString()); assertEquals("$.oneOf[1].additionalProperties.type", assertions.get(2).getEvaluationPath().toString()); - assertEquals("type", assertions.get(3).getType()); + assertEquals("type", assertions.get(3).getKeyword()); assertEquals("$.test", assertions.get(3).getInstanceLocation().toString()); assertEquals("$.oneOf[2].additionalProperties.type", assertions.get(3).getEvaluationPath().toString()); } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index d7f642e13..ac18a7dc9 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -70,12 +70,12 @@ void testTypeLoose() { // Without type loose this has 2 type errors List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); - assertEquals(2, messages.stream().filter(m -> "type".equals(m.getType())).count()); + assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); // 1 type error in array_of_integers messages = schema.validate(validTypeLooseInputData, InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals(1, messages.stream().filter(m -> "type".equals(m.getType())).count()); + assertEquals(1, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); // With type loose this has 0 type errors as any item can also be interpreted as an array of 1 item SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index bfad6228e..0d2f8b2a4 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -47,10 +47,10 @@ void unevaluatedItemsFalse() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("unevaluatedItems", assertions.get(0).getType()); + assertEquals("unevaluatedItems", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems", assertions.get(0).getEvaluationPath().toString()); - assertEquals("unevaluatedItems", assertions.get(1).getType()); + assertEquals("unevaluatedItems", assertions.get(1).getKeyword()); assertEquals("$", assertions.get(1).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems", assertions.get(1).getEvaluationPath().toString()); } @@ -73,10 +73,10 @@ void unevaluatedItemsSchema() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("type", assertions.get(0).getType()); + assertEquals("type", assertions.get(0).getKeyword()); assertEquals("$[1]", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems.type", assertions.get(0).getEvaluationPath().toString()); - assertEquals("type", assertions.get(1).getType()); + assertEquals("type", assertions.get(1).getKeyword()); assertEquals("$[2]", assertions.get(1).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems.type", assertions.get(1).getEvaluationPath().toString()); } diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 5e7ec489d..908bd3406 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -65,9 +65,9 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("required", assertions.get(0).getType()); + assertEquals("required", assertions.get(0).getKeyword()); assertEquals("key1", assertions.get(0).getProperty()); - assertEquals("unevaluatedProperties", assertions.get(1).getType()); + assertEquals("unevaluatedProperties", assertions.get(1).getKeyword()); assertEquals("key4", assertions.get(1).getProperty()); } @@ -120,7 +120,7 @@ void subschemaProcessing() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("additionalProperties", assertions.get(0).getType()); + assertEquals("additionalProperties", assertions.get(0).getKeyword()); assertEquals("notallowed", assertions.get(0).getProperty()); } @@ -148,7 +148,7 @@ void unevaluatedPropertiesSchema() { List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); - assertEquals("type", assertions.get(0).getType()); + assertEquals("type", assertions.get(0).getKeyword()); assertEquals("$.unevaluatedProperties.type", assertions.get(0).getEvaluationPath().toString()); } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 57da5b7a9..6b9b796a0 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -81,7 +81,7 @@ void noValidation() { .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals("minimum", messages.iterator().next().getType()); + assertEquals("minimum", messages.iterator().next().getKeyword()); assertEquals(VersionFlag.V202012, schema.getValidationContext().activeDialect().get()); } @@ -134,7 +134,7 @@ void noFormatValidation() { .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals("format", messages.iterator().next().getType()); + assertEquals("format", messages.iterator().next().getKeyword()); } @Test diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 08ba18786..82de4ffe3 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -64,8 +64,8 @@ void validateMetaSchema() { messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 74d9a12f8..2dc7784b9 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -58,8 +58,8 @@ void validateVocabulary() { messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); } @@ -87,8 +87,8 @@ void validateMetaSchema() { messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); } @@ -110,7 +110,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { + "}"; List messages = schema.validate(input, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); } /** @@ -129,8 +129,8 @@ void discriminatorOneOfNoMatchShouldFail() { + "}"; List messages = schema.validate(input, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); - assertEquals("oneOf", list.get(0).getType()); - assertEquals("required", list.get(1).getType()); + assertEquals("oneOf", list.get(0).getKeyword()); + assertEquals("required", list.get(1).getKeyword()); assertEquals("lovesRocks", list.get(1).getProperty()); } diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index bb8184366..b5892bb9c 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -102,7 +102,7 @@ void jsonLocation() { JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); - assertEquals("format", format.getType()); + assertEquals("format", format.getKeyword()); assertEquals("date", format.getSchemaNode().asText()); assertEquals(5, formatSchemaNodeTokenLocation.getLineNr()); @@ -112,7 +112,7 @@ void jsonLocation() { assertEquals(2, formatInstanceNodeTokenLocation.getLineNr()); assertEquals(16, formatInstanceNodeTokenLocation.getColumnNr()); - assertEquals("minLength", minLength.getType()); + assertEquals("minLength", minLength.getKeyword()); assertEquals("6", minLength.getSchemaNode().asText()); assertEquals(6, minLengthSchemaNodeTokenLocation.getLineNr()); @@ -148,7 +148,7 @@ void yamlLocation() { JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); - assertEquals("format", format.getType()); + assertEquals("format", format.getKeyword()); assertEquals("date", format.getSchemaNode().asText()); assertEquals(5, formatSchemaNodeTokenLocation.getLineNr()); @@ -158,7 +158,7 @@ void yamlLocation() { assertEquals(2, formatInstanceNodeTokenLocation.getLineNr()); assertEquals(12, formatInstanceNodeTokenLocation.getColumnNr()); - assertEquals("minLength", minLength.getType()); + assertEquals("minLength", minLength.getKeyword()); assertEquals("6", minLength.getSchemaNode().asText()); assertEquals(6, minLengthSchemaNodeTokenLocation.getLineNr()); From 5c399ff1a8e243468139ad066d6d5a92a27889b5 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 21 Sep 2025 12:44:46 +0800 Subject: [PATCH 02/74] Remove failFast from MessageSourceValidationMessage builder --- .../schema/AdditionalPropertiesValidator.java | 2 +- .../com/networknt/schema/AnyOfValidator.java | 2 +- .../networknt/schema/BaseJsonValidator.java | 11 +++----- .../com/networknt/schema/ConstValidator.java | 2 +- .../networknt/schema/ContainsValidator.java | 8 +++--- .../schema/ContentEncodingValidator.java | 2 +- .../schema/ContentMediaTypeValidator.java | 2 +- .../schema/DependenciesValidator.java | 1 - .../networknt/schema/DependentRequired.java | 2 +- .../com/networknt/schema/EnumValidator.java | 2 +- .../schema/ExclusiveMaximumValidator.java | 1 - .../schema/ExclusiveMinimumValidator.java | 1 - .../networknt/schema/ExecutionContext.java | 4 +-- .../com/networknt/schema/FalseValidator.java | 2 +- .../com/networknt/schema/FormatValidator.java | 2 +- .../com/networknt/schema/ItemsValidator.java | 3 +- .../schema/ItemsValidator202012.java | 2 +- .../networknt/schema/MaxItemsValidator.java | 4 +-- .../networknt/schema/MaxLengthValidator.java | 2 +- .../schema/MaxPropertiesValidator.java | 2 +- .../networknt/schema/MaximumValidator.java | 1 - .../MessageSourceValidationMessage.java | 28 ++++--------------- .../networknt/schema/MinItemsValidator.java | 4 +-- .../networknt/schema/MinLengthValidator.java | 2 +- .../schema/MinMaxContainsValidator.java | 1 - .../schema/MinPropertiesValidator.java | 2 +- .../networknt/schema/MinimumValidator.java | 1 - .../networknt/schema/MultipleOfValidator.java | 2 +- .../networknt/schema/NotAllowedValidator.java | 2 +- .../com/networknt/schema/NotValidator.java | 2 +- .../com/networknt/schema/OneOfValidator.java | 1 - .../networknt/schema/PatternValidator.java | 2 +- .../schema/PropertyNamesValidator.java | 2 +- .../networknt/schema/ReadOnlyValidator.java | 2 +- .../networknt/schema/RequiredValidator.java | 2 +- .../com/networknt/schema/TypeValidator.java | 1 - .../schema/UnevaluatedItemsValidator.java | 2 +- .../UnevaluatedPropertiesValidator.java | 2 +- .../networknt/schema/UnionTypeValidator.java | 2 +- .../schema/UniqueItemsValidator.java | 2 +- .../networknt/schema/WriteOnlyValidator.java | 2 +- 41 files changed, 47 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java index 6b498c4fb..39963cbc6 100644 --- a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java @@ -120,7 +120,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo executionContext.addError(message().instanceNode(node).property(pname) .instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(pname).build()); + .arguments(pname).build()); } else { if (additionalPropertiesSchema != null) { if (!walk) { diff --git a/src/main/java/com/networknt/schema/AnyOfValidator.java b/src/main/java/com/networknt/schema/AnyOfValidator.java index 8245b1673..3aad82677 100644 --- a/src/main/java/com/networknt/schema/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/AnyOfValidator.java @@ -122,7 +122,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { } allErrors.add(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(DISCRIMINATOR_REMARK) + .arguments(DISCRIMINATOR_REMARK) .build()); } else { // Clear all errors. Note that this is checked in finally. diff --git a/src/main/java/com/networknt/schema/BaseJsonValidator.java b/src/main/java/com/networknt/schema/BaseJsonValidator.java index 88a5d536b..fe4978255 100644 --- a/src/main/java/com/networknt/schema/BaseJsonValidator.java +++ b/src/main/java/com/networknt/schema/BaseJsonValidator.java @@ -216,13 +216,10 @@ protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { } protected MessageSourceValidationMessage.Builder message() { - return MessageSourceValidationMessage.builder(this.validationContext.getConfig().getMessageSource(), this.errorMessage, (message, failFast) -> { - if (failFast) { - throw new FailFastAssertionException(message); - } - }).schemaNode(this.schemaNode).schemaLocation(this.schemaLocation) - .evaluationPath(this.evaluationPath).keyword(this.keyword != null ? this.keyword.getValue() : null) - .messageKey(this.getKeyword()); + return MessageSourceValidationMessage + .builder(this.validationContext.getConfig().getMessageSource(), this.errorMessage) + .schemaNode(this.schemaNode).schemaLocation(this.schemaLocation).evaluationPath(this.evaluationPath) + .keyword(this.keyword != null ? this.keyword.getValue() : null).messageKey(this.getKeyword()); } /** diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/ConstValidator.java index db53eee8c..958a1746a 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/ConstValidator.java @@ -37,7 +37,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (schemaNode.decimalValue().compareTo(node.decimalValue()) != 0) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(schemaNode.asText(), node.asText()) + .arguments(schemaNode.asText(), node.asText()) .build()); } } else if (!schemaNode.equals(node)) { diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/ContainsValidator.java index af0183849..454fa7aaa 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/ContainsValidator.java @@ -116,13 +116,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (actual < m) { boundsViolated(executionContext, isMinV201909 ? ValidatorTypeCode.MIN_CONTAINS : ValidatorTypeCode.CONTAINS, executionContext.getExecutionConfig().getLocale(), - executionContext.isFailFast(), node, instanceLocation, m); + node, instanceLocation, m); } if (this.max != null && actual > this.max) { boundsViolated(executionContext, isMinV201909 ? ValidatorTypeCode.MAX_CONTAINS : ValidatorTypeCode.CONTAINS, executionContext.getExecutionConfig().getLocale(), - executionContext.isFailFast(), node, instanceLocation, this.max); + node, instanceLocation, this.max); } } @@ -184,7 +184,7 @@ public void preloadJsonSchema() { collectAnnotations(); // cache the flag } - private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode validatorTypeCode, Locale locale, boolean failFast, + private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode validatorTypeCode, Locale locale, JsonNode instanceNode, JsonNodePath instanceLocation, int bounds) { String messageKey = "contains"; if (ValidatorTypeCode.MIN_CONTAINS.equals(validatorTypeCode)) { @@ -193,7 +193,7 @@ private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode messageKey = CONTAINS_MAX; } executionContext.addError(message().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) - .locale(locale).failFast(failFast).arguments(String.valueOf(bounds), this.schema.getSchemaNode().toString()) + .locale(locale).arguments(String.valueOf(bounds), this.schema.getSchemaNode().toString()) .keyword(validatorTypeCode.getValue()).build()); } diff --git a/src/main/java/com/networknt/schema/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/ContentEncodingValidator.java index 66335052d..4208825db 100644 --- a/src/main/java/com/networknt/schema/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/ContentEncodingValidator.java @@ -81,7 +81,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!matches(node.asText())) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.contentEncoding) + .arguments(this.contentEncoding) .build()); } } diff --git a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java index 465f0d5f3..4ad8bd491 100644 --- a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java @@ -104,7 +104,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!matches(node.asText())) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.contentMediaType) + .arguments(this.contentMediaType) .build()); } } diff --git a/src/main/java/com/networknt/schema/DependenciesValidator.java b/src/main/java/com/networknt/schema/DependenciesValidator.java index 876f431bc..9e03e1191 100644 --- a/src/main/java/com/networknt/schema/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/DependenciesValidator.java @@ -73,7 +73,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.get(field) == null) { executionContext.addError(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(propertyDeps.toString()).build()); } } diff --git a/src/main/java/com/networknt/schema/DependentRequired.java b/src/main/java/com/networknt/schema/DependentRequired.java index da9294af7..80cd330bc 100644 --- a/src/main/java/com/networknt/schema/DependentRequired.java +++ b/src/main/java/com/networknt/schema/DependentRequired.java @@ -57,7 +57,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.get(field) == null) { executionContext.addError(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(field, pname) + .arguments(field, pname) .build()); } } diff --git a/src/main/java/com/networknt/schema/EnumValidator.java b/src/main/java/com/networknt/schema/EnumValidator.java index e474bcd4d..f6b3faf90 100644 --- a/src/main/java/com/networknt/schema/EnumValidator.java +++ b/src/main/java/com/networknt/schema/EnumValidator.java @@ -100,7 +100,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!nodes.contains(node) && !( this.validationContext.getConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(error).build()); + .arguments(error).build()); } } diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java index c461a01c8..f75e69d50 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java @@ -106,7 +106,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (typedMaximum.crossesThreshold(node)) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(typedMaximum.thresholdValue()).build()); } } diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java index c00281ae1..df77f9cc6 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java @@ -113,7 +113,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (typedMinimum.crossesThreshold(node)) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(typedMinimum.thresholdValue()).build()); } } diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 57e6b7ac8..2ba67aa0a 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -20,7 +20,6 @@ import com.networknt.schema.result.JsonNodeResults; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Stack; @@ -183,11 +182,10 @@ public List getErrors() { } public void addError(ValidationMessage error) { + this.errors.add(error); if (this.isFailFast()) { - this.errors = Collections.singletonList(error); throw new FailFastAssertionException(error); } - this.errors.add(error); } public void setErrors(List errors) { diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/FalseValidator.java index a33a2b745..9ae3bed6c 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/FalseValidator.java @@ -37,6 +37,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // For the false validator, it is always not valid executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(reason).build()); + .arguments(reason).build()); } } diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/FormatValidator.java index a71b5072b..862107f50 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/FormatValidator.java @@ -72,7 +72,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode () -> this.message().instanceNode(node).instanceLocation(instanceLocation) .messageKey(format.getMessageKey()) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()), + , this); } catch (PatternSyntaxException pse) { // String is considered valid if pattern is invalid diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/ItemsValidator.java index 1099a354f..d8d3de0d5 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/ItemsValidator.java @@ -182,7 +182,8 @@ private boolean doValidate(ExecutionContext executionContext, int i, JsonNode no .schemaLocation(this.additionalItemsSchemaLocation) .schemaNode(this.additionalItemsSchemaNode) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(i).build()); + .index(i) + .arguments(i).build()); } } } diff --git a/src/main/java/com/networknt/schema/ItemsValidator202012.java b/src/main/java/com/networknt/schema/ItemsValidator202012.java index 859f7542a..7f4e22b40 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/ItemsValidator202012.java @@ -78,7 +78,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode int x = i; executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(x).build()); + .index(x).arguments(x).build()); } evaluated = true; } diff --git a/src/main/java/com/networknt/schema/MaxItemsValidator.java b/src/main/java/com/networknt/schema/MaxItemsValidator.java index 75a4fbcae..6bba3618a 100644 --- a/src/main/java/com/networknt/schema/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/MaxItemsValidator.java @@ -45,13 +45,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.size() > this.max) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.max, node.size()).build()); + .arguments(this.max, node.size()).build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 > this.max) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.max, 1).build()); + .arguments(this.max, 1).build()); } } } diff --git a/src/main/java/com/networknt/schema/MaxLengthValidator.java b/src/main/java/com/networknt/schema/MaxLengthValidator.java index fb8504d49..7a5ba2d46 100644 --- a/src/main/java/com/networknt/schema/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/MaxLengthValidator.java @@ -48,7 +48,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.textValue().codePointCount(0, node.textValue().length()) > this.maxLength) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.maxLength).build()); + .arguments(this.maxLength).build()); } } diff --git a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java index 432186140..73908e5fe 100644 --- a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java @@ -45,7 +45,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.size() > max) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(max).build()); + .arguments(max).build()); } } } diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/MaximumValidator.java index 0c6630b94..4fb6d31af 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/MaximumValidator.java @@ -118,7 +118,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (this.typedMaximum.crossesThreshold(node)) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(this.typedMaximum.thresholdValue()).build()); } } diff --git a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java b/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java index 880ed6877..73111f0f2 100644 --- a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java +++ b/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java @@ -17,7 +17,6 @@ import java.util.Locale; import java.util.Map; -import java.util.function.BiConsumer; import com.networknt.schema.i18n.MessageSource; @@ -26,15 +25,13 @@ */ public class MessageSourceValidationMessage { - public static Builder builder(MessageSource messageSource, Map errorMessage, - BiConsumer observer) { - return new Builder(messageSource, errorMessage, observer); + public static Builder builder(MessageSource messageSource, Map errorMessage) { + return new Builder(messageSource, errorMessage); } public static class Builder extends BuilderSupport { - public Builder(MessageSource messageSource, Map errorMessage, - BiConsumer observer) { - super(messageSource, errorMessage, observer); + public Builder(MessageSource messageSource, Map errorMessage) { + super(messageSource, errorMessage); } @Override @@ -44,16 +41,12 @@ public Builder self() { } public abstract static class BuilderSupport extends ValidationMessage.BuilderSupport { - private final BiConsumer observer; private final MessageSource messageSource; private final Map errorMessage; - private boolean failFast; private Locale locale; - public BuilderSupport(MessageSource messageSource, Map errorMessage, - BiConsumer observer) { + public BuilderSupport(MessageSource messageSource, Map errorMessage) { this.messageSource = messageSource; - this.observer = observer; this.errorMessage = errorMessage; } @@ -79,21 +72,12 @@ public ValidationMessage build() { this.messageFormatter = args -> this.messageSource.getMessage(this.messageKey, this.locale == null ? Locale.ROOT : this.locale, args); } - ValidationMessage validationMessage = super.build(); - if (this.observer != null) { - this.observer.accept(validationMessage, this.failFast); - } - return validationMessage; + return super.build(); } public S locale(Locale locale) { this.locale = locale; return self(); } - - public S failFast(boolean failFast) { - this.failFast = failFast; - return self(); - } } } diff --git a/src/main/java/com/networknt/schema/MinItemsValidator.java b/src/main/java/com/networknt/schema/MinItemsValidator.java index 41da79afb..a242f4f20 100644 --- a/src/main/java/com/networknt/schema/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/MinItemsValidator.java @@ -42,14 +42,14 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.size() < min) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(min, node.size()) + .arguments(min, node.size()) .build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 < min) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(min, 1).build()); + .arguments(min, 1).build()); } } } diff --git a/src/main/java/com/networknt/schema/MinLengthValidator.java b/src/main/java/com/networknt/schema/MinLengthValidator.java index cce1f97b4..a61a25173 100644 --- a/src/main/java/com/networknt/schema/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/MinLengthValidator.java @@ -48,7 +48,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.textValue().codePointCount(0, node.textValue().length()) < minLength) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(minLength).build()); + .arguments(minLength).build()); } } diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java index 3985b57de..b4601a572 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java @@ -64,7 +64,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .map(analysis -> message().instanceNode(node) .instanceLocation(instanceLocation) .messageKey(analysis.getMessageKey()).locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .keyword(analysis.getMessageKey()) .arguments(parentSchema.getSchemaNode().toString()).build()) .forEach(executionContext::addError); diff --git a/src/main/java/com/networknt/schema/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/MinPropertiesValidator.java index 36584c162..dca27d602 100644 --- a/src/main/java/com/networknt/schema/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MinPropertiesValidator.java @@ -45,7 +45,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.size() < min) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(min).build()); + .arguments(min).build()); } } } diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/MinimumValidator.java index 877518732..9c2ff800c 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/MinimumValidator.java @@ -125,7 +125,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (this.typedMinimum.crossesThreshold(node)) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(this.typedMinimum.thresholdValue()).build()); } } diff --git a/src/main/java/com/networknt/schema/MultipleOfValidator.java b/src/main/java/com/networknt/schema/MultipleOfValidator.java index e3089cdea..1b46c2a5e 100644 --- a/src/main/java/com/networknt/schema/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/MultipleOfValidator.java @@ -47,7 +47,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (dividend.divideAndRemainder(this.divisor)[1].abs().compareTo(BigDecimal.ZERO) > 0) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.divisor) + .arguments(this.divisor) .build()); } } diff --git a/src/main/java/com/networknt/schema/NotAllowedValidator.java b/src/main/java/com/networknt/schema/NotAllowedValidator.java index 78f6c0c84..ec4b469a6 100644 --- a/src/main/java/com/networknt/schema/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/NotAllowedValidator.java @@ -53,7 +53,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode executionContext.addError(message().property(fieldName).instanceNode(node) .instanceLocation(instanceLocation.append(fieldName)) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(fieldName).build()); + .arguments(fieldName).build()); } } } diff --git a/src/main/java/com/networknt/schema/NotValidator.java b/src/main/java/com/networknt/schema/NotValidator.java index 67c607994..a564a05d8 100644 --- a/src/main/java/com/networknt/schema/NotValidator.java +++ b/src/main/java/com/networknt/schema/NotValidator.java @@ -67,7 +67,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo if (test.isEmpty()) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.schema.toString()) + .arguments(this.schema.toString()) .build()); } } diff --git a/src/main/java/com/networknt/schema/OneOfValidator.java b/src/main/java/com/networknt/schema/OneOfValidator.java index 0ad80e99c..65be57bca 100644 --- a/src/main/java/com/networknt/schema/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/OneOfValidator.java @@ -186,7 +186,6 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo ValidationMessage message = message().instanceNode(node).instanceLocation(instanceLocation) .messageKey(numberOfValidSchema > 1 ? "oneOf.indexes" : "oneOf") .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(Integer.toString(numberOfValidSchema), numberOfValidSchema > 1 ? String.join(", ", indexes) : "").build(); existingErrors.add(message); if (childErrors != null) { diff --git a/src/main/java/com/networknt/schema/PatternValidator.java b/src/main/java/com/networknt/schema/PatternValidator.java index b4b29e733..559748c5e 100644 --- a/src/main/java/com/networknt/schema/PatternValidator.java +++ b/src/main/java/com/networknt/schema/PatternValidator.java @@ -58,7 +58,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!matches(node.asText())) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(this.pattern).build()); + .arguments(this.pattern).build()); return; } } catch (JsonSchemaException | FailFastAssertionException e) { diff --git a/src/main/java/com/networknt/schema/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/PropertyNamesValidator.java index 0fa90bed5..b859f190b 100644 --- a/src/main/java/com/networknt/schema/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/PropertyNamesValidator.java @@ -52,7 +52,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode existingErrors.add( message().property(pname).instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(pname, msg).build()); + .arguments(pname, msg).build()); } schemaErrors.clear(); } diff --git a/src/main/java/com/networknt/schema/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/ReadOnlyValidator.java index f9416fe07..725b0652a 100644 --- a/src/main/java/com/networknt/schema/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/ReadOnlyValidator.java @@ -42,7 +42,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (this.readOnly) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).build()); + .build()); } return; } diff --git a/src/main/java/com/networknt/schema/RequiredValidator.java b/src/main/java/com/networknt/schema/RequiredValidator.java index 41bfa3c5b..d1852c81b 100644 --- a/src/main/java/com/networknt/schema/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/RequiredValidator.java @@ -73,7 +73,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode */ executionContext.addError(message().instanceNode(node).property(fieldName).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(fieldName).build()); + .arguments(fieldName).build()); } } } diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/TypeValidator.java index bbe0b54d6..7ce61c6be 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/TypeValidator.java @@ -61,7 +61,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()) .arguments(nodeType.toString(), this.schemaType.toString()).build()); } } diff --git a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java index fc08adc37..34bb37c2c 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java @@ -176,7 +176,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // All fails as "unevaluatedItems: false" executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation).arguments(x) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).build()); + .build()); } else { // Schema errors will be reported as is this.schema.validate(executionContext, node.get(x), node, instanceLocation.append(x)); diff --git a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java index db09c16e7..6af91d158 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java @@ -118,7 +118,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // All fails as "unevaluatedProperties: false" executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation).property(fieldName) .arguments(fieldName).locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).build()); + .build()); } else { // Schema errors will be reported as is this.schema.validate(executionContext, node.get(fieldName), node, diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index 4a02268c1..e1ade7dc1 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -98,7 +98,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .keyword("type") .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).arguments(nodeType.toString(), error) + .arguments(nodeType.toString(), error) .build()); } } diff --git a/src/main/java/com/networknt/schema/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/UniqueItemsValidator.java index 37486e4db..496f0cb81 100644 --- a/src/main/java/com/networknt/schema/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/UniqueItemsValidator.java @@ -49,7 +49,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!set.add(n)) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).build()); + .build()); } } } diff --git a/src/main/java/com/networknt/schema/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/WriteOnlyValidator.java index e28eccaaa..d5f9c4c9f 100644 --- a/src/main/java/com/networknt/schema/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/WriteOnlyValidator.java @@ -26,7 +26,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (this.writeOnly) { executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.isFailFast()).build()); + .build()); } } From 9594509d362518c5e20c9a1b4ffc88486f765cfa Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 21 Sep 2025 18:29:34 +0800 Subject: [PATCH 03/74] Remove hard coded instance location for the error message --- .../schema/DefaultJsonMetaSchemaFactory.java | 2 +- .../DisallowUnknownJsonMetaSchemaFactory.java | 2 +- .../schema/DisallowUnknownKeywordFactory.java | 2 +- .../networknt/schema/DynamicRefValidator.java | 4 +- .../com/networknt/schema/JsonMetaSchema.java | 2 +- .../java/com/networknt/schema/JsonSchema.java | 4 +- .../schema/RecursiveRefValidator.java | 6 +- .../com/networknt/schema/RefValidator.java | 4 +- .../networknt/schema/ValidationMessage.java | 47 ++---- .../regex/AllowRegularExpressionFactory.java | 2 +- .../schema/resource/AllowSchemaLoader.java | 2 +- .../schema/resource/DisallowSchemaLoader.java | 2 +- src/main/resources/jsv-messages.properties | 140 +++++++++--------- src/main/resources/jsv-messages_ar.properties | 140 +++++++++--------- src/main/resources/jsv-messages_cs.properties | 140 +++++++++--------- src/main/resources/jsv-messages_da.properties | 140 +++++++++--------- src/main/resources/jsv-messages_de.properties | 140 +++++++++--------- src/main/resources/jsv-messages_es.properties | 140 +++++++++--------- src/main/resources/jsv-messages_fa.properties | 140 +++++++++--------- src/main/resources/jsv-messages_fi.properties | 140 +++++++++--------- src/main/resources/jsv-messages_fr.properties | 140 +++++++++--------- src/main/resources/jsv-messages_he.properties | 140 +++++++++--------- src/main/resources/jsv-messages_hr.properties | 140 +++++++++--------- src/main/resources/jsv-messages_hu.properties | 140 +++++++++--------- src/main/resources/jsv-messages_it.properties | 140 +++++++++--------- src/main/resources/jsv-messages_ja.properties | 140 +++++++++--------- src/main/resources/jsv-messages_ko.properties | 140 +++++++++--------- src/main/resources/jsv-messages_nb.properties | 140 +++++++++--------- src/main/resources/jsv-messages_nl.properties | 140 +++++++++--------- src/main/resources/jsv-messages_pl.properties | 140 +++++++++--------- src/main/resources/jsv-messages_pt.properties | 140 +++++++++--------- src/main/resources/jsv-messages_ro.properties | 140 +++++++++--------- src/main/resources/jsv-messages_ru.properties | 140 +++++++++--------- src/main/resources/jsv-messages_sk.properties | 140 +++++++++--------- src/main/resources/jsv-messages_sv.properties | 140 +++++++++--------- src/main/resources/jsv-messages_th.properties | 140 +++++++++--------- src/main/resources/jsv-messages_tr.properties | 140 +++++++++--------- src/main/resources/jsv-messages_uk.properties | 140 +++++++++--------- src/main/resources/jsv-messages_vi.properties | 140 +++++++++--------- .../resources/jsv-messages_zh_CN.properties | 140 +++++++++--------- .../resources/jsv-messages_zh_TW.properties | 140 +++++++++--------- .../schema/AbstractJsonSchemaTestSuite.java | 4 +- .../AdditionalPropertiesValidatorTest.java | 4 +- .../networknt/schema/ConstValidatorTest.java | 4 +- .../schema/CustomMetaSchemaTest.java | 4 +- .../DefaultJsonSchemaIdValidatorTest.java | 2 +- .../schema/DependentRequiredTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 4 +- .../com/networknt/schema/Issue342Test.java | 2 +- .../com/networknt/schema/Issue347Test.java | 2 +- .../com/networknt/schema/Issue375Test.java | 2 +- .../com/networknt/schema/Issue493Test.java | 4 +- .../com/networknt/schema/Issue662Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 6 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue936Test.java | 2 +- .../schema/ItemsValidator202012Test.java | 2 +- .../networknt/schema/ItemsValidatorTest.java | 6 +- .../schema/JsonWalkApplyDefaultsTest.java | 8 +- .../java/com/networknt/schema/LocaleTest.java | 10 +- .../com/networknt/schema/MessageTest.java | 4 +- .../networknt/schema/OneOfValidatorTest.java | 4 +- .../networknt/schema/OutputFormatTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 2 +- .../PatternPropertiesValidatorTest.java | 4 +- .../schema/PrefixItemsValidatorTest.java | 4 +- .../schema/PropertyNamesValidatorTest.java | 2 +- .../schema/ReadOnlyValidatorTest.java | 2 +- .../i18n/ResourceBundleMessageSourceTest.java | 6 +- .../const-messages-override.properties | 2 +- .../issue686/translations.properties | 2 +- .../issue686/translations_de.properties | 2 +- .../issue686/translations_fr.properties | 2 +- .../schema/OverwritingCustomMessageBug.json | 4 +- .../custom-message-tests.json | 22 +-- 75 files changed, 2130 insertions(+), 2147 deletions(-) diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java index 69a41b631..c9f3f7453 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java @@ -46,7 +46,7 @@ protected JsonMetaSchema loadMetaSchema(String iri, JsonSchemaFactory schemaFact throw e; } catch (Exception e) { ValidationMessage validationMessage = ValidationMessage.builder() - .message("Failed to load meta-schema ''{1}''").arguments(iri).build(); + .message("Failed to load meta-schema ''{0}''").arguments(iri).build(); throw new InvalidSchemaException(validationMessage, e); } } diff --git a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java index 6ef036c61..6044f963a 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java @@ -23,7 +23,7 @@ public class DisallowUnknownJsonMetaSchemaFactory implements JsonMetaSchemaFacto @Override public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { throw new InvalidSchemaException(ValidationMessage.builder() - .message("Unknown meta-schema ''{1}''. Only meta-schemas that are explicitly configured can be used.") + .message("Unknown meta-schema ''{0}''. Only meta-schemas that are explicitly configured can be used.") .arguments(iri).build()); } diff --git a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java index f3397b957..ca46aaa32 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java @@ -28,7 +28,7 @@ public class DisallowUnknownKeywordFactory implements KeywordFactory { public Keyword getKeyword(String value, ValidationContext validationContext) { logger.error("Keyword '{}' is unknown and must be configured on the meta-schema or vocabulary", value); throw new InvalidSchemaException(ValidationMessage.builder() - .message("Keyword ''{1}'' is unknown and must be configured on the meta-schema or vocabulary") + .message("Keyword ''{0}'' is unknown and must be configured on the meta-schema or vocabulary") .arguments(value).build()); } diff --git a/src/main/java/com/networknt/schema/DynamicRefValidator.java b/src/main/java/com/networknt/schema/DynamicRefValidator.java index 1517df949..4b15a5cd3 100644 --- a/src/main/java/com/networknt/schema/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/DynamicRefValidator.java @@ -95,7 +95,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -112,7 +112,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index e2a90056e..29e5a40b5 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -284,7 +284,7 @@ public JsonMetaSchema build() { } } else if (Boolean.TRUE.equals(entry.getValue())) { ValidationMessage validationMessage = ValidationMessage.builder() - .message("Meta-schema ''{1}'' has unknown required vocabulary ''{2}''") + .message("Meta-schema ''{0}'' has unknown required vocabulary ''{1}''") .arguments(this.iri, id).build(); throw new InvalidSchemaException(validationMessage); } diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index c10556f87..9dada8962 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -510,7 +510,7 @@ public JsonSchema getSubSchema(JsonNodePath fragment) { if (found == null) { ValidationMessage validationMessage = ValidationMessage.builder() .keyword(ValidatorTypeCode.REF.getValue()).messageKey("internal.unresolvedRef") - .message("{0}: Reference {1} cannot be resolved") + .message("Reference {0} cannot be resolved") .instanceLocation(schemaLocation.getFragment()) .schemaLocation(schemaLocation) .evaluationPath(evaluationPath) @@ -630,7 +630,7 @@ private List read(JsonNode schemaNode) { ValidationMessage validationMessage = ValidationMessage.builder().keyword("$recursiveAnchor") .messageKey("internal.invalidRecursiveAnchor") .message( - "{0}: The value of a $recursiveAnchor must be a Boolean literal but is {1}") + "The value of a $recursiveAnchor must be a Boolean literal but is {0}") .instanceLocation(path) .evaluationPath(path) .schemaLocation(schemaPath) diff --git a/src/main/java/com/networknt/schema/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/RecursiveRefValidator.java index 87cd5f21e..594af0a6c 100644 --- a/src/main/java/com/networknt/schema/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/RecursiveRefValidator.java @@ -37,7 +37,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat if (!"#".equals(refValue)) { ValidationMessage validationMessage = message() .keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()).messageKey("internal.invalidRecursiveRef") - .message("{0}: The value of a $recursiveRef must be '#' but is '{1}'").instanceLocation(schemaLocation.getFragment()) + .message("The value of a $recursiveRef must be '#' but is '{0}'").instanceLocation(schemaLocation.getFragment()) .instanceNode(this.schemaNode) .evaluationPath(evaluationPath).arguments(refValue).build(); throw new JsonSchemaException(validationMessage); @@ -90,7 +90,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -107,7 +107,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/RefValidator.java b/src/main/java/com/networknt/schema/RefValidator.java index 8530de4d1..5042f796c 100644 --- a/src/main/java/com/networknt/schema/RefValidator.java +++ b/src/main/java/com/networknt/schema/RefValidator.java @@ -179,7 +179,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); @@ -196,7 +196,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) - .messageKey("internal.unresolvedRef").message("{0}: Reference {1} cannot be resolved") + .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); throw new InvalidSchemaRefException(validationMessage); diff --git a/src/main/java/com/networknt/schema/ValidationMessage.java b/src/main/java/com/networknt/schema/ValidationMessage.java index 454570db3..a0cb2225c 100644 --- a/src/main/java/com/networknt/schema/ValidationMessage.java +++ b/src/main/java/com/networknt/schema/ValidationMessage.java @@ -40,8 +40,8 @@ * "https://github.com/json-schema-org/json-schema-spec/blob/main/output/jsonschema-validation-output-machines.md">JSON * Schema */ -@JsonIgnoreProperties({ "messageSupplier", "schemaNode", "instanceNode", "valid", "error" }) -@JsonPropertyOrder({ "type", "code", "message", "instanceLocation", "property", "evaluationPath", "schemaLocation", +@JsonIgnoreProperties({ "messageSupplier", "schemaNode", "instanceNode", "valid" }) +@JsonPropertyOrder({ "keyword", "instanceLocation", "message", "evaluationPath", "schemaLocation", "messageKey", "arguments", "details" }) @JsonInclude(Include.NON_NULL) public class ValidationMessage { @@ -178,31 +178,19 @@ public boolean isValid() { return messageSupplier != null; } - /** - * Gets the error. - * - * @return the error - */ - public String getError() { - String message = getMessage(); - int index = message.indexOf(':'); - if (index != -1) { - int length = message.length(); - while (index + 1 < length) { - if (message.charAt(index + 1) == ' ') { - index++; - } else { - break; - } - } - return message.substring(index + 1); - } - return message; - } - @Override public String toString() { - return messageSupplier.get(); + StringBuilder builder = new StringBuilder(); + if (instanceLocation != null) { + // Validation Error + builder.append(instanceLocation.toString()); + } else if (schemaLocation != null) { + // Parse Error + builder.append(schemaLocation.toString()); + } + builder.append(": "); + builder.append(messageSupplier.get()); + return builder.toString(); } @Override @@ -400,14 +388,9 @@ public ValidationMessage build() { return new ValidationMessage(keyword, evaluationPath, schemaLocation, instanceLocation, arguments, details, messageKey, messageSupplier, this.instanceNode, this.schemaNode); } - + protected Object[] getMessageArguments() { - Object[] objs = new Object[(arguments == null ? 0 : arguments.length) + 1]; - objs[0] = instanceLocation; - if (arguments != null) { - System.arraycopy(arguments, 0, objs, 1, objs.length - 1); - } - return objs; + return arguments; } protected String getKeyword() { diff --git a/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java b/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java index b4bc84e7e..afe688a75 100644 --- a/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java +++ b/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java @@ -39,6 +39,6 @@ public RegularExpression getRegularExpression(String regex) { return this.delegate.getRegularExpression(regex); } throw new InvalidSchemaException(ValidationMessage.builder() - .message("Regular expression ''{1}'' is not allowed to be used.").arguments(regex).build()); + .message("Regular expression ''{0}'' is not allowed to be used.").arguments(regex).build()); } } diff --git a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java index a996585a7..0f396901a 100644 --- a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java @@ -44,6 +44,6 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } throw new InvalidSchemaException(ValidationMessage.builder() - .message("Schema from ''{1}'' is not allowed to be loaded.").arguments(absoluteIri).build()); + .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); } } diff --git a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java index a63375dfa..89eeafa5b 100644 --- a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java @@ -43,6 +43,6 @@ private DisallowSchemaLoader() { @Override public InputStreamSource getSchema(AbsoluteIri absoluteIri) { throw new InvalidSchemaException(ValidationMessage.builder() - .message("Schema from ''{1}'' is not allowed to be loaded.").arguments(absoluteIri).build()); + .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); } } diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 8e94095b6..8e3d3d845 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -1,70 +1,70 @@ -$ref = {0}: has an error with ''refs'' -additionalItems = {0}: index ''{1}'' is not defined in the schema and the schema does not allow additional items -additionalProperties = {0}: property ''{1}'' is not defined in the schema and the schema does not allow additional properties -allOf = {0}: must be valid to all the schemas {1} -anyOf = {0}: must be valid to any of the schemas {1} -const = {0}: must be the constant value ''{1}'' -contains = {0}: does not contain an element that passes these validations: {2} -contains.max = {0}: must contain at most {1} element(s) that passes these validations: {2} -contains.min = {0}: must contain at least {1} element(s) that passes these validations: {2} -dependencies = {0}: has an error with dependencies {1} -dependentRequired = {0}: has a missing property ''{1}'' which is dependent required because ''{2}'' is present -dependentSchemas = {0}: has an error with dependentSchemas {1} -enum = {0}: does not have a value in the enumeration {1} -exclusiveMaximum = {0}: must have an exclusive maximum value of {1} -exclusiveMinimum = {0}: must have an exclusive minimum value of {1} -false = {0}: schema for ''{1}'' is false -format = {0}: does not match the {1} pattern {2} -format.date = {0}: does not match the {1} pattern must be a valid RFC 3339 full-date -format.date-time = {0}: does not match the {1} pattern must be a valid RFC 3339 date-time -format.duration = {0}: does not match the {1} pattern must be a valid ISO 8601 duration -format.email = {0}: does not match the {1} pattern must be a valid RFC 5321 Mailbox -format.ipv4 = {0}: does not match the {1} pattern must be a valid RFC 2673 IP address -format.ipv6 = {0}: does not match the {1} pattern must be a valid RFC 4291 IP address -format.idn-email = {0}: does not match the {1} pattern must be a valid RFC 6531 Mailbox -format.idn-hostname = {0}: does not match the {1} pattern must be a valid RFC 5890 internationalized hostname -format.iri = {0}: does not match the {1} pattern must be a valid RFC 3987 IRI -format.iri-reference = {0}: does not match the {1} pattern must be a valid RFC 3987 IRI-reference -format.uri = {0}: does not match the {1} pattern must be a valid RFC 3986 URI -format.uri-reference = {0}: does not match the {1} pattern must be a valid RFC 3986 URI-reference -format.uri-template = {0}: does not match the {1} pattern must be a valid RFC 6570 URI Template -format.uuid = {0}: does not match the {1} pattern must be a valid RFC 4122 UUID -format.regex = {0}: does not match the {1} pattern must be a valid ECMA-262 regular expression -format.time = {0}: does not match the {1} pattern must be a valid RFC 3339 time -format.hostname = {0}: does not match the {1} pattern must be a valid RFC 1123 host name -format.json-pointer = {0}: does not match the {1} pattern must be a valid RFC 6901 JSON Pointer -format.relative-json-pointer = {0}: does not match the {1} pattern must be a valid IETF Relative JSON Pointer -format.unknown = {0}: has an unknown format ''{1}'' -id = {0}: ''{1}'' is not a valid {2} -items = {0}: index ''{1}'' is not defined in the schema and the schema does not allow additional items -maxContains = {0}: must be a non-negative integer in {1} -maxItems = {0}: must have at most {1} items but found {2} -maxLength = {0}: must be at most {1} characters long -maxProperties = {0}: must have at most {1} properties -maximum = {0}: must have a maximum value of {1} -minContains = {0}: must be a non-negative integer in {1} -minContainsVsMaxContains = {0}: minContains must less than or equal to maxContains in {1} -minItems = {0}: must have at least {1} items but found {2} -minLength = {0}: must be at least {1} characters long -minProperties = {0}: must have at least {1} properties -minimum = {0}: must have a minimum value of {1} -multipleOf = {0}: must be multiple of {1} -not = {0}: must not be valid to the schema {1} -notAllowed = {0}: property ''{1}'' is not allowed but it is in the data -oneOf = {0}: must be valid to one and only one schema, but {1} are valid -oneOf.indexes = {0}: must be valid to one and only one schema, but {1} are valid with indexes ''{2}'' -pattern = {0}: does not match the regex pattern {1} -patternProperties = {0}: has some error with ''pattern properties'' -prefixItems = {0}: no validator found at this index -properties = {0}: has an error with ''properties'' -propertyNames = {0}: property ''{1}'' name is not valid: {2} -readOnly = {0}: is a readonly field, it cannot be changed -required = {0}: required property ''{1}'' not found -type = {0}: {1} found, {2} expected -unevaluatedItems = {0}: index ''{1}'' is not evaluated and the schema does not allow unevaluated items -unevaluatedProperties = {0}: property ''{1}'' is not evaluated and the schema does not allow unevaluated properties -unionType = {0}: {1} found, {2} expected -uniqueItems = {0}: must have only unique items in the array -writeOnly = {0}: is a write-only field, it cannot appear in the data -contentEncoding = {0}: does not match content encoding {1} -contentMediaType = {0}: is not a content media type \ No newline at end of file +$ref = has an error with ''refs'' +additionalItems = index ''{0}'' is not defined in the schema and the schema does not allow additional items +additionalProperties = property ''{0}'' is not defined in the schema and the schema does not allow additional properties +allOf = must be valid to all the schemas {0} +anyOf = must be valid to any of the schemas {0} +const = must be the constant value ''{0}'' +contains = does not contain an element that passes these validations: {1} +contains.max = must contain at most {0} element(s) that passes these validations: {1} +contains.min = must contain at least {0} element(s) that passes these validations: {1} +dependencies = has an error with dependencies {0} +dependentRequired = has a missing property ''{0}'' which is dependent required because ''{1}'' is present +dependentSchemas = has an error with dependentSchemas {0} +enum = does not have a value in the enumeration {0} +exclusiveMaximum = must have an exclusive maximum value of {0} +exclusiveMinimum = must have an exclusive minimum value of {0} +false = schema for ''{0}'' is false +format = does not match the {0} pattern {1} +format.date = does not match the {0} pattern must be a valid RFC 3339 full-date +format.date-time = does not match the {0} pattern must be a valid RFC 3339 date-time +format.duration = does not match the {0} pattern must be a valid ISO 8601 duration +format.email = does not match the {0} pattern must be a valid RFC 5321 Mailbox +format.ipv4 = does not match the {0} pattern must be a valid RFC 2673 IP address +format.ipv6 = does not match the {0} pattern must be a valid RFC 4291 IP address +format.idn-email = does not match the {0} pattern must be a valid RFC 6531 Mailbox +format.idn-hostname = does not match the {0} pattern must be a valid RFC 5890 internationalized hostname +format.iri = does not match the {0} pattern must be a valid RFC 3987 IRI +format.iri-reference = does not match the {0} pattern must be a valid RFC 3987 IRI-reference +format.uri = does not match the {0} pattern must be a valid RFC 3986 URI +format.uri-reference = does not match the {0} pattern must be a valid RFC 3986 URI-reference +format.uri-template = does not match the {0} pattern must be a valid RFC 6570 URI Template +format.uuid = does not match the {0} pattern must be a valid RFC 4122 UUID +format.regex = does not match the {0} pattern must be a valid ECMA-262 regular expression +format.time = does not match the {0} pattern must be a valid RFC 3339 time +format.hostname = does not match the {0} pattern must be a valid RFC 1123 host name +format.json-pointer = does not match the {0} pattern must be a valid RFC 6901 JSON Pointer +format.relative-json-pointer = does not match the {0} pattern must be a valid IETF Relative JSON Pointer +format.unknown = has an unknown format ''{0}'' +id = ''{0}'' is not a valid {1} +items = index ''{0}'' is not defined in the schema and the schema does not allow additional items +maxContains = must be a non-negative integer in {0} +maxItems = must have at most {0} items but found {1} +maxLength = must be at most {0} characters long +maxProperties = must have at most {0} properties +maximum = must have a maximum value of {0} +minContains = must be a non-negative integer in {0} +minContainsVsMaxContains = minContains must less than or equal to maxContains in {0} +minItems = must have at least {0} items but found {1} +minLength = must be at least {0} characters long +minProperties = must have at least {0} properties +minimum = must have a minimum value of {0} +multipleOf = must be multiple of {0} +not = must not be valid to the schema {0} +notAllowed = property ''{0}'' is not allowed but it is in the data +oneOf = must be valid to one and only one schema, but {0} are valid +oneOf.indexes = must be valid to one and only one schema, but {0} are valid with indexes ''{1}'' +pattern = does not match the regex pattern {0} +patternProperties = has some error with ''pattern properties'' +prefixItems = no validator found at this index +properties = has an error with ''properties'' +propertyNames = property ''{0}'' name is not valid: {1} +readOnly = is a readonly field, it cannot be changed +required = required property ''{0}'' not found +type = {0} found, {1} expected +unevaluatedItems = index ''{0}'' is not evaluated and the schema does not allow unevaluated items +unevaluatedProperties = property ''{0}'' is not evaluated and the schema does not allow unevaluated properties +unionType = {0} found, {1} expected +uniqueItems = must have only unique items in the array +writeOnly = is a write-only field, it cannot appear in the data +contentEncoding = does not match content encoding {0} +contentMediaType = is not a content media type \ No newline at end of file diff --git a/src/main/resources/jsv-messages_ar.properties b/src/main/resources/jsv-messages_ar.properties index 2dd53b2a5..d6e0e0e47 100644 --- a/src/main/resources/jsv-messages_ar.properties +++ b/src/main/resources/jsv-messages_ar.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u0628\u0647 \u062E\u0637\u0623 \u0641\u064A ''refs'' -additionalItems = {0}: \u0644\u0645 \u064A\u062A\u0645 \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0641\u0647\u0631\u0633 ''{1}'' \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0639\u0646\u0627\u0635\u0631 \u0625\u0636\u0627\u0641\u064A\u0629 -additionalProperties = {0}: \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{1}'' \u063A\u064A\u0631 \u0645\u062D\u062F\u062F\u0629 \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u062E\u0635\u0627\u0626\u0635 \u0625\u0636\u0627\u0641\u064A\u0629 -allOf = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u062C\u0645\u064A\u0639 \u0627\u0644\u0645\u062E\u0637\u0637\u0627\u062A {1} -anyOf = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0623\u064A \u0645\u0646 \u0627\u0644\u0645\u062E\u0637\u0637\u0627\u062A {1} -const = {0}: \u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0627\u0644\u0642\u064A\u0645\u0629 \u0627\u0644\u062B\u0627\u0628\u062A\u0629 ''{1}'' -contains = {0}: \u0644\u0627 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0639\u0646\u0635\u0631 \u064A\u0642\u0648\u0645 \u0628\u062A\u0645\u0631\u064A\u0631 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {2} -contains.max = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0639\u0646\u0635\u0631 (\u0639\u0646\u0627\u0635\u0631) \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 \u064A\u062C\u062A\u0627\u0632 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {2} -contains.min = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0639\u0646\u0635\u0631 (\u0639\u0646\u0627\u0635\u0631) \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 \u064A\u0642\u0648\u0645 \u0628\u062A\u0645\u0631\u064A\u0631 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {2} -dependencies = {0}: \u064A\u0648\u062C\u062F \u062E\u0637\u0623 \u0641\u064A \u0627\u0644\u062A\u0628\u0639\u064A\u0627\u062A {1} -dependentRequired = {0}: \u0628\u0647 \u062E\u0627\u0635\u064A\u0629 \u0645\u0641\u0642\u0648\u062F\u0629 ''{1}'' \u0648\u0647\u064A \u062A\u0627\u0628\u0639\u0629 \u0645\u0637\u0644\u0648\u0628\u0629 \u0644\u0623\u0646 ''{2}'' \u0645\u0648\u062C\u0648\u062F\u0629 -dependentSchemas = {0}: \u0628\u0647 \u062E\u0637\u0623 \u0641\u064AdependentSchemas {1} -enum = {0}: \u0644\u0627 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u064A\u0645\u0629 \u0641\u064A \u0627\u0644\u062A\u0639\u062F\u0627\u062F {1} -exclusiveMaximum = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0644\u0647 \u0642\u064A\u0645\u0629 \u0642\u0635\u0648\u0649 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {1} -exclusiveMinimum = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u064A\u0645\u0629 \u062F\u0646\u064A\u0627 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {1} -false = {0}: \u0645\u062E\u0637\u0637 ''{1}'' \u063A\u064A\u0631 \u0635\u062D\u064A\u062D -format = {0}: \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 {1} {2} -format.date = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0643\u0627\u0645\u0644\u0627\u064B \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3339 -format.date-time = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0648\u0648\u0642\u062A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0641\u064A RFC 3339 -format.duration = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0645\u062F\u0629 ISO 8601 \u0635\u0627\u0644\u062D\u0629 -format.email = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0646\u062F\u0648\u0642 \u0628\u0631\u064A\u062F RFC 5321 \u0635\u0627\u0644\u062D\u064B\u0627 -format.ipv4 = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 IP \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 2673 -format.ipv6 = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 IP \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 4291 -format.idn-email = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0646\u062F\u0648\u0642 \u0628\u0631\u064A\u062F RFC 6531 \u0635\u0627\u0644\u062D\u064B\u0627 -format.idn-hostname = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0633\u0645 \u0645\u0636\u064A\u0641 \u062F\u0648\u0644\u064A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 5890 -format.iri = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 RFC 3987 IRI \u0635\u0627\u0644\u062D\u064B\u0627 -format.iri-reference = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0631\u062C\u0639 RFC 3987 IRI \u0635\u0627\u0644\u062D\u064B\u0627 -format.uri = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 URI \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3986 -format.uri-reference = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0631\u062C\u0639 URI \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3986 -format.uri-template = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0642\u0627\u0644\u0628 URI RFC 6570 \u0635\u0627\u0644\u062D\u064B\u0627 -format.uuid = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 RFC 4122 UUID \u0635\u0627\u0644\u062D\u064B\u0627 -format.regex = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0639\u0628\u064A\u0631\u064B\u0627 \u0639\u0627\u062F\u064A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 ECMA-262 -format.time = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0648\u0642\u062A RFC 3339 \u0635\u0627\u0644\u062D\u064B\u0627 -format.hostname = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0633\u0645 \u0645\u0636\u064A\u0641 RFC 1123 \u0635\u0627\u0644\u062D\u064B\u0627 -format.json-pointer = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0624\u0634\u0631 RFC 6901 JSON \u0635\u0627\u0644\u062D\u064B\u0627 -format.relative-json-pointer = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {1} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0624\u0634\u0631 IETF Relative JSON \u0635\u0627\u0644\u062D\u064B\u0627 -format.unknown = {0}: \u0644\u0647 \u062A\u0646\u0633\u064A\u0642 \u063A\u064A\u0631 \u0645\u0639\u0631\u0648\u0641 ''{1}'' -id = {0}: ''{1}'' \u0644\u064A\u0633 {2} \u0635\u0627\u0644\u062D\u064B\u0627 -items = {0}: \u0644\u0645 \u064A\u062A\u0645 \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0641\u0647\u0631\u0633 ''{1}'' \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0639\u0646\u0627\u0635\u0631 \u0625\u0636\u0627\u0641\u064A\u0629 -maxContains = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u062F\u062F\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627 \u063A\u064A\u0631 \u0633\u0627\u0644\u0628 \u0641\u064A {1} -maxItems = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0639\u0646\u0635\u0631 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 \u0648\u0644\u0643\u0646 \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {2} -maxLength = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0637\u0648\u0644\u0647 {1} \u062D\u0631\u0641\u064B\u0627 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 -maxProperties = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0645\u0646 \u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 -maximum = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 \u0644\u0642\u064A\u0645\u0629 {1} -minContains = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u062F\u062F\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627 \u063A\u064A\u0631 \u0633\u0627\u0644\u0628 \u0641\u064A {1} -minContainsVsMaxContains = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 minContains \u0623\u0642\u0644 \u0645\u0646 \u0623\u0648 \u064A\u0633\u0627\u0648\u064A maxContains \u0641\u064A {1} -minItems = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0639\u0646\u0635\u0631 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 \u0648\u0644\u0643\u0646 \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {2} -minLength = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0637\u0648\u0644\u0647 {1} \u062D\u0631\u0641\u064B\u0627 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 -minProperties = {0}: \u064A\u062C\u0628 \u0623\u0646 \u062A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {1} \u0645\u0646 \u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 -minimum = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u062F\u0646\u0649 \u0644\u0642\u064A\u0645\u0629 {1} -multipleOf = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A {1} -not = {0}: \u064A\u062C\u0628 \u0623\u0646 \u0644\u0627 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0644\u0645\u062E\u0637\u0637 {1} -notAllowed = {0}: \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{1}'' \u063A\u064A\u0631 \u0645\u0633\u0645\u0648\u062D \u0628\u0647\u0627 \u0648\u0644\u0643\u0646\u0647\u0627 \u0645\u0648\u062C\u0648\u062F\u0629 \u0641\u064A \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A -oneOf = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0645\u062E\u0637\u0637 \u0648\u0627\u062D\u062F \u0641\u0642\u0637\u060C \u0648\u0644\u0643\u0646 {1} \u0635\u0627\u0644\u062D -oneOf.indexes = {0}: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0645\u062E\u0637\u0637 \u0648\u0627\u062D\u062F \u0641\u0642\u0637\u060C \u0648\u0644\u0643\u0646 {1} \u0635\u0627\u0644\u062D \u0645\u0639 \u0627\u0644\u0641\u0647\u0627\u0631\u0633 ''{2}'' -pattern = {0}: \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0646\u0645\u0637 \u0627\u0644\u062A\u0639\u0628\u064A\u0631 \u0627\u0644\u0639\u0627\u062F\u064A {1} -patternProperties = {0}: \u0628\u0647 \u0628\u0639\u0636 \u0627\u0644\u0623\u062E\u0637\u0627\u0621 \u0641\u064A ''\u062E\u0635\u0627\u0626\u0635 \u0627\u0644\u0646\u0645\u0637'' -prefixItems = {0}: \u0644\u0645 \u064A\u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 \u0623\u062F\u0627\u0629 \u0627\u0644\u062A\u062D\u0642\u0642 \u0641\u064A \u0647\u0630\u0627 \u0627\u0644\u0641\u0647\u0631\u0633 -properties = {0}: \u064A\u0648\u062C\u062F \u062E\u0637\u0623 \u0641\u064A ''\u0627\u0644\u062E\u0635\u0627\u0626\u0635'' -propertyNames = {0}: \u0627\u0633\u0645 \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{1}'' \u063A\u064A\u0631 \u0635\u0627\u0644\u062D: {2} -readOnly = {0}: \u0647\u0648 \u062D\u0642\u0644 \u0644\u0644\u0642\u0631\u0627\u0621\u0629 \u0641\u0642\u0637\u060C \u0648\u0644\u0627 \u064A\u0645\u0643\u0646 \u062A\u063A\u064A\u064A\u0631\u0647 -required = {0}: \u0627\u0644\u062E\u0627\u0635\u064A\u0629 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629 ''{1}'' \u063A\u064A\u0631 \u0645\u0648\u062C\u0648\u062F\u0629 -type = {0}: \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {1}\u060C \u0648\u0627\u0644\u0645\u062A\u0648\u0642\u0639 \u0647\u0648 {2}. -unevaluatedItems = {0}: \u0644\u0645 \u064A\u062A\u0645 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0641\u0647\u0631\u0633 ''{1}'' \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u063A\u064A\u0631 \u0627\u0644\u0645\u0642\u064A\u064E\u0651\u0645\u0629 -unevaluatedProperties = {0}: \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{1}'' \u0644\u0645 \u064A\u062A\u0645 \u062A\u0642\u064A\u064A\u0645\u0647\u0627 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u063A\u064A\u0631 \u0627\u0644\u0645\u0642\u064A\u064E\u0651\u0645\u0629 -unionType = {0}: \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {1}\u060C \u0648\u0627\u0644\u0645\u062A\u0648\u0642\u0639 \u0647\u0648 {2}. -uniqueItems = {0}: \u064A\u062C\u0628 \u0623\u0646 \u062A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0639\u0646\u0627\u0635\u0631 \u0641\u0631\u064A\u062F\u0629 \u0641\u0642\u0637 \u0641\u064A \u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0629 -writeOnly = {0}: \u0647\u0648 \u062D\u0642\u0644 \u0644\u0644\u0643\u062A\u0627\u0628\u0629 \u0641\u0642\u0637\u060C \u0648\u0644\u0627 \u064A\u0645\u0643\u0646 \u0623\u0646 \u064A\u0638\u0647\u0631 \u0641\u064A \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A -contentEncoding = {0}: \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u062A\u0631\u0645\u064A\u0632 \u0627\u0644\u0645\u062D\u062A\u0648\u0649 {1} -contentMediaType = {0}: \u0644\u064A\u0633 \u0645\u062D\u062A\u0648\u0649 \u062E\u0627\u0635\u064B\u0627 \u0628\u064A +$ref = \u0628\u0647 \u062E\u0637\u0623 \u0641\u064A ''refs'' +additionalItems = \u0644\u0645 \u064A\u062A\u0645 \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0641\u0647\u0631\u0633 ''{0}'' \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0639\u0646\u0627\u0635\u0631 \u0625\u0636\u0627\u0641\u064A\u0629 +additionalProperties = \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{0}'' \u063A\u064A\u0631 \u0645\u062D\u062F\u062F\u0629 \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u062E\u0635\u0627\u0626\u0635 \u0625\u0636\u0627\u0641\u064A\u0629 +allOf = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u062C\u0645\u064A\u0639 \u0627\u0644\u0645\u062E\u0637\u0637\u0627\u062A {0} +anyOf = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0623\u064A \u0645\u0646 \u0627\u0644\u0645\u062E\u0637\u0637\u0627\u062A {0} +const = \u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0627\u0644\u0642\u064A\u0645\u0629 \u0627\u0644\u062B\u0627\u0628\u062A\u0629 ''{0}'' +contains = \u0644\u0627 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0639\u0646\u0635\u0631 \u064A\u0642\u0648\u0645 \u0628\u062A\u0645\u0631\u064A\u0631 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {1} +contains.max = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0639\u0646\u0635\u0631 (\u0639\u0646\u0627\u0635\u0631) \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 \u064A\u062C\u062A\u0627\u0632 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {1} +contains.min = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0639\u0646\u0635\u0631 (\u0639\u0646\u0627\u0635\u0631) \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 \u064A\u0642\u0648\u0645 \u0628\u062A\u0645\u0631\u064A\u0631 \u0639\u0645\u0644\u064A\u0627\u062A \u0627\u0644\u062A\u062D\u0642\u0642 \u0647\u0630\u0647: {1} +dependencies = \u064A\u0648\u062C\u062F \u062E\u0637\u0623 \u0641\u064A \u0627\u0644\u062A\u0628\u0639\u064A\u0627\u062A {0} +dependentRequired = \u0628\u0647 \u062E\u0627\u0635\u064A\u0629 \u0645\u0641\u0642\u0648\u062F\u0629 ''{0}'' \u0648\u0647\u064A \u062A\u0627\u0628\u0639\u0629 \u0645\u0637\u0644\u0648\u0628\u0629 \u0644\u0623\u0646 ''{1}'' \u0645\u0648\u062C\u0648\u062F\u0629 +dependentSchemas = \u0628\u0647 \u062E\u0637\u0623 \u0641\u064AdependentSchemas {0} +enum = \u0644\u0627 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u064A\u0645\u0629 \u0641\u064A \u0627\u0644\u062A\u0639\u062F\u0627\u062F {0} +exclusiveMaximum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0644\u0647 \u0642\u064A\u0645\u0629 \u0642\u0635\u0648\u0649 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {0} +exclusiveMinimum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u064A\u0645\u0629 \u062F\u0646\u064A\u0627 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {0} +false = \u0645\u062E\u0637\u0637 ''{0}'' \u063A\u064A\u0631 \u0635\u062D\u064A\u062D +format = \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 {0} {1} +format.date = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0643\u0627\u0645\u0644\u0627\u064B \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3339 +format.date-time = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0648\u0648\u0642\u062A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0641\u064A RFC 3339 +format.duration = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0645\u062F\u0629 ISO 8601 \u0635\u0627\u0644\u062D\u0629 +format.email = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0646\u062F\u0648\u0642 \u0628\u0631\u064A\u062F RFC 5321 \u0635\u0627\u0644\u062D\u064B\u0627 +format.ipv4 = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 IP \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 2673 +format.ipv6 = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 IP \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 4291 +format.idn-email = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0646\u062F\u0648\u0642 \u0628\u0631\u064A\u062F RFC 6531 \u0635\u0627\u0644\u062D\u064B\u0627 +format.idn-hostname = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0633\u0645 \u0645\u0636\u064A\u0641 \u062F\u0648\u0644\u064A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 5890 +format.iri = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 RFC 3987 IRI \u0635\u0627\u0644\u062D\u064B\u0627 +format.iri-reference = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0631\u062C\u0639 RFC 3987 IRI \u0635\u0627\u0644\u062D\u064B\u0627 +format.uri = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u0646\u0648\u0627\u0646 URI \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3986 +format.uri-reference = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0631\u062C\u0639 URI \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3986 +format.uri-template = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0642\u0627\u0644\u0628 URI RFC 6570 \u0635\u0627\u0644\u062D\u064B\u0627 +format.uuid = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 RFC 4122 UUID \u0635\u0627\u0644\u062D\u064B\u0627 +format.regex = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0639\u0628\u064A\u0631\u064B\u0627 \u0639\u0627\u062F\u064A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 ECMA-262 +format.time = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0648\u0642\u062A RFC 3339 \u0635\u0627\u0644\u062D\u064B\u0627 +format.hostname = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0633\u0645 \u0645\u0636\u064A\u0641 RFC 1123 \u0635\u0627\u0644\u062D\u064B\u0627 +format.json-pointer = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0624\u0634\u0631 RFC 6901 JSON \u0635\u0627\u0644\u062D\u064B\u0627 +format.relative-json-pointer = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0624\u0634\u0631 IETF Relative JSON \u0635\u0627\u0644\u062D\u064B\u0627 +format.unknown = \u0644\u0647 \u062A\u0646\u0633\u064A\u0642 \u063A\u064A\u0631 \u0645\u0639\u0631\u0648\u0641 ''{0}'' +id = ''{0}'' \u0644\u064A\u0633 {1} \u0635\u0627\u0644\u062D\u064B\u0627 +items = \u0644\u0645 \u064A\u062A\u0645 \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0641\u0647\u0631\u0633 ''{0}'' \u0641\u064A \u0627\u0644\u0645\u062E\u0637\u0637 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0639\u0646\u0627\u0635\u0631 \u0625\u0636\u0627\u0641\u064A\u0629 +maxContains = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u062F\u062F\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627 \u063A\u064A\u0631 \u0633\u0627\u0644\u0628 \u0641\u064A {0} +maxItems = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0639\u0646\u0635\u0631 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 \u0648\u0644\u0643\u0646 \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {1} +maxLength = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0637\u0648\u0644\u0647 {0} \u062D\u0631\u0641\u064B\u0627 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 +maxProperties = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0645\u0646 \u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631 +maximum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 \u0644\u0642\u064A\u0645\u0629 {0} +minContains = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0639\u062F\u062F\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627 \u063A\u064A\u0631 \u0633\u0627\u0644\u0628 \u0641\u064A {0} +minContainsVsMaxContains = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 minContains \u0623\u0642\u0644 \u0645\u0646 \u0623\u0648 \u064A\u0633\u0627\u0648\u064A maxContains \u0641\u064A {0} +minItems = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0639\u0646\u0635\u0631 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 \u0648\u0644\u0643\u0646 \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {1} +minLength = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0637\u0648\u0644\u0647 {0} \u062D\u0631\u0641\u064B\u0627 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 +minProperties = \u064A\u062C\u0628 \u0623\u0646 \u062A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 {0} \u0645\u0646 \u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644 +minimum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u062F\u0646\u0649 \u0644\u0642\u064A\u0645\u0629 {0} +multipleOf = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A {0} +not = \u064A\u062C\u0628 \u0623\u0646 \u0644\u0627 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0644\u0645\u062E\u0637\u0637 {0} +notAllowed = \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{0}'' \u063A\u064A\u0631 \u0645\u0633\u0645\u0648\u062D \u0628\u0647\u0627 \u0648\u0644\u0643\u0646\u0647\u0627 \u0645\u0648\u062C\u0648\u062F\u0629 \u0641\u064A \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A +oneOf = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0645\u062E\u0637\u0637 \u0648\u0627\u062D\u062F \u0641\u0642\u0637\u060C \u0648\u0644\u0643\u0646 {0} \u0635\u0627\u0644\u062D +oneOf.indexes = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0645\u062E\u0637\u0637 \u0648\u0627\u062D\u062F \u0641\u0642\u0637\u060C \u0648\u0644\u0643\u0646 {0} \u0635\u0627\u0644\u062D \u0645\u0639 \u0627\u0644\u0641\u0647\u0627\u0631\u0633 ''{1}'' +pattern = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0646\u0645\u0637 \u0627\u0644\u062A\u0639\u0628\u064A\u0631 \u0627\u0644\u0639\u0627\u062F\u064A {0} +patternProperties = \u0628\u0647 \u0628\u0639\u0636 \u0627\u0644\u0623\u062E\u0637\u0627\u0621 \u0641\u064A ''\u062E\u0635\u0627\u0626\u0635 \u0627\u0644\u0646\u0645\u0637'' +prefixItems = \u0644\u0645 \u064A\u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 \u0623\u062F\u0627\u0629 \u0627\u0644\u062A\u062D\u0642\u0642 \u0641\u064A \u0647\u0630\u0627 \u0627\u0644\u0641\u0647\u0631\u0633 +properties = \u064A\u0648\u062C\u062F \u062E\u0637\u0623 \u0641\u064A ''\u0627\u0644\u062E\u0635\u0627\u0626\u0635'' +propertyNames = \u0627\u0633\u0645 \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{0}'' \u063A\u064A\u0631 \u0635\u0627\u0644\u062D: {1} +readOnly = \u0647\u0648 \u062D\u0642\u0644 \u0644\u0644\u0642\u0631\u0627\u0621\u0629 \u0641\u0642\u0637\u060C \u0648\u0644\u0627 \u064A\u0645\u0643\u0646 \u062A\u063A\u064A\u064A\u0631\u0647 +required = \u0627\u0644\u062E\u0627\u0635\u064A\u0629 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629 ''{0}'' \u063A\u064A\u0631 \u0645\u0648\u062C\u0648\u062F\u0629 +type = \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {0}\u060C \u0648\u0627\u0644\u0645\u062A\u0648\u0642\u0639 \u0647\u0648 {1}. +unevaluatedItems = \u0644\u0645 \u064A\u062A\u0645 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0641\u0647\u0631\u0633 ''{0}'' \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0627\u0644\u0639\u0646\u0627\u0635\u0631 \u063A\u064A\u0631 \u0627\u0644\u0645\u0642\u064A\u064E\u0651\u0645\u0629 +unevaluatedProperties = \u0627\u0644\u062E\u0627\u0635\u064A\u0629 ''{0}'' \u0644\u0645 \u064A\u062A\u0645 \u062A\u0642\u064A\u064A\u0645\u0647\u0627 \u0648\u0644\u0627 \u064A\u0633\u0645\u062D \u0627\u0644\u0645\u062E\u0637\u0637 \u0628\u0627\u0644\u062E\u0635\u0627\u0626\u0635 \u063A\u064A\u0631 \u0627\u0644\u0645\u0642\u064A\u064E\u0651\u0645\u0629 +unionType = \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 {0}\u060C \u0648\u0627\u0644\u0645\u062A\u0648\u0642\u0639 \u0647\u0648 {1}. +uniqueItems = \u064A\u062C\u0628 \u0623\u0646 \u062A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0639\u0646\u0627\u0635\u0631 \u0641\u0631\u064A\u062F\u0629 \u0641\u0642\u0637 \u0641\u064A \u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0629 +writeOnly = \u0647\u0648 \u062D\u0642\u0644 \u0644\u0644\u0643\u062A\u0627\u0628\u0629 \u0641\u0642\u0637\u060C \u0648\u0644\u0627 \u064A\u0645\u0643\u0646 \u0623\u0646 \u064A\u0638\u0647\u0631 \u0641\u064A \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A +contentEncoding = \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u062A\u0631\u0645\u064A\u0632 \u0627\u0644\u0645\u062D\u062A\u0648\u0649 {0} +contentMediaType = \u0644\u064A\u0633 \u0645\u062D\u062A\u0648\u0649 \u062E\u0627\u0635\u064B\u0627 \u0628\u064A diff --git a/src/main/resources/jsv-messages_cs.properties b/src/main/resources/jsv-messages_cs.properties index 49088a932..f704ac45a 100644 --- a/src/main/resources/jsv-messages_cs.properties +++ b/src/main/resources/jsv-messages_cs.properties @@ -1,70 +1,70 @@ -$ref = {0}: obsahuje chybu s ''refs'' -additionalItems = {0}: index ''{1}'' není ve schématu definován a schéma nepovoluje dal\u0161í polo\u017Eky -additionalProperties = {0}: vlastnost ''{1}'' není ve schématu definována a schéma neumo\u017E\u0148uje dal\u0161í vlastnosti -allOf = {0}: musí být platné pro v\u0161echna schémata {1} -anyOf = {0}: musí být platné pro kterékoli ze schémat {1} -const = {0}: musí být konstantní hodnota ''{1}'' -contains = {0}: neobsahuje prvek, který pro\u0161el t\u011Bmito ov\u011B\u0159eními: {2} -contains.max = {0}: musí obsahovat nejvý\u0161e {1} prvk\u016F, které projdou t\u011Bmito ov\u011B\u0159eními: {2} -contains.min = {0}: musí obsahovat alespo\u0148 {1} prvk\u016F, které projdou t\u011Bmito ov\u011B\u0159eními: {2} -dependencies = {0}: obsahuje chybu se závislostmi {1} -dependentRequired = {0}: má chyb\u011Bjící vlastnost ''{1}'', která je závislá povinná, proto\u017Ee ''{2}'' je p\u0159ítomen -dependentSchemas = {0}: obsahuje chybu s dependentSchemas {1} -enum = {0}: nemá hodnotu ve vý\u010Dtu {1} -exclusiveMaximum = {0}: musí mít exkluzivní maximální hodnotu {1} -exclusiveMinimum = {0}: musí mít exkluzivní minimální hodnotu {1} -false = {0}: schéma pro ''{1}'' je nepravdivé -format = {0}: neodpovídá vzoru {1} {2} -format.date = {0}: neodpovídá vzoru {1} musí být platné plné datum RFC 3339 -format.date-time = {0}: neodpovídá vzoru {1} musí být platné datum a \u010Das RFC 3339 -format.duration = {0}: neodpovídá vzoru {1}, musí mít platnou dobu trvání ISO 8601 -format.email = {0}: neodpovídá vzoru {1} musí být platná po\u0161tovní schránka RFC 5321 -format.ipv4 = {0}: neodpovídá vzoru {1} musí být platná IP adresa RFC 2673 -format.ipv6 = {0}: neodpovídá vzoru {1} musí být platná IP adresa RFC 4291 -format.idn-email = {0}: neodpovídá vzoru {1} musí být platná po\u0161tovní schránka RFC 6531 -format.idn-hostname = {0}: neodpovídá vzoru {1}, musí být platným internacionalizovaným názvem hostitele RFC 5890 -format.iri = {0}: neodpovídá vzoru {1} musí být platný RFC 3987 IRI -format.iri-reference = {0}: neodpovídá vzoru {1} musí být platný RFC 3987 IRI-reference -format.uri = {0}: neodpovídá vzoru {1} musí být platný RFC 3986 URI -format.uri-reference = {0}: neodpovídá vzoru {1} musí být platný RFC 3986 URI odkaz -format.uri-template = {0}: neodpovídá vzoru {1} musí být platná \u0161ablona URI RFC 6570 -format.uuid = {0}: neodpovídá vzoru {1} musí být platný RFC 4122 UUID -format.regex = {0}: neodpovídá vzoru {1} musí být platný regulární výraz ECMA-262 -format.time = {0}: neodpovídá vzoru {1} musí být platný \u010Das RFC 3339 -format.hostname = {0}: neodpovídá vzoru {1} musí být platný název hostitele RFC 1123 -format.json-pointer = {0}: neodpovídá vzoru {1} musí být platný RFC 6901 JSON ukazatel -format.relative-json-pointer = {0}: neodpovídá vzoru {1} musí být platný IETF relativní ukazatel JSON -format.unknown = {0}: má neznámý formát ''{1}'' -id = {0}: ''{1}'' není platný {2} -items = {0}: index ''{1}'' není ve schématu definován a schéma neumo\u017E\u0148uje dal\u0161í polo\u017Eky -maxContains = {0}: musí být nezáporné celé \u010Díslo v {1} -maxItems = {0}: musí mít maximáln\u011B {1} polo\u017Eek, ale nalezeno {2} -maxLength = {0}: musí mít maximáln\u011B {1} znak\u016F -maxProperties = {0}: musí mít maximáln\u011B {1} vlastností -maximum = {0}: musí mít maximální hodnotu {1} -minContains = {0}: musí být nezáporné celé \u010Díslo v {1} -minContainsVsMaxContains = {0}: minContains musí být men\u0161í nebo roven maxContains v {1} -minItems = {0}: musí mít alespo\u0148 {1} polo\u017Eek, ale nalezeno {2} -minLength = {0}: musí mít alespo\u0148 {1} znak\u016F -minProperties = {0}: musí mít alespo\u0148 {1} vlastností -minimum = {0}: musí mít minimální hodnotu {1} -multipleOf = {0}: musí být násobkem {1} -not = {0}: nesmí být platné pro schéma {1} -notAllowed = {0}: vlastnost ''{1}'' není povolena, ale je v datech -oneOf = {0}: musí být platné pro jedno a pouze jedno schéma, ale {1} jsou platné -oneOf.indexes = {0}: musí být platné pro jedno a pouze jedno schéma, ale {1} jsou platné s indexy ''{2}'' -pattern = {0}: neodpovídá vzoru regulárního výrazu {1} -patternProperties = {0}: obsahuje n\u011Bjakou chybu s ''vlastnostmi vzoru'' -prefixItems = {0}: v tomto indexu nebyl nalezen \u017Eádný validátor -properties = {0}: obsahuje chybu s ''vlastnosti'' -propertyNames = {0}: název vlastnosti ''{1}'' není platný: {2} -readOnly = {0}: je pole pouze pro \u010Dtení, nelze jej zm\u011Bnit -required = {0}: po\u017Eadovaná vlastnost ''{1}'' nebyla nalezena -type = {0}: nalezeno {1}, o\u010Dekáváno {2} -unevaluatedItems = {0}: index ''{1}'' není vyhodnocen a schéma nepovoluje neohodnocené polo\u017Eky -unevaluatedProperties = {0}: vlastnost ''{1}'' není vyhodnocena a schéma nepovoluje neohodnocené vlastnosti -unionType = {0}: nalezeno {1}, o\u010Dekáváno {2} -uniqueItems = {0}: musí mít v poli pouze jedine\u010Dné polo\u017Eky -writeOnly = {0}: je pole pouze pro zápis, nem\u016F\u017Ee se objevit v datech -contentEncoding = {0}: neodpovídá kódování obsahu {1} -contentMediaType = {0}: není obsah já +$ref = obsahuje chybu s ''refs'' +additionalItems = index ''{0}'' není ve schématu definován a schéma nepovoluje dal\u0161í polo\u017Eky +additionalProperties = vlastnost ''{0}'' není ve schématu definována a schéma neumo\u017E\u0148uje dal\u0161í vlastnosti +allOf = musí být platné pro v\u0161echna schémata {0} +anyOf = musí být platné pro kterékoli ze schémat {0} +const = musí být konstantní hodnota ''{0}'' +contains = neobsahuje prvek, který pro\u0161el t\u011Bmito ov\u011B\u0159eními: {1} +contains.max = musí obsahovat nejvý\u0161e {0} prvk\u016F, které projdou t\u011Bmito ov\u011B\u0159eními: {1} +contains.min = musí obsahovat alespo\u0148 {0} prvk\u016F, které projdou t\u011Bmito ov\u011B\u0159eními: {1} +dependencies = obsahuje chybu se závislostmi {0} +dependentRequired = má chyb\u011Bjící vlastnost ''{0}'', která je závislá povinná, proto\u017Ee ''{1}'' je p\u0159ítomen +dependentSchemas = obsahuje chybu s dependentSchemas {0} +enum = nemá hodnotu ve vý\u010Dtu {0} +exclusiveMaximum = musí mít exkluzivní maximální hodnotu {0} +exclusiveMinimum = musí mít exkluzivní minimální hodnotu {0} +false = schéma pro ''{0}'' je nepravdivé +format = neodpovídá vzoru {0} {1} +format.date = neodpovídá vzoru {0} musí být platné plné datum RFC 3339 +format.date-time = neodpovídá vzoru {0} musí být platné datum a \u010Das RFC 3339 +format.duration = neodpovídá vzoru {0}, musí mít platnou dobu trvání ISO 8601 +format.email = neodpovídá vzoru {0} musí být platná po\u0161tovní schránka RFC 5321 +format.ipv4 = neodpovídá vzoru {0} musí být platná IP adresa RFC 2673 +format.ipv6 = neodpovídá vzoru {0} musí být platná IP adresa RFC 4291 +format.idn-email = neodpovídá vzoru {0} musí být platná po\u0161tovní schránka RFC 6531 +format.idn-hostname = neodpovídá vzoru {0}, musí být platným internacionalizovaným názvem hostitele RFC 5890 +format.iri = neodpovídá vzoru {0} musí být platný RFC 3987 IRI +format.iri-reference = neodpovídá vzoru {0} musí být platný RFC 3987 IRI-reference +format.uri = neodpovídá vzoru {0} musí být platný RFC 3986 URI +format.uri-reference = neodpovídá vzoru {0} musí být platný RFC 3986 URI odkaz +format.uri-template = neodpovídá vzoru {0} musí být platná \u0161ablona URI RFC 6570 +format.uuid = neodpovídá vzoru {0} musí být platný RFC 4122 UUID +format.regex = neodpovídá vzoru {0} musí být platný regulární výraz ECMA-262 +format.time = neodpovídá vzoru {0} musí být platný \u010Das RFC 3339 +format.hostname = neodpovídá vzoru {0} musí být platný název hostitele RFC 1123 +format.json-pointer = neodpovídá vzoru {0} musí být platný RFC 6901 JSON ukazatel +format.relative-json-pointer = neodpovídá vzoru {0} musí být platný IETF relativní ukazatel JSON +format.unknown = má neznámý formát ''{0}'' +id = ''{0}'' není platný {1} +items = index ''{0}'' není ve schématu definován a schéma neumo\u017E\u0148uje dal\u0161í polo\u017Eky +maxContains = musí být nezáporné celé \u010Díslo v {0} +maxItems = musí mít maximáln\u011B {0} polo\u017Eek, ale nalezeno {1} +maxLength = musí mít maximáln\u011B {0} znak\u016F +maxProperties = musí mít maximáln\u011B {0} vlastností +maximum = musí mít maximální hodnotu {0} +minContains = musí být nezáporné celé \u010Díslo v {0} +minContainsVsMaxContains = minContains musí být men\u0161í nebo roven maxContains v {0} +minItems = musí mít alespo\u0148 {0} polo\u017Eek, ale nalezeno {1} +minLength = musí mít alespo\u0148 {0} znak\u016F +minProperties = musí mít alespo\u0148 {0} vlastností +minimum = musí mít minimální hodnotu {0} +multipleOf = musí být násobkem {0} +not = nesmí být platné pro schéma {0} +notAllowed = vlastnost ''{0}'' není povolena, ale je v datech +oneOf = musí být platné pro jedno a pouze jedno schéma, ale {0} jsou platné +oneOf.indexes = musí být platné pro jedno a pouze jedno schéma, ale {0} jsou platné s indexy ''{1}'' +pattern = neodpovídá vzoru regulárního výrazu {0} +patternProperties = obsahuje n\u011Bjakou chybu s ''vlastnostmi vzoru'' +prefixItems = v tomto indexu nebyl nalezen \u017Eádný validátor +properties = obsahuje chybu s ''vlastnosti'' +propertyNames = název vlastnosti ''{0}'' není platný: {1} +readOnly = je pole pouze pro \u010Dtení, nelze jej zm\u011Bnit +required = po\u017Eadovaná vlastnost ''{0}'' nebyla nalezena +type = nalezeno {0}, o\u010Dekáváno {1} +unevaluatedItems = index ''{0}'' není vyhodnocen a schéma nepovoluje neohodnocené polo\u017Eky +unevaluatedProperties = vlastnost ''{0}'' není vyhodnocena a schéma nepovoluje neohodnocené vlastnosti +unionType = nalezeno {0}, o\u010Dekáváno {1} +uniqueItems = musí mít v poli pouze jedine\u010Dné polo\u017Eky +writeOnly = je pole pouze pro zápis, nem\u016F\u017Ee se objevit v datech +contentEncoding = neodpovídá kódování obsahu {0} +contentMediaType = není obsah já diff --git a/src/main/resources/jsv-messages_da.properties b/src/main/resources/jsv-messages_da.properties index 458269d9d..790a7bf8b 100644 --- a/src/main/resources/jsv-messages_da.properties +++ b/src/main/resources/jsv-messages_da.properties @@ -1,70 +1,70 @@ -$ref = {0}: har en fejl med ''refs'' -additionalItems = {0}: indeks ''{1}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere elementer -additionalProperties = {0}: egenskaben ''{1}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere egenskaber -allOf = {0}: skal være gyldig for alle skemaerne {1} -anyOf = {0}: skal være gyldig for et hvilket som helst af skemaerne {1} -const = {0}: skal være den konstante værdi ''{1}'' -contains = {0}: indeholder ikke et element, der består disse valideringer: {2} -contains.max = {0}: må højst indeholde {1} element(er), der består disse valideringer: {2} -contains.min = {0}: skal indeholde mindst {1} element(er), der består disse valideringer: {2} -dependencies = {0}: har en fejl med afhængigheder {1} -dependentRequired = {0}: har en manglende egenskab ''{1}'', som er afhængig påkrævet, fordi ''{2}'' er til stede -dependentSchemas = {0}: har en fejl med dependentSchemas {1} -enum = {0}: har ikke en værdi i opregningen {1} -exclusiveMaximum = {0}: skal have en eksklusiv maksimumværdi på {1} -exclusiveMinimum = {0}: skal have en eksklusiv minimumsværdi på {1} -false = {0}: skemaet for ''{1}'' er falsk -format = {0}: matcher ikke {1}-mønsteret {2} -format.date = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3339 fuld-dato -format.date-time = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3339 dato-tid -format.duration = {0}: matcher ikke {1}-mønsteret skal være en gyldig ISO 8601-varighed -format.email = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 5321-postkasse -format.ipv4 = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 2673 IP-adresse -format.ipv6 = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 4291 IP-adresse -format.idn-email = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 6531-postkasse -format.idn-hostname = {0}: matcher ikke {1}-mønsteret skal være et gyldigt RFC 5890 internationaliseret værtsnavn -format.iri = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3987 IRI -format.iri-reference = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3987 IRI-reference -format.uri = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3986 URI -format.uri-reference = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3986 URI-reference -format.uri-template = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 6570 URI-skabelon -format.uuid = {0}: matcher ikke {1}-mønsteret skal være et gyldigt RFC 4122 UUID -format.regex = {0}: matcher ikke {1}-mønsteret skal være et gyldigt ECMA-262 regulært udtryk -format.time = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 3339-tid -format.hostname = {0}: matcher ikke {1}-mønsteret skal være et gyldigt RFC 1123-værtsnavn -format.json-pointer = {0}: matcher ikke {1}-mønsteret skal være en gyldig RFC 6901 JSON-peger -format.relative-json-pointer = {0}: matcher ikke {1}-mønsteret skal være en gyldig IETF Relativ JSON-peger -format.unknown = {0}: har et ukendt format ''{1}'' -id = {0}: ''{1}'' er ikke en gyldig {2} -items = {0}: indeks ''{1}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere elementer -maxContains = {0}: skal være et ikke-negativt heltal i {1} -maxItems = {0}: må højst have {1} varer, men fundet {2} -maxLength = {0}: må højst være på {1} tegn -maxProperties = {0}: må højst have {1} egenskaber -maximum = {0}: skal have en maksimal værdi på {1} -minContains = {0}: skal være et ikke-negativt heltal i {1} -minContainsVsMaxContains = {0}: minContains skal være mindre end eller lig med maxContains i {1} -minItems = {0}: skal have mindst {1} elementer, men fundet {2} -minLength = {0}: skal være mindst {1} tegn lang -minProperties = {0}: skal have mindst {1} egenskaber -minimum = {0}: skal have en minimumsværdi på {1} -multipleOf = {0}: skal være multiplum af {1} -not = {0}: må ikke være gyldig for skemaet {1} -notAllowed = {0}: egenskaben ''{1}'' er ikke tilladt, men den er i dataene -oneOf = {0}: skal være gyldig for ét og kun ét skema, men {1} er gyldige -oneOf.indexes = {0}: skal være gyldig for ét og kun ét skema, men {1} er gyldige med indekser ''{2}'' -pattern = {0}: matcher ikke regex-mønsteret {1} -patternProperties = {0}: har en fejl med ''mønsteregenskaber'' -prefixItems = {0}: ingen validator fundet i dette indeks -properties = {0}: har en fejl med ''egenskaber'' -propertyNames = {0}: Ejendommen ''{1}'' navn er ikke gyldigt: {2} -readOnly = {0}: er et skrivebeskyttet felt, det kan ikke ændres -required = {0}: påkrævet egenskab ''{1}'' blev ikke fundet -type = {0}: {1} fundet, {2} forventet -unevaluatedItems = {0}: indeks ''{1}'' evalueres ikke, og skemaet tillader ikke uevaluerede elementer -unevaluatedProperties = {0}: egenskaben ''{1}'' evalueres ikke, og skemaet tillader ikke uevaluerede egenskaber -unionType = {0}: {1} fundet, {2} forventet -uniqueItems = {0}: må kun have unikke elementer i arrayet -writeOnly = {0}: er et skrivebeskyttet felt, det kan ikke vises i dataene -contentEncoding = {0}: matcher ikke indholdskodning {1} -contentMediaType = {0}: er ikke et indholds mig +$ref = har en fejl med ''refs'' +additionalItems = indeks ''{0}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere elementer +additionalProperties = egenskaben ''{0}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere egenskaber +allOf = skal være gyldig for alle skemaerne {0} +anyOf = skal være gyldig for et hvilket som helst af skemaerne {0} +const = skal være den konstante værdi ''{0}'' +contains = indeholder ikke et element, der består disse valideringer: {1} +contains.max = må højst indeholde {0} element(er), der består disse valideringer: {1} +contains.min = skal indeholde mindst {0} element(er), der består disse valideringer: {1} +dependencies = har en fejl med afhængigheder {0} +dependentRequired = har en manglende egenskab ''{0}'', som er afhængig påkrævet, fordi ''{1}'' er til stede +dependentSchemas = har en fejl med dependentSchemas {0} +enum = har ikke en værdi i opregningen {0} +exclusiveMaximum = skal have en eksklusiv maksimumværdi på {0} +exclusiveMinimum = skal have en eksklusiv minimumsværdi på {0} +false = skemaet for ''{0}'' er falsk +format = matcher ikke {0}-mønsteret {1} +format.date = matcher ikke {0}-mønsteret skal være en gyldig RFC 3339 fuld-dato +format.date-time = matcher ikke {0}-mønsteret skal være en gyldig RFC 3339 dato-tid +format.duration = matcher ikke {0}-mønsteret skal være en gyldig ISO 8601-varighed +format.email = matcher ikke {0}-mønsteret skal være en gyldig RFC 5321-postkasse +format.ipv4 = matcher ikke {0}-mønsteret skal være en gyldig RFC 2673 IP-adresse +format.ipv6 = matcher ikke {0}-mønsteret skal være en gyldig RFC 4291 IP-adresse +format.idn-email = matcher ikke {0}-mønsteret skal være en gyldig RFC 6531-postkasse +format.idn-hostname = matcher ikke {0}-mønsteret skal være et gyldigt RFC 5890 internationaliseret værtsnavn +format.iri = matcher ikke {0}-mønsteret skal være en gyldig RFC 3987 IRI +format.iri-reference = matcher ikke {0}-mønsteret skal være en gyldig RFC 3987 IRI-reference +format.uri = matcher ikke {0}-mønsteret skal være en gyldig RFC 3986 URI +format.uri-reference = matcher ikke {0}-mønsteret skal være en gyldig RFC 3986 URI-reference +format.uri-template = matcher ikke {0}-mønsteret skal være en gyldig RFC 6570 URI-skabelon +format.uuid = matcher ikke {0}-mønsteret skal være et gyldigt RFC 4122 UUID +format.regex = matcher ikke {0}-mønsteret skal være et gyldigt ECMA-262 regulært udtryk +format.time = matcher ikke {0}-mønsteret skal være en gyldig RFC 3339-tid +format.hostname = matcher ikke {0}-mønsteret skal være et gyldigt RFC 1123-værtsnavn +format.json-pointer = matcher ikke {0}-mønsteret skal være en gyldig RFC 6901 JSON-peger +format.relative-json-pointer = matcher ikke {0}-mønsteret skal være en gyldig IETF Relativ JSON-peger +format.unknown = har et ukendt format ''{0}'' +id = ''{0}'' er ikke en gyldig {1} +items = indeks ''{0}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere elementer +maxContains = skal være et ikke-negativt heltal i {0} +maxItems = må højst have {0} varer, men fundet {1} +maxLength = må højst være på {0} tegn +maxProperties = må højst have {0} egenskaber +maximum = skal have en maksimal værdi på {0} +minContains = skal være et ikke-negativt heltal i {0} +minContainsVsMaxContains = minContains skal være mindre end eller lig med maxContains i {0} +minItems = skal have mindst {0} elementer, men fundet {1} +minLength = skal være mindst {0} tegn lang +minProperties = skal have mindst {0} egenskaber +minimum = skal have en minimumsværdi på {0} +multipleOf = skal være multiplum af {0} +not = må ikke være gyldig for skemaet {0} +notAllowed = egenskaben ''{0}'' er ikke tilladt, men den er i dataene +oneOf = skal være gyldig for ét og kun ét skema, men {0} er gyldige +oneOf.indexes = skal være gyldig for ét og kun ét skema, men {0} er gyldige med indekser ''{1}'' +pattern = matcher ikke regex-mønsteret {0} +patternProperties = har en fejl med ''mønsteregenskaber'' +prefixItems = ingen validator fundet i dette indeks +properties = har en fejl med ''egenskaber'' +propertyNames = Ejendommen ''{0}'' navn er ikke gyldigt: {1} +readOnly = er et skrivebeskyttet felt, det kan ikke ændres +required = påkrævet egenskab ''{0}'' blev ikke fundet +type = {0} fundet, {1} forventet +unevaluatedItems = indeks ''{0}'' evalueres ikke, og skemaet tillader ikke uevaluerede elementer +unevaluatedProperties = egenskaben ''{0}'' evalueres ikke, og skemaet tillader ikke uevaluerede egenskaber +unionType = {0} fundet, {1} forventet +uniqueItems = må kun have unikke elementer i arrayet +writeOnly = er et skrivebeskyttet felt, det kan ikke vises i dataene +contentEncoding = matcher ikke indholdskodning {0} +contentMediaType = er ikke et indholds mig diff --git a/src/main/resources/jsv-messages_de.properties b/src/main/resources/jsv-messages_de.properties index 13d280605..5daed1825 100644 --- a/src/main/resources/jsv-messages_de.properties +++ b/src/main/resources/jsv-messages_de.properties @@ -1,70 +1,70 @@ -$ref = {0}: hat einen Fehler mit ''refs'' -additionalItems = {0}: Index \u201E{1}\u201C ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Elemente zu -additionalProperties = {0}: Eigenschaft ''{1}'' ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Eigenschaften zu -allOf = {0}: muss für alle Schemas {1} gültig sein -anyOf = {0}: muss für eines der Schemas {1} gültig sein -const = {0}: muss der konstante Wert ''{1}'' sein -contains = {0}: enthält kein Element, das diese Validierungen besteht: {2} -contains.max = {0}: muss höchstens {1} Elemente enthalten, die diese Validierungen bestehen: {2} -contains.min = {0}: muss mindestens {1} Elemente enthalten, die diese Validierungen bestehen: {2} -dependencies = {0}: Es liegt ein Fehler mit den Abhängigkeiten {1} vor. -dependentRequired = {0}: Es fehlt eine Eigenschaft \u201E{1}\u201C, die abhängig ist, da \u201E{2}\u201C vorhanden ist -dependentSchemas = {0}: Es liegt ein Fehler mit dependenceSchemas {1} vor. -enum = {0}: hat keinen Wert in der Aufzählung {1} -exclusiveMaximum = {0}: muss einen exklusiven Maximalwert von {1} haben -exclusiveMinimum = {0}: muss einen exklusiven Mindestwert von {1} haben -false = {0}: Schema für ''{1}'' ist falsch -format = {0}: entspricht nicht dem Muster {1} {2} -format.date = {0}: stimmt nicht mit dem {1}-Muster überein, muss ein gültiges RFC 3339-Volldatum sein -format.date-time = {0}: entspricht nicht dem {1}-Muster. Es muss sich um ein gültiges RFC 3339-Datum/Uhrzeit-Format handeln -format.duration = {0}: stimmt nicht mit dem {1}-Muster überein, muss eine gültige ISO 8601-Dauer sein -format.email = {0}: entspricht nicht dem {1}-Muster. Es muss sich um ein gültiges RFC 5321-Postfach handeln -format.ipv4 = {0}: entspricht nicht dem {1}-Muster. Es muss sich um eine gültige RFC 2673-IP-Adresse handeln -format.ipv6 = {0}: entspricht nicht dem {1}-Muster. Es muss sich um eine gültige RFC 4291-IP-Adresse handeln -format.idn-email = {0}: entspricht nicht dem {1}-Muster. Es muss sich um ein gültiges RFC 6531-Postfach handeln -format.idn-hostname = {0}: entspricht nicht dem {1}-Muster. Es muss sich um einen gültigen internationalisierten RFC 5890-Hostnamen handeln -format.iri = {0}: entspricht nicht dem {1}-Muster, muss ein gültiger RFC 3987 IRI sein -format.iri-reference = {0}: entspricht nicht dem {1}-Muster muss eine gültige RFC 3987 IRI-Referenz sein -format.uri = {0}: entspricht nicht dem {1}-Muster muss ein gültiger RFC 3986-URI sein -format.uri-reference = {0}: stimmt nicht mit dem {1}-Muster überein, muss eine gültige RFC 3986-URI-Referenz sein -format.uri-template = {0}: entspricht nicht dem {1}-Muster. Es muss sich um eine gültige RFC 6570-URI-Vorlage handeln -format.uuid = {0}: stimmt nicht mit dem {1}-Muster überein, muss eine gültige RFC 4122-UUID sein -format.regex = {0}: entspricht nicht dem Muster {1} muss ein gültiger regulärer ECMA-262-Ausdruck sein -format.time = {0}: entspricht nicht dem {1}-Muster muss eine gültige RFC 3339-Zeit sein -format.hostname = {0}: entspricht nicht dem {1}-Muster. Es muss sich um einen gültigen RFC 1123-Hostnamen handeln -format.json-pointer = {0}: stimmt nicht mit dem {1}-Muster überein, muss ein gültiger RFC 6901-JSON-Zeiger sein -format.relative-json-pointer = {0}: stimmt nicht mit dem {1}-Muster überein, muss ein gültiger relativer IETF-JSON-Zeiger sein -format.unknown = {0}: hat ein unbekanntes Format ''{1}'' -id = {0}: ''{1}'' ist kein gültiger {2} -items = {0}: Index ''{1}'' ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Elemente zu -maxContains = {0}: muss eine nicht negative Ganzzahl in {1} sein -maxItems = {0}: muss höchstens {1} Elemente haben, aber {2} gefunden -maxLength = {0}: darf höchstens {1} Zeichen lang sein -maxProperties = {0}: darf höchstens {1} Eigenschaften haben -maximum = {0}: muss einen Maximalwert von {1} haben -minContains = {0}: muss eine nicht negative Ganzzahl in {1} sein -minContainsVsMaxContains = {0}: minContains muss kleiner oder gleich maxContains in {1} sein -minItems = {0}: muss mindestens {1} Elemente haben, aber {2} gefunden -minLength = {0}: muss mindestens {1} Zeichen lang sein -minProperties = {0}: muss mindestens {1} Eigenschaften haben -minimum = {0}: muss einen Mindestwert von {1} haben -multipleOf = {0}: muss ein Vielfaches von {1} sein -not = {0}: darf für das Schema {1} nicht gültig sein -notAllowed = {0}: Eigenschaft ''{1}'' ist nicht zulässig, befindet sich aber in den Daten -oneOf = {0}: muss für ein und nur ein Schema gültig sein, aber {1} sind gültig -oneOf.indexes = {0}: muss für ein und nur ein Schema gültig sein, aber {1} sind mit den Indizes \u201E{2}\u201C gültig. -pattern = {0}: stimmt nicht mit dem Regex-Muster {1} überein -patternProperties = {0}: Es liegt ein Fehler mit den \u201EMustereigenschaften\u201C vor. -prefixItems = {0}: Bei diesem Index wurde kein Validator gefunden -properties = {0}: Es liegt ein Fehler mit \u201EProperties\u201C vor. -propertyNames = {0}: Der Name der Eigenschaft \u201E{1}\u201C ist ungültig: {2} -readOnly = {0}: ist ein schreibgeschütztes Feld, es kann nicht geändert werden -required = {0}: erforderliche Eigenschaft ''{1}'' nicht gefunden -type = {0}: {1} gefunden, {2} erwartet -unevaluatedItems = {0}: Index ''{1}'' wird nicht ausgewertet und das Schema lässt keine nicht ausgewerteten Elemente zu -unevaluatedProperties = {0}: Eigenschaft ''{1}'' wird nicht ausgewertet und das Schema lässt keine nicht ausgewerteten Eigenschaften zu -unionType = {0}: {1} gefunden, {2} erwartet -uniqueItems = {0}: Das Array darf nur eindeutige Elemente enthalten -writeOnly = {0}: ist ein schreibgeschütztes Feld, es kann nicht in den Daten erscheinen -contentEncoding = {0}: stimmt nicht mit der Inhaltskodierung {1} überein -contentMediaType = {0}: ist kein Inhalt für mich +$ref = hat einen Fehler mit ''refs'' +additionalItems = Index \u201E{0}\u201C ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Elemente zu +additionalProperties = Eigenschaft ''{0}'' ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Eigenschaften zu +allOf = muss für alle Schemas {0} gültig sein +anyOf = muss für eines der Schemas {0} gültig sein +const = muss der konstante Wert ''{0}'' sein +contains = enthält kein Element, das diese Validierungen besteht: {1} +contains.max = muss höchstens {0} Elemente enthalten, die diese Validierungen bestehen: {1} +contains.min = muss mindestens {0} Elemente enthalten, die diese Validierungen bestehen: {1} +dependencies = Es liegt ein Fehler mit den Abhängigkeiten {0} vor. +dependentRequired = Es fehlt eine Eigenschaft \u201E{0}\u201C, die abhängig ist, da \u201E{1}\u201C vorhanden ist +dependentSchemas = Es liegt ein Fehler mit dependenceSchemas {0} vor. +enum = hat keinen Wert in der Aufzählung {0} +exclusiveMaximum = muss einen exklusiven Maximalwert von {0} haben +exclusiveMinimum = muss einen exklusiven Mindestwert von {0} haben +false = Schema für ''{0}'' ist falsch +format = entspricht nicht dem Muster {0} {1} +format.date = stimmt nicht mit dem {0}-Muster überein, muss ein gültiges RFC 3339-Volldatum sein +format.date-time = entspricht nicht dem {0}-Muster. Es muss sich um ein gültiges RFC 3339-Datum/Uhrzeit-Format handeln +format.duration = stimmt nicht mit dem {0}-Muster überein, muss eine gültige ISO 8601-Dauer sein +format.email = entspricht nicht dem {0}-Muster. Es muss sich um ein gültiges RFC 5321-Postfach handeln +format.ipv4 = entspricht nicht dem {0}-Muster. Es muss sich um eine gültige RFC 2673-IP-Adresse handeln +format.ipv6 = entspricht nicht dem {0}-Muster. Es muss sich um eine gültige RFC 4291-IP-Adresse handeln +format.idn-email = entspricht nicht dem {0}-Muster. Es muss sich um ein gültiges RFC 6531-Postfach handeln +format.idn-hostname = entspricht nicht dem {0}-Muster. Es muss sich um einen gültigen internationalisierten RFC 5890-Hostnamen handeln +format.iri = entspricht nicht dem {0}-Muster, muss ein gültiger RFC 3987 IRI sein +format.iri-reference = entspricht nicht dem {0}-Muster muss eine gültige RFC 3987 IRI-Referenz sein +format.uri = entspricht nicht dem {0}-Muster muss ein gültiger RFC 3986-URI sein +format.uri-reference = stimmt nicht mit dem {0}-Muster überein, muss eine gültige RFC 3986-URI-Referenz sein +format.uri-template = entspricht nicht dem {0}-Muster. Es muss sich um eine gültige RFC 6570-URI-Vorlage handeln +format.uuid = stimmt nicht mit dem {0}-Muster überein, muss eine gültige RFC 4122-UUID sein +format.regex = entspricht nicht dem Muster {0} muss ein gültiger regulärer ECMA-262-Ausdruck sein +format.time = entspricht nicht dem {0}-Muster muss eine gültige RFC 3339-Zeit sein +format.hostname = entspricht nicht dem {0}-Muster. Es muss sich um einen gültigen RFC 1123-Hostnamen handeln +format.json-pointer = stimmt nicht mit dem {0}-Muster überein, muss ein gültiger RFC 6901-JSON-Zeiger sein +format.relative-json-pointer = stimmt nicht mit dem {0}-Muster überein, muss ein gültiger relativer IETF-JSON-Zeiger sein +format.unknown = hat ein unbekanntes Format ''{0}'' +id = ''{0}'' ist kein gültiger {1} +items = Index ''{0}'' ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Elemente zu +maxContains = muss eine nicht negative Ganzzahl in {0} sein +maxItems = muss höchstens {0} Elemente haben, aber {1} gefunden +maxLength = darf höchstens {0} Zeichen lang sein +maxProperties = darf höchstens {0} Eigenschaften haben +maximum = muss einen Maximalwert von {0} haben +minContains = muss eine nicht negative Ganzzahl in {0} sein +minContainsVsMaxContains = minContains muss kleiner oder gleich maxContains in {0} sein +minItems = muss mindestens {0} Elemente haben, aber {1} gefunden +minLength = muss mindestens {0} Zeichen lang sein +minProperties = muss mindestens {0} Eigenschaften haben +minimum = muss einen Mindestwert von {0} haben +multipleOf = muss ein Vielfaches von {0} sein +not = darf für das Schema {0} nicht gültig sein +notAllowed = Eigenschaft ''{0}'' ist nicht zulässig, befindet sich aber in den Daten +oneOf = muss für ein und nur ein Schema gültig sein, aber {0} sind gültig +oneOf.indexes = muss für ein und nur ein Schema gültig sein, aber {0} sind mit den Indizes \u201E{1}\u201C gültig. +pattern = stimmt nicht mit dem Regex-Muster {0} überein +patternProperties = Es liegt ein Fehler mit den \u201EMustereigenschaften\u201C vor. +prefixItems = Bei diesem Index wurde kein Validator gefunden +properties = Es liegt ein Fehler mit \u201EProperties\u201C vor. +propertyNames = Der Name der Eigenschaft \u201E{0}\u201C ist ungültig: {1} +readOnly = ist ein schreibgeschütztes Feld, es kann nicht geändert werden +required = erforderliche Eigenschaft ''{0}'' nicht gefunden +type = {0} gefunden, {1} erwartet +unevaluatedItems = Index ''{0}'' wird nicht ausgewertet und das Schema lässt keine nicht ausgewerteten Elemente zu +unevaluatedProperties = Eigenschaft ''{0}'' wird nicht ausgewertet und das Schema lässt keine nicht ausgewerteten Eigenschaften zu +unionType = {0} gefunden, {1} erwartet +uniqueItems = Das Array darf nur eindeutige Elemente enthalten +writeOnly = ist ein schreibgeschütztes Feld, es kann nicht in den Daten erscheinen +contentEncoding = stimmt nicht mit der Inhaltskodierung {0} überein +contentMediaType = ist kein Inhalt für mich diff --git a/src/main/resources/jsv-messages_es.properties b/src/main/resources/jsv-messages_es.properties index 44dbff7b5..f16d03c8a 100644 --- a/src/main/resources/jsv-messages_es.properties +++ b/src/main/resources/jsv-messages_es.properties @@ -1,70 +1,70 @@ -$ref = {0}: tiene un error con las 'referencias' -additionalItems = {0}: el \u00edndice ''{1}'' no est\u00e1 definido en el esquema y el esquema no permite elementos adicionales -additionalProperties = {0}: la propiedad ''{1}'' no est\u00e1 definida en el esquema y el esquema no permite propiedades adicionales -allOf = {0}: debe ser v\u00e1lido para todos los esquemas {1} -anyOf = {0}: debe ser v\u00e1lido para cualquiera de los esquemas {1} -const = {0}: debe ser el valor constante ''{1}'' -contains = {0}: no contiene un elemento que cumpla estas validaciones: {2} -contains.max = {0}: debe contener como m\u00e1ximo {1} elemento(s) que cumpla(n) estas validaciones: {2} -contains.min = {0}: debe contener al menos {1} elemento(s) que cumpla(n) estas validaciones: {2} -dependencies = {0}: tiene un error con las dependencias {1} -dependentRequired = {0}: tiene una propiedad faltante ''{1}'' que es dependiente y requerida porque ''{2}'' est\u00e1 presente -dependentSchemas = {0}: tiene un error con dependentSchemas {1} -enum = {0}: no tiene un valor en la enumeraci\u00f3n {1} -exclusiveMaximum = {0}: debe tener un valor m\u00e1ximo exclusivo de {1} -exclusiveMinimum = {0}: debe tener un valor m\u00ednimo exclusivo de {1} -false = {0}: el esquema para ''{1}'' es falso -format = {0}: no coincide con el patr\u00f3n {1} {2} -format.date = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3339 con fecha completa v\u00e1lido -format.date-time = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3339 con fecha y hora v\u00e1lido -format.duration = {0}: no coincide con el patr\u00f3n {1}; debe ser un ISO 8601 de duraci\u00f3n v\u00e1lido -format.email = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 5321 de buz\u00f3n de correo v\u00e1lido -format.ipv4 = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 2673 de direcci\u00f3n IP v\u00e1lido -format.ipv6 = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 4291 de direcci\u00f3n IP v\u00e1lido -format.idn-email = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 6531 de buz\u00f3n de correo v\u00e1lido -format.idn-hostname = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 5890 de nombre de host internacionalizado v\u00e1lido -format.iri = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3987 de IRI v\u00e1lido -format.iri-reference = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3987 de referencia IRI v\u00e1lido -format.uri = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3986 de URI v\u00e1lido -format.uri-reference = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3986 de referencia URI v\u00e1lido -format.uri-template = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 6570 de plantilla de URI v\u00e1lido -format.uuid = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 4122 de UUID v\u00e1lido -format.regex = {0}: no coincide con el patr\u00f3n {1}; debe ser una expresi\u00f3n regular ECMA-262 v\u00e1lida -format.time = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 3339 con hora v\u00e1lido -format.hostname = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 1123 de nombre de host v\u00e1lido -format.json-pointer = {0}: no coincide con el patr\u00f3n {1}; debe ser un RFC 6901 de puntero JSON v\u00e1lido -format.relative-json-pointer = {0}: no coincide con el patr\u00f3n {1}; debe ser un IETF relativo de puntero JSON v\u00e1lido -format.unknown = {0}: tiene un formato desconocido ''{1}'' -id = {0}: ''{1}'' no es un v\u00e1lido {2} -items = {0}: el \u00edndice ''{1}'' no est\u00e1 definido en el esquema y el esquema no permite elementos adicionales -maxContains = {0}: debe ser un entero no negativo en {1} -maxItems = {0}: debe tener como m\u00e1ximo {1} elementos, pero se encontraron {2} -maxLength = {0}: debe tener como m\u00e1ximo {1} caracteres -maxProperties = {0}: debe tener como m\u00e1ximo {1} propiedades -maximum = {0}: debe tener un valor m\u00e1ximo de {1} -minContains = {0}: debe ser un entero no negativo en {1} -minContainsVsMaxContains = {0}: minContains debe ser menor o igual a maxContains en {1} -minItems = {0}: debe tener al menos {1} elementos, pero se encontraron {2} -minLength = {0}: debe tener al menos {1} caracteres -minProperties = {0}: debe tener al menos {1} propiedades -minimum = {0}: debe tener un valor m\u00ednimo de {1} -multipleOf = {0}: debe ser m\u00faltiplo de {1} -not = {0}: no debe ser v\u00e1lido para el esquema {1} -notAllowed = {0}: la propiedad ''{1}'' no est\u00e1 permitida, pero est\u00e1 en los datos -oneOf = {0}: debe ser v\u00e1lido para uno y solo un esquema, pero {1} son v\u00e1lidos -oneOf.indexes = {0}: debe ser v\u00e1lido para uno y solo un esquema, pero {1} son v\u00e1lidos con los \u00edndices ''{2}'' -pattern = {0}: no coincide con el patr\u00f3n regex {1} -patternProperties = {0}: tiene algunos errores con las 'propiedades del patr\u00f3n' -prefixItems = {0}: no se encuentra ning\u00fan elemento de validaci\u00f3n en este \u00edndice -properties = {0}: tiene un error con las 'propiedades' -propertyNames = {0}: el nombre ''{1}'' de la propiedad no es v\u00e1lido: {2} -readOnly = {0}: no puede cambiarse, ya que es un campo de solo lectura -required = {0}: no se encontr\u00f3 la propiedad requerida ''{1}'' -type = {0}: se encontraron {1}, se preve\u00edan {2} -unevaluatedItems = {0}: el \u00edndice ''{1}'' no est\u00e1 evaluado y el esquema no permite elementos que no hayan sido evaluados -unevaluatedProperties = {0}: la propiedad ''{1}'' no est\u00e1 evaluada y el esquema no permite propiedades que no hayan sido evaluadas -unionType = {0}: se encontraron {1}, se preve\u00edan {2} -uniqueItems = {0}: debe tener solo elementos \u00fanicos en la matriz -writeOnly = {0}: es un campo de solo lectura, no puede aparecer en los datos -contentEncoding = {0}: no coincide con la codificaci\u00f3n de contenido {1} -contentMediaType = {0}: no es un tipo de medios de contenido +$ref = tiene un error con las 'referencias' +additionalItems = el \u00edndice ''{0}'' no est\u00e1 definido en el esquema y el esquema no permite elementos adicionales +additionalProperties = la propiedad ''{0}'' no est\u00e1 definida en el esquema y el esquema no permite propiedades adicionales +allOf = debe ser v\u00e1lido para todos los esquemas {0} +anyOf = debe ser v\u00e1lido para cualquiera de los esquemas {0} +const = debe ser el valor constante ''{0}'' +contains = no contiene un elemento que cumpla estas validaciones: {1} +contains.max = debe contener como m\u00e1ximo {0} elemento(s) que cumpla(n) estas validaciones: {1} +contains.min = debe contener al menos {0} elemento(s) que cumpla(n) estas validaciones: {1} +dependencies = tiene un error con las dependencias {0} +dependentRequired = tiene una propiedad faltante ''{0}'' que es dependiente y requerida porque ''{1}'' est\u00e1 presente +dependentSchemas = tiene un error con dependentSchemas {0} +enum = no tiene un valor en la enumeraci\u00f3n {0} +exclusiveMaximum = debe tener un valor m\u00e1ximo exclusivo de {0} +exclusiveMinimum = debe tener un valor m\u00ednimo exclusivo de {0} +false = el esquema para ''{0}'' es falso +format = no coincide con el patr\u00f3n {0} {1} +format.date = no coincide con el patr\u00f3n {0}; debe ser un RFC 3339 con fecha completa v\u00e1lido +format.date-time = no coincide con el patr\u00f3n {0}; debe ser un RFC 3339 con fecha y hora v\u00e1lido +format.duration = no coincide con el patr\u00f3n {0}; debe ser un ISO 8601 de duraci\u00f3n v\u00e1lido +format.email = no coincide con el patr\u00f3n {0}; debe ser un RFC 5321 de buz\u00f3n de correo v\u00e1lido +format.ipv4 = no coincide con el patr\u00f3n {0}; debe ser un RFC 2673 de direcci\u00f3n IP v\u00e1lido +format.ipv6 = no coincide con el patr\u00f3n {0}; debe ser un RFC 4291 de direcci\u00f3n IP v\u00e1lido +format.idn-email = no coincide con el patr\u00f3n {0}; debe ser un RFC 6531 de buz\u00f3n de correo v\u00e1lido +format.idn-hostname = no coincide con el patr\u00f3n {0}; debe ser un RFC 5890 de nombre de host internacionalizado v\u00e1lido +format.iri = no coincide con el patr\u00f3n {0}; debe ser un RFC 3987 de IRI v\u00e1lido +format.iri-reference = no coincide con el patr\u00f3n {0}; debe ser un RFC 3987 de referencia IRI v\u00e1lido +format.uri = no coincide con el patr\u00f3n {0}; debe ser un RFC 3986 de URI v\u00e1lido +format.uri-reference = no coincide con el patr\u00f3n {0}; debe ser un RFC 3986 de referencia URI v\u00e1lido +format.uri-template = no coincide con el patr\u00f3n {0}; debe ser un RFC 6570 de plantilla de URI v\u00e1lido +format.uuid = no coincide con el patr\u00f3n {0}; debe ser un RFC 4122 de UUID v\u00e1lido +format.regex = no coincide con el patr\u00f3n {0}; debe ser una expresi\u00f3n regular ECMA-262 v\u00e1lida +format.time = no coincide con el patr\u00f3n {0}; debe ser un RFC 3339 con hora v\u00e1lido +format.hostname = no coincide con el patr\u00f3n {0}; debe ser un RFC 1123 de nombre de host v\u00e1lido +format.json-pointer = no coincide con el patr\u00f3n {0}; debe ser un RFC 6901 de puntero JSON v\u00e1lido +format.relative-json-pointer = no coincide con el patr\u00f3n {0}; debe ser un IETF relativo de puntero JSON v\u00e1lido +format.unknown = tiene un formato desconocido ''{0}'' +id = ''{0}'' no es un v\u00e1lido {1} +items = el \u00edndice ''{0}'' no est\u00e1 definido en el esquema y el esquema no permite elementos adicionales +maxContains = debe ser un entero no negativo en {0} +maxItems = debe tener como m\u00e1ximo {0} elementos, pero se encontraron {1} +maxLength = debe tener como m\u00e1ximo {0} caracteres +maxProperties = debe tener como m\u00e1ximo {0} propiedades +maximum = debe tener un valor m\u00e1ximo de {0} +minContains = debe ser un entero no negativo en {0} +minContainsVsMaxContains = minContains debe ser menor o igual a maxContains en {0} +minItems = debe tener al menos {0} elementos, pero se encontraron {1} +minLength = debe tener al menos {0} caracteres +minProperties = debe tener al menos {0} propiedades +minimum = debe tener un valor m\u00ednimo de {0} +multipleOf = debe ser m\u00faltiplo de {0} +not = no debe ser v\u00e1lido para el esquema {0} +notAllowed = la propiedad ''{0}'' no est\u00e1 permitida, pero est\u00e1 en los datos +oneOf = debe ser v\u00e1lido para uno y solo un esquema, pero {0} son v\u00e1lidos +oneOf.indexes = debe ser v\u00e1lido para uno y solo un esquema, pero {0} son v\u00e1lidos con los \u00edndices ''{1}'' +pattern = no coincide con el patr\u00f3n regex {0} +patternProperties = tiene algunos errores con las 'propiedades del patr\u00f3n' +prefixItems = no se encuentra ning\u00fan elemento de validaci\u00f3n en este \u00edndice +properties = tiene un error con las 'propiedades' +propertyNames = el nombre ''{0}'' de la propiedad no es v\u00e1lido: {1} +readOnly = no puede cambiarse, ya que es un campo de solo lectura +required = no se encontr\u00f3 la propiedad requerida ''{0}'' +type = se encontraron {0}, se preve\u00edan {1} +unevaluatedItems = el \u00edndice ''{0}'' no est\u00e1 evaluado y el esquema no permite elementos que no hayan sido evaluados +unevaluatedProperties = la propiedad ''{0}'' no est\u00e1 evaluada y el esquema no permite propiedades que no hayan sido evaluadas +unionType = se encontraron {0}, se preve\u00edan {1} +uniqueItems = debe tener solo elementos \u00fanicos en la matriz +writeOnly = es un campo de solo lectura, no puede aparecer en los datos +contentEncoding = no coincide con la codificaci\u00f3n de contenido {0} +contentMediaType = no es un tipo de medios de contenido diff --git a/src/main/resources/jsv-messages_fa.properties b/src/main/resources/jsv-messages_fa.properties index d8a1ff726..bc337be39 100644 --- a/src/main/resources/jsv-messages_fa.properties +++ b/src/main/resources/jsv-messages_fa.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u062F\u0627\u0631\u0627\u06CC \u062E\u0637\u0627 \u0628\u0627 "refs" \u0627\u0633\u062A -additionalItems = {0}: \u0646\u0645\u0627\u06CC\u0647 ''{1}'' \u062F\u0631 \u0627\u06CC\u0646 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0637\u0631\u062D \u0645\u0648\u0627\u0631\u062F \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC\u200C\u062F\u0627\u0646\u062F -additionalProperties = {0}: \u062E\u0627\u0635\u06CC\u062A ''{1}'' \u062F\u0631 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0627\u06CC\u0646 \u0637\u0631\u062D \u0648\u06CC\u0698\u06AF\u06CC \u0647\u0627\u06CC \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0627\u062C\u0627\u0632\u0647 \u0646\u0645\u06CC \u062F\u0647\u062F -allOf = {0}: \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0647\u0645\u0647 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0647\u0627 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {1} -anyOf = {0}: \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0647\u0631 \u06CC\u06A9 \u0627\u0632 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0647\u0627 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {1} -const = {0}: \u0628\u0627\u06CC\u062F \u0645\u0642\u062F\u0627\u0631 \u062B\u0627\u0628\u062A "{1}" \u0628\u0627\u0634\u062F -contains = {0}: \u062D\u0627\u0648\u06CC \u0639\u0646\u0635\u0631\u06CC \u0646\u06CC\u0633\u062A \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u067E\u0627\u0633 \u06A9\u0646\u062F: {2} -contains.max = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u062D\u0627\u0648\u06CC {1} \u0639\u0646\u0635\u0631 (\u0647\u0627) \u0628\u0627\u0634\u062F \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u067E\u0627\u0633 \u0645\u06CC \u06A9\u0646\u062F: {2} -contains.min = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0634\u0627\u0645\u0644 {1} \u0639\u0646\u0635\u0631 (\u0647\u0627) \u0628\u0627\u0634\u062F \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u0628\u06AF\u0630\u0631\u0627\u0646\u062F: {2} -dependencies = {0}: \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u062E\u0637\u0627 \u062F\u0631 \u0648\u0627\u0628\u0633\u062A\u06AF\u06CC {1} -dependentRequired = {0}: \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u0648\u06CC\u0698\u06AF\u06CC \u06AF\u0645 \u0634\u062F\u0647 "{1}" \u0627\u0633\u062A \u06A9\u0647 \u0628\u0647 \u062F\u0644\u06CC\u0644 \u0648\u062C\u0648\u062F "{2}" \u0648\u0627\u0628\u0633\u062A\u0647 \u0627\u0633\u062A -dependentSchemas = {0}: \u062F\u0627\u0631\u0627\u06CC \u062E\u0637\u0627 \u0628\u0627 dependentSchemas {1} -enum = {0}: \u0645\u0642\u062F\u0627\u0631\u06CC \u062F\u0631 \u0634\u0645\u0627\u0631\u0634 {1} \u0646\u062F\u0627\u0631\u062F -exclusiveMaximum = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {1} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -exclusiveMinimum = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {1} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -false = {0}: \u0637\u0631\u062D\u0648\u0627\u0631\u0647 ''{1}'' \u0646\u0627\u062F\u0631\u0633\u062A \u0627\u0633\u062A -format = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} {2} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F -format.date = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u06A9\u0627\u0645\u0644 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.date-time = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.duration = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0645\u062F\u062A \u0632\u0645\u0627\u0646 ISO 8601 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.email = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0635\u0646\u062F\u0648\u0642 \u067E\u0633\u062A\u06CC RFC 5321 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.ipv4 = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0622\u062F\u0631\u0633 IP \u0645\u0639\u062A\u0628\u0631 RFC 2673 \u0628\u0627\u0634\u062F -format.ipv6 = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0622\u062F\u0631\u0633 IP \u0645\u0639\u062A\u0628\u0631 RFC 4291 \u0628\u0627\u0634\u062F -format.idn-email = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0635\u0646\u062F\u0648\u0642 \u067E\u0633\u062A\u06CC RFC 6531 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.idn-hostname = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0627\u0645 \u0645\u06CC\u0632\u0628\u0627\u0646 \u0628\u06CC\u0646 \u0627\u0644\u0645\u0644\u0644\u06CC \u0634\u062F\u0647 \u0645\u0639\u062A\u0628\u0631 RFC 5890 \u0628\u0627\u0634\u062F. -format.iri = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 RFC 3987 IRI \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.iri-reference = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0645\u0631\u062C\u0639 \u0645\u0639\u062A\u0628\u0631 RFC 3987 IRI \u0628\u0627\u0634\u062F -format.uri = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 URI RFC 3986 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.uri-reference = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0645\u0631\u062C\u0639 URI RFC 3986 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.uri-template = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0627\u0644\u06AF\u0648\u06CC URI RFC 6570 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.uuid = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 UUID RFC 4122 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.regex = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u0628\u0627\u0631\u062A \u0645\u0646\u0638\u0645 ECMA-262 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.time = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0632\u0645\u0627\u0646 \u0645\u0639\u062A\u0628\u0631 RFC 3339 \u0628\u0627\u0634\u062F -format.hostname = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0627\u0645 \u0645\u06CC\u0632\u0628\u0627\u0646 \u0645\u0639\u062A\u0628\u0631 RFC 1123 \u0628\u0627\u0634\u062F -format.json-pointer = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F RFC 6901 JSON Pointer \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.relative-json-pointer = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0634\u0627\u0646\u06AF\u0631 JSON \u0646\u0633\u0628\u06CC IETF \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F -format.unknown = {0}: \u062F\u0627\u0631\u0627\u06CC \u0642\u0627\u0644\u0628 \u0646\u0627\u0634\u0646\u0627\u062E\u062A\u0647 ''{1}'' -id = {0}: "{1}" \u06CC\u06A9 {2} \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A -items = {0}: \u0646\u0645\u0627\u06CC\u0647 ''{1}'' \u062F\u0631 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0637\u0631\u062D \u0645\u0648\u0627\u0631\u062F \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC \u06A9\u0646\u062F -maxContains = {0}: \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u063A\u06CC\u0631 \u0645\u0646\u0641\u06CC \u062F\u0631 {1} \u0628\u0627\u0634\u062F -maxItems = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {1} \u0645\u0648\u0631\u062F \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F \u0627\u0645\u0627 {2} \u06CC\u0627\u0641\u062A \u0634\u0648\u062F -maxLength = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {1} \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631 \u0628\u0627\u0634\u062F -maxProperties = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {1} \u0648\u06CC\u0698\u06AF\u06CC \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -maximum = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u0645\u0642\u062F\u0627\u0631 {1} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -minContains = {0}: \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u063A\u06CC\u0631 \u0645\u0646\u0641\u06CC \u062F\u0631 {1} \u0628\u0627\u0634\u062F -minContainsVsMaxContains = {0}: minContains \u0628\u0627\u06CC\u062F \u06A9\u0645\u062A\u0631 \u06CC\u0627 \u0645\u0633\u0627\u0648\u06CC maxContains \u062F\u0631 {1} -minItems = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {1} \u0645\u0648\u0631\u062F \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F \u0627\u0645\u0627 {2} \u067E\u06CC\u062F\u0627 \u0634\u062F\u0647 \u0628\u0627\u0634\u062F -minLength = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {1} \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631 \u0628\u0627\u0634\u062F -minProperties = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {1} \u0648\u06CC\u0698\u06AF\u06CC \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -minimum = {0}: \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0645\u0642\u062F\u0627\u0631 {1} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -multipleOf = {0}: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 {1} \u0628\u0627\u0634\u062F -not = {0}: \u0646\u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {1} -notAllowed = {0}: \u0648\u06CC\u0698\u06AF\u06CC "{1}" \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A \u0627\u0645\u0627 \u062F\u0631 \u062F\u0627\u062F\u0647 \u0647\u0627 \u0648\u062C\u0648\u062F \u062F\u0627\u0631\u062F -oneOf = {0}: \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u06CC\u06A9 \u0648 \u062A\u0646\u0647\u0627 \u06CC\u06A9 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F\u060C \u0627\u0645\u0627 {1} \u0645\u0639\u062A\u0628\u0631 \u0647\u0633\u062A\u0646\u062F -oneOf.indexes = {0}: \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u06CC\u06A9 \u0648 \u062A\u0646\u0647\u0627 \u06CC\u06A9 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F\u060C \u0627\u0645\u0627 {1} \u0628\u0627 \u0646\u0645\u0627\u06CC\u0647 \u0647\u0627\u06CC ''{2}'' \u0645\u0639\u062A\u0628\u0631 \u0647\u0633\u062A\u0646\u062F -pattern = {0}: \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC regex \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F {1} -patternProperties = {0}: \u062F\u0627\u0631\u0627\u06CC \u0645\u0642\u062F\u0627\u0631\u06CC \u062E\u0637\u0627 \u0628\u0627 "\u062E\u0648\u0627\u0635 \u0627\u0644\u06AF\u0648" \u0627\u0633\u062A -prefixItems = {0}: \u0647\u06CC\u0686 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u062F\u0631 \u0627\u06CC\u0646 \u0641\u0647\u0631\u0633\u062A \u06CC\u0627\u0641\u062A \u0646\u0634\u062F -properties = {0}: \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u062E\u0637\u0627 \u0628\u0627 "properties" \u0627\u0633\u062A -propertyNames = {0}: \u0646\u0627\u0645 \u0648\u06CC\u0698\u06AF\u06CC ''{1}'' \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A: {2} -readOnly = {0}: \u06CC\u06A9 \u0641\u06CC\u0644\u062F \u0641\u0642\u0637 \u062E\u0648\u0627\u0646\u062F\u0646\u06CC \u0627\u0633\u062A\u060C \u0646\u0645\u06CC \u062A\u0648\u0627\u0646 \u0622\u0646 \u0631\u0627 \u062A\u063A\u06CC\u06CC\u0631 \u062F\u0627\u062F -required = {0}: \u0648\u06CC\u0698\u06AF\u06CC \u0645\u0648\u0631\u062F \u0646\u06CC\u0627\u0632 ''{1}'' \u06CC\u0627\u0641\u062A \u0646\u0634\u062F -type = {0}: {1} \u06CC\u0627\u0641\u062A \u0634\u062F\u060C {2} \u0645\u0648\u0631\u062F \u0627\u0646\u062A\u0638\u0627\u0631 \u0628\u0648\u062F -unevaluatedItems = {0}: \u0646\u0645\u0627\u06CC\u0647 ''{1}'' \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0645\u06CC \u0634\u0648\u062F \u0648 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0648\u0627\u0631\u062F \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0634\u062F\u0647 \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC \u062F\u0627\u0646\u062F -unevaluatedProperties = {0}: \u0648\u06CC\u0698\u06AF\u06CC ''{1}'' \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0645\u06CC \u0634\u0648\u062F \u0648 \u0627\u06CC\u0646 \u0637\u0631\u062D \u0648\u06CC\u0698\u06AF\u06CC \u0647\u0627\u06CC \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0634\u062F\u0647 \u0631\u0627 \u0627\u062C\u0627\u0632\u0647 \u0646\u0645\u06CC \u062F\u0647\u062F -unionType = {0}: {1} \u06CC\u0627\u0641\u062A \u0634\u062F\u060C {2} \u0645\u0648\u0631\u062F \u0627\u0646\u062A\u0638\u0627\u0631 \u0628\u0648\u062F -uniqueItems = {0}: \u0628\u0627\u06CC\u062F \u0641\u0642\u0637 \u0645\u0648\u0627\u0631\u062F \u0645\u0646\u062D\u0635\u0631 \u0628\u0647 \u0641\u0631\u062F \u062F\u0631 \u0622\u0631\u0627\u06CC\u0647 \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F -writeOnly = {0}: \u06CC\u06A9 \u0641\u06CC\u0644\u062F \u0641\u0642\u0637 \u0646\u0648\u0634\u062A\u0646\u06CC \u0627\u0633\u062A\u060C \u0646\u0645\u06CC \u062A\u0648\u0627\u0646\u062F \u062F\u0631 \u062F\u0627\u062F\u0647 \u0647\u0627 \u0638\u0627\u0647\u0631 \u0634\u0648\u062F -contentEncoding = {0}: \u0628\u0627 \u06A9\u062F\u06AF\u0630\u0627\u0631\u06CC \u0645\u062D\u062A\u0648\u0627 \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F {1} -contentMediaType = {0}: \u06CC\u06A9 \u0645\u062D\u062A\u0648\u0627\u06CC \u0645\u0646 \u0646\u06CC\u0633\u062A +$ref = \u062F\u0627\u0631\u0627\u06CC \u062E\u0637\u0627 \u0628\u0627 "refs" \u0627\u0633\u062A +additionalItems = \u0646\u0645\u0627\u06CC\u0647 ''{0}'' \u062F\u0631 \u0627\u06CC\u0646 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0637\u0631\u062D \u0645\u0648\u0627\u0631\u062F \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC\u200C\u062F\u0627\u0646\u062F +additionalProperties = \u062E\u0627\u0635\u06CC\u062A ''{0}'' \u062F\u0631 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0627\u06CC\u0646 \u0637\u0631\u062D \u0648\u06CC\u0698\u06AF\u06CC \u0647\u0627\u06CC \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0627\u062C\u0627\u0632\u0647 \u0646\u0645\u06CC \u062F\u0647\u062F +allOf = \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0647\u0645\u0647 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0647\u0627 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {0} +anyOf = \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0647\u0631 \u06CC\u06A9 \u0627\u0632 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0647\u0627 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {0} +const = \u0628\u0627\u06CC\u062F \u0645\u0642\u062F\u0627\u0631 \u062B\u0627\u0628\u062A "{0}" \u0628\u0627\u0634\u062F +contains = \u062D\u0627\u0648\u06CC \u0639\u0646\u0635\u0631\u06CC \u0646\u06CC\u0633\u062A \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u067E\u0627\u0633 \u06A9\u0646\u062F: {1} +contains.max = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u062D\u0627\u0648\u06CC {0} \u0639\u0646\u0635\u0631 (\u0647\u0627) \u0628\u0627\u0634\u062F \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u067E\u0627\u0633 \u0645\u06CC \u06A9\u0646\u062F: {1} +contains.min = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0634\u0627\u0645\u0644 {0} \u0639\u0646\u0635\u0631 (\u0647\u0627) \u0628\u0627\u0634\u062F \u06A9\u0647 \u0627\u06CC\u0646 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u0647\u0627 \u0631\u0627 \u0628\u06AF\u0630\u0631\u0627\u0646\u062F: {1} +dependencies = \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u062E\u0637\u0627 \u062F\u0631 \u0648\u0627\u0628\u0633\u062A\u06AF\u06CC {0} +dependentRequired = \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u0648\u06CC\u0698\u06AF\u06CC \u06AF\u0645 \u0634\u062F\u0647 "{0}" \u0627\u0633\u062A \u06A9\u0647 \u0628\u0647 \u062F\u0644\u06CC\u0644 \u0648\u062C\u0648\u062F "{1}" \u0648\u0627\u0628\u0633\u062A\u0647 \u0627\u0633\u062A +dependentSchemas = \u062F\u0627\u0631\u0627\u06CC \u062E\u0637\u0627 \u0628\u0627 dependentSchemas {0} +enum = \u0645\u0642\u062F\u0627\u0631\u06CC \u062F\u0631 \u0634\u0645\u0627\u0631\u0634 {0} \u0646\u062F\u0627\u0631\u062F +exclusiveMaximum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +exclusiveMinimum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +false = \u0637\u0631\u062D\u0648\u0627\u0631\u0647 ''{0}'' \u0646\u0627\u062F\u0631\u0633\u062A \u0627\u0633\u062A +format = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F +format.date = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u06A9\u0627\u0645\u0644 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.date-time = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.duration = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0645\u062F\u062A \u0632\u0645\u0627\u0646 ISO 8601 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.email = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0635\u0646\u062F\u0648\u0642 \u067E\u0633\u062A\u06CC RFC 5321 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.ipv4 = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0622\u062F\u0631\u0633 IP \u0645\u0639\u062A\u0628\u0631 RFC 2673 \u0628\u0627\u0634\u062F +format.ipv6 = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0622\u062F\u0631\u0633 IP \u0645\u0639\u062A\u0628\u0631 RFC 4291 \u0628\u0627\u0634\u062F +format.idn-email = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0635\u0646\u062F\u0648\u0642 \u067E\u0633\u062A\u06CC RFC 6531 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.idn-hostname = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0627\u0645 \u0645\u06CC\u0632\u0628\u0627\u0646 \u0628\u06CC\u0646 \u0627\u0644\u0645\u0644\u0644\u06CC \u0634\u062F\u0647 \u0645\u0639\u062A\u0628\u0631 RFC 5890 \u0628\u0627\u0634\u062F. +format.iri = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 RFC 3987 IRI \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.iri-reference = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0645\u0631\u062C\u0639 \u0645\u0639\u062A\u0628\u0631 RFC 3987 IRI \u0628\u0627\u0634\u062F +format.uri = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 URI RFC 3986 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.uri-reference = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0645\u0631\u062C\u0639 URI RFC 3986 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.uri-template = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0627\u0644\u06AF\u0648\u06CC URI RFC 6570 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.uuid = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 UUID RFC 4122 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.regex = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u0628\u0627\u0631\u062A \u0645\u0646\u0638\u0645 ECMA-262 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.time = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0632\u0645\u0627\u0646 \u0645\u0639\u062A\u0628\u0631 RFC 3339 \u0628\u0627\u0634\u062F +format.hostname = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0627\u0645 \u0645\u06CC\u0632\u0628\u0627\u0646 \u0645\u0639\u062A\u0628\u0631 RFC 1123 \u0628\u0627\u0634\u062F +format.json-pointer = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F RFC 6901 JSON Pointer \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.relative-json-pointer = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0646\u0634\u0627\u0646\u06AF\u0631 JSON \u0646\u0633\u0628\u06CC IETF \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F +format.unknown = \u062F\u0627\u0631\u0627\u06CC \u0642\u0627\u0644\u0628 \u0646\u0627\u0634\u0646\u0627\u062E\u062A\u0647 ''{0}'' +id = "{0}" \u06CC\u06A9 {1} \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A +items = \u0646\u0645\u0627\u06CC\u0647 ''{0}'' \u062F\u0631 \u0637\u0631\u062D \u062A\u0639\u0631\u06CC\u0641 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A \u0648 \u0637\u0631\u062D \u0645\u0648\u0627\u0631\u062F \u0627\u0636\u0627\u0641\u06CC \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC \u06A9\u0646\u062F +maxContains = \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u063A\u06CC\u0631 \u0645\u0646\u0641\u06CC \u062F\u0631 {0} \u0628\u0627\u0634\u062F +maxItems = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {0} \u0645\u0648\u0631\u062F \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F \u0627\u0645\u0627 {1} \u06CC\u0627\u0641\u062A \u0634\u0648\u062F +maxLength = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {0} \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631 \u0628\u0627\u0634\u062F +maxProperties = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 {0} \u0648\u06CC\u0698\u06AF\u06CC \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +maximum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u0645\u0642\u062F\u0627\u0631 {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +minContains = \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u063A\u06CC\u0631 \u0645\u0646\u0641\u06CC \u062F\u0631 {0} \u0628\u0627\u0634\u062F +minContainsVsMaxContains = minContains \u0628\u0627\u06CC\u062F \u06A9\u0645\u062A\u0631 \u06CC\u0627 \u0645\u0633\u0627\u0648\u06CC maxContains \u062F\u0631 {0} +minItems = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {0} \u0645\u0648\u0631\u062F \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F \u0627\u0645\u0627 {1} \u067E\u06CC\u062F\u0627 \u0634\u062F\u0647 \u0628\u0627\u0634\u062F +minLength = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {0} \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631 \u0628\u0627\u0634\u062F +minProperties = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 {0} \u0648\u06CC\u0698\u06AF\u06CC \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +minimum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0645\u0642\u062F\u0627\u0631 {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +multipleOf = \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 {0} \u0628\u0627\u0634\u062F +not = \u0646\u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F {0} +notAllowed = \u0648\u06CC\u0698\u06AF\u06CC "{0}" \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A \u0627\u0645\u0627 \u062F\u0631 \u062F\u0627\u062F\u0647 \u0647\u0627 \u0648\u062C\u0648\u062F \u062F\u0627\u0631\u062F +oneOf = \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u06CC\u06A9 \u0648 \u062A\u0646\u0647\u0627 \u06CC\u06A9 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F\u060C \u0627\u0645\u0627 {0} \u0645\u0639\u062A\u0628\u0631 \u0647\u0633\u062A\u0646\u062F +oneOf.indexes = \u0628\u0627\u06CC\u062F \u0628\u0631\u0627\u06CC \u06CC\u06A9 \u0648 \u062A\u0646\u0647\u0627 \u06CC\u06A9 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F\u060C \u0627\u0645\u0627 {0} \u0628\u0627 \u0646\u0645\u0627\u06CC\u0647 \u0647\u0627\u06CC ''{1}'' \u0645\u0639\u062A\u0628\u0631 \u0647\u0633\u062A\u0646\u062F +pattern = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC regex \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F {0} +patternProperties = \u062F\u0627\u0631\u0627\u06CC \u0645\u0642\u062F\u0627\u0631\u06CC \u062E\u0637\u0627 \u0628\u0627 "\u062E\u0648\u0627\u0635 \u0627\u0644\u06AF\u0648" \u0627\u0633\u062A +prefixItems = \u0647\u06CC\u0686 \u0627\u0639\u062A\u0628\u0627\u0631\u0633\u0646\u062C\u06CC \u062F\u0631 \u0627\u06CC\u0646 \u0641\u0647\u0631\u0633\u062A \u06CC\u0627\u0641\u062A \u0646\u0634\u062F +properties = \u062F\u0627\u0631\u0627\u06CC \u06CC\u06A9 \u062E\u0637\u0627 \u0628\u0627 "properties" \u0627\u0633\u062A +propertyNames = \u0646\u0627\u0645 \u0648\u06CC\u0698\u06AF\u06CC ''{0}'' \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A: {1} +readOnly = \u06CC\u06A9 \u0641\u06CC\u0644\u062F \u0641\u0642\u0637 \u062E\u0648\u0627\u0646\u062F\u0646\u06CC \u0627\u0633\u062A\u060C \u0646\u0645\u06CC \u062A\u0648\u0627\u0646 \u0622\u0646 \u0631\u0627 \u062A\u063A\u06CC\u06CC\u0631 \u062F\u0627\u062F +required = \u0648\u06CC\u0698\u06AF\u06CC \u0645\u0648\u0631\u062F \u0646\u06CC\u0627\u0632 ''{0}'' \u06CC\u0627\u0641\u062A \u0646\u0634\u062F +type = {0} \u06CC\u0627\u0641\u062A \u0634\u062F\u060C {1} \u0645\u0648\u0631\u062F \u0627\u0646\u062A\u0638\u0627\u0631 \u0628\u0648\u062F +unevaluatedItems = \u0646\u0645\u0627\u06CC\u0647 ''{0}'' \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0645\u06CC \u0634\u0648\u062F \u0648 \u0637\u0631\u062D\u0648\u0627\u0631\u0647 \u0645\u0648\u0627\u0631\u062F \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0634\u062F\u0647 \u0631\u0627 \u0645\u062C\u0627\u0632 \u0646\u0645\u06CC \u062F\u0627\u0646\u062F +unevaluatedProperties = \u0648\u06CC\u0698\u06AF\u06CC ''{0}'' \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0645\u06CC \u0634\u0648\u062F \u0648 \u0627\u06CC\u0646 \u0637\u0631\u062D \u0648\u06CC\u0698\u06AF\u06CC \u0647\u0627\u06CC \u0627\u0631\u0632\u06CC\u0627\u0628\u06CC \u0646\u0634\u062F\u0647 \u0631\u0627 \u0627\u062C\u0627\u0632\u0647 \u0646\u0645\u06CC \u062F\u0647\u062F +unionType = {0} \u06CC\u0627\u0641\u062A \u0634\u062F\u060C {1} \u0645\u0648\u0631\u062F \u0627\u0646\u062A\u0638\u0627\u0631 \u0628\u0648\u062F +uniqueItems = \u0628\u0627\u06CC\u062F \u0641\u0642\u0637 \u0645\u0648\u0627\u0631\u062F \u0645\u0646\u062D\u0635\u0631 \u0628\u0647 \u0641\u0631\u062F \u062F\u0631 \u0622\u0631\u0627\u06CC\u0647 \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F +writeOnly = \u06CC\u06A9 \u0641\u06CC\u0644\u062F \u0641\u0642\u0637 \u0646\u0648\u0634\u062A\u0646\u06CC \u0627\u0633\u062A\u060C \u0646\u0645\u06CC \u062A\u0648\u0627\u0646\u062F \u062F\u0631 \u062F\u0627\u062F\u0647 \u0647\u0627 \u0638\u0627\u0647\u0631 \u0634\u0648\u062F +contentEncoding = \u0628\u0627 \u06A9\u062F\u06AF\u0630\u0627\u0631\u06CC \u0645\u062D\u062A\u0648\u0627 \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F {0} +contentMediaType = \u06CC\u06A9 \u0645\u062D\u062A\u0648\u0627\u06CC \u0645\u0646 \u0646\u06CC\u0633\u062A diff --git a/src/main/resources/jsv-messages_fi.properties b/src/main/resources/jsv-messages_fi.properties index a6498eb14..93ec79336 100644 --- a/src/main/resources/jsv-messages_fi.properties +++ b/src/main/resources/jsv-messages_fi.properties @@ -1,70 +1,70 @@ -$ref = {0}: siinä on virhe "viittauksilla" -additionalItems = {0}: hakemistoa ''{1}'' ei ole määritetty skeemassa, eikä skeema salli lisäkohteita -additionalProperties = {0}: ominaisuutta ''{1}'' ei ole määritetty skeemassa, eikä skeema salli lisäominaisuuksia -allOf = {0}: täytyy olla voimassa kaikissa malleissa {1} -anyOf = {0}: täytyy olla kelvollinen mille tahansa skeemalle {1} -const = {0}: on oltava vakioarvo ''{1}'' -contains = {0}: ei sisällä elementtiä, joka läpäisee seuraavat tarkistukset: {2} -contains.max = {0}: saa sisältää enintään {1} elementtiä, jotka läpäisevät nämä tarkistukset: {2} -contains.min = {0}: sisältää vähintään {1} elementtiä, jotka läpäisevät nämä tarkistukset: {2} -dependencies = {0}: siinä on virhe riippuvuuksien {1} kanssa -dependentRequired = {0}: puuttuu ominaisuus "{1}", joka on riippuvainen, koska "{2}" on läsnä -dependentSchemas = {0}: sisältää virheen dependentSchemasissa {1} -enum = {0}: sillä ei ole arvoa luettelossa {1} -exclusiveMaximum = {0}: eksklusiivisen enimmäisarvon on oltava {1} -exclusiveMinimum = {0}: on oltava yksinomainen vähimmäisarvo {1} -false = {0}: kaava kohteelle ''{1}'' on epätosi -format = {0}: ei vastaa mallia {1} {2} -format.date = {0}: ei vastaa mallia {1}, ja sen on oltava kelvollinen RFC 3339:n täysi päivämäärä -format.date-time = {0}: ei vastaa mallia {1}, ja sen on oltava kelvollinen RFC 3339 päivämäärä-aika -format.duration = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen ISO 8601 -kesto -format.email = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 5321 -postilaatikko -format.ipv4 = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 2673 IP-osoite -format.ipv6 = {0}: ei vastaa mallia {1}, ja sen on oltava kelvollinen RFC 4291 IP-osoite -format.idn-email = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 6531 -postilaatikko -format.idn-hostname = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 5890:n kansainvälistetty isäntänimi -format.iri = {0}: ei vastaa mallia {1}, ja sen on oltava kelvollinen RFC 3987 IRI -format.iri-reference = {0}: ei vastaa {1}-mallia, on oltava kelvollinen RFC 3987 IRI-viite -format.uri = {0}: ei vastaa mallia {1}, ja sen on oltava kelvollinen RFC 3986 URI -format.uri-reference = {0}: ei vastaa {1}-mallia, täytyy olla kelvollinen RFC 3986 URI-viite -format.uri-template = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 6570 URI-malli -format.uuid = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 4122 UUID -format.regex = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen ECMA-262-säännöllinen lauseke -format.time = {0}: ei vastaa mallia {1}, sen on oltava kelvollinen RFC 3339 -aika -format.hostname = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 1123 -isäntänimi -format.json-pointer = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen RFC 6901 JSON-osoitin -format.relative-json-pointer = {0}: ei vastaa mallia {1}. Sen on oltava kelvollinen IETF:n suhteellinen JSON-osoitin -format.unknown = {0}: sillä on tuntematon muoto ''{1}'' -id = {0}: ''{1}'' ei ole kelvollinen {2} -items = {0}: hakemistoa ''{1}'' ei ole määritetty skeemassa, eikä skeema salli lisäkohteita -maxContains = {0}: täytyy olla ei-negatiivinen kokonaisluku ryhmässä {1} -maxItems = {0}: saa olla enintään {1} kohdetta, mutta löytyi {2} -maxLength = {0}: saa olla enintään {1} merkkiä pitkä -maxProperties = {0}: saa olla enintään {1} ominaisuutta -maximum = {0}: maksimiarvon on oltava {1} -minContains = {0}: täytyy olla ei-negatiivinen kokonaisluku ryhmässä {1} -minContainsVsMaxContains = {0}: minContains on pienempi tai yhtä suuri kuin maxContains kohteessa {1} -minItems = {0}: on oltava vähintään {1} kohdetta, mutta löydetty {2} -minLength = {0}: on oltava vähintään {1} merkkiä pitkä -minProperties = {0}: on oltava vähintään {1} ominaisuutta -minimum = {0}: vähimmäisarvon on oltava {1} -multipleOf = {0}: täytyy olla {1}:n kerrannainen -not = {0}: ei saa olla kelvollinen kaavalle {1} -notAllowed = {0}: ominaisuus ''{1}'' ei ole sallittu, mutta se on tiedoissa -oneOf = {0}: täytyy olla voimassa vain yhdelle skeemalle, mutta {1} ovat kelvollisia -oneOf.indexes = {0}: täytyy olla voimassa vain yhdelle skeemalle, mutta {1} ovat kelvollisia indeksien ''{2}'' kanssa -pattern = {0}: ei vastaa säännöllisen lausekkeen mallia {1} -patternProperties = {0}: siinä on virhe komennolla "pattern properties" -prefixItems = {0}: tästä hakemistosta ei löytynyt vahvistusta -properties = {0}: sisältää virheen ominaisuuksissa -propertyNames = {0}: ominaisuuden ''{1}'' nimi ei kelpaa: {2} -readOnly = {0}: on vain luku -kenttä, sitä ei voi muuttaa -required = {0}: vaadittua ominaisuutta ''{1}'' ei löydy -type = {0}: {1} löydetty, {2} odotettu -unevaluatedItems = {0}: hakemistoa ''{1}'' ei arvioida, eikä skeema salli arvioimattomia kohteita -unevaluatedProperties = {0}: ominaisuutta ''{1}'' ei arvioida ja skeema ei salli arvioimattomia ominaisuuksia -unionType = {0}: {1} löydetty, {2} odotettu -uniqueItems = {0}: taulukossa saa olla vain yksilöllisiä kohteita -writeOnly = {0}: on vain kirjoituskenttä, se ei voi näkyä tiedoissa -contentEncoding = {0}: ei vastaa sisällön koodausta {1} -contentMediaType = {0}: ei ole sisältöni +$ref = siinä on virhe "viittauksilla" +additionalItems = hakemistoa ''{0}'' ei ole määritetty skeemassa, eikä skeema salli lisäkohteita +additionalProperties = ominaisuutta ''{0}'' ei ole määritetty skeemassa, eikä skeema salli lisäominaisuuksia +allOf = täytyy olla voimassa kaikissa malleissa {0} +anyOf = täytyy olla kelvollinen mille tahansa skeemalle {0} +const = on oltava vakioarvo ''{0}'' +contains = ei sisällä elementtiä, joka läpäisee seuraavat tarkistukset: {1} +contains.max = saa sisältää enintään {0} elementtiä, jotka läpäisevät nämä tarkistukset: {1} +contains.min = sisältää vähintään {0} elementtiä, jotka läpäisevät nämä tarkistukset: {1} +dependencies = siinä on virhe riippuvuuksien {0} kanssa +dependentRequired = puuttuu ominaisuus "{0}", joka on riippuvainen, koska "{1}" on läsnä +dependentSchemas = sisältää virheen dependentSchemasissa {0} +enum = sillä ei ole arvoa luettelossa {0} +exclusiveMaximum = eksklusiivisen enimmäisarvon on oltava {0} +exclusiveMinimum = on oltava yksinomainen vähimmäisarvo {0} +false = kaava kohteelle ''{0}'' on epätosi +format = ei vastaa mallia {0} {1} +format.date = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3339:n täysi päivämäärä +format.date-time = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3339 päivämäärä-aika +format.duration = ei vastaa mallia {0}. Sen on oltava kelvollinen ISO 8601 -kesto +format.email = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 5321 -postilaatikko +format.ipv4 = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 2673 IP-osoite +format.ipv6 = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 4291 IP-osoite +format.idn-email = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 6531 -postilaatikko +format.idn-hostname = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 5890:n kansainvälistetty isäntänimi +format.iri = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3987 IRI +format.iri-reference = ei vastaa {0}-mallia, on oltava kelvollinen RFC 3987 IRI-viite +format.uri = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3986 URI +format.uri-reference = ei vastaa {0}-mallia, täytyy olla kelvollinen RFC 3986 URI-viite +format.uri-template = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 6570 URI-malli +format.uuid = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 4122 UUID +format.regex = ei vastaa mallia {0}. Sen on oltava kelvollinen ECMA-262-säännöllinen lauseke +format.time = ei vastaa mallia {0}, sen on oltava kelvollinen RFC 3339 -aika +format.hostname = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 1123 -isäntänimi +format.json-pointer = ei vastaa mallia {0}. Sen on oltava kelvollinen RFC 6901 JSON-osoitin +format.relative-json-pointer = ei vastaa mallia {0}. Sen on oltava kelvollinen IETF:n suhteellinen JSON-osoitin +format.unknown = sillä on tuntematon muoto ''{0}'' +id = ''{0}'' ei ole kelvollinen {1} +items = hakemistoa ''{0}'' ei ole määritetty skeemassa, eikä skeema salli lisäkohteita +maxContains = täytyy olla ei-negatiivinen kokonaisluku ryhmässä {0} +maxItems = saa olla enintään {0} kohdetta, mutta löytyi {1} +maxLength = saa olla enintään {0} merkkiä pitkä +maxProperties = saa olla enintään {0} ominaisuutta +maximum = maksimiarvon on oltava {0} +minContains = täytyy olla ei-negatiivinen kokonaisluku ryhmässä {0} +minContainsVsMaxContains = minContains on pienempi tai yhtä suuri kuin maxContains kohteessa {0} +minItems = on oltava vähintään {0} kohdetta, mutta löydetty {1} +minLength = on oltava vähintään {0} merkkiä pitkä +minProperties = on oltava vähintään {0} ominaisuutta +minimum = vähimmäisarvon on oltava {0} +multipleOf = täytyy olla {0}:n kerrannainen +not = ei saa olla kelvollinen kaavalle {0} +notAllowed = ominaisuus ''{0}'' ei ole sallittu, mutta se on tiedoissa +oneOf = täytyy olla voimassa vain yhdelle skeemalle, mutta {0} ovat kelvollisia +oneOf.indexes = täytyy olla voimassa vain yhdelle skeemalle, mutta {0} ovat kelvollisia indeksien ''{1}'' kanssa +pattern = ei vastaa säännöllisen lausekkeen mallia {0} +patternProperties = siinä on virhe komennolla "pattern properties" +prefixItems = tästä hakemistosta ei löytynyt vahvistusta +properties = sisältää virheen ominaisuuksissa +propertyNames = ominaisuuden ''{0}'' nimi ei kelpaa: {1} +readOnly = on vain luku -kenttä, sitä ei voi muuttaa +required = vaadittua ominaisuutta ''{0}'' ei löydy +type = {0} löydetty, {1} odotettu +unevaluatedItems = hakemistoa ''{0}'' ei arvioida, eikä skeema salli arvioimattomia kohteita +unevaluatedProperties = ominaisuutta ''{0}'' ei arvioida ja skeema ei salli arvioimattomia ominaisuuksia +unionType = {0} löydetty, {1} odotettu +uniqueItems = taulukossa saa olla vain yksilöllisiä kohteita +writeOnly = on vain kirjoituskenttä, se ei voi näkyä tiedoissa +contentEncoding = ei vastaa sisällön koodausta {0} +contentMediaType = ei ole sisältöni diff --git a/src/main/resources/jsv-messages_fr.properties b/src/main/resources/jsv-messages_fr.properties index aff459ef4..f365b1e6f 100644 --- a/src/main/resources/jsv-messages_fr.properties +++ b/src/main/resources/jsv-messages_fr.properties @@ -1,70 +1,70 @@ -$ref = {0}: il y a une erreur avec ''refs'' -additionalItems = {0}: l''index ''{1}'' n''est pas défini dans le schéma et le schéma n''autorise pas les éléments supplémentaires -additionalProperties = {0}: la propriété ''{1}'' n''est pas définie dans le schéma et le schéma n''autorise pas de propriétés supplémentaires -allOf = {0}: doit être valide pour tous les schémas {1} -anyOf = {0}: doit être valide pour l''un des schémas {1} -const = {0}: doit être la valeur constante ''{1}'' -contains = {0}: ne contient aucun élément qui réussit ces validations : {2} -contains.max = {0}: doit contenir au plus {1} élément(s) qui réussissent ces validations : {2} -contains.min = {0}: doit contenir au moins {1} élément(s) qui réussissent ces validations : {2} -dependencies = {0}: il y a une erreur avec les dépendances {1} -dependentRequired = {0}: a une propriété manquante « {1} » qui est dépendante requise car « {2} » est présente -dependentSchemas = {0}: il y a une erreur avecdependentSchemas {1} -enum = {0}: n''a pas de valeur dans l''énumération {1} -exclusiveMaximum = {0}: doit avoir une valeur maximale exclusive de {1} -exclusiveMinimum = {0}: doit avoir une valeur minimale exclusive de {1} -false = {0}: le schéma de ''{1}'' est faux -format = {0}: ne correspond pas au modèle {1} {2} -format.date = {0}: ne correspond pas au modèle {1} doit être une date complète RFC 3339 valide -format.date-time = {0}: ne correspond pas au modèle {1} doit être une date-heure RFC 3339 valide -format.duration = {0}: ne correspond pas au modèle {1} doit être une durée ISO 8601 valide -format.email = {0}: ne correspond pas au modèle {1} doit être une boîte aux lettres RFC 5321 valide -format.ipv4 = {0}: ne correspond pas au modèle {1} doit être une adresse IP RFC 2673 valide -format.ipv6 = {0}: ne correspond pas au modèle {1} doit être une adresse IP RFC 4291 valide -format.idn-email = {0}: ne correspond pas au modèle {1} doit être une boîte aux lettres RFC 6531 valide -format.idn-hostname = {0}: ne correspond pas au modèle {1} doit être un nom d''hôte internationalisé RFC 5890 valide -format.iri = {0}: ne correspond pas au modèle {1} doit être un IRI RFC 3987 valide -format.iri-reference = {0}: ne correspond pas au modèle {1} doit être une référence IRI RFC 3987 valide -format.uri = {0}: ne correspond pas au modèle {1} doit être un URI RFC 3986 valide -format.uri-reference = {0}: ne correspond pas au modèle {1} doit être une référence URI RFC 3986 valide -format.uri-template = {0}: ne correspond pas au modèle {1} doit être un modèle d''URI RFC 6570 valide -format.uuid = {0}: ne correspond pas au modèle {1} doit être un UUID RFC 4122 valide -format.regex = {0}: ne correspond pas au modèle {1} doit être une expression régulière ECMA-262 valide -format.time = {0}: ne correspond pas au modèle {1} doit être une heure RFC 3339 valide -format.hostname = {0}: ne correspond pas au modèle {1} doit être un nom d''hôte RFC 1123 valide -format.json-pointer = {0}: ne correspond pas au modèle {1} doit être un pointeur JSON RFC 6901 valide -format.relative-json-pointer = {0}: ne correspond pas au modèle {1} doit être un pointeur JSON relatif IETF valide -format.unknown = {0}: a un format inconnu ''{1}'' -id = {0}: ''{1}'' n''est pas un {2} valide -items = {0}: l''index ''{1}'' n''est pas défini dans le schéma et le schéma n''autorise pas d''éléments supplémentaires -maxContains = {0}: doit être un entier non négatif dans {1} -maxItems = {0}: doit contenir au plus {1} éléments mais trouvé {2} -maxLength = {0}: doit contenir au plus {1} caractères -maxProperties = {0}: doit avoir au plus {1} propriétés -maximum = {0}: doit avoir une valeur maximale de {1} -minContains = {0}: doit être un entier non négatif dans {1} -minContainsVsMaxContains = {0}: minContains doit être inférieur ou égal à maxContains dans {1} -minItems = {0}: doit avoir au moins {1} éléments mais trouvé {2} -minLength = {0}: doit contenir au moins {1} caractères -minProperties = {0}: doit avoir au moins {1} propriétés -minimum = {0}: doit avoir une valeur minimale de {1} -multipleOf = {0}: doit être un multiple de {1} -not = {0}: ne doit pas être valide pour le schéma {1} -notAllowed = {0}: la propriété ''{1}'' n''est pas autorisée mais elle est dans les données -oneOf = {0}: doit être valide pour un et un seul schéma, mais {1} sont valides -oneOf.indexes = {0}: doit être valide pour un et un seul schéma, mais {1} sont valides avec les index ''{2}'' -pattern = {0}: ne correspond pas au modèle d''expression régulière {1} -patternProperties = {0}: il y a une erreur avec les « propriétés du modèle » -prefixItems = {0}: aucun validateur trouvé à cet index -properties = {0}: il y a une erreur avec « propriétés » -propertyNames = {0}: le nom de la propriété ''{1}'' n''est pas valide : {2} -readOnly = {0}: est un champ en lecture seule, il ne peut pas être modifié -required = {0}: propriété requise ''{1}'' introuvable -type = {0}: {1} trouvé, {2} attendu -unevaluatedItems = {0}: l''index ''{1}'' n''est pas évalué et le schéma n''autorise pas les éléments non évalués -unevaluatedProperties = {0}: la propriété ''{1}'' n''est pas évaluée et le schéma n''autorise pas les propriétés non évaluées -unionType = {0}: {1} trouvé, {2} attendu -uniqueItems = {0}: ne doit avoir que des éléments uniques dans le tableau -writeOnly = {0}: est un champ en écriture seule, il ne peut pas apparaître dans les données -contentEncoding = {0}: ne correspond pas à l''encodage du contenu {1} -contentMediaType = {0}: n''est pas un contenu moi +$ref = il y a une erreur avec ''refs'' +additionalItems = l''index ''{0}'' n''est pas défini dans le schéma et le schéma n''autorise pas les éléments supplémentaires +additionalProperties = la propriété ''{0}'' n''est pas définie dans le schéma et le schéma n''autorise pas de propriétés supplémentaires +allOf = doit être valide pour tous les schémas {0} +anyOf = doit être valide pour l''un des schémas {0} +const = doit être la valeur constante ''{0}'' +contains = ne contient aucun élément qui réussit ces validations : {1} +contains.max = doit contenir au plus {0} élément(s) qui réussissent ces validations : {1} +contains.min = doit contenir au moins {0} élément(s) qui réussissent ces validations : {1} +dependencies = il y a une erreur avec les dépendances {0} +dependentRequired = a une propriété manquante « {0} » qui est dépendante requise car « {1} » est présente +dependentSchemas = il y a une erreur avecdependentSchemas {0} +enum = n''a pas de valeur dans l''énumération {0} +exclusiveMaximum = doit avoir une valeur maximale exclusive de {0} +exclusiveMinimum = doit avoir une valeur minimale exclusive de {0} +false = le schéma de ''{0}'' est faux +format = ne correspond pas au modèle {0} {1} +format.date = ne correspond pas au modèle {0} doit être une date complète RFC 3339 valide +format.date-time = ne correspond pas au modèle {0} doit être une date-heure RFC 3339 valide +format.duration = ne correspond pas au modèle {0} doit être une durée ISO 8601 valide +format.email = ne correspond pas au modèle {0} doit être une boîte aux lettres RFC 5321 valide +format.ipv4 = ne correspond pas au modèle {0} doit être une adresse IP RFC 2673 valide +format.ipv6 = ne correspond pas au modèle {0} doit être une adresse IP RFC 4291 valide +format.idn-email = ne correspond pas au modèle {0} doit être une boîte aux lettres RFC 6531 valide +format.idn-hostname = ne correspond pas au modèle {0} doit être un nom d''hôte internationalisé RFC 5890 valide +format.iri = ne correspond pas au modèle {0} doit être un IRI RFC 3987 valide +format.iri-reference = ne correspond pas au modèle {0} doit être une référence IRI RFC 3987 valide +format.uri = ne correspond pas au modèle {0} doit être un URI RFC 3986 valide +format.uri-reference = ne correspond pas au modèle {0} doit être une référence URI RFC 3986 valide +format.uri-template = ne correspond pas au modèle {0} doit être un modèle d''URI RFC 6570 valide +format.uuid = ne correspond pas au modèle {0} doit être un UUID RFC 4122 valide +format.regex = ne correspond pas au modèle {0} doit être une expression régulière ECMA-262 valide +format.time = ne correspond pas au modèle {0} doit être une heure RFC 3339 valide +format.hostname = ne correspond pas au modèle {0} doit être un nom d''hôte RFC 1123 valide +format.json-pointer = ne correspond pas au modèle {0} doit être un pointeur JSON RFC 6901 valide +format.relative-json-pointer = ne correspond pas au modèle {0} doit être un pointeur JSON relatif IETF valide +format.unknown = a un format inconnu ''{0}'' +id = ''{0}'' n''est pas un {1} valide +items = l''index ''{0}'' n''est pas défini dans le schéma et le schéma n''autorise pas d''éléments supplémentaires +maxContains = doit être un entier non négatif dans {0} +maxItems = doit contenir au plus {0} éléments mais trouvé {1} +maxLength = doit contenir au plus {0} caractères +maxProperties = doit avoir au plus {0} propriétés +maximum = doit avoir une valeur maximale de {0} +minContains = doit être un entier non négatif dans {0} +minContainsVsMaxContains = minContains doit être inférieur ou égal à maxContains dans {0} +minItems = doit avoir au moins {0} éléments mais trouvé {1} +minLength = doit contenir au moins {0} caractères +minProperties = doit avoir au moins {0} propriétés +minimum = doit avoir une valeur minimale de {0} +multipleOf = doit être un multiple de {0} +not = ne doit pas être valide pour le schéma {0} +notAllowed = la propriété ''{0}'' n''est pas autorisée mais elle est dans les données +oneOf = doit être valide pour un et un seul schéma, mais {0} sont valides +oneOf.indexes = doit être valide pour un et un seul schéma, mais {0} sont valides avec les index ''{1}'' +pattern = ne correspond pas au modèle d''expression régulière {0} +patternProperties = il y a une erreur avec les « propriétés du modèle » +prefixItems = aucun validateur trouvé à cet index +properties = il y a une erreur avec « propriétés » +propertyNames = le nom de la propriété ''{0}'' n''est pas valide : {1} +readOnly = est un champ en lecture seule, il ne peut pas être modifié +required = propriété requise ''{0}'' introuvable +type = {0} trouvé, {1} attendu +unevaluatedItems = l''index ''{0}'' n''est pas évalué et le schéma n''autorise pas les éléments non évalués +unevaluatedProperties = la propriété ''{0}'' n''est pas évaluée et le schéma n''autorise pas les propriétés non évaluées +unionType = {0} trouvé, {1} attendu +uniqueItems = ne doit avoir que des éléments uniques dans le tableau +writeOnly = est un champ en écriture seule, il ne peut pas apparaître dans les données +contentEncoding = ne correspond pas à l''encodage du contenu {0} +contentMediaType = n''est pas un contenu moi diff --git a/src/main/resources/jsv-messages_he.properties b/src/main/resources/jsv-messages_he.properties index d33a29473..fab7ac4f2 100644 --- a/src/main/resources/jsv-messages_he.properties +++ b/src/main/resources/jsv-messages_he.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD ''refs'' -additionalItems = {0}: \u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD -additionalProperties = {0}: \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD -allOf = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05DB\u05DC \u05D4\u05E1\u05DB\u05DE\u05D5\u05EA {1} -anyOf = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05DB\u05DC \u05D0\u05D7\u05EA \u05DE\u05D4\u05E1\u05DB\u05D9\u05DE\u05D5\u05EA {1} -const = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E2\u05E8\u05DA \u05D4\u05E7\u05D1\u05D5\u05E2 ''{1}'' -contains = {0}: \u05D0\u05D9\u05E0\u05D5 \u05DE\u05DB\u05D9\u05DC \u05E8\u05DB\u05D9\u05D1 \u05E9\u05E2\u05D5\u05D1\u05E8 \u05D0\u05EA \u05D4\u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D4\u05D1\u05D0\u05D9\u05DD: {2} -contains.max = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05DB\u05D9\u05DC \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {1} \u05E8\u05DB\u05D9\u05D1\u05D9\u05DD \u05E9\u05E2\u05D5\u05D1\u05E8\u05D9\u05DD \u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D0\u05DC\u05D4: {2} -contains.min = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05DB\u05D9\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {1} \u05E8\u05DB\u05D9\u05D1\u05D9\u05DD \u05E9\u05E2\u05D5\u05D1\u05E8\u05D9\u05DD \u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D0\u05DC\u05D4: {2} -dependencies = {0}: \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD \u05EA\u05DC\u05D5\u05D9\u05D5\u05EA {1} -dependentRequired = {0}: \u05D7\u05E1\u05E8 \u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{1}'' \u05D0\u05E9\u05E8 \u05D3\u05E8\u05D5\u05E9 \u05EA\u05DC\u05D5\u05D9 \u05DB\u05D9 ''{2}'' \u05E7\u05D9\u05D9\u05DD -dependentSchemas = {0}: \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD dependentSchemas {1} -enum = {0}: \u05D0\u05D9\u05DF \u05E2\u05E8\u05DA \u05D1\u05E1\u05E4\u05D9\u05E8\u05D4 {1} -exclusiveMaximum = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05E7\u05E1\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {1} -exclusiveMinimum = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {1} -false = {0}: \u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05E2\u05D1\u05D5\u05E8 ''{1}'' \u05D4\u05D9\u05D0 \u05E9\u05E7\u05E8 -format = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} {2} -format.date = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D0\u05E8\u05D9\u05DA \u05DE\u05DC\u05D0 RFC 3339 \u05D7\u05D5\u05E7\u05D9 -format.date-time = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3339 \u05EA\u05D0\u05E8\u05D9\u05DA-\u05E9\u05E2\u05D4 \u05D7\u05D5\u05E7\u05D9 -format.duration = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E9\u05DA ISO 8601 \u05D7\u05D5\u05E7\u05D9 -format.email = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D9\u05D1\u05EA \u05D3\u05D5\u05D0\u05E8 RFC 5321 \u05D7\u05D5\u05E7\u05D9\u05EA -format.ipv4 = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05EA\u05D5\u05D1\u05EA IP \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 2673 -format.ipv6 = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05EA\u05D5\u05D1\u05EA IP \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 4291 -format.idn-email = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05D3\u05E4\u05D5\u05E1 {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D9\u05D1\u05EA \u05D3\u05D5\u05D0\u05E8 RFC 6531 \u05D7\u05D5\u05E7\u05D9\u05EA -format.idn-hostname = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E9\u05DD \u05DE\u05D0\u05E8\u05D7 \u05D7\u05D5\u05E7\u05D9 RFC 5890 \u05D1\u05D9\u05E0\u05DC\u05D0\u05D5\u05DE\u05D9 -format.iri = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3987 IRI \u05D7\u05D5\u05E7\u05D9 -format.iri-reference = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E4\u05E0\u05D9\u05D4 \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 3987 IRI -format.uri = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3986 URI \u05D7\u05D5\u05E7\u05D9 -format.uri-reference = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E4\u05E0\u05D9\u05D4 \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 3986 URI -format.uri-template = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D1\u05E0\u05D9\u05EA URI \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 6570 -format.uuid = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 4122 UUID \u05D7\u05D5\u05E7\u05D9 -format.regex = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D9\u05D8\u05D5\u05D9 \u05E8\u05D2\u05D5\u05DC\u05E8\u05D9 \u05D7\u05D5\u05E7\u05D9 ECMA-262 -format.time = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D6\u05DE\u05DF RFC 3339 \u05D7\u05D5\u05E7\u05D9 -format.hostname = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E9\u05DD \u05DE\u05D0\u05E8\u05D7 RFC 1123 \u05D7\u05D5\u05E7\u05D9 -format.json-pointer = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E6\u05D1\u05D9\u05E2 RFC 6901 JSON \u05D7\u05D5\u05E7\u05D9 -format.relative-json-pointer = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {1} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E6\u05D1\u05D9\u05E2 JSON \u05D9\u05D7\u05E1\u05D9 \u05E9\u05DC IETF \u05D7\u05D5\u05E7\u05D9 -format.unknown = {0}: \u05D9\u05E9 \u05E4\u05D5\u05E8\u05DE\u05D8 \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2 ''{1}'' -id = {0}: ''{1}'' \u05D0\u05D9\u05E0\u05D5 {2} \u05D7\u05D5\u05E7\u05D9 -items = {0}: \u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD -maxContains = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E1\u05E4\u05E8 \u05E9\u05DC\u05DD \u05DC\u05D0 \u05E9\u05DC\u05D9\u05DC\u05D9 \u05D1-{1} -maxItems = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05DB\u05DC\u05D5\u05DC \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {1} \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D0\u05DA \u05E0\u05DE\u05E6\u05D0\u05D5 {2} -maxLength = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D0\u05D5\u05E8\u05DA \u05E9\u05DC {1} \u05EA\u05D5\u05D5\u05D9\u05DD \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 -maxProperties = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {1} \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD -maximum = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05E7\u05E1\u05D9\u05DE\u05DC\u05D9 \u05E9\u05DC {1} -minContains = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E1\u05E4\u05E8 \u05E9\u05DC\u05DD \u05DC\u05D0 \u05E9\u05DC\u05D9\u05DC\u05D9 \u05D1-{1} -minContainsVsMaxContains = {0}: minContains \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-maxContains \u05D1-{1} -minItems = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05DB\u05DC\u05D5\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {1} \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D0\u05DA \u05E0\u05DE\u05E6\u05D0\u05D5 {2} -minLength = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D0\u05D5\u05E8\u05DA \u05E9\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {1} \u05EA\u05D5\u05D5\u05D9\u05DD -minProperties = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DC\u05E4\u05D7\u05D5\u05EA {1} \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD -minimum = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9 \u05E9\u05DC {1} -multipleOf = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05E4\u05D5\u05DC\u05D4 \u05E9\u05DC {1} -not = {0}: \u05DC\u05D0 \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 {1} -notAllowed = {0}: \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05EA\u05E8 \u05D0\u05DA \u05D4\u05D5\u05D0 \u05E0\u05DE\u05E6\u05D0 \u05D1\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD -oneOf = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D7\u05EA \u05D5\u05D9\u05D7\u05D9\u05D3\u05D4, \u05D0\u05D1\u05DC {1} \u05D7\u05D5\u05E7\u05D9\u05D9\u05DD -oneOf.indexes = {0}: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D7\u05EA \u05D5\u05D9\u05D7\u05D9\u05D3\u05D4, \u05D0\u05D1\u05DC {1} \u05EA\u05E7\u05E4\u05D9\u05DD \u05E2\u05DD \u05D4\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1\u05D9\u05DD ''{2}'' -pattern = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA \u05D4\u05D1\u05D9\u05D8\u05D5\u05D9 \u05D4\u05E8\u05D2\u05D5\u05DC\u05E8\u05D9 {1} -patternProperties = {0}: \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05DB\u05DC\u05E9\u05D4\u05D9 \u05E2\u05DD ''\u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9 \u05D3\u05E4\u05D5\u05E1'' -prefixItems = {0}: \u05DC\u05D0 \u05E0\u05DE\u05E6\u05D0 \u05DE\u05D0\u05DE\u05EA \u05D1\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 \u05D6\u05D4 -properties = {0}: \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD ''\u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD'' -propertyNames = {0}: \u05E9\u05DD \u05D4\u05E0\u05DB\u05E1 ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05D7\u05D5\u05E7\u05D9: {2} -readOnly = {0}: \u05D4\u05D5\u05D0 \u05E9\u05D3\u05D4 \u05DC\u05E7\u05E8\u05D9\u05D0\u05D4 \u05D1\u05DC\u05D1\u05D3, \u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E9\u05E0\u05D5\u05EA \u05D0\u05D5\u05EA\u05D5 -required = {0}: \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF \u05D4\u05E0\u05D3\u05E8\u05E9 ''{1}'' \u05DC\u05D0 \u05E0\u05DE\u05E6\u05D0 -type = {0}: {1} \u05E0\u05DE\u05E6\u05D0, {2} \u05E6\u05E4\u05D5\u05D9 -unevaluatedItems = {0}: \u05D4\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05E2\u05E8\u05DA \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05DC\u05DC\u05D0 \u05D4\u05E2\u05E8\u05DB\u05D4 -unevaluatedProperties = {0}: \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{1}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05E2\u05E8\u05DA \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD \u05DC\u05DC\u05D0 \u05D4\u05E2\u05E8\u05DB\u05D4 -unionType = {0}: {1} \u05E0\u05DE\u05E6\u05D0, {2} \u05E6\u05E4\u05D5\u05D9 -uniqueItems = {0}: \u05D7\u05D9\u05D9\u05D1\u05D9\u05DD \u05DC\u05DB\u05DC\u05D5\u05DC \u05E8\u05E7 \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D9\u05D9\u05D7\u05D5\u05D3\u05D9\u05D9\u05DD \u05D1\u05DE\u05E2\u05E8\u05DA -writeOnly = {0}: \u05D4\u05D5\u05D0 \u05E9\u05D3\u05D4 \u05DC\u05DB\u05EA\u05D9\u05D1\u05D4 \u05D1\u05DC\u05D1\u05D3, \u05D4\u05D5\u05D0 \u05DC\u05D0 \u05D9\u05DB\u05D5\u05DC \u05DC\u05D4\u05D5\u05E4\u05D9\u05E2 \u05D1\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD -contentEncoding = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05D0\u05EA \u05E7\u05D9\u05D3\u05D5\u05D3 \u05D4\u05EA\u05D5\u05DB\u05DF {1} -contentMediaType = {0}: \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05DB\u05DF \u05D0\u05E0\u05D9 +$ref = \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD ''refs'' +additionalItems = \u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD +additionalProperties = \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD +allOf = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05DB\u05DC \u05D4\u05E1\u05DB\u05DE\u05D5\u05EA {0} +anyOf = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05DB\u05DC \u05D0\u05D7\u05EA \u05DE\u05D4\u05E1\u05DB\u05D9\u05DE\u05D5\u05EA {0} +const = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E2\u05E8\u05DA \u05D4\u05E7\u05D1\u05D5\u05E2 ''{0}'' +contains = \u05D0\u05D9\u05E0\u05D5 \u05DE\u05DB\u05D9\u05DC \u05E8\u05DB\u05D9\u05D1 \u05E9\u05E2\u05D5\u05D1\u05E8 \u05D0\u05EA \u05D4\u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D4\u05D1\u05D0\u05D9\u05DD: {1} +contains.max = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05DB\u05D9\u05DC \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {0} \u05E8\u05DB\u05D9\u05D1\u05D9\u05DD \u05E9\u05E2\u05D5\u05D1\u05E8\u05D9\u05DD \u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D0\u05DC\u05D4: {1} +contains.min = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05DB\u05D9\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {0} \u05E8\u05DB\u05D9\u05D1\u05D9\u05DD \u05E9\u05E2\u05D5\u05D1\u05E8\u05D9\u05DD \u05D0\u05D9\u05DE\u05D5\u05EA\u05D9\u05DD \u05D0\u05DC\u05D4: {1} +dependencies = \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD \u05EA\u05DC\u05D5\u05D9\u05D5\u05EA {0} +dependentRequired = \u05D7\u05E1\u05E8 \u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{0}'' \u05D0\u05E9\u05E8 \u05D3\u05E8\u05D5\u05E9 \u05EA\u05DC\u05D5\u05D9 \u05DB\u05D9 ''{1}'' \u05E7\u05D9\u05D9\u05DD +dependentSchemas = \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD dependentSchemas {0} +enum = \u05D0\u05D9\u05DF \u05E2\u05E8\u05DA \u05D1\u05E1\u05E4\u05D9\u05E8\u05D4 {0} +exclusiveMaximum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05E7\u05E1\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {0} +exclusiveMinimum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {0} +false = \u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05E2\u05D1\u05D5\u05E8 ''{0}'' \u05D4\u05D9\u05D0 \u05E9\u05E7\u05E8 +format = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} {1} +format.date = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D0\u05E8\u05D9\u05DA \u05DE\u05DC\u05D0 RFC 3339 \u05D7\u05D5\u05E7\u05D9 +format.date-time = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3339 \u05EA\u05D0\u05E8\u05D9\u05DA-\u05E9\u05E2\u05D4 \u05D7\u05D5\u05E7\u05D9 +format.duration = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E9\u05DA ISO 8601 \u05D7\u05D5\u05E7\u05D9 +format.email = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D9\u05D1\u05EA \u05D3\u05D5\u05D0\u05E8 RFC 5321 \u05D7\u05D5\u05E7\u05D9\u05EA +format.ipv4 = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05EA\u05D5\u05D1\u05EA IP \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 2673 +format.ipv6 = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05EA\u05D5\u05D1\u05EA IP \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 4291 +format.idn-email = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05D3\u05E4\u05D5\u05E1 {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D9\u05D1\u05EA \u05D3\u05D5\u05D0\u05E8 RFC 6531 \u05D7\u05D5\u05E7\u05D9\u05EA +format.idn-hostname = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E9\u05DD \u05DE\u05D0\u05E8\u05D7 \u05D7\u05D5\u05E7\u05D9 RFC 5890 \u05D1\u05D9\u05E0\u05DC\u05D0\u05D5\u05DE\u05D9 +format.iri = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3987 IRI \u05D7\u05D5\u05E7\u05D9 +format.iri-reference = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E4\u05E0\u05D9\u05D4 \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 3987 IRI +format.uri = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3986 URI \u05D7\u05D5\u05E7\u05D9 +format.uri-reference = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05D4\u05E4\u05E0\u05D9\u05D4 \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 3986 URI +format.uri-template = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D1\u05E0\u05D9\u05EA URI \u05D7\u05D5\u05E7\u05D9\u05EA \u05E9\u05DC RFC 6570 +format.uuid = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 4122 UUID \u05D7\u05D5\u05E7\u05D9 +format.regex = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D9\u05D8\u05D5\u05D9 \u05E8\u05D2\u05D5\u05DC\u05E8\u05D9 \u05D7\u05D5\u05E7\u05D9 ECMA-262 +format.time = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D6\u05DE\u05DF RFC 3339 \u05D7\u05D5\u05E7\u05D9 +format.hostname = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E9\u05DD \u05DE\u05D0\u05E8\u05D7 RFC 1123 \u05D7\u05D5\u05E7\u05D9 +format.json-pointer = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E6\u05D1\u05D9\u05E2 RFC 6901 JSON \u05D7\u05D5\u05E7\u05D9 +format.relative-json-pointer = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E6\u05D1\u05D9\u05E2 JSON \u05D9\u05D7\u05E1\u05D9 \u05E9\u05DC IETF \u05D7\u05D5\u05E7\u05D9 +format.unknown = \u05D9\u05E9 \u05E4\u05D5\u05E8\u05DE\u05D8 \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2 ''{0}'' +id = ''{0}'' \u05D0\u05D9\u05E0\u05D5 {1} \u05D7\u05D5\u05E7\u05D9 +items = \u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05D2\u05D3\u05E8 \u05D1\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05E0\u05D5\u05E1\u05E4\u05D9\u05DD +maxContains = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E1\u05E4\u05E8 \u05E9\u05DC\u05DD \u05DC\u05D0 \u05E9\u05DC\u05D9\u05DC\u05D9 \u05D1-{0} +maxItems = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05DB\u05DC\u05D5\u05DC \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {0} \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D0\u05DA \u05E0\u05DE\u05E6\u05D0\u05D5 {1} +maxLength = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D0\u05D5\u05E8\u05DA \u05E9\u05DC {0} \u05EA\u05D5\u05D5\u05D9\u05DD \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 +maxProperties = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8 {0} \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD +maximum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05E7\u05E1\u05D9\u05DE\u05DC\u05D9 \u05E9\u05DC {0} +minContains = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E1\u05E4\u05E8 \u05E9\u05DC\u05DD \u05DC\u05D0 \u05E9\u05DC\u05D9\u05DC\u05D9 \u05D1-{0} +minContainsVsMaxContains = minContains \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-maxContains \u05D1-{0} +minItems = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05DB\u05DC\u05D5\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {0} \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D0\u05DA \u05E0\u05DE\u05E6\u05D0\u05D5 {1} +minLength = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05D0\u05D5\u05E8\u05DA \u05E9\u05DC \u05DC\u05E4\u05D7\u05D5\u05EA {0} \u05EA\u05D5\u05D5\u05D9\u05DD +minProperties = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DC\u05E4\u05D7\u05D5\u05EA {0} \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD +minimum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9 \u05E9\u05DC {0} +multipleOf = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DB\u05E4\u05D5\u05DC\u05D4 \u05E9\u05DC {0} +not = \u05DC\u05D0 \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 {0} +notAllowed = \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05EA\u05E8 \u05D0\u05DA \u05D4\u05D5\u05D0 \u05E0\u05DE\u05E6\u05D0 \u05D1\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD +oneOf = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D7\u05EA \u05D5\u05D9\u05D7\u05D9\u05D3\u05D4, \u05D0\u05D1\u05DC {0} \u05D7\u05D5\u05E7\u05D9\u05D9\u05DD +oneOf.indexes = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D7\u05D5\u05E7\u05D9 \u05DC\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D7\u05EA \u05D5\u05D9\u05D7\u05D9\u05D3\u05D4, \u05D0\u05D1\u05DC {0} \u05EA\u05E7\u05E4\u05D9\u05DD \u05E2\u05DD \u05D4\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1\u05D9\u05DD ''{1}'' +pattern = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA \u05D4\u05D1\u05D9\u05D8\u05D5\u05D9 \u05D4\u05E8\u05D2\u05D5\u05DC\u05E8\u05D9 {0} +patternProperties = \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05DB\u05DC\u05E9\u05D4\u05D9 \u05E2\u05DD ''\u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9 \u05D3\u05E4\u05D5\u05E1'' +prefixItems = \u05DC\u05D0 \u05E0\u05DE\u05E6\u05D0 \u05DE\u05D0\u05DE\u05EA \u05D1\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 \u05D6\u05D4 +properties = \u05D9\u05E9 \u05E9\u05D2\u05D9\u05D0\u05D4 \u05E2\u05DD ''\u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD'' +propertyNames = \u05E9\u05DD \u05D4\u05E0\u05DB\u05E1 ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05D7\u05D5\u05E7\u05D9: {1} +readOnly = \u05D4\u05D5\u05D0 \u05E9\u05D3\u05D4 \u05DC\u05E7\u05E8\u05D9\u05D0\u05D4 \u05D1\u05DC\u05D1\u05D3, \u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E9\u05E0\u05D5\u05EA \u05D0\u05D5\u05EA\u05D5 +required = \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF \u05D4\u05E0\u05D3\u05E8\u05E9 ''{0}'' \u05DC\u05D0 \u05E0\u05DE\u05E6\u05D0 +type = {0} \u05E0\u05DE\u05E6\u05D0, {1} \u05E6\u05E4\u05D5\u05D9 +unevaluatedItems = \u05D4\u05D0\u05D9\u05E0\u05D3\u05E7\u05E1 ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05E2\u05E8\u05DA \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05DC\u05DC\u05D0 \u05D4\u05E2\u05E8\u05DB\u05D4 +unevaluatedProperties = \u05D4\u05DE\u05D0\u05E4\u05D9\u05D9\u05DF ''{0}'' \u05D0\u05D9\u05E0\u05D5 \u05DE\u05D5\u05E2\u05E8\u05DA \u05D5\u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05D0\u05D9\u05E0\u05D4 \u05DE\u05D0\u05E4\u05E9\u05E8\u05EA \u05DE\u05D0\u05E4\u05D9\u05D9\u05E0\u05D9\u05DD \u05DC\u05DC\u05D0 \u05D4\u05E2\u05E8\u05DB\u05D4 +unionType = {0} \u05E0\u05DE\u05E6\u05D0, {1} \u05E6\u05E4\u05D5\u05D9 +uniqueItems = \u05D7\u05D9\u05D9\u05D1\u05D9\u05DD \u05DC\u05DB\u05DC\u05D5\u05DC \u05E8\u05E7 \u05E4\u05E8\u05D9\u05D8\u05D9\u05DD \u05D9\u05D9\u05D7\u05D5\u05D3\u05D9\u05D9\u05DD \u05D1\u05DE\u05E2\u05E8\u05DA +writeOnly = \u05D4\u05D5\u05D0 \u05E9\u05D3\u05D4 \u05DC\u05DB\u05EA\u05D9\u05D1\u05D4 \u05D1\u05DC\u05D1\u05D3, \u05D4\u05D5\u05D0 \u05DC\u05D0 \u05D9\u05DB\u05D5\u05DC \u05DC\u05D4\u05D5\u05E4\u05D9\u05E2 \u05D1\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD +contentEncoding = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05D0\u05EA \u05E7\u05D9\u05D3\u05D5\u05D3 \u05D4\u05EA\u05D5\u05DB\u05DF {0} +contentMediaType = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05DB\u05DF \u05D0\u05E0\u05D9 diff --git a/src/main/resources/jsv-messages_hr.properties b/src/main/resources/jsv-messages_hr.properties index ec55eac96..2ba81a440 100644 --- a/src/main/resources/jsv-messages_hr.properties +++ b/src/main/resources/jsv-messages_hr.properties @@ -1,70 +1,70 @@ -$ref = {0}: ima gre\u0161ku s ''refs'' -additionalItems = {0}: indeks ''{1}'' nije definiran u shemi i shema ne dopu\u0161ta dodatne stavke -additionalProperties = {0}: svojstvo ''{1}'' nije definirano u shemi i shema ne dopu\u0161ta dodatna svojstva -allOf = {0}: mora biti va\u017Ee\u0107e za sve sheme {1} -anyOf = {0}: mora biti va\u017Ee\u0107e za bilo koju od shema {1} -const = {0}: mora biti konstantna vrijednost ''{1}'' -contains = {0}: ne sadr\u017Ei element koji prolazi ove provjere: {2} -contains.max = {0}: mora sadr\u017Eavati najvi\u0161e {1} elemenata koji prolaze ove provjere: {2} -contains.min = {0}: mora sadr\u017Eavati najmanje {1} elementa koji prolaze ove provjere: {2} -dependencies = {0}: ima pogre\u0161ku s ovisnostima {1} -dependentRequired = {0}: nedostaje svojstvo ''{1}'' koje je ovisno potrebno jer je prisutan ''{2}'' -dependentSchemas = {0}: ima pogre\u0161ku s dependentSchemas {1} -enum = {0}: nema vrijednost u enumeraciji {1} -exclusiveMaximum = {0}: mora imati isklju\u010Divu maksimalnu vrijednost od {1} -exclusiveMinimum = {0}: mora imati isklju\u010Divu minimalnu vrijednost od {1} -false = {0}: shema za ''{1}'' je false -format = {0}: ne odgovara {1} uzorku {2} -format.date = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i puni datum RFC 3339 -format.date-time = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 3339 datum-vrijeme -format.duration = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107e ISO 8601 trajanje -format.email = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i po\u0161tanski sandu\u010Di\u0107 RFC 5321 -format.ipv4 = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107a RFC 2673 IP adresa -format.ipv6 = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107a RFC 4291 IP adresa -format.idn-email = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i po\u0161tanski sandu\u010Di\u0107 RFC 6531 -format.idn-hostname = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 5890 internacionalizirani naziv glavnog ra\u010Dunala -format.iri = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 3987 IRI -format.iri-reference = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107a RFC 3987 IRI referenca -format.uri = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 3986 URI -format.uri-reference = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107a RFC 3986 URI referenca -format.uri-template = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 6570 URI predlo\u017Eak -format.uuid = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 4122 UUID -format.regex = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i regularni izraz ECMA-262 -format.time = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107e RFC 3339 vrijeme -format.hostname = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107e RFC 1123 ime glavnog ra\u010Dunala -format.json-pointer = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i RFC 6901 JSON pokaziva\u010D -format.relative-json-pointer = {0}: ne odgovara uzorku {1} mora biti va\u017Ee\u0107i IETF relativni JSON pokaziva\u010D -format.unknown = {0}: ima nepoznati format ''{1}'' -id = {0}: ''{1}'' nije valjan {2} -items = {0}: indeks ''{1}'' nije definiran u shemi i shema ne dopu\u0161ta dodatne stavke -maxContains = {0}: mora biti nenegativan cijeli broj u {1} -maxItems = {0}: mora imati najvi\u0161e {1} stavki, ali prona\u0111eno {2} -maxLength = {0}: mora imati najvi\u0161e {1} znakova -maxProperties = {0}: mora imati najvi\u0161e {1} svojstava -maximum = {0}: mora imati najve\u0107u vrijednost od {1} -minContains = {0}: mora biti nenegativan cijeli broj u {1} -minContainsVsMaxContains = {0}: minContains mora biti manji od ili jednak maxContains u {1} -minItems = {0}: mora imati najmanje {1} stavki, ali prona\u0111eno {2} -minLength = {0}: mora imati najmanje {1} znakova -minProperties = {0}: mora imati najmanje {1} svojstava -minimum = {0}: mora imati minimalnu vrijednost od {1} -multipleOf = {0}: mora biti vi\u0161estruko od {1} -not = {0}: ne smije biti va\u017Ee\u0107e za shemu {1} -notAllowed = {0}: svojstvo ''{1}'' nije dopu\u0161teno, ali je u podacima -oneOf = {0}: mora biti va\u017Ee\u0107e za jednu i samo jednu shemu, ali {1} su va\u017Ee\u0107e -oneOf.indexes = {0}: mora biti va\u017Ee\u0107e za jednu i samo jednu shemu, ali {1} su va\u017Ee\u0107e s indeksima ''{2}'' -pattern = {0}: ne odgovara uzorku regularnog izraza {1} -patternProperties = {0}: ima neke gre\u0161ke sa ''svojstvima uzorka'' -prefixItems = {0}: validator nije prona\u0111en u ovom indeksu -properties = {0}: ima gre\u0161ku sa ''svojstvima'' -propertyNames = {0}: ime svojstva ''{1}'' nije va\u017Ee\u0107e: {2} -readOnly = {0}: polje je samo za \u010Ditanje, ne mo\u017Ee se mijenjati -required = {0}: potrebno svojstvo ''{1}'' nije prona\u0111eno -type = {0}: {1} prona\u0111eno, {2} o\u010Dekivano -unevaluatedItems = {0}: indeks ''{1}'' se ne procjenjuje i shema ne dopu\u0161ta neprocijenjene stavke -unevaluatedProperties = {0}: svojstvo ''{1}'' se ne procjenjuje i shema ne dopu\u0161ta neprocijenjena svojstva -unionType = {0}: {1} prona\u0111eno, {2} o\u010Dekivano -uniqueItems = {0}: mora imati samo jedinstvene stavke u nizu -writeOnly = {0}: polje je samo za pisanje, ne mo\u017Ee se pojaviti u podacima -contentEncoding = {0}: ne odgovara kodiranju sadr\u017Eaja {1} -contentMediaType = {0}: nije ja sadr\u017Eaj +$ref = ima gre\u0161ku s ''refs'' +additionalItems = indeks ''{0}'' nije definiran u shemi i shema ne dopu\u0161ta dodatne stavke +additionalProperties = svojstvo ''{0}'' nije definirano u shemi i shema ne dopu\u0161ta dodatna svojstva +allOf = mora biti va\u017Ee\u0107e za sve sheme {0} +anyOf = mora biti va\u017Ee\u0107e za bilo koju od shema {0} +const = mora biti konstantna vrijednost ''{0}'' +contains = ne sadr\u017Ei element koji prolazi ove provjere: {1} +contains.max = mora sadr\u017Eavati najvi\u0161e {0} elemenata koji prolaze ove provjere: {1} +contains.min = mora sadr\u017Eavati najmanje {0} elementa koji prolaze ove provjere: {1} +dependencies = ima pogre\u0161ku s ovisnostima {0} +dependentRequired = nedostaje svojstvo ''{0}'' koje je ovisno potrebno jer je prisutan ''{1}'' +dependentSchemas = ima pogre\u0161ku s dependentSchemas {0} +enum = nema vrijednost u enumeraciji {0} +exclusiveMaximum = mora imati isklju\u010Divu maksimalnu vrijednost od {0} +exclusiveMinimum = mora imati isklju\u010Divu minimalnu vrijednost od {0} +false = shema za ''{0}'' je false +format = ne odgovara {0} uzorku {1} +format.date = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i puni datum RFC 3339 +format.date-time = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 3339 datum-vrijeme +format.duration = ne odgovara uzorku {0} mora biti va\u017Ee\u0107e ISO 8601 trajanje +format.email = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i po\u0161tanski sandu\u010Di\u0107 RFC 5321 +format.ipv4 = ne odgovara uzorku {0} mora biti va\u017Ee\u0107a RFC 2673 IP adresa +format.ipv6 = ne odgovara uzorku {0} mora biti va\u017Ee\u0107a RFC 4291 IP adresa +format.idn-email = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i po\u0161tanski sandu\u010Di\u0107 RFC 6531 +format.idn-hostname = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 5890 internacionalizirani naziv glavnog ra\u010Dunala +format.iri = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 3987 IRI +format.iri-reference = ne odgovara uzorku {0} mora biti va\u017Ee\u0107a RFC 3987 IRI referenca +format.uri = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 3986 URI +format.uri-reference = ne odgovara uzorku {0} mora biti va\u017Ee\u0107a RFC 3986 URI referenca +format.uri-template = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 6570 URI predlo\u017Eak +format.uuid = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 4122 UUID +format.regex = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i regularni izraz ECMA-262 +format.time = ne odgovara uzorku {0} mora biti va\u017Ee\u0107e RFC 3339 vrijeme +format.hostname = ne odgovara uzorku {0} mora biti va\u017Ee\u0107e RFC 1123 ime glavnog ra\u010Dunala +format.json-pointer = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 6901 JSON pokaziva\u010D +format.relative-json-pointer = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i IETF relativni JSON pokaziva\u010D +format.unknown = ima nepoznati format ''{0}'' +id = ''{0}'' nije valjan {1} +items = indeks ''{0}'' nije definiran u shemi i shema ne dopu\u0161ta dodatne stavke +maxContains = mora biti nenegativan cijeli broj u {0} +maxItems = mora imati najvi\u0161e {0} stavki, ali prona\u0111eno {1} +maxLength = mora imati najvi\u0161e {0} znakova +maxProperties = mora imati najvi\u0161e {0} svojstava +maximum = mora imati najve\u0107u vrijednost od {0} +minContains = mora biti nenegativan cijeli broj u {0} +minContainsVsMaxContains = minContains mora biti manji od ili jednak maxContains u {0} +minItems = mora imati najmanje {0} stavki, ali prona\u0111eno {1} +minLength = mora imati najmanje {0} znakova +minProperties = mora imati najmanje {0} svojstava +minimum = mora imati minimalnu vrijednost od {0} +multipleOf = mora biti vi\u0161estruko od {0} +not = ne smije biti va\u017Ee\u0107e za shemu {0} +notAllowed = svojstvo ''{0}'' nije dopu\u0161teno, ali je u podacima +oneOf = mora biti va\u017Ee\u0107e za jednu i samo jednu shemu, ali {0} su va\u017Ee\u0107e +oneOf.indexes = mora biti va\u017Ee\u0107e za jednu i samo jednu shemu, ali {0} su va\u017Ee\u0107e s indeksima ''{1}'' +pattern = ne odgovara uzorku regularnog izraza {0} +patternProperties = ima neke gre\u0161ke sa ''svojstvima uzorka'' +prefixItems = validator nije prona\u0111en u ovom indeksu +properties = ima gre\u0161ku sa ''svojstvima'' +propertyNames = ime svojstva ''{0}'' nije va\u017Ee\u0107e: {1} +readOnly = polje je samo za \u010Ditanje, ne mo\u017Ee se mijenjati +required = potrebno svojstvo ''{0}'' nije prona\u0111eno +type = {0} prona\u0111eno, {1} o\u010Dekivano +unevaluatedItems = indeks ''{0}'' se ne procjenjuje i shema ne dopu\u0161ta neprocijenjene stavke +unevaluatedProperties = svojstvo ''{0}'' se ne procjenjuje i shema ne dopu\u0161ta neprocijenjena svojstva +unionType = {0} prona\u0111eno, {1} o\u010Dekivano +uniqueItems = mora imati samo jedinstvene stavke u nizu +writeOnly = polje je samo za pisanje, ne mo\u017Ee se pojaviti u podacima +contentEncoding = ne odgovara kodiranju sadr\u017Eaja {0} +contentMediaType = nije ja sadr\u017Eaj diff --git a/src/main/resources/jsv-messages_hu.properties b/src/main/resources/jsv-messages_hu.properties index 88485c631..9455b2766 100644 --- a/src/main/resources/jsv-messages_hu.properties +++ b/src/main/resources/jsv-messages_hu.properties @@ -1,70 +1,70 @@ -$ref = {0}: hibás a ''refs'' -additionalItems = {0}: a ''{1}'' index nincs megadva a sémában, és a séma nem engedélyez további elemeket -additionalProperties = {0}: a ''{1}'' tulajdonság nincs megadva a sémában, és a séma nem engedélyez további tulajdonságokat -allOf = {0}: érvényesnek kell lennie az összes sémára {1} -anyOf = {0}: érvényesnek kell lennie a(z) {1} sémák bármelyikére -const = {0}: a ''{1}'' állandó értéknek kell lennie -contains = {0}: nem tartalmaz olyan elemet, amely átmegy a következ\u0151 ellen\u0151rzéseken: {2} -contains.max = {0}: legfeljebb {1} olyan elemet tartalmazhat, amely megfelel a következ\u0151 ellen\u0151rzéseknek: {2} -contains.min = {0}: tartalmaznia kell legalább {1} olyan elemet, amely átmegy a következ\u0151 ellen\u0151rzéseken: {2} -dependencies = {0}: hiba van a(z) {1} függ\u0151ségekkel -dependentRequired = {0}: hiányzik a(z) ''{1}'' tulajdonsága, amely szükséges, mert a ''{2}'' jelen van -dependentSchemas = {0}: hibás a dependentSchemas {1} -enum = {0}: nincs értéke a(z) {1} felsorolásban -exclusiveMaximum = {0}: kizárólagos maximális értéke {1} -exclusiveMinimum = {0}: kizárólagos minimális értéke {1} -false = {0}: ''{1}'' séma hamis -format = {0}: nem egyezik a {1} mintával {2} -format.date = {0}: nem egyezik a(z) {1} mintával, érvényes RFC 3339 teljes dátumúnak kell lennie -format.date-time = {0}: nem egyezik a {1} mintával, érvényes RFC 3339 dátum-id\u0151 -format.duration = {0}: nem egyezik a {1} mintával, érvényes ISO 8601 id\u0151tartamnak kell lennie -format.email = {0}: nem egyezik a {1} mintával, érvényes RFC 5321-es postafióknak kell lennie -format.ipv4 = {0}: nem egyezik a(z) {1} mintával, érvényes RFC 2673 IP-címnek kell lennie -format.ipv6 = {0}: nem egyezik a {1} mintával, érvényes RFC 4291 IP-címnek kell lennie -format.idn-email = {0}: nem egyezik a {1} mintával, érvényes RFC 6531-es postafióknak kell lennie -format.idn-hostname = {0}: nem egyezik a(z) {1} mintával, érvényes RFC 5890 nemzetköziesített gazdagépnévnek kell lennie -format.iri = {0}: nem egyezik a {1} mintával, érvényes RFC 3987 IRI-nek kell lennie -format.iri-reference = {0}: nem egyezik a {1} mintával, érvényes RFC 3987 IRI-hivatkozásnak kell lennie -format.uri = {0}: nem egyezik a {1} mintával, érvényes RFC 3986 URI-nek kell lennie -format.uri-reference = {0}: nem egyezik a {1} mintával, érvényes RFC 3986 URI-hivatkozásnak kell lennie -format.uri-template = {0}: nem egyezik a {1} mintával, érvényes RFC 6570 URI-sablonnak kell lennie -format.uuid = {0}: nem egyezik a {1} mintával, érvényes RFC 4122 UUID-nek kell lennie -format.regex = {0}: nem egyezik a {1} mintával, érvényes ECMA-262 reguláris kifejezésnek kell lennie -format.time = {0}: nem egyezik a {1} mintával, érvényes RFC 3339 id\u0151nek kell lennie -format.hostname = {0}: nem egyezik a(z) {1} mintával, érvényes RFC 1123 gazdagépnévnek kell lennie -format.json-pointer = {0}: nem egyezik a {1} mintával, érvényes RFC 6901 JSON-mutatónak kell lennie -format.relative-json-pointer = {0}: nem egyezik a {1} mintával, érvényes IETF relatív JSON-mutatónak kell lennie -format.unknown = {0}: ismeretlen formátuma: ''{1}'' -id = {0}: a ''{1}'' nem érvényes {2} -items = {0}: a ''{1}'' index nincs megadva a sémában, és a séma nem engedélyez további elemeket -maxContains = {0}: egy nem negatív egész számnak kell lennie a következ\u0151ben: {1} -maxItems = {0}: legfeljebb {1} elemet tartalmazhat, de {2} található -maxLength = {0}: legfeljebb {1} karakter hosszúságú lehet -maxProperties = {0}: legfeljebb {1} tulajdonsággal kell rendelkeznie -maximum = {0}: maximum {1} értékkel kell rendelkeznie -minContains = {0}: egy nem negatív egész számnak kell lennie a következ\u0151ben: {1} -minContainsVsMaxContains = {0}: A minContains értékének kisebbnek vagy egyenl\u0151nek kell lennie, mint a maxContains a következ\u0151ben: {1} -minItems = {0}: legalább {1} elemnek kell lennie, de {2} található -minLength = {0}: legalább {1} karakter hosszúságúnak kell lennie -minProperties = {0}: legalább {1} tulajdonsággal kell rendelkeznie -minimum = {0}: legalább {1} értékkel kell rendelkeznie -multipleOf = {0}: {1} többszörösének kell lennie -not = {0}: nem érvényes a(z) {1} sémára -notAllowed = {0}: a ''{1}'' tulajdonság nem engedélyezett, de benne van az adatokban -oneOf = {0}: érvényesnek kell lennie egy és csak egy sémára, de a {1} érvényes -oneOf.indexes = {0}: érvényesnek kell lennie egy és csak egy sémára, de a {1} érvényes a következ\u0151 indexekkel: ''{2}'' -pattern = {0}: nem egyezik a következ\u0151 regex mintával: {1} -patternProperties = {0}: hibás a "minta tulajdonságai" -prefixItems = {0}: ezen az indexen nem található érvényesít\u0151 -properties = {0}: hibás a "tulajdonságok" -propertyNames = {0}: a(z) ''{1}'' tulajdonság neve érvénytelen: {2} -readOnly = {0}: csak olvasható mez\u0151, nem módosítható -required = {0}: a(z) ''{1}'' kötelez\u0151 tulajdonság nem található -type = {0}: {1} található, {2} várható -unevaluatedItems = {0}: a ''{1}'' index nincs kiértékelve, és a séma nem engedélyezi az értékeletlen elemeket -unevaluatedProperties = {0}: a(z) ''{1}'' tulajdonság nincs kiértékelve, és a séma nem engedélyezi az értékeletlen tulajdonságokat -unionType = {0}: {1} található, {2} várható -uniqueItems = {0}: csak egyedi elemek lehetnek a tömbben -writeOnly = {0}: csak írható mez\u0151, nem jelenhet meg az adatokban -contentEncoding = {0}: nem egyezik a következ\u0151 tartalomkódolással: {1} -contentMediaType = {0}: nem egy tartalom én +$ref = hibás a ''refs'' +additionalItems = a ''{0}'' index nincs megadva a sémában, és a séma nem engedélyez további elemeket +additionalProperties = a ''{0}'' tulajdonság nincs megadva a sémában, és a séma nem engedélyez további tulajdonságokat +allOf = érvényesnek kell lennie az összes sémára {0} +anyOf = érvényesnek kell lennie a(z) {0} sémák bármelyikére +const = a ''{0}'' állandó értéknek kell lennie +contains = nem tartalmaz olyan elemet, amely átmegy a következ\u0151 ellen\u0151rzéseken: {1} +contains.max = legfeljebb {0} olyan elemet tartalmazhat, amely megfelel a következ\u0151 ellen\u0151rzéseknek: {1} +contains.min = tartalmaznia kell legalább {0} olyan elemet, amely átmegy a következ\u0151 ellen\u0151rzéseken: {1} +dependencies = hiba van a(z) {0} függ\u0151ségekkel +dependentRequired = hiányzik a(z) ''{0}'' tulajdonsága, amely szükséges, mert a ''{1}'' jelen van +dependentSchemas = hibás a dependentSchemas {0} +enum = nincs értéke a(z) {0} felsorolásban +exclusiveMaximum = kizárólagos maximális értéke {0} +exclusiveMinimum = kizárólagos minimális értéke {0} +false = ''{0}'' séma hamis +format = nem egyezik a {0} mintával {1} +format.date = nem egyezik a(z) {0} mintával, érvényes RFC 3339 teljes dátumúnak kell lennie +format.date-time = nem egyezik a {0} mintával, érvényes RFC 3339 dátum-id\u0151 +format.duration = nem egyezik a {0} mintával, érvényes ISO 8601 id\u0151tartamnak kell lennie +format.email = nem egyezik a {0} mintával, érvényes RFC 5321-es postafióknak kell lennie +format.ipv4 = nem egyezik a(z) {0} mintával, érvényes RFC 2673 IP-címnek kell lennie +format.ipv6 = nem egyezik a {0} mintával, érvényes RFC 4291 IP-címnek kell lennie +format.idn-email = nem egyezik a {0} mintával, érvényes RFC 6531-es postafióknak kell lennie +format.idn-hostname = nem egyezik a(z) {0} mintával, érvényes RFC 5890 nemzetköziesített gazdagépnévnek kell lennie +format.iri = nem egyezik a {0} mintával, érvényes RFC 3987 IRI-nek kell lennie +format.iri-reference = nem egyezik a {0} mintával, érvényes RFC 3987 IRI-hivatkozásnak kell lennie +format.uri = nem egyezik a {0} mintával, érvényes RFC 3986 URI-nek kell lennie +format.uri-reference = nem egyezik a {0} mintával, érvényes RFC 3986 URI-hivatkozásnak kell lennie +format.uri-template = nem egyezik a {0} mintával, érvényes RFC 6570 URI-sablonnak kell lennie +format.uuid = nem egyezik a {0} mintával, érvényes RFC 4122 UUID-nek kell lennie +format.regex = nem egyezik a {0} mintával, érvényes ECMA-262 reguláris kifejezésnek kell lennie +format.time = nem egyezik a {0} mintával, érvényes RFC 3339 id\u0151nek kell lennie +format.hostname = nem egyezik a(z) {0} mintával, érvényes RFC 1123 gazdagépnévnek kell lennie +format.json-pointer = nem egyezik a {0} mintával, érvényes RFC 6901 JSON-mutatónak kell lennie +format.relative-json-pointer = nem egyezik a {0} mintával, érvényes IETF relatív JSON-mutatónak kell lennie +format.unknown = ismeretlen formátuma: ''{0}'' +id = a ''{0}'' nem érvényes {1} +items = a ''{0}'' index nincs megadva a sémában, és a séma nem engedélyez további elemeket +maxContains = egy nem negatív egész számnak kell lennie a következ\u0151ben: {0} +maxItems = legfeljebb {0} elemet tartalmazhat, de {1} található +maxLength = legfeljebb {0} karakter hosszúságú lehet +maxProperties = legfeljebb {0} tulajdonsággal kell rendelkeznie +maximum = maximum {0} értékkel kell rendelkeznie +minContains = egy nem negatív egész számnak kell lennie a következ\u0151ben: {0} +minContainsVsMaxContains = A minContains értékének kisebbnek vagy egyenl\u0151nek kell lennie, mint a maxContains a következ\u0151ben: {0} +minItems = legalább {0} elemnek kell lennie, de {1} található +minLength = legalább {0} karakter hosszúságúnak kell lennie +minProperties = legalább {0} tulajdonsággal kell rendelkeznie +minimum = legalább {0} értékkel kell rendelkeznie +multipleOf = {0} többszörösének kell lennie +not = nem érvényes a(z) {0} sémára +notAllowed = a ''{0}'' tulajdonság nem engedélyezett, de benne van az adatokban +oneOf = érvényesnek kell lennie egy és csak egy sémára, de a {0} érvényes +oneOf.indexes = érvényesnek kell lennie egy és csak egy sémára, de a {0} érvényes a következ\u0151 indexekkel: ''{1}'' +pattern = nem egyezik a következ\u0151 regex mintával: {0} +patternProperties = hibás a "minta tulajdonságai" +prefixItems = ezen az indexen nem található érvényesít\u0151 +properties = hibás a "tulajdonságok" +propertyNames = a(z) ''{0}'' tulajdonság neve érvénytelen: {1} +readOnly = csak olvasható mez\u0151, nem módosítható +required = a(z) ''{0}'' kötelez\u0151 tulajdonság nem található +type = {0} található, {1} várható +unevaluatedItems = a ''{0}'' index nincs kiértékelve, és a séma nem engedélyezi az értékeletlen elemeket +unevaluatedProperties = a(z) ''{0}'' tulajdonság nincs kiértékelve, és a séma nem engedélyezi az értékeletlen tulajdonságokat +unionType = {0} található, {1} várható +uniqueItems = csak egyedi elemek lehetnek a tömbben +writeOnly = csak írható mez\u0151, nem jelenhet meg az adatokban +contentEncoding = nem egyezik a következ\u0151 tartalomkódolással: {0} +contentMediaType = nem egy tartalom én diff --git a/src/main/resources/jsv-messages_it.properties b/src/main/resources/jsv-messages_it.properties index 87efce766..c3ed9dad3 100644 --- a/src/main/resources/jsv-messages_it.properties +++ b/src/main/resources/jsv-messages_it.properties @@ -1,70 +1,70 @@ -$ref = {0}: ha un errore con ''refs'' -additionalItems = {0}: l''indice ''{1}'' non è definito nello schema e lo schema non consente elementi aggiuntivi -additionalProperties = {0}: la proprietà ''{1}'' non è definita nello schema e lo schema non consente proprietà aggiuntive -allOf = {0}: deve essere valido per tutti gli schemi {1} -anyOf = {0}: deve essere valido per uno qualsiasi degli schemi {1} -const = {0}: deve essere il valore costante ''{1}'' -contains = {0}: non contiene un elemento che supera queste convalide: {2} -contains.max = {0}: deve contenere al massimo {1} elemento/i che supera queste convalide: {2} -contains.min = {0}: deve contenere almeno {1} elemento/i che supera queste convalide: {2} -dependencies = {0}: presenta un errore con le dipendenze {1} -dependentRequired = {0}: ha una proprietà mancante ''{1}'' che è dipendente obbligatoria perché ''{2}'' è presente -dependentSchemas = {0}: ha un errore con dipendentiSchemas {1} -enum = {0}: non ha un valore nell''enumerazione {1} -exclusiveMaximum = {0}: deve avere un valore massimo esclusivo di {1} -exclusiveMinimum = {0}: deve avere un valore minimo esclusivo di {1} -false = {0}: lo schema per ''{1}'' è falso -format = {0}: non corrisponde al modello {1} {2} -format.date = {0}: non corrisponde al modello {1} deve essere una data completa RFC 3339 valida -format.date-time = {0}: non corrisponde al modello {1} deve essere una data-ora RFC 3339 valida -format.duration = {0}: non corrisponde al modello {1} deve essere una durata ISO 8601 valida -format.email = {0}: non corrisponde al modello {1} deve essere una casella di posta RFC 5321 valida -format.ipv4 = {0}: non corrisponde al modello {1} deve essere un indirizzo IP RFC 2673 valido -format.ipv6 = {0}: non corrisponde al modello {1} deve essere un indirizzo IP RFC 4291 valido -format.idn-email = {0}: non corrisponde al modello {1} deve essere una casella di posta RFC 6531 valida -format.idn-hostname = {0}: non corrisponde al modello {1} deve essere un nome host internazionalizzato RFC 5890 valido -format.iri = {0}: non corrisponde al modello {1} deve essere un IRI RFC 3987 valido -format.iri-reference = {0}: non corrisponde al modello {1} deve essere un riferimento IRI RFC 3987 valido -format.uri = {0}: non corrisponde al modello {1} deve essere un URI RFC 3986 valido -format.uri-reference = {0}: non corrisponde al modello {1} deve essere un riferimento URI RFC 3986 valido -format.uri-template = {0}: non corrisponde al modello {1} deve essere un modello URI RFC 6570 valido -format.uuid = {0}: non corrisponde al modello {1} deve essere un UUID RFC 4122 valido -format.regex = {0}: non corrisponde al modello {1} deve essere un''espressione regolare ECMA-262 valida -format.time = {0}: non corrisponde al modello {1} deve essere un''ora RFC 3339 valida -format.hostname = {0}: non corrisponde al modello {1} deve essere un nome host RFC 1123 valido -format.json-pointer = {0}: non corrisponde al modello {1} deve essere un puntatore JSON RFC 6901 valido -format.relative-json-pointer = {0}: non corrisponde al modello {1} deve essere un puntatore JSON relativo IETF valido -format.unknown = {0}: ha un formato sconosciuto ''{1}'' -id = {0}: ''{1}'' non è un {2} valido -items = {0}: l''indice ''{1}'' non è definito nello schema e lo schema non consente elementi aggiuntivi -maxContains = {0}: deve essere un numero intero non negativo in {1} -maxItems = {0}: deve avere al massimo {1} elementi ma trovati {2} -maxLength = {0}: deve contenere al massimo {1} caratteri -maxProperties = {0}: deve avere al massimo {1} proprietà -maximum = {0}: deve avere un valore massimo di {1} -minContains = {0}: deve essere un numero intero non negativo in {1} -minContainsVsMaxContains = {0}: minContains deve essere minore o uguale a maxContains in {1} -minItems = {0}: deve avere almeno {1} elementi ma trovati {2} -minLength = {0}: deve contenere almeno {1} caratteri -minProperties = {0}: deve avere almeno {1} proprietà -minimum = {0}: deve avere un valore minimo di {1} -multipleOf = {0}: deve essere multiplo di {1} -not = {0}: non deve essere valido per lo schema {1} -notAllowed = {0}: la proprietà ''{1}'' non è consentita ma è nei dati -oneOf = {0}: deve essere valido per uno e un solo schema, ma {1} sono validi -oneOf.indexes = {0}: deve essere valido per uno e un solo schema, ma {1} sono validi con gli indici ''{2}'' -pattern = {0}: non corrisponde al pattern regex {1} -patternProperties = {0}: presenta qualche errore con le ''proprietà del modello'' -prefixItems = {0}: nessun validatore trovato in questo indice -properties = {0}: presenta un errore con ''proprietà'' -propertyNames = {0}: il nome della proprietà ''{1}'' non è valido: {2} -readOnly = {0}: è un campo di sola lettura, non può essere modificato -required = {0}: proprietà richiesta ''{1}'' non trovata -type = {0}: {1} trovato, {2} previsto -unevaluatedItems = {0}: l''indice ''{1}'' non viene valutato e lo schema non consente elementi non valutati -unevaluatedProperties = {0}: la proprietà ''{1}'' non viene valutata e lo schema non consente proprietà non valutate -unionType = {0}: {1} trovato, {2} previsto -uniqueItems = {0}: deve contenere solo elementi univoci nell''array -writeOnly = {0}: è un campo di sola scrittura, non può apparire nei dati -contentEncoding = {0}: non corrisponde alla codifica del contenuto {1} -contentMediaType = {0}: non è un contenuto me +$ref = ha un errore con ''refs'' +additionalItems = l''indice ''{0}'' non è definito nello schema e lo schema non consente elementi aggiuntivi +additionalProperties = la proprietà ''{0}'' non è definita nello schema e lo schema non consente proprietà aggiuntive +allOf = deve essere valido per tutti gli schemi {0} +anyOf = deve essere valido per uno qualsiasi degli schemi {0} +const = deve essere il valore costante ''{0}'' +contains = non contiene un elemento che supera queste convalide: {1} +contains.max = deve contenere al massimo {0} elemento/i che supera queste convalide: {1} +contains.min = deve contenere almeno {0} elemento/i che supera queste convalide: {1} +dependencies = presenta un errore con le dipendenze {0} +dependentRequired = ha una proprietà mancante ''{0}'' che è dipendente obbligatoria perché ''{1}'' è presente +dependentSchemas = ha un errore con dipendentiSchemas {0} +enum = non ha un valore nell''enumerazione {0} +exclusiveMaximum = deve avere un valore massimo esclusivo di {0} +exclusiveMinimum = deve avere un valore minimo esclusivo di {0} +false = lo schema per ''{0}'' è falso +format = non corrisponde al modello {0} {1} +format.date = non corrisponde al modello {0} deve essere una data completa RFC 3339 valida +format.date-time = non corrisponde al modello {0} deve essere una data-ora RFC 3339 valida +format.duration = non corrisponde al modello {0} deve essere una durata ISO 8601 valida +format.email = non corrisponde al modello {0} deve essere una casella di posta RFC 5321 valida +format.ipv4 = non corrisponde al modello {0} deve essere un indirizzo IP RFC 2673 valido +format.ipv6 = non corrisponde al modello {0} deve essere un indirizzo IP RFC 4291 valido +format.idn-email = non corrisponde al modello {0} deve essere una casella di posta RFC 6531 valida +format.idn-hostname = non corrisponde al modello {0} deve essere un nome host internazionalizzato RFC 5890 valido +format.iri = non corrisponde al modello {0} deve essere un IRI RFC 3987 valido +format.iri-reference = non corrisponde al modello {0} deve essere un riferimento IRI RFC 3987 valido +format.uri = non corrisponde al modello {0} deve essere un URI RFC 3986 valido +format.uri-reference = non corrisponde al modello {0} deve essere un riferimento URI RFC 3986 valido +format.uri-template = non corrisponde al modello {0} deve essere un modello URI RFC 6570 valido +format.uuid = non corrisponde al modello {0} deve essere un UUID RFC 4122 valido +format.regex = non corrisponde al modello {0} deve essere un''espressione regolare ECMA-262 valida +format.time = non corrisponde al modello {0} deve essere un''ora RFC 3339 valida +format.hostname = non corrisponde al modello {0} deve essere un nome host RFC 1123 valido +format.json-pointer = non corrisponde al modello {0} deve essere un puntatore JSON RFC 6901 valido +format.relative-json-pointer = non corrisponde al modello {0} deve essere un puntatore JSON relativo IETF valido +format.unknown = ha un formato sconosciuto ''{0}'' +id = ''{0}'' non è un {1} valido +items = l''indice ''{0}'' non è definito nello schema e lo schema non consente elementi aggiuntivi +maxContains = deve essere un numero intero non negativo in {0} +maxItems = deve avere al massimo {0} elementi ma trovati {1} +maxLength = deve contenere al massimo {0} caratteri +maxProperties = deve avere al massimo {0} proprietà +maximum = deve avere un valore massimo di {0} +minContains = deve essere un numero intero non negativo in {0} +minContainsVsMaxContains = minContains deve essere minore o uguale a maxContains in {0} +minItems = deve avere almeno {0} elementi ma trovati {1} +minLength = deve contenere almeno {0} caratteri +minProperties = deve avere almeno {0} proprietà +minimum = deve avere un valore minimo di {0} +multipleOf = deve essere multiplo di {0} +not = non deve essere valido per lo schema {0} +notAllowed = la proprietà ''{0}'' non è consentita ma è nei dati +oneOf = deve essere valido per uno e un solo schema, ma {0} sono validi +oneOf.indexes = deve essere valido per uno e un solo schema, ma {0} sono validi con gli indici ''{1}'' +pattern = non corrisponde al pattern regex {0} +patternProperties = presenta qualche errore con le ''proprietà del modello'' +prefixItems = nessun validatore trovato in questo indice +properties = presenta un errore con ''proprietà'' +propertyNames = il nome della proprietà ''{0}'' non è valido: {1} +readOnly = è un campo di sola lettura, non può essere modificato +required = proprietà richiesta ''{0}'' non trovata +type = {0} trovato, {1} previsto +unevaluatedItems = l''indice ''{0}'' non viene valutato e lo schema non consente elementi non valutati +unevaluatedProperties = la proprietà ''{0}'' non viene valutata e lo schema non consente proprietà non valutate +unionType = {0} trovato, {1} previsto +uniqueItems = deve contenere solo elementi univoci nell''array +writeOnly = è un campo di sola scrittura, non può apparire nei dati +contentEncoding = non corrisponde alla codifica del contenuto {0} +contentMediaType = non è un contenuto me diff --git a/src/main/resources/jsv-messages_ja.properties b/src/main/resources/jsv-messages_ja.properties index 15a6b6a52..36a9ef794 100644 --- a/src/main/resources/jsv-messages_ja.properties +++ b/src/main/resources/jsv-messages_ja.properties @@ -1,70 +1,70 @@ -$ref = {0}: ''refs'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 -additionalItems = {0}: \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{1}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u9805\u76EE\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -additionalProperties = {0}: \u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -allOf = {0}: \u3059\u3079\u3066\u306E\u30B9\u30AD\u30FC\u30DE {1} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -anyOf = {0}: \u3044\u305A\u308C\u304B\u306E\u30B9\u30AD\u30FC\u30DE {1} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -const = {0}: \u5B9A\u6570\u5024 ''{1}'' \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -contains = {0}: \u6B21\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u8981\u7D20\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093: {2} -contains.max = {0}: \u3053\u308C\u3089\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u8981\u7D20\u306F\u6700\u5927\u3067\u3082 {1} \u500B\u542B\u307E\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {2} -contains.min = {0}: \u3053\u308C\u3089\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u5C11\u306A\u304F\u3068\u3082 {1} \u500B\u306E\u8981\u7D20\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {2} -dependencies = {0}: \u4F9D\u5B58\u95A2\u4FC2 {1} \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 -dependentRequired = {0}: \u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u304C\u3042\u308A\u307E\u305B\u3093\u3002''{2}'' \u304C\u5B58\u5728\u3059\u308B\u305F\u3081\u3001\u4F9D\u5B58\u95A2\u4FC2\u304C\u5FC5\u8981\u3067\u3059\u3002 -dependentSchemas = {0}:dependentSchemas {1} \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 -enum = {0}: \u5217\u6319\u578B {1} \u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093 -exclusiveMaximum = {0}: \u6392\u4ED6\u7684\u306A\u6700\u5927\u5024\u306F {1} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -exclusiveMinimum = {0}: \u6392\u4ED6\u7684\u306A\u6700\u5C0F\u5024\u306F {1} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -false = {0}: ''{1}'' \u306E\u30B9\u30AD\u30FC\u30DE\u306F false \u3067\u3059 -format = {0}: {1} \u30D1\u30BF\u30FC\u30F3 {2} \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 -format.date = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u306E\u5B8C\u5168\u306A\u65E5\u4ED8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.date-time = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u65E5\u4ED8/\u6642\u523B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.duration = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A ISO 8601 \u671F\u9593\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.email = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 5321 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.ipv4 = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 2673 IP \u30A2\u30C9\u30EC\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.ipv6 = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 4291 IP \u30A2\u30C9\u30EC\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.idn-email = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6531 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.idn-hostname = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 5890 \u56FD\u969B\u5316\u30DB\u30B9\u30C8\u540D\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.iri = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3987 IRI \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.iri-reference = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3987 IRI \u53C2\u7167\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.uri = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3986 URI \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.uri-reference = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3986 URI \u53C2\u7167\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.uri-template = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6570 URI \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.uuid = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 4122 UUID \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.regex = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A ECMA-262 \u6B63\u898F\u8868\u73FE\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.time = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u6642\u523B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.hostname = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 1123 \u30DB\u30B9\u30C8\u540D\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.json-pointer = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6901 JSON \u30DD\u30A4\u30F3\u30BF\u30FC\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.relative-json-pointer = {0}: {1} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A IETF \u76F8\u5BFE JSON \u30DD\u30A4\u30F3\u30BF\u30FC\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -format.unknown = {0}: \u4E0D\u660E\u306A\u5F62\u5F0F ''{1}'' \u304C\u3042\u308A\u307E\u3059 -id = {0}: ''{1}'' \u306F\u6709\u52B9\u306A {2} \u3067\u306F\u3042\u308A\u307E\u305B\u3093 -items = {0}: \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{1}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u9805\u76EE\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -maxContains = {0}: {1} \u306B\u306F\u8CA0\u3067\u306A\u3044\u6574\u6570\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -maxItems = {0}: \u30A2\u30A4\u30C6\u30E0\u306F\u6700\u5927\u3067\u3082 {1} \u500B\u5FC5\u8981\u3067\u3059\u304C\u3001{2} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F -maxLength = {0}: \u9577\u3055\u306F\u6700\u5927 {1} \u6587\u5B57\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -maxProperties = {0}: \u6700\u5927\u3067 {1} \u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059 -maximum = {0}: \u6700\u5927\u5024\u306F {1} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -minContains = {0}: {1} \u306B\u306F\u8CA0\u3067\u306A\u3044\u6574\u6570\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -minContainsVsMaxContains = {0}: minContains \u306F {1} \u306E maxContains \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -minItems = {0}: \u5C11\u306A\u304F\u3068\u3082 {1} \u500B\u306E\u9805\u76EE\u304C\u5FC5\u8981\u3067\u3059\u304C\u3001{2} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F -minLength = {0}: \u5C11\u306A\u304F\u3068\u3082 {1} \u6587\u5B57\u306E\u9577\u3055\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -minProperties = {0}: \u5C11\u306A\u304F\u3068\u3082 {1} \u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059 -minimum = {0}: \u6700\u5C0F\u5024\u306F {1} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 -multipleOf = {0}: {1} \u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -not = {0}: \u30B9\u30AD\u30FC\u30DE {1} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u3063\u3066\u306F\u306A\u308A\u307E\u305B\u3093 -notAllowed = {0}: \u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u30C7\u30FC\u30BF\u5185\u306B\u3042\u308A\u307E\u3059 -oneOf = {0}: 1 \u3064\u306E\u30B9\u30AD\u30FC\u30DE\u306B\u5BFE\u3057\u3066\u306E\u307F\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304C\u3001{1} \u306F\u6709\u52B9\u3067\u3059 -oneOf.indexes = {0}: 1 \u3064\u306E\u30B9\u30AD\u30FC\u30DE\u306B\u5BFE\u3057\u3066\u306E\u307F\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304C\u3001{1} \u306F\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{2}'' \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3059 -pattern = {0}: \u6B63\u898F\u8868\u73FE\u30D1\u30BF\u30FC\u30F3 {1} \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 -patternProperties = {0}: ''\u30D1\u30BF\u30FC\u30F3 \u30D7\u30ED\u30D1\u30C6\u30A3'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 -prefixItems = {0}: \u3053\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3067\u30D0\u30EA\u30C7\u30FC\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -properties = {0}: ''\u30D7\u30ED\u30D1\u30C6\u30A3'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 -propertyNames = {0}: \u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u306E\u540D\u524D\u304C\u7121\u52B9\u3067\u3059: {2} -readOnly = {0}: \u306F\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\u5909\u66F4\u3067\u304D\u307E\u305B\u3093 -required = {0}: \u5FC5\u9808\u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -type = {0}: {1} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3001{2} \u304C\u4E88\u671F\u3055\u308C\u307E\u3057\u305F -unevaluatedItems = {0}: \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{1}'' \u306F\u8A55\u4FA1\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u306F\u672A\u8A55\u4FA1\u306E\u9805\u76EE\u3092\u8A31\u53EF\u3057\u3066\u3044\u307E\u305B\u3093 -unevaluatedProperties = {0}: \u30D7\u30ED\u30D1\u30C6\u30A3 ''{1}'' \u306F\u8A55\u4FA1\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u306F\u672A\u8A55\u4FA1\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u8A31\u53EF\u3057\u3066\u3044\u307E\u305B\u3093 -unionType = {0}: {1} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3001{2} \u304C\u4E88\u671F\u3055\u308C\u307E\u3057\u305F -uniqueItems = {0}: \u914D\u5217\u306B\u306F\u4E00\u610F\u306E\u9805\u76EE\u306E\u307F\u3092\u542B\u3081\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -writeOnly = {0}: \u306F\u66F8\u304D\u8FBC\u307F\u5C02\u7528\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\u30C7\u30FC\u30BF\u306B\u306F\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3002 -contentEncoding = {0}: \u30B3\u30F3\u30C6\u30F3\u30C4 \u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0 {1} \u3068\u4E00\u81F4\u3057\u307E\u305B\u3093 -contentMediaType = {0}: \u30B3\u30F3\u30C6\u30F3\u30C4\u3067\u306F\u3042\u308A\u307E\u305B\u3093 +$ref = ''refs'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 +additionalItems = \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{0}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u9805\u76EE\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 +additionalProperties = \u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 +allOf = \u3059\u3079\u3066\u306E\u30B9\u30AD\u30FC\u30DE {0} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +anyOf = \u3044\u305A\u308C\u304B\u306E\u30B9\u30AD\u30FC\u30DE {0} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +const = \u5B9A\u6570\u5024 ''{0}'' \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +contains = \u6B21\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u8981\u7D20\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093: {1} +contains.max = \u3053\u308C\u3089\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u8981\u7D20\u306F\u6700\u5927\u3067\u3082 {0} \u500B\u542B\u307E\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {1} +contains.min = \u3053\u308C\u3089\u306E\u691C\u8A3C\u306B\u5408\u683C\u3059\u308B\u5C11\u306A\u304F\u3068\u3082 {0} \u500B\u306E\u8981\u7D20\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {1} +dependencies = \u4F9D\u5B58\u95A2\u4FC2 {0} \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 +dependentRequired = \u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u304C\u3042\u308A\u307E\u305B\u3093\u3002''{1}'' \u304C\u5B58\u5728\u3059\u308B\u305F\u3081\u3001\u4F9D\u5B58\u95A2\u4FC2\u304C\u5FC5\u8981\u3067\u3059\u3002 +dependentSchemas = {0}:dependentSchemas {0} \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 +enum = \u5217\u6319\u578B {0} \u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093 +exclusiveMaximum = \u6392\u4ED6\u7684\u306A\u6700\u5927\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +exclusiveMinimum = \u6392\u4ED6\u7684\u306A\u6700\u5C0F\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +false = ''{0}'' \u306E\u30B9\u30AD\u30FC\u30DE\u306F false \u3067\u3059 +format = {0} \u30D1\u30BF\u30FC\u30F3 {1} \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 +format.date = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u306E\u5B8C\u5168\u306A\u65E5\u4ED8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.date-time = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u65E5\u4ED8/\u6642\u523B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.duration = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A ISO 8601 \u671F\u9593\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.email = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 5321 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.ipv4 = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 2673 IP \u30A2\u30C9\u30EC\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.ipv6 = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 4291 IP \u30A2\u30C9\u30EC\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.idn-email = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6531 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.idn-hostname = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 5890 \u56FD\u969B\u5316\u30DB\u30B9\u30C8\u540D\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.iri = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3987 IRI \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.iri-reference = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3987 IRI \u53C2\u7167\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.uri = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3986 URI \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.uri-reference = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3986 URI \u53C2\u7167\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.uri-template = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6570 URI \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.uuid = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 4122 UUID \u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.regex = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A ECMA-262 \u6B63\u898F\u8868\u73FE\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.time = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u6642\u523B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.hostname = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 1123 \u30DB\u30B9\u30C8\u540D\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.json-pointer = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 6901 JSON \u30DD\u30A4\u30F3\u30BF\u30FC\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.relative-json-pointer = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A IETF \u76F8\u5BFE JSON \u30DD\u30A4\u30F3\u30BF\u30FC\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +format.unknown = \u4E0D\u660E\u306A\u5F62\u5F0F ''{0}'' \u304C\u3042\u308A\u307E\u3059 +id = ''{0}'' \u306F\u6709\u52B9\u306A {1} \u3067\u306F\u3042\u308A\u307E\u305B\u3093 +items = \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{0}'' \u304C\u30B9\u30AD\u30FC\u30DE\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u3067\u306F\u8FFD\u52A0\u306E\u9805\u76EE\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093 +maxContains = {0} \u306B\u306F\u8CA0\u3067\u306A\u3044\u6574\u6570\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +maxItems = \u30A2\u30A4\u30C6\u30E0\u306F\u6700\u5927\u3067\u3082 {0} \u500B\u5FC5\u8981\u3067\u3059\u304C\u3001{1} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F +maxLength = \u9577\u3055\u306F\u6700\u5927 {0} \u6587\u5B57\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +maxProperties = \u6700\u5927\u3067 {0} \u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059 +maximum = \u6700\u5927\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +minContains = {0} \u306B\u306F\u8CA0\u3067\u306A\u3044\u6574\u6570\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +minContainsVsMaxContains = minContains \u306F {0} \u306E maxContains \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +minItems = \u5C11\u306A\u304F\u3068\u3082 {0} \u500B\u306E\u9805\u76EE\u304C\u5FC5\u8981\u3067\u3059\u304C\u3001{1} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F +minLength = \u5C11\u306A\u304F\u3068\u3082 {0} \u6587\u5B57\u306E\u9577\u3055\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +minProperties = \u5C11\u306A\u304F\u3068\u3082 {0} \u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059 +minimum = \u6700\u5C0F\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 +multipleOf = {0} \u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +not = \u30B9\u30AD\u30FC\u30DE {0} \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3042\u3063\u3066\u306F\u306A\u308A\u307E\u305B\u3093 +notAllowed = \u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u30C7\u30FC\u30BF\u5185\u306B\u3042\u308A\u307E\u3059 +oneOf = 1 \u3064\u306E\u30B9\u30AD\u30FC\u30DE\u306B\u5BFE\u3057\u3066\u306E\u307F\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304C\u3001{0} \u306F\u6709\u52B9\u3067\u3059 +oneOf.indexes = 1 \u3064\u306E\u30B9\u30AD\u30FC\u30DE\u306B\u5BFE\u3057\u3066\u306E\u307F\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304C\u3001{0} \u306F\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{1}'' \u306B\u5BFE\u3057\u3066\u6709\u52B9\u3067\u3059 +pattern = \u6B63\u898F\u8868\u73FE\u30D1\u30BF\u30FC\u30F3 {0} \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 +patternProperties = ''\u30D1\u30BF\u30FC\u30F3 \u30D7\u30ED\u30D1\u30C6\u30A3'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 +prefixItems = \u3053\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3067\u30D0\u30EA\u30C7\u30FC\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 +properties = ''\u30D7\u30ED\u30D1\u30C6\u30A3'' \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 +propertyNames = \u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u306E\u540D\u524D\u304C\u7121\u52B9\u3067\u3059: {1} +readOnly = \u306F\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\u5909\u66F4\u3067\u304D\u307E\u305B\u3093 +required = \u5FC5\u9808\u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 +type = {0} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3001{1} \u304C\u4E88\u671F\u3055\u308C\u307E\u3057\u305F +unevaluatedItems = \u30A4\u30F3\u30C7\u30C3\u30AF\u30B9 ''{0}'' \u306F\u8A55\u4FA1\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u306F\u672A\u8A55\u4FA1\u306E\u9805\u76EE\u3092\u8A31\u53EF\u3057\u3066\u3044\u307E\u305B\u3093 +unevaluatedProperties = \u30D7\u30ED\u30D1\u30C6\u30A3 ''{0}'' \u306F\u8A55\u4FA1\u3055\u308C\u3066\u304A\u3089\u305A\u3001\u30B9\u30AD\u30FC\u30DE\u306F\u672A\u8A55\u4FA1\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u8A31\u53EF\u3057\u3066\u3044\u307E\u305B\u3093 +unionType = {0} \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3001{1} \u304C\u4E88\u671F\u3055\u308C\u307E\u3057\u305F +uniqueItems = \u914D\u5217\u306B\u306F\u4E00\u610F\u306E\u9805\u76EE\u306E\u307F\u3092\u542B\u3081\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +writeOnly = \u306F\u66F8\u304D\u8FBC\u307F\u5C02\u7528\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\u30C7\u30FC\u30BF\u306B\u306F\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3002 +contentEncoding = \u30B3\u30F3\u30C6\u30F3\u30C4 \u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0 {0} \u3068\u4E00\u81F4\u3057\u307E\u305B\u3093 +contentMediaType = \u30B3\u30F3\u30C6\u30F3\u30C4\u3067\u306F\u3042\u308A\u307E\u305B\u3093 diff --git a/src/main/resources/jsv-messages_ko.properties b/src/main/resources/jsv-messages_ko.properties index 7c03d5d00..4bc1605cc 100644 --- a/src/main/resources/jsv-messages_ko.properties +++ b/src/main/resources/jsv-messages_ko.properties @@ -1,70 +1,70 @@ -$ref = {0}: ''refs''\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. -additionalItems = {0}: \uC0C9\uC778 ''{1}''\uC774(\uAC00) \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -additionalProperties = {0}: ''{1}'' \uC18D\uC131\uC774 \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uC18D\uC131\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -allOf = {0}: \uBAA8\uB4E0 \uC2A4\uD0A4\uB9C8\uC5D0 \uC720\uD6A8\uD574\uC57C \uD569\uB2C8\uB2E4. {1} -anyOf = {0}: \uBAA8\uB4E0 \uC2A4\uD0A4\uB9C8 {1}\uC5D0 \uC720\uD6A8\uD574\uC57C \uD569\uB2C8\uB2E4. -const = {0}: \uC0C1\uC218 \uAC12 ''{1}''\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -contains = {0}: \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD55C \uC694\uC18C\uB97C \uD3EC\uD568\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: {2} -contains.max = {0}: \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uB294 \uCD5C\uB300 {1}\uAC1C\uC758 \uC694\uC18C\uB97C \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4: {2} -contains.min = {0}: \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uB294 \uC694\uC18C\uAC00 \uCD5C\uC18C\uD55C {1}\uAC1C \uD3EC\uD568\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4: {2} -dependencies = {0}: \uC885\uC18D\uC131 {1}\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. -dependentRequired = {0}: ''{2}''\uC774(\uAC00) \uC874\uC7AC\uD558\uAE30 \uB54C\uBB38\uC5D0 \uC885\uC18D \uD544\uC218\uC778 ''{1}'' \uC18D\uC131\uC774 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4. -dependentSchemas = {0}:dependentSchemas {1}\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. -enum = {0}: \uC5F4\uAC70\uD615 {1}\uC5D0 \uAC12\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. -exclusiveMaximum = {0}: {1}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uB300\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. -exclusiveMinimum = {0}: {1}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uC18C\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. -false = {0}: ''{1}''\uC5D0 \uB300\uD55C \uC2A4\uD0A4\uB9C8\uAC00 false\uC785\uB2C8\uB2E4. -format = {0}: {1} \uD328\uD134 {2}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -format.date = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uC804\uCCB4 \uB0A0\uC9DC\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.date-time = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uB0A0\uC9DC-\uC2DC\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.duration = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C ISO 8601 \uAE30\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.email = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 5321 \uBA54\uC77C\uBC15\uC2A4\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.ipv4 = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 2673 IP \uC8FC\uC18C\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.ipv6 = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 4291 IP \uC8FC\uC18C\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.idn-email = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6531 \uC0AC\uC11C\uD568\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.idn-hostname = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 5890 \uAD6D\uC81C\uD654 \uD638\uC2A4\uD2B8 \uC774\uB984\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.iri = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3987 IRI\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.iri-reference = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3987 IRI \uCC38\uC870\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.uri = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3986 URI\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.uri-reference = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3986 URI \uCC38\uC870\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.uri-template = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6570 URI \uD15C\uD50C\uB9BF\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.uuid = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 4122 UUID\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.regex = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C ECMA-262 \uC815\uADDC \uD45C\uD604\uC2DD\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.time = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uC2DC\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.hostname = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 1123 \uD638\uC2A4\uD2B8 \uC774\uB984\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -format.json-pointer = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6901 JSON \uD3EC\uC778\uD130\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.relative-json-pointer = {0}: {1} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C IETF \uC0C1\uB300 JSON \uD3EC\uC778\uD130\uC5EC\uC57C \uD569\uB2C8\uB2E4. -format.unknown = {0}: \uC54C \uC218 \uC5C6\uB294 \uD615\uC2DD ''{1}''\uC774(\uAC00) \uC788\uC2B5\uB2C8\uB2E4. -id = {0}: ''{1}''\uC740(\uB294) \uC720\uD6A8\uD55C {2}\uC774 \uC544\uB2D9\uB2C8\uB2E4. -items = {0}: \uC0C9\uC778 ''{1}''\uC774(\uAC00) \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -maxContains = {0}: {1}\uC5D0\uC11C \uC74C\uC218\uAC00 \uC544\uB2CC \uC815\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. -maxItems = {0}: \uCD5C\uB300 {1}\uAC1C\uC758 \uD56D\uBAA9\uC774 \uC788\uC5B4\uC57C \uD558\uC9C0\uB9CC {2}\uAC1C\uB97C \uCC3E\uC558\uC2B5\uB2C8\uB2E4. -maxLength = {0}: \uAE38\uC774\uB294 \uCD5C\uB300 {1}\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4. -maxProperties = {0}: \uCD5C\uB300 {1}\uAC1C\uC758 \uC18D\uC131\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. -maximum = {0}: \uCD5C\uB300\uAC12\uC740 {1}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -minContains = {0}: {1}\uC5D0\uC11C \uC74C\uC218\uAC00 \uC544\uB2CC \uC815\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. -minContainsVsMaxContains = {0}: minContains\uB294 {1}\uC758 maxContains\uBCF4\uB2E4 \uC791\uAC70\uB098 \uAC19\uC544\uC57C \uD569\uB2C8\uB2E4. -minItems = {0}: \uCD5C\uC18C {1}\uAC1C\uC758 \uD56D\uBAA9\uC774 \uC788\uC5B4\uC57C \uD558\uC9C0\uB9CC {2}\uAC1C\uB97C \uCC3E\uC558\uC2B5\uB2C8\uB2E4. -minLength = {0}: \uAE38\uC774\uB294 {1}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -minProperties = {0}: \uCD5C\uC18C\uD55C {1}\uAC1C\uC758 \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4. -minimum = {0}: \uCD5C\uC18C\uAC12\uC740 {1}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. -multipleOf = {0}: {1}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. -not = {0}: \uC2A4\uD0A4\uB9C8 {1}\uC5D0 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC544\uC57C \uD569\uB2C8\uB2E4. -notAllowed = {0}: ''{1}'' \uC18D\uC131\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC9C0\uB9CC \uB370\uC774\uD130\uC5D0 \uC788\uC2B5\uB2C8\uB2E4. -oneOf = {0}: \uD558\uB098\uC758 \uC2A4\uD0A4\uB9C8\uC5D0\uB9CC \uC720\uD6A8\uD574\uC57C \uD558\uC9C0\uB9CC {1}\uC740(\uB294) \uC720\uD6A8\uD569\uB2C8\uB2E4. -oneOf.indexes = {0}: \uD558\uB098\uC758 \uC2A4\uD0A4\uB9C8\uC5D0\uB9CC \uC720\uD6A8\uD574\uC57C \uD558\uC9C0\uB9CC {1}\uC740(\uB294) \uC0C9\uC778 ''{2}''\uC5D0 \uC720\uD6A8\uD569\uB2C8\uB2E4. -pattern = {0}: \uC815\uADDC\uC2DD \uD328\uD134 {1}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -patternProperties = {0}: ''\uD328\uD134 \uC18D\uC131''\uC5D0 \uC77C\uBD80 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. -prefixItems = {0}: \uC774 \uC0C9\uC778\uC5D0\uC11C \uC720\uD6A8\uC131 \uAC80\uC0AC\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -properties = {0}: ''\uC18D\uC131''\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. -propertyNames = {0}: ''{1}'' \uC18D\uC131 \uC774\uB984\uC774 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: {2} -readOnly = {0}: \uC77D\uAE30 \uC804\uC6A9 \uD544\uB4DC\uC774\uBBC0\uB85C \uBCC0\uACBD\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -required = {0}: \uD544\uC218 \uC18D\uC131 ''{1}''\uC744(\uB97C) \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -type = {0}: {1} \uBC1C\uACAC, {2} \uC608\uC0C1 -unevaluatedItems = {0}: ''{1}'' \uC0C9\uC778\uC740 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uB294 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC740 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -unevaluatedProperties = {0}: ''{1}'' \uC18D\uC131\uC740 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uB294 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC740 \uC18D\uC131\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -unionType = {0}: {1} \uBC1C\uACAC, {2} \uC608\uC0C1 -uniqueItems = {0}: \uBC30\uC5F4\uC5D0 \uACE0\uC720\uD55C \uD56D\uBAA9\uB9CC \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4. -writeOnly = {0}: \uC4F0\uAE30 \uC804\uC6A9 \uD544\uB4DC\uC774\uBBC0\uB85C \uB370\uC774\uD130\uC5D0 \uB098\uD0C0\uB0A0 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -contentEncoding = {0}: \uCF58\uD150\uCE20 \uC778\uCF54\uB529 {1}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. -contentMediaType = {0}: \uCF58\uD150\uCE20\uAC00 \uC544\uB2D9\uB2C8\uB2E4. +$ref = ''refs''\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. +additionalItems = \uC0C9\uC778 ''{0}''\uC774(\uAC00) \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +additionalProperties = ''{0}'' \uC18D\uC131\uC774 \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uC18D\uC131\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +allOf = \uBAA8\uB4E0 \uC2A4\uD0A4\uB9C8\uC5D0 \uC720\uD6A8\uD574\uC57C \uD569\uB2C8\uB2E4. {0} +anyOf = \uBAA8\uB4E0 \uC2A4\uD0A4\uB9C8 {0}\uC5D0 \uC720\uD6A8\uD574\uC57C \uD569\uB2C8\uB2E4. +const = \uC0C1\uC218 \uAC12 ''{0}''\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +contains = \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD55C \uC694\uC18C\uB97C \uD3EC\uD568\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: {1} +contains.max = \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uB294 \uCD5C\uB300 {0}\uAC1C\uC758 \uC694\uC18C\uB97C \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4: {1} +contains.min = \uB2E4\uC74C \uC720\uD6A8\uC131 \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uB294 \uC694\uC18C\uAC00 \uCD5C\uC18C\uD55C {0}\uAC1C \uD3EC\uD568\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4: {1} +dependencies = \uC885\uC18D\uC131 {0}\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. +dependentRequired = ''{1}''\uC774(\uAC00) \uC874\uC7AC\uD558\uAE30 \uB54C\uBB38\uC5D0 \uC885\uC18D \uD544\uC218\uC778 ''{0}'' \uC18D\uC131\uC774 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4. +dependentSchemas = {0}:dependentSchemas {0}\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. +enum = \uC5F4\uAC70\uD615 {0}\uC5D0 \uAC12\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. +exclusiveMaximum = {0}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uB300\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. +exclusiveMinimum = {0}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uC18C\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. +false = ''{0}''\uC5D0 \uB300\uD55C \uC2A4\uD0A4\uB9C8\uAC00 false\uC785\uB2C8\uB2E4. +format = {0} \uD328\uD134 {1}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +format.date = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uC804\uCCB4 \uB0A0\uC9DC\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.date-time = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uB0A0\uC9DC-\uC2DC\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.duration = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C ISO 8601 \uAE30\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.email = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 5321 \uBA54\uC77C\uBC15\uC2A4\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.ipv4 = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 2673 IP \uC8FC\uC18C\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.ipv6 = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 4291 IP \uC8FC\uC18C\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.idn-email = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6531 \uC0AC\uC11C\uD568\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.idn-hostname = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 5890 \uAD6D\uC81C\uD654 \uD638\uC2A4\uD2B8 \uC774\uB984\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.iri = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3987 IRI\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.iri-reference = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3987 IRI \uCC38\uC870\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.uri = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3986 URI\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.uri-reference = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3986 URI \uCC38\uC870\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.uri-template = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6570 URI \uD15C\uD50C\uB9BF\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.uuid = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 4122 UUID\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.regex = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C ECMA-262 \uC815\uADDC \uD45C\uD604\uC2DD\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.time = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uC2DC\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.hostname = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 1123 \uD638\uC2A4\uD2B8 \uC774\uB984\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +format.json-pointer = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 6901 JSON \uD3EC\uC778\uD130\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.relative-json-pointer = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C IETF \uC0C1\uB300 JSON \uD3EC\uC778\uD130\uC5EC\uC57C \uD569\uB2C8\uB2E4. +format.unknown = \uC54C \uC218 \uC5C6\uB294 \uD615\uC2DD ''{0}''\uC774(\uAC00) \uC788\uC2B5\uB2C8\uB2E4. +id = ''{0}''\uC740(\uB294) \uC720\uD6A8\uD55C {1}\uC774 \uC544\uB2D9\uB2C8\uB2E4. +items = \uC0C9\uC778 ''{0}''\uC774(\uAC00) \uC2A4\uD0A4\uB9C8\uC5D0 \uC815\uC758\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uAC00 \uCD94\uAC00 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +maxContains = {0}\uC5D0\uC11C \uC74C\uC218\uAC00 \uC544\uB2CC \uC815\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. +maxItems = \uCD5C\uB300 {0}\uAC1C\uC758 \uD56D\uBAA9\uC774 \uC788\uC5B4\uC57C \uD558\uC9C0\uB9CC {1}\uAC1C\uB97C \uCC3E\uC558\uC2B5\uB2C8\uB2E4. +maxLength = \uAE38\uC774\uB294 \uCD5C\uB300 {0}\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4. +maxProperties = \uCD5C\uB300 {0}\uAC1C\uC758 \uC18D\uC131\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. +maximum = \uCD5C\uB300\uAC12\uC740 {0}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +minContains = {0}\uC5D0\uC11C \uC74C\uC218\uAC00 \uC544\uB2CC \uC815\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. +minContainsVsMaxContains = minContains\uB294 {0}\uC758 maxContains\uBCF4\uB2E4 \uC791\uAC70\uB098 \uAC19\uC544\uC57C \uD569\uB2C8\uB2E4. +minItems = \uCD5C\uC18C {0}\uAC1C\uC758 \uD56D\uBAA9\uC774 \uC788\uC5B4\uC57C \uD558\uC9C0\uB9CC {1}\uAC1C\uB97C \uCC3E\uC558\uC2B5\uB2C8\uB2E4. +minLength = \uAE38\uC774\uB294 {0}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +minProperties = \uCD5C\uC18C\uD55C {0}\uAC1C\uC758 \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4. +minimum = \uCD5C\uC18C\uAC12\uC740 {0}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. +multipleOf = {0}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4. +not = \uC2A4\uD0A4\uB9C8 {0}\uC5D0 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC544\uC57C \uD569\uB2C8\uB2E4. +notAllowed = ''{0}'' \uC18D\uC131\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC9C0\uB9CC \uB370\uC774\uD130\uC5D0 \uC788\uC2B5\uB2C8\uB2E4. +oneOf = \uD558\uB098\uC758 \uC2A4\uD0A4\uB9C8\uC5D0\uB9CC \uC720\uD6A8\uD574\uC57C \uD558\uC9C0\uB9CC {0}\uC740(\uB294) \uC720\uD6A8\uD569\uB2C8\uB2E4. +oneOf.indexes = \uD558\uB098\uC758 \uC2A4\uD0A4\uB9C8\uC5D0\uB9CC \uC720\uD6A8\uD574\uC57C \uD558\uC9C0\uB9CC {0}\uC740(\uB294) \uC0C9\uC778 ''{1}''\uC5D0 \uC720\uD6A8\uD569\uB2C8\uB2E4. +pattern = \uC815\uADDC\uC2DD \uD328\uD134 {0}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +patternProperties = ''\uD328\uD134 \uC18D\uC131''\uC5D0 \uC77C\uBD80 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. +prefixItems = \uC774 \uC0C9\uC778\uC5D0\uC11C \uC720\uD6A8\uC131 \uAC80\uC0AC\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. +properties = ''\uC18D\uC131''\uC5D0 \uC624\uB958\uAC00 \uC788\uC2B5\uB2C8\uB2E4. +propertyNames = ''{0}'' \uC18D\uC131 \uC774\uB984\uC774 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: {1} +readOnly = \uC77D\uAE30 \uC804\uC6A9 \uD544\uB4DC\uC774\uBBC0\uB85C \uBCC0\uACBD\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. +required = \uD544\uC218 \uC18D\uC131 ''{0}''\uC744(\uB97C) \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. +type = {0} \uBC1C\uACAC, {1} \uC608\uC0C1 +unevaluatedItems = ''{0}'' \uC0C9\uC778\uC740 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uB294 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC740 \uD56D\uBAA9\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +unevaluatedProperties = ''{0}'' \uC18D\uC131\uC740 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC73C\uBA70 \uC2A4\uD0A4\uB9C8\uB294 \uD3C9\uAC00\uB418\uC9C0 \uC54A\uC740 \uC18D\uC131\uC744 \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +unionType = {0} \uBC1C\uACAC, {1} \uC608\uC0C1 +uniqueItems = \uBC30\uC5F4\uC5D0 \uACE0\uC720\uD55C \uD56D\uBAA9\uB9CC \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4. +writeOnly = \uC4F0\uAE30 \uC804\uC6A9 \uD544\uB4DC\uC774\uBBC0\uB85C \uB370\uC774\uD130\uC5D0 \uB098\uD0C0\uB0A0 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. +contentEncoding = \uCF58\uD150\uCE20 \uC778\uCF54\uB529 {0}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +contentMediaType = \uCF58\uD150\uCE20\uAC00 \uC544\uB2D9\uB2C8\uB2E4. diff --git a/src/main/resources/jsv-messages_nb.properties b/src/main/resources/jsv-messages_nb.properties index 2a9437008..5cad08f72 100644 --- a/src/main/resources/jsv-messages_nb.properties +++ b/src/main/resources/jsv-messages_nb.properties @@ -1,70 +1,70 @@ -$ref = {0}: har en feil med ''refs'' -additionalItems = {0}: indeks ''{1}'' er ikke definert i skjemaet og skjemaet tillater ikke flere elementer -additionalProperties = {0}: egenskapen ''{1}'' er ikke definert i skjemaet og skjemaet tillater ikke ytterligere egenskaper -allOf = {0}: må være gyldig for alle skjemaene {1} -anyOf = {0}: må være gyldig for alle skjemaene {1} -const = {0}: må være konstantverdien ''{1}'' -contains = {0}: inneholder ikke et element som består disse valideringene: {2} -contains.max = {0}: må inneholde maksimalt {1} element(er) som består disse valideringene: {2} -contains.min = {0}: må inneholde minst {1} element(er) som består disse valideringene: {2} -dependencies = {0}: har en feil med avhengigheter {1} -dependentRequired = {0}: har en manglende egenskap ''{1}'' som er avhengig nødvendig fordi ''{2}'' er tilstede -dependentSchemas = {0}: har en feil med dependentSchemas {1} -enum = {0}: har ikke en verdi i oppregningen {1} -exclusiveMaximum = {0}: må ha en eksklusiv maksimumsverdi på {1} -exclusiveMinimum = {0}: må ha en eksklusiv minimumsverdi på {1} -false = {0}: skjemaet for ''{1}'' er usant -format = {0}: samsvarer ikke med {1}-mønsteret {2} -format.date = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3339 full-dato -format.date-time = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3339 dato-klokkeslett -format.duration = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig ISO 8601-varighet -format.email = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 5321-postboks -format.ipv4 = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 2673 IP-adresse -format.ipv6 = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 4291 IP-adresse -format.idn-email = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 6531-postboks -format.idn-hostname = {0}: samsvarer ikke med {1}-mønsteret må være et gyldig RFC 5890 internasjonalisert vertsnavn -format.iri = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3987 IRI -format.iri-reference = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3987 IRI-referanse -format.uri = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3986 URI -format.uri-reference = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3986 URI-referanse -format.uri-template = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 6570 URI-mal -format.uuid = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 4122 UUID -format.regex = {0}: samsvarer ikke med {1}-mønsteret må være et gyldig ECMA-262 regulært uttrykk -format.time = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 3339-tid -format.hostname = {0}: samsvarer ikke med {1}-mønsteret må være et gyldig RFC 1123-vertsnavn -format.json-pointer = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig RFC 6901 JSON-peker -format.relative-json-pointer = {0}: samsvarer ikke med {1}-mønsteret må være en gyldig IETF relativ JSON-peker -format.unknown = {0}: har et ukjent format ''{1}'' -id = {0}: ''{1}'' er ikke en gyldig {2} -items = {0}: indeks ''{1}'' er ikke definert i skjemaet, og skjemaet tillater ikke flere elementer -maxContains = {0}: må være et ikke-negativt heltall i {1} -maxItems = {0}: må ha maksimalt {1} varer, men fant {2} -maxLength = {0}: må bestå av maksimalt {1} tegn -maxProperties = {0}: må ha maksimalt {1} egenskaper -maximum = {0}: må ha en maksimal verdi på {1} -minContains = {0}: må være et ikke-negativt heltall i {1} -minContainsVsMaxContains = {0}: minContains må være mindre enn eller lik maxContains i {1} -minItems = {0}: må ha minst {1} elementer, men fant {2} -minLength = {0}: må bestå av minst {1} tegn -minProperties = {0}: må ha minst {1} egenskaper -minimum = {0}: må ha en minimumsverdi på {1} -multipleOf = {0}: må være multiplum av {1} -not = {0}: må ikke være gyldig for skjemaet {1} -notAllowed = {0}: egenskapen ''{1}'' er ikke tillatt, men den er i dataene -oneOf = {0}: må være gyldig for ett og bare ett skjema, men {1} er gyldige -oneOf.indexes = {0}: må være gyldig for ett og bare ett skjema, men {1} er gyldige med indeksene ''{2}'' -pattern = {0}: samsvarer ikke med regex-mønsteret {1} -patternProperties = {0}: har en feil med ''mønsteregenskaper'' -prefixItems = {0}: ingen validator funnet i denne indeksen -properties = {0}: har en feil med ''egenskaper'' -propertyNames = {0}: egenskapen ''{1}'' navn er ikke gyldig: {2} -readOnly = {0}: er et skrivebeskyttet felt, det kan ikke endres -required = {0}: påkrevd egenskap ''{1}'' ikke funnet -type = {0}: {1} funnet, {2} forventet -unevaluatedItems = {0}: indeks ''{1}'' er ikke evaluert og skjemaet tillater ikke uevaluerte elementer -unevaluatedProperties = {0}: egenskapen ''{1}'' er ikke evaluert og skjemaet tillater ikke uevaluerte egenskaper -unionType = {0}: {1} funnet, {2} forventet -uniqueItems = {0}: må bare ha unike elementer i matrisen -writeOnly = {0}: er et skrivebeskyttet felt, det kan ikke vises i dataene -contentEncoding = {0}: samsvarer ikke med innholdskoding {1} -contentMediaType = {0}: er ikke et innhold for meg +$ref = har en feil med ''refs'' +additionalItems = indeks ''{0}'' er ikke definert i skjemaet og skjemaet tillater ikke flere elementer +additionalProperties = egenskapen ''{0}'' er ikke definert i skjemaet og skjemaet tillater ikke ytterligere egenskaper +allOf = må være gyldig for alle skjemaene {0} +anyOf = må være gyldig for alle skjemaene {0} +const = må være konstantverdien ''{0}'' +contains = inneholder ikke et element som består disse valideringene: {1} +contains.max = må inneholde maksimalt {0} element(er) som består disse valideringene: {1} +contains.min = må inneholde minst {0} element(er) som består disse valideringene: {1} +dependencies = har en feil med avhengigheter {0} +dependentRequired = har en manglende egenskap ''{0}'' som er avhengig nødvendig fordi ''{1}'' er tilstede +dependentSchemas = har en feil med dependentSchemas {0} +enum = har ikke en verdi i oppregningen {0} +exclusiveMaximum = må ha en eksklusiv maksimumsverdi på {0} +exclusiveMinimum = må ha en eksklusiv minimumsverdi på {0} +false = skjemaet for ''{0}'' er usant +format = samsvarer ikke med {0}-mønsteret {1} +format.date = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3339 full-dato +format.date-time = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3339 dato-klokkeslett +format.duration = samsvarer ikke med {0}-mønsteret må være en gyldig ISO 8601-varighet +format.email = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 5321-postboks +format.ipv4 = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 2673 IP-adresse +format.ipv6 = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 4291 IP-adresse +format.idn-email = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 6531-postboks +format.idn-hostname = samsvarer ikke med {0}-mønsteret må være et gyldig RFC 5890 internasjonalisert vertsnavn +format.iri = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3987 IRI +format.iri-reference = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3987 IRI-referanse +format.uri = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3986 URI +format.uri-reference = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3986 URI-referanse +format.uri-template = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 6570 URI-mal +format.uuid = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 4122 UUID +format.regex = samsvarer ikke med {0}-mønsteret må være et gyldig ECMA-262 regulært uttrykk +format.time = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3339-tid +format.hostname = samsvarer ikke med {0}-mønsteret må være et gyldig RFC 1123-vertsnavn +format.json-pointer = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 6901 JSON-peker +format.relative-json-pointer = samsvarer ikke med {0}-mønsteret må være en gyldig IETF relativ JSON-peker +format.unknown = har et ukjent format ''{0}'' +id = ''{0}'' er ikke en gyldig {1} +items = indeks ''{0}'' er ikke definert i skjemaet, og skjemaet tillater ikke flere elementer +maxContains = må være et ikke-negativt heltall i {0} +maxItems = må ha maksimalt {0} varer, men fant {1} +maxLength = må bestå av maksimalt {0} tegn +maxProperties = må ha maksimalt {0} egenskaper +maximum = må ha en maksimal verdi på {0} +minContains = må være et ikke-negativt heltall i {0} +minContainsVsMaxContains = minContains må være mindre enn eller lik maxContains i {0} +minItems = må ha minst {0} elementer, men fant {1} +minLength = må bestå av minst {0} tegn +minProperties = må ha minst {0} egenskaper +minimum = må ha en minimumsverdi på {0} +multipleOf = må være multiplum av {0} +not = må ikke være gyldig for skjemaet {0} +notAllowed = egenskapen ''{0}'' er ikke tillatt, men den er i dataene +oneOf = må være gyldig for ett og bare ett skjema, men {0} er gyldige +oneOf.indexes = må være gyldig for ett og bare ett skjema, men {0} er gyldige med indeksene ''{1}'' +pattern = samsvarer ikke med regex-mønsteret {0} +patternProperties = har en feil med ''mønsteregenskaper'' +prefixItems = ingen validator funnet i denne indeksen +properties = har en feil med ''egenskaper'' +propertyNames = egenskapen ''{0}'' navn er ikke gyldig: {1} +readOnly = er et skrivebeskyttet felt, det kan ikke endres +required = påkrevd egenskap ''{0}'' ikke funnet +type = {0} funnet, {1} forventet +unevaluatedItems = indeks ''{0}'' er ikke evaluert og skjemaet tillater ikke uevaluerte elementer +unevaluatedProperties = egenskapen ''{0}'' er ikke evaluert og skjemaet tillater ikke uevaluerte egenskaper +unionType = {0} funnet, {1} forventet +uniqueItems = må bare ha unike elementer i matrisen +writeOnly = er et skrivebeskyttet felt, det kan ikke vises i dataene +contentEncoding = samsvarer ikke med innholdskoding {0} +contentMediaType = er ikke et innhold for meg diff --git a/src/main/resources/jsv-messages_nl.properties b/src/main/resources/jsv-messages_nl.properties index bf77c37a6..800c43e5a 100644 --- a/src/main/resources/jsv-messages_nl.properties +++ b/src/main/resources/jsv-messages_nl.properties @@ -1,70 +1,70 @@ -$ref = {0}: bevat een fout met ''refs'' -additionalItems = {0}: index ''{1}'' is niet gedefinieerd in het schema en het schema staat geen extra items toe -additionalProperties = {0}: eigenschap ''{1}'' is niet gedefinieerd in het schema en het schema staat geen aanvullende eigenschappen toe -allOf = {0}: moet geldig zijn voor alle schema''s {1} -anyOf = {0}: moet geldig zijn voor elk van de schema''s {1} -const = {0}: moet de constante waarde ''{1}'' zijn -contains = {0}: bevat geen element dat deze validaties doorstaat: {2} -contains.max = {0}: moet maximaal {1} element(en) bevatten die aan deze validaties voldoen: {2} -contains.min = {0}: moet minimaal {1} element(en) bevatten die aan deze validaties voldoen: {2} -dependencies = {0}: bevat een fout met afhankelijkheden {1} -dependentRequired = {0}: heeft een ontbrekende eigenschap ''{1}'' die afhankelijk is vereist omdat ''{2}'' aanwezig is -dependentSchemas = {0}: bevat een fout met dependSchemas {1} -enum = {0}: heeft geen waarde in de opsomming {1} -exclusiveMaximum = {0}: moet een exclusieve maximumwaarde hebben van {1} -exclusiveMinimum = {0}: moet een exclusieve minimumwaarde hebben van {1} -false = {0}: schema voor ''{1}'' is false -format = {0}: komt niet overeen met het {1} patroon {2} -format.date = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3339-volledige datum zijn -format.date-time = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3339-datum-tijd zijn -format.duration = {0}: komt niet overeen met het patroon {1} moet een geldige ISO 8601-duur hebben -format.email = {0}: komt niet overeen met het patroon {1} moet een geldige RFC 5321-mailbox zijn -format.ipv4 = {0}: komt niet overeen met het patroon {1} moet een geldig RFC 2673 IP-adres zijn -format.ipv6 = {0}: komt niet overeen met het patroon {1} moet een geldig RFC 4291 IP-adres zijn -format.idn-email = {0}: komt niet overeen met het patroon {1} moet een geldige RFC 6531-mailbox zijn -format.idn-hostname = {0}: komt niet overeen met het patroon {1} moet een geldige geïnternationaliseerde RFC 5890-hostnaam zijn -format.iri = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3987 IRI zijn -format.iri-reference = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3987 IRI-referentie zijn -format.uri = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3986-URI zijn -format.uri-reference = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3986 URI-referentie zijn -format.uri-template = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 6570 URI-sjabloon zijn -format.uuid = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 4122 UUID zijn -format.regex = {0}: komt niet overeen met het patroon {1} moet een geldige reguliere ECMA-262-expressie zijn -format.time = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 3339-tijd zijn -format.hostname = {0}: komt niet overeen met het patroon {1} moet een geldige RFC 1123-hostnaam zijn -format.json-pointer = {0}: komt niet overeen met het {1}-patroon moet een geldige RFC 6901 JSON-aanwijzer zijn -format.relative-json-pointer = {0}: komt niet overeen met het {1}-patroon moet een geldige IETF relatieve JSON-aanwijzer zijn -format.unknown = {0}: heeft een onbekend formaat ''{1}'' -id = {0}: ''{1}'' is geen geldige {2} -items = {0}: index ''{1}'' is niet gedefinieerd in het schema en het schema staat geen extra items toe -maxContains = {0}: moet een niet-negatief geheel getal zijn in {1} -maxItems = {0}: moet maximaal {1} items bevatten, maar heeft {2} gevonden -maxLength = {0}: mag maximaal {1} tekens lang zijn -maxProperties = {0}: moet maximaal {1} eigenschappen hebben -maximum = {0}: moet een maximale waarde van {1} hebben -minContains = {0}: moet een niet-negatief geheel getal zijn in {1} -minContainsVsMaxContains = {0}: minContains moet kleiner zijn dan of gelijk zijn aan maxContains in {1} -minItems = {0}: moet minstens {1} items hebben, maar {2} gevonden -minLength = {0}: moet minimaal {1} tekens lang zijn -minProperties = {0}: moet minimaal {1} eigenschappen hebben -minimum = {0}: moet een minimumwaarde van {1} hebben -multipleOf = {0}: moet een veelvoud zijn van {1} -not = {0}: mag niet geldig zijn voor het schema {1} -notAllowed = {0}: eigenschap ''{1}'' is niet toegestaan, maar staat wel in de gegevens -oneOf = {0}: moet geldig zijn voor slechts één schema, maar {1} zijn geldig -oneOf.indexes = {0}: moet geldig zijn voor één en slechts één schema, maar {1} zijn geldig met indexen ''{2}'' -pattern = {0}: komt niet overeen met het regex-patroon {1} -patternProperties = {0}: bevat een fout met ''patrooneigenschappen'' -prefixItems = {0}: geen validator gevonden bij deze index -properties = {0}: bevat een fout met ''properties'' -propertyNames = {0}: eigenschap ''{1}'' naam is niet geldig: {2} -readOnly = {0}: is een alleen-lezen veld, dit kan niet worden gewijzigd -required = {0}: vereiste eigenschap ''{1}'' niet gevonden -type = {0}: {1} gevonden, {2} verwacht -unevaluatedItems = {0}: index ''{1}'' wordt niet geëvalueerd en het schema staat geen niet-geëvalueerde items toe -unevaluatedProperties = {0}: eigenschap ''{1}'' wordt niet geëvalueerd en het schema staat geen niet-geëvalueerde eigenschappen toe -unionType = {0}: {1} gevonden, {2} verwacht -uniqueItems = {0}: mag alleen unieke items in de array bevatten -writeOnly = {0}: is een alleen-schrijven-veld, het kan niet voorkomen in de gegevens -contentEncoding = {0}: komt niet overeen met inhoudscodering {1} -contentMediaType = {0}: is geen inhoudsmij +$ref = bevat een fout met ''refs'' +additionalItems = index ''{0}'' is niet gedefinieerd in het schema en het schema staat geen extra items toe +additionalProperties = eigenschap ''{0}'' is niet gedefinieerd in het schema en het schema staat geen aanvullende eigenschappen toe +allOf = moet geldig zijn voor alle schema''s {0} +anyOf = moet geldig zijn voor elk van de schema''s {0} +const = moet de constante waarde ''{0}'' zijn +contains = bevat geen element dat deze validaties doorstaat: {1} +contains.max = moet maximaal {0} element(en) bevatten die aan deze validaties voldoen: {1} +contains.min = moet minimaal {0} element(en) bevatten die aan deze validaties voldoen: {1} +dependencies = bevat een fout met afhankelijkheden {0} +dependentRequired = heeft een ontbrekende eigenschap ''{0}'' die afhankelijk is vereist omdat ''{1}'' aanwezig is +dependentSchemas = bevat een fout met dependSchemas {0} +enum = heeft geen waarde in de opsomming {0} +exclusiveMaximum = moet een exclusieve maximumwaarde hebben van {0} +exclusiveMinimum = moet een exclusieve minimumwaarde hebben van {0} +false = schema voor ''{0}'' is false +format = komt niet overeen met het {0} patroon {1} +format.date = komt niet overeen met het {0}-patroon moet een geldige RFC 3339-volledige datum zijn +format.date-time = komt niet overeen met het {0}-patroon moet een geldige RFC 3339-datum-tijd zijn +format.duration = komt niet overeen met het patroon {0} moet een geldige ISO 8601-duur hebben +format.email = komt niet overeen met het patroon {0} moet een geldige RFC 5321-mailbox zijn +format.ipv4 = komt niet overeen met het patroon {0} moet een geldig RFC 2673 IP-adres zijn +format.ipv6 = komt niet overeen met het patroon {0} moet een geldig RFC 4291 IP-adres zijn +format.idn-email = komt niet overeen met het patroon {0} moet een geldige RFC 6531-mailbox zijn +format.idn-hostname = komt niet overeen met het patroon {0} moet een geldige geïnternationaliseerde RFC 5890-hostnaam zijn +format.iri = komt niet overeen met het {0}-patroon moet een geldige RFC 3987 IRI zijn +format.iri-reference = komt niet overeen met het {0}-patroon moet een geldige RFC 3987 IRI-referentie zijn +format.uri = komt niet overeen met het {0}-patroon moet een geldige RFC 3986-URI zijn +format.uri-reference = komt niet overeen met het {0}-patroon moet een geldige RFC 3986 URI-referentie zijn +format.uri-template = komt niet overeen met het {0}-patroon moet een geldige RFC 6570 URI-sjabloon zijn +format.uuid = komt niet overeen met het {0}-patroon moet een geldige RFC 4122 UUID zijn +format.regex = komt niet overeen met het patroon {0} moet een geldige reguliere ECMA-262-expressie zijn +format.time = komt niet overeen met het {0}-patroon moet een geldige RFC 3339-tijd zijn +format.hostname = komt niet overeen met het patroon {0} moet een geldige RFC 1123-hostnaam zijn +format.json-pointer = komt niet overeen met het {0}-patroon moet een geldige RFC 6901 JSON-aanwijzer zijn +format.relative-json-pointer = komt niet overeen met het {0}-patroon moet een geldige IETF relatieve JSON-aanwijzer zijn +format.unknown = heeft een onbekend formaat ''{0}'' +id = ''{0}'' is geen geldige {1} +items = index ''{0}'' is niet gedefinieerd in het schema en het schema staat geen extra items toe +maxContains = moet een niet-negatief geheel getal zijn in {0} +maxItems = moet maximaal {0} items bevatten, maar heeft {1} gevonden +maxLength = mag maximaal {0} tekens lang zijn +maxProperties = moet maximaal {0} eigenschappen hebben +maximum = moet een maximale waarde van {0} hebben +minContains = moet een niet-negatief geheel getal zijn in {0} +minContainsVsMaxContains = minContains moet kleiner zijn dan of gelijk zijn aan maxContains in {0} +minItems = moet minstens {0} items hebben, maar {1} gevonden +minLength = moet minimaal {0} tekens lang zijn +minProperties = moet minimaal {0} eigenschappen hebben +minimum = moet een minimumwaarde van {0} hebben +multipleOf = moet een veelvoud zijn van {0} +not = mag niet geldig zijn voor het schema {0} +notAllowed = eigenschap ''{0}'' is niet toegestaan, maar staat wel in de gegevens +oneOf = moet geldig zijn voor slechts één schema, maar {0} zijn geldig +oneOf.indexes = moet geldig zijn voor één en slechts één schema, maar {0} zijn geldig met indexen ''{1}'' +pattern = komt niet overeen met het regex-patroon {0} +patternProperties = bevat een fout met ''patrooneigenschappen'' +prefixItems = geen validator gevonden bij deze index +properties = bevat een fout met ''properties'' +propertyNames = eigenschap ''{0}'' naam is niet geldig: {1} +readOnly = is een alleen-lezen veld, dit kan niet worden gewijzigd +required = vereiste eigenschap ''{0}'' niet gevonden +type = {0} gevonden, {1} verwacht +unevaluatedItems = index ''{0}'' wordt niet geëvalueerd en het schema staat geen niet-geëvalueerde items toe +unevaluatedProperties = eigenschap ''{0}'' wordt niet geëvalueerd en het schema staat geen niet-geëvalueerde eigenschappen toe +unionType = {0} gevonden, {1} verwacht +uniqueItems = mag alleen unieke items in de array bevatten +writeOnly = is een alleen-schrijven-veld, het kan niet voorkomen in de gegevens +contentEncoding = komt niet overeen met inhoudscodering {0} +contentMediaType = is geen inhoudsmij diff --git a/src/main/resources/jsv-messages_pl.properties b/src/main/resources/jsv-messages_pl.properties index 254477b1c..e68a00d30 100644 --- a/src/main/resources/jsv-messages_pl.properties +++ b/src/main/resources/jsv-messages_pl.properties @@ -1,70 +1,70 @@ -$ref = {0}: zawiera b\u0142\u0105d z \u201Erefami\u201D -additionalItems = {0}: indeks \u201E{1}\u201D nie jest zdefiniowany w schemacie i schemat nie pozwala na dodatkowe elementy -additionalProperties = {0}: w\u0142a\u015Bciwo\u015B\u0107 \u201E{1}\u201D nie jest zdefiniowana w schemacie i schemat nie pozwala na dodatkowe w\u0142a\u015Bciwo\u015Bci -allOf = {0}: musi by\u0107 poprawny dla wszystkich schematów {1} -anyOf = {0}: musi by\u0107 poprawny dla dowolnego schematu {1} -const = {0}: musi by\u0107 sta\u0142\u0105 warto\u015Bci\u0105 \u201E{1}\u201D -contains = {0}: nie zawiera elementu, który przechodzi te weryfikacje: {2} -contains.max = {0}: musi zawiera\u0107 maksymalnie {1} elementów, które przechodz\u0105 t\u0119 weryfikacj\u0119: {2} -contains.min = {0}: musi zawiera\u0107 co najmniej {1} elementów, które przechodz\u0105 t\u0119 weryfikacj\u0119: {2} -dependencies = {0}: zawiera b\u0142\u0105d z zale\u017Cno\u015Bciami {1} -dependentRequired = {0}: ma brakuj\u0105c\u0105 w\u0142a\u015Bciwo\u015B\u0107 \u201E{1}\u201D, która jest zale\u017Cna i wymagana, poniewa\u017C wyst\u0119puje \u201E{2}\u201D -dependentSchemas = {0}: zawiera b\u0142\u0105d w schematach zale\u017Cnych {1} -enum = {0}: nie ma warto\u015Bci w wyliczeniu {1} -exclusiveMaximum = {0}: musi mie\u0107 wy\u0142\u0105czn\u0105 warto\u015B\u0107 maksymaln\u0105 wynosz\u0105c\u0105 {1} -exclusiveMinimum = {0}: musi mie\u0107 wy\u0142\u0105czn\u0105 minimaln\u0105 warto\u015B\u0107 {1} -false = {0}: schemat dla \u201E{1}\u201D jest fa\u0142szywy -format = {0}: nie pasuje do wzorca {1} {2} -format.date = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 pe\u0142n\u0105 dat\u0105 RFC 3339 -format.date-time = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 dat\u0105 i godzin\u0105 RFC 3339 -format.duration = {0}: nie pasuje do wzorca {1}, musi mie\u0107 prawid\u0142owy czas trwania ISO 8601 -format.email = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 skrzynk\u0105 pocztow\u0105 RFC 5321 -format.ipv4 = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym adresem IP RFC 2673 -format.ipv6 = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym adresem IP RFC 4291 -format.idn-email = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 skrzynk\u0105 pocztow\u0105 RFC 6531 -format.idn-hostname = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 mi\u0119dzynarodow\u0105 nazw\u0105 hosta zgodn\u0105 z RFC 5890 -format.iri = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym IRI RFC 3987 -format.iri-reference = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym odwo\u0142aniem IRI RFC 3987 -format.uri = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym identyfikatorem URI RFC 3986 -format.uri-reference = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym odwo\u0142aniem URI RFC 3986 -format.uri-template = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym szablonem URI RFC 6570 -format.uuid = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym identyfikatorem UUID RFC 4122 -format.regex = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym wyra\u017Ceniem regularnym ECMA-262 -format.time = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym czasem RFC 3339 -format.hostname = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142ow\u0105 nazw\u0105 hosta zgodn\u0105 z RFC 1123 -format.json-pointer = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym wska\u017Anikiem JSON RFC 6901 -format.relative-json-pointer = {0}: nie pasuje do wzorca {1} musi by\u0107 prawid\u0142owym wzgl\u0119dnym wska\u017Anikiem JSON IETF -format.unknown = {0}: ma nieznany format \u201E{1}\u201D -id = {0}: \u201E{1}\u201D nie jest prawid\u0142owym {2} -items = {0}: indeks ''{1}'' nie jest zdefiniowany w schemacie i schemat nie pozwala na dodatkowe elementy -maxContains = {0}: musi by\u0107 nieujemn\u0105 liczb\u0105 ca\u0142kowit\u0105 w {1} -maxItems = {0}: musi mie\u0107 co najwy\u017Cej {1} elementów, ale znaleziono {2} -maxLength = {0}: musi mie\u0107 maksymalnie {1} znaków -maxProperties = {0}: musi mie\u0107 co najwy\u017Cej {1} w\u0142a\u015Bciwo\u015Bci -maximum = {0}: musi mie\u0107 maksymaln\u0105 warto\u015B\u0107 {1} -minContains = {0}: musi by\u0107 nieujemn\u0105 liczb\u0105 ca\u0142kowit\u0105 w {1} -minContainsVsMaxContains = {0}: minContains musi by\u0107 mniejsze lub równe maxContains w {1} -minItems = {0}: musi mie\u0107 co najmniej {1} elementów, ale znaleziono {2} -minLength = {0}: musi mie\u0107 co najmniej {1} znaków -minProperties = {0}: musi mie\u0107 co najmniej {1} w\u0142a\u015Bciwo\u015Bci -minimum = {0}: musi mie\u0107 minimaln\u0105 warto\u015B\u0107 {1} -multipleOf = {0}: musi by\u0107 wielokrotno\u015Bci\u0105 {1} -not = {0}: nie mo\u017Ce by\u0107 poprawny dla schematu {1} -notAllowed = {0}: w\u0142a\u015Bciwo\u015B\u0107 \u201E{1}\u201D jest niedozwolona, ale znajduje si\u0119 w danych -oneOf = {0}: musi by\u0107 poprawny dla jednego i tylko jednego schematu, ale {1} s\u0105 prawid\u0142owe -oneOf.indexes = {0}: musi by\u0107 poprawny dla jednego i tylko jednego schematu, ale {1} jest prawid\u0142owe z indeksami \u201E{2}\u201D -pattern = {0}: nie pasuje do wzorca wyra\u017Cenia regularnego {1} -patternProperties = {0}: zawiera b\u0142\u0105d dotycz\u0105cy \u201Ew\u0142a\u015Bciwo\u015Bci wzorca\u201D -prefixItems = {0}: w tym indeksie nie znaleziono walidatora -properties = {0}: zawiera b\u0142\u0105d dotycz\u0105cy \u201Ew\u0142a\u015Bciwo\u015Bci\u201D -propertyNames = {0}: nazwa w\u0142a\u015Bciwo\u015Bci \u201E{1}\u201D jest nieprawid\u0142owa: {2} -readOnly = {0}: jest polem tylko do odczytu, nie mo\u017Cna go zmieni\u0107 -required = {0}: nie znaleziono wymaganej w\u0142a\u015Bciwo\u015Bci \u201E{1}\u201D. -type = {0}: Znaleziono {1}, oczekiwano {2} -unevaluatedItems = {0}: indeks \u201E{1}\u201D nie jest oceniany i schemat nie pozwala na nieocenione elementy -unevaluatedProperties = {0}: w\u0142a\u015Bciwo\u015B\u0107 \u201E{1}\u201D nie jest oceniana i schemat nie pozwala na nieocenione w\u0142a\u015Bciwo\u015Bci -unionType = {0}: Znaleziono {1}, oczekiwano {2} -uniqueItems = {0}: tablica musi zawiera\u0107 tylko unikalne elementy -writeOnly = {0}: jest polem tylko do zapisu, nie mo\u017Ce pojawia\u0107 si\u0119 w danych -contentEncoding = {0}: nie pasuje do kodowania tre\u015Bci {1} -contentMediaType = {0}: nie jest tre\u015Bci\u0105 +$ref = zawiera b\u0142\u0105d z \u201Erefami\u201D +additionalItems = indeks \u201E{0}\u201D nie jest zdefiniowany w schemacie i schemat nie pozwala na dodatkowe elementy +additionalProperties = w\u0142a\u015Bciwo\u015B\u0107 \u201E{0}\u201D nie jest zdefiniowana w schemacie i schemat nie pozwala na dodatkowe w\u0142a\u015Bciwo\u015Bci +allOf = musi by\u0107 poprawny dla wszystkich schematów {0} +anyOf = musi by\u0107 poprawny dla dowolnego schematu {0} +const = musi by\u0107 sta\u0142\u0105 warto\u015Bci\u0105 \u201E{0}\u201D +contains = nie zawiera elementu, który przechodzi te weryfikacje: {1} +contains.max = musi zawiera\u0107 maksymalnie {0} elementów, które przechodz\u0105 t\u0119 weryfikacj\u0119: {1} +contains.min = musi zawiera\u0107 co najmniej {0} elementów, które przechodz\u0105 t\u0119 weryfikacj\u0119: {1} +dependencies = zawiera b\u0142\u0105d z zale\u017Cno\u015Bciami {0} +dependentRequired = ma brakuj\u0105c\u0105 w\u0142a\u015Bciwo\u015B\u0107 \u201E{0}\u201D, która jest zale\u017Cna i wymagana, poniewa\u017C wyst\u0119puje \u201E{1}\u201D +dependentSchemas = zawiera b\u0142\u0105d w schematach zale\u017Cnych {0} +enum = nie ma warto\u015Bci w wyliczeniu {0} +exclusiveMaximum = musi mie\u0107 wy\u0142\u0105czn\u0105 warto\u015B\u0107 maksymaln\u0105 wynosz\u0105c\u0105 {0} +exclusiveMinimum = musi mie\u0107 wy\u0142\u0105czn\u0105 minimaln\u0105 warto\u015B\u0107 {0} +false = schemat dla \u201E{0}\u201D jest fa\u0142szywy +format = nie pasuje do wzorca {0} {1} +format.date = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 pe\u0142n\u0105 dat\u0105 RFC 3339 +format.date-time = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 dat\u0105 i godzin\u0105 RFC 3339 +format.duration = nie pasuje do wzorca {0}, musi mie\u0107 prawid\u0142owy czas trwania ISO 8601 +format.email = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 skrzynk\u0105 pocztow\u0105 RFC 5321 +format.ipv4 = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym adresem IP RFC 2673 +format.ipv6 = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym adresem IP RFC 4291 +format.idn-email = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 skrzynk\u0105 pocztow\u0105 RFC 6531 +format.idn-hostname = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 mi\u0119dzynarodow\u0105 nazw\u0105 hosta zgodn\u0105 z RFC 5890 +format.iri = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym IRI RFC 3987 +format.iri-reference = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym odwo\u0142aniem IRI RFC 3987 +format.uri = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym identyfikatorem URI RFC 3986 +format.uri-reference = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym odwo\u0142aniem URI RFC 3986 +format.uri-template = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym szablonem URI RFC 6570 +format.uuid = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym identyfikatorem UUID RFC 4122 +format.regex = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym wyra\u017Ceniem regularnym ECMA-262 +format.time = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym czasem RFC 3339 +format.hostname = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 nazw\u0105 hosta zgodn\u0105 z RFC 1123 +format.json-pointer = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym wska\u017Anikiem JSON RFC 6901 +format.relative-json-pointer = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142owym wzgl\u0119dnym wska\u017Anikiem JSON IETF +format.unknown = ma nieznany format \u201E{0}\u201D +id = \u201E{0}\u201D nie jest prawid\u0142owym {1} +items = indeks ''{0}'' nie jest zdefiniowany w schemacie i schemat nie pozwala na dodatkowe elementy +maxContains = musi by\u0107 nieujemn\u0105 liczb\u0105 ca\u0142kowit\u0105 w {0} +maxItems = musi mie\u0107 co najwy\u017Cej {0} elementów, ale znaleziono {1} +maxLength = musi mie\u0107 maksymalnie {0} znaków +maxProperties = musi mie\u0107 co najwy\u017Cej {0} w\u0142a\u015Bciwo\u015Bci +maximum = musi mie\u0107 maksymaln\u0105 warto\u015B\u0107 {0} +minContains = musi by\u0107 nieujemn\u0105 liczb\u0105 ca\u0142kowit\u0105 w {0} +minContainsVsMaxContains = minContains musi by\u0107 mniejsze lub równe maxContains w {0} +minItems = musi mie\u0107 co najmniej {0} elementów, ale znaleziono {1} +minLength = musi mie\u0107 co najmniej {0} znaków +minProperties = musi mie\u0107 co najmniej {0} w\u0142a\u015Bciwo\u015Bci +minimum = musi mie\u0107 minimaln\u0105 warto\u015B\u0107 {0} +multipleOf = musi by\u0107 wielokrotno\u015Bci\u0105 {0} +not = nie mo\u017Ce by\u0107 poprawny dla schematu {0} +notAllowed = w\u0142a\u015Bciwo\u015B\u0107 \u201E{0}\u201D jest niedozwolona, ale znajduje si\u0119 w danych +oneOf = musi by\u0107 poprawny dla jednego i tylko jednego schematu, ale {0} s\u0105 prawid\u0142owe +oneOf.indexes = musi by\u0107 poprawny dla jednego i tylko jednego schematu, ale {0} jest prawid\u0142owe z indeksami \u201E{1}\u201D +pattern = nie pasuje do wzorca wyra\u017Cenia regularnego {0} +patternProperties = zawiera b\u0142\u0105d dotycz\u0105cy \u201Ew\u0142a\u015Bciwo\u015Bci wzorca\u201D +prefixItems = w tym indeksie nie znaleziono walidatora +properties = zawiera b\u0142\u0105d dotycz\u0105cy \u201Ew\u0142a\u015Bciwo\u015Bci\u201D +propertyNames = nazwa w\u0142a\u015Bciwo\u015Bci \u201E{0}\u201D jest nieprawid\u0142owa: {1} +readOnly = jest polem tylko do odczytu, nie mo\u017Cna go zmieni\u0107 +required = nie znaleziono wymaganej w\u0142a\u015Bciwo\u015Bci \u201E{0}\u201D. +type = Znaleziono {0}, oczekiwano {1} +unevaluatedItems = indeks \u201E{0}\u201D nie jest oceniany i schemat nie pozwala na nieocenione elementy +unevaluatedProperties = w\u0142a\u015Bciwo\u015B\u0107 \u201E{0}\u201D nie jest oceniana i schemat nie pozwala na nieocenione w\u0142a\u015Bciwo\u015Bci +unionType = Znaleziono {0}, oczekiwano {1} +uniqueItems = tablica musi zawiera\u0107 tylko unikalne elementy +writeOnly = jest polem tylko do zapisu, nie mo\u017Ce pojawia\u0107 si\u0119 w danych +contentEncoding = nie pasuje do kodowania tre\u015Bci {0} +contentMediaType = nie jest tre\u015Bci\u0105 diff --git a/src/main/resources/jsv-messages_pt.properties b/src/main/resources/jsv-messages_pt.properties index ae3ebc145..c3dedcbe2 100644 --- a/src/main/resources/jsv-messages_pt.properties +++ b/src/main/resources/jsv-messages_pt.properties @@ -1,70 +1,70 @@ -$ref = {0}: tem um erro com ''refs'' -additionalItems = {0}: o índice ''{1}'' não está definido no esquema e o esquema não permite itens adicionais -additionalProperties = {0}: a propriedade ''{1}'' não está definida no esquema e o esquema não permite propriedades adicionais -allOf = {0}: deve ser válido para todos os esquemas {1} -anyOf = {0}: deve ser válido para qualquer um dos esquemas {1} -const = {0}: deve ser o valor constante ''{1}'' -contains = {0}: não contém um elemento que passe nestas validações: {2} -contains.max = {0}: deve conter no máximo {1} elemento(s) que passe(m) nestas validações: {2} -contains.min = {0}: deve conter pelo menos {1} elemento(s) que passe(m) nestas validações: {2} -dependencies = {0}: há um erro com dependências {1} -dependentRequired = {0}: tem uma propriedade ausente ''{1}'' que é dependente necessária porque ''{2}'' está presente -dependentSchemas = {0}: há um erro com dependenteSchemas {1} -enum = {0}: não possui valor na enumeração {1} -exclusiveMaximum = {0}: deve ter um valor máximo exclusivo de {1} -exclusiveMinimum = {0}: deve ter um valor mínimo exclusivo de {1} -false = {0}: o esquema para ''{1}'' é falso -format = {0}: não corresponde ao padrão {1} {2} -format.date = {0}: não corresponde ao padrão {1} deve ser uma data completa RFC 3339 válida -format.date-time = {0}: não corresponde ao padrão {1} deve ser uma data e hora RFC 3339 válida -format.duration = {0}: não corresponde ao padrão {1} deve ter uma duração ISO 8601 válida -format.email = {0}: não corresponde ao padrão {1} deve ser uma caixa de correio RFC 5321 válida -format.ipv4 = {0}: não corresponde ao padrão {1} deve ser um endereço IP RFC 2673 válido -format.ipv6 = {0}: não corresponde ao padrão {1} deve ser um endereço IP RFC 4291 válido -format.idn-email = {0}: não corresponde ao padrão {1} deve ser uma caixa de correio RFC 6531 válida -format.idn-hostname = {0}: não corresponde ao padrão {1} deve ser um nome de host internacionalizado RFC 5890 válido -format.iri = {0}: não corresponde ao padrão {1} deve ser um RFC 3987 IRI válido -format.iri-reference = {0}: não corresponde ao padrão {1} deve ser uma referência IRI RFC 3987 válida -format.uri = {0}: não corresponde ao padrão {1} deve ser um URI RFC 3986 válido -format.uri-reference = {0}: não corresponde ao padrão {1} deve ser uma referência de URI RFC 3986 válida -format.uri-template = {0}: não corresponde ao padrão {1} deve ser um modelo de URI RFC 6570 válido -format.uuid = {0}: não corresponde ao padrão {1} deve ser um UUID RFC 4122 válido -format.regex = {0}: não corresponde ao padrão {1} deve ser uma expressão regular ECMA-262 válida -format.time = {0}: não corresponde ao padrão {1} deve ser um horário RFC 3339 válido -format.hostname = {0}: não corresponde ao padrão {1} deve ser um nome de host RFC 1123 válido -format.json-pointer = {0}: não corresponde ao padrão {1} deve ser um ponteiro JSON RFC 6901 válido -format.relative-json-pointer = {0}: não corresponde ao padrão {1} deve ser um ponteiro JSON relativo IETF válido -format.unknown = {0}: tem um formato desconhecido ''{1}'' -id = {0}: ''{1}'' não é um {2} válido -items = {0}: o índice ''{1}'' não está definido no esquema e o esquema não permite itens adicionais -maxContains = {0}: deve ser um número inteiro não negativo em {1} -maxItems = {0}: deve ter no máximo {1} itens, mas foram encontrados {2} -maxLength = {0}: deve ter no máximo {1} caracteres -maxProperties = {0}: deve ter no máximo {1} propriedades -maximum = {0}: deve ter um valor máximo de {1} -minContains = {0}: deve ser um número inteiro não negativo em {1} -minContainsVsMaxContains = {0}: minContains deve ser menor ou igual a maxContains em {1} -minItems = {0}: deve ter pelo menos {1} itens, mas foi encontrado {2} -minLength = {0}: deve ter pelo menos {1} caracteres -minProperties = {0}: deve ter pelo menos {1} propriedades -minimum = {0}: deve ter um valor mínimo de {1} -multipleOf = {0}: deve ser múltiplo de {1} -not = {0}: não deve ser válido para o esquema {1} -notAllowed = {0}: propriedade ''{1}'' não é permitida, mas está nos dados -oneOf = {0}: deve ser válido para um e apenas um esquema, mas {1} são válidos -oneOf.indexes = {0}: deve ser válido para um e somente um esquema, mas {1} são válidos com índices ''{2}'' -pattern = {0}: não corresponde ao padrão regex {1} -patternProperties = {0}: há algum erro com ''propriedades do padrão'' -prefixItems = {0}: nenhum validador encontrado neste índice -properties = {0}: há um erro com ''propriedades'' -propertyNames = {0}: o nome da propriedade ''{1}'' não é válido: {2} -readOnly = {0}: é um campo somente leitura, não pode ser alterado -required = {0}: propriedade obrigatória ''{1}'' não encontrada -type = {0}: {1} encontrado, {2} esperado -unevaluatedItems = {0}: o índice ''{1}'' não é avaliado e o esquema não permite itens não avaliados -unevaluatedProperties = {0}: a propriedade ''{1}'' não foi avaliada e o esquema não permite propriedades não avaliadas -unionType = {0}: {1} encontrado, {2} esperado -uniqueItems = {0}: deve ter apenas itens únicos no array -writeOnly = {0}: é um campo somente gravação, não pode aparecer nos dados -contentEncoding = {0}: não corresponde à codificação de conteúdo {1} -contentMediaType = {0}: não é um conteúdo para mim +$ref = tem um erro com ''refs'' +additionalItems = o índice ''{0}'' não está definido no esquema e o esquema não permite itens adicionais +additionalProperties = a propriedade ''{0}'' não está definida no esquema e o esquema não permite propriedades adicionais +allOf = deve ser válido para todos os esquemas {0} +anyOf = deve ser válido para qualquer um dos esquemas {0} +const = deve ser o valor constante ''{0}'' +contains = não contém um elemento que passe nestas validações: {1} +contains.max = deve conter no máximo {0} elemento(s) que passe(m) nestas validações: {1} +contains.min = deve conter pelo menos {0} elemento(s) que passe(m) nestas validações: {1} +dependencies = há um erro com dependências {0} +dependentRequired = tem uma propriedade ausente ''{0}'' que é dependente necessária porque ''{1}'' está presente +dependentSchemas = há um erro com dependenteSchemas {0} +enum = não possui valor na enumeração {0} +exclusiveMaximum = deve ter um valor máximo exclusivo de {0} +exclusiveMinimum = deve ter um valor mínimo exclusivo de {0} +false = o esquema para ''{0}'' é falso +format = não corresponde ao padrão {0} {1} +format.date = não corresponde ao padrão {0} deve ser uma data completa RFC 3339 válida +format.date-time = não corresponde ao padrão {0} deve ser uma data e hora RFC 3339 válida +format.duration = não corresponde ao padrão {0} deve ter uma duração ISO 8601 válida +format.email = não corresponde ao padrão {0} deve ser uma caixa de correio RFC 5321 válida +format.ipv4 = não corresponde ao padrão {0} deve ser um endereço IP RFC 2673 válido +format.ipv6 = não corresponde ao padrão {0} deve ser um endereço IP RFC 4291 válido +format.idn-email = não corresponde ao padrão {0} deve ser uma caixa de correio RFC 6531 válida +format.idn-hostname = não corresponde ao padrão {0} deve ser um nome de host internacionalizado RFC 5890 válido +format.iri = não corresponde ao padrão {0} deve ser um RFC 3987 IRI válido +format.iri-reference = não corresponde ao padrão {0} deve ser uma referência IRI RFC 3987 válida +format.uri = não corresponde ao padrão {0} deve ser um URI RFC 3986 válido +format.uri-reference = não corresponde ao padrão {0} deve ser uma referência de URI RFC 3986 válida +format.uri-template = não corresponde ao padrão {0} deve ser um modelo de URI RFC 6570 válido +format.uuid = não corresponde ao padrão {0} deve ser um UUID RFC 4122 válido +format.regex = não corresponde ao padrão {0} deve ser uma expressão regular ECMA-262 válida +format.time = não corresponde ao padrão {0} deve ser um horário RFC 3339 válido +format.hostname = não corresponde ao padrão {0} deve ser um nome de host RFC 1123 válido +format.json-pointer = não corresponde ao padrão {0} deve ser um ponteiro JSON RFC 6901 válido +format.relative-json-pointer = não corresponde ao padrão {0} deve ser um ponteiro JSON relativo IETF válido +format.unknown = tem um formato desconhecido ''{0}'' +id = ''{0}'' não é um {1} válido +items = o índice ''{0}'' não está definido no esquema e o esquema não permite itens adicionais +maxContains = deve ser um número inteiro não negativo em {0} +maxItems = deve ter no máximo {0} itens, mas foram encontrados {1} +maxLength = deve ter no máximo {0} caracteres +maxProperties = deve ter no máximo {0} propriedades +maximum = deve ter um valor máximo de {0} +minContains = deve ser um número inteiro não negativo em {0} +minContainsVsMaxContains = minContains deve ser menor ou igual a maxContains em {0} +minItems = deve ter pelo menos {0} itens, mas foi encontrado {1} +minLength = deve ter pelo menos {0} caracteres +minProperties = deve ter pelo menos {0} propriedades +minimum = deve ter um valor mínimo de {0} +multipleOf = deve ser múltiplo de {0} +not = não deve ser válido para o esquema {0} +notAllowed = propriedade ''{0}'' não é permitida, mas está nos dados +oneOf = deve ser válido para um e apenas um esquema, mas {0} são válidos +oneOf.indexes = deve ser válido para um e somente um esquema, mas {0} são válidos com índices ''{1}'' +pattern = não corresponde ao padrão regex {0} +patternProperties = há algum erro com ''propriedades do padrão'' +prefixItems = nenhum validador encontrado neste índice +properties = há um erro com ''propriedades'' +propertyNames = o nome da propriedade ''{0}'' não é válido: {1} +readOnly = é um campo somente leitura, não pode ser alterado +required = propriedade obrigatória ''{0}'' não encontrada +type = {0} encontrado, {1} esperado +unevaluatedItems = o índice ''{0}'' não é avaliado e o esquema não permite itens não avaliados +unevaluatedProperties = a propriedade ''{0}'' não foi avaliada e o esquema não permite propriedades não avaliadas +unionType = {0} encontrado, {1} esperado +uniqueItems = deve ter apenas itens únicos no array +writeOnly = é um campo somente gravação, não pode aparecer nos dados +contentEncoding = não corresponde à codificação de conteúdo {0} +contentMediaType = não é um conteúdo para mim diff --git a/src/main/resources/jsv-messages_ro.properties b/src/main/resources/jsv-messages_ro.properties index 3ade90c74..c0978f555 100644 --- a/src/main/resources/jsv-messages_ro.properties +++ b/src/main/resources/jsv-messages_ro.properties @@ -1,70 +1,70 @@ -$ref = {0}: are o eroare cu \u201Erefs\u201D -additionalItems = {0}: indexul \u201E{1}\u201D nu este definit în schem\u0103, iar schema nu permite elemente suplimentare -additionalProperties = {0}: proprietatea \u201E{1}\u201D nu este definit\u0103 în schem\u0103, iar schema nu permite propriet\u0103\u021Bi suplimentare -allOf = {0}: trebuie s\u0103 fie valid pentru toate schemele {1} -anyOf = {0}: trebuie s\u0103 fie valid pentru oricare dintre schemele {1} -const = {0}: trebuie s\u0103 fie valoarea constant\u0103 \u201E{1}\u201D -contains = {0}: nu con\u0163ine un element care trece aceste valid\u0103ri: {2} -contains.max = {0}: trebuie s\u0103 con\u021Bin\u0103 cel mult {1} element(e) care trece aceste valid\u0103ri: {2} -contains.min = {0}: trebuie s\u0103 con\u021Bin\u0103 cel pu\u021Bin {1} element(e) care trece aceste valid\u0103ri: {2} -dependencies = {0}: are o eroare cu dependen\u021Bele {1} -dependentRequired = {0}: are o proprietate lips\u0103 ''{1}'' care este dependent\u0103 necesar\u0103 deoarece ''{2}'' este prezent -dependentSchemas = {0}: are o eroare cu dependentSchemas {1} -enum = {0}: nu are o valoare în enumerarea {1} -exclusiveMaximum = {0}: trebuie s\u0103 aib\u0103 o valoare maxim\u0103 exclusiv\u0103 de {1} -exclusiveMinimum = {0}: trebuie s\u0103 aib\u0103 o valoare minim\u0103 exclusiv\u0103 de {1} -false = {0}: schema pentru \u201E{1}\u201D este fals\u0103 -format = {0}: nu se potrive\u0219te cu modelul {1} {2} -format.date = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o dat\u0103 complet\u0103 RFC 3339 valid\u0103 -format.date-time = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un RFC 3339 data-ora valid -format.duration = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o durat\u0103 ISO 8601 valid\u0103 -format.email = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o cutie po\u0219tal\u0103 RFC 5321 valid\u0103 -format.ipv4 = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o adres\u0103 IP RFC 2673 valid\u0103 -format.ipv6 = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o adres\u0103 IP RFC 4291 valid\u0103 -format.idn-email = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o cutie po\u0219tal\u0103 RFC 6531 valid\u0103 -format.idn-hostname = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un nume de gazd\u0103 interna\u021Bionalizat RFC 5890 valid -format.iri = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un RFC 3987 IRI valid -format.iri-reference = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o referin\u021B\u0103 IRI RFC 3987 valid\u0103 -format.uri = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un URI RFC 3986 valid -format.uri-reference = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o referin\u021B\u0103 URI RFC 3986 valid\u0103 -format.uri-template = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un \u0219ablon URI RFC 6570 valid -format.uuid = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un UUID RFC 4122 valid -format.regex = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie o expresie regulat\u0103 ECMA-262 valid\u0103 -format.time = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un timp RFC 3339 valid -format.hostname = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un nume de gazd\u0103 RFC 1123 valid -format.json-pointer = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un pointer JSON RFC 6901 valid -format.relative-json-pointer = {0}: nu se potrive\u0219te cu modelul {1} trebuie s\u0103 fie un pointer JSON relativ IETF valid -format.unknown = {0}: are un format necunoscut ''{1}'' -id = {0}: \u201E{1}\u201D nu este un {2} valid -items = {0}: indexul \u201E{1}\u201D nu este definit în schem\u0103, iar schema nu permite articole suplimentare -maxContains = {0}: trebuie s\u0103 fie un num\u0103r întreg nenegativ în {1} -maxItems = {0}: trebuie s\u0103 aib\u0103 cel mult {1} articole, dar g\u0103site {2} -maxLength = {0}: trebuie s\u0103 aib\u0103 cel mult {1} caractere -maxProperties = {0}: trebuie s\u0103 aib\u0103 cel mult {1} propriet\u0103\u021Bi -maximum = {0}: trebuie s\u0103 aib\u0103 o valoare maxim\u0103 de {1} -minContains = {0}: trebuie s\u0103 fie un num\u0103r întreg nenegativ în {1} -minContainsVsMaxContains = {0}: minContains trebuie s\u0103 fie mai mic sau egal cu maxContains în {1} -minItems = {0}: trebuie s\u0103 aib\u0103 cel pu\u021Bin {1} articole, dar g\u0103site {2} -minLength = {0}: trebuie s\u0103 aib\u0103 cel pu\u021Bin {1} caractere -minProperties = {0}: trebuie s\u0103 aib\u0103 cel pu\u021Bin {1} propriet\u0103\u021Bi -minimum = {0}: trebuie s\u0103 aib\u0103 o valoare minim\u0103 de {1} -multipleOf = {0}: trebuie s\u0103 fie multiplu de {1} -not = {0}: nu trebuie s\u0103 fie valid pentru schema {1} -notAllowed = {0}: proprietatea \u201E{1}\u201D nu este permis\u0103, dar este în date -oneOf = {0}: trebuie s\u0103 fie valid pentru una \u0219i doar o schem\u0103, dar {1} sunt valide -oneOf.indexes = {0}: trebuie s\u0103 fie valid pentru una \u0219i doar o schem\u0103, dar {1} sunt valide cu indec\u0219ii \u201E{2}\u201D -pattern = {0}: nu se potrive\u0219te cu modelul regex {1} -patternProperties = {0}: are o eroare cu \u201Epropriet\u0103\u021Bile modelului\u201D -prefixItems = {0}: nu a fost g\u0103sit niciun validator la acest index -properties = {0}: are o eroare cu \u201Epropriet\u0103\u021Bi\u201D -propertyNames = {0}: numele propriet\u0103\u021Bii \u201E{1}\u201D nu este valid: {2} -readOnly = {0}: este un câmp numai în citire, nu poate fi modificat -required = {0}: proprietatea obligatorie \u201E{1}\u201D nu a fost g\u0103sit\u0103 -type = {0}: {1} g\u0103sit, {2} a\u0219teptat -unevaluatedItems = {0}: indexul \u201E{1}\u201D nu este evaluat \u0219i schema nu permite elemente neevaluate -unevaluatedProperties = {0}: proprietatea \u201E{1}\u201D nu este evaluat\u0103 \u0219i schema nu permite propriet\u0103\u021Bi neevaluate -unionType = {0}: {1} g\u0103sit, {2} a\u0219teptat -uniqueItems = {0}: trebuie s\u0103 aib\u0103 numai elemente unice în matrice -writeOnly = {0}: este un câmp numai pentru scriere, nu poate ap\u0103rea în date -contentEncoding = {0}: nu se potrive\u0219te cu codificarea con\u021Binutului {1} -contentMediaType = {0}: nu este un con\u021Binut eu +$ref = are o eroare cu \u201Erefs\u201D +additionalItems = indexul \u201E{0}\u201D nu este definit în schem\u0103, iar schema nu permite elemente suplimentare +additionalProperties = proprietatea \u201E{0}\u201D nu este definit\u0103 în schem\u0103, iar schema nu permite propriet\u0103\u021Bi suplimentare +allOf = trebuie s\u0103 fie valid pentru toate schemele {0} +anyOf = trebuie s\u0103 fie valid pentru oricare dintre schemele {0} +const = trebuie s\u0103 fie valoarea constant\u0103 \u201E{0}\u201D +contains = nu con\u0163ine un element care trece aceste valid\u0103ri: {1} +contains.max = trebuie s\u0103 con\u021Bin\u0103 cel mult {0} element(e) care trece aceste valid\u0103ri: {1} +contains.min = trebuie s\u0103 con\u021Bin\u0103 cel pu\u021Bin {0} element(e) care trece aceste valid\u0103ri: {1} +dependencies = are o eroare cu dependen\u021Bele {0} +dependentRequired = are o proprietate lips\u0103 ''{0}'' care este dependent\u0103 necesar\u0103 deoarece ''{1}'' este prezent +dependentSchemas = are o eroare cu dependentSchemas {0} +enum = nu are o valoare în enumerarea {0} +exclusiveMaximum = trebuie s\u0103 aib\u0103 o valoare maxim\u0103 exclusiv\u0103 de {0} +exclusiveMinimum = trebuie s\u0103 aib\u0103 o valoare minim\u0103 exclusiv\u0103 de {0} +false = schema pentru \u201E{0}\u201D este fals\u0103 +format = nu se potrive\u0219te cu modelul {0} {1} +format.date = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o dat\u0103 complet\u0103 RFC 3339 valid\u0103 +format.date-time = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un RFC 3339 data-ora valid +format.duration = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o durat\u0103 ISO 8601 valid\u0103 +format.email = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o cutie po\u0219tal\u0103 RFC 5321 valid\u0103 +format.ipv4 = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o adres\u0103 IP RFC 2673 valid\u0103 +format.ipv6 = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o adres\u0103 IP RFC 4291 valid\u0103 +format.idn-email = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o cutie po\u0219tal\u0103 RFC 6531 valid\u0103 +format.idn-hostname = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un nume de gazd\u0103 interna\u021Bionalizat RFC 5890 valid +format.iri = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un RFC 3987 IRI valid +format.iri-reference = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o referin\u021B\u0103 IRI RFC 3987 valid\u0103 +format.uri = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un URI RFC 3986 valid +format.uri-reference = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o referin\u021B\u0103 URI RFC 3986 valid\u0103 +format.uri-template = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un \u0219ablon URI RFC 6570 valid +format.uuid = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un UUID RFC 4122 valid +format.regex = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o expresie regulat\u0103 ECMA-262 valid\u0103 +format.time = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un timp RFC 3339 valid +format.hostname = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un nume de gazd\u0103 RFC 1123 valid +format.json-pointer = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un pointer JSON RFC 6901 valid +format.relative-json-pointer = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un pointer JSON relativ IETF valid +format.unknown = are un format necunoscut ''{0}'' +id = \u201E{0}\u201D nu este un {1} valid +items = indexul \u201E{0}\u201D nu este definit în schem\u0103, iar schema nu permite articole suplimentare +maxContains = trebuie s\u0103 fie un num\u0103r întreg nenegativ în {0} +maxItems = trebuie s\u0103 aib\u0103 cel mult {0} articole, dar g\u0103site {1} +maxLength = trebuie s\u0103 aib\u0103 cel mult {0} caractere +maxProperties = trebuie s\u0103 aib\u0103 cel mult {0} propriet\u0103\u021Bi +maximum = trebuie s\u0103 aib\u0103 o valoare maxim\u0103 de {0} +minContains = trebuie s\u0103 fie un num\u0103r întreg nenegativ în {0} +minContainsVsMaxContains = minContains trebuie s\u0103 fie mai mic sau egal cu maxContains în {0} +minItems = trebuie s\u0103 aib\u0103 cel pu\u021Bin {0} articole, dar g\u0103site {1} +minLength = trebuie s\u0103 aib\u0103 cel pu\u021Bin {0} caractere +minProperties = trebuie s\u0103 aib\u0103 cel pu\u021Bin {0} propriet\u0103\u021Bi +minimum = trebuie s\u0103 aib\u0103 o valoare minim\u0103 de {0} +multipleOf = trebuie s\u0103 fie multiplu de {0} +not = nu trebuie s\u0103 fie valid pentru schema {0} +notAllowed = proprietatea \u201E{0}\u201D nu este permis\u0103, dar este în date +oneOf = trebuie s\u0103 fie valid pentru una \u0219i doar o schem\u0103, dar {0} sunt valide +oneOf.indexes = trebuie s\u0103 fie valid pentru una \u0219i doar o schem\u0103, dar {0} sunt valide cu indec\u0219ii \u201E{1}\u201D +pattern = nu se potrive\u0219te cu modelul regex {0} +patternProperties = are o eroare cu \u201Epropriet\u0103\u021Bile modelului\u201D +prefixItems = nu a fost g\u0103sit niciun validator la acest index +properties = are o eroare cu \u201Epropriet\u0103\u021Bi\u201D +propertyNames = numele propriet\u0103\u021Bii \u201E{0}\u201D nu este valid: {1} +readOnly = este un câmp numai în citire, nu poate fi modificat +required = proprietatea obligatorie \u201E{0}\u201D nu a fost g\u0103sit\u0103 +type = {0} g\u0103sit, {1} a\u0219teptat +unevaluatedItems = indexul \u201E{0}\u201D nu este evaluat \u0219i schema nu permite elemente neevaluate +unevaluatedProperties = proprietatea \u201E{0}\u201D nu este evaluat\u0103 \u0219i schema nu permite propriet\u0103\u021Bi neevaluate +unionType = {0} g\u0103sit, {1} a\u0219teptat +uniqueItems = trebuie s\u0103 aib\u0103 numai elemente unice în matrice +writeOnly = este un câmp numai pentru scriere, nu poate ap\u0103rea în date +contentEncoding = nu se potrive\u0219te cu codificarea con\u021Binutului {0} +contentMediaType = nu este un con\u021Binut eu diff --git a/src/main/resources/jsv-messages_ru.properties b/src/main/resources/jsv-messages_ru.properties index 2ea8b4ef4..23c171413 100644 --- a/src/main/resources/jsv-messages_ru.properties +++ b/src/main/resources/jsv-messages_ru.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441 «refs». -additionalItems = {0}: \u0438\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. -additionalProperties = {0}: \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{1}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u0441\u0432\u043E\u0439\u0441\u0442\u0432. -allOf = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u0432\u0441\u0435\u0445 \u0441\u0445\u0435\u043C {1}. -anyOf = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043B\u044E\u0431\u043E\u0439 \u0438\u0437 \u0441\u0445\u0435\u043C {1}. -const = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043F\u043E\u0441\u0442\u043E\u044F\u043D\u043D\u044B\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435\u043C ''{1}'' -contains = {0}: \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442 \u044D\u0442\u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {2} -contains.max = {0}: \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {1} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043F\u0440\u043E\u0448\u0435\u0434\u0448\u0438\u0445 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {2} -contains.min = {0}: \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043A\u0430\u043A \u043C\u0438\u043D\u0438\u043C\u0443\u043C {1} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043F\u0440\u043E\u0448\u0435\u0434\u0448\u0438\u0445 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {2} -dependencies = {0}: \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044F\u043C\u0438 {1}. -dependentRequired = {0}: \u0438\u043C\u0435\u0435\u0442 \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044E\u0449\u0435\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{1}'', \u043A\u043E\u0442\u043E\u0440\u043E\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u043C, \u043F\u043E\u0441\u043A\u043E\u043B\u044C\u043A\u0443 \u043F\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 ''{2}''. -dependentSchemas = {0}: \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441dependentSchemas {1}. -enum = {0}: \u043D\u0435 \u0438\u043C\u0435\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F \u0432 \u043F\u0435\u0440\u0435\u0447\u0438\u0441\u043B\u0435\u043D\u0438\u0438 {1} -exclusiveMaximum = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u044D\u043A\u0441\u043A\u043B\u044E\u0437\u0438\u0432\u043D\u043E\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {1}. -exclusiveMinimum = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u0438\u0441\u043A\u043B\u044E\u0447\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {1}. -false = {0}: \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{1}'' \u043D\u0435\u0432\u0435\u0440\u043D\u0430 -format = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} {2} -format.date = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u043E\u043B\u043D\u0430\u044F \u0434\u0430\u0442\u0430 RFC 3339. -format.date-time = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u0430\u044F \u0434\u0430\u0442\u0430-\u0432\u0440\u0435\u043C\u044F RFC 3339. -format.duration = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C ISO 8601. -format.email = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u043F\u043E\u0447\u0442\u043E\u0432\u044B\u043C \u044F\u0449\u0438\u043A\u043E\u043C RFC 5321. -format.ipv4 = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IP-\u0430\u0434\u0440\u0435\u0441\u043E\u043C RFC 2673. -format.ipv6 = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IP-\u0430\u0434\u0440\u0435\u0441\u043E\u043C RFC 4291. -format.idn-email = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u043F\u043E\u0447\u0442\u043E\u0432\u044B\u043C \u044F\u0449\u0438\u043A\u043E\u043C RFC 6531. -format.idn-hostname = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0438\u043D\u0442\u0435\u0440\u043D\u0430\u0446\u0438\u043E\u043D\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u043C \u0438\u043C\u0435\u043D\u0435\u043C \u0445\u043E\u0441\u0442\u0430 RFC 5890. -format.iri = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IRI RFC 3987. -format.iri-reference = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0439 \u0441\u0441\u044B\u043B\u043A\u043E\u0439 RFC 3987 IRI. -format.uri = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C URI RFC 3986. -format.uri-reference = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0439 \u0441\u0441\u044B\u043B\u043A\u043E\u0439 URI RFC 3986. -format.uri-template = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C URI RFC 6570. -format.uuid = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C UUID RFC 4122. -format.regex = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u044B\u043C \u0432\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435\u043C ECMA-262. -format.time = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0432\u0440\u0435\u043C\u044F RFC 3339. -format.hostname = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0438\u043C\u0435\u043D\u0435\u043C \u0445\u043E\u0441\u0442\u0430 RFC 1123. -format.json-pointer = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0443\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u0435\u043C JSON RFC 6901. -format.relative-json-pointer = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0443\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u0435\u043C JSON IETF -format.unknown = {0}: \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 ''{1}'' -id = {0}: ''{1}'' \u043D\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C {2} -items = {0}: \u0438\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. -maxContains = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435\u043E\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0446\u0435\u043B\u044B\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0432 {1}. -maxItems = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {1} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043D\u043E \u043D\u0430\u0439\u0434\u0435\u043D\u043E {2} -maxLength = {0}: \u0434\u043B\u0438\u043D\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {1} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432. -maxProperties = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {1} \u0441\u0432\u043E\u0439\u0441\u0442\u0432. -maximum = {0}: \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C {1}. -minContains = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435\u043E\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0446\u0435\u043B\u044B\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0432 {1}. -minContainsVsMaxContains = {0}: minContains \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043C\u0435\u043D\u044C\u0448\u0435 \u0438\u043B\u0438 \u0440\u0430\u0432\u043D\u043E maxContains \u0432 {1}. -minItems = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {1} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043D\u043E \u043D\u0430\u0439\u0434\u0435\u043D\u043E {2} -minLength = {0}: \u0434\u043B\u0438\u043D\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {1} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432. -minProperties = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {1} \u0441\u0432\u043E\u0439\u0441\u0442\u0432. -minimum = {0}: \u043C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C {1}. -multipleOf = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u043E {1} -not = {0}: \u043D\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u0441\u0445\u0435\u043C\u044B {1} -notAllowed = {0}: \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{1}'' \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u043E, \u043D\u043E \u043E\u043D\u043E \u0435\u0441\u0442\u044C \u0432 \u0434\u0430\u043D\u043D\u044B\u0445 -oneOf = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043E\u0434\u043D\u043E\u0439 \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0434\u043D\u043E\u0439 \u0441\u0445\u0435\u043C\u044B, \u043D\u043E {1} \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E. -oneOf.indexes = {0}: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043E\u0434\u043D\u043E\u0439 \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0434\u043D\u043E\u0439 \u0441\u0445\u0435\u043C\u044B, \u043D\u043E {1} \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0441 \u0438\u043D\u0434\u0435\u043A\u0441\u0430\u043C\u0438 ''{2}'' -pattern = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u043E\u0433\u043E \u0432\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u044F {1} -patternProperties = {0}: \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043D\u0435\u043A\u043E\u0442\u043E\u0440\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E «\u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430\u043C\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0430». -prefixItems = {0}: \u043F\u043E \u044D\u0442\u043E\u043C\u0443 \u0438\u043D\u0434\u0435\u043A\u0441\u0443 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432\u0430\u043B\u0438\u0434\u0430\u0442\u043E\u0440 -properties = {0}: \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430\u043C\u0438. -propertyNames = {0}: \u0438\u043C\u044F \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430 ''{1}'' \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E: {2} -readOnly = {0}: \u043F\u043E\u043B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0447\u0442\u0435\u043D\u0438\u044F, \u0435\u0433\u043E \u043D\u0435\u043B\u044C\u0437\u044F \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C. -required = {0}: \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{1}'' \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E -type = {0}: \u043D\u0430\u0439\u0434\u0435\u043D\u043E {1}, \u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F {2} -unevaluatedItems = {0}: \u0438\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u043E\u0446\u0435\u043D\u0438\u0432\u0430\u0435\u0442\u0441\u044F, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435\u043E\u0446\u0435\u043D\u0435\u043D\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. -unevaluatedProperties = {0}: \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{1}'' \u043D\u0435 \u043E\u0446\u0435\u043D\u0438\u0432\u0430\u0435\u0442\u0441\u044F, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435\u043E\u0446\u0435\u043D\u0435\u043D\u043D\u044B\u0445 \u0441\u0432\u043E\u0439\u0441\u0442\u0432. -unionType = {0}: \u043D\u0430\u0439\u0434\u0435\u043D\u043E {1}, \u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F {2} -uniqueItems = {0}: \u043C\u0430\u0441\u0441\u0438\u0432 \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B. -writeOnly = {0}: \u043F\u043E\u043B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438, \u043E\u043D\u043E \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u044C\u0441\u044F \u0432 \u0434\u0430\u043D\u043D\u044B\u0445. -contentEncoding = {0}: \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043A\u043E\u0434\u0438\u0440\u043E\u0432\u043A\u0435 \u043A\u043E\u043D\u0442\u0435\u043D\u0442\u0430 {1} -contentMediaType = {0}: \u043C\u0435\u043D\u044F \u043D\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 +$ref = \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441 «refs». +additionalItems = \u0438\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. +additionalProperties = \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{0}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u0441\u0432\u043E\u0439\u0441\u0442\u0432. +allOf = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u0432\u0441\u0435\u0445 \u0441\u0445\u0435\u043C {0}. +anyOf = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043B\u044E\u0431\u043E\u0439 \u0438\u0437 \u0441\u0445\u0435\u043C {0}. +const = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043F\u043E\u0441\u0442\u043E\u044F\u043D\u043D\u044B\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435\u043C ''{0}'' +contains = \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442 \u044D\u0442\u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {1} +contains.max = \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {0} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043F\u0440\u043E\u0448\u0435\u0434\u0448\u0438\u0445 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {1} +contains.min = \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043A\u0430\u043A \u043C\u0438\u043D\u0438\u043C\u0443\u043C {0} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043F\u0440\u043E\u0448\u0435\u0434\u0448\u0438\u0445 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: {1} +dependencies = \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044F\u043C\u0438 {0}. +dependentRequired = \u0438\u043C\u0435\u0435\u0442 \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044E\u0449\u0435\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{0}'', \u043A\u043E\u0442\u043E\u0440\u043E\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u043C, \u043F\u043E\u0441\u043A\u043E\u043B\u044C\u043A\u0443 \u043F\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 ''{1}''. +dependentSchemas = \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441dependentSchemas {0}. +enum = \u043D\u0435 \u0438\u043C\u0435\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F \u0432 \u043F\u0435\u0440\u0435\u0447\u0438\u0441\u043B\u0435\u043D\u0438\u0438 {0} +exclusiveMaximum = \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u044D\u043A\u0441\u043A\u043B\u044E\u0437\u0438\u0432\u043D\u043E\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {0}. +exclusiveMinimum = \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u0438\u0441\u043A\u043B\u044E\u0447\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {0}. +false = \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{0}'' \u043D\u0435\u0432\u0435\u0440\u043D\u0430 +format = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} {1} +format.date = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u043E\u043B\u043D\u0430\u044F \u0434\u0430\u0442\u0430 RFC 3339. +format.date-time = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u0430\u044F \u0434\u0430\u0442\u0430-\u0432\u0440\u0435\u043C\u044F RFC 3339. +format.duration = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C ISO 8601. +format.email = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u043F\u043E\u0447\u0442\u043E\u0432\u044B\u043C \u044F\u0449\u0438\u043A\u043E\u043C RFC 5321. +format.ipv4 = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IP-\u0430\u0434\u0440\u0435\u0441\u043E\u043C RFC 2673. +format.ipv6 = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IP-\u0430\u0434\u0440\u0435\u0441\u043E\u043C RFC 4291. +format.idn-email = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u043F\u043E\u0447\u0442\u043E\u0432\u044B\u043C \u044F\u0449\u0438\u043A\u043E\u043C RFC 6531. +format.idn-hostname = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0438\u043D\u0442\u0435\u0440\u043D\u0430\u0446\u0438\u043E\u043D\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u043C \u0438\u043C\u0435\u043D\u0435\u043C \u0445\u043E\u0441\u0442\u0430 RFC 5890. +format.iri = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C IRI RFC 3987. +format.iri-reference = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0439 \u0441\u0441\u044B\u043B\u043A\u043E\u0439 RFC 3987 IRI. +format.uri = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C URI RFC 3986. +format.uri-reference = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0439 \u0441\u0441\u044B\u043B\u043A\u043E\u0439 URI RFC 3986. +format.uri-template = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C URI RFC 6570. +format.uuid = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C UUID RFC 4122. +format.regex = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u044B\u043C \u0432\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435\u043C ECMA-262. +format.time = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0432\u0440\u0435\u043C\u044F RFC 3339. +format.hostname = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0438\u043C\u0435\u043D\u0435\u043C \u0445\u043E\u0441\u0442\u0430 RFC 1123. +format.json-pointer = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0443\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u0435\u043C JSON RFC 6901. +format.relative-json-pointer = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0443\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u0435\u043C JSON IETF +format.unknown = \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 ''{0}'' +id = ''{0}'' \u043D\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u043C {1} +items = \u0438\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D \u0432 \u0441\u0445\u0435\u043C\u0435, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. +maxContains = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435\u043E\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0446\u0435\u043B\u044B\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0432 {0}. +maxItems = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {0} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043D\u043E \u043D\u0430\u0439\u0434\u0435\u043D\u043E {1} +maxLength = \u0434\u043B\u0438\u043D\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {0} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432. +maxProperties = \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {0} \u0441\u0432\u043E\u0439\u0441\u0442\u0432. +maximum = \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C {0}. +minContains = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435\u043E\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u0446\u0435\u043B\u044B\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0432 {0}. +minContainsVsMaxContains = minContains \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043C\u0435\u043D\u044C\u0448\u0435 \u0438\u043B\u0438 \u0440\u0430\u0432\u043D\u043E maxContains \u0432 {0}. +minItems = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {0} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043D\u043E \u043D\u0430\u0439\u0434\u0435\u043D\u043E {1} +minLength = \u0434\u043B\u0438\u043D\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {0} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432. +minProperties = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {0} \u0441\u0432\u043E\u0439\u0441\u0442\u0432. +minimum = \u043C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C {0}. +multipleOf = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u043E {0} +not = \u043D\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u0441\u0445\u0435\u043C\u044B {0} +notAllowed = \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{0}'' \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u043E, \u043D\u043E \u043E\u043D\u043E \u0435\u0441\u0442\u044C \u0432 \u0434\u0430\u043D\u043D\u044B\u0445 +oneOf = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043E\u0434\u043D\u043E\u0439 \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0434\u043D\u043E\u0439 \u0441\u0445\u0435\u043C\u044B, \u043D\u043E {0} \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E. +oneOf.indexes = \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0434\u043B\u044F \u043E\u0434\u043D\u043E\u0439 \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0434\u043D\u043E\u0439 \u0441\u0445\u0435\u043C\u044B, \u043D\u043E {0} \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E \u0441 \u0438\u043D\u0434\u0435\u043A\u0441\u0430\u043C\u0438 ''{1}'' +pattern = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u043E\u0433\u043E \u0432\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u044F {0} +patternProperties = \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043D\u0435\u043A\u043E\u0442\u043E\u0440\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E «\u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430\u043C\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0430». +prefixItems = \u043F\u043E \u044D\u0442\u043E\u043C\u0443 \u0438\u043D\u0434\u0435\u043A\u0441\u0443 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432\u0430\u043B\u0438\u0434\u0430\u0442\u043E\u0440 +properties = \u0438\u043C\u0435\u0435\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430\u043C\u0438. +propertyNames = \u0438\u043C\u044F \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430 ''{0}'' \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E: {1} +readOnly = \u043F\u043E\u043B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0447\u0442\u0435\u043D\u0438\u044F, \u0435\u0433\u043E \u043D\u0435\u043B\u044C\u0437\u044F \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C. +required = \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{0}'' \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E +type = \u043D\u0430\u0439\u0434\u0435\u043D\u043E {0}, \u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F {1} +unevaluatedItems = \u0438\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u043E\u0446\u0435\u043D\u0438\u0432\u0430\u0435\u0442\u0441\u044F, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435\u043E\u0446\u0435\u043D\u0435\u043D\u043D\u044B\u0445 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. +unevaluatedProperties = \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E ''{0}'' \u043D\u0435 \u043E\u0446\u0435\u043D\u0438\u0432\u0430\u0435\u0442\u0441\u044F, \u0438 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435\u043E\u0446\u0435\u043D\u0435\u043D\u043D\u044B\u0445 \u0441\u0432\u043E\u0439\u0441\u0442\u0432. +unionType = \u043D\u0430\u0439\u0434\u0435\u043D\u043E {0}, \u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F {1} +uniqueItems = \u043C\u0430\u0441\u0441\u0438\u0432 \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B. +writeOnly = \u043F\u043E\u043B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438, \u043E\u043D\u043E \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u044C\u0441\u044F \u0432 \u0434\u0430\u043D\u043D\u044B\u0445. +contentEncoding = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043A\u043E\u0434\u0438\u0440\u043E\u0432\u043A\u0435 \u043A\u043E\u043D\u0442\u0435\u043D\u0442\u0430 {0} +contentMediaType = \u043C\u0435\u043D\u044F \u043D\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 diff --git a/src/main/resources/jsv-messages_sk.properties b/src/main/resources/jsv-messages_sk.properties index 63e3329e9..a027a6988 100644 --- a/src/main/resources/jsv-messages_sk.properties +++ b/src/main/resources/jsv-messages_sk.properties @@ -1,70 +1,70 @@ -$ref = {0}: obsahuje chybu s ''refs'' -additionalItems = {0}: index ''{1}'' nie je definovaný v schéme a schéma nepovo\u013Euje \u010Fal\u0161ie polo\u017Eky -additionalProperties = {0}: vlastnos\u0165 ''{1}'' nie je definovaná v schéme a schéma neumo\u017E\u0148uje \u010Fal\u0161ie vlastnosti -allOf = {0}: musí by\u0165 platné pre v\u0161etky schémy {1} -anyOf = {0}: musí by\u0165 platné pre ktorúko\u013Evek schému {1} -const = {0}: musí by\u0165 kon\u0161tantná hodnota ''{1}'' -contains = {0}: neobsahuje prvok, ktorý vyhovuje týmto overeniam: {2} -contains.max = {0}: musí obsahova\u0165 najviac {1} prvkov, ktoré prejdú týmito overeniami: {2} -contains.min = {0}: musí obsahova\u0165 aspo\u0148 {1} prvkov, ktoré prejdú týmito overeniami: {2} -dependencies = {0}: obsahuje chybu so závislos\u0165ami {1} -dependentRequired = {0}: má chýbajúcu vlastnos\u0165 ''{1}'', ktorá je závislá vy\u017Eadovaná, preto\u017Ee ''{2}'' je prítomná -dependentSchemas = {0}: obsahuje chybu s dependentSchemas {1} -enum = {0}: nemá hodnotu v enumerácii {1} -exclusiveMaximum = {0}: musí ma\u0165 výlu\u010Dnú maximálnu hodnotu {1} -exclusiveMinimum = {0}: musí ma\u0165 výlu\u010Dnú minimálnu hodnotu {1} -false = {0}: schéma pre ''{1}'' je nepravda -format = {0}: nezhoduje sa so vzorom {1} {2} -format.date = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný úplný dátum RFC 3339 -format.date-time = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný dátum a \u010Das RFC 3339 -format.duration = {0}: nezhoduje sa so vzorom {1}, musí ma\u0165 platné trvanie ISO 8601 -format.email = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platná po\u0161tová schránka RFC 5321 -format.ipv4 = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platná adresa IP RFC 2673 -format.ipv6 = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platná adresa IP RFC 4291 -format.idn-email = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platná po\u0161tová schránka RFC 6531 -format.idn-hostname = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný medzinárodný názov hostite\u013Ea pod\u013Ea RFC 5890 -format.iri = {0}: nezhoduje sa so vzorom {1} musí by\u0165 platný RFC 3987 IRI -format.iri-reference = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný RFC 3987 IRI-reference -format.uri = {0}: nezhoduje sa so vzorom {1}, musí by\u0165 platný RFC 3986 URI -format.uri-reference = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný odkaz URI RFC 3986 -format.uri-template = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platná \u0161ablóna URI RFC 6570 -format.uuid = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný UUID RFC 4122 -format.regex = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný regulárny výraz ECMA-262 -format.time = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný \u010Das RFC 3339 -format.hostname = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný názov hostite\u013Ea RFC 1123 -format.json-pointer = {0}: nezhoduje sa so vzorom {1}, musí to by\u0165 platný ukazovate\u013E RFC 6901 JSON -format.relative-json-pointer = {0}: nezhoduje sa so vzorom {1}, musí by\u0165 platným IETF relatívnym ukazovate\u013Eom JSON -format.unknown = {0}: má neznámy formát ''{1}'' -id = {0}: ''{1}'' nie je platný {2} -items = {0}: index ''{1}'' nie je definovaný v schéme a schéma nepovo\u013Euje \u010Fal\u0161ie polo\u017Eky -maxContains = {0}: musí by\u0165 nezáporné celé \u010Díslo v {1} -maxItems = {0}: musí ma\u0165 najviac {1} polo\u017Eiek, ale nájdených {2} -maxLength = {0}: musí ma\u0165 maximálne {1} znakov -maxProperties = {0}: musí ma\u0165 najviac {1} vlastností -maximum = {0}: musí ma\u0165 maximálnu hodnotu {1} -minContains = {0}: musí by\u0165 nezáporné celé \u010Díslo v {1} -minContainsVsMaxContains = {0}: minContains musí by\u0165 men\u0161í alebo rovný maxContains v {1} -minItems = {0}: musí ma\u0165 aspo\u0148 {1} polo\u017Eiek, ale nájdených {2} -minLength = {0}: musí ma\u0165 aspo\u0148 {1} znakov -minProperties = {0}: musí ma\u0165 aspo\u0148 {1} vlastností -minimum = {0}: musí ma\u0165 minimálnu hodnotu {1} -multipleOf = {0}: musí by\u0165 násobkom {1} -not = {0}: nesmie by\u0165 platné pre schému {1} -notAllowed = {0}: vlastnos\u0165 ''{1}'' nie je povolená, ale je v údajoch -oneOf = {0}: musí by\u0165 platné pre jednu a iba jednu schému, ale {1} sú platné -oneOf.indexes = {0}: musí by\u0165 platné pre jednu a iba jednu schému, ale {1} sú platné s indexmi ''{2}'' -pattern = {0}: nezodpovedá vzoru regulárneho výrazu {1} -patternProperties = {0}: obsahuje nejakú chybu s ''vlastnos\u0165ami vzoru'' -prefixItems = {0}: v tomto indexe sa nena\u0161iel \u017Eiadny validátor -properties = {0}: obsahuje chybu s ''vlastnosti'' -propertyNames = {0}: názov vlastnosti ''{1}'' nie je platný: {2} -readOnly = {0}: je pole len na \u010Dítanie, nemo\u017Eno ho zmeni\u0165 -required = {0}: po\u017Eadovaná vlastnos\u0165 ''{1}'' sa nena\u0161la -type = {0}: nájdených {1}, o\u010Dakávaných {2} -unevaluatedItems = {0}: index ''{1}'' nie je vyhodnotený a schéma nepovo\u013Euje nehodnotené polo\u017Eky -unevaluatedProperties = {0}: vlastnos\u0165 ''{1}'' nie je vyhodnotená a schéma nepovo\u013Euje nehodnotené vlastnosti -unionType = {0}: nájdených {1}, o\u010Dakávaných {2} -uniqueItems = {0}: v poli musia by\u0165 iba jedine\u010Dné polo\u017Eky -writeOnly = {0}: je pole ur\u010Dené len na zápis, nemô\u017Ee sa objavi\u0165 v údajoch -contentEncoding = {0}: nezhoduje sa s kódovaním obsahu {1} -contentMediaType = {0}: nie je obsah ja +$ref = obsahuje chybu s ''refs'' +additionalItems = index ''{0}'' nie je definovaný v schéme a schéma nepovo\u013Euje \u010Fal\u0161ie polo\u017Eky +additionalProperties = vlastnos\u0165 ''{0}'' nie je definovaná v schéme a schéma neumo\u017E\u0148uje \u010Fal\u0161ie vlastnosti +allOf = musí by\u0165 platné pre v\u0161etky schémy {0} +anyOf = musí by\u0165 platné pre ktorúko\u013Evek schému {0} +const = musí by\u0165 kon\u0161tantná hodnota ''{0}'' +contains = neobsahuje prvok, ktorý vyhovuje týmto overeniam: {1} +contains.max = musí obsahova\u0165 najviac {0} prvkov, ktoré prejdú týmito overeniami: {1} +contains.min = musí obsahova\u0165 aspo\u0148 {0} prvkov, ktoré prejdú týmito overeniami: {1} +dependencies = obsahuje chybu so závislos\u0165ami {0} +dependentRequired = má chýbajúcu vlastnos\u0165 ''{0}'', ktorá je závislá vy\u017Eadovaná, preto\u017Ee ''{1}'' je prítomná +dependentSchemas = obsahuje chybu s dependentSchemas {0} +enum = nemá hodnotu v enumerácii {0} +exclusiveMaximum = musí ma\u0165 výlu\u010Dnú maximálnu hodnotu {0} +exclusiveMinimum = musí ma\u0165 výlu\u010Dnú minimálnu hodnotu {0} +false = schéma pre ''{0}'' je nepravda +format = nezhoduje sa so vzorom {0} {1} +format.date = nezhoduje sa so vzorom {0}, musí to by\u0165 platný úplný dátum RFC 3339 +format.date-time = nezhoduje sa so vzorom {0}, musí to by\u0165 platný dátum a \u010Das RFC 3339 +format.duration = nezhoduje sa so vzorom {0}, musí ma\u0165 platné trvanie ISO 8601 +format.email = nezhoduje sa so vzorom {0}, musí to by\u0165 platná po\u0161tová schránka RFC 5321 +format.ipv4 = nezhoduje sa so vzorom {0}, musí to by\u0165 platná adresa IP RFC 2673 +format.ipv6 = nezhoduje sa so vzorom {0}, musí to by\u0165 platná adresa IP RFC 4291 +format.idn-email = nezhoduje sa so vzorom {0}, musí to by\u0165 platná po\u0161tová schránka RFC 6531 +format.idn-hostname = nezhoduje sa so vzorom {0}, musí to by\u0165 platný medzinárodný názov hostite\u013Ea pod\u013Ea RFC 5890 +format.iri = nezhoduje sa so vzorom {0} musí by\u0165 platný RFC 3987 IRI +format.iri-reference = nezhoduje sa so vzorom {0}, musí to by\u0165 platný RFC 3987 IRI-reference +format.uri = nezhoduje sa so vzorom {0}, musí by\u0165 platný RFC 3986 URI +format.uri-reference = nezhoduje sa so vzorom {0}, musí to by\u0165 platný odkaz URI RFC 3986 +format.uri-template = nezhoduje sa so vzorom {0}, musí to by\u0165 platná \u0161ablóna URI RFC 6570 +format.uuid = nezhoduje sa so vzorom {0}, musí to by\u0165 platný UUID RFC 4122 +format.regex = nezhoduje sa so vzorom {0}, musí to by\u0165 platný regulárny výraz ECMA-262 +format.time = nezhoduje sa so vzorom {0}, musí to by\u0165 platný \u010Das RFC 3339 +format.hostname = nezhoduje sa so vzorom {0}, musí to by\u0165 platný názov hostite\u013Ea RFC 1123 +format.json-pointer = nezhoduje sa so vzorom {0}, musí to by\u0165 platný ukazovate\u013E RFC 6901 JSON +format.relative-json-pointer = nezhoduje sa so vzorom {0}, musí by\u0165 platným IETF relatívnym ukazovate\u013Eom JSON +format.unknown = má neznámy formát ''{0}'' +id = ''{0}'' nie je platný {1} +items = index ''{0}'' nie je definovaný v schéme a schéma nepovo\u013Euje \u010Fal\u0161ie polo\u017Eky +maxContains = musí by\u0165 nezáporné celé \u010Díslo v {0} +maxItems = musí ma\u0165 najviac {0} polo\u017Eiek, ale nájdených {1} +maxLength = musí ma\u0165 maximálne {0} znakov +maxProperties = musí ma\u0165 najviac {0} vlastností +maximum = musí ma\u0165 maximálnu hodnotu {0} +minContains = musí by\u0165 nezáporné celé \u010Díslo v {0} +minContainsVsMaxContains = minContains musí by\u0165 men\u0161í alebo rovný maxContains v {0} +minItems = musí ma\u0165 aspo\u0148 {0} polo\u017Eiek, ale nájdených {1} +minLength = musí ma\u0165 aspo\u0148 {0} znakov +minProperties = musí ma\u0165 aspo\u0148 {0} vlastností +minimum = musí ma\u0165 minimálnu hodnotu {0} +multipleOf = musí by\u0165 násobkom {0} +not = nesmie by\u0165 platné pre schému {0} +notAllowed = vlastnos\u0165 ''{0}'' nie je povolená, ale je v údajoch +oneOf = musí by\u0165 platné pre jednu a iba jednu schému, ale {0} sú platné +oneOf.indexes = musí by\u0165 platné pre jednu a iba jednu schému, ale {0} sú platné s indexmi ''{1}'' +pattern = nezodpovedá vzoru regulárneho výrazu {0} +patternProperties = obsahuje nejakú chybu s ''vlastnos\u0165ami vzoru'' +prefixItems = v tomto indexe sa nena\u0161iel \u017Eiadny validátor +properties = obsahuje chybu s ''vlastnosti'' +propertyNames = názov vlastnosti ''{0}'' nie je platný: {1} +readOnly = je pole len na \u010Dítanie, nemo\u017Eno ho zmeni\u0165 +required = po\u017Eadovaná vlastnos\u0165 ''{0}'' sa nena\u0161la +type = nájdených {0}, o\u010Dakávaných {1} +unevaluatedItems = index ''{0}'' nie je vyhodnotený a schéma nepovo\u013Euje nehodnotené polo\u017Eky +unevaluatedProperties = vlastnos\u0165 ''{0}'' nie je vyhodnotená a schéma nepovo\u013Euje nehodnotené vlastnosti +unionType = nájdených {0}, o\u010Dakávaných {1} +uniqueItems = v poli musia by\u0165 iba jedine\u010Dné polo\u017Eky +writeOnly = je pole ur\u010Dené len na zápis, nemô\u017Ee sa objavi\u0165 v údajoch +contentEncoding = nezhoduje sa s kódovaním obsahu {0} +contentMediaType = nie je obsah ja diff --git a/src/main/resources/jsv-messages_sv.properties b/src/main/resources/jsv-messages_sv.properties index b9dc6ffc0..f99caa869 100644 --- a/src/main/resources/jsv-messages_sv.properties +++ b/src/main/resources/jsv-messages_sv.properties @@ -1,70 +1,70 @@ -$ref = {0}: har ett fel med ''refs'' -additionalItems = {0}: index ''{1}'' är inte definierat i schemat och schemat tillåter inte ytterligare objekt -additionalProperties = {0}: egenskapen ''{1}'' är inte definierad i schemat och schemat tillåter inte ytterligare egenskaper -allOf = {0}: måste vara giltig för alla scheman {1} -anyOf = {0}: måste vara giltigt för något av schemana {1} -const = {0}: måste vara det konstanta värdet ''{1}'' -contains = {0}: innehåller inte ett element som klarar dessa valideringar: {2} -contains.max = {0}: måste innehålla högst {1} element som klarar dessa valideringar: {2} -contains.min = {0}: måste innehålla minst {1} element som klarar dessa valideringar: {2} -dependencies = {0}: har ett fel med beroenden {1} -dependentRequired = {0}: har en saknad egenskap ''{1}'' som är beroende krävs eftersom ''{2}'' är närvarande -dependentSchemas = {0}: har ett fel med dependentSchemas {1} -enum = {0}: har inget värde i uppräkningen {1} -exclusiveMaximum = {0}: måste ha ett exklusivt maxvärde på {1} -exclusiveMinimum = {0}: måste ha ett exklusivt lägsta värde på {1} -false = {0}: schemat för ''{1}'' är falskt -format = {0}: matchar inte {1}-mönstret {2} -format.date = {0}: matchar inte {1}-mönstret måste vara ett giltigt RFC 3339 fulldatum -format.date-time = {0}: matchar inte {1}-mönstret måste vara ett giltigt RFC 3339 datum-tid -format.duration = {0}: matchar inte {1}-mönstret måste vara en giltig ISO 8601-varaktighet -format.email = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 5321-postlåda -format.ipv4 = {0}: matchar inte mönstret {1} måste vara en giltig RFC 2673 IP-adress -format.ipv6 = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 4291 IP-adress -format.idn-email = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 6531-postlåda -format.idn-hostname = {0}: matchar inte mönstret {1} måste vara ett giltigt RFC 5890 internationaliserat värdnamn -format.iri = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 3987 IRI -format.iri-reference = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 3987 IRI-referens -format.uri = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 3986 URI -format.uri-reference = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 3986 URI-referens -format.uri-template = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 6570 URI-mall -format.uuid = {0}: matchar inte {1}-mönstret måste vara ett giltigt RFC 4122 UUID -format.regex = {0}: matchar inte {1}-mönstret måste vara ett giltigt ECMA-262 reguljärt uttryck -format.time = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 3339-tid -format.hostname = {0}: matchar inte {1}-mönstret måste vara ett giltigt RFC 1123-värdnamn -format.json-pointer = {0}: matchar inte {1}-mönstret måste vara en giltig RFC 6901 JSON-pekare -format.relative-json-pointer = {0}: matchar inte {1}-mönstret måste vara en giltig IETF Relativ JSON-pekare -format.unknown = {0}: har ett okänt format ''{1}'' -id = {0}: ''{1}'' är inte en giltig {2} -items = {0}: index ''{1}'' är inte definierat i schemat och schemat tillåter inte ytterligare objekt -maxContains = {0}: måste vara ett icke-negativt heltal i {1} -maxItems = {0}: måste ha högst {1} objekt men hittade {2} -maxLength = {0}: får vara högst {1} tecken lång -maxProperties = {0}: måste ha högst {1} egenskaper -maximum = {0}: måste ha ett maximalt värde på {1} -minContains = {0}: måste vara ett icke-negativt heltal i {1} -minContainsVsMaxContains = {0}: minContains måste vara mindre än eller lika med maxContains i {1} -minItems = {0}: måste ha minst {1} objekt men hittade {2} -minLength = {0}: måste vara minst {1} tecken lång -minProperties = {0}: måste ha minst {1} egenskaper -minimum = {0}: måste ha ett lägsta värde på {1} -multipleOf = {0}: måste vara multipel av {1} -not = {0}: får inte vara giltigt för schemat {1} -notAllowed = {0}: egenskapen ''{1}'' är inte tillåten men den finns i data -oneOf = {0}: måste vara giltigt för ett och endast ett schema, men {1} är giltiga -oneOf.indexes = {0}: måste vara giltigt för ett och endast ett schema, men {1} är giltiga med index ''{2}'' -pattern = {0}: matchar inte regexmönstret {1} -patternProperties = {0}: har något fel med ''mönsteregenskaper'' -prefixItems = {0}: ingen validator hittades i detta index -properties = {0}: har ett fel med ''egenskaper'' -propertyNames = {0}: egenskapen ''{1}'' namn är inte giltigt: {2} -readOnly = {0}: är ett skrivskyddat fält, det kan inte ändras -required = {0}: den obligatoriska egenskapen ''{1}'' hittades inte -type = {0}: {1} hittades, {2} förväntas -unevaluatedItems = {0}: index ''{1}'' utvärderas inte och schemat tillåter inte oevaluerade objekt -unevaluatedProperties = {0}: egenskapen ''{1}'' utvärderas inte och schemat tillåter inte oevaluerade egenskaper -unionType = {0}: {1} hittades, {2} förväntas -uniqueItems = {0}: får endast ha unika objekt i arrayen -writeOnly = {0}: är ett skrivskyddat fält, det kan inte visas i data -contentEncoding = {0}: matchar inte innehållskodning {1} -contentMediaType = {0}: är inte ett innehåll jag +$ref = har ett fel med ''refs'' +additionalItems = index ''{0}'' är inte definierat i schemat och schemat tillåter inte ytterligare objekt +additionalProperties = egenskapen ''{0}'' är inte definierad i schemat och schemat tillåter inte ytterligare egenskaper +allOf = måste vara giltig för alla scheman {0} +anyOf = måste vara giltigt för något av schemana {0} +const = måste vara det konstanta värdet ''{0}'' +contains = innehåller inte ett element som klarar dessa valideringar: {1} +contains.max = måste innehålla högst {0} element som klarar dessa valideringar: {1} +contains.min = måste innehålla minst {0} element som klarar dessa valideringar: {1} +dependencies = har ett fel med beroenden {0} +dependentRequired = har en saknad egenskap ''{0}'' som är beroende krävs eftersom ''{1}'' är närvarande +dependentSchemas = har ett fel med dependentSchemas {0} +enum = har inget värde i uppräkningen {0} +exclusiveMaximum = måste ha ett exklusivt maxvärde på {0} +exclusiveMinimum = måste ha ett exklusivt lägsta värde på {0} +false = schemat för ''{0}'' är falskt +format = matchar inte {0}-mönstret {1} +format.date = matchar inte {0}-mönstret måste vara ett giltigt RFC 3339 fulldatum +format.date-time = matchar inte {0}-mönstret måste vara ett giltigt RFC 3339 datum-tid +format.duration = matchar inte {0}-mönstret måste vara en giltig ISO 8601-varaktighet +format.email = matchar inte {0}-mönstret måste vara en giltig RFC 5321-postlåda +format.ipv4 = matchar inte mönstret {0} måste vara en giltig RFC 2673 IP-adress +format.ipv6 = matchar inte {0}-mönstret måste vara en giltig RFC 4291 IP-adress +format.idn-email = matchar inte {0}-mönstret måste vara en giltig RFC 6531-postlåda +format.idn-hostname = matchar inte mönstret {0} måste vara ett giltigt RFC 5890 internationaliserat värdnamn +format.iri = matchar inte {0}-mönstret måste vara en giltig RFC 3987 IRI +format.iri-reference = matchar inte {0}-mönstret måste vara en giltig RFC 3987 IRI-referens +format.uri = matchar inte {0}-mönstret måste vara en giltig RFC 3986 URI +format.uri-reference = matchar inte {0}-mönstret måste vara en giltig RFC 3986 URI-referens +format.uri-template = matchar inte {0}-mönstret måste vara en giltig RFC 6570 URI-mall +format.uuid = matchar inte {0}-mönstret måste vara ett giltigt RFC 4122 UUID +format.regex = matchar inte {0}-mönstret måste vara ett giltigt ECMA-262 reguljärt uttryck +format.time = matchar inte {0}-mönstret måste vara en giltig RFC 3339-tid +format.hostname = matchar inte {0}-mönstret måste vara ett giltigt RFC 1123-värdnamn +format.json-pointer = matchar inte {0}-mönstret måste vara en giltig RFC 6901 JSON-pekare +format.relative-json-pointer = matchar inte {0}-mönstret måste vara en giltig IETF Relativ JSON-pekare +format.unknown = har ett okänt format ''{0}'' +id = ''{0}'' är inte en giltig {1} +items = index ''{0}'' är inte definierat i schemat och schemat tillåter inte ytterligare objekt +maxContains = måste vara ett icke-negativt heltal i {0} +maxItems = måste ha högst {0} objekt men hittade {1} +maxLength = får vara högst {0} tecken lång +maxProperties = måste ha högst {0} egenskaper +maximum = måste ha ett maximalt värde på {0} +minContains = måste vara ett icke-negativt heltal i {0} +minContainsVsMaxContains = minContains måste vara mindre än eller lika med maxContains i {0} +minItems = måste ha minst {0} objekt men hittade {1} +minLength = måste vara minst {0} tecken lång +minProperties = måste ha minst {0} egenskaper +minimum = måste ha ett lägsta värde på {0} +multipleOf = måste vara multipel av {0} +not = får inte vara giltigt för schemat {0} +notAllowed = egenskapen ''{0}'' är inte tillåten men den finns i data +oneOf = måste vara giltigt för ett och endast ett schema, men {0} är giltiga +oneOf.indexes = måste vara giltigt för ett och endast ett schema, men {0} är giltiga med index ''{1}'' +pattern = matchar inte regexmönstret {0} +patternProperties = har något fel med ''mönsteregenskaper'' +prefixItems = ingen validator hittades i detta index +properties = har ett fel med ''egenskaper'' +propertyNames = egenskapen ''{0}'' namn är inte giltigt: {1} +readOnly = är ett skrivskyddat fält, det kan inte ändras +required = den obligatoriska egenskapen ''{0}'' hittades inte +type = {0} hittades, {1} förväntas +unevaluatedItems = index ''{0}'' utvärderas inte och schemat tillåter inte oevaluerade objekt +unevaluatedProperties = egenskapen ''{0}'' utvärderas inte och schemat tillåter inte oevaluerade egenskaper +unionType = {0} hittades, {1} förväntas +uniqueItems = får endast ha unika objekt i arrayen +writeOnly = är ett skrivskyddat fält, det kan inte visas i data +contentEncoding = matchar inte innehållskodning {0} +contentMediaType = är inte ett innehåll jag diff --git a/src/main/resources/jsv-messages_th.properties b/src/main/resources/jsv-messages_th.properties index d13a67b2e..201a6191d 100644 --- a/src/main/resources/jsv-messages_th.properties +++ b/src/main/resources/jsv-messages_th.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A ''refs'' -additionalItems = {0}: \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{1}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 -additionalProperties = {0}: \u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{1}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 -allOf = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 {1} -anyOf = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E43\u0E14\u0E46 {1} -const = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E04\u0E48\u0E32\u0E04\u0E07\u0E17\u0E35\u0E48 ''{1}'' -contains = {0}: \u0E44\u0E21\u0E48\u0E21\u0E35\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {2} -contains.max = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E21\u0E32\u0E01\u0E17\u0E35\u0E48\u0E2A\u0E38\u0E14 {1} \u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {2} -contains.min = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {1} \u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {2} -dependencies = {0}: \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E02\u0E36\u0E49\u0E19\u0E15\u0E48\u0E2D\u0E01\u0E31\u0E19 {1} -dependentRequired = {0}: \u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E02\u0E32\u0E14\u0E2B\u0E32\u0E22\u0E44\u0E1B ''{1}'' \u0E0B\u0E36\u0E48\u0E07\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E49\u0E2D\u0E07\u0E1E\u0E36\u0E48\u0E07\u0E1E\u0E32\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E21\u0E35 ''{2}'' \u0E2D\u0E22\u0E39\u0E48 -dependentSchemas = {0}: \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A dependentSchemas {1} -enum = {0}: \u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32\u0E43\u0E19\u0E01\u0E32\u0E23\u0E41\u0E08\u0E07\u0E19\u0E31\u0E1A {1} -exclusiveMaximum = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {1} -exclusiveMinimum = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {1} -false = {0}: \u0E2A\u0E04\u0E35\u0E21\u0E32\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A ''{1}'' \u0E40\u0E1B\u0E47\u0E19\u0E40\u0E17\u0E47\u0E08 -format = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} {2} -format.date = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E15\u0E47\u0E21 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.date-time = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48-\u0E40\u0E27\u0E25\u0E32 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.duration = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E23\u0E30\u0E22\u0E30\u0E40\u0E27\u0E25\u0E32 ISO 8601 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.email = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E08\u0E14\u0E2B\u0E21\u0E32\u0E22 RFC 5321 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.ipv4 = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IP RFC 2673 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.ipv6 = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IP RFC 4291 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.idn-email = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E08\u0E14\u0E2B\u0E21\u0E32\u0E22 RFC 6531 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.idn-hostname = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E2E\u0E2A\u0E15\u0E4C\u0E2A\u0E32\u0E01\u0E25 RFC 5890 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.iri = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3987 IRI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.iri-reference = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3987 IRI-reference \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.uri = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3986 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.uri-reference = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2D\u0E49\u0E32\u0E07\u0E2D\u0E34\u0E07 RFC 3986 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.uri-template = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E17\u0E21\u0E40\u0E1E\u0E25\u0E15 RFC 6570 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.uuid = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 4122 UUID \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.regex = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E19\u0E34\u0E1E\u0E08\u0E19\u0E4C\u0E17\u0E31\u0E48\u0E27\u0E44\u0E1B ECMA-262 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.time = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E27\u0E25\u0E32 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.hostname = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E2E\u0E2A\u0E15\u0E4C RFC 1123 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.json-pointer = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E31\u0E27\u0E0A\u0E35\u0E49 RFC 6901 JSON \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.relative-json-pointer = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {1} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E31\u0E27\u0E0A\u0E35\u0E49 JSON \u0E41\u0E1A\u0E1A\u0E2A\u0E31\u0E21\u0E1E\u0E31\u0E19\u0E18\u0E4C\u0E02\u0E2D\u0E07 IETF \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -format.unknown = {0}: \u0E21\u0E35\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01 ''{1}'' -id = {0}: ''{1}'' \u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48 {2} \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -items = {0}: \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{1}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 -maxContains = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E40\u0E15\u0E47\u0E21\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E40\u0E1B\u0E47\u0E19\u0E25\u0E1A\u0E43\u0E19 {1} -maxItems = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E21\u0E32\u0E01\u0E17\u0E35\u0E48\u0E2A\u0E38\u0E14 {1} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23 \u0E41\u0E15\u0E48\u0E1E\u0E1A {2} -maxLength = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 {1} \u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30 -maxProperties = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 {1} -maximum = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E40\u0E1B\u0E47\u0E19 {1} -minContains = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E40\u0E15\u0E47\u0E21\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E40\u0E1B\u0E47\u0E19\u0E25\u0E1A\u0E43\u0E19 {1} -minContainsVsMaxContains = {0}: minContains \u0E15\u0E49\u0E2D\u0E07\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E2B\u0E23\u0E37\u0E2D\u0E40\u0E17\u0E48\u0E32\u0E01\u0E31\u0E1A maxContains \u0E43\u0E19 {1} -minItems = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {1} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23 \u0E41\u0E15\u0E48\u0E1E\u0E1A {2} -minLength = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {1} \u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30 -minProperties = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {1} -minimum = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E2A\u0E38\u0E14\u0E40\u0E1B\u0E47\u0E19 {1} -multipleOf = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E1C\u0E25\u0E04\u0E39\u0E13\u0E02\u0E2D\u0E07 {1} -not = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32 {1} -notAllowed = {0}: \u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E43\u0E0A\u0E49\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{1}'' \u0E41\u0E15\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 -oneOf = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E40\u0E14\u0E35\u0E22\u0E27\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E41\u0E15\u0E48 {1} \u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 -oneOf.indexes = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E40\u0E14\u0E35\u0E22\u0E27\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E41\u0E15\u0E48 {1} \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E14\u0E31\u0E0A\u0E19\u0E35 ''{2}'' -pattern = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A regex {1} -patternProperties = {0}: \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E1A\u0E32\u0E07\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E01\u0E31\u0E1A ''\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A'' -prefixItems = {0}: \u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E40\u0E04\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E21\u0E37\u0E2D\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E04\u0E27\u0E32\u0E21\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19\u0E14\u0E31\u0E0A\u0E19\u0E35\u0E19\u0E35\u0E49 -properties = {0}: \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A ''\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34'' -propertyNames = {0}: \u0E0A\u0E37\u0E48\u0E2D\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{1}'' \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: {2} -readOnly = {0}: \u0E40\u0E1B\u0E47\u0E19\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E41\u0E1A\u0E1A\u0E2D\u0E48\u0E32\u0E19\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27 \u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E44\u0E14\u0E49 -required = {0}: \u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E17\u0E35\u0E48\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23 ''{1}'' -type = {0}: \u0E1E\u0E1A {1}, \u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 {2} -unevaluatedItems = {0}: \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{1}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 -unevaluatedProperties = {0}: \u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{1}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 -unionType = {0}: \u0E1E\u0E1A {1}, \u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23 {2} -uniqueItems = {0}: \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E0B\u0E49\u0E33\u0E43\u0E19\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C -writeOnly = {0}: \u0E40\u0E1B\u0E47\u0E19\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E41\u0E1A\u0E1A\u0E40\u0E02\u0E35\u0E22\u0E19\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E1B\u0E23\u0E32\u0E01\u0E0F\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E14\u0E49 -contentEncoding = {0}: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E40\u0E02\u0E49\u0E32\u0E23\u0E2B\u0E31\u0E2A\u0E40\u0E19\u0E37\u0E49\u0E2D\u0E2B\u0E32 {1} -contentMediaType = {0}: \u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E40\u0E19\u0E37\u0E49\u0E2D\u0E2B\u0E32\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19 +$ref = \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A ''refs'' +additionalItems = \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{0}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 +additionalProperties = \u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{0}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 +allOf = \u0E15\u0E49\u0E2D\u0E07\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 {0} +anyOf = \u0E15\u0E49\u0E2D\u0E07\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E43\u0E14\u0E46 {0} +const = \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E04\u0E48\u0E32\u0E04\u0E07\u0E17\u0E35\u0E48 ''{0}'' +contains = \u0E44\u0E21\u0E48\u0E21\u0E35\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {1} +contains.max = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E21\u0E32\u0E01\u0E17\u0E35\u0E48\u0E2A\u0E38\u0E14 {0} \u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {1} +contains.min = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {0} \u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E40\u0E2B\u0E25\u0E48\u0E32\u0E19\u0E35\u0E49: {1} +dependencies = \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E02\u0E36\u0E49\u0E19\u0E15\u0E48\u0E2D\u0E01\u0E31\u0E19 {0} +dependentRequired = \u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E02\u0E32\u0E14\u0E2B\u0E32\u0E22\u0E44\u0E1B ''{0}'' \u0E0B\u0E36\u0E48\u0E07\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E49\u0E2D\u0E07\u0E1E\u0E36\u0E48\u0E07\u0E1E\u0E32\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E21\u0E35 ''{1}'' \u0E2D\u0E22\u0E39\u0E48 +dependentSchemas = \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A dependentSchemas {0} +enum = \u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32\u0E43\u0E19\u0E01\u0E32\u0E23\u0E41\u0E08\u0E07\u0E19\u0E31\u0E1A {0} +exclusiveMaximum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {0} +exclusiveMinimum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {0} +false = \u0E2A\u0E04\u0E35\u0E21\u0E32\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A ''{0}'' \u0E40\u0E1B\u0E47\u0E19\u0E40\u0E17\u0E47\u0E08 +format = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} {1} +format.date = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E15\u0E47\u0E21 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.date-time = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48-\u0E40\u0E27\u0E25\u0E32 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.duration = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E23\u0E30\u0E22\u0E30\u0E40\u0E27\u0E25\u0E32 ISO 8601 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.email = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E08\u0E14\u0E2B\u0E21\u0E32\u0E22 RFC 5321 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.ipv4 = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IP RFC 2673 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.ipv6 = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IP RFC 4291 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.idn-email = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E08\u0E14\u0E2B\u0E21\u0E32\u0E22 RFC 6531 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.idn-hostname = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E2E\u0E2A\u0E15\u0E4C\u0E2A\u0E32\u0E01\u0E25 RFC 5890 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.iri = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3987 IRI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.iri-reference = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3987 IRI-reference \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.uri = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 3986 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.uri-reference = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2D\u0E49\u0E32\u0E07\u0E2D\u0E34\u0E07 RFC 3986 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.uri-template = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E17\u0E21\u0E40\u0E1E\u0E25\u0E15 RFC 6570 URI \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.uuid = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19 RFC 4122 UUID \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.regex = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E19\u0E34\u0E1E\u0E08\u0E19\u0E4C\u0E17\u0E31\u0E48\u0E27\u0E44\u0E1B ECMA-262 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.time = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E27\u0E25\u0E32 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.hostname = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E2E\u0E2A\u0E15\u0E4C RFC 1123 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.json-pointer = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E31\u0E27\u0E0A\u0E35\u0E49 RFC 6901 JSON \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.relative-json-pointer = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E15\u0E31\u0E27\u0E0A\u0E35\u0E49 JSON \u0E41\u0E1A\u0E1A\u0E2A\u0E31\u0E21\u0E1E\u0E31\u0E19\u0E18\u0E4C\u0E02\u0E2D\u0E07 IETF \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +format.unknown = \u0E21\u0E35\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01 ''{0}'' +id = ''{0}'' \u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48 {1} \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +items = \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{0}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49\u0E43\u0E19\u0E2A\u0E04\u0E35\u0E21\u0E32 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21 +maxContains = \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E40\u0E15\u0E47\u0E21\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E40\u0E1B\u0E47\u0E19\u0E25\u0E1A\u0E43\u0E19 {0} +maxItems = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E21\u0E32\u0E01\u0E17\u0E35\u0E48\u0E2A\u0E38\u0E14 {0} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23 \u0E41\u0E15\u0E48\u0E1E\u0E1A {1} +maxLength = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 {0} \u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30 +maxProperties = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 {0} +maximum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E40\u0E1B\u0E47\u0E19 {0} +minContains = \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E40\u0E15\u0E47\u0E21\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E40\u0E1B\u0E47\u0E19\u0E25\u0E1A\u0E43\u0E19 {0} +minContainsVsMaxContains = minContains \u0E15\u0E49\u0E2D\u0E07\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E2B\u0E23\u0E37\u0E2D\u0E40\u0E17\u0E48\u0E32\u0E01\u0E31\u0E1A maxContains \u0E43\u0E19 {0} +minItems = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {0} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23 \u0E41\u0E15\u0E48\u0E1E\u0E1A {1} +minLength = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {0} \u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30 +minProperties = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 {0} +minimum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E2A\u0E38\u0E14\u0E40\u0E1B\u0E47\u0E19 {0} +multipleOf = \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E1C\u0E25\u0E04\u0E39\u0E13\u0E02\u0E2D\u0E07 {0} +not = \u0E15\u0E49\u0E2D\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32 {0} +notAllowed = \u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E43\u0E0A\u0E49\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{0}'' \u0E41\u0E15\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 +oneOf = \u0E15\u0E49\u0E2D\u0E07\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E40\u0E14\u0E35\u0E22\u0E27\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E41\u0E15\u0E48 {0} \u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 +oneOf.indexes = \u0E15\u0E49\u0E2D\u0E07\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E40\u0E14\u0E35\u0E22\u0E27\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E41\u0E15\u0E48 {0} \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E01\u0E31\u0E1A\u0E14\u0E31\u0E0A\u0E19\u0E35 ''{1}'' +pattern = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A regex {0} +patternProperties = \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E1A\u0E32\u0E07\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E01\u0E31\u0E1A ''\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A'' +prefixItems = \u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E40\u0E04\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E21\u0E37\u0E2D\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E04\u0E27\u0E32\u0E21\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19\u0E14\u0E31\u0E0A\u0E19\u0E35\u0E19\u0E35\u0E49 +properties = \u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E31\u0E1A ''\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34'' +propertyNames = \u0E0A\u0E37\u0E48\u0E2D\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{0}'' \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: {1} +readOnly = \u0E40\u0E1B\u0E47\u0E19\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E41\u0E1A\u0E1A\u0E2D\u0E48\u0E32\u0E19\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27 \u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E44\u0E14\u0E49 +required = \u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E17\u0E35\u0E48\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23 ''{0}'' +type = \u0E1E\u0E1A {0}, \u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 {1} +unevaluatedItems = \u0E14\u0E31\u0E0A\u0E19\u0E35 ''{0}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 +unevaluatedProperties = \u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34 ''{0}'' \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 \u0E41\u0E25\u0E30\u0E2A\u0E04\u0E35\u0E21\u0E32\u0E44\u0E21\u0E48\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E21\u0E35\u0E04\u0E38\u0E13\u0E2A\u0E21\u0E1A\u0E31\u0E15\u0E34\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1B\u0E23\u0E30\u0E40\u0E21\u0E34\u0E19 +unionType = \u0E1E\u0E1A {0}, \u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23 {1} +uniqueItems = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E0B\u0E49\u0E33\u0E43\u0E19\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C +writeOnly = \u0E40\u0E1B\u0E47\u0E19\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E41\u0E1A\u0E1A\u0E40\u0E02\u0E35\u0E22\u0E19\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19 \u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E1B\u0E23\u0E32\u0E01\u0E0F\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E14\u0E49 +contentEncoding = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E40\u0E02\u0E49\u0E32\u0E23\u0E2B\u0E31\u0E2A\u0E40\u0E19\u0E37\u0E49\u0E2D\u0E2B\u0E32 {0} +contentMediaType = \u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E40\u0E19\u0E37\u0E49\u0E2D\u0E2B\u0E32\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19 diff --git a/src/main/resources/jsv-messages_tr.properties b/src/main/resources/jsv-messages_tr.properties index 20e9b3a48..08823b951 100644 --- a/src/main/resources/jsv-messages_tr.properties +++ b/src/main/resources/jsv-messages_tr.properties @@ -1,70 +1,70 @@ -$ref = {0}: ''refs'' ile ilgili bir hata var -additionalItems = {0}: ''{1}'' dizini \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek ö\u011Felere izin vermiyor -additionalProperties = {0}: ''{1}'' özelli\u011Fi \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek özelliklere izin vermiyor -allOf = {0}: tüm {1} \u015Femalar\u0131 için geçerli olmal\u0131d\u0131r -anyOf = {0}: {1} \u015Femalar\u0131ndan herhangi biri için geçerli olmal\u0131d\u0131r -const = {0}: ''{1}'' sabit de\u011Feri olmal\u0131d\u0131r -contains = {0}: bu do\u011Frulamalar\u0131 geçen bir ö\u011Fe içermiyor: {2} -contains.max = {0}: \u015Fu do\u011Frulamalar\u0131 geçen en fazla {1} ö\u011Fe içermelidir: {2} -contains.min = {0}: \u015Fu do\u011Frulamalar\u0131 geçen en az {1} ö\u011Fe içermelidir: {2} -dependencies = {0}: ba\u011F\u0131ml\u0131l\u0131klarda hata var {1} -dependentRequired = {0}: ''{1}'' eksik bir özelli\u011Fi var ve ''{2}'' mevcut oldu\u011Fundan ba\u011F\u0131ml\u0131 gerekli -dependentSchemas = {0}: DependedSchemas {1} ile ilgili bir hata var -enum = {0}: {1} numaraland\u0131rmas\u0131nda bir de\u011Fer yok -exclusiveMaximum = {0}: özel maksimum de\u011Feri {1} olmal\u0131d\u0131r -exclusiveMinimum = {0}: özel minimum de\u011Feri {1} olmal\u0131d\u0131r -false = {0}: ''{1}'' \u015Femas\u0131 yanl\u0131\u015F -format = {0}: {1} modeliyle {2} e\u015Fle\u015Fmiyor -format.date = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tam tarihi olmal\u0131d\u0131r -format.date-time = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tarih-saat olmal\u0131d\u0131r -format.duration = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir ISO 8601 süresi olmal\u0131d\u0131r -format.email = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 5321 Posta Kutusu olmal\u0131d\u0131r -format.ipv4 = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 2673 IP adresi olmal\u0131d\u0131r -format.ipv6 = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 4291 IP adresi olmal\u0131d\u0131r -format.idn-email = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6531 Posta Kutusu olmal\u0131d\u0131r -format.idn-hostname = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 5890 uluslararas\u0131la\u015Ft\u0131r\u0131lm\u0131\u015F ana bilgisayar ad\u0131 olmal\u0131d\u0131r -format.iri = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3987 IRI olmal\u0131d\u0131r -format.iri-reference = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3987 IRI referans\u0131 olmal\u0131d\u0131r -format.uri = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3986 URI olmal\u0131d\u0131r -format.uri-reference = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3986 URI referans\u0131 olmal\u0131d\u0131r -format.uri-template = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6570 URI \u015Eablonu olmal\u0131d\u0131r -format.uuid = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 4122 UUID olmal\u0131d\u0131r -format.regex = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir ECMA-262 normal ifadesi olmal\u0131d\u0131r -format.time = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 saati olmal\u0131d\u0131r -format.hostname = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 1123 ana bilgisayar ad\u0131 olmal\u0131d\u0131r -format.json-pointer = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6901 JSON \u0130\u015Faretçisi olmal\u0131d\u0131r -format.relative-json-pointer = {0}: {1} modeliyle e\u015Fle\u015Fmiyor, geçerli bir IETF Göreli JSON \u0130\u015Faretçisi olmal\u0131d\u0131r -format.unknown = {0}: bilinmeyen bir formata sahip ''{1}'' -id = {0}: ''{1}'' geçerli bir {2} de\u011Fil -items = {0}: ''{1}'' dizini \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek ö\u011Felere izin vermiyor -maxContains = {0}: {1}''de negatif olmayan bir tamsay\u0131 olmal\u0131d\u0131r -maxItems = {0}: en fazla {1} ö\u011Feye sahip olmal\u0131 ancak {2} bulundu -maxLength = {0}: en fazla {1} karakter uzunlu\u011Funda olmal\u0131d\u0131r -maxProperties = {0}: en fazla {1} özelli\u011Fe sahip olmal\u0131d\u0131r -maximum = {0}: maksimum de\u011Feri {1} olmal\u0131d\u0131r -minContains = {0}: {1}''de negatif olmayan bir tam say\u0131 olmal\u0131d\u0131r -minContainsVsMaxContains = {0}: minContains, {1} içindeki maxContains de\u011Ferinden küçük veya ona e\u015Fit olmal\u0131d\u0131r -minItems = {0}: en az {1} ö\u011Feye sahip olmal\u0131 ancak {2} bulundu -minLength = {0}: en az {1} karakter uzunlu\u011Funda olmal\u0131d\u0131r -minProperties = {0}: en az {1} özelli\u011Fe sahip olmal\u0131d\u0131r -minimum = {0}: minimum de\u011Feri {1} olmal\u0131d\u0131r -multipleOf = {0}: {1}''\u0131n kat\u0131 olmal\u0131d\u0131r -not = {0}: {1} \u015Femas\u0131 için geçerli olmamal\u0131d\u0131r -notAllowed = {0}: ''{1}'' özelli\u011Fine izin verilmiyor ancak verilerde mevcut -oneOf = {0}: yaln\u0131zca bir \u015Fema için geçerli olmal\u0131d\u0131r, ancak {1} geçerlidir -oneOf.indexes = {0}: yaln\u0131zca bir \u015Fema için geçerli olmal\u0131d\u0131r, ancak {1} ''{2}'' dizinleriyle geçerlidir -pattern = {0}: normal ifade modeli {1} ile e\u015Fle\u015Fmiyor -patternProperties = {0}: ''desen özelliklerinde'' baz\u0131 hatalar var -prefixItems = {0}: bu dizinde do\u011Frulay\u0131c\u0131 bulunamad\u0131 -properties = {0}: ''özellikler'' ile ilgili bir hata var -propertyNames = {0}: ''{1}'' özelli\u011Finin ad\u0131 geçerli de\u011Fil: {2} -readOnly = {0}: salt okunur bir aland\u0131r, de\u011Fi\u015Ftirilemez -required = {0}: gerekli ''{1}'' özelli\u011Fi bulunamad\u0131 -type = {0}: {1} bulundu, {2} bekleniyor -unevaluatedItems = {0}: ''{1}'' dizini de\u011Ferlendirilmez ve \u015Fema, de\u011Ferlendirilmemi\u015F ö\u011Felere izin vermez -unevaluatedProperties = {0}: ''{1}'' özelli\u011Fi de\u011Ferlendirilmez ve \u015Fema, de\u011Ferlendirilmemi\u015F özelliklere izin vermez -unionType = {0}: {1} bulundu, {2} bekleniyor -uniqueItems = {0}: dizide yaln\u0131zca benzersiz ö\u011Feler bulunmal\u0131d\u0131r -writeOnly = {0}: salt yaz\u0131l\u0131r bir aland\u0131r, verilerde görünemez -contentEncoding = {0}: içerik kodlamas\u0131 {1} ile e\u015Fle\u015Fmiyor -contentMediaType = {0}: bir içerik de\u011Fil +$ref = ''refs'' ile ilgili bir hata var +additionalItems = ''{0}'' dizini \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek ö\u011Felere izin vermiyor +additionalProperties = ''{0}'' özelli\u011Fi \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek özelliklere izin vermiyor +allOf = tüm {0} \u015Femalar\u0131 için geçerli olmal\u0131d\u0131r +anyOf = {0} \u015Femalar\u0131ndan herhangi biri için geçerli olmal\u0131d\u0131r +const = ''{0}'' sabit de\u011Feri olmal\u0131d\u0131r +contains = bu do\u011Frulamalar\u0131 geçen bir ö\u011Fe içermiyor: {1} +contains.max = \u015Fu do\u011Frulamalar\u0131 geçen en fazla {0} ö\u011Fe içermelidir: {1} +contains.min = \u015Fu do\u011Frulamalar\u0131 geçen en az {0} ö\u011Fe içermelidir: {1} +dependencies = ba\u011F\u0131ml\u0131l\u0131klarda hata var {0} +dependentRequired = ''{0}'' eksik bir özelli\u011Fi var ve ''{1}'' mevcut oldu\u011Fundan ba\u011F\u0131ml\u0131 gerekli +dependentSchemas = DependedSchemas {0} ile ilgili bir hata var +enum = {0} numaraland\u0131rmas\u0131nda bir de\u011Fer yok +exclusiveMaximum = özel maksimum de\u011Feri {0} olmal\u0131d\u0131r +exclusiveMinimum = özel minimum de\u011Feri {0} olmal\u0131d\u0131r +false = ''{0}'' \u015Femas\u0131 yanl\u0131\u015F +format = {0} modeliyle {1} e\u015Fle\u015Fmiyor +format.date = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tam tarihi olmal\u0131d\u0131r +format.date-time = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tarih-saat olmal\u0131d\u0131r +format.duration = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir ISO 8601 süresi olmal\u0131d\u0131r +format.email = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 5321 Posta Kutusu olmal\u0131d\u0131r +format.ipv4 = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 2673 IP adresi olmal\u0131d\u0131r +format.ipv6 = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 4291 IP adresi olmal\u0131d\u0131r +format.idn-email = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6531 Posta Kutusu olmal\u0131d\u0131r +format.idn-hostname = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 5890 uluslararas\u0131la\u015Ft\u0131r\u0131lm\u0131\u015F ana bilgisayar ad\u0131 olmal\u0131d\u0131r +format.iri = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3987 IRI olmal\u0131d\u0131r +format.iri-reference = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3987 IRI referans\u0131 olmal\u0131d\u0131r +format.uri = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3986 URI olmal\u0131d\u0131r +format.uri-reference = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3986 URI referans\u0131 olmal\u0131d\u0131r +format.uri-template = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6570 URI \u015Eablonu olmal\u0131d\u0131r +format.uuid = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 4122 UUID olmal\u0131d\u0131r +format.regex = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir ECMA-262 normal ifadesi olmal\u0131d\u0131r +format.time = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 saati olmal\u0131d\u0131r +format.hostname = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 1123 ana bilgisayar ad\u0131 olmal\u0131d\u0131r +format.json-pointer = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 6901 JSON \u0130\u015Faretçisi olmal\u0131d\u0131r +format.relative-json-pointer = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir IETF Göreli JSON \u0130\u015Faretçisi olmal\u0131d\u0131r +format.unknown = bilinmeyen bir formata sahip ''{0}'' +id = ''{0}'' geçerli bir {1} de\u011Fil +items = ''{0}'' dizini \u015Femada tan\u0131ml\u0131 de\u011Fil ve \u015Fema ek ö\u011Felere izin vermiyor +maxContains = {0}''de negatif olmayan bir tamsay\u0131 olmal\u0131d\u0131r +maxItems = en fazla {0} ö\u011Feye sahip olmal\u0131 ancak {1} bulundu +maxLength = en fazla {0} karakter uzunlu\u011Funda olmal\u0131d\u0131r +maxProperties = en fazla {0} özelli\u011Fe sahip olmal\u0131d\u0131r +maximum = maksimum de\u011Feri {0} olmal\u0131d\u0131r +minContains = {0}''de negatif olmayan bir tam say\u0131 olmal\u0131d\u0131r +minContainsVsMaxContains = minContains, {0} içindeki maxContains de\u011Ferinden küçük veya ona e\u015Fit olmal\u0131d\u0131r +minItems = en az {0} ö\u011Feye sahip olmal\u0131 ancak {1} bulundu +minLength = en az {0} karakter uzunlu\u011Funda olmal\u0131d\u0131r +minProperties = en az {0} özelli\u011Fe sahip olmal\u0131d\u0131r +minimum = minimum de\u011Feri {0} olmal\u0131d\u0131r +multipleOf = {0}''\u0131n kat\u0131 olmal\u0131d\u0131r +not = {0} \u015Femas\u0131 için geçerli olmamal\u0131d\u0131r +notAllowed = ''{0}'' özelli\u011Fine izin verilmiyor ancak verilerde mevcut +oneOf = yaln\u0131zca bir \u015Fema için geçerli olmal\u0131d\u0131r, ancak {0} geçerlidir +oneOf.indexes = yaln\u0131zca bir \u015Fema için geçerli olmal\u0131d\u0131r, ancak {0} ''{1}'' dizinleriyle geçerlidir +pattern = normal ifade modeli {0} ile e\u015Fle\u015Fmiyor +patternProperties = ''desen özelliklerinde'' baz\u0131 hatalar var +prefixItems = bu dizinde do\u011Frulay\u0131c\u0131 bulunamad\u0131 +properties = ''özellikler'' ile ilgili bir hata var +propertyNames = ''{0}'' özelli\u011Finin ad\u0131 geçerli de\u011Fil: {1} +readOnly = salt okunur bir aland\u0131r, de\u011Fi\u015Ftirilemez +required = gerekli ''{0}'' özelli\u011Fi bulunamad\u0131 +type = {0} bulundu, {1} bekleniyor +unevaluatedItems = ''{0}'' dizini de\u011Ferlendirilmez ve \u015Fema, de\u011Ferlendirilmemi\u015F ö\u011Felere izin vermez +unevaluatedProperties = ''{0}'' özelli\u011Fi de\u011Ferlendirilmez ve \u015Fema, de\u011Ferlendirilmemi\u015F özelliklere izin vermez +unionType = {0} bulundu, {1} bekleniyor +uniqueItems = dizide yaln\u0131zca benzersiz ö\u011Feler bulunmal\u0131d\u0131r +writeOnly = salt yaz\u0131l\u0131r bir aland\u0131r, verilerde görünemez +contentEncoding = içerik kodlamas\u0131 {0} ile e\u015Fle\u015Fmiyor +contentMediaType = bir içerik de\u011Fil diff --git a/src/main/resources/jsv-messages_uk.properties b/src/main/resources/jsv-messages_uk.properties index ee627824a..2e8d1b464 100644 --- a/src/main/resources/jsv-messages_uk.properties +++ b/src/main/resources/jsv-messages_uk.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0437 ''refs'' -additionalItems = {0}: \u0456\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 -additionalProperties = {0}: \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{1}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0456 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 -allOf = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0432\u0441\u0456\u0445 \u0441\u0445\u0435\u043C {1} -anyOf = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0431\u0443\u0434\u044C-\u044F\u043A\u043E\u0457 \u0437\u0456 \u0441\u0445\u0435\u043C {1} -const = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043F\u043E\u0441\u0442\u0456\u0439\u043D\u0438\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F\u043C ''{1}'' -contains = {0}: \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u0435\u043B\u0435\u043C\u0435\u043D\u0442, \u044F\u043A\u0438\u0439 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {2} -contains.max = {0}: \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {1} \u0435\u043B\u0435\u043C\u0435\u043D\u0442(\u0456\u0432), \u044F\u043A\u0456 \u043F\u0440\u043E\u0445\u043E\u0434\u044F\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {2} -contains.min = {0}: \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {1} \u0435\u043B\u0435\u043C\u0435\u043D\u0442(\u0456\u0432), \u044F\u043A\u0456 \u043F\u0440\u043E\u0445\u043E\u0434\u044F\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {2} -dependencies = {0}: \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0456\u0437 \u0437\u0430\u043B\u0435\u0436\u043D\u043E\u0441\u0442\u044F\u043C\u0438 {1} -dependentRequired = {0}: \u043C\u0430\u0454 \u0432\u0456\u0434\u0441\u0443\u0442\u043D\u044E \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{1}'', \u044F\u043A\u0430 \u0454 \u0437\u0430\u043B\u0435\u0436\u043D\u043E\u044E, \u043E\u0441\u043A\u0456\u043B\u044C\u043A\u0438 \u043F\u0440\u0438\u0441\u0443\u0442\u043D\u044F ''{2}'' -dependentSchemas = {0}: \u0454 \u043F\u043E\u043C\u0438\u043B\u043A\u0430 \u0437 dependentSchemas {1} -enum = {0}: \u043D\u0435 \u043C\u0430\u0454 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0432 \u043F\u0435\u0440\u0435\u043B\u0456\u043A\u0443 {1} -exclusiveMaximum = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {1} -exclusiveMinimum = {0}: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0456\u043D\u0456\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {1} -false = {0}: \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{1}'' \u043D\u0435\u0432\u0456\u0440\u043D\u0430 -format = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} {2} -format.date = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0432\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E RFC 3339 -format.date-time = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E-\u0447\u0430\u0441\u043E\u043C RFC 3339 -format.duration = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044E ISO 8601 -format.email = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0448\u0442\u043E\u0432\u043E\u044E \u0441\u043A\u0440\u0438\u043D\u044C\u043A\u043E\u044E RFC 5321 -format.ipv4 = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E IP-\u0430\u0434\u0440\u0435\u0441\u043E\u044E RFC 2673 -format.ipv6 = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E IP-\u0430\u0434\u0440\u0435\u0441\u043E\u044E RFC 4291 -format.idn-email = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0448\u0442\u043E\u0432\u043E\u044E \u0441\u043A\u0440\u0438\u043D\u044C\u043A\u043E\u044E RFC 6531 -format.idn-hostname = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0456\u043D\u0442\u0435\u0440\u043D\u0430\u0446\u0456\u043E\u043D\u0430\u043B\u0456\u0437\u043E\u0432\u0430\u043D\u0438\u043C \u0456\u043C\u2019\u044F\u043C \u0445\u043E\u0441\u0442\u0430 RFC 5890 -format.iri = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C RFC 3987 IRI -format.iri-reference = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F\u043C IRI RFC 3987 -format.uri = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C URI RFC 3986 -format.uri-reference = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F\u043C URI RFC 3986 -format.uri-template = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C URI RFC 6570 -format.uuid = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C UUID RFC 4122 -format.regex = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u0438\u043C \u0432\u0438\u0440\u0430\u0437\u043E\u043C ECMA-262 -format.time = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0447\u0430\u0441\u043E\u043C RFC 3339 -format.hostname = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0456\u043C\u2019\u044F\u043C \u0445\u043E\u0441\u0442\u0430 RFC 1123 -format.json-pointer = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C RFC 6901 JSON Pointer -format.relative-json-pointer = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {1}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0432\u0456\u0434\u043D\u043E\u0441\u043D\u0438\u043C \u043F\u043E\u043A\u0430\u0436\u0447\u0438\u043A\u043E\u043C JSON IETF -format.unknown = {0}: \u043C\u0430\u0454 \u043D\u0435\u0432\u0456\u0434\u043E\u043C\u0438\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 ''{1}'' -id = {0}: ''{1}'' \u043D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 {2} -items = {0}: \u0456\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0438\u0445 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432 -maxContains = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043D\u0435\u0432\u0456\u0434\u2019\u0454\u043C\u043D\u0438\u043C \u0446\u0456\u043B\u0438\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0443 {1} -maxItems = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {1} \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432, \u0430\u043B\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {2} -maxLength = {0}: \u043D\u0435 \u0431\u0456\u043B\u044C\u0448\u0435 \u043D\u0456\u0436 {1} \u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432 -maxProperties = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {1} \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0435\u0439 -maximum = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {1} -minContains = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043D\u0435\u0432\u0456\u0434\u2019\u0454\u043C\u043D\u0438\u043C \u0446\u0456\u043B\u0438\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0443 {1} -minContainsVsMaxContains = {0}: minContains \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043C\u0435\u043D\u0448\u0438\u043C \u0430\u0431\u043E \u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u0442\u0438 maxContains \u0443 {1} -minItems = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {1} \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432, \u0430\u043B\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {2} -minLength = {0}: \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {1} \u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432 -minProperties = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {1} \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0435\u0439 -minimum = {0}: \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043C\u0456\u043D\u0456\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {1} -multipleOf = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C {1} -not = {0}: \u043D\u0435 \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0441\u0445\u0435\u043C\u0438 {1} -notAllowed = {0}: \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{1}'' \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u0435\u043D\u0430, \u0430\u043B\u0435 \u0432\u043E\u043D\u0430 \u0454 \u0432 \u0434\u0430\u043D\u0438\u0445 -oneOf = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u043E\u0434\u043D\u0456\u0454\u0457 \u0439 \u043B\u0438\u0448\u0435 \u043E\u0434\u043D\u0456\u0454\u0457 \u0441\u0445\u0435\u043C\u0438, \u0430\u043B\u0435 {1} \u0454 \u0434\u0456\u0439\u0441\u043D\u0438\u043C\u0438 -oneOf.indexes = {0}: \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u043E\u0434\u043D\u0456\u0454\u0457 \u0439 \u043B\u0438\u0448\u0435 \u043E\u0434\u043D\u0456\u0454\u0457 \u0441\u0445\u0435\u043C\u0438, \u0430\u043B\u0435 {1} \u0454 \u0434\u0456\u0439\u0441\u043D\u0438\u043C\u0438 \u0437 \u0456\u043D\u0434\u0435\u043A\u0441\u0430\u043C\u0438 ''{2}'' -pattern = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u043E\u0433\u043E \u0432\u0438\u0440\u0430\u0437\u0443 {1} -patternProperties = {0}: \u0454 \u0434\u0435\u044F\u043A\u0430 \u043F\u043E\u043C\u0438\u043B\u043A\u0430 \u0437 ''\u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 \u0448\u0430\u0431\u043B\u043E\u043D\u0443'' -prefixItems = {0}: \u0437\u0430 \u0446\u0438\u043C \u0456\u043D\u0434\u0435\u043A\u0441\u043E\u043C \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E \u0432\u0430\u043B\u0456\u0434\u0430\u0442\u043E\u0440\u0430 -properties = {0}: \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0437 ''\u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456'' -propertyNames = {0}: \u043D\u0430\u0437\u0432\u0430 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 ''{1}'' \u043D\u0435\u0434\u0456\u0439\u0441\u043D\u0430: {2} -readOnly = {0}: \u0446\u0435 \u043F\u043E\u043B\u0435 \u043B\u0438\u0448\u0435 \u0434\u043B\u044F \u0447\u0438\u0442\u0430\u043D\u043D\u044F, \u0439\u043E\u0433\u043E \u043D\u0435 \u043C\u043E\u0436\u043D\u0430 \u0437\u043C\u0456\u043D\u0438\u0442\u0438 -required = {0}: \u043D\u0435\u043E\u0431\u0445\u0456\u0434\u043D\u0430 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{1}'' \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0430 -type = {0}: \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {1}, \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F {2} -unevaluatedItems = {0}: \u0456\u043D\u0434\u0435\u043A\u0441 ''{1}'' \u043D\u0435 \u043E\u0446\u0456\u043D\u044E\u0454\u0442\u044C\u0441\u044F, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u043D\u0435 \u043E\u0446\u0456\u043D\u0435\u043D\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 -unevaluatedProperties = {0}: \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{1}'' \u043D\u0435 \u043E\u0446\u0456\u043D\u044E\u0454\u0442\u044C\u0441\u044F, \u0430 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 \u0431\u0435\u0437 \u043E\u0446\u0456\u043D\u043A\u0438 -unionType = {0}: \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {1}, \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F {2} -uniqueItems = {0}: \u0443 \u043C\u0430\u0441\u0438\u0432\u0456 \u043F\u043E\u0432\u0438\u043D\u043D\u0456 \u0431\u0443\u0442\u0438 \u043B\u0438\u0448\u0435 \u0443\u043D\u0456\u043A\u0430\u043B\u044C\u043D\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 -writeOnly = {0}: \u0446\u0435 \u043F\u043E\u043B\u0435 \u043B\u0438\u0448\u0435 \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0443, \u0432\u043E\u043D\u043E \u043D\u0435 \u043C\u043E\u0436\u0435 \u0432\u0456\u0434\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u0438\u0441\u044F \u0432 \u0434\u0430\u043D\u0438\u0445 -contentEncoding = {0}: \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u044E \u0432\u043C\u0456\u0441\u0442\u0443 {1} -contentMediaType = {0}: \u043D\u0435 \u0454 \u0432\u043C\u0456\u0441\u0442\u043E\u043C me +$ref = \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0437 ''refs'' +additionalItems = \u0456\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 +additionalProperties = \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{0}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0456 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 +allOf = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0432\u0441\u0456\u0445 \u0441\u0445\u0435\u043C {0} +anyOf = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0431\u0443\u0434\u044C-\u044F\u043A\u043E\u0457 \u0437\u0456 \u0441\u0445\u0435\u043C {0} +const = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043F\u043E\u0441\u0442\u0456\u0439\u043D\u0438\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F\u043C ''{0}'' +contains = \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u0435\u043B\u0435\u043C\u0435\u043D\u0442, \u044F\u043A\u0438\u0439 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {1} +contains.max = \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {0} \u0435\u043B\u0435\u043C\u0435\u043D\u0442(\u0456\u0432), \u044F\u043A\u0456 \u043F\u0440\u043E\u0445\u043E\u0434\u044F\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {1} +contains.min = \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {0} \u0435\u043B\u0435\u043C\u0435\u043D\u0442(\u0456\u0432), \u044F\u043A\u0456 \u043F\u0440\u043E\u0445\u043E\u0434\u044F\u0442\u044C \u0446\u0456 \u043F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0438: {1} +dependencies = \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0456\u0437 \u0437\u0430\u043B\u0435\u0436\u043D\u043E\u0441\u0442\u044F\u043C\u0438 {0} +dependentRequired = \u043C\u0430\u0454 \u0432\u0456\u0434\u0441\u0443\u0442\u043D\u044E \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{0}'', \u044F\u043A\u0430 \u0454 \u0437\u0430\u043B\u0435\u0436\u043D\u043E\u044E, \u043E\u0441\u043A\u0456\u043B\u044C\u043A\u0438 \u043F\u0440\u0438\u0441\u0443\u0442\u043D\u044F ''{1}'' +dependentSchemas = \u0454 \u043F\u043E\u043C\u0438\u043B\u043A\u0430 \u0437 dependentSchemas {0} +enum = \u043D\u0435 \u043C\u0430\u0454 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0432 \u043F\u0435\u0440\u0435\u043B\u0456\u043A\u0443 {0} +exclusiveMaximum = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} +exclusiveMinimum = \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0456\u043D\u0456\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} +false = \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{0}'' \u043D\u0435\u0432\u0456\u0440\u043D\u0430 +format = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} {1} +format.date = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0432\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E RFC 3339 +format.date-time = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E-\u0447\u0430\u0441\u043E\u043C RFC 3339 +format.duration = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044E ISO 8601 +format.email = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0448\u0442\u043E\u0432\u043E\u044E \u0441\u043A\u0440\u0438\u043D\u044C\u043A\u043E\u044E RFC 5321 +format.ipv4 = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E IP-\u0430\u0434\u0440\u0435\u0441\u043E\u044E RFC 2673 +format.ipv6 = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E IP-\u0430\u0434\u0440\u0435\u0441\u043E\u044E RFC 4291 +format.idn-email = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0448\u0442\u043E\u0432\u043E\u044E \u0441\u043A\u0440\u0438\u043D\u044C\u043A\u043E\u044E RFC 6531 +format.idn-hostname = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0456\u043D\u0442\u0435\u0440\u043D\u0430\u0446\u0456\u043E\u043D\u0430\u043B\u0456\u0437\u043E\u0432\u0430\u043D\u0438\u043C \u0456\u043C\u2019\u044F\u043C \u0445\u043E\u0441\u0442\u0430 RFC 5890 +format.iri = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C RFC 3987 IRI +format.iri-reference = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F\u043C IRI RFC 3987 +format.uri = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C URI RFC 3986 +format.uri-reference = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F\u043C URI RFC 3986 +format.uri-template = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C URI RFC 6570 +format.uuid = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C UUID RFC 4122 +format.regex = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u0438\u043C \u0432\u0438\u0440\u0430\u0437\u043E\u043C ECMA-262 +format.time = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0447\u0430\u0441\u043E\u043C RFC 3339 +format.hostname = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0456\u043C\u2019\u044F\u043C \u0445\u043E\u0441\u0442\u0430 RFC 1123 +format.json-pointer = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C RFC 6901 JSON Pointer +format.relative-json-pointer = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0432\u0456\u0434\u043D\u043E\u0441\u043D\u0438\u043C \u043F\u043E\u043A\u0430\u0436\u0447\u0438\u043A\u043E\u043C JSON IETF +format.unknown = \u043C\u0430\u0454 \u043D\u0435\u0432\u0456\u0434\u043E\u043C\u0438\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 ''{0}'' +id = ''{0}'' \u043D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 {1} +items = \u0456\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E \u0432 \u0441\u0445\u0435\u043C\u0456, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0434\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u0438\u0445 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432 +maxContains = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043D\u0435\u0432\u0456\u0434\u2019\u0454\u043C\u043D\u0438\u043C \u0446\u0456\u043B\u0438\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0443 {0} +maxItems = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {0} \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432, \u0430\u043B\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {1} +maxLength = \u043D\u0435 \u0431\u0456\u043B\u044C\u0448\u0435 \u043D\u0456\u0436 {0} \u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432 +maxProperties = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0449\u043E\u043D\u0430\u0439\u0431\u0456\u043B\u044C\u0448\u0435 {0} \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0435\u0439 +maximum = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} +minContains = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043D\u0435\u0432\u0456\u0434\u2019\u0454\u043C\u043D\u0438\u043C \u0446\u0456\u043B\u0438\u043C \u0447\u0438\u0441\u043B\u043E\u043C \u0443 {0} +minContainsVsMaxContains = minContains \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043C\u0435\u043D\u0448\u0438\u043C \u0430\u0431\u043E \u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u0442\u0438 maxContains \u0443 {0} +minItems = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {0} \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432, \u0430\u043B\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {1} +minLength = \u043C\u0430\u0454 \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {0} \u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432 +minProperties = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043F\u0440\u0438\u043D\u0430\u0439\u043C\u043D\u0456 {0} \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0435\u0439 +minimum = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u043C\u0456\u043D\u0456\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} +multipleOf = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C {0} +not = \u043D\u0435 \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u0441\u0445\u0435\u043C\u0438 {0} +notAllowed = \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{0}'' \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u0435\u043D\u0430, \u0430\u043B\u0435 \u0432\u043E\u043D\u0430 \u0454 \u0432 \u0434\u0430\u043D\u0438\u0445 +oneOf = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u043E\u0434\u043D\u0456\u0454\u0457 \u0439 \u043B\u0438\u0448\u0435 \u043E\u0434\u043D\u0456\u0454\u0457 \u0441\u0445\u0435\u043C\u0438, \u0430\u043B\u0435 {0} \u0454 \u0434\u0456\u0439\u0441\u043D\u0438\u043C\u0438 +oneOf.indexes = \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u0438\u043C \u0434\u043B\u044F \u043E\u0434\u043D\u0456\u0454\u0457 \u0439 \u043B\u0438\u0448\u0435 \u043E\u0434\u043D\u0456\u0454\u0457 \u0441\u0445\u0435\u043C\u0438, \u0430\u043B\u0435 {0} \u0454 \u0434\u0456\u0439\u0441\u043D\u0438\u043C\u0438 \u0437 \u0456\u043D\u0434\u0435\u043A\u0441\u0430\u043C\u0438 ''{1}'' +pattern = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0440\u0435\u0433\u0443\u043B\u044F\u0440\u043D\u043E\u0433\u043E \u0432\u0438\u0440\u0430\u0437\u0443 {0} +patternProperties = \u0454 \u0434\u0435\u044F\u043A\u0430 \u043F\u043E\u043C\u0438\u043B\u043A\u0430 \u0437 ''\u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 \u0448\u0430\u0431\u043B\u043E\u043D\u0443'' +prefixItems = \u0437\u0430 \u0446\u0438\u043C \u0456\u043D\u0434\u0435\u043A\u0441\u043E\u043C \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E \u0432\u0430\u043B\u0456\u0434\u0430\u0442\u043E\u0440\u0430 +properties = \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u043C\u0438\u043B\u043A\u0443 \u0437 ''\u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456'' +propertyNames = \u043D\u0430\u0437\u0432\u0430 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 ''{0}'' \u043D\u0435\u0434\u0456\u0439\u0441\u043D\u0430: {1} +readOnly = \u0446\u0435 \u043F\u043E\u043B\u0435 \u043B\u0438\u0448\u0435 \u0434\u043B\u044F \u0447\u0438\u0442\u0430\u043D\u043D\u044F, \u0439\u043E\u0433\u043E \u043D\u0435 \u043C\u043E\u0436\u043D\u0430 \u0437\u043C\u0456\u043D\u0438\u0442\u0438 +required = \u043D\u0435\u043E\u0431\u0445\u0456\u0434\u043D\u0430 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{0}'' \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0430 +type = \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {0}, \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F {1} +unevaluatedItems = \u0456\u043D\u0434\u0435\u043A\u0441 ''{0}'' \u043D\u0435 \u043E\u0446\u0456\u043D\u044E\u0454\u0442\u044C\u0441\u044F, \u0456 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u043D\u0435 \u043E\u0446\u0456\u043D\u0435\u043D\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 +unevaluatedProperties = \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044C ''{0}'' \u043D\u0435 \u043E\u0446\u0456\u043D\u044E\u0454\u0442\u044C\u0441\u044F, \u0430 \u0441\u0445\u0435\u043C\u0430 \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043B\u044F\u0454 \u0432\u043B\u0430\u0441\u0442\u0438\u0432\u043E\u0441\u0442\u0456 \u0431\u0435\u0437 \u043E\u0446\u0456\u043D\u043A\u0438 +unionType = \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E {0}, \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F {1} +uniqueItems = \u0443 \u043C\u0430\u0441\u0438\u0432\u0456 \u043F\u043E\u0432\u0438\u043D\u043D\u0456 \u0431\u0443\u0442\u0438 \u043B\u0438\u0448\u0435 \u0443\u043D\u0456\u043A\u0430\u043B\u044C\u043D\u0456 \u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438 +writeOnly = \u0446\u0435 \u043F\u043E\u043B\u0435 \u043B\u0438\u0448\u0435 \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0443, \u0432\u043E\u043D\u043E \u043D\u0435 \u043C\u043E\u0436\u0435 \u0432\u0456\u0434\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u0438\u0441\u044F \u0432 \u0434\u0430\u043D\u0438\u0445 +contentEncoding = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u044E \u0432\u043C\u0456\u0441\u0442\u0443 {0} +contentMediaType = \u043D\u0435 \u0454 \u0432\u043C\u0456\u0441\u0442\u043E\u043C me diff --git a/src/main/resources/jsv-messages_vi.properties b/src/main/resources/jsv-messages_vi.properties index 94797c3b6..aa18b6e53 100644 --- a/src/main/resources/jsv-messages_vi.properties +++ b/src/main/resources/jsv-messages_vi.properties @@ -1,70 +1,70 @@ -$ref = {0}: có l\u1ED7i ''refs'' -additionalItems = {0}: ch\u1EC9 m\u1EE5c ''{1}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c b\u1ED5 sung -additionalProperties = {0}: thu\u1ED9c tính ''{1}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các thu\u1ED9c tính b\u1ED5 sung -allOf = {0}: ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi t\u1EA5t c\u1EA3 l\u01B0\u1EE3c \u0111\u1ED3 {1} -anyOf = {0}: ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi b\u1EA5t k\u1EF3 l\u01B0\u1EE3c \u0111\u1ED3 nào {1} -const = {0}: ph\u1EA3i là giá tr\u1ECB không \u0111\u1ED5i ''{1}'' -contains = {0}: không ch\u1EE9a ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác nh\u1EADn này: {2} -contains.max = {0}: ph\u1EA3i ch\u1EE9a t\u1ED1i \u0111a {1} ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác th\u1EF1c này: {2} -contains.min = {0}: ph\u1EA3i ch\u1EE9a ít nh\u1EA5t {1} ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác nh\u1EADn này: {2} -dependencies = {0}: có l\u1ED7i v\u1EDBi ph\u1EE5 thu\u1ED9c {1} -dependentRequired = {0}: thi\u1EBFu thu\u1ED9c tính ''{1}'' thu\u1ED9c tính ph\u1EE5 thu\u1ED9c b\u1EAFt bu\u1ED9c vì ''{2}'' hi\u1EC7n di\u1EC7n -dependentSchemas = {0}: có l\u1ED7i v\u1EDBi dependencySchemas {1} -enum = {0}: không có giá tr\u1ECB trong b\u1EA3ng li\u1EC7t kê {1} -exclusiveMaximum = {0}: ph\u1EA3i có giá tr\u1ECB t\u1ED1i \u0111a \u0111\u1ED9c quy\u1EC1n là {1} -exclusiveMinimum = {0}: ph\u1EA3i có giá tr\u1ECB t\u1ED1i thi\u1EC3u duy nh\u1EA5t là {1} -false = {0}: l\u01B0\u1EE3c \u0111\u1ED3 cho ''{1}'' là sai -format = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} {2} -format.date = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là ngày \u0111\u1EA7y \u0111\u1EE7 RFC 3339 h\u1EE3p l\u1EC7 -format.date-time = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là ngày gi\u1EDD h\u1EE3p l\u1EC7 RFC 3339 -format.duration = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i có th\u1EDDi l\u01B0\u1EE3ng ISO 8601 h\u1EE3p l\u1EC7 -format.email = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là H\u1ED9p th\u01B0 RFC 5321 h\u1EE3p l\u1EC7 -format.ipv4 = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là \u0111\u1ECBa ch\u1EC9 IP RFC 2673 h\u1EE3p l\u1EC7 -format.ipv6 = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là \u0111\u1ECBa ch\u1EC9 IP RFC 4291 h\u1EE3p l\u1EC7 -format.idn-email = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là H\u1ED9p th\u01B0 RFC 6531 h\u1EE3p l\u1EC7 -format.idn-hostname = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là tên máy ch\u1EE7 \u0111\u01B0\u1EE3c qu\u1ED1c t\u1EBF hóa RFC 5890 h\u1EE3p l\u1EC7 -format.iri = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là RFC 3987 IRI h\u1EE3p l\u1EC7 -format.iri-reference = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là tham chi\u1EBFu IRI RFC 3987 h\u1EE3p l\u1EC7 -format.uri = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là URI RFC 3986 h\u1EE3p l\u1EC7 -format.uri-reference = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là tham chi\u1EBFu URI RFC 3986 h\u1EE3p l\u1EC7 -format.uri-template = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là M\u1EABu URI RFC 6570 h\u1EE3p l\u1EC7 -format.uuid = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là UUID RFC 4122 h\u1EE3p l\u1EC7 -format.regex = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là bi\u1EC3u th\u1EE9c chính quy ECMA-262 h\u1EE3p l\u1EC7 -format.time = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là th\u1EDDi gian RFC 3339 h\u1EE3p l\u1EC7 -format.hostname = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là tên máy ch\u1EE7 RFC 1123 h\u1EE3p l\u1EC7 -format.json-pointer = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là Con tr\u1ECF JSON RFC 6901 h\u1EE3p l\u1EC7 -format.relative-json-pointer = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu {1} ph\u1EA3i là Con tr\u1ECF JSON t\u01B0\u01A1ng \u0111\u1ED1i c\u1EE7a IETF h\u1EE3p l\u1EC7 -format.unknown = {0}: có \u0111\u1ECBnh d\u1EA1ng không xác \u0111\u1ECBnh ''{1}'' -id = {0}: ''{1}'' không ph\u1EA3i là {2} h\u1EE3p l\u1EC7 -items = {0}: ch\u1EC9 m\u1EE5c ''{1}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c b\u1ED5 sung -maxContains = {0}: ph\u1EA3i là s\u1ED1 nguyên không âm trong {1} -maxItems = {0}: ph\u1EA3i có t\u1ED1i \u0111a {1} m\u1EE5c nh\u01B0ng \u0111ã tìm th\u1EA5y {2} -maxLength = {0}: ph\u1EA3i dài t\u1ED1i \u0111a {1} ký t\u1EF1 -maxProperties = {0}: ph\u1EA3i có t\u1ED1i \u0111a {1} thu\u1ED9c tính -maximum = {0}: ph\u1EA3i có giá tr\u1ECB t\u1ED1i \u0111a là {1} -minContains = {0}: ph\u1EA3i là s\u1ED1 nguyên không âm trong {1} -minContainsVsMaxContains = {0}: minContains ph\u1EA3i nh\u1ECF h\u01A1n ho\u1EB7c b\u1EB1ng maxContains trong {1} -minItems = {0}: ph\u1EA3i có ít nh\u1EA5t {1} m\u1EE5c nh\u01B0ng \u0111ã tìm th\u1EA5y {2} -minLength = {0}: ph\u1EA3i dài ít nh\u1EA5t {1} ký t\u1EF1 -minProperties = {0}: ph\u1EA3i có ít nh\u1EA5t {1} thu\u1ED9c tính -minimum = {0}: ph\u1EA3i có giá tr\u1ECB t\u1ED1i thi\u1EC3u là {1} -multipleOf = {0}: ph\u1EA3i là b\u1ED9i s\u1ED1 c\u1EE7a {1} -not = {0}: không \u0111\u01B0\u1EE3c h\u1EE3p l\u1EC7 \u0111\u1ED1i v\u1EDBi l\u01B0\u1EE3c \u0111\u1ED3 {1} -notAllowed = {0}: thu\u1ED9c tính ''{1}'' không \u0111\u01B0\u1EE3c phép nh\u01B0ng nó có trong d\u1EEF li\u1EC7u -oneOf = {0}: ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi m\u1ED9t và ch\u1EC9 m\u1ED9t l\u01B0\u1EE3c \u0111\u1ED3, nh\u01B0ng {1} h\u1EE3p l\u1EC7 -oneOf.indexes = {0}: ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi m\u1ED9t và ch\u1EC9 m\u1ED9t l\u01B0\u1EE3c \u0111\u1ED3, nh\u01B0ng {1} h\u1EE3p l\u1EC7 v\u1EDBi các ch\u1EC9 m\u1EE5c ''{2}'' -pattern = {0}: không kh\u1EDBp v\u1EDBi m\u1EABu bi\u1EC3u th\u1EE9c chính quy {1} -patternProperties = {0}: có m\u1ED9t s\u1ED1 l\u1ED7i v\u1EDBi ''thu\u1ED9c tính m\u1EABu'' -prefixItems = {0}: không tìm th\u1EA5y trình xác th\u1EF1c nào t\u1EA1i ch\u1EC9 m\u1EE5c này -properties = {0}: có l\u1ED7i ''thu\u1ED9c tính'' -propertyNames = {0}: tên thu\u1ED9c tính ''{1}'' không h\u1EE3p l\u1EC7: {2} -readOnly = {0}: là tr\u01B0\u1EDDng ch\u1EC9 \u0111\u1ECDc, không th\u1EC3 thay \u0111\u1ED5i -required = {0}: không tìm th\u1EA5y thu\u1ED9c tính b\u1EAFt bu\u1ED9c ''{1}'' -type = {0}: \u0111ã tìm th\u1EA5y {1}, mong \u0111\u1EE3i {2} -unevaluatedItems = {0}: ch\u1EC9 m\u1EE5c ''{1}'' không \u0111\u01B0\u1EE3c \u0111ánh giá và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c không \u0111\u01B0\u1EE3c \u0111ánh giá -unevaluatedProperties = {0}: thu\u1ED9c tính ''{1}'' không \u0111\u01B0\u1EE3c \u0111ánh giá và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các thu\u1ED9c tính không \u0111\u01B0\u1EE3c \u0111ánh giá -unionType = {0}: \u0111ã tìm th\u1EA5y {1}, mong \u0111\u1EE3i {2} -uniqueItems = {0}: ch\u1EC9 \u0111\u01B0\u1EE3c có các m\u1EE5c duy nh\u1EA5t trong m\u1EA3ng -writeOnly = {0}: là tr\u01B0\u1EDDng ch\u1EC9 ghi, không xu\u1EA5t hi\u1EC7n trong d\u1EEF li\u1EC7u -contentEncoding = {0}: không kh\u1EDBp v\u1EDBi mã hóa n\u1ED9i dung {1} -contentMediaType = {0}: không ph\u1EA3i là n\u1ED9i dung c\u1EE7a tôi +$ref = có l\u1ED7i ''refs'' +additionalItems = ch\u1EC9 m\u1EE5c ''{0}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c b\u1ED5 sung +additionalProperties = thu\u1ED9c tính ''{0}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các thu\u1ED9c tính b\u1ED5 sung +allOf = ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi t\u1EA5t c\u1EA3 l\u01B0\u1EE3c \u0111\u1ED3 {0} +anyOf = ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi b\u1EA5t k\u1EF3 l\u01B0\u1EE3c \u0111\u1ED3 nào {0} +const = ph\u1EA3i là giá tr\u1ECB không \u0111\u1ED5i ''{0}'' +contains = không ch\u1EE9a ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác nh\u1EADn này: {1} +contains.max = ph\u1EA3i ch\u1EE9a t\u1ED1i \u0111a {0} ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác th\u1EF1c này: {1} +contains.min = ph\u1EA3i ch\u1EE9a ít nh\u1EA5t {0} ph\u1EA7n t\u1EED v\u01B0\u1EE3t qua các xác nh\u1EADn này: {1} +dependencies = có l\u1ED7i v\u1EDBi ph\u1EE5 thu\u1ED9c {0} +dependentRequired = thi\u1EBFu thu\u1ED9c tính ''{0}'' thu\u1ED9c tính ph\u1EE5 thu\u1ED9c b\u1EAFt bu\u1ED9c vì ''{1}'' hi\u1EC7n di\u1EC7n +dependentSchemas = có l\u1ED7i v\u1EDBi dependencySchemas {0} +enum = không có giá tr\u1ECB trong b\u1EA3ng li\u1EC7t kê {0} +exclusiveMaximum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i \u0111a \u0111\u1ED9c quy\u1EC1n là {0} +exclusiveMinimum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i thi\u1EC3u duy nh\u1EA5t là {0} +false = l\u01B0\u1EE3c \u0111\u1ED3 cho ''{0}'' là sai +format = không kh\u1EDBp v\u1EDBi m\u1EABu {0} {1} +format.date = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là ngày \u0111\u1EA7y \u0111\u1EE7 RFC 3339 h\u1EE3p l\u1EC7 +format.date-time = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là ngày gi\u1EDD h\u1EE3p l\u1EC7 RFC 3339 +format.duration = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i có th\u1EDDi l\u01B0\u1EE3ng ISO 8601 h\u1EE3p l\u1EC7 +format.email = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là H\u1ED9p th\u01B0 RFC 5321 h\u1EE3p l\u1EC7 +format.ipv4 = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là \u0111\u1ECBa ch\u1EC9 IP RFC 2673 h\u1EE3p l\u1EC7 +format.ipv6 = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là \u0111\u1ECBa ch\u1EC9 IP RFC 4291 h\u1EE3p l\u1EC7 +format.idn-email = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là H\u1ED9p th\u01B0 RFC 6531 h\u1EE3p l\u1EC7 +format.idn-hostname = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là tên máy ch\u1EE7 \u0111\u01B0\u1EE3c qu\u1ED1c t\u1EBF hóa RFC 5890 h\u1EE3p l\u1EC7 +format.iri = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là RFC 3987 IRI h\u1EE3p l\u1EC7 +format.iri-reference = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là tham chi\u1EBFu IRI RFC 3987 h\u1EE3p l\u1EC7 +format.uri = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là URI RFC 3986 h\u1EE3p l\u1EC7 +format.uri-reference = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là tham chi\u1EBFu URI RFC 3986 h\u1EE3p l\u1EC7 +format.uri-template = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là M\u1EABu URI RFC 6570 h\u1EE3p l\u1EC7 +format.uuid = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là UUID RFC 4122 h\u1EE3p l\u1EC7 +format.regex = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là bi\u1EC3u th\u1EE9c chính quy ECMA-262 h\u1EE3p l\u1EC7 +format.time = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là th\u1EDDi gian RFC 3339 h\u1EE3p l\u1EC7 +format.hostname = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là tên máy ch\u1EE7 RFC 1123 h\u1EE3p l\u1EC7 +format.json-pointer = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là Con tr\u1ECF JSON RFC 6901 h\u1EE3p l\u1EC7 +format.relative-json-pointer = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là Con tr\u1ECF JSON t\u01B0\u01A1ng \u0111\u1ED1i c\u1EE7a IETF h\u1EE3p l\u1EC7 +format.unknown = có \u0111\u1ECBnh d\u1EA1ng không xác \u0111\u1ECBnh ''{0}'' +id = ''{0}'' không ph\u1EA3i là {1} h\u1EE3p l\u1EC7 +items = ch\u1EC9 m\u1EE5c ''{0}'' không \u0111\u01B0\u1EE3c xác \u0111\u1ECBnh trong l\u01B0\u1EE3c \u0111\u1ED3 và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c b\u1ED5 sung +maxContains = ph\u1EA3i là s\u1ED1 nguyên không âm trong {0} +maxItems = ph\u1EA3i có t\u1ED1i \u0111a {0} m\u1EE5c nh\u01B0ng \u0111ã tìm th\u1EA5y {1} +maxLength = ph\u1EA3i dài t\u1ED1i \u0111a {0} ký t\u1EF1 +maxProperties = ph\u1EA3i có t\u1ED1i \u0111a {0} thu\u1ED9c tính +maximum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i \u0111a là {0} +minContains = ph\u1EA3i là s\u1ED1 nguyên không âm trong {0} +minContainsVsMaxContains = minContains ph\u1EA3i nh\u1ECF h\u01A1n ho\u1EB7c b\u1EB1ng maxContains trong {0} +minItems = ph\u1EA3i có ít nh\u1EA5t {0} m\u1EE5c nh\u01B0ng \u0111ã tìm th\u1EA5y {1} +minLength = ph\u1EA3i dài ít nh\u1EA5t {0} ký t\u1EF1 +minProperties = ph\u1EA3i có ít nh\u1EA5t {0} thu\u1ED9c tính +minimum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i thi\u1EC3u là {0} +multipleOf = ph\u1EA3i là b\u1ED9i s\u1ED1 c\u1EE7a {0} +not = không \u0111\u01B0\u1EE3c h\u1EE3p l\u1EC7 \u0111\u1ED1i v\u1EDBi l\u01B0\u1EE3c \u0111\u1ED3 {0} +notAllowed = thu\u1ED9c tính ''{0}'' không \u0111\u01B0\u1EE3c phép nh\u01B0ng nó có trong d\u1EEF li\u1EC7u +oneOf = ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi m\u1ED9t và ch\u1EC9 m\u1ED9t l\u01B0\u1EE3c \u0111\u1ED3, nh\u01B0ng {0} h\u1EE3p l\u1EC7 +oneOf.indexes = ph\u1EA3i h\u1EE3p l\u1EC7 v\u1EDBi m\u1ED9t và ch\u1EC9 m\u1ED9t l\u01B0\u1EE3c \u0111\u1ED3, nh\u01B0ng {0} h\u1EE3p l\u1EC7 v\u1EDBi các ch\u1EC9 m\u1EE5c ''{1}'' +pattern = không kh\u1EDBp v\u1EDBi m\u1EABu bi\u1EC3u th\u1EE9c chính quy {0} +patternProperties = có m\u1ED9t s\u1ED1 l\u1ED7i v\u1EDBi ''thu\u1ED9c tính m\u1EABu'' +prefixItems = không tìm th\u1EA5y trình xác th\u1EF1c nào t\u1EA1i ch\u1EC9 m\u1EE5c này +properties = có l\u1ED7i ''thu\u1ED9c tính'' +propertyNames = tên thu\u1ED9c tính ''{0}'' không h\u1EE3p l\u1EC7: {1} +readOnly = là tr\u01B0\u1EDDng ch\u1EC9 \u0111\u1ECDc, không th\u1EC3 thay \u0111\u1ED5i +required = không tìm th\u1EA5y thu\u1ED9c tính b\u1EAFt bu\u1ED9c ''{0}'' +type = \u0111ã tìm th\u1EA5y {0}, mong \u0111\u1EE3i {1} +unevaluatedItems = ch\u1EC9 m\u1EE5c ''{0}'' không \u0111\u01B0\u1EE3c \u0111ánh giá và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các m\u1EE5c không \u0111\u01B0\u1EE3c \u0111ánh giá +unevaluatedProperties = thu\u1ED9c tính ''{0}'' không \u0111\u01B0\u1EE3c \u0111ánh giá và l\u01B0\u1EE3c \u0111\u1ED3 không cho phép các thu\u1ED9c tính không \u0111\u01B0\u1EE3c \u0111ánh giá +unionType = \u0111ã tìm th\u1EA5y {0}, mong \u0111\u1EE3i {1} +uniqueItems = ch\u1EC9 \u0111\u01B0\u1EE3c có các m\u1EE5c duy nh\u1EA5t trong m\u1EA3ng +writeOnly = là tr\u01B0\u1EDDng ch\u1EC9 ghi, không xu\u1EA5t hi\u1EC7n trong d\u1EEF li\u1EC7u +contentEncoding = không kh\u1EDBp v\u1EDBi mã hóa n\u1ED9i dung {0} +contentMediaType = không ph\u1EA3i là n\u1ED9i dung c\u1EE7a tôi diff --git a/src/main/resources/jsv-messages_zh_CN.properties b/src/main/resources/jsv-messages_zh_CN.properties index d5d7d45be..30caad9b3 100644 --- a/src/main/resources/jsv-messages_zh_CN.properties +++ b/src/main/resources/jsv-messages_zh_CN.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u201Crefs\u201D\u6709\u9519\u8BEF -additionalItems = {0}: \u7D22\u5F15\u201C{1}\u201D\u672A\u5728\u67B6\u6784\u4E2D\u5B9A\u4E49\uFF0C\u5E76\u4E14\u8BE5\u67B6\u6784\u4E0D\u5141\u8BB8\u9644\u52A0\u9879\u76EE -additionalProperties = {0}: \u67B6\u6784\u4E2D\u672A\u5B9A\u4E49\u5C5E\u6027\u201C{1}\u201D\uFF0C\u5E76\u4E14\u67B6\u6784\u4E0D\u5141\u8BB8\u9644\u52A0\u5C5E\u6027 -allOf = {0}: \u5FC5\u987B\u5BF9\u6240\u6709\u67B6\u6784 {1} \u6709\u6548 -anyOf = {0}: \u5FC5\u987B\u5BF9\u4EFB\u4F55\u67B6\u6784 {1} \u6709\u6548 -const = {0}: \u5FC5\u987B\u662F\u5E38\u91CF\u503C\u201C{1}\u201D -contains = {0}: \u4E0D\u5305\u542B\u901A\u8FC7\u8FD9\u4E9B\u9A8C\u8BC1\u7684\u5143\u7D20: {2} -contains.max = {0}: \u5FC5\u987B\u5305\u542B\u6700\u591A {1} \u4E2A\u901A\u8FC7\u4EE5\u4E0B\u9A8C\u8BC1\u7684\u5143\u7D20: {2} -contains.min = {0}: \u5FC5\u987B\u5305\u542B\u81F3\u5C11 {1} \u4E2A\u901A\u8FC7\u8FD9\u4E9B\u9A8C\u8BC1\u7684\u5143\u7D20: {2} -dependencies = {0}: \u4F9D\u8D56\u9879 {1} \u5B58\u5728\u9519\u8BEF -dependentRequired = {0}: \u7F3A\u5C11\u5C5E\u6027\u201C{1}\u201D\uFF0C\u8BE5\u5C5E\u6027\u662F\u4F9D\u8D56\u5FC5\u9700\u7684\uFF0C\u56E0\u4E3A\u5B58\u5728\u201C{2}\u201D -dependentSchemas = {0}: dependentSchemas {1} \u5B58\u5728\u9519\u8BEF -enum = {0}: \u679A\u4E3E {1} \u4E2D\u6CA1\u6709\u503C -exclusiveMaximum = {0}: \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5927\u503C {1} -exclusiveMinimum = {0}: \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5C0F\u503C {1} -false = {0}: \u201C{1}\u201D\u7684\u67B6\u6784\u4E3A false -format = {0}: \u4E0E {1} \u6A21\u5F0F {2} \u4E0D\u5339\u914D -format.date = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F -format.date-time = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u65F6\u95F4 -format.duration = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7EED\u65F6\u95F4 -format.email = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 5321 \u90AE\u7BB1 -format.ipv4 = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 2673 IP \u5730\u5740 -format.ipv6 = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 4291 IP \u5730\u5740 -format.idn-email = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6531 \u90AE\u7BB1 -format.idn-hostname = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 5890 \u56FD\u9645\u5316\u4E3B\u673A\u540D -format.iri = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3987 IRI -format.iri-reference = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3987 IRI-reference -format.uri = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3986 URI -format.uri-reference = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3986 URI \u5F15\u7528 -format.uri-template = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6570 URI \u6A21\u677F -format.uuid = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 4122 UUID -format.regex = {0}: \u4E0D\u5339\u914D {1} \u6A21\u5F0F\u5FC5\u987B\u662F\u6709\u6548\u7684 ECMA-262 \u6B63\u5219\u8868\u8FBE\u5F0F -format.time = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u65F6\u95F4 -format.hostname = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 1123 \u4E3B\u673A\u540D -format.json-pointer = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6901 JSON \u6307\u9488 -format.relative-json-pointer = {0}: \u4E0E {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 IETF \u76F8\u5BF9 JSON \u6307\u9488 -format.unknown = {0}: \u683C\u5F0F\u672A\u77E5\u201C{1}\u201D -id = {0}: \u201C{1}\u201D\u4E0D\u662F\u6709\u6548\u7684 {2} -items = {0}: \u7D22\u5F15\u201C{1}\u201D\u672A\u5728\u67B6\u6784\u4E2D\u5B9A\u4E49\uFF0C\u5E76\u4E14\u8BE5\u67B6\u6784\u4E0D\u5141\u8BB8\u6DFB\u52A0\u5176\u4ED6\u9879\u76EE -maxContains = {0}: \u5FC5\u987B\u662F {1} \u4E2D\u7684\u975E\u8D1F\u6574\u6570 -maxItems = {0}: \u6700\u591A\u5FC5\u987B\u6709 {1} \u4E2A\u9879\u76EE\uFF0C\u4F46\u627E\u5230\u4E86 {2} \u4E2A -maxLength = {0}: \u957F\u5EA6\u4E0D\u5F97\u8D85\u8FC7 {1} \u4E2A\u5B57\u7B26 -maxProperties = {0}: \u6700\u591A\u5FC5\u987B\u6709 {1} \u4E2A\u5C5E\u6027 -maximum = {0}: \u6700\u5927\u503C\u5FC5\u987B\u4E3A {1} -minContains = {0}: \u5FC5\u987B\u662F {1} \u4E2D\u7684\u975E\u8D1F\u6574\u6570 -minContainsVsMaxContains = {0}: minContains \u5FC5\u987B\u5C0F\u4E8E\u6216\u7B49\u4E8E {1} \u4E2D\u7684 maxContains -minItems = {0}: \u5FC5\u987B\u81F3\u5C11\u6709 {1} \u4E2A\u9879\u76EE\uFF0C\u4F46\u5DF2\u627E\u5230 {2} \u4E2A -minLength = {0}: \u957F\u5EA6\u5FC5\u987B\u81F3\u5C11\u4E3A {1} \u4E2A\u5B57\u7B26 -minProperties = {0}: \u5FC5\u987B\u81F3\u5C11\u5177\u6709 {1} \u4E2A\u5C5E\u6027 -minimum = {0}: \u6700\u5C0F\u503C\u5FC5\u987B\u4E3A {1} -multipleOf = {0}: \u5FC5\u987B\u662F {1} \u7684\u500D\u6570 -not = {0}: \u5BF9\u4E8E\u67B6\u6784 {1} \u5FC5\u987B\u65E0\u6548 -notAllowed = {0}: \u4E0D\u5141\u8BB8\u4F7F\u7528\u5C5E\u6027\u201C{1}\u201D\uFF0C\u4F46\u5B83\u5B58\u5728\u4E8E\u6570\u636E\u4E2D -oneOf = {0}: \u5FC5\u987B\u5BF9\u4E00\u4E2A\u4E14\u4EC5\u4E00\u4E2A\u67B6\u6784\u6709\u6548\uFF0C\u4F46 {1} \u6709\u6548 -oneOf.indexes = {0}: \u5FC5\u987B\u5BF9\u4E00\u4E2A\u4E14\u4EC5\u4E00\u4E2A\u67B6\u6784\u6709\u6548\uFF0C\u4F46 {1} \u5BF9\u7D22\u5F15\u201C{2}\u201D\u6709\u6548 -pattern = {0}: \u4E0E\u6B63\u5219\u8868\u8FBE\u5F0F\u6A21\u5F0F {1} \u4E0D\u5339\u914D -patternProperties = {0}: \u201C\u6A21\u5F0F\u5C5E\u6027\u201D\u6709\u4E00\u4E9B\u9519\u8BEF -prefixItems = {0}: \u5728\u6B64\u7D22\u5F15\u5904\u627E\u4E0D\u5230\u9A8C\u8BC1\u5668 -properties = {0}: \u201C\u5C5E\u6027\u201D\u6709\u9519\u8BEF -propertyNames = {0}: \u5C5E\u6027\u201C{1}\u201D\u540D\u79F0\u65E0\u6548: {2} -readOnly = {0}: \u662F\u53EA\u8BFB\u5B57\u6BB5\uFF0C\u65E0\u6CD5\u66F4\u6539 -required = {0}: \u672A\u627E\u5230\u6240\u9700\u5C5E\u6027\u201C{1}\u201D -type = {0}: \u5DF2\u627E\u5230 {1}\uFF0C\u5FC5\u987B\u662F {2} -unevaluatedItems = {0}: \u672A\u8BC4\u4F30\u7D22\u5F15\u201C{1}\u201D\uFF0C\u67B6\u6784\u4E0D\u5141\u8BB8\u672A\u8BC4\u4F30\u7684\u9879\u76EE -unevaluatedProperties = {0}: \u672A\u8BC4\u4F30\u5C5E\u6027\u201C{1}\u201D\uFF0C\u5E76\u4E14\u67B6\u6784\u4E0D\u5141\u8BB8\u672A\u8BC4\u4F30\u7684\u5C5E\u6027 -unionType = {0}: \u5DF2\u627E\u5230 {1}\uFF0C\u5FC5\u987B\u662F {2} -uniqueItems = {0}: \u6570\u7EC4\u4E2D\u5FC5\u987B\u4EC5\u5305\u542B\u552F\u4E00\u9879 -writeOnly = {0}: \u662F\u53EA\u5199\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u51FA\u73B0\u5728\u6570\u636E\u4E2D -contentEncoding = {0}: \u4E0E\u5185\u5BB9\u7F16\u7801 {1} \u4E0D\u5339\u914D -contentMediaType = {0}: \u4E0D\u662F\u5185\u5BB9\u6211 +$ref = \u201Crefs\u201D\u6709\u9519\u8BEF +additionalItems = \u7D22\u5F15\u201C{0}\u201D\u672A\u5728\u67B6\u6784\u4E2D\u5B9A\u4E49\uFF0C\u5E76\u4E14\u8BE5\u67B6\u6784\u4E0D\u5141\u8BB8\u9644\u52A0\u9879\u76EE +additionalProperties = \u67B6\u6784\u4E2D\u672A\u5B9A\u4E49\u5C5E\u6027\u201C{0}\u201D\uFF0C\u5E76\u4E14\u67B6\u6784\u4E0D\u5141\u8BB8\u9644\u52A0\u5C5E\u6027 +allOf = \u5FC5\u987B\u5BF9\u6240\u6709\u67B6\u6784 {0} \u6709\u6548 +anyOf = \u5FC5\u987B\u5BF9\u4EFB\u4F55\u67B6\u6784 {0} \u6709\u6548 +const = \u5FC5\u987B\u662F\u5E38\u91CF\u503C\u201C{0}\u201D +contains = \u4E0D\u5305\u542B\u901A\u8FC7\u8FD9\u4E9B\u9A8C\u8BC1\u7684\u5143\u7D20: {1} +contains.max = \u5FC5\u987B\u5305\u542B\u6700\u591A {0} \u4E2A\u901A\u8FC7\u4EE5\u4E0B\u9A8C\u8BC1\u7684\u5143\u7D20: {1} +contains.min = \u5FC5\u987B\u5305\u542B\u81F3\u5C11 {0} \u4E2A\u901A\u8FC7\u8FD9\u4E9B\u9A8C\u8BC1\u7684\u5143\u7D20: {1} +dependencies = \u4F9D\u8D56\u9879 {0} \u5B58\u5728\u9519\u8BEF +dependentRequired = \u7F3A\u5C11\u5C5E\u6027\u201C{0}\u201D\uFF0C\u8BE5\u5C5E\u6027\u662F\u4F9D\u8D56\u5FC5\u9700\u7684\uFF0C\u56E0\u4E3A\u5B58\u5728\u201C{1}\u201D +dependentSchemas = dependentSchemas {0} \u5B58\u5728\u9519\u8BEF +enum = \u679A\u4E3E {0} \u4E2D\u6CA1\u6709\u503C +exclusiveMaximum = \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5927\u503C {0} +exclusiveMinimum = \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5C0F\u503C {0} +false = \u201C{0}\u201D\u7684\u67B6\u6784\u4E3A false +format = \u4E0E {0} \u6A21\u5F0F {1} \u4E0D\u5339\u914D +format.date = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F +format.date-time = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u65F6\u95F4 +format.duration = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7EED\u65F6\u95F4 +format.email = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 5321 \u90AE\u7BB1 +format.ipv4 = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 2673 IP \u5730\u5740 +format.ipv6 = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 4291 IP \u5730\u5740 +format.idn-email = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6531 \u90AE\u7BB1 +format.idn-hostname = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 5890 \u56FD\u9645\u5316\u4E3B\u673A\u540D +format.iri = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3987 IRI +format.iri-reference = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3987 IRI-reference +format.uri = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3986 URI +format.uri-reference = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3986 URI \u5F15\u7528 +format.uri-template = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6570 URI \u6A21\u677F +format.uuid = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 4122 UUID +format.regex = \u4E0D\u5339\u914D {0} \u6A21\u5F0F\u5FC5\u987B\u662F\u6709\u6548\u7684 ECMA-262 \u6B63\u5219\u8868\u8FBE\u5F0F +format.time = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u65F6\u95F4 +format.hostname = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 1123 \u4E3B\u673A\u540D +format.json-pointer = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 6901 JSON \u6307\u9488 +format.relative-json-pointer = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 IETF \u76F8\u5BF9 JSON \u6307\u9488 +format.unknown = \u683C\u5F0F\u672A\u77E5\u201C{0}\u201D +id = \u201C{0}\u201D\u4E0D\u662F\u6709\u6548\u7684 {1} +items = \u7D22\u5F15\u201C{0}\u201D\u672A\u5728\u67B6\u6784\u4E2D\u5B9A\u4E49\uFF0C\u5E76\u4E14\u8BE5\u67B6\u6784\u4E0D\u5141\u8BB8\u6DFB\u52A0\u5176\u4ED6\u9879\u76EE +maxContains = \u5FC5\u987B\u662F {0} \u4E2D\u7684\u975E\u8D1F\u6574\u6570 +maxItems = \u6700\u591A\u5FC5\u987B\u6709 {0} \u4E2A\u9879\u76EE\uFF0C\u4F46\u627E\u5230\u4E86 {1} \u4E2A +maxLength = \u957F\u5EA6\u4E0D\u5F97\u8D85\u8FC7 {0} \u4E2A\u5B57\u7B26 +maxProperties = \u6700\u591A\u5FC5\u987B\u6709 {0} \u4E2A\u5C5E\u6027 +maximum = \u6700\u5927\u503C\u5FC5\u987B\u4E3A {0} +minContains = \u5FC5\u987B\u662F {0} \u4E2D\u7684\u975E\u8D1F\u6574\u6570 +minContainsVsMaxContains = minContains \u5FC5\u987B\u5C0F\u4E8E\u6216\u7B49\u4E8E {0} \u4E2D\u7684 maxContains +minItems = \u5FC5\u987B\u81F3\u5C11\u6709 {0} \u4E2A\u9879\u76EE\uFF0C\u4F46\u5DF2\u627E\u5230 {1} \u4E2A +minLength = \u957F\u5EA6\u5FC5\u987B\u81F3\u5C11\u4E3A {0} \u4E2A\u5B57\u7B26 +minProperties = \u5FC5\u987B\u81F3\u5C11\u5177\u6709 {0} \u4E2A\u5C5E\u6027 +minimum = \u6700\u5C0F\u503C\u5FC5\u987B\u4E3A {0} +multipleOf = \u5FC5\u987B\u662F {0} \u7684\u500D\u6570 +not = \u5BF9\u4E8E\u67B6\u6784 {0} \u5FC5\u987B\u65E0\u6548 +notAllowed = \u4E0D\u5141\u8BB8\u4F7F\u7528\u5C5E\u6027\u201C{0}\u201D\uFF0C\u4F46\u5B83\u5B58\u5728\u4E8E\u6570\u636E\u4E2D +oneOf = \u5FC5\u987B\u5BF9\u4E00\u4E2A\u4E14\u4EC5\u4E00\u4E2A\u67B6\u6784\u6709\u6548\uFF0C\u4F46 {0} \u6709\u6548 +oneOf.indexes = \u5FC5\u987B\u5BF9\u4E00\u4E2A\u4E14\u4EC5\u4E00\u4E2A\u67B6\u6784\u6709\u6548\uFF0C\u4F46 {0} \u5BF9\u7D22\u5F15\u201C{1}\u201D\u6709\u6548 +pattern = \u4E0E\u6B63\u5219\u8868\u8FBE\u5F0F\u6A21\u5F0F {0} \u4E0D\u5339\u914D +patternProperties = \u201C\u6A21\u5F0F\u5C5E\u6027\u201D\u6709\u4E00\u4E9B\u9519\u8BEF +prefixItems = \u5728\u6B64\u7D22\u5F15\u5904\u627E\u4E0D\u5230\u9A8C\u8BC1\u5668 +properties = \u201C\u5C5E\u6027\u201D\u6709\u9519\u8BEF +propertyNames = \u5C5E\u6027\u201C{0}\u201D\u540D\u79F0\u65E0\u6548: {1} +readOnly = \u662F\u53EA\u8BFB\u5B57\u6BB5\uFF0C\u65E0\u6CD5\u66F4\u6539 +required = \u672A\u627E\u5230\u6240\u9700\u5C5E\u6027\u201C{0}\u201D +type = \u5DF2\u627E\u5230 {0}\uFF0C\u5FC5\u987B\u662F {1} +unevaluatedItems = \u672A\u8BC4\u4F30\u7D22\u5F15\u201C{0}\u201D\uFF0C\u67B6\u6784\u4E0D\u5141\u8BB8\u672A\u8BC4\u4F30\u7684\u9879\u76EE +unevaluatedProperties = \u672A\u8BC4\u4F30\u5C5E\u6027\u201C{0}\u201D\uFF0C\u5E76\u4E14\u67B6\u6784\u4E0D\u5141\u8BB8\u672A\u8BC4\u4F30\u7684\u5C5E\u6027 +unionType = \u5DF2\u627E\u5230 {0}\uFF0C\u5FC5\u987B\u662F {1} +uniqueItems = \u6570\u7EC4\u4E2D\u5FC5\u987B\u4EC5\u5305\u542B\u552F\u4E00\u9879 +writeOnly = \u662F\u53EA\u5199\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u51FA\u73B0\u5728\u6570\u636E\u4E2D +contentEncoding = \u4E0E\u5185\u5BB9\u7F16\u7801 {0} \u4E0D\u5339\u914D +contentMediaType = \u4E0D\u662F\u5185\u5BB9\u6211 diff --git a/src/main/resources/jsv-messages_zh_TW.properties b/src/main/resources/jsv-messages_zh_TW.properties index c69f2670b..14c1dde19 100644 --- a/src/main/resources/jsv-messages_zh_TW.properties +++ b/src/main/resources/jsv-messages_zh_TW.properties @@ -1,70 +1,70 @@ -$ref = {0}: \u300Crefs\u300D\u6709\u932F\u8AA4 -additionalItems = {0}: \u7D22\u5F15\u300C{1}\u300D\u672A\u5728\u67B6\u69CB\u4E2D\u5B9A\u7FA9\uFF0C\u4E14\u8A72\u67B6\u69CB\u4E0D\u5141\u8A31\u9644\u52A0\u9805\u76EE -additionalProperties = {0}: \u67B6\u69CB\u4E2D\u672A\u5B9A\u7FA9\u5C6C\u6027\u201C{1}\u201D\uFF0C\u4E14\u67B6\u69CB\u4E0D\u5141\u8A31\u9644\u52A0\u5C6C\u6027 -allOf = {0}: \u5FC5\u9808\u5C0D\u6240\u6709\u67B6\u69CB {1} \u6709\u6548 -anyOf = {0}: \u5FC5\u9808\u5C0D\u4EFB\u4F55\u67B6\u69CB {1} \u6709\u6548 -const = {0}: \u5FC5\u9808\u662F\u5E38\u6578\u503C\u201C{1}\u201D -contains = {0}: \u4E0D\u5305\u542B\u901A\u904E\u9019\u4E9B\u9A57\u8B49\u7684\u5143\u7D20: {2} -contains.max = {0}: \u5FC5\u9808\u5305\u542B\u6700\u591A {1} \u500B\u901A\u904E\u4EE5\u4E0B\u9A57\u8B49\u7684\u5143\u7D20: {2} -contains.min = {0}: \u5FC5\u9808\u5305\u542B\u81F3\u5C11 {1} \u500B\u901A\u904E\u9019\u4E9B\u9A57\u8B49\u7684\u5143\u7D20: {2} -dependencies = {0}: \u4F9D\u8CF4\u9805 {1} \u5B58\u5728\u932F\u8AA4 -dependentRequired = {0}: \u7F3A\u5C11\u5C6C\u6027\u201C{1}\u201D\uFF0C\u8A72\u5C6C\u6027\u662F\u4F9D\u8CF4\u5FC5\u9700\u7684\uFF0C\u56E0\u70BA\u5B58\u5728\u201C{2}\u201D -dependentSchemas = {0}: dependentSchemas {1} \u5B58\u5728\u932F\u8AA4 -enum = {0}: \u679A\u8209 {1} \u4E2D\u6C92\u6709\u503C -exclusiveMaximum = {0}: \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5927\u503C {1} -exclusiveMinimum = {0}: \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5C0F\u503C {1} -false = {0}: \u300C{1}\u300D\u7684\u67B6\u69CB\u70BA false -format = {0}: \u8207 {1} \u6A21\u5F0F {2} \u4E0D\u5339\u914D -format.date = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F -format.date-time = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u6642\u9593 -format.duration = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7E8C\u6642\u9593 -format.email = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 5321 \u90F5\u7BB1 -format.ipv4 = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 2673 IP \u4F4D\u5740 -format.ipv6 = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 4291 IP \u4F4D\u5740 -format.idn-email = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6531 \u90F5\u7BB1 -format.idn-hostname = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 5890 \u570B\u969B\u5316\u4E3B\u6A5F\u540D -format.iri = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3987 IRI -format.iri-reference = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3987 IRI-reference -format.uri = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3986 URI -format.uri-reference = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3986 URI \u5F15\u7528 -format.uri-template = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6570 URI \u6A21\u677F -format.uuid = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 4122 UUID -format.regex = {0}: \u4E0D\u7B26\u5408 {1} \u6A21\u5F0F\u5FC5\u9808\u662F\u6709\u6548\u7684 ECMA-262 \u6B63\u898F\u8868\u793A\u5F0F -format.time = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u6642\u9593 -format.hostname = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 1123 \u4E3B\u6A5F\u540D -format.json-pointer = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6901 JSON \u6307\u91DD -format.relative-json-pointer = {0}: \u8207 {1} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u9808\u662F\u6709\u6548\u7684 IETF \u76F8\u5C0D JSON \u6307\u91DD -format.unknown = {0}: \u683C\u5F0F\u672A\u77E5\u201C{1}\u201D -id = {0}: \u300C{1}\u300D\u4E0D\u662F\u6709\u6548\u7684 {2} -items = {0}: \u7D22\u5F15\u300C{1}\u300D\u672A\u5728\u67B6\u69CB\u4E2D\u5B9A\u7FA9\uFF0C\u4E14\u8A72\u67B6\u69CB\u4E0D\u5141\u8A31\u65B0\u589E\u5176\u4ED6\u9805\u76EE -maxContains = {0}: \u5FC5\u9808\u662F {1} \u4E2D\u7684\u975E\u8CA0\u6574\u6578 -maxItems = {0}: \u6700\u591A\u5FC5\u9808\u6709 {1} \u500B\u9805\u76EE\uFF0C\u4F46\u627E\u5230\u4E86 {2} \u500B -maxLength = {0}: \u9577\u5EA6\u4E0D\u5F97\u8D85\u904E {1} \u500B\u5B57\u5143 -maxProperties = {0}: \u6700\u591A\u5FC5\u9808\u6709 {1} \u500B\u5C6C\u6027 -maximum = {0}: \u6700\u5927\u503C\u5FC5\u9808\u70BA {1} -minContains = {0}: \u5FC5\u9808\u662F {1} \u4E2D\u7684\u975E\u8CA0\u6574\u6578 -minContainsVsMaxContains = {0}: minContains \u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC {1} \u4E2D\u7684 maxContains -minItems = {0}: \u5FC5\u9808\u81F3\u5C11\u6709 {1} \u500B\u9805\u76EE\uFF0C\u4F46\u5DF2\u627E\u5230 {2} \u500B -minLength = {0}: \u9577\u5EA6\u5FC5\u9808\u81F3\u5C11\u70BA {1} \u500B\u5B57\u5143 -minProperties = {0}: \u5FC5\u9808\u81F3\u5C11\u5177\u6709 {1} \u500B\u5C6C\u6027 -minimum = {0}: \u6700\u5C0F\u503C\u5FC5\u9808\u70BA {1} -multipleOf = {0}: \u5FC5\u9808\u662F {1} \u7684\u500D\u6578 -not = {0}: \u5C0D\u65BC\u67B6\u69CB {1} \u5FC5\u9808\u7121\u6548 -notAllowed = {0}: \u4E0D\u5141\u8A31\u4F7F\u7528\u5C6C\u6027\u201C{1}\u201D\uFF0C\u4F46\u5B83\u5B58\u5728\u65BC\u8CC7\u6599\u4E2D -oneOf = {0}: \u5FC5\u9808\u5C0D\u4E00\u500B\u4E14\u50C5\u4E00\u500B\u67B6\u69CB\u6709\u6548\uFF0C\u4F46 {1} \u6709\u6548 -oneOf.indexes = {0}: \u5FC5\u9808\u5C0D\u4E00\u500B\u4E14\u50C5\u4E00\u500B\u67B6\u69CB\u6709\u6548\uFF0C\u4F46 {1} \u5C0D\u7D22\u5F15\u300C{2}\u300D\u6709\u6548 -pattern = {0}: \u8207\u6B63\u898F\u8868\u793A\u5F0F\u6A21\u5F0F {1} \u4E0D\u5339\u914D -patternProperties = {0}: \u300C\u6A21\u5F0F\u5C6C\u6027\u300D\u6709\u4E00\u4E9B\u932F\u8AA4 -prefixItems = {0}: \u5728\u6B64\u7D22\u5F15\u8655\u627E\u4E0D\u5230\u9A57\u8B49\u5668 -properties = {0}: \u300C\u5C6C\u6027\u300D\u6709\u932F\u8AA4 -propertyNames = {0}: \u5C6C\u6027\u300C{1}\u300D\u540D\u7A31\u7121\u6548: {2} -readOnly = {0}: \u662F\u552F\u8B80\u5B57\u6BB5\uFF0C\u7121\u6CD5\u66F4\u6539 -required = {0}: \u672A\u627E\u5230\u6240\u9700\u5C6C\u6027\u201C{1}\u201D -type = {0}: \u5DF2\u627E\u5230 {1}\uFF0C\u5FC5\u9808\u662F {2} -unevaluatedItems = {0}: \u672A\u8A55\u4F30\u7D22\u5F15\u201C{1}\u201D\uFF0C\u67B6\u69CB\u4E0D\u5141\u8A31\u672A\u8A55\u4F30\u7684\u9805\u76EE -unevaluatedProperties = {0}: \u672A\u8A55\u4F30\u5C6C\u6027\u201C{1}\u201D\uFF0C\u4E14\u67B6\u69CB\u4E0D\u5141\u8A31\u672A\u8A55\u4F30\u7684\u5C6C\u6027 -unionType = {0}: \u5DF2\u627E\u5230 {1}\uFF0C\u5FC5\u9808\u662F {2} -uniqueItems = {0}: \u6578\u7D44\u4E2D\u5FC5\u9808\u53EA\u5305\u542B\u552F\u4E00\u9805 -writeOnly = {0}: \u662F\u53EA\u5BEB\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u51FA\u73FE\u5728\u8CC7\u6599\u4E2D -contentEncoding = {0}: \u8207\u5167\u5BB9\u7DE8\u78BC {1} \u4E0D\u7B26 -contentMediaType = {0}: \u4E0D\u662F\u5167\u5BB9\u6211 +$ref = \u300Crefs\u300D\u6709\u932F\u8AA4 +additionalItems = \u7D22\u5F15\u300C{0}\u300D\u672A\u5728\u67B6\u69CB\u4E2D\u5B9A\u7FA9\uFF0C\u4E14\u8A72\u67B6\u69CB\u4E0D\u5141\u8A31\u9644\u52A0\u9805\u76EE +additionalProperties = \u67B6\u69CB\u4E2D\u672A\u5B9A\u7FA9\u5C6C\u6027\u201C{0}\u201D\uFF0C\u4E14\u67B6\u69CB\u4E0D\u5141\u8A31\u9644\u52A0\u5C6C\u6027 +allOf = \u5FC5\u9808\u5C0D\u6240\u6709\u67B6\u69CB {0} \u6709\u6548 +anyOf = \u5FC5\u9808\u5C0D\u4EFB\u4F55\u67B6\u69CB {0} \u6709\u6548 +const = \u5FC5\u9808\u662F\u5E38\u6578\u503C\u201C{0}\u201D +contains = \u4E0D\u5305\u542B\u901A\u904E\u9019\u4E9B\u9A57\u8B49\u7684\u5143\u7D20: {1} +contains.max = \u5FC5\u9808\u5305\u542B\u6700\u591A {0} \u500B\u901A\u904E\u4EE5\u4E0B\u9A57\u8B49\u7684\u5143\u7D20: {1} +contains.min = \u5FC5\u9808\u5305\u542B\u81F3\u5C11 {0} \u500B\u901A\u904E\u9019\u4E9B\u9A57\u8B49\u7684\u5143\u7D20: {1} +dependencies = \u4F9D\u8CF4\u9805 {0} \u5B58\u5728\u932F\u8AA4 +dependentRequired = \u7F3A\u5C11\u5C6C\u6027\u201C{0}\u201D\uFF0C\u8A72\u5C6C\u6027\u662F\u4F9D\u8CF4\u5FC5\u9700\u7684\uFF0C\u56E0\u70BA\u5B58\u5728\u201C{1}\u201D +dependentSchemas = dependentSchemas {0} \u5B58\u5728\u932F\u8AA4 +enum = \u679A\u8209 {0} \u4E2D\u6C92\u6709\u503C +exclusiveMaximum = \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5927\u503C {0} +exclusiveMinimum = \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5C0F\u503C {0} +false = \u300C{0}\u300D\u7684\u67B6\u69CB\u70BA false +format = \u8207 {0} \u6A21\u5F0F {1} \u4E0D\u5339\u914D +format.date = \u8207 {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F +format.date-time = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u6642\u9593 +format.duration = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7E8C\u6642\u9593 +format.email = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 5321 \u90F5\u7BB1 +format.ipv4 = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 2673 IP \u4F4D\u5740 +format.ipv6 = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 4291 IP \u4F4D\u5740 +format.idn-email = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6531 \u90F5\u7BB1 +format.idn-hostname = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 5890 \u570B\u969B\u5316\u4E3B\u6A5F\u540D +format.iri = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3987 IRI +format.iri-reference = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3987 IRI-reference +format.uri = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3986 URI +format.uri-reference = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3986 URI \u5F15\u7528 +format.uri-template = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6570 URI \u6A21\u677F +format.uuid = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 4122 UUID +format.regex = \u4E0D\u7B26\u5408 {0} \u6A21\u5F0F\u5FC5\u9808\u662F\u6709\u6548\u7684 ECMA-262 \u6B63\u898F\u8868\u793A\u5F0F +format.time = \u8207 {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u6642\u9593 +format.hostname = \u8207 {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 1123 \u4E3B\u6A5F\u540D +format.json-pointer = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 6901 JSON \u6307\u91DD +format.relative-json-pointer = \u8207 {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u9808\u662F\u6709\u6548\u7684 IETF \u76F8\u5C0D JSON \u6307\u91DD +format.unknown = \u683C\u5F0F\u672A\u77E5\u201C{0}\u201D +id = \u300C{0}\u300D\u4E0D\u662F\u6709\u6548\u7684 {1} +items = \u7D22\u5F15\u300C{0}\u300D\u672A\u5728\u67B6\u69CB\u4E2D\u5B9A\u7FA9\uFF0C\u4E14\u8A72\u67B6\u69CB\u4E0D\u5141\u8A31\u65B0\u589E\u5176\u4ED6\u9805\u76EE +maxContains = \u5FC5\u9808\u662F {0} \u4E2D\u7684\u975E\u8CA0\u6574\u6578 +maxItems = \u6700\u591A\u5FC5\u9808\u6709 {0} \u500B\u9805\u76EE\uFF0C\u4F46\u627E\u5230\u4E86 {1} \u500B +maxLength = \u9577\u5EA6\u4E0D\u5F97\u8D85\u904E {0} \u500B\u5B57\u5143 +maxProperties = \u6700\u591A\u5FC5\u9808\u6709 {0} \u500B\u5C6C\u6027 +maximum = \u6700\u5927\u503C\u5FC5\u9808\u70BA {0} +minContains = \u5FC5\u9808\u662F {0} \u4E2D\u7684\u975E\u8CA0\u6574\u6578 +minContainsVsMaxContains = minContains \u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC {0} \u4E2D\u7684 maxContains +minItems = \u5FC5\u9808\u81F3\u5C11\u6709 {0} \u500B\u9805\u76EE\uFF0C\u4F46\u5DF2\u627E\u5230 {1} \u500B +minLength = \u9577\u5EA6\u5FC5\u9808\u81F3\u5C11\u70BA {0} \u500B\u5B57\u5143 +minProperties = \u5FC5\u9808\u81F3\u5C11\u5177\u6709 {0} \u500B\u5C6C\u6027 +minimum = \u6700\u5C0F\u503C\u5FC5\u9808\u70BA {0} +multipleOf = \u5FC5\u9808\u662F {0} \u7684\u500D\u6578 +not = \u5C0D\u65BC\u67B6\u69CB {0} \u5FC5\u9808\u7121\u6548 +notAllowed = \u4E0D\u5141\u8A31\u4F7F\u7528\u5C6C\u6027\u201C{0}\u201D\uFF0C\u4F46\u5B83\u5B58\u5728\u65BC\u8CC7\u6599\u4E2D +oneOf = \u5FC5\u9808\u5C0D\u4E00\u500B\u4E14\u50C5\u4E00\u500B\u67B6\u69CB\u6709\u6548\uFF0C\u4F46 {0} \u6709\u6548 +oneOf.indexes = \u5FC5\u9808\u5C0D\u4E00\u500B\u4E14\u50C5\u4E00\u500B\u67B6\u69CB\u6709\u6548\uFF0C\u4F46 {0} \u5C0D\u7D22\u5F15\u300C{1}\u300D\u6709\u6548 +pattern = \u8207\u6B63\u898F\u8868\u793A\u5F0F\u6A21\u5F0F {0} \u4E0D\u5339\u914D +patternProperties = \u300C\u6A21\u5F0F\u5C6C\u6027\u300D\u6709\u4E00\u4E9B\u932F\u8AA4 +prefixItems = \u5728\u6B64\u7D22\u5F15\u8655\u627E\u4E0D\u5230\u9A57\u8B49\u5668 +properties = \u300C\u5C6C\u6027\u300D\u6709\u932F\u8AA4 +propertyNames = \u5C6C\u6027\u300C{0}\u300D\u540D\u7A31\u7121\u6548: {1} +readOnly = \u662F\u552F\u8B80\u5B57\u6BB5\uFF0C\u7121\u6CD5\u66F4\u6539 +required = \u672A\u627E\u5230\u6240\u9700\u5C6C\u6027\u201C{0}\u201D +type = \u5DF2\u627E\u5230 {0}\uFF0C\u5FC5\u9808\u662F {1} +unevaluatedItems = \u672A\u8A55\u4F30\u7D22\u5F15\u201C{0}\u201D\uFF0C\u67B6\u69CB\u4E0D\u5141\u8A31\u672A\u8A55\u4F30\u7684\u9805\u76EE +unevaluatedProperties = \u672A\u8A55\u4F30\u5C6C\u6027\u201C{0}\u201D\uFF0C\u4E14\u67B6\u69CB\u4E0D\u5141\u8A31\u672A\u8A55\u4F30\u7684\u5C6C\u6027 +unionType = \u5DF2\u627E\u5230 {0}\uFF0C\u5FC5\u9808\u662F {1} +uniqueItems = \u6578\u7D44\u4E2D\u5FC5\u9808\u53EA\u5305\u542B\u552F\u4E00\u9805 +writeOnly = \u662F\u53EA\u5BEB\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u51FA\u73FE\u5728\u8CC7\u6599\u4E2D +contentEncoding = \u8207\u5167\u5BB9\u7DE8\u78BC {0} \u4E0D\u7B26 +contentMediaType = \u4E0D\u662F\u5167\u5BB9\u6211 diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 7b98ef3d1..632ee72ed 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -100,7 +100,9 @@ private static void executeTest(JsonSchema schema, TestSpec testSpec) { // Expected Validation Messages need not be exactly same as actual errors. // This code checks if expected validation message is subset of actual errors - Set actual = errors.stream().map(ValidationMessage::getMessage).collect(Collectors.toSet()); + Set actual = errors.stream() + .map(error -> error.getInstanceLocation().toString() + ": " + error.getMessage()) + .collect(Collectors.toSet()); Set expected = testSpec.getValidationMessages(); expected.removeAll(actual); if (!expected.isEmpty()) { diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index af20d956a..156c4e7ac 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -60,7 +60,7 @@ void messageFalse() { assertEquals("", message.getInstanceLocation().toString()); assertEquals("false", message.getSchemaNode().toString()); assertEquals("{\"foo\":\"hello\",\"bar\":\"world\"}", message.getInstanceNode().toString()); - assertEquals(": property 'bar' is not defined in the schema and the schema does not allow additional properties", message.getMessage()); + assertEquals(": property 'bar' is not defined in the schema and the schema does not allow additional properties", message.toString()); assertEquals("bar", message.getProperty()); } @@ -95,7 +95,7 @@ void messageSchema() { assertEquals("/bar", message.getInstanceLocation().toString()); assertEquals("\"number\"", message.getSchemaNode().toString()); assertEquals("\"world\"", message.getInstanceNode().toString()); - assertEquals("/bar: string found, number expected", message.getMessage()); + assertEquals("/bar: string found, number expected", message.toString()); assertNull(message.getProperty()); } diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 94794f6b5..aac9e5afe 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -42,7 +42,7 @@ void localeMessageOthers() { JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); - assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().getMessage()); + assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); } @Test @@ -56,7 +56,7 @@ void localeMessageNumber() { JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); - assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().getMessage()); + assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); } @Test diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 11a8e4a8b..3d4d556b2 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -67,7 +67,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode ValidationMessage validationMessage = ValidationMessage.builder().keyword(keyword) .schemaNode(node) .instanceNode(node) - .messageKey("tests.example.enumNames").message("{0}: enumName is {1}").instanceLocation(instanceLocation) + .messageKey("tests.example.enumNames").message("enumName is {0}").instanceLocation(instanceLocation) .arguments(valueName).build(); executionContext.addError(validationMessage); } @@ -130,6 +130,6 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { assertEquals(1, messages.size()); ValidationMessage message = messages.iterator().next(); - assertEquals("$: enumName is Foo !", message.getMessage()); + assertEquals("$: enumName is Foo !", message.toString()); } } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index e2326132f..32572efe7 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -39,7 +39,7 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { try { JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config); } catch (InvalidSchemaException e) { - assertEquals("/$id: '0' is not a valid $id", e.getMessage()); + assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 3455d8cf9..6ddf2ebc6 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -46,7 +46,7 @@ void shouldReturnErrorMessageForObjectWithoutDependentRequiredField() throws IOE List messages = whenValidate("{ \"optional\": \"present\" }"); assertThat( - messages.stream().map(ValidationMessage::getMessage).collect(Collectors.toList()), + messages.stream().map(ValidationMessage::toString).collect(Collectors.toList()), contains("$: has a missing property 'requiredWhenOptionalPresent' which is dependent required because 'optional' is present")); } diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 801555e1a..593f6851a 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -177,7 +177,7 @@ void patternFormatDeprecated() { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertFalse(messages.isEmpty()); - assertEquals(": does not match the custom pattern must be test", messages.iterator().next().getMessage()); + assertEquals(": does not match the custom pattern must be test", messages.iterator().next().toString()); } static class CustomNumberFormat implements Format { @@ -226,7 +226,7 @@ void shouldAllowNumberFormat() { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertFalse(messages.isEmpty()); - assertEquals(": does not match the custom-number pattern ", messages.iterator().next().getMessage()); + assertEquals(": does not match the custom-number pattern ", messages.iterator().next().toString()); messages = schema.validate("12345", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 89e3f7e9c..323681cb9 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -33,6 +33,6 @@ void propertyNameEnumShouldFailV7() throws Exception { Assertions.assertEquals(1, errors.size()); final ValidationMessage error = errors.iterator().next(); Assertions.assertEquals("$", error.getInstanceLocation().toString()); - Assertions.assertEquals("$: property 'z' name is not valid: does not have a value in the enumeration [\"a\", \"b\", \"c\"]", error.getMessage()); + Assertions.assertEquals("$: property 'z' name is not valid: does not have a value in the enumeration [\"a\", \"b\", \"c\"]", error.toString()); } } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index c5e47c386..e988f1e88 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -17,7 +17,7 @@ void failure() { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); } catch (Throwable e) { assertThat(e, instanceOf(JsonSchemaException.class)); - assertEquals("/$id: 'test' is not a valid $id", e.getMessage()); + assertEquals("/$id: 'test' is not a valid $id", ((JsonSchemaException) e).getError().toString()); } } } diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 7e60581d2..2efc4eb33 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -48,7 +48,7 @@ void shouldFailAndShowValidationValuesWithError() throws Exception { List errors = schema.validate(node); List errorMessages = new ArrayList(); for (ValidationMessage error: errors) { - errorMessages.add(error.getMessage()); + errorMessages.add(error.toString()); } List expectedMessages = Arrays.asList( diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index 591fbab9d..d33330e17 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -66,7 +66,7 @@ void testInvalidJson1 () Set allErrorMessages = new HashSet<>(); errors.forEach(vm -> { - allErrorMessages.add(vm.getMessage()); + allErrorMessages.add(vm.toString()); }); assertThat(allErrorMessages, Matchers.containsInAnyOrder("$.parameters[0].value: string found, integer expected", @@ -86,7 +86,7 @@ void testInvalidJson2 () Set allErrorMessages = new HashSet<>(); errors.forEach(vm -> { - allErrorMessages.add(vm.getMessage()); + allErrorMessages.add(vm.toString()); }); assertThat(allErrorMessages, Matchers.containsInAnyOrder( "$.parameters[1].value: string found, integer expected", diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index 3e1eaba9c..3510a31a0 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -39,7 +39,7 @@ void testCorrectErrorForInvalidValue() throws IOException { JsonNode node = getJsonNodeFromClasspath(resource("objectInvalidValue.json")); List errors = schema.validate(node); List errorMessages = errors.stream() - .map(v -> v.getEvaluationPath() + " = " + v.getMessage()) + .map(v -> v.getEvaluationPath() + " = " + v.toString()) .collect(toList()); // As this is from an anyOf evaluation both error messages should be present as they didn't match any diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index 9fd5556ac..ae2a5f5cc 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -26,8 +26,8 @@ void testDefaults() { void testValidationWithDefaultBundleAndLocale() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); ResourceBundle resourceBundle = ResourceBundle.getBundle(DefaultMessageSource.BUNDLE_BASE_NAME, Locale.getDefault()); - String expectedMessage = new MessageFormat(resourceBundle.getString("type")).format(new String[] {"/foo", "integer", "string"}); - verify(config, expectedMessage); + String expectedMessage = new MessageFormat(resourceBundle.getString("type")).format(new String[] {"integer", "string"}); + verify(config, "/foo: " + expectedMessage); } @Test @@ -61,7 +61,7 @@ private JsonSchema getSchema(SchemaValidatorsConfig config) { private void verify(SchemaValidatorsConfig config, String expectedMessage) throws JsonProcessingException { List messages = getSchema(config).validate(new ObjectMapper().readTree(" { \"foo\": 123 } ")); assertEquals(1, messages.size()); - assertEquals(expectedMessage, messages.iterator().next().getMessage()); + assertEquals(expectedMessage, messages.iterator().next().toString()); } } diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index bbb97197a..67a03ead4 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -19,7 +19,7 @@ void testMessagesWithSingleQuotes() throws Exception { JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); List messages = schema.validate(node).stream() - .map(ValidationMessage::getMessage) + .map(ValidationMessage::toString) .collect(toList()); Assertions.assertEquals(2, messages.size()); diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index fe8d9300f..27cca2005 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -35,7 +35,7 @@ void shouldThrowInvalidSchemaException() { try { JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config); } catch (InvalidSchemaException e) { - assertEquals("/$id: '0' is not a valid $id", e.getMessage()); + assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } } } diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index f6f6fccb1..1235aa784 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -56,7 +56,7 @@ void messageInvalid() { assertEquals("/1", message.getInstanceLocation().toString()); assertEquals("\"integer\"", message.getSchemaNode().toString()); assertEquals("\"x\"", message.getInstanceNode().toString()); - assertEquals("/1: string found, integer expected", message.getMessage()); + assertEquals("/1: string found, integer expected", message.toString()); assertNull(message.getProperty()); } diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 78c37ff28..769b14c58 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -59,7 +59,7 @@ void messageInvalid() { assertEquals("/1", message.getInstanceLocation().toString()); assertEquals("\"integer\"", message.getSchemaNode().toString()); assertEquals("\"x\"", message.getInstanceNode().toString()); - assertEquals("/1: string found, integer expected", message.getMessage()); + assertEquals("/1: string found, integer expected", message.toString()); assertNull(message.getProperty()); } @@ -86,7 +86,7 @@ void messageAdditionalItemsInvalid() { assertEquals("/3", message.getInstanceLocation().toString()); assertEquals("\"integer\"", message.getSchemaNode().toString()); assertEquals("\"foo\"", message.getInstanceNode().toString()); - assertEquals("/3: string found, integer expected", message.getMessage()); + assertEquals("/3: string found, integer expected", message.toString()); assertNull(message.getProperty()); } @@ -113,7 +113,7 @@ void messageAdditionalItemsFalseInvalid() { assertEquals("", message.getInstanceLocation().toString()); assertEquals("false", message.getSchemaNode().toString()); assertEquals("[null,2,3,\"foo\"]", message.getInstanceNode().toString()); - assertEquals(": index '1' is not defined in the schema and the schema does not allow additional items", message.getMessage()); + assertEquals(": index '1' is not defined in the schema and the schema does not allow additional items", message.toString()); assertNull(message.getProperty()); } diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 5ca6fb561..9a8d964d6 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -24,7 +24,7 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema); if (shouldValidateSchema) { - assertThat(result.getValidationMessages().stream().map(ValidationMessage::getMessage).collect(Collectors.toList()), + assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/badArray/1: integer found, string expected", "/outer/reference/stringValue_missing_with_default_null: null found, string expected")); @@ -44,7 +44,7 @@ void testApplyDefaults2() throws IOException { JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, false)); ValidationResult result = jsonSchema.walk(inputNode, true); - assertThat(result.getValidationMessages().stream().map(ValidationMessage::getMessage).collect(Collectors.toList()), + assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", "/outer/badArray/1: null found, string expected", @@ -61,7 +61,7 @@ void testApplyDefaults1() throws IOException { JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, false, false)); ValidationResult result = jsonSchema.walk(inputNode, true); - assertThat(result.getValidationMessages().stream().map(ValidationMessage::getMessage).collect(Collectors.toList()), + assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_null: null found, integer expected", "/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", @@ -100,7 +100,7 @@ void testApplyDefaults0(String method) throws IOException { default: throw new UnsupportedOperationException(); } - assertThat(validationMessages.stream().map(ValidationMessage::getMessage).collect(Collectors.toList()), + assertThat(validationMessages.stream().map(ValidationMessage::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject: required property 'intValue_missing' not found", "/outer/mixedObject: required property 'intValue_missingButError' not found", "/outer/mixedObject/intValue_null: null found, integer expected", diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index e4bd7f8be..3f7707fbc 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -57,19 +57,17 @@ void executionContextLocale() throws JsonMappingException, JsonProcessingExcepti ExecutionContext executionContext = jsonSchema.createExecutionContext(); assertEquals(config.getLocale(), executionContext.getExecutionConfig().getLocale()); executionContext.getExecutionConfig().setLocale(locale); - jsonSchema.validate(executionContext, rootNode); - List messages = executionContext.getErrors(); + List messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); assertEquals(1, messages.size()); - assertEquals("/foo: integer trouvé, string attendu", messages.iterator().next().getMessage()); + assertEquals("/foo: integer trouvé, string attendu", messages.iterator().next().toString()); locale = Locales.findSupported("it;q=1.0,fr;q=0.9"); // it executionContext = jsonSchema.createExecutionContext(); assertEquals(config.getLocale(), executionContext.getExecutionConfig().getLocale()); executionContext.getExecutionConfig().setLocale(locale); - jsonSchema.validate(executionContext, rootNode); - messages = executionContext.getErrors(); + messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); assertEquals(1, messages.size()); - assertEquals("/foo: integer trovato, string previsto", messages.iterator().next().getMessage()); + assertEquals("/foo: integer trovato, string previsto", messages.iterator().next().toString()); } /** diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index f278c78ca..09b088563 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -42,7 +42,7 @@ static class EqualsValidator extends BaseJsonValidator { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { if (!node.asText().equals(value)) { - executionContext.addError(message().message("{0}: must be equal to ''{1}''") + executionContext.addError(message().message("must be equal to ''{0}''") .arguments(value) .instanceLocation(instanceLocation).instanceNode(node).build()); } @@ -76,7 +76,7 @@ void message() { JsonSchema schema = factory.getSchema(schemaData); List messages = schema.validate("\"helloworlda\"", InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals("$: must be equal to 'helloworld'", messages.iterator().next().getMessage()); + assertEquals("$: must be equal to 'helloworld'", messages.iterator().next().toString()); messages = schema.validate("\"helloworld\"", InputFormat.JSON); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 1b41cb86b..a92141cbb 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -72,7 +72,7 @@ void oneOfMultiple() { assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); assertEquals("$: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", - assertions.get(0).getMessage()); + assertions.get(0).toString()); } @Test @@ -112,7 +112,7 @@ void oneOfZero() { assertEquals("oneOf", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); - assertEquals("$: must be valid to one and only one schema, but 0 are valid", assertions.get(0).getMessage()); + assertEquals("$: must be valid to one and only one schema, but 0 are valid", assertions.get(0).toString()); assertEquals("additionalProperties", assertions.get(1).getKeyword()); assertEquals("$", assertions.get(1).getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 84a87169c..dcd56dcc7 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -42,7 +42,7 @@ void testInvalidJson() throws Exception { Assertions.assertEquals(3, errors.size()); Set messages = errors.stream().map(m -> new String[] { m.getEvaluationPath().toString(), - m.getSchemaLocation().toString(), m.getInstanceLocation().toString(), m.getMessage() }) + m.getSchemaLocation().toString(), m.getInstanceLocation().toString(), m.toString() }) .collect(Collectors.toSet()); assertThat(messages, @@ -68,7 +68,7 @@ private ValidationMessage format(ValidationMessage message) { builder.append("'"); builder.append(" "); } - builder.append(message.getError()); + builder.append(message.getMessage()); return builder.toString(); }; diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 3018a8eef..a9a404e5e 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -45,7 +45,7 @@ private List validate() throws Exception { private Map transferErrorMsg(List validationMessages) { Map pathToMessage = new HashMap<>(); validationMessages.forEach(msg -> { - pathToMessage.put(msg.getInstanceLocation().toString(), msg.getMessage()); + pathToMessage.put(msg.getInstanceLocation().toString(), msg.toString()); }); return pathToMessage; } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index de7d298a9..63dc09411 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -95,7 +95,7 @@ void message() { assertEquals("/valid_key", message.getInstanceLocation().toString()); assertEquals("[\"array\",\"string\"]", message.getSchemaNode().toString()); assertEquals("5", message.getInstanceNode().toString()); - assertEquals("/valid_key: integer found, [array, string] expected", message.getMessage()); + assertEquals("/valid_key: integer found, [array, string] expected", message.toString()); assertNull(message.getProperty()); String inputData2 = "{\n" @@ -111,7 +111,7 @@ void message() { assertEquals("/valid_array/0", message.getInstanceLocation().toString()); assertEquals("\"string\"", message.getSchemaNode().toString()); assertEquals("999", message.getInstanceNode().toString()); - assertEquals("/valid_array/0: integer found, string expected", message.getMessage()); + assertEquals("/valid_array/0: integer found, string expected", message.toString()); assertNull(message.getProperty()); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 27bc08db8..fb2f9a6a9 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -65,7 +65,7 @@ void messageInvalid() { assertEquals("/0", message.getInstanceLocation().toString()); assertEquals("\"string\"", message.getSchemaNode().toString()); assertEquals("1", message.getInstanceNode().toString()); - assertEquals("/0: integer found, string expected", message.getMessage()); + assertEquals("/0: integer found, string expected", message.toString()); assertNull(message.getProperty()); } @@ -110,7 +110,7 @@ void messageInvalidAdditionalItems() { assertEquals("", message.getInstanceLocation().toString()); assertEquals("false", message.getSchemaNode().toString()); assertEquals("[\"x\",1,1,2]", message.getInstanceNode().toString()); - assertEquals(": index '2' is not defined in the schema and the schema does not allow additional items", message.getMessage()); + assertEquals(": index '2' is not defined in the schema and the schema does not allow additional items", message.toString()); assertNull(message.getProperty()); } diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 9100c6429..2ab459ed7 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -53,7 +53,7 @@ void messageInvalid() { assertEquals("", message.getInstanceLocation().toString()); assertEquals("{\"maxLength\":3}", message.getSchemaNode().toString()); assertEquals("{\"foo\":{},\"foobar\":{}}", message.getInstanceNode().toString()); - assertEquals(": property 'foobar' name is not valid: must be at most 3 characters long", message.getMessage()); + assertEquals(": property 'foobar' name is not valid: must be at most 3 characters long", message.toString()); assertEquals("foobar", message.getProperty()); } } diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index dc2ba4c0d..93d48bf7e 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -29,7 +29,7 @@ void givenConfigWriteTrueWhenReadOnlyTrueThenDenies() throws IOException { List errors = loadJsonSchema(true).validate(node); assertFalse(errors.isEmpty()); assertEquals("/firstName: is a readonly field, it cannot be changed", - errors.stream().map(e -> e.getMessage()).collect(Collectors.toList()).get(0)); + errors.stream().map(e -> e.toString()).collect(Collectors.toList()).get(0)); } private JsonSchema loadJsonSchema(Boolean write) { diff --git a/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java b/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java index aa69109be..86e91e223 100644 --- a/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java +++ b/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java @@ -63,8 +63,8 @@ void messageFrench() { @Test void messageMaxItems() { - String message = messageSource.getMessage("maxItems", Locale.getDefault(), "item", 5, 10); - assertEquals("item: must have at most 5 items but found 10", message); + String message = messageSource.getMessage("maxItems", Locale.getDefault(), 5, 10); + assertEquals("must have at most 5 items but found 10", message); } @Test @@ -78,6 +78,6 @@ void overrideMessage() { MessageSource messageSource = new ResourceBundleMessageSource("jsv-messages-override", "jsv-messages"); assertEquals("path: overridden message value", messageSource.getMessage("allOf", Locale.ROOT, "path", "value")); assertEquals("path: overridden message value", messageSource.getMessage("allOf", Locale.FRENCH, "path", "value")); - assertEquals("path: must be valid to any of the schemas value", messageSource.getMessage("anyOf", Locale.ROOT, "path", "value")); + assertEquals("must be valid to any of the schemas value", messageSource.getMessage("anyOf", Locale.ROOT, "value")); } } diff --git a/src/test/resources/const-messages-override.properties b/src/test/resources/const-messages-override.properties index 247e95263..896237ecd 100644 --- a/src/test/resources/const-messages-override.properties +++ b/src/test/resources/const-messages-override.properties @@ -1 +1 @@ -const = {0}: must be the constant value ''{1}'' but is ''{2}'' \ No newline at end of file +const = must be the constant value ''{0}'' but is ''{1}'' \ No newline at end of file diff --git a/src/test/resources/issue686/translations.properties b/src/test/resources/issue686/translations.properties index 4dfc094c0..b57350150 100644 --- a/src/test/resources/issue686/translations.properties +++ b/src/test/resources/issue686/translations.properties @@ -1 +1 @@ -type = {0}: {1} found, {2} expected (TEST) +type = {0} found, {1} expected (TEST) diff --git a/src/test/resources/issue686/translations_de.properties b/src/test/resources/issue686/translations_de.properties index f9df24408..5db69d10b 100644 --- a/src/test/resources/issue686/translations_de.properties +++ b/src/test/resources/issue686/translations_de.properties @@ -1 +1 @@ -type = {0}: {1} found, {2} expected (TEST) (DE) +type = {0} found, {1} expected (TEST) (DE) diff --git a/src/test/resources/issue686/translations_fr.properties b/src/test/resources/issue686/translations_fr.properties index d627e458d..518a44aef 100644 --- a/src/test/resources/issue686/translations_fr.properties +++ b/src/test/resources/issue686/translations_fr.properties @@ -1 +1 @@ -type = {0}: {1} found, {2} expected (TEST) (FR) +type = {0} found, {1} expected (TEST) (FR) diff --git a/src/test/resources/schema/OverwritingCustomMessageBug.json b/src/test/resources/schema/OverwritingCustomMessageBug.json index 6ead21bc1..8eecb3bfb 100644 --- a/src/test/resources/schema/OverwritingCustomMessageBug.json +++ b/src/test/resources/schema/OverwritingCustomMessageBug.json @@ -10,7 +10,7 @@ "type": "string", "pattern": "(foo)+", "message": { - "pattern": "{0}: Must be a string with the a shape foofoofoofoo... with at least one foo" + "pattern": "Must be a string with the a shape foofoofoofoo... with at least one foo" } }, "Nope": { @@ -20,7 +20,7 @@ "type": "string", "pattern": "(bar)+", "message": { - "pattern": "{0}: Must be a string with the a shape barbarbar... with at least one bar" + "pattern": "Must be a string with the a shape barbarbar... with at least one bar" } } } diff --git a/src/test/resources/schema/customMessageTests/custom-message-tests.json b/src/test/resources/schema/customMessageTests/custom-message-tests.json index 18e1ef138..fa92002d9 100644 --- a/src/test/resources/schema/customMessageTests/custom-message-tests.json +++ b/src/test/resources/schema/customMessageTests/custom-message-tests.json @@ -51,7 +51,7 @@ }, "valid": false, "validationMessages": [ - "Custom Message: Invalid type provided" + "/bar: Custom Message: Invalid type provided" ] }, { @@ -65,7 +65,7 @@ }, "valid": false, "validationMessages": [ - "Custom Message: Only numbers are supported in 'foo'" + "/foo/2: Custom Message: Only numbers are supported in 'foo'" ] }, { @@ -79,7 +79,7 @@ }, "valid": false, "validationMessages": [ - "Custom Message: Maximum 3 numbers can be given in 'foo'" + "/foo: Custom Message: Maximum 3 numbers can be given in 'foo'" ] }, { @@ -93,8 +93,8 @@ }, "valid": false, "validationMessages": [ - "Custom Message: Invalid type provided", - "Custom Message: Only numbers are supported in 'foo'" + "/bar: Custom Message: Invalid type provided", + "/foo/2: Custom Message: Only numbers are supported in 'foo'" ] }, { @@ -108,9 +108,9 @@ }, "valid": false, "validationMessages": [ - "Custom Message: Invalid type provided", - "Custom Message: Only numbers are supported in 'foo'", - "Custom Message: Maximum 3 numbers can be given in 'foo'" + "/bar: Custom Message: Invalid type provided", + "/foo/2: Custom Message: Only numbers are supported in 'foo'", + "/foo: Custom Message: Maximum 3 numbers can be given in 'foo'" ] } ] @@ -131,8 +131,8 @@ "message": { "type" : "should be an object", "required": { - "foo" : "{0}: ''foo'' is required", - "bar" : "{0}: ''bar'' is required" + "foo" : "'foo' is required", + "bar" : "'bar' is required" } } }, @@ -192,7 +192,7 @@ "type": "string", "minLength": 1, "message": { - "minLength": "{0}: Item should not be empty" + "minLength": "Item should not be empty" } } } From 88574644730a003bde0b9bab871bbe1f22d87586 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 21 Sep 2025 22:03:34 +0800 Subject: [PATCH 04/74] Rename ValidationMessage to Error --- .../schema/AdditionalPropertiesValidator.java | 2 +- .../com/networknt/schema/AllOfValidator.java | 2 +- .../com/networknt/schema/AnyOfValidator.java | 12 ++--- .../networknt/schema/BaseJsonValidator.java | 5 +- .../com/networknt/schema/ConstValidator.java | 4 +- .../networknt/schema/ContainsValidator.java | 6 +-- .../schema/ContentEncodingValidator.java | 4 +- .../schema/ContentMediaTypeValidator.java | 4 +- .../schema/DefaultJsonMetaSchemaFactory.java | 4 +- .../schema/DependenciesValidator.java | 2 +- .../networknt/schema/DependentRequired.java | 2 +- .../DisallowUnknownJsonMetaSchemaFactory.java | 2 +- .../schema/DisallowUnknownKeywordFactory.java | 2 +- .../networknt/schema/DynamicRefValidator.java | 8 ++-- .../com/networknt/schema/EnumValidator.java | 2 +- .../{ValidationMessage.java => Error.java} | 15 +++--- .../schema/ExclusiveMaximumValidator.java | 2 +- .../schema/ExclusiveMinimumValidator.java | 2 +- .../networknt/schema/ExecutionContext.java | 8 ++-- .../schema/FailFastAssertionException.java | 8 ++-- .../com/networknt/schema/FalseValidator.java | 2 +- .../java/com/networknt/schema/Format.java | 2 +- .../com/networknt/schema/FormatValidator.java | 4 +- .../com/networknt/schema/IfValidator.java | 8 ++-- .../schema/InvalidSchemaException.java | 4 +- .../schema/InvalidSchemaRefException.java | 4 +- .../com/networknt/schema/ItemsValidator.java | 2 +- .../schema/ItemsValidator202012.java | 2 +- .../com/networknt/schema/JsonMetaSchema.java | 4 +- .../java/com/networknt/schema/JsonSchema.java | 31 ++++++------- .../networknt/schema/JsonSchemaException.java | 8 ++-- .../networknt/schema/MaxItemsValidator.java | 4 +- .../networknt/schema/MaxLengthValidator.java | 2 +- .../schema/MaxPropertiesValidator.java | 2 +- .../networknt/schema/MaximumValidator.java | 2 +- ...onMessage.java => MessageSourceError.java} | 8 ++-- .../networknt/schema/MinItemsValidator.java | 4 +- .../networknt/schema/MinLengthValidator.java | 2 +- .../schema/MinMaxContainsValidator.java | 2 +- .../schema/MinPropertiesValidator.java | 2 +- .../networknt/schema/MinimumValidator.java | 2 +- .../networknt/schema/MultipleOfValidator.java | 2 +- .../networknt/schema/NotAllowedValidator.java | 2 +- .../com/networknt/schema/NotValidator.java | 6 +-- .../com/networknt/schema/OneOfValidator.java | 12 ++--- .../com/networknt/schema/OutputFormat.java | 28 +++++------ .../networknt/schema/PatternValidator.java | 2 +- .../schema/PropertyNamesValidator.java | 8 ++-- .../networknt/schema/ReadOnlyValidator.java | 2 +- .../schema/RecursiveRefValidator.java | 12 ++--- .../com/networknt/schema/RefValidator.java | 8 ++-- .../networknt/schema/RequiredValidator.java | 2 +- .../schema/SchemaValidatorsConfig.java | 2 +- .../com/networknt/schema/TrueValidator.java | 2 +- .../com/networknt/schema/TypeValidator.java | 2 +- .../schema/UnevaluatedItemsValidator.java | 2 +- .../UnevaluatedPropertiesValidator.java | 2 +- .../networknt/schema/UnionTypeValidator.java | 6 +-- .../schema/UniqueItemsValidator.java | 2 +- .../networknt/schema/ValidationResult.java | 2 +- .../networknt/schema/WriteOnlyValidator.java | 2 +- .../HierarchicalOutputUnitFormatter.java | 10 ++-- .../output/ListOutputUnitFormatter.java | 10 ++-- .../schema/output/OutputUnitData.java | 46 ++++++------------- .../regex/AllowRegularExpressionFactory.java | 4 +- .../schema/resource/AllowSchemaLoader.java | 4 +- .../schema/resource/DisallowSchemaLoader.java | 4 +- .../walk/AbstractWalkListenerRunner.java | 6 +-- .../walk/DefaultItemWalkListenerRunner.java | 6 +-- .../DefaultKeywordWalkListenerRunner.java | 21 +++++---- .../DefaultPropertyWalkListenerRunner.java | 6 +-- .../schema/walk/JsonSchemaWalkListener.java | 4 +- .../schema/walk/WalkListenerRunner.java | 4 +- .../schema/AbstractJsonSchemaTest.java | 6 +-- .../schema/AbstractJsonSchemaTestSuite.java | 6 +-- .../AdditionalPropertiesValidatorTest.java | 8 ++-- .../networknt/schema/AllOfValidatorTest.java | 2 +- .../networknt/schema/AnyOfValidatorTest.java | 2 +- .../schema/CollectorContextTest.java | 10 ++-- .../networknt/schema/ConstValidatorTest.java | 10 ++-- .../schema/CustomMetaSchemaTest.java | 8 ++-- .../com/networknt/schema/CustomUriTest.java | 2 +- .../com/networknt/schema/DateTimeDSTTest.java | 2 +- .../schema/DependentRequiredTest.java | 10 ++-- .../schema/DiscriminatorValidatorTest.java | 28 +++++------ .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 8 ++-- ...HandlerTest.java => ErrorHandlerTest.java} | 8 ++-- ...idationMessageTest.java => ErrorTest.java} | 6 +-- .../com/networknt/schema/ExampleTest.java | 4 +- .../schema/ExclusiveMinimumValidatorTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 14 +++--- .../com/networknt/schema/IfValidatorTest.java | 16 +++---- .../com/networknt/schema/Issue1091Test.java | 2 +- .../com/networknt/schema/Issue255Test.java | 2 +- .../com/networknt/schema/Issue285Test.java | 18 ++++---- .../com/networknt/schema/Issue295Test.java | 2 +- .../com/networknt/schema/Issue313Test.java | 4 +- .../com/networknt/schema/Issue327Test.java | 2 +- .../com/networknt/schema/Issue342Test.java | 4 +- .../schema/Issue366FailFastTest.java | 4 +- .../schema/Issue366FailSlowTest.java | 8 ++-- .../com/networknt/schema/Issue375Test.java | 4 +- .../com/networknt/schema/Issue383Test.java | 2 +- .../com/networknt/schema/Issue396Test.java | 4 +- .../com/networknt/schema/Issue404Test.java | 2 +- .../com/networknt/schema/Issue426Test.java | 4 +- .../com/networknt/schema/Issue428Test.java | 6 +-- .../com/networknt/schema/Issue451Test.java | 2 +- .../com/networknt/schema/Issue456Test.java | 4 +- .../com/networknt/schema/Issue461Test.java | 4 +- .../com/networknt/schema/Issue467Test.java | 8 ++-- .../com/networknt/schema/Issue471Test.java | 8 ++-- .../com/networknt/schema/Issue475Test.java | 10 ++-- .../com/networknt/schema/Issue493Test.java | 8 ++-- .../com/networknt/schema/Issue550Test.java | 12 ++--- .../com/networknt/schema/Issue575Test.java | 4 +- .../com/networknt/schema/Issue606Test.java | 2 +- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue662Test.java | 6 +-- .../com/networknt/schema/Issue664Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 4 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 14 +++--- .../com/networknt/schema/Issue724Test.java | 2 +- .../com/networknt/schema/Issue784Test.java | 2 +- .../com/networknt/schema/Issue824Test.java | 4 +- .../com/networknt/schema/Issue832Test.java | 2 +- .../com/networknt/schema/Issue857Test.java | 2 +- .../com/networknt/schema/Issue877Test.java | 4 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 2 +- .../com/networknt/schema/Issue939Test.java | 2 +- .../schema/ItemsValidator202012Test.java | 12 ++--- .../networknt/schema/ItemsValidatorTest.java | 32 ++++++------- .../com/networknt/schema/JsonSchemaTest.java | 2 +- .../schema/JsonWalkApplyDefaultsTest.java | 18 ++++---- .../com/networknt/schema/JsonWalkTest.java | 6 +-- .../java/com/networknt/schema/LocaleTest.java | 6 +-- .../schema/MaximumValidatorTest.java | 14 +++--- .../com/networknt/schema/MessageTest.java | 4 +- .../schema/MetaSchemaValidationTest.java | 2 +- .../schema/MinimumValidatorTest.java | 14 +++--- .../schema/MultipleOfValidatorTest.java | 4 +- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 26 +++++------ .../schema/OpenAPI30JsonSchemaTest.java | 6 +-- .../networknt/schema/OutputFormatTest.java | 14 +++--- .../com/networknt/schema/OutputUnitTest.java | 4 +- .../schema/OverrideValidatorTest.java | 2 +- .../OverwritingCustomMessageBugTest.java | 8 ++-- .../PatternPropertiesValidatorTest.java | 8 ++-- .../schema/PrefixItemsValidatorTest.java | 18 ++++---- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 4 +- .../schema/ReadOnlyValidatorTest.java | 4 +- .../java/com/networknt/schema/RefTest.java | 8 ++-- .../networknt/schema/RefValidatorTest.java | 8 ++-- .../schema/RequiredValidatorTest.java | 12 ++--- .../java/com/networknt/schema/SampleTest.java | 10 ++-- .../networknt/schema/SchemaLocationTest.java | 2 +- .../networknt/schema/SharedConfigTest.java | 2 +- .../networknt/schema/TypeValidatorTest.java | 10 ++-- .../schema/UnevaluatedItemsValidatorTest.java | 8 ++-- .../UnevaluatedPropertiesValidatorTest.java | 14 +++--- .../schema/UnknownMetaSchemaTest.java | 12 ++--- .../networknt/schema/V4JsonSchemaTest.java | 12 ++--- .../com/networknt/schema/VocabularyTest.java | 4 +- .../schema/format/IriFormatTest.java | 16 +++---- .../schema/format/IriReferenceFormatTest.java | 16 +++---- .../schema/format/TimeFormatTest.java | 6 +-- .../schema/format/UriFormatTest.java | 16 +++---- .../schema/format/UriReferenceFormatTest.java | 16 +++---- .../networknt/schema/oas/OpenApi30Test.java | 6 +-- .../networknt/schema/oas/OpenApi31Test.java | 20 ++++---- .../schema/output/OutputUnitDataTest.java | 39 ---------------- .../com/networknt/schema/suite/TestSpec.java | 12 ++--- .../networknt/schema/utils/JsonNodesTest.java | 18 ++++---- .../walk/JsonSchemaWalkListenerTest.java | 46 +++++++++---------- .../invalid-min-max-contains.json | 14 +++--- .../invalid-min-max-contains.json | 14 +++--- src/test/resources/draft2020-12/issue656.json | 2 +- src/test/resources/draft2020-12/issue798.json | 6 +-- src/test/resources/draft4/issue425.json | 2 +- src/test/resources/draft7/issue470.json | 8 ++-- src/test/resources/draft7/issue491.json | 16 +++---- src/test/resources/draft7/issue516.json | 2 +- src/test/resources/draft7/issue653.json | 2 +- src/test/resources/draft7/issue678.json | 2 +- .../custom-message-disabled-tests.json | 10 ++-- .../custom-message-tests.json | 18 ++++---- .../unevaluatedTests/unevaluated-tests.json | 26 +++++------ 192 files changed, 679 insertions(+), 732 deletions(-) rename src/main/java/com/networknt/schema/{ValidationMessage.java => Error.java} (94%) rename src/main/java/com/networknt/schema/{MessageSourceValidationMessage.java => MessageSourceError.java} (90%) rename src/test/java/com/networknt/schema/{ValidationMessageHandlerTest.java => ErrorHandlerTest.java} (89%) rename src/test/java/com/networknt/schema/{ValidationMessageTest.java => ErrorTest.java} (86%) delete mode 100644 src/test/java/com/networknt/schema/output/OutputUnitDataTest.java diff --git a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java index 39963cbc6..5e7a91caa 100644 --- a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java @@ -117,7 +117,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } if (!allowedProperties.contains(pname) && !handledByPatternProperties(pname)) { if (!allowAdditionalProperties) { - executionContext.addError(message().instanceNode(node).property(pname) + executionContext.addError(error().instanceNode(node).property(pname) .instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(pname).build()); diff --git a/src/main/java/com/networknt/schema/AllOfValidator.java b/src/main/java/com/networknt/schema/AllOfValidator.java index a74e7aeec..e0f5996aa 100644 --- a/src/main/java/com/networknt/schema/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/AllOfValidator.java @@ -36,7 +36,7 @@ public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ALL_OF, validationContext); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); - throw new JsonSchemaException(message().instanceNode(schemaNode) + throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") diff --git a/src/main/java/com/networknt/schema/AnyOfValidator.java b/src/main/java/com/networknt/schema/AnyOfValidator.java index 3aad82677..87cd71fc0 100644 --- a/src/main/java/com/networknt/schema/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/AnyOfValidator.java @@ -38,7 +38,7 @@ public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ANY_OF, validationContext); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); - throw new JsonSchemaException(message().instanceNode(schemaNode) + throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") @@ -66,9 +66,9 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo executionContext.enterDiscriminatorContext(new DiscriminatorContext(), instanceLocation); } int numberOfValidSubSchemas = 0; - List existingErrors = executionContext.getErrors(); - List allErrors = null; - List errors = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List allErrors = null; + List errors = new ArrayList<>(); executionContext.setErrors(errors); try { // Save flag as nested schema evaluation shouldn't trigger fail fast @@ -120,7 +120,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { if (allErrors == null) { allErrors = new ArrayList<>(); } - allErrors.add(message().instanceNode(node).instanceLocation(instanceLocation) + allErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(DISCRIMINATOR_REMARK) .build()); @@ -146,7 +146,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled() && executionContext.getCurrentDiscriminatorContext().isActive() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { - existingErrors.add(message().instanceNode(node).instanceLocation(instanceLocation) + existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments( "based on the provided discriminator. No alternative could be chosen based on the discriminator property") diff --git a/src/main/java/com/networknt/schema/BaseJsonValidator.java b/src/main/java/com/networknt/schema/BaseJsonValidator.java index fe4978255..0fde1100a 100644 --- a/src/main/java/com/networknt/schema/BaseJsonValidator.java +++ b/src/main/java/com/networknt/schema/BaseJsonValidator.java @@ -76,7 +76,6 @@ protected BaseJsonValidator( /* Below from BaseJsonValidator */ JsonNode schemaNode, ValidationContext validationContext, - /* Below from ValidationMessageHandler */ Keyword keyword, JsonSchema parentSchema, SchemaLocation schemaLocation, @@ -215,8 +214,8 @@ protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { return false; } - protected MessageSourceValidationMessage.Builder message() { - return MessageSourceValidationMessage + protected MessageSourceError.Builder error() { + return MessageSourceError .builder(this.validationContext.getConfig().getMessageSource(), this.errorMessage) .schemaNode(this.schemaNode).schemaLocation(this.schemaLocation).evaluationPath(this.evaluationPath) .keyword(this.keyword != null ? this.keyword.getValue() : null).messageKey(this.getKeyword()); diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/ConstValidator.java index 958a1746a..078ad0f07 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/ConstValidator.java @@ -35,13 +35,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (schemaNode.isNumber() && node.isNumber()) { if (schemaNode.decimalValue().compareTo(node.decimalValue()) != 0) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(schemaNode.asText(), node.asText()) .build()); } } else if (!schemaNode.equals(node)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()).arguments(schemaNode.asText(), node.asText()).build()); } } diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/ContainsValidator.java index 454fa7aaa..cad439eed 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/ContainsValidator.java @@ -88,10 +88,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (null != this.schema && node.isArray()) { // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - List existingErrors = executionContext.getErrors(); + List existingErrors = executionContext.getErrors(); try { executionContext.setFailFast(false); - List test = new ArrayList<>(); + List test = new ArrayList<>(); executionContext.setErrors(test); for (JsonNode n : node) { JsonNodePath path = instanceLocation.append(i); @@ -192,7 +192,7 @@ private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode } else if (ValidatorTypeCode.MAX_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MAX; } - executionContext.addError(message().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) + executionContext.addError(error().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) .locale(locale).arguments(String.valueOf(bounds), this.schema.getSchemaNode().toString()) .keyword(validatorTypeCode.getValue()).build()); } diff --git a/src/main/java/com/networknt/schema/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/ContentEncodingValidator.java index 4208825db..93d5fda54 100644 --- a/src/main/java/com/networknt/schema/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/ContentEncodingValidator.java @@ -27,7 +27,7 @@ * {@link JsonValidator} for contentEncoding. *

* Note that since 2019-09 this keyword only generates annotations and not - * assertions. + * errors. */ public class ContentEncodingValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(ContentEncodingValidator.class); @@ -79,7 +79,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (!matches(node.asText())) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.contentEncoding) .build()); diff --git a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java index 4ad8bd491..f367c8bb3 100644 --- a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java @@ -30,7 +30,7 @@ /** * {@link JsonValidator} for contentMediaType. *

- * Note that since 2019-09 this keyword only generates annotations and not assertions. + * Note that since 2019-09 this keyword only generates annotations and not errors. */ public class ContentMediaTypeValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(ContentMediaTypeValidator.class); @@ -102,7 +102,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (!matches(node.asText())) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.contentMediaType) .build()); diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java index c9f3f7453..2d62b9b3e 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java @@ -45,9 +45,9 @@ protected JsonMetaSchema loadMetaSchema(String iri, JsonSchemaFactory schemaFact } catch (InvalidSchemaException e) { throw e; } catch (Exception e) { - ValidationMessage validationMessage = ValidationMessage.builder() + Error error = Error.builder() .message("Failed to load meta-schema ''{0}''").arguments(iri).build(); - throw new InvalidSchemaException(validationMessage, e); + throw new InvalidSchemaException(error, e); } } diff --git a/src/main/java/com/networknt/schema/DependenciesValidator.java b/src/main/java/com/networknt/schema/DependenciesValidator.java index 9e03e1191..85557f6d3 100644 --- a/src/main/java/com/networknt/schema/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/DependenciesValidator.java @@ -71,7 +71,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (deps != null && !deps.isEmpty()) { for (String field : deps) { if (node.get(field) == null) { - executionContext.addError(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(propertyDeps.toString()).build()); } diff --git a/src/main/java/com/networknt/schema/DependentRequired.java b/src/main/java/com/networknt/schema/DependentRequired.java index 80cd330bc..189c13201 100644 --- a/src/main/java/com/networknt/schema/DependentRequired.java +++ b/src/main/java/com/networknt/schema/DependentRequired.java @@ -55,7 +55,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (dependencies != null && !dependencies.isEmpty()) { for (String field : dependencies) { if (node.get(field) == null) { - executionContext.addError(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(field, pname) .build()); diff --git a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java index 6044f963a..8f788166d 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java @@ -22,7 +22,7 @@ public class DisallowUnknownJsonMetaSchemaFactory implements JsonMetaSchemaFactory { @Override public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { - throw new InvalidSchemaException(ValidationMessage.builder() + throw new InvalidSchemaException(Error.builder() .message("Unknown meta-schema ''{0}''. Only meta-schemas that are explicitly configured can be used.") .arguments(iri).build()); } diff --git a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java index ca46aaa32..7c52edf5c 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java @@ -27,7 +27,7 @@ public class DisallowUnknownKeywordFactory implements KeywordFactory { @Override public Keyword getKeyword(String value, ValidationContext validationContext) { logger.error("Keyword '{}' is unknown and must be configured on the meta-schema or vocabulary", value); - throw new InvalidSchemaException(ValidationMessage.builder() + throw new InvalidSchemaException(Error.builder() .message("Keyword ''{0}'' is unknown and must be configured on the meta-schema or vocabulary") .arguments(value).build()); } diff --git a/src/main/java/com/networknt/schema/DynamicRefValidator.java b/src/main/java/com/networknt/schema/DynamicRefValidator.java index 4b15a5cd3..820f5fbe1 100644 --- a/src/main/java/com/networknt/schema/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/DynamicRefValidator.java @@ -94,11 +94,11 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } refSchema.validate(executionContext, node, rootNode, instanceLocation); } @@ -111,11 +111,11 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } if (node == null) { // Check for circular dependency diff --git a/src/main/java/com/networknt/schema/EnumValidator.java b/src/main/java/com/networknt/schema/EnumValidator.java index f6b3faf90..a8f2d924d 100644 --- a/src/main/java/com/networknt/schema/EnumValidator.java +++ b/src/main/java/com/networknt/schema/EnumValidator.java @@ -98,7 +98,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode node = processArrayNode((ArrayNode) node); } if (!nodes.contains(node) && !( this.validationContext.getConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(error).build()); } diff --git a/src/main/java/com/networknt/schema/ValidationMessage.java b/src/main/java/com/networknt/schema/Error.java similarity index 94% rename from src/main/java/com/networknt/schema/ValidationMessage.java rename to src/main/java/com/networknt/schema/Error.java index a0cb2225c..8b04a66b4 100644 --- a/src/main/java/com/networknt/schema/ValidationMessage.java +++ b/src/main/java/com/networknt/schema/Error.java @@ -34,17 +34,18 @@ import java.util.function.Supplier; /** - * The output format. + * Represents an error which could be when parsing a schema or when validating + * an instance. * * @see JSON + * "https://github.com/json-schema-org/json-schema-spec/blob/main/specs/output/jsonschema-validation-output-machines.md">JSON * Schema */ @JsonIgnoreProperties({ "messageSupplier", "schemaNode", "instanceNode", "valid" }) @JsonPropertyOrder({ "keyword", "instanceLocation", "message", "evaluationPath", "schemaLocation", "messageKey", "arguments", "details" }) @JsonInclude(Include.NON_NULL) -public class ValidationMessage { +public class Error { private final String keyword; @JsonSerialize(using = ToStringSerializer.class) private final JsonNodePath evaluationPath; @@ -59,7 +60,7 @@ public class ValidationMessage { private final JsonNode instanceNode; private final JsonNode schemaNode; - ValidationMessage(String keyword, JsonNodePath evaluationPath, SchemaLocation schemaLocation, + Error(String keyword, JsonNodePath evaluationPath, SchemaLocation schemaLocation, JsonNodePath instanceLocation, Object[] arguments, Map details, String messageKey, Supplier messageSupplier, JsonNode instanceNode, JsonNode schemaNode) { super(); @@ -198,7 +199,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ValidationMessage that = (ValidationMessage) o; + Error that = (Error) o; if (keyword != null ? !keyword.equals(that.keyword) : that.keyword != null) return false; if (instanceLocation != null ? !instanceLocation.equals(that.instanceLocation) : that.instanceLocation != null) return false; @@ -365,7 +366,7 @@ public S schemaNode(JsonNode schemaNode) { return self(); } - public ValidationMessage build() { + public Error build() { Supplier messageSupplier = this.messageSupplier; String messageKey = this.messageKey; @@ -385,7 +386,7 @@ public ValidationMessage build() { return formatter.format(getMessageArguments()); }); } - return new ValidationMessage(keyword, evaluationPath, schemaLocation, instanceLocation, + return new Error(keyword, evaluationPath, schemaLocation, instanceLocation, arguments, details, messageKey, messageSupplier, this.instanceNode, this.schemaNode); } diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java index f75e69d50..b416f97a1 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java @@ -104,7 +104,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (typedMaximum.crossesThreshold(node)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(typedMaximum.thresholdValue()).build()); } diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java index df77f9cc6..8f903d97e 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java @@ -111,7 +111,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (typedMinimum.crossesThreshold(node)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(typedMinimum.thresholdValue()).build()); } diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 2ba67aa0a..75ede6b46 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -32,7 +32,7 @@ public class ExecutionContext { private Stack discriminatorContexts = null; private JsonNodeAnnotations annotations = null; private JsonNodeResults results = null; - private List errors = new ArrayList<>(); + private List errors = new ArrayList<>(); /** * This is used during the execution to determine if the validator should fail fast. @@ -177,18 +177,18 @@ public void leaveDiscriminatorContextImmediately(@SuppressWarnings("unused") Jso this.discriminatorContexts.pop(); } - public List getErrors() { + public List getErrors() { return this.errors; } - public void addError(ValidationMessage error) { + public void addError(Error error) { this.errors.add(error); if (this.isFailFast()) { throw new FailFastAssertionException(error); } } - public void setErrors(List errors) { + public void setErrors(List errors) { this.errors = errors; } } diff --git a/src/main/java/com/networknt/schema/FailFastAssertionException.java b/src/main/java/com/networknt/schema/FailFastAssertionException.java index 84f8f6e84..8185365d6 100644 --- a/src/main/java/com/networknt/schema/FailFastAssertionException.java +++ b/src/main/java/com/networknt/schema/FailFastAssertionException.java @@ -32,14 +32,14 @@ public class FailFastAssertionException extends RuntimeException { private static final long serialVersionUID = 1L; - private final ValidationMessage error; + private final Error error; /** * Constructor. * * @param error the validation message */ - public FailFastAssertionException(ValidationMessage error) { + public FailFastAssertionException(Error error) { this.error = Objects.requireNonNull(error); } @@ -48,7 +48,7 @@ public FailFastAssertionException(ValidationMessage error) { * * @return the validation message */ - public ValidationMessage getError() { + public Error getError() { return this.error; } @@ -57,7 +57,7 @@ public ValidationMessage getError() { * * @return the validation message */ - public List getErrors() { + public List getErrors() { return Collections.singletonList(this.error); } diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/FalseValidator.java index 9ae3bed6c..aa9e0f338 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/FalseValidator.java @@ -35,7 +35,7 @@ public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); // For the false validator, it is always not valid - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(reason).build()); } diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/Format.java index f1632c0f4..85fec7845 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/Format.java @@ -140,7 +140,7 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val */ default void validate(ExecutionContext executionContext, ValidationContext validationContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, - Supplier message, + Supplier message, FormatValidator formatValidator) { if (assertionsEnabled) { if (!matches(executionContext, validationContext, node, rootNode, instanceLocation, assertionsEnabled, diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/FormatValidator.java index 862107f50..314486665 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/FormatValidator.java @@ -69,7 +69,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode try { format.validate(executionContext, validationContext, node, rootNode, instanceLocation, assertionsEnabled, - () -> this.message().instanceNode(node).instanceLocation(instanceLocation) + () -> this.error().instanceNode(node).instanceLocation(instanceLocation) .messageKey(format.getMessageKey()) .locale(executionContext.getExecutionConfig().getLocale()) , @@ -99,7 +99,7 @@ protected void validateUnknownFormat(ExecutionContext executionContext, * according to the specification. */ if (createUnknownFormatAssertions(executionContext) && this.schemaNode.isTextual()) { - executionContext.addError(message().instanceLocation(instanceLocation).instanceNode(node) + executionContext.addError(error().instanceLocation(instanceLocation).instanceNode(node) .messageKey("format.unknown").arguments(schemaNode.textValue()).build()); } } diff --git a/src/main/java/com/networknt/schema/IfValidator.java b/src/main/java/com/networknt/schema/IfValidator.java index 5a4bfb2e5..117163ebe 100644 --- a/src/main/java/com/networknt/schema/IfValidator.java +++ b/src/main/java/com/networknt/schema/IfValidator.java @@ -71,8 +71,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - List existingErrors = executionContext.getErrors(); - List test = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List test = new ArrayList<>(); executionContext.setErrors(test); try { executionContext.setFailFast(false); @@ -111,8 +111,8 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - List existingErrors = executionContext.getErrors(); - List test = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List test = new ArrayList<>(); executionContext.setErrors(test); try { executionContext.setFailFast(false); diff --git a/src/main/java/com/networknt/schema/InvalidSchemaException.java b/src/main/java/com/networknt/schema/InvalidSchemaException.java index e60a34811..788b0fe9a 100644 --- a/src/main/java/com/networknt/schema/InvalidSchemaException.java +++ b/src/main/java/com/networknt/schema/InvalidSchemaException.java @@ -24,12 +24,12 @@ public class InvalidSchemaException extends JsonSchemaException { private static final long serialVersionUID = 1L; - public InvalidSchemaException(ValidationMessage message, Exception cause) { + public InvalidSchemaException(Error message, Exception cause) { super(Objects.requireNonNull(message)); this.initCause(cause); } - public InvalidSchemaException(ValidationMessage message) { + public InvalidSchemaException(Error message) { super(Objects.requireNonNull(message)); } } diff --git a/src/main/java/com/networknt/schema/InvalidSchemaRefException.java b/src/main/java/com/networknt/schema/InvalidSchemaRefException.java index 9aad3a5c6..adb655718 100644 --- a/src/main/java/com/networknt/schema/InvalidSchemaRefException.java +++ b/src/main/java/com/networknt/schema/InvalidSchemaRefException.java @@ -22,11 +22,11 @@ public class InvalidSchemaRefException extends InvalidSchemaException { private static final long serialVersionUID = 1L; - public InvalidSchemaRefException(ValidationMessage message, Exception cause) { + public InvalidSchemaRefException(Error message, Exception cause) { super(message, cause); } - public InvalidSchemaRefException(ValidationMessage message) { + public InvalidSchemaRefException(Error message) { super(message); } } diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/ItemsValidator.java index d8d3de0d5..00c99c081 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/ItemsValidator.java @@ -175,7 +175,7 @@ private boolean doValidate(ExecutionContext executionContext, int i, JsonNode no // evaluatedItems.add(path); } else { // no additional item allowed, return error - executionContext.addError(message().instanceNode(rootNode).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(rootNode).instanceLocation(instanceLocation) .keyword("additionalItems") .messageKey("additionalItems") .evaluationPath(this.additionalItemsEvaluationPath) diff --git a/src/main/java/com/networknt/schema/ItemsValidator202012.java b/src/main/java/com/networknt/schema/ItemsValidator202012.java index 7f4e22b40..d115a8a18 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/ItemsValidator202012.java @@ -76,7 +76,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // This handles the case where "items": false as the boolean false schema doesn't // generate a helpful message int x = i; - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .index(x).arguments(x).build()); } diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index 29e5a40b5..110ed9a83 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -283,10 +283,10 @@ public JsonMetaSchema build() { keywords.put(keyword.getValue(), keyword); } } else if (Boolean.TRUE.equals(entry.getValue())) { - ValidationMessage validationMessage = ValidationMessage.builder() + Error error = Error.builder() .message("Meta-schema ''{0}'' has unknown required vocabulary ''{1}''") .arguments(this.iri, id).build(); - throw new InvalidSchemaException(validationMessage); + throw new InvalidSchemaException(error); } } } diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index 9dada8962..5fcf49417 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -184,7 +184,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc if (validator != null) { if (!validator.validate(id, rootSchema, schemaLocation, result, validationContext)) { SchemaLocation idSchemaLocation = schemaLocation.append(validationContext.getMetaSchema().getIdKeyword()); - ValidationMessage validationMessage = ValidationMessage.builder() + Error error = Error.builder() .messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) .arguments(id, validationContext.getMetaSchema().getIdKeyword(), idSchemaLocation) @@ -193,7 +193,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc .messageFormatter(args -> validationContext.getConfig().getMessageSource().getMessage( ValidatorTypeCode.ID.getValue(), validationContext.getConfig().getLocale(), args)) .build(); - throw new InvalidSchemaException(validationMessage); + throw new InvalidSchemaException(error); } } return result; @@ -286,7 +286,6 @@ protected JsonSchema( boolean suppressSubSchemaRetrieval, JsonNode schemaNode, ValidationContext validationContext, - /* Below from ValidationMessageHandler */ JsonSchema parentSchema, SchemaLocation schemaLocation, JsonNodePath evaluationPath, @@ -345,7 +344,6 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref suppressSubSchemaRetrieval, schemaNode, validationContext, - /* Below from ValidationMessageHandler */ parentSchema, schemaLocation, evaluationPath, evaluationParentSchema, /* errorMessage */ null); } @@ -378,7 +376,6 @@ public JsonSchema withConfig(SchemaValidatorsConfig config) { suppressSubSchemaRetrieval, schemaNode, validationContext, - /* Below from ValidationMessageHandler */ parentSchema, schemaLocation, evaluationPath, @@ -508,14 +505,14 @@ public JsonSchema getSubSchema(JsonNodePath fragment) { found = found.getSubSchema(fragment); } if (found == null) { - ValidationMessage validationMessage = ValidationMessage.builder() + Error error = Error.builder() .keyword(ValidatorTypeCode.REF.getValue()).messageKey("internal.unresolvedRef") .message("Reference {0} cannot be resolved") .instanceLocation(schemaLocation.getFragment()) .schemaLocation(schemaLocation) .evaluationPath(evaluationPath) .arguments(fragment).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } return found; } @@ -627,7 +624,7 @@ private List read(JsonNode schemaNode) { if ("$recursiveAnchor".equals(pname)) { if (!nodeToUse.isBoolean()) { - ValidationMessage validationMessage = ValidationMessage.builder().keyword("$recursiveAnchor") + Error error = Error.builder().keyword("$recursiveAnchor") .messageKey("internal.invalidRecursiveAnchor") .message( "The value of a $recursiveAnchor must be a Boolean literal but is {0}") @@ -636,7 +633,7 @@ private List read(JsonNode schemaNode) { .schemaLocation(schemaPath) .arguments(nodeToUse.getNodeType().toString()) .build(); - throw new JsonSchemaException(validationMessage); + throw new JsonSchemaException(error); } this.recursiveAnchor = nodeToUse.booleanValue(); } @@ -760,10 +757,10 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN * the default. * * @param rootNode the root node - * @return A list of ValidationMessage if there is any validation error, or an + * @return A list of Error if there is any validation error, or an * empty list if there is no error. */ - public List validate(JsonNode rootNode) { + public List validate(JsonNode rootNode) { return validate(rootNode, OutputFormat.DEFAULT); } @@ -780,7 +777,7 @@ public List validate(JsonNode rootNode) { * @param executionCustomizer the execution customizer * @return the assertions */ - public List validate(JsonNode rootNode, ExecutionContextCustomizer executionCustomizer) { + public List validate(JsonNode rootNode, ExecutionContextCustomizer executionCustomizer) { return validate(rootNode, OutputFormat.DEFAULT, executionCustomizer); } @@ -797,7 +794,7 @@ public List validate(JsonNode rootNode, ExecutionContextCusto * @param executionCustomizer the execution customizer * @return the assertions */ - public List validate(JsonNode rootNode, Consumer executionCustomizer) { + public List validate(JsonNode rootNode, Consumer executionCustomizer) { return validate(rootNode, OutputFormat.DEFAULT, executionCustomizer); } @@ -872,10 +869,10 @@ public T validate(JsonNode rootNode, OutputFormat format, Consumer validate(String input, InputFormat inputFormat) { + public List validate(String input, InputFormat inputFormat) { return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT); } @@ -894,7 +891,7 @@ public List validate(String input, InputFormat inputFormat) { * @param executionCustomizer the execution customizer * @return the assertions */ - public List validate(String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer) { + public List validate(String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer) { return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); } @@ -913,7 +910,7 @@ public List validate(String input, InputFormat inputFormat, E * @param executionCustomizer the execution customizer * @return the assertions */ - public List validate(String input, InputFormat inputFormat, Consumer executionCustomizer) { + public List validate(String input, InputFormat inputFormat, Consumer executionCustomizer) { return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); } diff --git a/src/main/java/com/networknt/schema/JsonSchemaException.java b/src/main/java/com/networknt/schema/JsonSchemaException.java index 1add66f77..47a76c86b 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaException.java +++ b/src/main/java/com/networknt/schema/JsonSchemaException.java @@ -24,9 +24,9 @@ */ public class JsonSchemaException extends RuntimeException { private static final long serialVersionUID = -7805792737596582110L; - private final ValidationMessage error; + private final Error error; - public JsonSchemaException(ValidationMessage error) { + public JsonSchemaException(Error error) { this.error = error; } @@ -45,11 +45,11 @@ public String getMessage() { return this.error != null ? this.error.getMessage() : super.getMessage(); } - public ValidationMessage getError() { + public Error getError() { return this.error; } - public List getErrors() { + public List getErrors() { if (error == null) { return Collections.emptyList(); } diff --git a/src/main/java/com/networknt/schema/MaxItemsValidator.java b/src/main/java/com/networknt/schema/MaxItemsValidator.java index 6bba3618a..741d9d682 100644 --- a/src/main/java/com/networknt/schema/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/MaxItemsValidator.java @@ -43,13 +43,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.isArray()) { if (node.size() > this.max) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.max, node.size()).build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 > this.max) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.max, 1).build()); } diff --git a/src/main/java/com/networknt/schema/MaxLengthValidator.java b/src/main/java/com/networknt/schema/MaxLengthValidator.java index 7a5ba2d46..a144df836 100644 --- a/src/main/java/com/networknt/schema/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/MaxLengthValidator.java @@ -46,7 +46,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode return; } if (node.textValue().codePointCount(0, node.textValue().length()) > this.maxLength) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.maxLength).build()); } diff --git a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java index 73908e5fe..44da54001 100644 --- a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java @@ -43,7 +43,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.isObject()) { if (node.size() > max) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(max).build()); } diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/MaximumValidator.java index 4fb6d31af..e5be2dcb3 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/MaximumValidator.java @@ -116,7 +116,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (this.typedMaximum.crossesThreshold(node)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.typedMaximum.thresholdValue()).build()); } diff --git a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java b/src/main/java/com/networknt/schema/MessageSourceError.java similarity index 90% rename from src/main/java/com/networknt/schema/MessageSourceValidationMessage.java rename to src/main/java/com/networknt/schema/MessageSourceError.java index 73111f0f2..eb8ca652a 100644 --- a/src/main/java/com/networknt/schema/MessageSourceValidationMessage.java +++ b/src/main/java/com/networknt/schema/MessageSourceError.java @@ -21,9 +21,9 @@ import com.networknt.schema.i18n.MessageSource; /** - * MessageSourceValidationMessage. + * MessageSourceError. */ -public class MessageSourceValidationMessage { +public class MessageSourceError { public static Builder builder(MessageSource messageSource, Map errorMessage) { return new Builder(messageSource, errorMessage); @@ -40,7 +40,7 @@ public Builder self() { } } - public abstract static class BuilderSupport extends ValidationMessage.BuilderSupport { + public abstract static class BuilderSupport extends Error.BuilderSupport { private final MessageSource messageSource; private final Map errorMessage; private Locale locale; @@ -51,7 +51,7 @@ public BuilderSupport(MessageSource messageSource, Map errorMess } @Override - public ValidationMessage build() { + public Error build() { // Use custom error message if present String messagePattern = null; if (this.errorMessage != null) { diff --git a/src/main/java/com/networknt/schema/MinItemsValidator.java b/src/main/java/com/networknt/schema/MinItemsValidator.java index a242f4f20..54fb1a0ca 100644 --- a/src/main/java/com/networknt/schema/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/MinItemsValidator.java @@ -40,14 +40,14 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.isArray()) { if (node.size() < min) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(min, node.size()) .build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 < min) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(min, 1).build()); } diff --git a/src/main/java/com/networknt/schema/MinLengthValidator.java b/src/main/java/com/networknt/schema/MinLengthValidator.java index a61a25173..e8bfefb96 100644 --- a/src/main/java/com/networknt/schema/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/MinLengthValidator.java @@ -46,7 +46,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (node.textValue().codePointCount(0, node.textValue().length()) < minLength) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(minLength).build()); } diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java index b4601a572..05ae19e23 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java @@ -61,7 +61,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonNodePath instanceLocation) { if (this.analysis != null) { this.analysis.stream() - .map(analysis -> message().instanceNode(node) + .map(analysis -> error().instanceNode(node) .instanceLocation(instanceLocation) .messageKey(analysis.getMessageKey()).locale(executionContext.getExecutionConfig().getLocale()) .keyword(analysis.getMessageKey()) diff --git a/src/main/java/com/networknt/schema/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/MinPropertiesValidator.java index dca27d602..6aa221bbb 100644 --- a/src/main/java/com/networknt/schema/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MinPropertiesValidator.java @@ -43,7 +43,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (node.isObject()) { if (node.size() < min) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(min).build()); } diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/MinimumValidator.java index 9c2ff800c..078988dc0 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/MinimumValidator.java @@ -123,7 +123,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (this.typedMinimum.crossesThreshold(node)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.typedMinimum.thresholdValue()).build()); } diff --git a/src/main/java/com/networknt/schema/MultipleOfValidator.java b/src/main/java/com/networknt/schema/MultipleOfValidator.java index 1b46c2a5e..e5e95ae27 100644 --- a/src/main/java/com/networknt/schema/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/MultipleOfValidator.java @@ -45,7 +45,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode BigDecimal dividend = getDividend(node); if (dividend != null) { if (dividend.divideAndRemainder(this.divisor)[1].abs().compareTo(BigDecimal.ZERO) > 0) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.divisor) .build()); diff --git a/src/main/java/com/networknt/schema/NotAllowedValidator.java b/src/main/java/com/networknt/schema/NotAllowedValidator.java index ec4b469a6..7fd3323e2 100644 --- a/src/main/java/com/networknt/schema/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/NotAllowedValidator.java @@ -50,7 +50,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonNode propertyNode = node.get(fieldName); if (propertyNode != null) { - executionContext.addError(message().property(fieldName).instanceNode(node) + executionContext.addError(error().property(fieldName).instanceNode(node) .instanceLocation(instanceLocation.append(fieldName)) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(fieldName).build()); diff --git a/src/main/java/com/networknt/schema/NotValidator.java b/src/main/java/com/networknt/schema/NotValidator.java index a564a05d8..72cc61169 100644 --- a/src/main/java/com/networknt/schema/NotValidator.java +++ b/src/main/java/com/networknt/schema/NotValidator.java @@ -49,8 +49,8 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - List existingErrors = executionContext.getErrors(); - List test = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List test = new ArrayList<>(); executionContext.setErrors(test); try { executionContext.setFailFast(false); @@ -65,7 +65,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo executionContext.setErrors(existingErrors); } if (test.isEmpty()) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.schema.toString()) .build()); diff --git a/src/main/java/com/networknt/schema/OneOfValidator.java b/src/main/java/com/networknt/schema/OneOfValidator.java index 65be57bca..81d92b832 100644 --- a/src/main/java/com/networknt/schema/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/OneOfValidator.java @@ -39,7 +39,7 @@ public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ONE_OF, validationContext); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); - throw new JsonSchemaException(message().instanceNode(schemaNode) + throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") @@ -65,9 +65,9 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo int numberOfValidSchema = 0; int index = 0; List indexes = null; - List existingErrors = executionContext.getErrors(); - List childErrors = null; - List schemaErrors = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List childErrors = null; + List schemaErrors = new ArrayList<>(); executionContext.setErrors(schemaErrors); // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); @@ -164,7 +164,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorMatchFound() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { addMessages = false; - existingErrors.add(message().instanceNode(node).instanceLocation(instanceLocation) + existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments( "based on the provided discriminator. No alternative could be chosen based on the discriminator property") @@ -183,7 +183,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo // is not equal to 1. // errors will only not be null in the discriminator case where no match is found if (numberOfValidSchema != 1 && addMessages) { - ValidationMessage message = message().instanceNode(node).instanceLocation(instanceLocation) + Error message = error().instanceNode(node).instanceLocation(instanceLocation) .messageKey(numberOfValidSchema > 1 ? "oneOf.indexes" : "oneOf") .locale(executionContext.getExecutionConfig().getLocale()) .arguments(Integer.toString(numberOfValidSchema), numberOfValidSchema > 1 ? String.join(", ", indexes) : "").build(); diff --git a/src/main/java/com/networknt/schema/OutputFormat.java b/src/main/java/com/networknt/schema/OutputFormat.java index 93d1da44e..fd1ef5edc 100644 --- a/src/main/java/com/networknt/schema/OutputFormat.java +++ b/src/main/java/com/networknt/schema/OutputFormat.java @@ -88,14 +88,14 @@ T format(JsonSchema jsonSchema, /** * The Default output format. */ - class Default implements OutputFormat> { + class Default implements OutputFormat> { @Override public void customize(ExecutionContext executionContext, ValidationContext validationContext) { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(false); } @Override - public java.util.List format(JsonSchema jsonSchema, + public java.util.List format(JsonSchema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return executionContext.getErrors(); } @@ -139,19 +139,19 @@ public java.lang.Boolean format(JsonSchema jsonSchema, * The List output format. */ class List implements OutputFormat { - private final Function assertionMapper; + private final Function errorMapper; public List() { - this(OutputUnitData::formatAssertion); + this(OutputUnitData::formatError); } /** * Constructor. * - * @param assertionMapper to map the assertion + * @param errorMapper to map the error */ - public List(Function assertionMapper) { - this.assertionMapper = assertionMapper; + public List(Function errorMapper) { + this.errorMapper = errorMapper; } @Override @@ -162,7 +162,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid public OutputUnit format(JsonSchema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return ListOutputUnitFormatter.format(executionContext.getErrors(), executionContext, validationContext, - this.assertionMapper); + this.errorMapper); } } @@ -170,19 +170,19 @@ public OutputUnit format(JsonSchema jsonSchema, * The Hierarchical output format. */ class Hierarchical implements OutputFormat { - private final Function assertionMapper; + private final Function errorMapper; public Hierarchical() { - this(OutputUnitData::formatAssertion); + this(OutputUnitData::formatError); } /** * Constructor. * - * @param assertionMapper to map the assertion + * @param errorMapper to map the error */ - public Hierarchical(Function assertionMapper) { - this.assertionMapper = assertionMapper; + public Hierarchical(Function errorMapper) { + this.errorMapper = errorMapper; } @Override @@ -193,7 +193,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid public OutputUnit format(JsonSchema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return HierarchicalOutputUnitFormatter.format(jsonSchema, executionContext.getErrors(), executionContext, - validationContext, this.assertionMapper); + validationContext, this.errorMapper); } } diff --git a/src/main/java/com/networknt/schema/PatternValidator.java b/src/main/java/com/networknt/schema/PatternValidator.java index 559748c5e..dbf1f8fe1 100644 --- a/src/main/java/com/networknt/schema/PatternValidator.java +++ b/src/main/java/com/networknt/schema/PatternValidator.java @@ -56,7 +56,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode try { if (!matches(node.asText())) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.pattern).build()); return; diff --git a/src/main/java/com/networknt/schema/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/PropertyNamesValidator.java index b859f190b..374ff323f 100644 --- a/src/main/java/com/networknt/schema/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/PropertyNamesValidator.java @@ -36,21 +36,21 @@ public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evalua public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); - List existingErrors = executionContext.getErrors(); - List schemaErrors = new ArrayList<>(); + List existingErrors = executionContext.getErrors(); + List schemaErrors = new ArrayList<>(); executionContext.setErrors(schemaErrors); for (Iterator it = node.fieldNames(); it.hasNext(); ) { final String pname = it.next(); final TextNode pnameText = TextNode.valueOf(pname); innerSchema.validate(executionContext, pnameText, node, instanceLocation.append(pname)); - for (final ValidationMessage schemaError : schemaErrors) { + for (final Error schemaError : schemaErrors) { final String path = schemaError.getInstanceLocation().toString(); String msg = schemaError.getMessage(); if (msg.startsWith(path)) { msg = msg.substring(path.length()).replaceFirst("^:\\s*", ""); } existingErrors.add( - message().property(pname).instanceNode(node).instanceLocation(instanceLocation) + error().property(pname).instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(pname, msg).build()); } diff --git a/src/main/java/com/networknt/schema/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/ReadOnlyValidator.java index 725b0652a..9895c57cf 100644 --- a/src/main/java/com/networknt/schema/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/ReadOnlyValidator.java @@ -40,7 +40,7 @@ public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); if (this.readOnly) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .build()); } diff --git a/src/main/java/com/networknt/schema/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/RecursiveRefValidator.java index 594af0a6c..a7f8cf009 100644 --- a/src/main/java/com/networknt/schema/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/RecursiveRefValidator.java @@ -35,12 +35,12 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat String refValue = schemaNode.asText(); if (!"#".equals(refValue)) { - ValidationMessage validationMessage = message() + Error error = error() .keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()).messageKey("internal.invalidRecursiveRef") .message("The value of a $recursiveRef must be '#' but is '{0}'").instanceLocation(schemaLocation.getFragment()) .instanceNode(this.schemaNode) .evaluationPath(evaluationPath).arguments(refValue).build(); - throw new JsonSchemaException(validationMessage); + throw new JsonSchemaException(error); } this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } @@ -89,11 +89,11 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } refSchema.validate(executionContext, node, rootNode, instanceLocation); } @@ -106,11 +106,11 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } if (node == null) { // Check for circular dependency diff --git a/src/main/java/com/networknt/schema/RefValidator.java b/src/main/java/com/networknt/schema/RefValidator.java index 5042f796c..bdc8b614b 100644 --- a/src/main/java/com/networknt/schema/RefValidator.java +++ b/src/main/java/com/networknt/schema/RefValidator.java @@ -178,11 +178,11 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode debug(logger, executionContext, node, rootNode, instanceLocation); JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } refSchema.validate(executionContext, node, rootNode, instanceLocation); } @@ -195,11 +195,11 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. JsonSchema refSchema = this.schema.getSchema(); if (refSchema == null) { - ValidationMessage validationMessage = message().keyword(ValidatorTypeCode.REF.getValue()) + Error error = error().keyword(ValidatorTypeCode.REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); - throw new InvalidSchemaRefException(validationMessage); + throw new InvalidSchemaRefException(error); } if (node == null) { // Check for circular dependency diff --git a/src/main/java/com/networknt/schema/RequiredValidator.java b/src/main/java/com/networknt/schema/RequiredValidator.java index d1852c81b..a1509e1f5 100644 --- a/src/main/java/com/networknt/schema/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/RequiredValidator.java @@ -71,7 +71,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode *

* @see Basic */ - executionContext.addError(message().instanceNode(node).property(fieldName).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).property(fieldName).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(fieldName).build()); } diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java index a08f7abed..121ca7c5f 100644 --- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java +++ b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java @@ -608,7 +608,7 @@ public void setExecutionContextCustomizer(ExecutionContextCustomizer executionCo /** * When enabled, * {@link JsonValidator#validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)} - * doesn't return any {@link java.util.Set}<{@link ValidationMessage}>, + * doesn't return any {@link java.util.Set}<{@link Error}>, * instead a {@link JsonSchemaException} is thrown as soon as a validation * errors is discovered. * diff --git a/src/main/java/com/networknt/schema/TrueValidator.java b/src/main/java/com/networknt/schema/TrueValidator.java index 0c02cbb85..c1dde192e 100644 --- a/src/main/java/com/networknt/schema/TrueValidator.java +++ b/src/main/java/com/networknt/schema/TrueValidator.java @@ -31,6 +31,6 @@ public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); - // For the true validator, it is always valid which means there is no ValidationMessage. + // For the true validator, it is always valid which means there is no Error. } } diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/TypeValidator.java index 7ce61c6be..fcdb866c8 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/TypeValidator.java @@ -59,7 +59,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!equalsToSchemaType(node)) { JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(nodeType.toString(), this.schemaType.toString()).build()); } diff --git a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java index 34bb37c2c..22ea92cbf 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java @@ -174,7 +174,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!containsEvaluated.contains(x)) { if (this.schemaNode.isBoolean() && this.schemaNode.booleanValue() == false) { // All fails as "unevaluatedItems: false" - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation).arguments(x) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation).arguments(x) .locale(executionContext.getExecutionConfig().getLocale()) .build()); } else { diff --git a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java index 6af91d158..ebadd5889 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java @@ -116,7 +116,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode evaluatedProperties.add(fieldName); if (this.schemaNode.isBoolean() && this.schemaNode.booleanValue() == false) { // All fails as "unevaluatedProperties: false" - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation).property(fieldName) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation).property(fieldName) .arguments(fieldName).locale(executionContext.getExecutionConfig().getLocale()) .build()); } else { diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index e1ade7dc1..04ca3df9b 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -74,9 +74,9 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - List existingErrors = executionContext.getErrors(); + List existingErrors = executionContext.getErrors(); try { - List test = new ArrayList<>(); + List test = new ArrayList<>(); executionContext.setFailFast(false); executionContext.setErrors(test); for (JsonSchemaValidator schema : schemas) { @@ -95,7 +95,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (!valid) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .keyword("type") .locale(executionContext.getExecutionConfig().getLocale()) .arguments(nodeType.toString(), error) diff --git a/src/main/java/com/networknt/schema/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/UniqueItemsValidator.java index 496f0cb81..93e8fb21d 100644 --- a/src/main/java/com/networknt/schema/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/UniqueItemsValidator.java @@ -47,7 +47,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode Set set = new HashSet<>(); for (JsonNode n : node) { if (!set.add(n)) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .build()); } diff --git a/src/main/java/com/networknt/schema/ValidationResult.java b/src/main/java/com/networknt/schema/ValidationResult.java index 5495fedb1..fe6ded59f 100644 --- a/src/main/java/com/networknt/schema/ValidationResult.java +++ b/src/main/java/com/networknt/schema/ValidationResult.java @@ -28,7 +28,7 @@ public ValidationResult(ExecutionContext executionContext) { this.executionContext = executionContext; } - public List getValidationMessages() { + public List getErrors() { return getExecutionContext().getErrors(); } diff --git a/src/main/java/com/networknt/schema/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/WriteOnlyValidator.java index d5f9c4c9f..0592abdb6 100644 --- a/src/main/java/com/networknt/schema/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/WriteOnlyValidator.java @@ -24,7 +24,7 @@ public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluation public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); if (this.writeOnly) { - executionContext.addError(message().instanceNode(node).instanceLocation(instanceLocation) + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .build()); } diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index eea8d67d6..a197e7aee 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -30,7 +30,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.ValidationContext; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * HierarchicalOutputUnitFormatter. @@ -108,17 +108,17 @@ public static OutputUnit format(OutputUnit root, OutputUnitData data, JsonNodePa return root; } - public static OutputUnit format(JsonSchema jsonSchema, List validationMessages, + public static OutputUnit format(JsonSchema jsonSchema, List errors, ExecutionContext executionContext, ValidationContext validationContext, - Function assertionMapper) { + Function errorMapper) { OutputUnit root = new OutputUnit(); - root.setValid(validationMessages.isEmpty()); + root.setValid(errors.isEmpty()); root.setInstanceLocation(validationContext.getConfig().getPathType().getRoot()); root.setEvaluationPath(validationContext.getConfig().getPathType().getRoot()); root.setSchemaLocation(jsonSchema.getSchemaLocation().toString()); - OutputUnitData data = OutputUnitData.from(validationMessages, executionContext, assertionMapper); + OutputUnitData data = OutputUnitData.from(errors, executionContext, errorMapper); return format(root, data, new JsonNodePath(validationContext.getConfig().getPathType())); } diff --git a/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java index 44bb20260..eb5574cd3 100644 --- a/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java @@ -24,7 +24,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.ValidationContext; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * ListOutputUnitFormatter. @@ -90,10 +90,10 @@ public static OutputUnit format(OutputUnit root, OutputUnitData data) { return root; } - public static OutputUnit format(List validationMessages, ExecutionContext executionContext, - ValidationContext validationContext, Function assertionMapper) { + public static OutputUnit format(List errors, ExecutionContext executionContext, + ValidationContext validationContext, Function errorMapper) { OutputUnit root = new OutputUnit(); - root.setValid(validationMessages.isEmpty()); - return format(root, OutputUnitData.from(validationMessages, executionContext, assertionMapper)); + root.setValid(errors.isEmpty()); + return format(root, OutputUnitData.from(errors, executionContext, errorMapper)); } } diff --git a/src/main/java/com/networknt/schema/output/OutputUnitData.java b/src/main/java/com/networknt/schema/output/OutputUnitData.java index 9398d4f53..76b7c0881 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitData.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitData.java @@ -23,7 +23,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import com.networknt.schema.annotation.JsonNodeAnnotation; /** @@ -51,29 +51,13 @@ public Map> getDroppedAnnotations() { return droppedAnnotations; } - public static String formatAssertion(ValidationMessage validationMessage) { - return formatMessage(validationMessage.getMessage()); - } - - public static String formatMessage(String message) { - int index = message.indexOf(':'); - if (index != -1) { - int length = message.length(); - while (index + 1 < length) { - if (message.charAt(index + 1) == ' ') { - index++; - } else { - break; - } - } - return message.substring(index + 1); - } - return message; + public static String formatError(Error error) { + return error.getMessage(); } @SuppressWarnings("unchecked") - public static OutputUnitData from(List validationMessages, ExecutionContext executionContext, - Function assertionMapper) { + public static OutputUnitData from(List validationErrors, ExecutionContext executionContext, + Function errorMapper) { OutputUnitData data = new OutputUnitData(); Map valid = data.valid; @@ -81,25 +65,25 @@ public static OutputUnitData from(List validationMessages, Ex Map> annotations = data.annotations; Map> droppedAnnotations = data.droppedAnnotations; - for (ValidationMessage assertion : validationMessages) { - SchemaLocation assertionSchemaLocation = new SchemaLocation(assertion.getSchemaLocation().getAbsoluteIri(), - assertion.getSchemaLocation().getFragment().getParent()); - OutputUnitKey key = new OutputUnitKey(assertion.getEvaluationPath().getParent(), - assertionSchemaLocation, assertion.getInstanceLocation()); + for (Error error : validationErrors) { + SchemaLocation assertionSchemaLocation = new SchemaLocation(error.getSchemaLocation().getAbsoluteIri(), + error.getSchemaLocation().getFragment().getParent()); + OutputUnitKey key = new OutputUnitKey(error.getEvaluationPath().getParent(), + assertionSchemaLocation, error.getInstanceLocation()); valid.put(key, false); Map errorMap = errors.computeIfAbsent(key, k -> new LinkedHashMap<>()); - Object value = errorMap.get(assertion.getKeyword()); + Object value = errorMap.get(error.getKeyword()); if (value == null) { - errorMap.put(assertion.getKeyword(), assertionMapper.apply(assertion)); + errorMap.put(error.getKeyword(), errorMapper.apply(error)); } else { // Existing error, make it into a list if (value instanceof List) { - ((List) value).add(assertionMapper.apply(assertion)); + ((List) value).add(errorMapper.apply(error)); } else { List values = new ArrayList<>(); values.add(value.toString()); - values.add(assertionMapper.apply(assertion)); - errorMap.put(assertion.getKeyword(), values); + values.add(errorMapper.apply(error)); + errorMap.put(error.getKeyword(), values); } } } diff --git a/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java b/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java index afe688a75..333273e33 100644 --- a/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java +++ b/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java @@ -18,7 +18,7 @@ import java.util.function.Predicate; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * {@link RegularExpressionFactory} that allows regular expressions to be used. @@ -38,7 +38,7 @@ public RegularExpression getRegularExpression(String regex) { // Allowed to delegate return this.delegate.getRegularExpression(regex); } - throw new InvalidSchemaException(ValidationMessage.builder() + throw new InvalidSchemaException(Error.builder() .message("Regular expression ''{0}'' is not allowed to be used.").arguments(regex).build()); } } diff --git a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java index 0f396901a..3580771de 100644 --- a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java @@ -19,7 +19,7 @@ import com.networknt.schema.AbsoluteIri; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * {@link SchemaLoader} that allows loading external resources. @@ -43,7 +43,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { // Allow to delegate to the next schema loader return null; } - throw new InvalidSchemaException(ValidationMessage.builder() + throw new InvalidSchemaException(Error.builder() .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); } } diff --git a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java index 89eeafa5b..b07118192 100644 --- a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java @@ -17,7 +17,7 @@ import com.networknt.schema.AbsoluteIri; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * {@link SchemaLoader} that disallows loading external resources. @@ -42,7 +42,7 @@ private DisallowSchemaLoader() { @Override public InputStreamSource getSchema(AbsoluteIri absoluteIri) { - throw new InvalidSchemaException(ValidationMessage.builder() + throw new InvalidSchemaException(Error.builder() .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); } } diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index cb0d197a9..941d86157 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -5,7 +5,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonValidator; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import java.util.List; @@ -35,10 +35,10 @@ protected boolean runPreWalkListeners(List walkListeners } protected void runPostWalkListeners(List walkListeners, WalkEvent walkEvent, - List validationMessages) { + List errors) { if (walkListeners != null) { for (JsonSchemaWalkListener walkListener : walkListeners) { - walkListener.onWalkEnd(walkEvent, validationMessages); + walkListener.onWalkEnd(walkEvent, errors); } } } diff --git a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java index 6d0e3d865..8c0f529ca 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java @@ -5,7 +5,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonValidator; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import java.util.List; @@ -27,10 +27,10 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List validationMessages) { + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - runPostWalkListeners(itemWalkListeners, walkEvent, validationMessages); + runPostWalkListeners(itemWalkListeners, walkEvent, errors); } } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java index 6f3692f51..8d93384a2 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java @@ -1,11 +1,16 @@ package com.networknt.schema.walk; -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.*; - import java.util.List; import java.util.Map; +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonValidator; +import com.networknt.schema.SchemaValidatorsConfig; + public class DefaultKeywordWalkListenerRunner extends AbstractWalkListenerRunner { private final Map> keywordWalkListenersMap; @@ -32,16 +37,16 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key } @Override - public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, JsonNodePath instanceLocation, - JsonSchema schema, JsonValidator validator, List validationMessages) { + public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, + List errors) { WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); // Run Listeners that are setup only for this keyword. List currentKeywordListeners = keywordWalkListenersMap.get(keyword); - runPostWalkListeners(currentKeywordListeners, keywordWalkEvent, validationMessages); + runPostWalkListeners(currentKeywordListeners, keywordWalkEvent, errors); // Run Listeners that are setup for all keywords. List allKeywordListeners = keywordWalkListenersMap .get(SchemaValidatorsConfig.ALL_KEYWORD_WALK_LISTENER_KEY); - runPostWalkListeners(allKeywordListeners, keywordWalkEvent, validationMessages); + runPostWalkListeners(allKeywordListeners, keywordWalkEvent, errors); } - } diff --git a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java index 7acdc407d..0f4cc054e 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java @@ -5,7 +5,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonValidator; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import java.util.List; @@ -26,9 +26,9 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, JsonNodePath instanceLocation, - JsonSchema schema, JsonValidator validator, List validationMessages) { + JsonSchema schema, JsonValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - runPostWalkListeners(propertyWalkListeners, walkEvent, validationMessages); + runPostWalkListeners(propertyWalkListeners, walkEvent, errors); } diff --git a/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java b/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java index a93c49367..9d18261c9 100644 --- a/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java +++ b/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java @@ -1,6 +1,6 @@ package com.networknt.schema.walk; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import java.util.List; @@ -13,5 +13,5 @@ public interface JsonSchemaWalkListener { WalkFlow onWalkStart(WalkEvent walkEvent); - void onWalkEnd(WalkEvent walkEvent, List validationMessages); + void onWalkEnd(WalkEvent walkEvent, List errors); } diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index 4a0ef3dcf..424c70d0c 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -5,7 +5,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonValidator; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import java.util.List; @@ -15,6 +15,6 @@ boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, J JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator); void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List errors); + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List errors); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 8d226fabb..2241bd77f 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -24,16 +24,16 @@ abstract class AbstractJsonSchemaTest { private static final SpecVersion.VersionFlag DEFAULT_VERSION_FLAG = SpecVersion.VersionFlag.V202012; private static final String ASSERT_MSG_KEYWORD = "Validation result should contain {0} keyword"; - protected List validate(String dataPath) { + protected List validate(String dataPath) { JsonNode dataNode = getJsonNodeFromPath(dataPath); return getJsonSchemaFromDataNode(dataNode).validate(dataNode); } protected void assertValidatorType(String filename, ValidatorTypeCode validatorTypeCode) { - List validationMessages = validate(getDataTestFolder() + filename); + List errors = validate(getDataTestFolder() + filename); assertTrue( - validationMessages.stream().anyMatch(vm -> validatorTypeCode.getValue().equals(vm.getKeyword())), + errors.stream().anyMatch(vm -> validatorTypeCode.getValue().equals(vm.getKeyword())), () -> MessageFormat.format(ASSERT_MSG_KEYWORD, validatorTypeCode.getValue())); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 632ee72ed..c46e1a9f5 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -55,7 +55,7 @@ private static String toForwardSlashPath(Path file) { } private static void executeTest(JsonSchema schema, TestSpec testSpec) { - List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, validationContext) -> { if (testSpec.getTestCase().getSource().getPath().getParent().toString().endsWith("format")) { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); } @@ -74,7 +74,7 @@ private static void executeTest(JsonSchema schema, TestSpec testSpec) { AssertionFailedError t = AssertionFailureBuilder.assertionFailure() .message(msg) - .reason(errors.stream().map(ValidationMessage::getMessage).collect(Collectors.joining("\n ", "\n errors:\n ", ""))) + .reason(errors.stream().map(Error::getMessage).collect(Collectors.joining("\n ", "\n errors:\n ", ""))) .build(); t.setStackTrace(new StackTraceElement[0]); throw t; @@ -103,7 +103,7 @@ private static void executeTest(JsonSchema schema, TestSpec testSpec) { Set actual = errors.stream() .map(error -> error.getInstanceLocation().toString() + ": " + error.getMessage()) .collect(Collectors.toSet()); - Set expected = testSpec.getValidationMessages(); + Set expected = testSpec.getErrors(); expected.removeAll(actual); if (!expected.isEmpty()) { String msg = new StringBuilder("Expected Validation Messages") diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 156c4e7ac..e22fd81b7 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -52,9 +52,9 @@ void messageFalse() { + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/additionalProperties", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/additionalProperties", message.getSchemaLocation().toString()); assertEquals("", message.getInstanceLocation().toString()); @@ -87,9 +87,9 @@ void messageSchema() { + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/additionalProperties/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/additionalProperties/type", message.getSchemaLocation().toString()); assertEquals("/bar", message.getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 3db78312b..164775c02 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -62,6 +62,6 @@ void walkValidationWithNullNodeShouldNotValidate() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); - assertEquals(true, result.getValidationMessages().isEmpty()); + assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index f230b2d7b..41e874780 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -62,6 +62,6 @@ void walkValidationWithNullNodeShouldNotValidate() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); - assertEquals(true, result.getValidationMessages().isEmpty()); + assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index a39e8d42f..3498a3bf9 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -54,10 +54,10 @@ void setup() throws Exception { @Test void testCollectorContextWithKeyword() throws Exception { ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); - Assertions.assertEquals(0, validationResult.getValidationMessages().size()); + Assertions.assertEquals(0, validationResult.getErrors().size()); List contextValues = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); contextValues.sort(null); - Assertions.assertEquals(0, validationResult.getValidationMessages().size()); + Assertions.assertEquals(0, validationResult.getErrors().size()); Assertions.assertEquals(2, contextValues.size()); Assertions.assertEquals(contextValues.get(0), "actual_value_added_to_context1"); Assertions.assertEquals(contextValues.get(1), "actual_value_added_to_context2"); @@ -90,9 +90,9 @@ void testCollectorContextWithMultipleThreads() throws Exception { ValidationResult validationResult2 = validationRunnable2.getValidationResult(); ValidationResult validationResult3 = validationRunnable3.getValidationResult(); - Assertions.assertEquals(0, validationResult1.getValidationMessages().size()); - Assertions.assertEquals(0, validationResult2.getValidationMessages().size()); - Assertions.assertEquals(0, validationResult3.getValidationMessages().size()); + Assertions.assertEquals(0, validationResult1.getErrors().size()); + Assertions.assertEquals(0, validationResult2.getErrors().size()); + Assertions.assertEquals(0, validationResult3.getErrors().size()); List contextValue1 = (List) validationResult1.getCollectorContext().get(SAMPLE_COLLECTOR); List contextValue2 = (List) validationResult2.getCollectorContext().get(SAMPLE_COLLECTOR); diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index aac9e5afe..39de1a33b 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -41,7 +41,7 @@ void localeMessageOthers() { .build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "\"bb\""; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); } @@ -55,7 +55,7 @@ void localeMessageNumber() { .build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "2"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); } @@ -67,7 +67,7 @@ void validOthers() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "\"aa\""; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -79,7 +79,7 @@ void validNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "1234.56789"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -91,7 +91,7 @@ void invalidNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); String inputData = "\"1234.56789\""; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 3d4d556b2..a48ea4b13 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -64,12 +64,12 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode throw new IllegalArgumentException("value not found in enum. value: " + value + " enum: " + enumValues); } String valueName = enumNames.get(idx); - ValidationMessage validationMessage = ValidationMessage.builder().keyword(keyword) + Error error = Error.builder().keyword(keyword) .schemaNode(node) .instanceNode(node) .messageKey("tests.example.enumNames").message("enumName is {0}").instanceLocation(instanceLocation) .arguments(valueName).build(); - executionContext.addError(validationMessage); + executionContext.addError(error); } } @@ -126,10 +126,10 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { " \"enumNames\": [\"Foo !\", \"Bar !\"]\n" + "}"); - List messages = schema.validate(objectMapper.readTree("\"foo\"")); + List messages = schema.validate(objectMapper.readTree("\"foo\"")); assertEquals(1, messages.size()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("$: enumName is Foo !", message.toString()); } } diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index bfd613469..7c7f06cbf 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -24,7 +24,7 @@ void customUri() throws Exception { final JsonNode value = mapper.readTree("{\"customAnyOf\": null,\"customOneOf\": null}"); /* When */ - final List errors = schema.validate(value); + final List errors = schema.validate(value); /* Then */ assertThat(errors.isEmpty(), is(true)); diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index ea182bf83..ae6570a4b 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -28,7 +28,7 @@ void shouldWorkV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 6ddf2ebc6..863d00bd5 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -35,7 +35,7 @@ class DependentRequiredTest { @Test void shouldReturnNoErrorMessagesForObjectWithoutOptionalField() throws IOException { - List messages = whenValidate("{}"); + List messages = whenValidate("{}"); assertThat(messages, empty()); } @@ -43,23 +43,23 @@ void shouldReturnNoErrorMessagesForObjectWithoutOptionalField() throws IOExcepti @Test void shouldReturnErrorMessageForObjectWithoutDependentRequiredField() throws IOException { - List messages = whenValidate("{ \"optional\": \"present\" }"); + List messages = whenValidate("{ \"optional\": \"present\" }"); assertThat( - messages.stream().map(ValidationMessage::toString).collect(Collectors.toList()), + messages.stream().map(Error::toString).collect(Collectors.toList()), contains("$: has a missing property 'requiredWhenOptionalPresent' which is dependent required because 'optional' is present")); } @Test void shouldReturnNoErrorMessagesForObjectWithOptionalAndDependentRequiredFieldSet() throws JsonProcessingException { - List messages = + List messages = whenValidate("{ \"optional\": \"present\", \"requiredWhenOptionalPresent\": \"present\" }"); assertThat(messages, empty()); } - private static List whenValidate(String content) throws JsonProcessingException { + private static List whenValidate(String content) throws JsonProcessingException { return schema.validate(mapper.readTree(content)); } diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 0327d44f9..01120acbb 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -118,7 +118,7 @@ void discriminatorInArray() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -150,7 +150,7 @@ void anyOfWithConfigEnabledButNoDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -243,7 +243,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -336,7 +336,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -426,11 +426,11 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); @@ -522,11 +522,11 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); @@ -622,11 +622,11 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("numberOfBeds", list.get(1).getProperty()); @@ -677,9 +677,9 @@ void oneOfMissingDiscriminatorValue() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("required", list.get(2).getKeyword()); @@ -773,8 +773,8 @@ void anyOfMissingDiscriminatorValue() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); - List list = messages.stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON); + List list = messages.stream().collect(Collectors.toList()); assertEquals("required", list.get(0).getKeyword()); } } diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 00b1086cc..f018b1c5f 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -37,7 +37,7 @@ void durationFormatValidatorTest() throws IOException { final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).build(); final JsonSchema validatorSchema = validatorFactory.getSchema(schema); - List messages = validatorSchema.validate(validTargetNode); + List messages = validatorSchema.validate(validTargetNode); assertEquals(0, messages.size()); messages = validatorSchema.validate(invalidTargetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index ef8b6c496..02fcc6897 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -87,9 +87,9 @@ void enumWithObjectNodes() { + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); - List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); - ValidationMessage message = messages.get(0); + Error message = messages.get(0); assertEquals( ": does not have a value in the enumeration [{\"name\":\"EMPTY\",\"cardinality\":0}, {\"name\":\"OK\",\"cardinality\":20}, {\"name\":\"UNKNOWN\",\"cardinality\":30}, {\"name\":\"WARNING\",\"cardinality\":40}, {\"name\":\"CRITICAL\",\"cardinality\":50}]", message.toString()); @@ -107,9 +107,9 @@ void enumWithHeterogenousNodes() { + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); - List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); - ValidationMessage message = messages.get(0); + Error message = messages.get(0); assertEquals(": does not have a value in the enumeration [6, \"foo\", [], true, {\"foo\":12}]", message.toString()); } } diff --git a/src/test/java/com/networknt/schema/ValidationMessageHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java similarity index 89% rename from src/test/java/com/networknt/schema/ValidationMessageHandlerTest.java rename to src/test/java/com/networknt/schema/ErrorHandlerTest.java index 4ff9a8ef7..8fd5a66f2 100644 --- a/src/test/java/com/networknt/schema/ValidationMessageHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -25,9 +25,9 @@ import com.networknt.schema.SpecVersion.VersionFlag; /** - * ValidationMessageHandlerTest. + * ErrorHandlerTest. */ -class ValidationMessageHandlerTest { +class ErrorHandlerTest { @Test void errorMessage() { String schemaData = "{\r\n" @@ -53,7 +53,7 @@ void errorMessage() { + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); - List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); assertEquals("/foo", messages.get(0).getInstanceLocation().toString()); assertEquals("should be an object", messages.get(0).getMessage()); @@ -83,7 +83,7 @@ void errorMessageUnionType() { + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); - List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); assertEquals("/keyword1", messages.get(0).getInstanceLocation().toString()); assertEquals("关键字1必须为字符串", messages.get(0).getMessage()); diff --git a/src/test/java/com/networknt/schema/ValidationMessageTest.java b/src/test/java/com/networknt/schema/ErrorTest.java similarity index 86% rename from src/test/java/com/networknt/schema/ValidationMessageTest.java rename to src/test/java/com/networknt/schema/ErrorTest.java index 2357e395b..a24746c4f 100644 --- a/src/test/java/com/networknt/schema/ValidationMessageTest.java +++ b/src/test/java/com/networknt/schema/ErrorTest.java @@ -23,13 +23,13 @@ import com.networknt.schema.serialization.JsonMapperFactory; /** - * ValidationMessageTest. + * ErrorTest. */ -class ValidationMessageTest { +class ErrorTest { @Test void testSerialization() throws JsonProcessingException { String value = JsonMapperFactory.getInstance() - .writeValueAsString(ValidationMessage.builder().messageSupplier(() -> "hello") + .writeValueAsString(Error.builder().messageSupplier(() -> "hello") .schemaLocation(SchemaLocation.of("https://www.example.com/#defs/definition")).build()); assertEquals("{\"message\":\"hello\",\"schemaLocation\":\"https://www.example.com/#defs/definition\"}", value); } diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 8b559e7a2..193c32e78 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -41,7 +41,7 @@ void exampleSchemaLocation() { + "}"; // The example-main.json schema defines $schema with Draft 07 assertEquals(SchemaId.V7, schema.getValidationContext().getMetaSchema().getIri()); - List assertions = schema.validate(input, InputFormat.JSON); + List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 @@ -64,7 +64,7 @@ void exampleClasspath() { + "}"; // The example-main.json schema defines $schema with Draft 07 assertEquals(SchemaId.V7, schema.getValidationContext().getMetaSchema().getIri()); - List assertions = schema.validate(input, InputFormat.JSON); + List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 332661c53..1780a0959 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -48,7 +48,7 @@ void draftV4ShouldHaveExclusiveMinimum() { String inputData = "{\"value1\":0}"; String validData = "{\"value1\":0.1}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals(1, messages.stream().filter(m -> "minimum".equals(m.getKeyword())).count()); diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 593f6851a..c4e512261 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -42,7 +42,7 @@ void unknownFormatNoVocab() { + " \"format\":\"unknown\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { + List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertEquals(0, messages.size()); @@ -55,7 +55,7 @@ void unknownFormatNoVocabStrictTrue() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { + List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertEquals(1, messages.size()); @@ -88,7 +88,7 @@ void unknownFormatAssertionsVocab() { builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) .getSchema(schemaData, config); - List messages = schema.validate("\"hello\"", InputFormat.JSON); + List messages = schema.validate("\"hello\"", InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("format.unknown", messages.iterator().next().getMessageKey()); } @@ -144,7 +144,7 @@ void formatAssertions(FormatInput formatInput) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); - List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { + List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertFalse(messages.isEmpty()); @@ -173,7 +173,7 @@ void patternFormatDeprecated() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); - List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { + List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertFalse(messages.isEmpty()); @@ -222,7 +222,7 @@ void shouldAllowNumberFormat() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); - List messages = schema.validate("123451", InputFormat.JSON, executionConfiguration -> { + List messages = schema.validate("123451", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); assertFalse(messages.isEmpty()); @@ -240,7 +240,7 @@ void draft7DisableFormat() { + " \"format\":\"uri\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData); - List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { + List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); }); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 04573e8ee..57533907d 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -56,7 +56,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -68,7 +68,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes .build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, true); - assertFalse(result.getValidationMessages().isEmpty()); + assertFalse(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List types = (List) result.getExecutionContext().getCollectorContext().get("types"); @@ -99,7 +99,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -111,7 +111,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes .build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"hello\"", InputFormat.JSON, true); - assertFalse(result.getValidationMessages().isEmpty()); + assertFalse(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List types = (List) result.getExecutionContext().getCollectorContext().get("types"); @@ -142,7 +142,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -154,7 +154,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes .build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List types = (List) result.getExecutionContext().getCollectorContext().get("types"); @@ -183,7 +183,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -195,7 +195,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes .build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, false); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List types = (List) result.getExecutionContext().getCollectorContext().get("types"); diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 2f11b5c53..542a01a2a 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -40,7 +40,7 @@ void testHasAdjacentKeywordInEvaluationPath() throws Exception { List messages = schema.validate(node) .stream() - .map(ValidationMessage::getMessage) + .map(Error::getMessage) .collect(Collectors.toList()); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index 4af40b527..afac8731e 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -43,7 +43,7 @@ void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() throws Ex JsonSchema schema = getJsonSchemaFromStreamContent(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index c9611d073..c669d2f4e 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -57,11 +57,11 @@ class Issue285Test { @Test void nestedValidation() throws IOException { JsonSchema jsonSchema = schemaFactory.getSchema(schemaStr); - List validationMessages = jsonSchema.validate(mapper.readTree(person)); + List errors = jsonSchema.validate(mapper.readTree(person)); - System.err.println("\n" + Arrays.toString(validationMessages.toArray())); + System.err.println("\n" + Arrays.toString(errors.toArray())); - assertFalse(validationMessages.isEmpty()); + assertFalse(errors.isEmpty()); } @@ -98,11 +98,11 @@ void nestedValidation() throws IOException { void nestedTypeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); JsonSchema jsonSchema = schemaFactory.getSchema(uri); - List validationMessages = jsonSchema.validate(mapper.readTree(invalidNestedSchema)); + List errors = jsonSchema.validate(mapper.readTree(invalidNestedSchema)); - System.err.println("\n" + Arrays.toString(validationMessages.toArray())); + System.err.println("\n" + Arrays.toString(errors.toArray())); - assertFalse(validationMessages.isEmpty()); + assertFalse(errors.isEmpty()); } String invalidSchema = "{\n" + @@ -121,10 +121,10 @@ void nestedTypeValidation() throws IOException { void typeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); JsonSchema jsonSchema = schemaFactory.getSchema(uri); - List validationMessages = jsonSchema.validate(mapper.readTree(invalidSchema)); + List errors = jsonSchema.validate(mapper.readTree(invalidSchema)); - System.err.println("\n" + Arrays.toString(validationMessages.toArray())); + System.err.println("\n" + Arrays.toString(errors.toArray())); - assertFalse(validationMessages.isEmpty()); + assertFalse(errors.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index 79f85f7a9..e77500216 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -28,7 +28,7 @@ void shouldWorkV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 002c5cd67..602c55f74 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -35,7 +35,7 @@ void shouldFailV201909() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV201909(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); } @@ -47,7 +47,7 @@ void shouldFailV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); } diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index ba74134db..e32fcd686 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -28,7 +28,7 @@ void shouldWorkV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 323681cb9..e5e869f0d 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -29,9 +29,9 @@ void propertyNameEnumShouldFailV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(1, errors.size()); - final ValidationMessage error = errors.iterator().next(); + final Error error = errors.iterator().next(); Assertions.assertEquals("$", error.getInstanceLocation().toString()); Assertions.assertEquals("$: property 'z' name is not valid: does not have a value in the enumeration [\"a\", \"b\", \"c\"]", error.toString()); } diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 3fde9a6d8..48f5fea76 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -50,7 +50,7 @@ void firstOneValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(0); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertTrue(errors.isEmpty()); } @@ -63,7 +63,7 @@ void secondOneValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(1); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertTrue(errors.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index b395ebd57..c306773fe 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -51,7 +51,7 @@ void firstOneValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(0); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertTrue(errors.isEmpty()); } @@ -64,7 +64,7 @@ void secondOneValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(1); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertTrue(errors.isEmpty()); } @@ -77,7 +77,7 @@ void bothValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(2); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertFalse(errors.isEmpty()); assertEquals(errors.size(), 1); } @@ -91,7 +91,7 @@ void neitherValid() throws Exception { List testNodes = node.findValues("tests"); JsonNode testNode = testNodes.get(0).get(3); JsonNode dataNode = testNode.get("data"); - List errors = jsonSchema.validate(dataNode); + List errors = jsonSchema.validate(dataNode); assertFalse(errors.isEmpty()); assertEquals(errors.size(), 3); } diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 2efc4eb33..94e07ec57 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -45,9 +45,9 @@ void shouldFailAndShowValidationValuesWithError() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContent(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); List errorMessages = new ArrayList(); - for (ValidationMessage error: errors) { + for (Error error: errors) { errorMessages.add(error.toString()); } diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index d22009c98..b7d817e87 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -29,7 +29,7 @@ void nestedOneOfsShouldStillMatchV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index df89d7a6e..26f4f6ff7 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -39,8 +39,8 @@ void testComplexPropertyNamesV7() throws Exception { expected.add(entry.getKey()); }); - List errors = schema.validate(node); - final Set actual = errors.stream().map(ValidationMessage::getProperty).map(Object::toString).collect(Collectors.toSet()); + List errors = schema.validate(node); + final Set actual = errors.stream().map(Error::getProperty).map(Object::toString).collect(Collectors.toSet()); Assertions.assertEquals(expected, actual); } } diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 52581d49d..66c747a0f 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -28,7 +28,7 @@ void expectObjectNotIntegerV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 7775a4804..4d35ae4af 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -30,10 +30,10 @@ void shouldWorkV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); final JsonNode message = schema.schemaNode.get("message"); - for(ValidationMessage error : errors) { + for(Error error : errors) { //validating custom message Assertions.assertEquals(message.get(error.getKeyword()).asText(), error.getMessage()); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index f5d7e725f..e2067cd2e 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -40,7 +40,7 @@ private void runTestFile(String testCaseFile) throws Exception { configBuilder.discriminatorKeywordEnabled(false); JsonSchema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); - List errors = new ArrayList(schema.validate(node)); + List errors = new ArrayList(schema.validate(node)); if (test.get("valid").asBoolean()) { if (!errors.isEmpty()) { @@ -48,7 +48,7 @@ private void runTestFile(String testCaseFile) throws Exception { System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors:"); - for (ValidationMessage error : errors) { + for (Error error : errors) { System.out.println(error); } } @@ -65,7 +65,7 @@ private void runTestFile(String testCaseFile) throws Exception { System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors: " + errors); - for (ValidationMessage error : errors) { + for (Error error : errors) { System.out.println(error); } assertEquals(errorCount.asInt(), errors.size(), "expected error count"); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 5d873377b..2c0222210 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -77,7 +77,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index 473ab9996..ff107d707 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -29,7 +29,7 @@ void shouldWorkT2() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } @@ -41,7 +41,7 @@ void shouldWorkT3() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index a95788fb4..c174a858a 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -28,7 +28,7 @@ void shouldWalkWithValidation() throws IOException { JsonSchema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); JsonNode data = mapper.readTree(Issue461Test.class.getResource("/data/issue461-v7.json")); ValidationResult result = schema.walk(data, true); - Assertions.assertTrue(result.getValidationMessages().isEmpty()); + Assertions.assertTrue(result.getErrors().isEmpty()); } /** @@ -42,7 +42,7 @@ public WalkFlow onWalkStart(final WalkEvent walkEvent) { @Override public void onWalkEnd(final WalkEvent walkEvent, - final List validationMessages) { + final List errors) { } } } diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index ff92735ba..2442702ec 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -54,7 +54,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List set) { + public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); @@ -63,7 +63,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { ValidationResult result = schema.walk(data, true); assertEquals(new HashSet<>(Arrays.asList("/properties", "/properties/tags/items/0/properties")), properties.stream().map(Object::toString).collect(Collectors.toSet())); - assertEquals(1, result.getValidationMessages().size()); + assertEquals(1, result.getErrors().size()); } @Test @@ -79,7 +79,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List set) { + public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); @@ -89,7 +89,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { assertEquals( new HashSet<>(Arrays.asList("/properties/tags", "/properties/tags/items/0/properties/category", "/properties/tags/items/0/properties/value")), properties.stream().map(Object::toString).collect(Collectors.toSet())); - assertEquals(1, result.getValidationMessages().size()); + assertEquals(1, result.getErrors().size()); } } diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index fc4f7bf1e..905320d59 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -69,12 +69,12 @@ private Map validate() throws Exception { InputStream dataInputStream = Issue471Test.class.getResourceAsStream(DATA_PATH); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List validationMessages = schema.validate(node); - return convertValidationMessagesToMap(validationMessages); + List errors = schema.validate(node); + return convertErrorsToMap(errors); } - private Map convertValidationMessagesToMap(List validationMessages) { - return validationMessages.stream().collect(Collectors.toMap(m -> m.getInstanceLocation().toString(), ValidationMessage::getMessage)); + private Map convertErrorsToMap(List errors) { + return errors.stream().collect(Collectors.toMap(m -> m.getInstanceLocation().toString(), Error::getMessage)); } private JsonSchema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 9cb928b94..7907a462f 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -55,7 +55,7 @@ void draft4() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V4), config); - List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); + List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); assertions = schema.validate(JsonMapperFactory.getInstance().readTree(VALID_INPUT)); @@ -69,7 +69,7 @@ void draft6() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V6), config); - List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); + List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); assertions = schema.validate(JsonMapperFactory.getInstance().readTree(VALID_INPUT)); @@ -83,7 +83,7 @@ void draft7() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V7), config); - List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); + List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); assertions = schema.validate(JsonMapperFactory.getInstance().readTree(VALID_INPUT)); @@ -97,7 +97,7 @@ void draft201909() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V201909), config); - List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); + List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); assertions = schema.validate(JsonMapperFactory.getInstance().readTree(VALID_INPUT)); @@ -111,7 +111,7 @@ void draft202012() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V202012), config); - List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); + List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); assertions = schema.validate(JsonMapperFactory.getInstance().readTree(VALID_INPUT)); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index d33330e17..274558840 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -37,7 +37,7 @@ void testValidJson1 () InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); JsonSchema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-valid-1.json"); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertTrue(errors.isEmpty()); } @@ -49,7 +49,7 @@ void testValidJson2 () InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); JsonSchema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-valid-2.json"); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertTrue(errors.isEmpty()); } @@ -61,7 +61,7 @@ void testInvalidJson1 () InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); JsonSchema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-invalid-1.json"); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); Set allErrorMessages = new HashSet<>(); @@ -81,7 +81,7 @@ void testInvalidJson2 () InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); JsonSchema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-invalid-2.json"); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(3, errors.size()); Set allErrorMessages = new HashSet<>(); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index fbe39f7f3..5b3c702d5 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -30,10 +30,10 @@ void testValidationMessageDoContainSchemaPath() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaPath); JsonNode node = getJsonNodeFromStreamContent(dataPath); - List errors = schema.validate(node); - ValidationMessage validationMessage = errors.stream().findFirst().get(); + List errors = schema.validate(node); + Error error = errors.stream().findFirst().get(); - Assertions.assertEquals("https://example.com/person.schema.json#/properties/age/minimum", validationMessage.getSchemaLocation().toString()); + Assertions.assertEquals("https://example.com/person.schema.json#/properties/age/minimum", error.getSchemaLocation().toString()); Assertions.assertEquals(1, errors.size()); } @@ -44,11 +44,11 @@ void testValidationMessageDoContainSchemaPathForOneOf() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaPath); JsonNode node = getJsonNodeFromStreamContent(dataPath); - List errors = schema.validate(node); - ValidationMessage validationMessage = errors.stream().findFirst().get(); + List errors = schema.validate(node); + Error error = errors.stream().findFirst().get(); // Instead of capturing all subSchema within oneOf, a pointer to oneOf should be provided. - Assertions.assertEquals("https://example.com/person.schema.json#/oneOf", validationMessage.getSchemaLocation().toString()); + Assertions.assertEquals("https://example.com/person.schema.json#/oneOf", error.getSchemaLocation().toString()); Assertions.assertEquals(1, errors.size()); } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index 52cdddc87..b689eca10 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -79,7 +79,7 @@ static Stream validTimeZoneOffsets() { @ParameterizedTest @MethodSource("validTimeZoneOffsets") void testValidTimeZoneOffsets(String jsonObject) throws JsonProcessingException { - List errors = schema.validate(new ObjectMapper().readTree(jsonObject)); + List errors = schema.validate(new ObjectMapper().readTree(jsonObject)); Assertions.assertTrue(errors.isEmpty()); } @@ -121,7 +121,7 @@ static Stream invalidTimeRepresentations() { @ParameterizedTest @MethodSource("invalidTimeRepresentations") void testInvalidTimeRepresentations(String jsonObject) throws JsonProcessingException { - List errors = schema.validate(new ObjectMapper().readTree(jsonObject), OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List errors = schema.validate(new ObjectMapper().readTree(jsonObject), OutputFormat.DEFAULT, (executionContext, validationContext) -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); Assertions.assertFalse(errors.isEmpty()); diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index 999b2fc5b..f79314c0e 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -28,7 +28,7 @@ void shouldWorkV7() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(0, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index 0d15bdb0f..1e691efcf 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -46,7 +46,7 @@ void testBinaryNode() throws Exception { JsonNode node = mapper.valueToTree(model); // validate: - List errors = schema.validate(node); + List errors = schema.validate(node); // check result: Assertions.assertTrue(errors.isEmpty()); diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index 3510a31a0..41979d83c 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -23,21 +23,21 @@ static void setup() { @Test void testNoErrorsForEmptyObject() throws IOException { JsonNode node = getJsonNodeFromClasspath(resource("emptyObject.json")); - List errors = schema.validate(node); + List errors = schema.validate(node); assertTrue(errors.isEmpty(), "No validation errors for empty optional object"); } @Test void testNoErrorsForValidObject() throws IOException { JsonNode node = getJsonNodeFromClasspath(resource("validObject.json")); - List errors = schema.validate(node); + List errors = schema.validate(node); assertTrue(errors.isEmpty(), "No validation errors for a valid optional object"); } @Test void testCorrectErrorForInvalidValue() throws IOException { JsonNode node = getJsonNodeFromClasspath(resource("objectInvalidValue.json")); - List errors = schema.validate(node); + List errors = schema.validate(node); List errorMessages = errors.stream() .map(v -> v.getEvaluationPath() + " = " + v.toString()) .collect(toList()); diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index 7056ab223..88987cbeb 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -31,7 +31,7 @@ void shouldHaveFullSchemaPaths() throws Exception { JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errorSchemaPaths = schema.validate(node).stream().map(ValidationMessage::getSchemaLocation) + List errorSchemaPaths = schema.validate(node).stream().map(Error::getSchemaLocation) .map(Object::toString).collect(Collectors.toList()); List expectedSchemaPaths = Arrays.asList( diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index d05f7bd9b..5ec0aab09 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -16,7 +16,7 @@ void testUrnUriAsLocalRef() throws IOException { JsonSchema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", SpecVersion.VersionFlag.V7); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); - List messages = schema.validate(getJsonNodeFromStringContent( + List messages = schema.validate(getJsonNodeFromStringContent( "{\"myData\": {\"value\": \"hello\"}}")); Assertions.assertTrue(messages.isEmpty()); } @@ -36,7 +36,7 @@ void testUrnUriAsLocalRef_ExternalURN() { JsonSchema schema = factory.getSchema(is); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); - List messages = schema.validate(getJsonNodeFromStringContent( + List messages = schema.validate(getJsonNodeFromStringContent( "{\"myData\": {\"value\": \"hello\"}}")); Assertions.assertTrue(messages.isEmpty()); } catch (IOException e) { diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index ae2a5f5cc..fde91b5c6 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -59,7 +59,7 @@ private JsonSchema getSchema(SchemaValidatorsConfig config) { } private void verify(SchemaValidatorsConfig config, String expectedMessage) throws JsonProcessingException { - List messages = getSchema(config).validate(new ObjectMapper().readTree(" { \"foo\": 123 } ")); + List messages = getSchema(config).validate(new ObjectMapper().readTree(" { \"foo\": 123 } ")); assertEquals(1, messages.size()); assertEquals(expectedMessage, messages.iterator().next().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index 457ace08f..b21445c7d 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -54,7 +54,7 @@ static Stream appendIndexes() { ); } - static Stream validationMessages() { + static Stream errors() { String schemaPath = "/schema/issue687.json"; String content = "{ \"foo\": \"a\", \"b.ar\": 1, \"children\": [ { \"childFoo\": \"a\", \"c/hildBar\": 1 } ] }"; return Stream.of( @@ -78,12 +78,12 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin } @ParameterizedTest - @MethodSource("validationMessages") - void testValidationMessage(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { + @MethodSource("errors") + void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); JsonSchema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); - List messages = schema.validate(new ObjectMapper().readTree(content)); + List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); for (String expectedPath: expectedMessagePaths) { assertTrue(messages.stream().anyMatch(msg -> expectedPath.equals(msg.getInstanceLocation().toString()))); @@ -124,9 +124,9 @@ void testSpecialCharacters(PathType pathType, String propertyName, String expect " }\n" + " }\n" + "}"), schemaValidatorsConfig); - List validationMessages = schema.validate(mapper.readTree("{\""+propertyName+"\": 1}")); - assertEquals(1, validationMessages.size()); - assertEquals(expectedPath, validationMessages.iterator().next().getInstanceLocation().toString()); + List errors = schema.validate(mapper.readTree("{\""+propertyName+"\": 1}")); + assertEquals(1, errors.size()); + assertEquals(expectedPath, errors.iterator().next().getInstanceLocation().toString()); } } diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 8cdbe9cc9..310e56e90 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -77,7 +77,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { // nothing to do here } } diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index dbdcff706..71b8e1852 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -56,7 +56,7 @@ void useDefaultValidatorIfNotOverriden() throws IOException { } - private List validate(JsonSchema jsonSchema, String myDateTimeContent) throws JsonProcessingException { + private List validate(JsonSchema jsonSchema, String myDateTimeContent) throws JsonProcessingException { return jsonSchema.validate(new ObjectMapper().readTree(" { \"my-date-time\": \"" + myDateTimeContent + "\" } ")); } diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index cfa8ba0f2..20220a311 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -26,8 +26,8 @@ void validate() throws JsonProcessingException { "}"); // Validate same JSON schema against v2019-09 spec schema twice - final List validationErrors1 = v201909SpecSchema.validate(invalidSchema); - final List validationErrors2 = v201909SpecSchema.validate(invalidSchema); + final List validationErrors1 = v201909SpecSchema.validate(invalidSchema); + final List validationErrors2 = v201909SpecSchema.validate(invalidSchema); // Validation errors should be the same assertEquals(validationErrors1, validationErrors2); diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 76e5ae0d2..4d6afea33 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -55,7 +55,7 @@ void testV7WithNonMatchingCustomFormat() throws IOException { JsonSchema schema = factory.getSchema(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); - List errors = schema.validate(node); + List errors = schema.validate(node); // Both the custom no_match format and the standard email format should fail. // This ensures that both the standard and custom formatters have been invoked. Assertions.assertEquals(2, errors.size()); diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index 722080918..5dbb1c3b0 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -50,7 +50,7 @@ void test() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); - List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); + List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 899723d24..40fed4b46 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -34,10 +34,10 @@ void test() throws Exception { JsonSchema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); - assertEquals(0, result.getValidationMessages().size()); + assertEquals(0, result.getErrors().size()); input = ""; result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); - assertEquals(1, result.getValidationMessages().size()); + assertEquals(1, result.getErrors().size()); } } diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index 67a03ead4..9a932d2c2 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -19,7 +19,7 @@ void testMessagesWithSingleQuotes() throws Exception { JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); List messages = schema.validate(node).stream() - .map(ValidationMessage::toString) + .map(Error::toString) .collect(toList()); Assertions.assertEquals(2, messages.size()); diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index 690abbe40..20d2239b1 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -127,7 +127,7 @@ void test() throws JsonProcessingException { + " ]\r\n" + " }\r\n" + "}"; - List messages = jsonSchema.validate(input, InputFormat.JSON); + List messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(0, messages.size()); } diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 7ca3a449d..104f2c70a 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -50,7 +50,7 @@ void shouldNotThrowException() { + " }"; JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); - List assertions = jsonSchema + List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); assertEquals(2, assertions.size()); } diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 1235aa784..40510d1c1 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -48,9 +48,9 @@ void messageInvalid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/items/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); assertEquals("/1", message.getInstanceLocation().toString()); @@ -75,7 +75,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -86,7 +86,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -114,7 +114,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -125,7 +125,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 769b14c58..9b2638cb0 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -51,9 +51,9 @@ void messageInvalid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/items/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); assertEquals("/1", message.getInstanceLocation().toString()); @@ -78,9 +78,9 @@ void messageAdditionalItemsInvalid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/additionalItems/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/additionalItems/type", message.getSchemaLocation().toString()); assertEquals("/3", message.getInstanceLocation().toString()); @@ -105,9 +105,9 @@ void messageAdditionalItemsFalseInvalid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/additionalItems", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/additionalItems", message.getSchemaLocation().toString()); assertEquals("", message.getInstanceLocation().toString()); @@ -132,7 +132,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -143,7 +143,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -168,7 +168,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -179,7 +179,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -210,7 +210,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -221,7 +221,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -260,7 +260,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -272,7 +272,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonSchema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); ValidationResult result = schema.walk(input, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -317,7 +317,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -330,7 +330,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonSchema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); ValidationResult result = schema.walk(input, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTest.java b/src/test/java/com/networknt/schema/JsonSchemaTest.java index 0f76ac1f6..fa6303fd5 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTest.java @@ -72,7 +72,7 @@ public void run() { throw new RuntimeException(e); } try { - List messages = schema.validate(inputData, InputFormat.JSON) + List messages = schema.validate(inputData, InputFormat.JSON) .stream() .collect(Collectors.toList()); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 9a8d964d6..866a0e30d 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -24,12 +24,12 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema); if (shouldValidateSchema) { - assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), + assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/badArray/1: integer found, string expected", "/outer/reference/stringValue_missing_with_default_null: null found, string expected")); } else { - assertThat(result.getValidationMessages(), Matchers.empty()); + assertThat(result.getErrors(), Matchers.empty()); } // TODO: In Java 14 use text blocks assertEquals( @@ -44,7 +44,7 @@ void testApplyDefaults2() throws IOException { JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, false)); ValidationResult result = jsonSchema.walk(inputNode, true); - assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), + assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", "/outer/badArray/1: null found, string expected", @@ -61,7 +61,7 @@ void testApplyDefaults1() throws IOException { JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, false, false)); ValidationResult result = jsonSchema.walk(inputNode, true); - assertThat(result.getValidationMessages().stream().map(ValidationMessage::toString).collect(Collectors.toList()), + assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_null: null found, integer expected", "/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", @@ -79,28 +79,28 @@ void testApplyDefaults0(String method) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); JsonNode inputNodeOriginal = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - List validationMessages; + List errors; switch (method) { case "walkWithEmptyStrategy": { JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(false, false, false)); - validationMessages = jsonSchema.walk(inputNode, true).getValidationMessages(); + errors = jsonSchema.walk(inputNode, true).getErrors(); break; } case "walkWithNoDefaults": { // same empty strategy, but tests for NullPointerException JsonSchema jsonSchema = createSchema(null); - validationMessages = jsonSchema.walk(inputNode, true).getValidationMessages(); + errors = jsonSchema.walk(inputNode, true).getErrors(); break; } case "validateWithApplyAllDefaults": { JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); - validationMessages = jsonSchema.validate(inputNode); + errors = jsonSchema.validate(inputNode); break; } default: throw new UnsupportedOperationException(); } - assertThat(validationMessages.stream().map(ValidationMessage::toString).collect(Collectors.toList()), + assertThat(errors.stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject: required property 'intValue_missing' not found", "/outer/mixedObject: required property 'intValue_missingButError' not found", "/outer/mixedObject/intValue_null: null found, integer expected", diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 573cdb096..3b36ef859 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -197,7 +197,7 @@ public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { } @Override - public void onWalkEnd(WalkEvent keywordWalkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent keywordWalkEvent, List errors) { } } @@ -218,7 +218,7 @@ public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { } @Override - public void onWalkEnd(WalkEvent keywordWalkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent keywordWalkEvent, List errors) { } } @@ -235,7 +235,7 @@ public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { } @Override - public void onWalkEnd(WalkEvent keywordWalkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent keywordWalkEvent, List errors) { } } diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index 3f7707fbc..ed4a74a2f 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -57,7 +57,7 @@ void executionContextLocale() throws JsonMappingException, JsonProcessingExcepti ExecutionContext executionContext = jsonSchema.createExecutionContext(); assertEquals(config.getLocale(), executionContext.getExecutionConfig().getLocale()); executionContext.getExecutionConfig().setLocale(locale); - List messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); + List messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); assertEquals(1, messages.size()); assertEquals("/foo: integer trouvé, string attendu", messages.iterator().next().toString()); @@ -91,7 +91,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; - List messages = jsonSchema.validate(input, InputFormat.JSON); + List messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("$: integer gefunden, object erwartet", messages.iterator().next().toString()); @@ -157,7 +157,7 @@ void encoding() { JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { - List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { + List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setLocale(locale); }); String msg = messages.iterator().next().toString(); diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 27c34beb2..5e5a9d544 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -189,13 +189,13 @@ void negativeDoubleOverflowTest() throws IOException { // Schema and document parsed with just double JsonSchema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Maximum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", maximum, value)); // document parsed with BigDecimal doc = bigDecimalMapper.readTree(value); - List messages2 = v.validate(doc); + List messages2 = v.validate(doc); if (Double.valueOf(maximum).equals(Double.POSITIVE_INFINITY)) { assertTrue(messages2.isEmpty(), format("Maximum %s and value %s are equal, thus no schema violation should be reported", maximum, value)); } else { @@ -205,7 +205,7 @@ void negativeDoubleOverflowTest() throws IOException { // schema and document parsed with BigDecimal v = factory.getSchema(bigDecimalMapper.readTree(schema), config); - List messages3 = v.validate(doc); + List messages3 = v.validate(doc); //when the schema and value are both using BigDecimal, the value should be parsed in same mechanism. String theValue = value.toLowerCase().replace("\"", ""); if (maximum.toLowerCase().equals(theValue)) { @@ -228,7 +228,7 @@ void doubleValueCoarsing() throws IOException { JsonNode doc = mapper.readTree(content); JsonSchema v = factory.getSchema(mapper.readTree(schema)); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); doc = bigDecimalMapper.readTree(content); @@ -260,7 +260,7 @@ void doubleValueCoarsingExceedRange() throws IOException { JsonNode doc = mapper.readTree(content); JsonSchema v = factory.getSchema(mapper.readTree(schema)); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); doc = bigDecimalMapper.readTree(content); @@ -299,7 +299,7 @@ private static void expectNoMessages(String[][] values, String schemaTemplate, O JsonSchema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), format(MaximumValidatorTest.POSITIVE_TEST_CASE_TEMPLATE, maximum, value)); } } @@ -319,7 +319,7 @@ private static void expectSomeMessages(String[][] values, String schemaTemplate, JsonSchema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper2.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertFalse(messages.isEmpty(), format(MaximumValidatorTest.NEGATIVE_TEST_CASE_TEMPLATE, value, maximum)); } } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 09b088563..c11d2834b 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -42,7 +42,7 @@ static class EqualsValidator extends BaseJsonValidator { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { if (!node.asText().equals(value)) { - executionContext.addError(message().message("must be equal to ''{0}''") + executionContext.addError(error().message("must be equal to ''{0}''") .arguments(value) .instanceLocation(instanceLocation).instanceNode(node).build()); } @@ -74,7 +74,7 @@ void message() { + " \"equals\": \"helloworld\"\r\n" + "}"; JsonSchema schema = factory.getSchema(schemaData); - List messages = schema.validate("\"helloworlda\"", InputFormat.JSON); + List messages = schema.validate("\"helloworlda\"", InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("$: must be equal to 'helloworld'", messages.iterator().next().toString()); diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 4cb345774..7a362cc13 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -46,7 +46,7 @@ void oas31() throws IOException { builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07"), config); - List messages = schema.validate(inputData); + List messages = schema.validate(inputData); assertEquals(0, messages.size()); } } diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 5a23b0aa8..6a082c06d 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -177,12 +177,12 @@ void negativeDoubleOverflowTest() throws IOException { // Schema and document parsed with just double JsonSchema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Minimum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", minimum, value)); // document parsed with BigDecimal doc = bigDecimalMapper.readTree(value); - List messages2 = v.validate(doc); + List messages2 = v.validate(doc); //when the schema and value are both using BigDecimal, the value should be parsed in same mechanism. if (Double.valueOf(minimum).equals(Double.NEGATIVE_INFINITY)) { @@ -197,7 +197,7 @@ void negativeDoubleOverflowTest() throws IOException { // schema and document parsed with BigDecimal v = factory.getSchema(bigDecimalMapper.readTree(schema), config); - List messages3 = v.validate(doc); + List messages3 = v.validate(doc); //when the schema and value are both using BigDecimal, the value should be parsed in same mechanism. String theValue = value.toLowerCase().replace("\"", ""); if (minimum.toLowerCase().equals(theValue)) { @@ -220,7 +220,7 @@ void doubleValueCoarsing() throws IOException { JsonNode doc = mapper.readTree(content); JsonSchema v = factory.getSchema(mapper.readTree(schema)); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); doc = bigDecimalMapper.readTree(content); @@ -250,7 +250,7 @@ void doubleValueCoarsingExceedRange() throws IOException { JsonNode doc = mapper.readTree(content); JsonSchema v = factory.getSchema(mapper.readTree(schema)); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); doc = bigDecimalMapper.readTree(content); @@ -273,7 +273,7 @@ private void expectSomeMessages(String[][] values, String number, ObjectMapper m JsonSchema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper2.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertFalse(messages.isEmpty(), format(MinimumValidatorTest.NEGATIVE_MESSAGE_TEMPLATE, value, minimum)); } } @@ -292,7 +292,7 @@ private void expectNoMessages(String[][] values, String integer, ObjectMapper ma JsonSchema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = bigIntegerMapper.readTree(value); - List messages = v.validate(doc); + List messages = v.validate(doc); assertTrue(messages.isEmpty(), format(MinimumValidatorTest.POSITIVT_MESSAGE_TEMPLATE, value, minimum)); } } diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 4f6fb2c36..4689fe649 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -52,7 +52,7 @@ void test() { String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); @@ -69,7 +69,7 @@ void testTypeLoose() { String validTypeLooseInputData = "{\"value1\":\"123.89\",\"value2\":\"123456.29\",\"value3\":123.12}"; // Without type loose this has 2 type and 1 multipleOf errors - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); assertEquals(1, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index 50607fe2b..e6eb3baeb 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -39,6 +39,6 @@ void walkValidationWithNullNodeShouldNotValidate() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); - assertEquals(true, result.getValidationMessages().isEmpty()); + assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index a92141cbb..ef167f9fc 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -65,9 +65,9 @@ void oneOfMultiple() { + " \"world\" : \"test\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); @@ -106,9 +106,9 @@ void oneOfZero() { + " \"test\" : 1\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.oneOf", assertions.get(0).getEvaluationPath().toString()); @@ -304,7 +304,7 @@ void oneOfDiscriminatorEnabled() { JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); String inputData = "{}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); } @@ -362,7 +362,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " \"type\": \"number\",\r\n" + " \"value\": 1\r\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); // Invalid only 1 message returned for number @@ -370,13 +370,13 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " \"type\": \"number\",\r\n" + " \"value\": {}\r\n" + "}"; - List messages2 = schema.validate(inputData2, InputFormat.JSON); + List messages2 = schema.validate(inputData2, InputFormat.JSON); assertEquals(2, messages2.size()); // Invalid both messages for string and object returned JsonSchema schema2 = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); - List messages3 = schema2.validate(inputData2, InputFormat.JSON); + List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); } @@ -450,7 +450,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " \"type\": \"number\",\r\n" + " \"value\": 1\r\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); // Invalid only 1 message returned for number @@ -458,13 +458,13 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " \"type\": \"number\",\r\n" + " \"value\": {}\r\n" + "}"; - List messages2 = schema.validate(inputData2, InputFormat.JSON); + List messages2 = schema.validate(inputData2, InputFormat.JSON); assertEquals(2, messages2.size()); // Invalid both messages for string and object returned JsonSchema schema2 = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); - List messages3 = schema2.validate(inputData2, InputFormat.JSON); + List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); } @@ -492,8 +492,8 @@ void walkValidationWithNullNodeShouldNotValidate() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); - result.getValidationMessages().forEach(m -> System.out.println(m)); - assertEquals(true, result.getValidationMessages().isEmpty()); + result.getErrors().forEach(m -> System.out.println(m)); + assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 98606325c..8017606ed 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -43,7 +43,7 @@ private void runTestFile(String testCaseFile) throws Exception { configBuilder.discriminatorKeywordEnabled(true); JsonSchema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); - List errors = new ArrayList(schema.validate(node)); + List errors = new ArrayList(schema.validate(node)); if (test.get("valid").asBoolean()) { if (!errors.isEmpty()) { @@ -51,7 +51,7 @@ private void runTestFile(String testCaseFile) throws Exception { System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors:"); - for (ValidationMessage error : errors) { + for (Error error : errors) { System.out.println(error); } } @@ -68,7 +68,7 @@ private void runTestFile(String testCaseFile) throws Exception { System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors: " + errors); - for (ValidationMessage error : errors) { + for (Error error : errors) { System.out.println(error); } assertEquals(errorCount.asInt(), errors.size(), "expected error count"); diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index dcd56dcc7..6b1008132 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -38,7 +38,7 @@ void testInvalidJson() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaInputStream, config); JsonNode node = getJsonNodeFromJsonData("/data/output-format-input.json"); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(3, errors.size()); Set messages = errors.stream().map(m -> new String[] { m.getEvaluationPath().toString(), @@ -53,8 +53,8 @@ void testInvalidJson() throws Exception { new String[] { "/items/$ref/required", "https://example.com/polygon#/$defs/point/required", "/1", "/1: required property 'y' not found"})); } - public static class Detailed implements OutputFormat> { - private ValidationMessage format(ValidationMessage message) { + public static class Detailed implements OutputFormat> { + private Error format(Error message) { Supplier messageSupplier = () -> { StringBuilder builder = new StringBuilder(); builder.append("["); @@ -72,7 +72,7 @@ private ValidationMessage format(ValidationMessage message) { return builder.toString(); }; - return ValidationMessage.builder() + return Error.builder() .messageSupplier(new CachingSupplier<>(messageSupplier)) .evaluationPath(message.getEvaluationPath()) .instanceLocation(message.getInstanceLocation()) @@ -84,13 +84,13 @@ private ValidationMessage format(ValidationMessage message) { } @Override - public java.util.List format(JsonSchema jsonSchema, + public java.util.List format(JsonSchema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return executionContext.getErrors().stream().map(this::format).collect(Collectors.toCollection(ArrayList::new)); } } - public static final OutputFormat> DETAILED = new Detailed(); + public static final OutputFormat> DETAILED = new Detailed(); @Test void customFormat() { @@ -113,7 +113,7 @@ void customFormat() { + " \"type\": \"cat\",\n" + " \"id\": 1\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON, DETAILED).stream().collect(Collectors.toList()); + List messages = schema.validate(inputData, InputFormat.JSON, DETAILED).stream().collect(Collectors.toList()); assertEquals("[/type] with value 'cat' does not have a value in the enumeration [\"book\", \"author\"]", messages.get(0).getMessage()); assertEquals("[/id] with value '1' integer found, string expected", messages.get(1).getMessage()); } diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index 2f0f7a12c..b0cdfc2df 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -344,7 +344,7 @@ void listAssertionMapper() { assertFalse(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); Object assertion = details.getErrors().get("type"); - assertInstanceOf(ValidationMessage.class, assertion); + assertInstanceOf(Error.class, assertion); } @Test @@ -358,6 +358,6 @@ void hierarchicalAssertionMapper() { OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); assertFalse(outputUnit.isValid()); Object assertion = outputUnit.getErrors().get("type"); - assertInstanceOf(ValidationMessage.class, assertion); + assertInstanceOf(Error.class, assertion); } } diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 9f12297ac..37a456cbd 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -56,7 +56,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).metaSchema(validatorMetaSchema).build(); final JsonSchema validatorSchema = validatorFactory.getSchema(schema); - List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index a9a404e5e..7796ef238 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -23,7 +23,7 @@ private JsonNode getJsonNodeFromStreamContent(InputStream content) throws Except @Test void customMessageIsNotOverwritten() throws Exception { - List errors = validate(); + List errors = validate(); Map errorMsgMap = transferErrorMsg(errors); Assertions.assertTrue(errorMsgMap.containsKey("$.toplevel[1].foos"), "error message must contains key: $.foos"); Assertions.assertTrue(errorMsgMap.containsKey("$.toplevel[1].bars"), "error message must contains key: $.bars"); @@ -32,7 +32,7 @@ void customMessageIsNotOverwritten() throws Exception { } - private List validate() throws Exception { + private List validate() throws Exception { String schemaPath = "/schema/OverwritingCustomMessageBug.json"; String dataPath = "/data/OverwritingCustomMessageBug.json"; InputStream schemaInputStream = OverwritingCustomMessageBugTest.class.getResourceAsStream(schemaPath); @@ -42,9 +42,9 @@ private List validate() throws Exception { return schema.validate(node); } - private Map transferErrorMsg(List validationMessages) { + private Map transferErrorMsg(List errors) { Map pathToMessage = new HashMap<>(); - validationMessages.forEach(msg -> { + errors.forEach(msg -> { pathToMessage.put(msg.getInstanceLocation().toString(), msg.toString()); }); return pathToMessage; diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 63dc09411..649ace3da 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -45,7 +45,7 @@ void testInvalidPatternPropertiesValidator() throws Exception { JsonSchema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(errors.size(), 0); }); } @@ -60,7 +60,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { JsonSchema schema = factory.getSchema("{\"patternProperties\":6}", config); JsonNode node = getJsonNodeFromStringContent(""); - List errors = schema.validate(node); + List errors = schema.validate(node); Assertions.assertEquals(errors.size(), 0); }); } @@ -87,9 +87,9 @@ void message() { + " \"valid_string\": \"string_value\",\n" + " \"valid_key\": 5\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/patternProperties/^valid_/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/patternProperties/^valid_/type", message.getSchemaLocation().toString()); assertEquals("/valid_key", message.getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index fb2f9a6a9..2bf0a6794 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -57,9 +57,9 @@ void messageInvalid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/prefixItems/0/type", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/prefixItems/0/type", message.getSchemaLocation().toString()); assertEquals("/0", message.getInstanceLocation().toString()); @@ -83,7 +83,7 @@ void messageValid() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -102,9 +102,9 @@ void messageInvalidAdditionalItems() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1, 2]"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/items", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/items", message.getSchemaLocation().toString()); assertEquals("", message.getInstanceLocation().toString()); @@ -137,7 +137,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -148,7 +148,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes }).build(); JsonSchema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -193,7 +193,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -206,7 +206,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonSchema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null]"); ValidationResult result = schema.walk(input, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index b9de07034..e0a6c3ad9 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -21,7 +21,7 @@ void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exceptio JsonSchema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}", schemaValidatorsConfig); JsonNode node = getJsonNodeFromStringContent("{\"foo\": \"bar\"}"); ValidationResult result = schema.walk(node, true); - Assertions.assertEquals(result.getValidationMessages().size(), 1); + Assertions.assertEquals(result.getErrors().size(), 1); }); } } diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 2ab459ed7..86db1f688 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -45,9 +45,9 @@ void messageInvalid() { + " \"foo\": {},\r\n" + " \"foobar\": {}\r\n" + "}"; - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); - ValidationMessage message = messages.iterator().next(); + Error message = messages.iterator().next(); assertEquals("/propertyNames", message.getEvaluationPath().toString()); assertEquals("https://www.example.org/schema#/propertyNames", message.getSchemaLocation().toString()); assertEquals("", message.getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 93d48bf7e..df1785fe8 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -19,14 +19,14 @@ class ReadOnlyValidatorTest { @Test void givenConfigWriteFalseWhenReadOnlyTrueThenAllows() throws IOException { ObjectNode node = getJsonNode(); - List errors = loadJsonSchema(false).validate(node); + List errors = loadJsonSchema(false).validate(node); assertTrue(errors.isEmpty()); } @Test void givenConfigWriteTrueWhenReadOnlyTrueThenDenies() throws IOException { ObjectNode node = getJsonNode(); - List errors = loadJsonSchema(true).validate(node); + List errors = loadJsonSchema(true).validate(node); assertFalse(errors.isEmpty()); assertEquals("/firstName: is a readonly field, it cannot be changed", errors.stream().map(e -> e.toString()).collect(Collectors.toList()).get(0)); diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 6ad35635e..c88caf4f6 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -26,9 +26,9 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { + " }\r\n" + "}"; assertEquals(SchemaId.V4, schema.getValidationContext().getMetaSchema().getIri()); - List errors = schema.validate(OBJECT_MAPPER.readTree(input)); + List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); - ValidationMessage error = errors.iterator().next(); + Error error = errors.iterator().next(); assertEquals("classpath:///schema/ref-ref.json#/definitions/DriverProperties/required", error.getSchemaLocation().toString()); assertEquals("/properties/DriverProperties/properties/CommonProperties/$ref/required", @@ -49,9 +49,9 @@ void shouldLoadSchemaResource() throws JsonProcessingException { + " }\r\n" + "}"; assertEquals(SchemaId.V4, schema.getValidationContext().getMetaSchema().getIri()); - List errors = schema.validate(OBJECT_MAPPER.readTree(input)); + List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); - ValidationMessage error = errors.iterator().next(); + Error error = errors.iterator().next(); assertEquals("https://www.example.org/common#/definitions/DriverProperties/required", error.getSchemaLocation().toString()); assertEquals("/properties/DriverProperties/properties/CommonProperties/$ref/required", diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 6f15bd19f..bcc05c25a 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -44,7 +44,7 @@ void resolveSamePathDotSlash() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); - List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); + List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -63,7 +63,7 @@ void resolveSamePath() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); - List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); + List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -82,7 +82,7 @@ void resolveParent() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); - List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); + List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -101,7 +101,7 @@ void resolveComplex() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); - List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); + List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 599b87831..589e77202 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -62,9 +62,9 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); assertEquals(messages.size(), 2); - ValidationMessage message = messages.get(0); + Error message = messages.get(0); assertEquals("/required", message.getEvaluationPath().toString()); assertEquals("amount", message.getProperty()); message = messages.get(1); @@ -106,9 +106,9 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); assertEquals(messages.size(), 2); - ValidationMessage message = messages.get(0); + Error message = messages.get(0); assertEquals("/required", message.getEvaluationPath().toString()); assertEquals("description", message.getProperty()); message = messages.get(1); @@ -150,7 +150,7 @@ void validateRequestRequired() { + " \"amount\":10,\r\n" + " \"description\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); assertEquals(messages.size(), 0); } @@ -188,7 +188,7 @@ void validateResponseRequired() { + " \"description\":\"world\",\r\n" + " \"name\":\"hello\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); assertEquals(messages.size(), 0); } } diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index 650008220..fe03bf0fc 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -31,7 +31,7 @@ void schemaFromSchemaLocationMapping() { * initializeValidators() */ schemaFromSchemaLocation.initializeValidators(); - List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, + List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(1, errors.size()); } @@ -54,7 +54,7 @@ void schemaFromSchemaLocationContent() { * initializeValidators() */ schemaFromSchemaLocation.initializeValidators(); - List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, + List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(1, errors.size()); } @@ -75,7 +75,7 @@ void schemaFromClasspath() { * initializeValidators() */ schemaFromClasspath.initializeValidators(); - List errors = schemaFromClasspath.validate("{\"id\": \"2\"}", InputFormat.JSON, + List errors = schemaFromClasspath.validate("{\"id\": \"2\"}", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(1, errors.size()); } @@ -91,7 +91,7 @@ void schemaFromString() { */ JsonSchema schemaFromString = factory .getSchema("{\"enum\":[1, 2, 3, 4]}"); - List errors = schemaFromString.validate("7", InputFormat.JSON, + List errors = schemaFromString.validate("7", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(1, errors.size()); } @@ -117,7 +117,7 @@ void schemaFromJsonNode() throws JsonProcessingException { * initializeValidators() */ schemaFromNode.initializeValidators(); - List errors = schemaFromNode.validate("{\"id\": \"2\"}", InputFormat.JSON, + List errors = schemaFromNode.validate("{\"id\": \"2\"}", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(1, errors.size()); } diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index f8663039b..382881156 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -220,7 +220,7 @@ void shouldLoadEscapedFragment() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); JsonSchema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); - List result = schema.validate("1", InputFormat.JSON); + List result = schema.validate("1", InputFormat.JSON); assertFalse(result.isEmpty()); result = schema.validate("{}", InputFormat.JSON); assertTrue(result.isEmpty()); diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index a7f469006..636b4fa44 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -24,7 +24,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index ac18a7dc9..f84684977 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -68,7 +68,7 @@ void testTypeLoose() { + " \"array_of_objects\": {}\r\n" + "}"; // Without type loose this has 2 type errors - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); @@ -102,7 +102,7 @@ void integer() { + " \"type\": \"integer\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate("1", InputFormat.JSON); + List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); assertEquals(0, messages.size()); @@ -131,7 +131,7 @@ void integerDraft4() { + " \"type\": \"integer\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V4).getSchema(schemaData); - List messages = schema.validate("1", InputFormat.JSON); + List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling messages = schema.validate("2.0", InputFormat.JSON); @@ -147,7 +147,7 @@ void walkNull() { + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V4).getSchema(schemaData); ValidationResult result = schema.walk(null, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); } @Test @@ -178,7 +178,7 @@ void nullable() { .nullableKeywordEnabled(false) .build()); - final List errors = validator.validate(inputData, InputFormat.JSON); + final List errors = validator.validate(inputData, InputFormat.JSON); assertEquals(1, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index 0d2f8b2a4..eee96813b 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -44,9 +44,9 @@ void unevaluatedItemsFalse() { + "}"; String inputData = "[1,2,3]"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("unevaluatedItems", assertions.get(0).getKeyword()); assertEquals("$", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems", assertions.get(0).getEvaluationPath().toString()); @@ -70,9 +70,9 @@ void unevaluatedItemsSchema() { + "}"; String inputData = "[1,2,3]"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("type", assertions.get(0).getKeyword()); assertEquals("$[1]", assertions.get(0).getInstanceLocation().toString()); assertEquals("$.unevaluatedItems.type", assertions.get(0).getEvaluationPath().toString()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 908bd3406..86c534bcf 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -62,9 +62,9 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key4\": \"value4\"\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("required", assertions.get(0).getKeyword()); assertEquals("key1", assertions.get(0).getProperty()); assertEquals("unevaluatedProperties", assertions.get(1).getKeyword()); @@ -117,9 +117,9 @@ void subschemaProcessing() { + " }\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("additionalProperties", assertions.get(0).getKeyword()); assertEquals("notallowed", assertions.get(0).getProperty()); } @@ -145,9 +145,9 @@ void unevaluatedPropertiesSchema() { + " }\r\n" + "}"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); - List assertions = messages.stream().collect(Collectors.toList()); + List assertions = messages.stream().collect(Collectors.toList()); assertEquals("type", assertions.get(0).getKeyword()); assertEquals("$.unevaluatedProperties.type", assertions.get(0).getEvaluationPath().toString()); } @@ -190,7 +190,7 @@ void ref() { + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index dc4688053..d838163cc 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -24,8 +24,8 @@ void testSchema1() throws IOException { JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); JsonSchema jsonSchema = factory.getSchema(schema1); - List errors = jsonSchema.validate(jsonNode); - for(ValidationMessage error:errors) { + List errors = jsonSchema.validate(jsonNode); + for(Error error:errors) { System.out.println(error.getMessage()); } } @@ -38,8 +38,8 @@ void testSchema2() throws IOException { JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); JsonSchema jsonSchema = factory.getSchema(schema2); - List errors = jsonSchema.validate(jsonNode); - for(ValidationMessage error:errors) { + List errors = jsonSchema.validate(jsonNode); + for(Error error:errors) { System.out.println(error.getMessage()); } } @@ -51,8 +51,8 @@ void testSchema3() throws IOException { JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); JsonSchema jsonSchema = factory.getSchema(schema3); - List errors = jsonSchema.validate(jsonNode); - for(ValidationMessage error:errors) { + List errors = jsonSchema.validate(jsonNode); + for(Error error:errors) { System.out.println(error.getMessage()); } } diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index fca017322..427ee98e6 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -48,7 +48,7 @@ void testLoadingWithId() throws Exception { */ @Test void testFailFast_AllErrors() throws IOException { - List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", + List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-all-errors-data.json"); assertEquals(1, messages.size()); } @@ -58,7 +58,7 @@ void testFailFast_AllErrors() throws IOException { */ @Test void testFailFast_OneErrors() throws IOException { - List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", + List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-one-error-data.json"); assertEquals(1, messages.size()); } @@ -68,23 +68,23 @@ void testFailFast_OneErrors() throws IOException { */ @Test void testFailFast_TwoErrors() throws IOException { - List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", + List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-two-errors-data.json"); assertEquals(1, messages.size()); } /** * The file contains no errors, in ths case - * {@link Set}<{@link ValidationMessage}> must be empty + * {@link Set}<{@link Error}> must be empty */ @Test void testFailFast_NoErrors() throws IOException { - final List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", + final List messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-no-errors-data.json"); assertTrue(messages.isEmpty()); } - private List validateFailingFastSchemaFor(final String schemaFileName, final String dataFileName) throws IOException { + private List validateFailingFastSchemaFor(final String schemaFileName, final String dataFileName) throws IOException { final ObjectMapper objectMapper = new ObjectMapper(); final JsonNode schema = getJsonNodeFromResource(objectMapper, schemaFileName); final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 6b9b796a0..2b63e1654 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -68,7 +68,7 @@ void noValidation() { + " \"numberProperty\": 1\r\n" + "}"; - List messages = schema.validate(inputDataNoValidation, InputFormat.JSON); + List messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(0, messages.size()); // Set validation vocab @@ -120,7 +120,7 @@ void noFormatValidation() { + " \"dateProperty\": \"hello\"\r\n" + "}"; - List messages = schema.validate(inputDataNoValidation, InputFormat.JSON, + List messages = schema.validate(inputDataNoValidation, InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index 497604b6d..1a91eb897 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; class IriFormatTest { @Test @@ -38,7 +38,7 @@ void uriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -51,7 +51,7 @@ void queryWithBracketsShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -64,7 +64,7 @@ void queryWithEncodedBracketsShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -77,7 +77,7 @@ void iriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", + List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -90,7 +90,7 @@ void noAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -102,7 +102,7 @@ void noSchemeNoAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -114,7 +114,7 @@ void noPathShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index b541ee3fc..94e27201c 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; class IriReferenceFormatTest { @Test @@ -38,7 +38,7 @@ void uriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -51,7 +51,7 @@ void queryWithBracketsShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -64,7 +64,7 @@ void queryWithEncodedBracketsShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -77,7 +77,7 @@ void iriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", + List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -90,7 +90,7 @@ void noAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -102,7 +102,7 @@ void noSchemeNoAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -114,7 +114,7 @@ void noPathShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index 373e660c0..e42976798 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; class TimeFormatTest { @@ -61,7 +61,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -90,7 +90,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index 02edd5cf2..2976f6cfa 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; class UriFormatTest { @Test @@ -38,7 +38,7 @@ void uriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -51,7 +51,7 @@ void queryWithBracketsShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -64,7 +64,7 @@ void queryWithEncodedBracketsShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -77,7 +77,7 @@ void iriShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", + List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -90,7 +90,7 @@ void noAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -102,7 +102,7 @@ void noSchemeNoAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -114,7 +114,7 @@ void noPathShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index 00c8b855e..d62bcd842 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; class UriReferenceFormatTest { @Test @@ -38,7 +38,7 @@ void uriShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -51,7 +51,7 @@ void queryWithBracketsShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -64,7 +64,7 @@ void queryWithEncodedBracketsShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", + List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -77,7 +77,7 @@ void iriShouldFail() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", + List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); } @@ -90,7 +90,7 @@ void noAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -102,7 +102,7 @@ void noSchemeNoAuthorityShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -114,7 +114,7 @@ void noPathShouldPass() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 82de4ffe3..4153831a2 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -33,7 +33,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * OpenApi30Test. @@ -54,7 +54,7 @@ void validateMetaSchema() { + " \"petType\": \"dog\",\r\n" + " \"bark\": \"woof\"\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); + List messages = schema.validate(input, InputFormat.JSON); assertEquals(0, messages.size()); String invalid = "{\r\n" @@ -63,7 +63,7 @@ void validateMetaSchema() { + "}"; messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 2dc7784b9..058315330 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -28,7 +28,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; /** * OpenApi31Test. @@ -48,7 +48,7 @@ void validateVocabulary() { + " \"petType\": \"dog\",\r\n" + " \"bark\": \"woof\"\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); + List messages = schema.validate(input, InputFormat.JSON); assertEquals(0, messages.size()); String invalid = "{\r\n" @@ -57,7 +57,7 @@ void validateVocabulary() { + "}"; messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); @@ -77,7 +77,7 @@ void validateMetaSchema() { + " \"petType\": \"dog\",\r\n" + " \"bark\": \"woof\"\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); + List messages = schema.validate(input, InputFormat.JSON); assertEquals(0, messages.size()); String invalid = "{\r\n" @@ -86,7 +86,7 @@ void validateMetaSchema() { + "}"; messages = schema.validate(invalid, InputFormat.JSON); assertEquals(2, messages.size()); - List list = messages.stream().collect(Collectors.toList()); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("bark", list.get(1).getProperty()); @@ -108,8 +108,8 @@ void discriminatorOneOfMultipleMatchShouldFail() { + " \"bark\": \"woof\",\r\n" + " \"lovesRocks\": true\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); - List list = messages.stream().collect(Collectors.toList()); + List messages = schema.validate(input, InputFormat.JSON); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); } @@ -127,8 +127,8 @@ void discriminatorOneOfNoMatchShouldFail() { + " \"petType\": \"lizard\",\r\n" + " \"none\": true\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); - List list = messages.stream().collect(Collectors.toList()); + List messages = schema.validate(input, InputFormat.JSON); + List list = messages.stream().collect(Collectors.toList()); assertEquals("oneOf", list.get(0).getKeyword()); assertEquals("required", list.get(1).getKeyword()); assertEquals("lovesRocks", list.get(1).getProperty()); @@ -149,7 +149,7 @@ void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { + " \"petType\": \"dog\",\r\n" + " \"lovesRocks\": true\r\n" + "}"; - List messages = schema.validate(input, InputFormat.JSON); + List messages = schema.validate(input, InputFormat.JSON); assertEquals(0, messages.size()); } diff --git a/src/test/java/com/networknt/schema/output/OutputUnitDataTest.java b/src/test/java/com/networknt/schema/output/OutputUnitDataTest.java deleted file mode 100644 index 098ba11ae..000000000 --- a/src/test/java/com/networknt/schema/output/OutputUnitDataTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.output; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -/** - * OutputUnitDataTest. - */ -class OutputUnitDataTest { - - @Test - void format() { - String result = OutputUnitData.formatMessage("hello:"); - assertEquals("", result); - result = OutputUnitData.formatMessage("hello: "); - assertEquals("", result); - result = OutputUnitData.formatMessage("hello: "); - assertEquals("", result); - result = OutputUnitData.formatMessage("hello: world"); - assertEquals("world", result); - } -} diff --git a/src/test/java/com/networknt/schema/suite/TestSpec.java b/src/test/java/com/networknt/schema/suite/TestSpec.java index 0b03625c7..6d8f73bb4 100644 --- a/src/test/java/com/networknt/schema/suite/TestSpec.java +++ b/src/test/java/com/networknt/schema/suite/TestSpec.java @@ -56,7 +56,7 @@ public class TestSpec { * This is an extension of the schema used to describe tests in the compliance suite *

*/ - private final Set validationMessages; + private final Set errors; /** * Indicates whether this test should be executed @@ -120,7 +120,7 @@ public class TestSpec { * @param data The instance which should be validated against the schema in "schema" (Required) * @param valid Whether the validation process of this instance should consider the instance valid or not (Required) * @param strictness A mapping of how strict a keyword's validators should be. - * @param validationMessages A sequence of validation messages expected from testing data against the schema + * @param errors A sequence of validation messages expected from testing data against the schema * @param disabled Indicates whether this test should be executed (Defaults to FALSE) * @param isTypeLoose Indicates whether the test should consider a strict definition of an enum (Defaults to FALSE) */ @@ -132,7 +132,7 @@ public TestSpec( @JsonProperty("data") JsonNode data, @JsonProperty("valid") boolean valid, @JsonProperty("strictness") Map strictness, - @JsonProperty("validationMessages") Set validationMessages, + @JsonProperty("errors") Set errors, @JsonProperty("isTypeLoose") Boolean isTypeLoose, @JsonProperty("disabled") Boolean disabled, @JsonProperty("reason") String reason, @@ -143,7 +143,7 @@ public TestSpec( this.config = config; this.data = data; this.valid = valid; - this.validationMessages = validationMessages; + this.errors = errors; this.disabled = Boolean.TRUE.equals(disabled); this.reason = reason; this.typeLoose = Boolean.TRUE.equals(isTypeLoose); @@ -237,8 +237,8 @@ public Map getStrictness() { * * @return a non-null list of expected validation messages */ - public Set getValidationMessages() { - return new HashSet<>(null != this.validationMessages ? this.validationMessages : Collections.emptySet()); + public Set getErrors() { + return new HashSet<>(null != this.errors ? this.errors : Collections.emptySet()); } /** diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index b5892bb9c..6d696b6ff 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -36,7 +36,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.serialization.JsonNodeReader; import com.networknt.schema.serialization.node.LocationJsonNodeFactoryFactory; @@ -91,14 +91,14 @@ void jsonLocation() { builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, InputFormat.JSON, config); - List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { + List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); - List list = messages.stream().collect(Collectors.toList()); - ValidationMessage format = list.get(0); + List list = messages.stream().collect(Collectors.toList()); + Error format = list.get(0); JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(format.getInstanceNode()); JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(format.getSchemaNode()); - ValidationMessage minLength = list.get(1); + Error minLength = list.get(1); JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); @@ -137,14 +137,14 @@ void yamlLocation() { builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, InputFormat.YAML, config); - List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { + List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); - List list = messages.stream().collect(Collectors.toList()); - ValidationMessage format = list.get(0); + List list = messages.stream().collect(Collectors.toList()); + Error format = list.get(0); JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(format.getInstanceNode()); JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(format.getSchemaNode()); - ValidationMessage minLength = list.get(1); + Error minLength = list.get(1); JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index f8f4db5d0..42e77d3f2 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -49,7 +49,7 @@ import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; import com.networknt.schema.utils.JsonSchemaRefs; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Error; import com.networknt.schema.ValidationResult; import com.networknt.schema.ValidatorTypeCode; @@ -100,7 +100,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -118,7 +118,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes + " ]\r\n" + "}"; ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List propertyKeywords = (List) result.getExecutionContext().getCollectorContext().get("propertyKeywords"); assertEquals(3, propertyKeywords.size()); @@ -180,7 +180,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -198,7 +198,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes + " ]\r\n" + "}"; ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List properties = (List) result.getExecutionContext().getCollectorContext().get("properties"); @@ -266,7 +266,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); @@ -283,7 +283,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes + " ]\r\n" + "}"; ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -339,7 +339,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); @@ -356,7 +356,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes + " ]\r\n" + "}"; ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -387,7 +387,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -409,7 +409,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes + " }\r\n" + "}"; ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List propertyKeywords = (List) result.getExecutionContext().getCollectorContext().getCollectorMap().get("propertyKeywords"); @@ -559,7 +559,7 @@ void applyDefaults() throws JsonProcessingException { JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); } @Test @@ -607,7 +607,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -616,7 +616,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); } @Test @@ -664,7 +664,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -673,12 +673,12 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); - assertFalse(result.getValidationMessages().isEmpty()); + assertFalse(result.getErrors().isEmpty()); inputNode = JsonMapperFactory.getInstance().readTree("{}"); result = schema.walk(inputNode, false); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); } @Test @@ -732,7 +732,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -740,7 +740,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); - assertFalse(result.getValidationMessages().isEmpty()); + assertFalse(result.getErrors().isEmpty()); assertEquals("{\"type\":\"integer\"}", missingSchemaNode.get("s").toString()); assertEquals("{\"type\":\"string\"}", missingSchemaNode.get("ref").toString()); } @@ -802,7 +802,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); @@ -811,7 +811,7 @@ public void onWalkEnd(WalkEvent walkEvent, List validationMes JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); - assertTrue(result.getValidationMessages().isEmpty()); + assertTrue(result.getErrors().isEmpty()); } /** @@ -845,7 +845,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() @@ -908,7 +908,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { } @Override - public void onWalkEnd(WalkEvent walkEvent, List validationMessages) { + public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() diff --git a/src/test/resources/draft2019-09/invalid-min-max-contains.json b/src/test/resources/draft2019-09/invalid-min-max-contains.json index 17fa59c3f..8acbb8664 100644 --- a/src/test/resources/draft2019-09/invalid-min-max-contains.json +++ b/src/test/resources/draft2019-09/invalid-min-max-contains.json @@ -10,7 +10,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":\"1\"}" ] } @@ -27,7 +27,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":0.5}" ] } @@ -44,7 +44,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":-1}" ] } @@ -61,7 +61,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":\"1\"}" ] } @@ -78,7 +78,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0.5}" ] } @@ -95,7 +95,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":-1}" ] } @@ -113,7 +113,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}", ": minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}" ] diff --git a/src/test/resources/draft2020-12/invalid-min-max-contains.json b/src/test/resources/draft2020-12/invalid-min-max-contains.json index 84fae3cec..8b35ce883 100644 --- a/src/test/resources/draft2020-12/invalid-min-max-contains.json +++ b/src/test/resources/draft2020-12/invalid-min-max-contains.json @@ -10,7 +10,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":\"1\"}" ] } @@ -27,7 +27,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":0.5}" ] } @@ -44,7 +44,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":-1}" ] } @@ -61,7 +61,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":\"1\"}" ] } @@ -78,7 +78,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0.5}" ] } @@ -95,7 +95,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":-1}" ] } @@ -113,7 +113,7 @@ "description": "should fail", "data": [], "valid": false, - "validationMessages": [ + "errors": [ ": minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}", ": minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}" ] diff --git a/src/test/resources/draft2020-12/issue656.json b/src/test/resources/draft2020-12/issue656.json index e46dd6cbd..fc012ce0f 100644 --- a/src/test/resources/draft2020-12/issue656.json +++ b/src/test/resources/draft2020-12/issue656.json @@ -154,7 +154,7 @@ "followup-treatments": [] }, "valid": false, - "validationMessages": [ + "errors": [ ": must be valid to one and only one schema, but 2 are valid with indexes '0, 1'" ] } diff --git a/src/test/resources/draft2020-12/issue798.json b/src/test/resources/draft2020-12/issue798.json index 20d500336..b5875ff29 100644 --- a/src/test/resources/draft2020-12/issue798.json +++ b/src/test/resources/draft2020-12/issue798.json @@ -22,21 +22,21 @@ "data": { "a": "a string", "b": "a string" }, "valid": false, "config": { "readOnly": true, "writeOnly": true }, - "validationMessages": [ "/b: is a readonly field, it cannot be changed" ] + "errors": [ "/b: is a readonly field, it cannot be changed" ] }, { "description": "write-only behavior", "data": { "a": "a string", "c": "a string" }, "valid": false, "config": { "readOnly": true, "writeOnly": true }, - "validationMessages": [ "/c: is a write-only field, it cannot appear in the data" ] + "errors": [ "/c: is a write-only field, it cannot appear in the data" ] }, { "description": "both behavior", "data": { "a": "a string", "d": "a string" }, "valid": false, "config": { "readOnly": true, "writeOnly": true }, - "validationMessages": [ + "errors": [ "/d: is a readonly field, it cannot be changed", "/d: is a write-only field, it cannot appear in the data" ] diff --git a/src/test/resources/draft4/issue425.json b/src/test/resources/draft4/issue425.json index c9c614337..20e1d6e91 100644 --- a/src/test/resources/draft4/issue425.json +++ b/src/test/resources/draft4/issue425.json @@ -34,7 +34,7 @@ "values": 3 }, "valid": false, - "validationMessages": [ + "errors": [ "/values: must be valid to one and only one schema, but 0 are valid", "/values: integer found, array expected", "/values: integer found, string expected" diff --git a/src/test/resources/draft7/issue470.json b/src/test/resources/draft7/issue470.json index d5ced20c4..7956a85f3 100644 --- a/src/test/resources/draft7/issue470.json +++ b/src/test/resources/draft7/issue470.json @@ -83,7 +83,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: must be valid to one and only one schema, but 0 are valid", "/search: property 'byName' is not defined in the schema and the schema does not allow additional properties", "/search/byName/name: integer found, string expected" @@ -99,7 +99,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: must be valid to one and only one schema, but 0 are valid", "/search: property 'byName' is not defined in the schema and the schema does not allow additional properties", "/search/byName/name: must be at most 20 characters long" @@ -115,7 +115,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: must be valid to one and only one schema, but 0 are valid", "/search/byAge/age: string found, integer expected", "/search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" @@ -131,7 +131,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: must be valid to one and only one schema, but 0 are valid", "/search/byAge/age: must have a maximum value of 150", "/search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" diff --git a/src/test/resources/draft7/issue491.json b/src/test/resources/draft7/issue491.json index 68562bdb5..f52f0334d 100644 --- a/src/test/resources/draft7/issue491.json +++ b/src/test/resources/draft7/issue491.json @@ -81,7 +81,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: required property 'name' not found", "/search/searchAge/age: string found, integer expected", "/search: must be valid to one and only one schema, but 0 are valid" @@ -95,7 +95,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search/name: integer found, string expected", "/search: required property 'searchAge' not found", "/search: must be valid to one and only one schema, but 0 are valid" @@ -183,7 +183,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: required property 'name' not found", "/search/byAge/age: string found, integer expected", "/search: must be valid to one and only one schema, but 0 are valid" @@ -197,7 +197,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search/name: integer found, string expected", "/search: required property 'byAge' not found", "/search: must be valid to one and only one schema, but 0 are valid" @@ -275,7 +275,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: required property 'name' not found", "/search/age: string found, integer expected", "/search: must be valid to one and only one schema, but 0 are valid" @@ -289,7 +289,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search/name: integer found, string expected", "/search: required property 'age' not found", "/search: must be valid to one and only one schema, but 0 are valid" @@ -303,7 +303,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search: required property 'name' not found", "/search/age: must have a maximum value of 150", "/search: must be valid to one and only one schema, but 0 are valid" @@ -317,7 +317,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/search/name: must be at most 20 characters long", "/search: required property 'age' not found", "/search: must be valid to one and only one schema, but 0 are valid" diff --git a/src/test/resources/draft7/issue516.json b/src/test/resources/draft7/issue516.json index 9556574b0..dd0a10c81 100644 --- a/src/test/resources/draft7/issue516.json +++ b/src/test/resources/draft7/issue516.json @@ -118,7 +118,7 @@ ] }, "valid": false, - "validationMessages": [ + "errors": [ "/activities/0: must be valid to one and only one schema, but 0 are valid", "/activities/0: property 'age' is not defined in the schema and the schema does not allow additional properties", "/activities/0: required property 'chemicalCharacteristic' not found", diff --git a/src/test/resources/draft7/issue653.json b/src/test/resources/draft7/issue653.json index 6e7f7180b..9d14f2717 100644 --- a/src/test/resources/draft7/issue653.json +++ b/src/test/resources/draft7/issue653.json @@ -79,7 +79,7 @@ ] }, "valid": false, - "validationMessages": [ + "errors": [ "/pets/0: must be valid to one and only one schema, but 0 are valid", "/pets/0: required property 'age' not found", "/pets/0: schema for 'else' is false" diff --git a/src/test/resources/draft7/issue678.json b/src/test/resources/draft7/issue678.json index d743f6263..08603efe6 100644 --- a/src/test/resources/draft7/issue678.json +++ b/src/test/resources/draft7/issue678.json @@ -48,7 +48,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/outerObject/innerObject: object found, string expected", "/outerObject/innerObject: required property 'value' not found", "/outerObject/innerObject: required property 'unit' not found", diff --git a/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json b/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json index a8df5a767..9464fb320 100644 --- a/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json +++ b/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json @@ -56,7 +56,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/bar: integer found, string expected" ] }, @@ -70,7 +70,7 @@ "bar": "Bar 1" }, "valid": false, - "validationMessages": [ + "errors": [ "/foo/2: string found, number expected" ] }, @@ -84,7 +84,7 @@ "bar": "Bar 1" }, "valid": false, - "validationMessages": [ + "errors": [ "/foo: must have at most 3 items but found 4" ] }, @@ -98,7 +98,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/foo/2: string found, number expected", "/bar: integer found, string expected" ] @@ -113,7 +113,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/foo: must have at most 3 items but found 4", "/foo/2: string found, number expected", "/bar: integer found, string expected" diff --git a/src/test/resources/schema/customMessageTests/custom-message-tests.json b/src/test/resources/schema/customMessageTests/custom-message-tests.json index fa92002d9..1dd846514 100644 --- a/src/test/resources/schema/customMessageTests/custom-message-tests.json +++ b/src/test/resources/schema/customMessageTests/custom-message-tests.json @@ -50,7 +50,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/bar: Custom Message: Invalid type provided" ] }, @@ -64,7 +64,7 @@ "bar": "Bar 1" }, "valid": false, - "validationMessages": [ + "errors": [ "/foo/2: Custom Message: Only numbers are supported in 'foo'" ] }, @@ -78,7 +78,7 @@ "bar": "Bar 1" }, "valid": false, - "validationMessages": [ + "errors": [ "/foo: Custom Message: Maximum 3 numbers can be given in 'foo'" ] }, @@ -92,7 +92,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/bar: Custom Message: Invalid type provided", "/foo/2: Custom Message: Only numbers are supported in 'foo'" ] @@ -107,7 +107,7 @@ "bar": 123 }, "valid": false, - "validationMessages": [ + "errors": [ "/bar: Custom Message: Invalid type provided", "/foo/2: Custom Message: Only numbers are supported in 'foo'", "/foo: Custom Message: Maximum 3 numbers can be given in 'foo'" @@ -146,7 +146,7 @@ "foo": 1 }, "valid": false, - "validationMessages": [ + "errors": [ ": 'bar' is required" ] }, @@ -159,7 +159,7 @@ "bar": "bar" }, "valid": false, - "validationMessages": [ + "errors": [ ": 'foo' is required" ] }, @@ -171,7 +171,7 @@ "data": { }, "valid": false, - "validationMessages": [ + "errors": [ ": 'foo' is required", ": 'bar' is required" ] @@ -214,7 +214,7 @@ ] }, "valid": false, - "validationMessages": [ + "errors": [ "/requestedItems/0/item: Item should not be empty" ] } diff --git a/src/test/resources/schema/unevaluatedTests/unevaluated-tests.json b/src/test/resources/schema/unevaluatedTests/unevaluated-tests.json index 277db639f..0c9099768 100644 --- a/src/test/resources/schema/unevaluatedTests/unevaluated-tests.json +++ b/src/test/resources/schema/unevaluatedTests/unevaluated-tests.json @@ -88,7 +88,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ ": property 'invalid' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -105,7 +105,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/address: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -122,7 +122,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/address: property 'invalid2' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -141,7 +141,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/address/residence: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" ] } @@ -236,7 +236,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: property 'wheels' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -252,7 +252,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", "/vehicle: required property 'wheels' not found", "/vehicle: required property 'headlights' not found" @@ -271,7 +271,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", "/vehicle: property 'invalid' is not evaluated and the schema does not allow unevaluated properties", "/vehicle: required property 'wheels' not found", @@ -289,7 +289,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: must be valid to one and only one schema, but 0 are valid", "/vehicle: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" ] @@ -385,7 +385,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -400,7 +400,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" ] }, @@ -417,7 +417,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" ] } @@ -514,7 +514,7 @@ } }, "valid": false, - "validationMessages": [ + "errors": [ "/vehicle: required property 'wings' not found", "/vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" ] @@ -577,7 +577,7 @@ "unevaluated": true }, "valid": false, - "validationMessages": [ + "errors": [ ": property 'age' is not evaluated and the schema does not allow unevaluated properties", ": property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" ] From b58d5df40594485f714ab5f9da5aecd3403099a8 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 08:30:51 +0800 Subject: [PATCH 05/74] Rename JsonSchemaWalker to Walker --- .../networknt/schema/JsonSchemaValidator.java | 4 +-- .../schema/walk/JsonSchemaWalker.java | 29 ------------------ .../com/networknt/schema/walk/Walker.java | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 31 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/walk/JsonSchemaWalker.java create mode 100644 src/main/java/com/networknt/schema/walk/Walker.java diff --git a/src/main/java/com/networknt/schema/JsonSchemaValidator.java b/src/main/java/com/networknt/schema/JsonSchemaValidator.java index cb551a1b4..ca1eea871 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaValidator.java +++ b/src/main/java/com/networknt/schema/JsonSchemaValidator.java @@ -17,12 +17,12 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.walk.JsonSchemaWalker; +import com.networknt.schema.walk.Walker; /** * Standard json validator interface, implemented by all validators and JsonSchema. */ -public interface JsonSchemaValidator extends JsonSchemaWalker { +public interface JsonSchemaValidator extends Walker { /** * Validate the given JsonNode, the given node is the child node of the root node at given * data path. diff --git a/src/main/java/com/networknt/schema/walk/JsonSchemaWalker.java b/src/main/java/com/networknt/schema/walk/JsonSchemaWalker.java deleted file mode 100644 index 091f6f3ac..000000000 --- a/src/main/java/com/networknt/schema/walk/JsonSchemaWalker.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.networknt.schema.walk; - -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.BaseJsonValidator; -import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; - -public interface JsonSchemaWalker { - /** - * - * This method gives the capability to walk through the given JsonNode, allowing - * functionality beyond validation like collecting information,handling cross-cutting - * concerns like logging or instrumentation. This method also performs - * the validation if {@code shouldValidateSchema} is set to true.
- *
- * {@link BaseJsonValidator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)} provides - * a default implementation of this method. However, validators that parse - * sub-schemas should override this method to call walk method on those - * sub-schemas. - * - * @param executionContext ExecutionContext - * @param node JsonNode - * @param rootNode JsonNode - * @param instanceLocation JsonNodePath - * @param shouldValidateSchema boolean - */ - void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema); -} diff --git a/src/main/java/com/networknt/schema/walk/Walker.java b/src/main/java/com/networknt/schema/walk/Walker.java new file mode 100644 index 000000000..4b3042387 --- /dev/null +++ b/src/main/java/com/networknt/schema/walk/Walker.java @@ -0,0 +1,30 @@ +package com.networknt.schema.walk; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.JsonSchemaValidator; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; + +public interface Walker { + /** + * + * This method gives the capability to walk through the given JsonNode, allowing + * functionality beyond validation like collecting information,handling + * cross-cutting concerns like logging or instrumentation. This method also + * performs the validation if {@code shouldValidateSchema} is set to true.
+ *
+ * {@link JsonSchemaValidator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)} + * provides a default implementation of this method. However, validators that + * parse sub-schemas should override this method to call walk method on those + * sub-schemas. + * + * @param executionContext the execution context + * @param instanceNode the instance node being processed + * @param instance the instance document that the instance node + * belongs to + * @param instanceLocation the location of the instance node being processed + * @param shouldValidateSchema true to validate the schema while walking + */ + void walk(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, + JsonNodePath instanceLocation, boolean shouldValidateSchema); +} From a3af13bb426e1910256820f44cb23a21937c7678 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 08:37:20 +0800 Subject: [PATCH 06/74] Rename JsonSchemaValidator to Validator --- .../java/com/networknt/schema/JsonSchema.java | 2 +- .../com/networknt/schema/JsonValidator.java | 2 +- .../networknt/schema/UnionTypeValidator.java | 6 ++--- ...sonSchemaValidator.java => Validator.java} | 27 ++++++++++--------- .../com/networknt/schema/walk/Walker.java | 5 ++-- 5 files changed, 22 insertions(+), 20 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchemaValidator.java => Validator.java} (68%) diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index 5fcf49417..2710b0359 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -46,7 +46,7 @@ * JsonSchema instances are thread-safe provided its configuration is not * modified. */ -public class JsonSchema implements JsonSchemaValidator { +public class JsonSchema implements Validator { private static final long V201909_VALUE = VersionFlag.V201909.getVersionFlagValue(); private final String id; diff --git a/src/main/java/com/networknt/schema/JsonValidator.java b/src/main/java/com/networknt/schema/JsonValidator.java index d81d01bb8..b8d6069fe 100644 --- a/src/main/java/com/networknt/schema/JsonValidator.java +++ b/src/main/java/com/networknt/schema/JsonValidator.java @@ -19,7 +19,7 @@ /** * KeywordValidator interface implemented by all keyword validators. */ -public interface JsonValidator extends JsonSchemaValidator { +public interface JsonValidator extends Validator { /** * In case the {@link com.networknt.schema.JsonValidator} has a related {@link com.networknt.schema.JsonSchema} or several * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index 04ca3df9b..15ee5d9cc 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -29,7 +29,7 @@ public class UnionTypeValidator extends BaseJsonValidator implements JsonValidator { private static final Logger logger = LoggerFactory.getLogger(UnionTypeValidator.class); - private final List schemas; + private final List schemas; private final String error; public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { @@ -79,7 +79,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode List test = new ArrayList<>(); executionContext.setFailFast(false); executionContext.setErrors(test); - for (JsonSchemaValidator schema : schemas) { + for (Validator schema : schemas) { schema.validate(executionContext, node, rootNode, instanceLocation); if (test.isEmpty()) { valid = true; @@ -105,7 +105,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void preloadJsonSchema() { - for (final JsonSchemaValidator validator : schemas) { + for (final Validator validator : schemas) { if (validator instanceof JsonValidator) { ((JsonValidator) validator).preloadJsonSchema(); } else if (validator instanceof JsonSchema) { diff --git a/src/main/java/com/networknt/schema/JsonSchemaValidator.java b/src/main/java/com/networknt/schema/Validator.java similarity index 68% rename from src/main/java/com/networknt/schema/JsonSchemaValidator.java rename to src/main/java/com/networknt/schema/Validator.java index ca1eea871..4d78e278a 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaValidator.java +++ b/src/main/java/com/networknt/schema/Validator.java @@ -20,18 +20,21 @@ import com.networknt.schema.walk.Walker; /** - * Standard json validator interface, implemented by all validators and JsonSchema. + * A processor that checks an instance node belonging to an instance document + * against a schema. */ -public interface JsonSchemaValidator extends Walker { +public interface Validator extends Walker { /** - * Validate the given JsonNode, the given node is the child node of the root node at given - * data path. - * @param executionContext ExecutionContext - * @param node JsonNode - * @param rootNode JsonNode - * @param instanceLocation JsonNodePath + * Validate the instance node which belongs to the instance document at the + * instance location. + * + * @param executionContext the execution context + * @param instanceNode the instance node being processed + * @param instance the instance document that the instance node belongs + * to + * @param instanceLocation the location of the instance node being processed */ - void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + void validate(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, JsonNodePath instanceLocation); /** @@ -39,14 +42,14 @@ void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNod * validate method if shouldValidateSchema is enabled. */ @Override - default void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + default void walk(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, JsonNodePath instanceLocation, boolean shouldValidateSchema) { - if (node == null) { + if (instanceNode == null) { // Note that null is not the same as NullNode return; } if (shouldValidateSchema) { - validate(executionContext, node, rootNode, instanceLocation); + validate(executionContext, instanceNode, instance, instanceLocation); } } diff --git a/src/main/java/com/networknt/schema/walk/Walker.java b/src/main/java/com/networknt/schema/walk/Walker.java index 4b3042387..190d7ac1f 100644 --- a/src/main/java/com/networknt/schema/walk/Walker.java +++ b/src/main/java/com/networknt/schema/walk/Walker.java @@ -1,19 +1,18 @@ package com.networknt.schema.walk; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.JsonSchemaValidator; +import com.networknt.schema.Validator; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; public interface Walker { /** - * * This method gives the capability to walk through the given JsonNode, allowing * functionality beyond validation like collecting information,handling * cross-cutting concerns like logging or instrumentation. This method also * performs the validation if {@code shouldValidateSchema} is set to true.
*
- * {@link JsonSchemaValidator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)} + * {@link Validator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)} * provides a default implementation of this method. However, validators that * parse sub-schemas should override this method to call walk method on those * sub-schemas. From b2d6a14018c5e65257324d5ed4f186051c5e8ba1 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:24:49 +0800 Subject: [PATCH 07/74] Rename JsonValidator to KeywordValidator and fix class hierarchy --- ...tor.java => AbstractKeywordValidator.java} | 33 ++++-- .../schema/AdditionalPropertiesValidator.java | 6 +- .../com/networknt/schema/AllOfValidator.java | 6 +- .../networknt/schema/AnnotationKeyword.java | 6 +- .../com/networknt/schema/AnyOfValidator.java | 8 +- ...lidator.java => BaseKeywordValidator.java} | 104 +++--------------- .../com/networknt/schema/ConstValidator.java | 6 +- .../networknt/schema/ContainsValidator.java | 6 +- .../schema/ContentEncodingValidator.java | 8 +- .../schema/ContentMediaTypeValidator.java | 6 +- .../schema/DependenciesValidator.java | 6 +- .../networknt/schema/DependentRequired.java | 6 +- .../networknt/schema/DependentSchemas.java | 6 +- .../schema/DiscriminatorValidator.java | 8 +- .../networknt/schema/DynamicRefValidator.java | 6 +- .../com/networknt/schema/EnumValidator.java | 6 +- .../schema/ExclusiveMaximumValidator.java | 6 +- .../schema/ExclusiveMinimumValidator.java | 6 +- .../com/networknt/schema/FalseValidator.java | 6 +- .../com/networknt/schema/FormatKeyword.java | 2 +- .../com/networknt/schema/FormatValidator.java | 2 +- .../com/networknt/schema/IfValidator.java | 6 +- .../com/networknt/schema/ItemsValidator.java | 6 +- .../schema/ItemsValidator202012.java | 8 +- .../com/networknt/schema/JsonMetaSchema.java | 2 +- .../java/com/networknt/schema/JsonSchema.java | 30 ++--- .../java/com/networknt/schema/Keyword.java | 2 +- ...onValidator.java => KeywordValidator.java} | 4 +- .../networknt/schema/MaxItemsValidator.java | 6 +- .../networknt/schema/MaxLengthValidator.java | 6 +- .../schema/MaxPropertiesValidator.java | 6 +- .../networknt/schema/MaximumValidator.java | 6 +- .../networknt/schema/MinItemsValidator.java | 6 +- .../networknt/schema/MinLengthValidator.java | 6 +- .../schema/MinMaxContainsValidator.java | 6 +- .../schema/MinPropertiesValidator.java | 6 +- .../networknt/schema/MinimumValidator.java | 6 +- .../networknt/schema/MultipleOfValidator.java | 6 +- .../schema/NonValidationKeyword.java | 6 +- .../networknt/schema/NotAllowedValidator.java | 6 +- .../com/networknt/schema/NotValidator.java | 6 +- .../com/networknt/schema/OneOfValidator.java | 8 +- .../schema/PatternPropertiesValidator.java | 6 +- .../networknt/schema/PatternValidator.java | 4 +- .../schema/PrefixItemsValidator.java | 6 +- .../networknt/schema/PropertiesValidator.java | 6 +- .../schema/PropertyNamesValidator.java | 4 +- .../networknt/schema/ReadOnlyValidator.java | 6 +- .../schema/RecursiveRefValidator.java | 6 +- .../com/networknt/schema/RefValidator.java | 6 +- .../networknt/schema/RequiredValidator.java | 6 +- .../schema/SchemaValidatorsConfig.java | 2 +- .../com/networknt/schema/TrueValidator.java | 6 +- .../com/networknt/schema/TypeValidator.java | 6 +- .../schema/UnevaluatedItemsValidator.java | 8 +- .../UnevaluatedPropertiesValidator.java | 6 +- .../networknt/schema/UnionTypeValidator.java | 10 +- .../schema/UniqueItemsValidator.java | 6 +- .../networknt/schema/ValidationContext.java | 2 +- .../networknt/schema/ValidatorTypeCode.java | 6 +- .../networknt/schema/WriteOnlyValidator.java | 6 +- .../format/BaseFormatJsonValidator.java | 6 +- .../schema/utils/JsonSchemaRefs.java | 4 +- .../walk/AbstractWalkListenerRunner.java | 4 +- .../walk/DefaultItemWalkListenerRunner.java | 6 +- .../DefaultKeywordWalkListenerRunner.java | 6 +- .../DefaultPropertyWalkListenerRunner.java | 6 +- .../com/networknt/schema/walk/WalkEvent.java | 8 +- .../schema/walk/WalkListenerRunner.java | 6 +- .../schema/CollectorContextTest.java | 18 +-- .../schema/CustomMetaSchemaTest.java | 6 +- .../schema/FormatKeywordFactoryTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 6 +- .../com/networknt/schema/MessageTest.java | 6 +- 74 files changed, 260 insertions(+), 325 deletions(-) rename src/main/java/com/networknt/schema/{AbstractJsonValidator.java => AbstractKeywordValidator.java} (78%) rename src/main/java/com/networknt/schema/{BaseJsonValidator.java => BaseKeywordValidator.java} (66%) rename src/main/java/com/networknt/schema/{JsonValidator.java => KeywordValidator.java} (85%) diff --git a/src/main/java/com/networknt/schema/AbstractJsonValidator.java b/src/main/java/com/networknt/schema/AbstractKeywordValidator.java similarity index 78% rename from src/main/java/com/networknt/schema/AbstractJsonValidator.java rename to src/main/java/com/networknt/schema/AbstractKeywordValidator.java index bf3fc5d53..54814e4c6 100644 --- a/src/main/java/com/networknt/schema/AbstractJsonValidator.java +++ b/src/main/java/com/networknt/schema/AbstractKeywordValidator.java @@ -22,27 +22,38 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; /** - * Base {@link JsonValidator}. + * Abstract {@link KeywordValidator}. */ -public abstract class AbstractJsonValidator implements JsonValidator { - private final SchemaLocation schemaLocation; - private final JsonNode schemaNode; - private final JsonNodePath evaluationPath; +public abstract class AbstractKeywordValidator implements KeywordValidator { private final String keyword; + protected final JsonNode schemaNode; + protected final SchemaLocation schemaLocation; + + protected final JsonNodePath evaluationPath; /** * Constructor. - * - * @param schemaLocation the schema location - * @param evaluationPath the evaluation path * @param keyword the keyword * @param schemaNode the schema node + * @param schemaLocation the schema location + * @param evaluationPath the evaluation path */ - public AbstractJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, Keyword keyword, JsonNode schemaNode) { + public AbstractKeywordValidator(String keyword, JsonNode schemaNode, SchemaLocation schemaLocation, JsonNodePath evaluationPath) { + this.keyword = keyword; + this.schemaNode = schemaNode; this.schemaLocation = schemaLocation; this.evaluationPath = evaluationPath; - this.keyword = keyword.getValue(); - this.schemaNode = schemaNode; + } + + /** + * Constructor. + * @param keyword the keyword + * @param schemaNode the schema node + * @param schemaLocation the schema location + * @param evaluationPath the evaluation path + */ + public AbstractKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, JsonNodePath evaluationPath) { + this(keyword.getValue(), schemaNode, schemaLocation, evaluationPath); } @Override diff --git a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java index 5e7a91caa..50a167fe8 100644 --- a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java @@ -33,9 +33,9 @@ import java.util.Set; /** - * {@link JsonValidator} for additionalProperties. + * {@link KeywordValidator} for additionalProperties. */ -public class AdditionalPropertiesValidator extends BaseJsonValidator { +public class AdditionalPropertiesValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AdditionalPropertiesValidator.class); private final boolean allowAdditionalProperties; @@ -47,7 +47,7 @@ public class AdditionalPropertiesValidator extends BaseJsonValidator { public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ADDITIONAL_PROPERTIES, validationContext); + super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isBoolean()) { allowAdditionalProperties = schemaNode.booleanValue(); additionalPropertiesSchema = null; diff --git a/src/main/java/com/networknt/schema/AllOfValidator.java b/src/main/java/com/networknt/schema/AllOfValidator.java index e0f5996aa..beacad495 100644 --- a/src/main/java/com/networknt/schema/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/AllOfValidator.java @@ -25,15 +25,15 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for allOf. + * {@link KeywordValidator} for allOf. */ -public class AllOfValidator extends BaseJsonValidator { +public class AllOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AllOfValidator.class); private final List schemas; public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ALL_OF, validationContext); + super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/AnnotationKeyword.java b/src/main/java/com/networknt/schema/AnnotationKeyword.java index 65aae35ee..6d3908935 100644 --- a/src/main/java/com/networknt/schema/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/AnnotationKeyword.java @@ -23,10 +23,10 @@ */ public class AnnotationKeyword extends AbstractKeyword { - private static final class Validator extends AbstractJsonValidator { + private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext, Keyword keyword) { - super(schemaLocation, evaluationPath, keyword, schemaNode); + super(keyword, schemaNode, schemaLocation, evaluationPath); } @Override @@ -57,7 +57,7 @@ public AnnotationKeyword(String keyword) { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); } diff --git a/src/main/java/com/networknt/schema/AnyOfValidator.java b/src/main/java/com/networknt/schema/AnyOfValidator.java index 87cd71fc0..f298e2e36 100644 --- a/src/main/java/com/networknt/schema/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/AnyOfValidator.java @@ -24,9 +24,9 @@ import java.util.*; /** - * {@link JsonValidator} for anyOf. + * {@link KeywordValidator} for anyOf. */ -public class AnyOfValidator extends BaseJsonValidator { +public class AnyOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AnyOfValidator.class); private static final String DISCRIMINATOR_REMARK = "and the discriminator-selected candidate schema didn't pass validation"; @@ -35,7 +35,7 @@ public class AnyOfValidator extends BaseJsonValidator { private Boolean canShortCircuit = null; public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ANY_OF, validationContext); + super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) @@ -200,7 +200,7 @@ protected boolean canShortCircuit(ExecutionContext executionContext) { protected boolean canShortCircuit() { if (this.canShortCircuit == null) { boolean canShortCircuit = true; - for (JsonValidator validator : getEvaluationParentSchema().getValidators()) { + for (KeywordValidator validator : getEvaluationParentSchema().getValidators()) { if ("unevaluatedProperties".equals(validator.getKeyword()) || "unevaluatedItems".equals(validator.getKeyword())) { canShortCircuit = false; diff --git a/src/main/java/com/networknt/schema/BaseJsonValidator.java b/src/main/java/com/networknt/schema/BaseKeywordValidator.java similarity index 66% rename from src/main/java/com/networknt/schema/BaseJsonValidator.java rename to src/main/java/com/networknt/schema/BaseKeywordValidator.java index 0fde1100a..8a18d8b78 100644 --- a/src/main/java/com/networknt/schema/BaseJsonValidator.java +++ b/src/main/java/com/networknt/schema/BaseKeywordValidator.java @@ -17,80 +17,65 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.annotation.JsonNodeAnnotation; import org.slf4j.Logger; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; /** - * Base {@link JsonValidator}. + * Base {@link KeywordValidator}. */ -public abstract class BaseJsonValidator implements JsonValidator { - protected final JsonNode schemaNode; - +public abstract class BaseKeywordValidator extends AbstractKeywordValidator { protected final ValidationContext validationContext; - protected final Keyword keyword; protected final JsonSchema parentSchema; - protected final SchemaLocation schemaLocation; protected final Map errorMessage; - protected final JsonNodePath evaluationPath; protected final JsonSchema evaluationParentSchema; - public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, Keyword keyword, - ValidationContext validationContext) { + public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, + JsonSchema parentSchema, ValidationContext validationContext, + JsonNodePath evaluationPath) { + super(keyword, schemaNode, schemaLocation, evaluationPath); this.validationContext = validationContext; - this.schemaNode = schemaNode; - this.keyword = keyword; this.parentSchema = parentSchema; - this.schemaLocation = schemaLocation; if (keyword != null && parentSchema != null && validationContext.getConfig().getErrorMessageKeyword() != null) { this.errorMessage = ErrorMessages.getErrorMessage(parentSchema, validationContext.getConfig().getErrorMessageKeyword(), keyword.getValue()); } else { this.errorMessage = null; } - this.evaluationPath = evaluationPath; this.evaluationParentSchema = null; } /** * Constructor to create a copy using fields. - * + * @param keyword the keyword * @param schemaNode the schema node + * @param schemaLocation the schema location * @param validationContext the validation context - * @param keyword the keyword * @param parentSchema the parent schema - * @param schemaLocation the schema location * @param evaluationPath the evaluation path * @param evaluationParentSchema the evaluation parent schema * @param errorMessage the error message */ - protected BaseJsonValidator( - /* Below from BaseJsonValidator */ + protected BaseKeywordValidator( + Keyword keyword, JsonNode schemaNode, + SchemaLocation schemaLocation, ValidationContext validationContext, - Keyword keyword, JsonSchema parentSchema, - SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonSchema evaluationParentSchema, Map errorMessage) { - this.schemaNode = schemaNode; + super(keyword, schemaNode, schemaLocation, evaluationPath); this.validationContext = validationContext; - this.keyword = keyword; this.parentSchema = parentSchema; - this.schemaLocation = schemaLocation; this.errorMessage = errorMessage; - this.evaluationPath = evaluationPath; this.evaluationParentSchema = evaluationParentSchema; } @@ -117,25 +102,6 @@ public static void debug(Logger logger, ExecutionContext executionContext, JsonN } } - @Override - public SchemaLocation getSchemaLocation() { - return this.schemaLocation; - } - - @Override - public JsonNodePath getEvaluationPath() { - return this.evaluationPath; - } - - @Override - public String getKeyword() { - return this.keyword.getValue(); - } - - public JsonNode getSchemaNode() { - return this.schemaNode; - } - /** * Gets the parent schema. *

@@ -176,13 +142,6 @@ protected void preloadJsonSchemas(final Collection schemas) { } } - - - @Override - public String toString() { - return getEvaluationPath().getName(-1); - } - /** * Determines if the keyword exists adjacent in the evaluation path. *

@@ -199,7 +158,7 @@ public String toString() { protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { JsonSchema schema = getEvaluationParentSchema(); while (schema != null) { - for (JsonValidator validator : schema.getValidators()) { + for (KeywordValidator validator : schema.getValidators()) { if (keyword.equals(validator.getKeyword())) { return true; } @@ -218,41 +177,6 @@ protected MessageSourceError.Builder error() { return MessageSourceError .builder(this.validationContext.getConfig().getMessageSource(), this.errorMessage) .schemaNode(this.schemaNode).schemaLocation(this.schemaLocation).evaluationPath(this.evaluationPath) - .keyword(this.keyword != null ? this.keyword.getValue() : null).messageKey(this.getKeyword()); - } - - /** - * Determine if annotations should be reported. - * - * @param executionContext the execution context - * @return true if annotations should be reported - */ - protected boolean collectAnnotations(ExecutionContext executionContext) { - return collectAnnotations(executionContext, getKeyword()); - } - - /** - * Determine if annotations should be reported. - * - * @param executionContext the execution context - * @param keyword the keyword - * @return true if annotations should be reported - */ - protected boolean collectAnnotations(ExecutionContext executionContext, String keyword) { - return executionContext.getExecutionConfig().isAnnotationCollectionEnabled() - && executionContext.getExecutionConfig().getAnnotationCollectionFilter().test(keyword); - } - - /** - * Puts an annotation. - * - * @param executionContext the execution context - * @param customizer to customize the annotation - */ - protected void putAnnotation(ExecutionContext executionContext, Consumer customizer) { - JsonNodeAnnotation.Builder builder = JsonNodeAnnotation.builder().evaluationPath(this.evaluationPath) - .schemaLocation(this.schemaLocation).keyword(getKeyword()); - customizer.accept(builder); - executionContext.getAnnotations().put(builder.build()); + .keyword(this.getKeyword()).messageKey(this.getKeyword()); } } diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/ConstValidator.java index 078ad0f07..e94ee8320 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/ConstValidator.java @@ -20,14 +20,14 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for const. + * {@link KeywordValidator} for const. */ -public class ConstValidator extends BaseJsonValidator implements JsonValidator { +public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ConstValidator.class); public ConstValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.CONST, validationContext); + super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/ContainsValidator.java index cad439eed..934156995 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/ContainsValidator.java @@ -30,9 +30,9 @@ import static com.networknt.schema.VersionCode.MinV201909; /** - * {@link JsonValidator} for contains. + * {@link KeywordValidator} for contains. */ -public class ContainsValidator extends BaseJsonValidator { +public class ContainsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ContainsValidator.class); private static final String CONTAINS_MAX = "contains.max"; private static final String CONTAINS_MIN = "contains.min"; @@ -46,7 +46,7 @@ public class ContainsValidator extends BaseJsonValidator { private Boolean hasUnevaluatedItemsValidator = null; public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.CONTAINS, validationContext); + super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes diff --git a/src/main/java/com/networknt/schema/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/ContentEncodingValidator.java index 93d5fda54..d0d3ce773 100644 --- a/src/main/java/com/networknt/schema/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/ContentEncodingValidator.java @@ -24,12 +24,12 @@ import java.util.Base64; /** - * {@link JsonValidator} for contentEncoding. + * {@link KeywordValidator} for contentEncoding. *

* Note that since 2019-09 this keyword only generates annotations and not * errors. */ -public class ContentEncodingValidator extends BaseJsonValidator { +public class ContentEncodingValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ContentEncodingValidator.class); private final String contentEncoding; @@ -44,8 +44,8 @@ public class ContentEncodingValidator extends BaseJsonValidator { */ public ContentEncodingValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.CONTENT_ENCODING, - validationContext); + super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, validationContext, + evaluationPath); this.contentEncoding = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java index f367c8bb3..87b3d0ce8 100644 --- a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java @@ -28,11 +28,11 @@ import com.networknt.schema.serialization.JsonMapperFactory; /** - * {@link JsonValidator} for contentMediaType. + * {@link KeywordValidator} for contentMediaType. *

* Note that since 2019-09 this keyword only generates annotations and not errors. */ -public class ContentMediaTypeValidator extends BaseJsonValidator { +public class ContentMediaTypeValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ContentMediaTypeValidator.class); private static final String PATTERN_STRING = "(application|audio|font|example|image|message|model|multipart|text|video|x-(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+))/([0-9A-Za-z!#$%&'*+.^_`|~-]+)((?:[ \t]*;[ \t]*[0-9A-Za-z!#$%&'*+.^_`|~-]+=(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+|\"(?:[^\"\\\\]|\\.)*\"))*)"; private static final Pattern PATTERN = Pattern.compile(PATTERN_STRING); @@ -49,7 +49,7 @@ public class ContentMediaTypeValidator extends BaseJsonValidator { */ public ContentMediaTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.CONTENT_MEDIA_TYPE, validationContext); + super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/DependenciesValidator.java b/src/main/java/com/networknt/schema/DependenciesValidator.java index 85557f6d3..4a7b3ebd1 100644 --- a/src/main/java/com/networknt/schema/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/DependenciesValidator.java @@ -23,9 +23,9 @@ import java.util.*; /** - * {@link JsonValidator} for dependencies. + * {@link KeywordValidator} for dependencies. */ -public class DependenciesValidator extends BaseJsonValidator implements JsonValidator { +public class DependenciesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DependenciesValidator.class); private final Map> propertyDeps = new HashMap<>(); private final Map schemaDeps = new HashMap<>(); @@ -41,7 +41,7 @@ public class DependenciesValidator extends BaseJsonValidator implements JsonVali */ public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.DEPENDENCIES, validationContext); + super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/DependentRequired.java b/src/main/java/com/networknt/schema/DependentRequired.java index 189c13201..eb52ddadc 100644 --- a/src/main/java/com/networknt/schema/DependentRequired.java +++ b/src/main/java/com/networknt/schema/DependentRequired.java @@ -23,15 +23,15 @@ import java.util.*; /** - * {@link JsonValidator} for dependentRequired. + * {@link KeywordValidator} for dependentRequired. */ -public class DependentRequired extends BaseJsonValidator implements JsonValidator { +public class DependentRequired extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DependentRequired.class); private final Map> propertyDependencies = new HashMap<>(); public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.DEPENDENT_REQUIRED, validationContext); + super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/DependentSchemas.java b/src/main/java/com/networknt/schema/DependentSchemas.java index b9bfa47b4..eaf6de355 100644 --- a/src/main/java/com/networknt/schema/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/DependentSchemas.java @@ -23,15 +23,15 @@ import java.util.*; /** - * {@link JsonValidator} for dependentSchemas. + * {@link KeywordValidator} for dependentSchemas. */ -public class DependentSchemas extends BaseJsonValidator { +public class DependentSchemas extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DependentSchemas.class); private final Map schemaDependencies = new HashMap<>(); public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.DEPENDENT_SCHEMAS, validationContext); + super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/DiscriminatorValidator.java index c87ef6f7a..d9b2660ff 100644 --- a/src/main/java/com/networknt/schema/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/DiscriminatorValidator.java @@ -26,16 +26,16 @@ import com.fasterxml.jackson.databind.node.ObjectNode; /** - * {@link JsonValidator} that resolves discriminator. + * {@link KeywordValidator} that resolves discriminator. */ -public class DiscriminatorValidator extends BaseJsonValidator { +public class DiscriminatorValidator extends BaseKeywordValidator { private final String propertyName; private final Map mapping; public DiscriminatorValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.DISCRIMINATOR, - validationContext); + super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, validationContext, + evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; if (discriminator != null) { JsonNode propertyName = discriminator.get("propertyName"); diff --git a/src/main/java/com/networknt/schema/DynamicRefValidator.java b/src/main/java/com/networknt/schema/DynamicRefValidator.java index 820f5fbe1..07cb96192 100644 --- a/src/main/java/com/networknt/schema/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/DynamicRefValidator.java @@ -23,15 +23,15 @@ import java.util.function.Supplier; /** - * {@link JsonValidator} that resolves $dynamicRef. + * {@link KeywordValidator} that resolves $dynamicRef. */ -public class DynamicRefValidator extends BaseJsonValidator { +public class DynamicRefValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DynamicRefValidator.class); protected final JsonSchemaRef schema; public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.DYNAMIC_REF, validationContext); + super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } diff --git a/src/main/java/com/networknt/schema/EnumValidator.java b/src/main/java/com/networknt/schema/EnumValidator.java index a8f2d924d..66fb7d0c8 100644 --- a/src/main/java/com/networknt/schema/EnumValidator.java +++ b/src/main/java/com/networknt/schema/EnumValidator.java @@ -29,9 +29,9 @@ import java.util.Set; /** - * {@link JsonValidator} for enum. + * {@link KeywordValidator} for enum. */ -public class EnumValidator extends BaseJsonValidator implements JsonValidator { +public class EnumValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(EnumValidator.class); private final Set nodes; @@ -46,7 +46,7 @@ static String asText(JsonNode node) { } public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ENUM, validationContext); + super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java index b416f97a1..52b4f1539 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java @@ -26,15 +26,15 @@ import java.math.BigInteger; /** - * {@link JsonValidator} for exclusiveMaximum. + * {@link KeywordValidator} for exclusiveMaximum. */ -public class ExclusiveMaximumValidator extends BaseJsonValidator { +public class ExclusiveMaximumValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ExclusiveMaximumValidator.class); private final ThresholdMixin typedMaximum; public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.EXCLUSIVE_MAXIMUM, validationContext); + super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMaximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java index 8f903d97e..0b363ff0a 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java @@ -26,9 +26,9 @@ import java.math.BigInteger; /** - * {@link JsonValidator} for exclusiveMinimum. + * {@link KeywordValidator} for exclusiveMinimum. */ -public class ExclusiveMinimumValidator extends BaseJsonValidator { +public class ExclusiveMinimumValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ExclusiveMinimumValidator.class); /** @@ -38,7 +38,7 @@ public class ExclusiveMinimumValidator extends BaseJsonValidator { private final ThresholdMixin typedMinimum; public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.EXCLUSIVE_MINIMUM, validationContext); + super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMinimum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/FalseValidator.java index aa9e0f338..a1621c7ca 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/FalseValidator.java @@ -20,15 +20,15 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for false. + * {@link KeywordValidator} for false. */ -public class FalseValidator extends BaseJsonValidator implements JsonValidator { +public class FalseValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(FalseValidator.class); private final String reason; public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.FALSE, validationContext); + super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } diff --git a/src/main/java/com/networknt/schema/FormatKeyword.java b/src/main/java/com/networknt/schema/FormatKeyword.java index 44d780526..7dd3cda52 100644 --- a/src/main/java/com/networknt/schema/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/FormatKeyword.java @@ -47,7 +47,7 @@ Collection getFormats() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { Format format = null; if (schemaNode != null && schemaNode.isTextual()) { String formatName = schemaNode.textValue(); diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/FormatValidator.java index 314486665..c98fe24b5 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/FormatValidator.java @@ -27,7 +27,7 @@ /** * Validator for Format. */ -public class FormatValidator extends BaseFormatJsonValidator implements JsonValidator { +public class FormatValidator extends BaseFormatJsonValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(FormatValidator.class); private final Format format; diff --git a/src/main/java/com/networknt/schema/IfValidator.java b/src/main/java/com/networknt/schema/IfValidator.java index 117163ebe..28e30b240 100644 --- a/src/main/java/com/networknt/schema/IfValidator.java +++ b/src/main/java/com/networknt/schema/IfValidator.java @@ -24,9 +24,9 @@ import java.util.*; /** - * {@link JsonValidator} for if. + * {@link KeywordValidator} for if. */ -public class IfValidator extends BaseJsonValidator { +public class IfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(IfValidator.class); private static final List KEYWORDS = Arrays.asList("if", "then", "else"); @@ -36,7 +36,7 @@ public class IfValidator extends BaseJsonValidator { private final JsonSchema elseSchema; public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.IF_THEN_ELSE, validationContext); + super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); JsonSchema foundIfSchema = null; JsonSchema foundThenSchema = null; diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/ItemsValidator.java index 00c99c081..15f671f96 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/ItemsValidator.java @@ -27,9 +27,9 @@ import java.util.*; /** - * {@link JsonValidator} for items V4 to V2019-09. + * {@link KeywordValidator} for items V4 to V2019-09. */ -public class ItemsValidator extends BaseJsonValidator { +public class ItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ItemsValidator.class); private static final String PROPERTY_ADDITIONAL_ITEMS = "additionalItems"; @@ -45,7 +45,7 @@ public class ItemsValidator extends BaseJsonValidator { private final JsonNode additionalItemsSchemaNode; public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS, validationContext); + super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); Boolean additionalItems = null; diff --git a/src/main/java/com/networknt/schema/ItemsValidator202012.java b/src/main/java/com/networknt/schema/ItemsValidator202012.java index d115a8a18..23ab6cfc0 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/ItemsValidator202012.java @@ -25,9 +25,9 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for items from V2012-12. + * {@link KeywordValidator} for items from V2012-12. */ -public class ItemsValidator202012 extends BaseJsonValidator { +public class ItemsValidator202012 extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ItemsValidator202012.class); private final JsonSchema schema; @@ -38,8 +38,8 @@ public class ItemsValidator202012 extends BaseJsonValidator { public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS_202012, - validationContext); + super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, validationContext, + evaluationPath); JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); if (prefixItems instanceof ArrayNode) { diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index 110ed9a83..9d82eb7bd 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -470,7 +470,7 @@ public VersionFlag getSpecification() { * @param parentSchema the parent schema * @return the validator */ - public JsonValidator newValidator(ValidationContext validationContext, SchemaLocation schemaLocation, + public KeywordValidator newValidator(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword, JsonNode schemaNode, JsonSchema parentSchema) { try { Keyword kw = this.keywords.get(keyword); diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index 2710b0359..5227c91db 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -53,7 +53,7 @@ public class JsonSchema implements Validator { /** * The validators sorted and indexed by evaluation path. */ - private List validators = null; + private List validators = null; private boolean validatorsLoaded = false; private boolean recursiveAnchor = false; private TypeValidator typeValidator = null; @@ -277,7 +277,7 @@ private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLoc */ protected JsonSchema( /* Below from JsonSchema */ - List validators, + List validators, boolean validatorsLoaded, boolean recursiveAnchor, TypeValidator typeValidator, @@ -331,7 +331,7 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref // Validator state is reset due to the changes in evaluation path boolean validatorsLoaded = false; TypeValidator typeValidator = null; - List validators = null; + List validators = null; return new JsonSchema( /* Below from JsonSchema */ @@ -364,7 +364,7 @@ public JsonSchema withConfig(SchemaValidatorsConfig config) { this.getValidationContext().getDynamicAnchors()); boolean validatorsLoaded = false; TypeValidator typeValidator = null; - List validators = null; + List validators = null; return new JsonSchema( /* Below from JsonSchema */ validators, @@ -594,23 +594,23 @@ private JsonNode handleNullNode(String ref, JsonSchema schema) { /** * Please note that the key in {@link #validators} map is the evaluation path. */ - private List read(JsonNode schemaNode) { - List validators; + private List read(JsonNode schemaNode) { + List validators; if (schemaNode.isBoolean()) { validators = new ArrayList<>(1); if (schemaNode.booleanValue()) { JsonNodePath path = getEvaluationPath().append("true"); - JsonValidator validator = this.validationContext.newValidator(getSchemaLocation().append("true"), path, + KeywordValidator validator = this.validationContext.newValidator(getSchemaLocation().append("true"), path, "true", schemaNode, this); validators.add(validator); } else { JsonNodePath path = getEvaluationPath().append("false"); - JsonValidator validator = this.validationContext.newValidator(getSchemaLocation().append("false"), + KeywordValidator validator = this.validationContext.newValidator(getSchemaLocation().append("false"), path, "false", schemaNode, this); validators.add(validator); } } else { - JsonValidator refValidator = null; + KeywordValidator refValidator = null; Iterator> iterator = schemaNode.fields(); validators = new ArrayList<>(schemaNode.size()); @@ -638,7 +638,7 @@ private List read(JsonNode schemaNode) { this.recursiveAnchor = nodeToUse.booleanValue(); } - JsonValidator validator = this.validationContext.newValidator(schemaPath, path, + KeywordValidator validator = this.validationContext.newValidator(schemaPath, path, pname, nodeToUse, this); if (validator != null) { validators.add(validator); @@ -677,7 +677,7 @@ private long activeDialect() { * A comparator that sorts validators, such that 'properties' comes before 'required', * so that we can apply default values before validating required. */ - private static final Comparator VALIDATOR_SORT = (lhs, rhs) -> { + private static final Comparator VALIDATOR_SORT = (lhs, rhs) -> { String lhsName = lhs.getEvaluationPath().getName(-1); String rhsName = rhs.getEvaluationPath().getName(-1); @@ -707,7 +707,7 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN } } int currentErrors = executionContext.getErrors().size(); - for (JsonValidator v : getValidators()) { + for (KeywordValidator v : getValidators()) { v.validate(executionContext, jsonNode, rootNode, instanceLocation); } @@ -1350,7 +1350,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root JsonNodePath instanceLocation, boolean shouldValidateSchema) { // Walk through all the JSONWalker's. int currentErrors = executionContext.getErrors().size(); - for (JsonValidator validator : getValidators()) { + for (KeywordValidator validator : getValidators()) { JsonNodePath evaluationPathWithKeyword = validator.getEvaluationPath(); try { // Call all the pre-walk listeners. If at least one of the pre walk listeners @@ -1389,7 +1389,7 @@ public TypeValidator getTypeValidator() { return this.typeValidator; } - public List getValidators() { + public List getValidators() { if (this.validators == null) { this.validators = Collections.unmodifiableList(read(getSchemaNode())); } @@ -1407,7 +1407,7 @@ public List getValidators() { */ public void initializeValidators() { if (!this.validatorsLoaded) { - for (final JsonValidator validator : getValidators()) { + for (final KeywordValidator validator : getValidators()) { validator.preloadJsonSchema(); } /* diff --git a/src/main/java/com/networknt/schema/Keyword.java b/src/main/java/com/networknt/schema/Keyword.java index 592c80384..82f012b1e 100644 --- a/src/main/java/com/networknt/schema/Keyword.java +++ b/src/main/java/com/networknt/schema/Keyword.java @@ -41,6 +41,6 @@ public interface Keyword { * @throws JsonSchemaException the exception * @throws Exception the exception */ - JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception; } diff --git a/src/main/java/com/networknt/schema/JsonValidator.java b/src/main/java/com/networknt/schema/KeywordValidator.java similarity index 85% rename from src/main/java/com/networknt/schema/JsonValidator.java rename to src/main/java/com/networknt/schema/KeywordValidator.java index b8d6069fe..c9a43d010 100644 --- a/src/main/java/com/networknt/schema/JsonValidator.java +++ b/src/main/java/com/networknt/schema/KeywordValidator.java @@ -19,9 +19,9 @@ /** * KeywordValidator interface implemented by all keyword validators. */ -public interface JsonValidator extends Validator { +public interface KeywordValidator extends Validator { /** - * In case the {@link com.networknt.schema.JsonValidator} has a related {@link com.networknt.schema.JsonSchema} or several + * In case the {@link com.networknt.schema.KeywordValidator} has a related {@link com.networknt.schema.JsonSchema} or several * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. * * @throws JsonSchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.JsonSchema} or nested schemas diff --git a/src/main/java/com/networknt/schema/MaxItemsValidator.java b/src/main/java/com/networknt/schema/MaxItemsValidator.java index 741d9d682..b9ff5d403 100644 --- a/src/main/java/com/networknt/schema/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/MaxItemsValidator.java @@ -21,16 +21,16 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for maxItems. + * {@link KeywordValidator} for maxItems. */ -public class MaxItemsValidator extends BaseJsonValidator implements JsonValidator { +public class MaxItemsValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MaxItemsValidator.class); private final int max; public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MAX_ITEMS, validationContext); + super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/MaxLengthValidator.java b/src/main/java/com/networknt/schema/MaxLengthValidator.java index a144df836..830c4236d 100644 --- a/src/main/java/com/networknt/schema/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/MaxLengthValidator.java @@ -21,15 +21,15 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for maxLength. + * {@link KeywordValidator} for maxLength. */ -public class MaxLengthValidator extends BaseJsonValidator implements JsonValidator { +public class MaxLengthValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MaxLengthValidator.class); private final int maxLength; public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MAX_LENGTH, validationContext); + super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java index 44da54001..c4938ffcc 100644 --- a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java @@ -21,16 +21,16 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator}for maxProperties. + * {@link KeywordValidator}for maxProperties. */ -public class MaxPropertiesValidator extends BaseJsonValidator implements JsonValidator { +public class MaxPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MaxPropertiesValidator.class); private final int max; public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MAX_PROPERTIES, validationContext); + super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/MaximumValidator.java index e5be2dcb3..db407acef 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/MaximumValidator.java @@ -26,9 +26,9 @@ import java.math.BigInteger; /** - * {@link JsonValidator} for maxmimum. + * {@link KeywordValidator} for maxmimum. */ -public class MaximumValidator extends BaseJsonValidator { +public class MaximumValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MaximumValidator.class); private static final String PROPERTY_EXCLUSIVE_MAXIMUM = "exclusiveMaximum"; @@ -38,7 +38,7 @@ public class MaximumValidator extends BaseJsonValidator { public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MAXIMUM, validationContext); + super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("maximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/MinItemsValidator.java b/src/main/java/com/networknt/schema/MinItemsValidator.java index 54fb1a0ca..cb886d384 100644 --- a/src/main/java/com/networknt/schema/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/MinItemsValidator.java @@ -21,15 +21,15 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for minItems. + * {@link KeywordValidator} for minItems. */ -public class MinItemsValidator extends BaseJsonValidator implements JsonValidator { +public class MinItemsValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MinItemsValidator.class); private int min = 0; public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MIN_ITEMS, validationContext); + super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } diff --git a/src/main/java/com/networknt/schema/MinLengthValidator.java b/src/main/java/com/networknt/schema/MinLengthValidator.java index e8bfefb96..a3810e8c6 100644 --- a/src/main/java/com/networknt/schema/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/MinLengthValidator.java @@ -21,15 +21,15 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for minLength. + * {@link KeywordValidator} for minLength. */ -public class MinLengthValidator extends BaseJsonValidator implements JsonValidator { +public class MinLengthValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MinLengthValidator.class); private int minLength; public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MIN_LENGTH, validationContext); + super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { minLength = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java index 05ae19e23..6306b5d62 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java @@ -6,18 +6,18 @@ import java.util.Set; /** - * {@link JsonValidator} for {@literal maxContains} and {@literal minContains} in a schema. + * {@link KeywordValidator} for {@literal maxContains} and {@literal minContains} in a schema. *

* This validator only checks that the schema is valid. The functionality for * testing whether an instance array conforms to the {@literal maxContains} * and {@literal minContains} constraints exists within {@code ContainsValidator}. */ -public class MinMaxContainsValidator extends BaseJsonValidator { +public class MinMaxContainsValidator extends BaseKeywordValidator { private final Set analysis; public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MAX_CONTAINS, validationContext); + super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); Set analysis = null; int min = 1; diff --git a/src/main/java/com/networknt/schema/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/MinPropertiesValidator.java index 6aa221bbb..bd0c3e818 100644 --- a/src/main/java/com/networknt/schema/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MinPropertiesValidator.java @@ -21,16 +21,16 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for minProperties. + * {@link KeywordValidator} for minProperties. */ -public class MinPropertiesValidator extends BaseJsonValidator implements JsonValidator { +public class MinPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MinPropertiesValidator.class); protected final int min; public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MIN_PROPERTIES, validationContext); + super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/MinimumValidator.java index 078988dc0..dc8d6b661 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/MinimumValidator.java @@ -26,9 +26,9 @@ import java.math.BigInteger; /** - * {@link JsonValidator} for minimum. + * {@link KeywordValidator} for minimum. */ -public class MinimumValidator extends BaseJsonValidator { +public class MinimumValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MinimumValidator.class); private static final String PROPERTY_EXCLUSIVE_MINIMUM = "exclusiveMinimum"; @@ -41,7 +41,7 @@ public class MinimumValidator extends BaseJsonValidator { private final ThresholdMixin typedMinimum; public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MINIMUM, validationContext); + super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("minimum value is not a number"); diff --git a/src/main/java/com/networknt/schema/MultipleOfValidator.java b/src/main/java/com/networknt/schema/MultipleOfValidator.java index e5e95ae27..25ca4ce90 100644 --- a/src/main/java/com/networknt/schema/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/MultipleOfValidator.java @@ -25,16 +25,16 @@ import java.math.BigDecimal; /** - * {@link JsonValidator} for multipleOf. + * {@link KeywordValidator} for multipleOf. */ -public class MultipleOfValidator extends BaseJsonValidator implements JsonValidator { +public class MultipleOfValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(MultipleOfValidator.class); private final BigDecimal divisor; public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.MULTIPLE_OF, validationContext); + super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.divisor = getDivisor(schemaNode); } diff --git a/src/main/java/com/networknt/schema/NonValidationKeyword.java b/src/main/java/com/networknt/schema/NonValidationKeyword.java index 2b2cde777..5c00c8240 100644 --- a/src/main/java/com/networknt/schema/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/NonValidationKeyword.java @@ -26,10 +26,10 @@ */ public class NonValidationKeyword extends AbstractKeyword { - private static final class Validator extends AbstractJsonValidator { + private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext, Keyword keyword) { - super(schemaLocation, evaluationPath, keyword, schemaNode); + super(keyword, schemaNode, schemaLocation, evaluationPath); String id = validationContext.resolveSchemaId(schemaNode); String anchor = validationContext.getMetaSchema().readAnchor(schemaNode); String dynamicAnchor = validationContext.getMetaSchema().readDynamicAnchor(schemaNode); @@ -59,7 +59,7 @@ public NonValidationKeyword(String keyword) { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); } diff --git a/src/main/java/com/networknt/schema/NotAllowedValidator.java b/src/main/java/com/networknt/schema/NotAllowedValidator.java index 7fd3323e2..5b0b724ee 100644 --- a/src/main/java/com/networknt/schema/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/NotAllowedValidator.java @@ -23,15 +23,15 @@ import java.util.*; /** - * {@link JsonValidator} for notAllowed. + * {@link KeywordValidator} for notAllowed. */ -public class NotAllowedValidator extends BaseJsonValidator implements JsonValidator { +public class NotAllowedValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(NotAllowedValidator.class); private final List fieldNames; public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.NOT_ALLOWED, validationContext); + super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); this.fieldNames = new ArrayList<>(size); diff --git a/src/main/java/com/networknt/schema/NotValidator.java b/src/main/java/com/networknt/schema/NotValidator.java index 72cc61169..0e18af03c 100644 --- a/src/main/java/com/networknt/schema/NotValidator.java +++ b/src/main/java/com/networknt/schema/NotValidator.java @@ -24,15 +24,15 @@ import java.util.*; /** - * {@link JsonValidator} for not. + * {@link KeywordValidator} for not. */ -public class NotValidator extends BaseJsonValidator { +public class NotValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(NotValidator.class); private final JsonSchema schema; public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.NOT, validationContext); + super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/OneOfValidator.java b/src/main/java/com/networknt/schema/OneOfValidator.java index 81d92b832..6374345a5 100644 --- a/src/main/java/com/networknt/schema/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/OneOfValidator.java @@ -26,9 +26,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode; /** - * {@link JsonValidator} for oneOf. + * {@link KeywordValidator} for oneOf. */ -public class OneOfValidator extends BaseJsonValidator { +public class OneOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(OneOfValidator.class); private final List schemas; @@ -36,7 +36,7 @@ public class OneOfValidator extends BaseJsonValidator { private Boolean canShortCircuit = null; public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ONE_OF, validationContext); + super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) @@ -211,7 +211,7 @@ protected boolean reportChildErrors(ExecutionContext executionContext) { protected boolean canShortCircuit() { if (this.canShortCircuit == null) { boolean canShortCircuit = true; - for (JsonValidator validator : getEvaluationParentSchema().getValidators()) { + for (KeywordValidator validator : getEvaluationParentSchema().getValidators()) { if ("unevaluatedProperties".equals(validator.getKeyword()) || "unevaluatedItems".equals(validator.getKeyword())) { canShortCircuit = false; diff --git a/src/main/java/com/networknt/schema/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/PatternPropertiesValidator.java index 95403ad0d..1ef9bf81e 100644 --- a/src/main/java/com/networknt/schema/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/PatternPropertiesValidator.java @@ -25,9 +25,9 @@ import java.util.*; /** - * {@link JsonValidator} for patternProperties. + * {@link KeywordValidator} for patternProperties. */ -public class PatternPropertiesValidator extends BaseJsonValidator { +public class PatternPropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "patternProperties"; private static final Logger logger = LoggerFactory.getLogger(PatternPropertiesValidator.class); private final Map schemas = new IdentityHashMap<>(); @@ -36,7 +36,7 @@ public class PatternPropertiesValidator extends BaseJsonValidator { public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.PATTERN_PROPERTIES, validationContext); + super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isObject()) { throw new JsonSchemaException("patternProperties must be an object node"); } diff --git a/src/main/java/com/networknt/schema/PatternValidator.java b/src/main/java/com/networknt/schema/PatternValidator.java index dbf1f8fe1..992958478 100644 --- a/src/main/java/com/networknt/schema/PatternValidator.java +++ b/src/main/java/com/networknt/schema/PatternValidator.java @@ -23,13 +23,13 @@ import java.util.Optional; -public class PatternValidator extends BaseJsonValidator { +public class PatternValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PatternValidator.class); private final String pattern; private final RegularExpression compiledPattern; public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.PATTERN, validationContext); + super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); try { diff --git a/src/main/java/com/networknt/schema/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/PrefixItemsValidator.java index 9abaa1848..0188f4f1c 100644 --- a/src/main/java/com/networknt/schema/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/PrefixItemsValidator.java @@ -28,9 +28,9 @@ import java.util.List; /** - * {@link JsonValidator} for prefixItems. + * {@link KeywordValidator} for prefixItems. */ -public class PrefixItemsValidator extends BaseJsonValidator { +public class PrefixItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PrefixItemsValidator.class); private final List tupleSchema; @@ -38,7 +38,7 @@ public class PrefixItemsValidator extends BaseJsonValidator { private Boolean hasUnevaluatedItemsValidator = null; public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.PREFIX_ITEMS, validationContext); + super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { int i = 0; diff --git a/src/main/java/com/networknt/schema/PropertiesValidator.java b/src/main/java/com/networknt/schema/PropertiesValidator.java index c64e767ef..a454caf64 100644 --- a/src/main/java/com/networknt/schema/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/PropertiesValidator.java @@ -35,9 +35,9 @@ import java.util.Set; /** - * {@link JsonValidator} for properties. + * {@link KeywordValidator} for properties. */ -public class PropertiesValidator extends BaseJsonValidator { +public class PropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "properties"; private static final Logger logger = LoggerFactory.getLogger(PropertiesValidator.class); private final Map schemas = new LinkedHashMap<>(); @@ -45,7 +45,7 @@ public class PropertiesValidator extends BaseJsonValidator { private Boolean hasUnevaluatedPropertiesValidator; public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.PROPERTIES, validationContext); + super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); String pname = entry.getKey(); diff --git a/src/main/java/com/networknt/schema/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/PropertyNamesValidator.java index 374ff323f..320f9dae5 100644 --- a/src/main/java/com/networknt/schema/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/PropertyNamesValidator.java @@ -25,11 +25,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; -public class PropertyNamesValidator extends BaseJsonValidator implements JsonValidator { +public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PropertyNamesValidator.class); private final JsonSchema innerSchema; public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.PROPERTYNAMES, validationContext); + super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); innerSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/ReadOnlyValidator.java index 9895c57cf..5abdcf483 100644 --- a/src/main/java/com/networknt/schema/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/ReadOnlyValidator.java @@ -22,15 +22,15 @@ import com.fasterxml.jackson.databind.JsonNode; /** - * {@link JsonValidator} for readOnly. + * {@link KeywordValidator} for readOnly. */ -public class ReadOnlyValidator extends BaseJsonValidator { +public class ReadOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ReadOnlyValidator.class); private final boolean readOnly; public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.READ_ONLY, validationContext); + super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.readOnly = validationContext.getConfig().isReadOnly(); logger.debug("Loaded ReadOnlyValidator for property {} as {}", parentSchema, "read mode"); diff --git a/src/main/java/com/networknt/schema/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/RecursiveRefValidator.java index a7f8cf009..60c255dc2 100644 --- a/src/main/java/com/networknt/schema/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/RecursiveRefValidator.java @@ -23,15 +23,15 @@ import java.util.function.Supplier; /** - * {@link JsonValidator} that resolves $recursiveRef. + * {@link KeywordValidator} that resolves $recursiveRef. */ -public class RecursiveRefValidator extends BaseJsonValidator { +public class RecursiveRefValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(RecursiveRefValidator.class); protected final JsonSchemaRef schema; public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.RECURSIVE_REF, validationContext); + super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); if (!"#".equals(refValue)) { diff --git a/src/main/java/com/networknt/schema/RefValidator.java b/src/main/java/com/networknt/schema/RefValidator.java index bdc8b614b..73e16185f 100644 --- a/src/main/java/com/networknt/schema/RefValidator.java +++ b/src/main/java/com/networknt/schema/RefValidator.java @@ -23,9 +23,9 @@ import java.util.function.Supplier; /** - * {@link JsonValidator} that resolves $ref. + * {@link KeywordValidator} that resolves $ref. */ -public class RefValidator extends BaseJsonValidator { +public class RefValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(RefValidator.class); protected final JsonSchemaRef schema; @@ -33,7 +33,7 @@ public class RefValidator extends BaseJsonValidator { private static final String REF_CURRENT = "#"; public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.REF, validationContext); + super(ValidatorTypeCode.REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } diff --git a/src/main/java/com/networknt/schema/RequiredValidator.java b/src/main/java/com/networknt/schema/RequiredValidator.java index a1509e1f5..350e36d73 100644 --- a/src/main/java/com/networknt/schema/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/RequiredValidator.java @@ -23,15 +23,15 @@ import java.util.*; /** - * {@link JsonValidator} for required. + * {@link KeywordValidator} for required. */ -public class RequiredValidator extends BaseJsonValidator implements JsonValidator { +public class RequiredValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(RequiredValidator.class); private final List fieldNames; public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.REQUIRED, validationContext); + super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); for (JsonNode fieldNme : schemaNode) { diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java index 121ca7c5f..a98cf6b90 100644 --- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java +++ b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java @@ -607,7 +607,7 @@ public void setExecutionContextCustomizer(ExecutionContextCustomizer executionCo /** * When enabled, - * {@link JsonValidator#validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)} + * {@link KeywordValidator#validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)} * doesn't return any {@link java.util.Set}<{@link Error}>, * instead a {@link JsonSchemaException} is thrown as soon as a validation * errors is discovered. diff --git a/src/main/java/com/networknt/schema/TrueValidator.java b/src/main/java/com/networknt/schema/TrueValidator.java index c1dde192e..ed7943207 100644 --- a/src/main/java/com/networknt/schema/TrueValidator.java +++ b/src/main/java/com/networknt/schema/TrueValidator.java @@ -20,13 +20,13 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for true. + * {@link KeywordValidator} for true. */ -public class TrueValidator extends BaseJsonValidator implements JsonValidator { +public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(TrueValidator.class); public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.TRUE, validationContext); + super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/TypeValidator.java index fcdb866c8..cfb22da33 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/TypeValidator.java @@ -22,16 +22,16 @@ import org.slf4j.LoggerFactory; /** - * {@link JsonValidator} for type. + * {@link KeywordValidator} for type. */ -public class TypeValidator extends BaseJsonValidator { +public class TypeValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(TypeValidator.class); private final JsonType schemaType; private final UnionTypeValidator unionTypeValidator; public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.TYPE, validationContext); + super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { this.unionTypeValidator = new UnionTypeValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext); diff --git a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java index 22ea92cbf..a7c6ed850 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java @@ -30,9 +30,9 @@ import static com.networknt.schema.VersionCode.MinV202012; /** - * {@link JsonValidator} for unevaluatedItems. + * {@link KeywordValidator} for unevaluatedItems. */ -public class UnevaluatedItemsValidator extends BaseJsonValidator { +public class UnevaluatedItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UnevaluatedItemsValidator.class); private final JsonSchema schema; @@ -42,8 +42,8 @@ public class UnevaluatedItemsValidator extends BaseJsonValidator { public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.UNEVALUATED_ITEMS, - validationContext); + super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, + evaluationPath); isMinV202012 = MinV202012.getVersions().contains(validationContext.activeDialect().orElse(DEFAULT_VERSION)); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); diff --git a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java index ebadd5889..ac9e3dec6 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java @@ -27,15 +27,15 @@ import java.util.stream.Collectors; /** - * {@link JsonValidator} for unevaluatedProperties. + * {@link KeywordValidator} for unevaluatedProperties. */ -public class UnevaluatedPropertiesValidator extends BaseJsonValidator { +public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UnevaluatedPropertiesValidator.class); private final JsonSchema schema; public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.UNEVALUATED_PROPERTIES, validationContext); + super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index 15ee5d9cc..3649c76c7 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -24,16 +24,16 @@ import java.util.List; /** - * {@link JsonValidator} for type union. + * {@link KeywordValidator} for type union. */ -public class UnionTypeValidator extends BaseJsonValidator implements JsonValidator { +public class UnionTypeValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UnionTypeValidator.class); private final List schemas; private final String error; public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.TYPE, validationContext); + super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); String sep = ""; @@ -106,8 +106,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void preloadJsonSchema() { for (final Validator validator : schemas) { - if (validator instanceof JsonValidator) { - ((JsonValidator) validator).preloadJsonSchema(); + if (validator instanceof KeywordValidator) { + ((KeywordValidator) validator).preloadJsonSchema(); } else if (validator instanceof JsonSchema) { ((JsonSchema) validator).initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/UniqueItemsValidator.java index 93e8fb21d..19d371920 100644 --- a/src/main/java/com/networknt/schema/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/UniqueItemsValidator.java @@ -24,15 +24,15 @@ import java.util.Set; /** - * {@link JsonValidator} for uniqueItems. + * {@link KeywordValidator} for uniqueItems. */ -public class UniqueItemsValidator extends BaseJsonValidator implements JsonValidator { +public class UniqueItemsValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UniqueItemsValidator.class); private final boolean unique; public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.UNIQUE_ITEMS, validationContext); + super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); } else { diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index d35b29b94..1d6a54b8e 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -58,7 +58,7 @@ public JsonSchema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluati return getJsonSchemaFactory().create(this, schemaLocation, evaluationPath, schemaNode, parentSchema); } - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword /* keyword */, JsonNode schemaNode, JsonSchema parentSchema) { return this.metaSchema.newValidator(this, schemaLocation, evaluationPath, keyword, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/ValidatorTypeCode.java index 691f0fc9b..c2513207a 100644 --- a/src/main/java/com/networknt/schema/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/ValidatorTypeCode.java @@ -28,7 +28,7 @@ @FunctionalInterface interface ValidatorFactory { - JsonValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + KeywordValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext); } @@ -75,7 +75,7 @@ public enum ValidatorTypeCode implements Keyword { EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), FALSE("false", FalseValidator::new, VersionCode.MinV6), FORMAT("format", null, VersionCode.MaxV7) { - @Override public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, @@ -152,7 +152,7 @@ public static ValidatorTypeCode fromValue(String value) { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { if (this.validatorFactory == null) { throw new UnsupportedOperationException("No suitable validator for " + getValue()); diff --git a/src/main/java/com/networknt/schema/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/WriteOnlyValidator.java index 0592abdb6..a42fc3016 100644 --- a/src/main/java/com/networknt/schema/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/WriteOnlyValidator.java @@ -6,15 +6,15 @@ import com.fasterxml.jackson.databind.JsonNode; /** - * {@link JsonValidator} for writeOnly. + * {@link KeywordValidator} for writeOnly. */ -public class WriteOnlyValidator extends BaseJsonValidator { +public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); private final boolean writeOnly; public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.WRITE_ONLY, validationContext); + super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.writeOnly = validationContext.getConfig().isWriteOnly(); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index 94813221a..02a459a85 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -3,7 +3,7 @@ import java.util.Map; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.BaseJsonValidator; +import com.networknt.schema.BaseKeywordValidator; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; @@ -12,13 +12,13 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.SpecVersion.VersionFlag; -public abstract class BaseFormatJsonValidator extends BaseJsonValidator { +public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); + super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); VersionFlag dialect = this.validationContext.getMetaSchema().getSpecification(); if (dialect == null || dialect.getVersionFlagValue() < VersionFlag.V201909.getVersionFlagValue()) { assertionsEnabled = true; diff --git a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java index 9a6231fd4..6d038d969 100644 --- a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java +++ b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java @@ -18,7 +18,7 @@ import com.networknt.schema.DynamicRefValidator; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaRef; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.RecursiveRefValidator; import com.networknt.schema.RefValidator; @@ -34,7 +34,7 @@ public class JsonSchemaRefs { * @return the ref */ public static JsonSchemaRef from(JsonSchema schema) { - for (JsonValidator validator : schema.getValidators()) { + for (KeywordValidator validator : schema.getValidators()) { if (validator instanceof RefValidator) { return ((RefValidator) validator).getSchemaRef(); } else if (validator instanceof DynamicRefValidator) { diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index 941d86157..acc96faf9 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.Error; import java.util.List; @@ -12,7 +12,7 @@ public abstract class AbstractWalkListenerRunner implements WalkListenerRunner { protected WalkEvent constructWalkEvent(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator) { + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { return WalkEvent.builder().executionContext(executionContext).instanceLocation(instanceLocation) .keyword(keyword).instanceNode(instanceNode) .rootNode(rootNode).schema(schema).validator(validator).build(); diff --git a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java index 8c0f529ca..496a4e6d8 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.Error; import java.util.List; @@ -19,7 +19,7 @@ public DefaultItemWalkListenerRunner(List itemWalkListen @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator) { + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(itemWalkListeners, walkEvent); @@ -27,7 +27,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List errors) { + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); runPostWalkListeners(itemWalkListeners, walkEvent, errors); diff --git a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java index 8d93384a2..08f9a9a7b 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java @@ -8,7 +8,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.SchemaValidatorsConfig; public class DefaultKeywordWalkListenerRunner extends AbstractWalkListenerRunner { @@ -21,7 +21,7 @@ public DefaultKeywordWalkListenerRunner(Map @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator) { + JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { boolean continueRunningListenersAndWalk = true; WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); // Run Listeners that are setup only for this keyword. @@ -38,7 +38,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, List errors) { WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); // Run Listeners that are setup only for this keyword. diff --git a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java index 0f4cc054e..c04040345 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.Error; import java.util.List; @@ -19,14 +19,14 @@ public DefaultPropertyWalkListenerRunner(List propertyWa @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator) { + JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(propertyWalkListeners, walkEvent); } @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, JsonNodePath instanceLocation, - JsonSchema schema, JsonValidator validator, List errors) { + JsonSchema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); runPostWalkListeners(propertyWalkListeners, walkEvent, errors); diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index 36f857c6f..b34fb9688 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; /** * Encapsulation of Walk data that is passed into the {@link JsonSchemaWalkListener}. @@ -17,7 +17,7 @@ public class WalkEvent { private JsonNode rootNode; private JsonNode instanceNode; private JsonNodePath instanceLocation; - private JsonValidator validator; + private KeywordValidator validator; /** * Gets the execution context. @@ -87,7 +87,7 @@ public JsonNodePath getInstanceLocation() { * @return the validator */ @SuppressWarnings("unchecked") - public T getValidator() { + public T getValidator() { return (T) this.validator; } @@ -135,7 +135,7 @@ public WalkEventBuilder instanceLocation(JsonNodePath instanceLocation) { return this; } - public WalkEventBuilder validator(JsonValidator validator) { + public WalkEventBuilder validator(KeywordValidator validator) { walkEvent.validator = validator; return this; } diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index 424c70d0c..dc800b1a1 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonValidator; +import com.networknt.schema.KeywordValidator; import com.networknt.schema.Error; import java.util.List; @@ -12,9 +12,9 @@ public interface WalkListenerRunner { boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator); + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator); void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, List errors); + JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, List errors); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 3498a3bf9..d5e912094 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -264,7 +264,7 @@ public String getValue() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); @@ -279,9 +279,9 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev * This will be helpful in cases where we don't want to revisit the entire JSON * document again just for gathering this kind of information. */ - private class CustomValidator extends AbstractJsonValidator { + private class CustomValidator extends AbstractKeywordValidator { public CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { - super(schemaLocation, evaluationPath, new CustomKeyword(), schemaNode); + super(new CustomKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override @@ -334,7 +334,7 @@ public String getValue() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator1(schemaLocation, evaluationPath, schemaNode); @@ -351,9 +351,9 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev * we expect this validator to be called multiple times as the associated * keyword has been used multiple times in JSON Schema. */ - private class CustomValidator1 extends AbstractJsonValidator { + private class CustomValidator1 extends AbstractKeywordValidator { public CustomValidator1(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { - super(schemaLocation, evaluationPath,new CustomKeyword(), schemaNode); + super(new CustomKeyword(), schemaNode,schemaLocation, evaluationPath); } @SuppressWarnings("unchecked") @@ -413,7 +413,7 @@ public String getValue() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isBoolean()) { return new CollectValidator(schemaLocation, evaluationPath, schemaNode); @@ -422,9 +422,9 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev } } - private class CollectValidator extends AbstractJsonValidator { + private class CollectValidator extends AbstractKeywordValidator { CollectValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { - super(schemaLocation, evaluationPath, new CollectKeyword(), schemaNode); + super(new CollectKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index a48ea4b13..3abb9e4ef 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -40,14 +40,14 @@ class CustomMetaSchemaTest { */ static class EnumNamesKeyword extends AbstractKeyword { - private static final class Validator extends AbstractJsonValidator { + private static final class Validator extends AbstractKeywordValidator { private final List enumValues; private final List enumNames; private final String keyword; private Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword, List enumValues, List enumNames, JsonNode schemaNode) { - super(schemaLocation, evaluationPath, new EnumNamesKeyword(), schemaNode); + super(new EnumNamesKeyword(), schemaNode, schemaLocation, evaluationPath); if (enumNames.size() != enumValues.size()) { throw new IllegalArgumentException("enum and enumNames need to be of same length"); } @@ -79,7 +79,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { /* * You can access the schema node here to read data from your keyword diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index c709b874a..c85cc4a38 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -32,7 +32,7 @@ public CustomFormatKeyword(Map formats) { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { throw new IllegalArgumentException(); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 3b36ef859..e4b55bd92 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -145,7 +145,7 @@ public String getValue() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); @@ -159,10 +159,10 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev * This will be helpful in cases where we don't want to revisit the entire JSON * document again just for gathering this kind of information. */ - private static class CustomValidator extends AbstractJsonValidator { + private static class CustomValidator extends AbstractKeywordValidator { CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { - super(schemaLocation, evaluationPath, new CustomKeyword(), schemaNode); + super(new CustomKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index c11d2834b..41cec0ffd 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -28,13 +28,13 @@ * Test for messages. */ class MessageTest { - static class EqualsValidator extends BaseJsonValidator { + static class EqualsValidator extends BaseKeywordValidator { private final String value; EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); + super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.value = schemaNode.textValue(); } @@ -57,7 +57,7 @@ public String getValue() { } @Override - public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, validationContext); From 868a967996db8488e7a991a69ab25b498d9b2f8b Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:45:10 +0800 Subject: [PATCH 08/74] Move keyword and keyword validators to keyword package --- .../java/com/networknt/schema/Format.java | 1 + .../com/networknt/schema/JsonMetaSchema.java | 6 ++++++ .../java/com/networknt/schema/JsonSchema.java | 4 ++++ .../networknt/schema/JsonSchemaFactory.java | 2 +- .../schema/SchemaValidatorsConfig.java | 9 ++++---- .../networknt/schema/ValidationContext.java | 1 + .../com/networknt/schema/Version201909.java | 3 +++ .../com/networknt/schema/Version202012.java | 3 +++ .../java/com/networknt/schema/Version4.java | 4 ++++ .../java/com/networknt/schema/Version6.java | 4 ++++ .../java/com/networknt/schema/Version7.java | 4 ++++ .../java/com/networknt/schema/Vocabulary.java | 5 +++++ .../schema/annotation/JsonNodeAnnotation.java | 2 +- .../format/BaseFormatJsonValidator.java | 4 ++-- .../schema/{ => keyword}/AbstractKeyword.java | 2 +- .../AbstractKeywordValidator.java | 5 ++++- .../AdditionalPropertiesValidator.java | 7 ++++++- .../schema/{ => keyword}/AllOfValidator.java | 11 +++++++++- .../{ => keyword}/AnnotationKeyword.java | 7 ++++++- .../schema/{ => keyword}/AnyOfValidator.java | 12 ++++++++++- .../{ => keyword}/BaseKeywordValidator.java | 9 +++++++- .../schema/{ => keyword}/ConstValidator.java | 8 ++++++- .../{ => keyword}/ContainsValidator.java | 12 ++++++++--- .../ContentEncodingValidator.java | 9 +++++++- .../ContentMediaTypeValidator.java | 9 +++++++- .../{ => keyword}/DependenciesValidator.java | 8 ++++++- .../{ => keyword}/DependentRequired.java | 8 ++++++- .../{ => keyword}/DependentSchemas.java | 8 ++++++- .../DisallowUnknownKeywordFactory.java | 6 +++++- .../{ => keyword}/DiscriminatorValidator.java | 21 ++++++++++++------- .../{ => keyword}/DynamicRefValidator.java | 17 ++++++++++++--- .../schema/{ => keyword}/EnumValidator.java | 10 ++++++++- .../ExclusiveMaximumValidator.java | 10 ++++++++- .../ExclusiveMinimumValidator.java | 10 ++++++++- .../schema/{ => keyword}/FalseValidator.java | 8 ++++++- .../schema/{ => keyword}/FormatKeyword.java | 7 ++++++- .../schema/{ => keyword}/FormatValidator.java | 8 ++++++- .../schema/{ => keyword}/IfValidator.java | 12 ++++++++--- .../schema/{ => keyword}/ItemsValidator.java | 16 +++++++++----- .../{ => keyword}/ItemsValidator202012.java | 8 ++++++- .../schema/{ => keyword}/Keyword.java | 7 ++++++- .../schema/{ => keyword}/KeywordFactory.java | 4 +++- .../{ => keyword}/KeywordValidator.java | 7 +++++-- .../{ => keyword}/MaxItemsValidator.java | 8 ++++++- .../{ => keyword}/MaxLengthValidator.java | 10 ++++++++- .../{ => keyword}/MaxPropertiesValidator.java | 8 ++++++- .../{ => keyword}/MaximumValidator.java | 10 ++++++++- .../{ => keyword}/MinItemsValidator.java | 8 ++++++- .../{ => keyword}/MinLengthValidator.java | 10 ++++++++- .../MinMaxContainsValidator.java | 7 ++++++- .../{ => keyword}/MinPropertiesValidator.java | 8 ++++++- .../{ => keyword}/MinimumValidator.java | 10 ++++++++- .../{ => keyword}/MultipleOfValidator.java | 7 ++++++- .../{ => keyword}/NonValidationKeyword.java | 7 ++++++- .../{ => keyword}/NotAllowedValidator.java | 8 ++++++- .../schema/{ => keyword}/NotValidator.java | 8 ++++++- .../schema/{ => keyword}/OneOfValidator.java | 12 ++++++++++- .../PatternPropertiesValidator.java | 8 ++++++- .../{ => keyword}/PatternValidator.java | 11 +++++++++- .../{ => keyword}/PrefixItemsValidator.java | 8 ++++++- .../{ => keyword}/PropertiesValidator.java | 8 ++++++- .../{ => keyword}/PropertyNamesValidator.java | 8 ++++++- .../{ => keyword}/ReadOnlyValidator.java | 7 ++++++- .../{ => keyword}/RecursiveRefValidator.java | 13 +++++++++++- .../schema/{ => keyword}/RefValidator.java | 17 ++++++++++++--- .../{ => keyword}/RequiredValidator.java | 8 ++++++- .../schema/{ => keyword}/TrueValidator.java | 8 ++++++- .../schema/{ => keyword}/TypeValidator.java | 9 +++++++- .../UnevaluatedItemsValidator.java | 11 +++++++--- .../UnevaluatedPropertiesValidator.java | 7 ++++++- .../{ => keyword}/UnionTypeValidator.java | 13 +++++++++++- .../{ => keyword}/UniqueItemsValidator.java | 8 ++++++- .../{ => keyword}/UnknownKeywordFactory.java | 4 +++- .../{ => keyword}/ValidatorTypeCode.java | 7 ++++++- .../{ => keyword}/WriteOnlyValidator.java | 7 ++++++- .../com/networknt/schema/oas/OpenApi30.java | 6 +++--- .../com/networknt/schema/oas/OpenApi31.java | 4 ++-- .../schema/utils/JsonSchemaRefs.java | 8 +++---- .../walk/AbstractWalkListenerRunner.java | 2 +- .../walk/DefaultItemWalkListenerRunner.java | 2 +- .../DefaultKeywordWalkListenerRunner.java | 2 +- .../DefaultPropertyWalkListenerRunner.java | 2 +- .../com/networknt/schema/walk/WalkEvent.java | 2 +- .../schema/walk/WalkListenerRunner.java | 2 +- .../schema/AbstractJsonSchemaTest.java | 1 + .../schema/CollectorContextTest.java | 3 +++ .../schema/CustomMetaSchemaTest.java | 4 ++++ .../DisallowUnknownKeywordFactoryTest.java | 1 + .../schema/ExclusiveMinimumValidatorTest.java | 1 + .../schema/FormatKeywordFactoryTest.java | 2 ++ .../com/networknt/schema/IfValidatorTest.java | 1 + .../com/networknt/schema/Issue461Test.java | 1 + .../com/networknt/schema/Issue467Test.java | 1 + .../schema/Issue769ContainsTest.java | 3 +++ .../com/networknt/schema/JsonWalkTest.java | 4 ++++ .../com/networknt/schema/MessageTest.java | 3 +++ .../schema/NotAllowedValidatorTest.java | 3 +++ .../schema/PrefixItemsValidatorTest.java | 1 + ...ursiveReferenceValidatorExceptionTest.java | 2 ++ .../schema/UnknownKeywordFactoryTest.java | 4 ++++ .../schema/ValidatorTypeCodeTest.java | 2 ++ .../com/networknt/schema/VocabularyTest.java | 1 + .../walk/JsonSchemaWalkListenerTest.java | 8 +++---- 103 files changed, 568 insertions(+), 109 deletions(-) rename src/main/java/com/networknt/schema/{ => keyword}/AbstractKeyword.java (97%) rename src/main/java/com/networknt/schema/{ => keyword}/AbstractKeywordValidator.java (95%) rename src/main/java/com/networknt/schema/{ => keyword}/AdditionalPropertiesValidator.java (94%) rename src/main/java/com/networknt/schema/{ => keyword}/AllOfValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/AnnotationKeyword.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/AnyOfValidator.java (95%) rename src/main/java/com/networknt/schema/{ => keyword}/BaseKeywordValidator.java (95%) rename src/main/java/com/networknt/schema/{ => keyword}/ConstValidator.java (89%) rename src/main/java/com/networknt/schema/{ => keyword}/ContainsValidator.java (96%) rename src/main/java/com/networknt/schema/{ => keyword}/ContentEncodingValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/ContentMediaTypeValidator.java (93%) rename src/main/java/com/networknt/schema/{ => keyword}/DependenciesValidator.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/DependentRequired.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/DependentSchemas.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/DisallowUnknownKeywordFactory.java (88%) rename src/main/java/com/networknt/schema/{ => keyword}/DiscriminatorValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/DynamicRefValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/EnumValidator.java (94%) rename src/main/java/com/networknt/schema/{ => keyword}/ExclusiveMaximumValidator.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/ExclusiveMinimumValidator.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/FalseValidator.java (87%) rename src/main/java/com/networknt/schema/{ => keyword}/FormatKeyword.java (89%) rename src/main/java/com/networknt/schema/{ => keyword}/FormatValidator.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/IfValidator.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/ItemsValidator.java (95%) rename src/main/java/com/networknt/schema/{ => keyword}/ItemsValidator202012.java (96%) rename src/main/java/com/networknt/schema/{ => keyword}/Keyword.java (85%) rename src/main/java/com/networknt/schema/{ => keyword}/KeywordFactory.java (89%) rename src/main/java/com/networknt/schema/{ => keyword}/KeywordValidator.java (81%) rename src/main/java/com/networknt/schema/{ => keyword}/MaxItemsValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/MaxLengthValidator.java (84%) rename src/main/java/com/networknt/schema/{ => keyword}/MaxPropertiesValidator.java (86%) rename src/main/java/com/networknt/schema/{ => keyword}/MaximumValidator.java (93%) rename src/main/java/com/networknt/schema/{ => keyword}/MinItemsValidator.java (89%) rename src/main/java/com/networknt/schema/{ => keyword}/MinLengthValidator.java (84%) rename src/main/java/com/networknt/schema/{ => keyword}/MinMaxContainsValidator.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/MinPropertiesValidator.java (86%) rename src/main/java/com/networknt/schema/{ => keyword}/MinimumValidator.java (93%) rename src/main/java/com/networknt/schema/{ => keyword}/MultipleOfValidator.java (93%) rename src/main/java/com/networknt/schema/{ => keyword}/NonValidationKeyword.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/NotAllowedValidator.java (87%) rename src/main/java/com/networknt/schema/{ => keyword}/NotValidator.java (90%) rename src/main/java/com/networknt/schema/{ => keyword}/OneOfValidator.java (94%) rename src/main/java/com/networknt/schema/{ => keyword}/PatternPropertiesValidator.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/PatternValidator.java (86%) rename src/main/java/com/networknt/schema/{ => keyword}/PrefixItemsValidator.java (96%) rename src/main/java/com/networknt/schema/{ => keyword}/PropertiesValidator.java (94%) rename src/main/java/com/networknt/schema/{ => keyword}/PropertyNamesValidator.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/ReadOnlyValidator.java (86%) rename src/main/java/com/networknt/schema/{ => keyword}/RecursiveRefValidator.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/RefValidator.java (93%) rename src/main/java/com/networknt/schema/{ => keyword}/RequiredValidator.java (91%) rename src/main/java/com/networknt/schema/{ => keyword}/TrueValidator.java (85%) rename src/main/java/com/networknt/schema/{ => keyword}/TypeValidator.java (89%) rename src/main/java/com/networknt/schema/{ => keyword}/UnevaluatedItemsValidator.java (96%) rename src/main/java/com/networknt/schema/{ => keyword}/UnevaluatedPropertiesValidator.java (94%) rename src/main/java/com/networknt/schema/{ => keyword}/UnionTypeValidator.java (88%) rename src/main/java/com/networknt/schema/{ => keyword}/UniqueItemsValidator.java (86%) rename src/main/java/com/networknt/schema/{ => keyword}/UnknownKeywordFactory.java (92%) rename src/main/java/com/networknt/schema/{ => keyword}/ValidatorTypeCode.java (97%) rename src/main/java/com/networknt/schema/{ => keyword}/WriteOnlyValidator.java (83%) diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/Format.java index 85fec7845..ba3246a60 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/Format.java @@ -19,6 +19,7 @@ import java.util.function.Supplier; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.keyword.FormatValidator; /** * Used to implement the various formats for the format keyword. diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index 9d82eb7bd..db524ab60 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -18,6 +18,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.FormatKeyword; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.KeywordFactory; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.keyword.UnknownKeywordFactory; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index 5227c91db..d77d6f1e4 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -32,6 +32,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.DiscriminatorValidator; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.keyword.TypeValidator; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.utils.JsonNodes; /** diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 6e4d56787..0e2048b99 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -626,7 +626,7 @@ public JsonSchema getSchema(final SchemaLocation schemaUri, final SchemaValidato * @param config the config * @return the schema */ - protected JsonSchema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { + public JsonSchema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { if (enableSchemaCache) { // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java index a98cf6b90..3046bd514 100644 --- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java +++ b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.i18n.DefaultMessageSource; import com.networknt.schema.i18n.MessageSource; +import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.regex.ECMAScriptRegularExpressionFactory; import com.networknt.schema.regex.JDKRegularExpressionFactory; import com.networknt.schema.regex.RegularExpressionFactory; @@ -325,7 +326,7 @@ public Boolean getFormatAssertionsEnabled() { return formatAssertionsEnabled; } - WalkListenerRunner getItemWalkListenerRunner() { + public WalkListenerRunner getItemWalkListenerRunner() { return this.itemWalkListenerRunner; } @@ -384,7 +385,7 @@ public int getPreloadJsonSchemaRefMaxNestingDepth() { return preloadJsonSchemaRefMaxNestingDepth; } - WalkListenerRunner getPropertyWalkListenerRunner() { + public WalkListenerRunner getPropertyWalkListenerRunner() { return this.propertyWalkListenerRunner; } @@ -510,7 +511,7 @@ public boolean isReadOnly() { return null != this.readOnly && this.readOnly; } - Boolean getReadOnly() { + public Boolean getReadOnly() { return this.readOnly; } @@ -552,7 +553,7 @@ public boolean isWriteOnly() { return null != this.writeOnly && this.writeOnly; } - Boolean getWriteOnly() { + public Boolean getWriteOnly() { return this.writeOnly; } diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index 1d6a54b8e..729d06a9e 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.KeywordValidator; public class ValidationContext { private final JsonMetaSchema metaSchema; diff --git a/src/main/java/com/networknt/schema/Version201909.java b/src/main/java/com/networknt/schema/Version201909.java index 69763f2bc..d085b2c0a 100644 --- a/src/main/java/com/networknt/schema/Version201909.java +++ b/src/main/java/com/networknt/schema/Version201909.java @@ -4,6 +4,9 @@ import java.util.HashMap; import java.util.Map; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Draft 2019-09 dialect. */ diff --git a/src/main/java/com/networknt/schema/Version202012.java b/src/main/java/com/networknt/schema/Version202012.java index 32fabc35a..d8e8caa79 100644 --- a/src/main/java/com/networknt/schema/Version202012.java +++ b/src/main/java/com/networknt/schema/Version202012.java @@ -4,6 +4,9 @@ import java.util.HashMap; import java.util.Map; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Draft 2020-12 dialect. */ diff --git a/src/main/java/com/networknt/schema/Version4.java b/src/main/java/com/networknt/schema/Version4.java index 84ad7138a..dcec9284d 100644 --- a/src/main/java/com/networknt/schema/Version4.java +++ b/src/main/java/com/networknt/schema/Version4.java @@ -2,6 +2,10 @@ import java.util.Arrays; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Draft 4 dialect. */ diff --git a/src/main/java/com/networknt/schema/Version6.java b/src/main/java/com/networknt/schema/Version6.java index 3b308227d..8080fe993 100644 --- a/src/main/java/com/networknt/schema/Version6.java +++ b/src/main/java/com/networknt/schema/Version6.java @@ -2,6 +2,10 @@ import java.util.Arrays; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Draft 6 dialect. */ diff --git a/src/main/java/com/networknt/schema/Version7.java b/src/main/java/com/networknt/schema/Version7.java index de8d2d74d..e42c088ca 100644 --- a/src/main/java/com/networknt/schema/Version7.java +++ b/src/main/java/com/networknt/schema/Version7.java @@ -2,6 +2,10 @@ import java.util.Arrays; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Draft 7 dialect. */ diff --git a/src/main/java/com/networknt/schema/Vocabulary.java b/src/main/java/com/networknt/schema/Vocabulary.java index aa2c360de..7bc9295d1 100644 --- a/src/main/java/com/networknt/schema/Vocabulary.java +++ b/src/main/java/com/networknt/schema/Vocabulary.java @@ -20,6 +20,11 @@ import java.util.Objects; import java.util.Set; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * Represents a vocabulary in meta-schema. *

diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java index 086bc35ee..5843b11f2 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java +++ b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java @@ -18,8 +18,8 @@ import java.util.Objects; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.Keyword; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.keyword.Keyword; /** * The annotation. diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index 02a459a85..4cbd10183 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -3,14 +3,14 @@ import java.util.Map; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.BaseKeywordValidator; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.Keyword; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.BaseKeywordValidator; +import com.networknt.schema.keyword.Keyword; public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; diff --git a/src/main/java/com/networknt/schema/AbstractKeyword.java b/src/main/java/com/networknt/schema/keyword/AbstractKeyword.java similarity index 97% rename from src/main/java/com/networknt/schema/AbstractKeyword.java rename to src/main/java/com/networknt/schema/keyword/AbstractKeyword.java index 3b6945d9f..3683b2123 100644 --- a/src/main/java/com/networknt/schema/AbstractKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AbstractKeyword.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.Objects; diff --git a/src/main/java/com/networknt/schema/AbstractKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java similarity index 95% rename from src/main/java/com/networknt/schema/AbstractKeywordValidator.java rename to src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java index 54814e4c6..1e76b4e1d 100644 --- a/src/main/java/com/networknt/schema/AbstractKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java @@ -14,11 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.function.Consumer; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.SchemaLocation; import com.networknt.schema.annotation.JsonNodeAnnotation; /** diff --git a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java similarity index 94% rename from src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index 50a167fe8..b2ab75a8c 100644 --- a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; diff --git a/src/main/java/com/networknt/schema/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/AllOfValidator.java rename to src/main/java/com/networknt/schema/keyword/AllOfValidator.java index beacad495..d2a6080ab 100644 --- a/src/main/java/com/networknt/schema/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -14,12 +14,21 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.*; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.DiscriminatorContext; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/AnnotationKeyword.java b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java similarity index 90% rename from src/main/java/com/networknt/schema/AnnotationKeyword.java rename to src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java index 6d3908935..61e04643f 100644 --- a/src/main/java/com/networknt/schema/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; /** * Used for Keywords that have no validation aspect, but are part of the metaschema, where annotations may need to be collected. diff --git a/src/main/java/com/networknt/schema/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java similarity index 95% rename from src/main/java/com/networknt/schema/AnyOfValidator.java rename to src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index f298e2e36..547bd163f 100644 --- a/src/main/java/com/networknt/schema/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -14,9 +14,19 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.DiscriminatorContext; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java similarity index 95% rename from src/main/java/com/networknt/schema/BaseKeywordValidator.java rename to src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 8a18d8b78..6257adadc 100644 --- a/src/main/java/com/networknt/schema/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -14,9 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ErrorMessages; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.MessageSourceError; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java similarity index 89% rename from src/main/java/com/networknt/schema/ConstValidator.java rename to src/main/java/com/networknt/schema/keyword/ConstValidator.java index e94ee8320..f8e828eb5 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java similarity index 96% rename from src/main/java/com/networknt/schema/ContainsValidator.java rename to src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 934156995..6a8d3146e 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -14,21 +14,27 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static com.networknt.schema.keyword.VersionCode.MinV201909; + import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Optional; -import static com.networknt.schema.VersionCode.MinV201909; - /** * {@link KeywordValidator} for contains. */ diff --git a/src/main/java/com/networknt/schema/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/ContentEncodingValidator.java rename to src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index d0d3ce773..12a868c96 100644 --- a/src/main/java/com/networknt/schema/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -14,9 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java similarity index 93% rename from src/main/java/com/networknt/schema/ContentMediaTypeValidator.java rename to src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 87b3d0ce8..775091452 100644 --- a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -25,6 +25,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import com.networknt.schema.serialization.JsonMapperFactory; /** diff --git a/src/main/java/com/networknt/schema/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java similarity index 91% rename from src/main/java/com/networknt/schema/DependenciesValidator.java rename to src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 4a7b3ebd1..73824d975 100644 --- a/src/main/java/com/networknt/schema/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java similarity index 91% rename from src/main/java/com/networknt/schema/DependentRequired.java rename to src/main/java/com/networknt/schema/keyword/DependentRequired.java index eb52ddadc..1beb00dd8 100644 --- a/src/main/java/com/networknt/schema/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java similarity index 92% rename from src/main/java/com/networknt/schema/DependentSchemas.java rename to src/main/java/com/networknt/schema/keyword/DependentSchemas.java index eaf6de355..944e4c9ea 100644 --- a/src/main/java/com/networknt/schema/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java b/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java similarity index 88% rename from src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java rename to src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java index 7c52edf5c..64c3dd5f2 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java @@ -13,11 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.networknt.schema.Error; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.ValidationContext; + /** * Unknown keyword factory that rejects unknown keywords. */ diff --git a/src/main/java/com/networknt/schema/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/DiscriminatorValidator.java rename to src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index d9b2660ff..d03bd0951 100644 --- a/src/main/java/com/networknt/schema/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.Collections; import java.util.HashMap; @@ -24,6 +24,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.DiscriminatorContext; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; /** * {@link KeywordValidator} that resolves discriminator. @@ -131,9 +138,9 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr final ObjectNode discriminator, final JsonSchema schema, final JsonNodePath instanceLocation) { - final JsonNode discriminatorOnSchema = schema.schemaNode.get("discriminator"); + final JsonNode discriminatorOnSchema = schema.getSchemaNode().get("discriminator"); if (null != discriminatorOnSchema && null != currentDiscriminatorContext - .getDiscriminatorForPath(schema.schemaLocation)) { + .getDiscriminatorForPath(schema.getSchemaLocation())) { // this is where A -> B -> C inheritance exists, A has the root discriminator and B adds to the mapping final JsonNode propertyName = discriminatorOnSchema.get("propertyName"); if (null != propertyName) { @@ -164,13 +171,13 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr } } } - currentDiscriminatorContext.registerDiscriminator(schema.schemaLocation, discriminator); + currentDiscriminatorContext.registerDiscriminator(schema.getSchemaLocation(), discriminator); } private static void checkForImplicitDiscriminatorMappingMatch(final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, final JsonSchema schema) { - if (schema.schemaLocation.getFragment().getName(-1).equals(discriminatorPropertyValue)) { + if (schema.getSchemaLocation().getFragment().getName(-1).equals(discriminatorPropertyValue)) { currentDiscriminatorContext.markMatch(); } } @@ -183,7 +190,7 @@ private static void checkForExplicitDiscriminatorMappingMatch(final Discriminato while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); if (candidateExplicitMapping.getKey().equals(discriminatorPropertyValue) - && ("#" + schema.schemaLocation.getFragment().toString()) + && ("#" + schema.getSchemaLocation().getFragment().toString()) .equals(candidateExplicitMapping.getValue().asText())) { currentDiscriminatorContext.markMatch(); break; @@ -197,7 +204,7 @@ private static boolean noExplicitDiscriminatorKeyOverride(final JsonNode discrim while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); if (candidateExplicitMapping.getValue().asText() - .equals(parentSchema.schemaLocation.getFragment().toString())) { + .equals(parentSchema.getSchemaLocation().getFragment().toString())) { return false; } } diff --git a/src/main/java/com/networknt/schema/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/DynamicRefValidator.java rename to src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 07cb96192..a5462464f 100644 --- a/src/main/java/com/networknt/schema/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -14,9 +14,20 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.CachedSupplier; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.InvalidSchemaRefException; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,8 +94,8 @@ static Supplier getSupplier(Supplier supplier, boolean cache) { private static String resolve(JsonSchema parentSchema, String refValue) { // $ref prevents a sibling $id from changing the base uri JsonSchema base = parentSchema; - if (parentSchema.getId() != null && parentSchema.parentSchema != null) { - base = parentSchema.parentSchema; + if (parentSchema.getId() != null && parentSchema.getParentSchema() != null) { + base = parentSchema.getParentSchema(); } return SchemaLocation.resolve(base.getSchemaLocation(), refValue); } diff --git a/src/main/java/com/networknt/schema/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java similarity index 94% rename from src/main/java/com/networknt/schema/EnumValidator.java rename to src/main/java/com/networknt/schema/keyword/EnumValidator.java index 66fb7d0c8..48e4d6d94 100644 --- a/src/main/java/com/networknt/schema/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -14,12 +14,20 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.DecimalNode; import com.fasterxml.jackson.databind.node.NullNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java similarity index 92% rename from src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java rename to src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 52b4f1539..7f64cce96 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ThresholdMixin; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java similarity index 92% rename from src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java rename to src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 0b363ff0a..346f0effe 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ThresholdMixin; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java similarity index 87% rename from src/main/java/com/networknt/schema/FalseValidator.java rename to src/main/java/com/networknt/schema/keyword/FalseValidator.java index a1621c7ca..fc3b583c0 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java similarity index 89% rename from src/main/java/com/networknt/schema/FormatKeyword.java rename to src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 7dd3cda52..62d43924f 100644 --- a/src/main/java/com/networknt/schema/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Format; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java similarity index 92% rename from src/main/java/com/networknt/schema/FormatValidator.java rename to src/main/java/com/networknt/schema/keyword/FormatValidator.java index c98fe24b5..6d8e9faf2 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.Format; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.format.BaseFormatJsonValidator; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java similarity index 91% rename from src/main/java/com/networknt/schema/IfValidator.java rename to src/main/java/com/networknt/schema/keyword/IfValidator.java index 28e30b240..9f422686b 100644 --- a/src/main/java/com/networknt/schema/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,8 +50,8 @@ public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, J for (final String keyword : KEYWORDS) { final JsonNode node = parentSchema.getSchemaNode().get(keyword); - final SchemaLocation schemaLocationOfSchema = parentSchema.schemaLocation.append(keyword); - final JsonNodePath evaluationPathOfSchema = parentSchema.evaluationPath.append(keyword); + final SchemaLocation schemaLocationOfSchema = parentSchema.getSchemaLocation().append(keyword); + final JsonNodePath evaluationPathOfSchema = parentSchema.getEvaluationPath().append(keyword); if (keyword.equals("if")) { foundIfSchema = validationContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, parentSchema); diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java similarity index 95% rename from src/main/java/com/networknt/schema/ItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 15f671f96..5c43a456f 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -14,10 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; @@ -72,16 +78,16 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath additionalItems = addItemNode.asBoolean(); } else if (addItemNode.isObject()) { foundAdditionalSchema = validationContext.newSchema( - parentSchema.schemaLocation.append(PROPERTY_ADDITIONAL_ITEMS), - parentSchema.evaluationPath.append(PROPERTY_ADDITIONAL_ITEMS), addItemNode, parentSchema); + parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS), + parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS), addItemNode, parentSchema); } } } this.additionalItems = additionalItems; this.schema = foundSchema; this.additionalSchema = foundAdditionalSchema; - this.additionalItemsEvaluationPath = parentSchema.evaluationPath.append(PROPERTY_ADDITIONAL_ITEMS); - this.additionalItemsSchemaLocation = parentSchema.schemaLocation.append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsEvaluationPath = parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsSchemaLocation = parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS); this.additionalItemsSchemaNode = additionalItemsSchemaNode; } diff --git a/src/main/java/com/networknt/schema/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java similarity index 96% rename from src/main/java/com/networknt/schema/ItemsValidator202012.java rename to src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 23ab6cfc0..83033a2eb 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -14,10 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; diff --git a/src/main/java/com/networknt/schema/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java similarity index 85% rename from src/main/java/com/networknt/schema/Keyword.java rename to src/main/java/com/networknt/schema/keyword/Keyword.java index 82f012b1e..62989e17e 100644 --- a/src/main/java/com/networknt/schema/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; /** * Represents a keyword. diff --git a/src/main/java/com/networknt/schema/KeywordFactory.java b/src/main/java/com/networknt/schema/keyword/KeywordFactory.java similarity index 89% rename from src/main/java/com/networknt/schema/KeywordFactory.java rename to src/main/java/com/networknt/schema/keyword/KeywordFactory.java index e887bc580..8711b5d96 100644 --- a/src/main/java/com/networknt/schema/KeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordFactory.java @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; + +import com.networknt.schema.ValidationContext; /** * Factory for {@link Keyword}. diff --git a/src/main/java/com/networknt/schema/KeywordValidator.java b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java similarity index 81% rename from src/main/java/com/networknt/schema/KeywordValidator.java rename to src/main/java/com/networknt/schema/keyword/KeywordValidator.java index c9a43d010..0727f7896 100644 --- a/src/main/java/com/networknt/schema/KeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java @@ -14,14 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; + +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.Validator; /** * KeywordValidator interface implemented by all keyword validators. */ public interface KeywordValidator extends Validator { /** - * In case the {@link com.networknt.schema.KeywordValidator} has a related {@link com.networknt.schema.JsonSchema} or several + * In case the {@link com.networknt.schema.keyword.KeywordValidator} has a related {@link com.networknt.schema.JsonSchema} or several * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. * * @throws JsonSchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.JsonSchema} or nested schemas diff --git a/src/main/java/com/networknt/schema/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/MaxItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index b9ff5d403..a23fc4fa4 100644 --- a/src/main/java/com/networknt/schema/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java similarity index 84% rename from src/main/java/com/networknt/schema/MaxLengthValidator.java rename to src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 830c4236d..70fd7a1ec 100644 --- a/src/main/java/com/networknt/schema/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java similarity index 86% rename from src/main/java/com/networknt/schema/MaxPropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index c4938ffcc..21e5ab879 100644 --- a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java similarity index 93% rename from src/main/java/com/networknt/schema/MaximumValidator.java rename to src/main/java/com/networknt/schema/keyword/MaximumValidator.java index db407acef..a389fd177 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ThresholdMixin; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java similarity index 89% rename from src/main/java/com/networknt/schema/MinItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index cb886d384..e076b7919 100644 --- a/src/main/java/com/networknt/schema/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java similarity index 84% rename from src/main/java/com/networknt/schema/MinLengthValidator.java rename to src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index a3810e8c6..eac2b9b4d 100644 --- a/src/main/java/com/networknt/schema/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java similarity index 92% rename from src/main/java/com/networknt/schema/MinMaxContainsValidator.java rename to src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 6306b5d62..7a9881bc2 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -1,6 +1,11 @@ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import java.util.LinkedHashSet; import java.util.Set; diff --git a/src/main/java/com/networknt/schema/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java similarity index 86% rename from src/main/java/com/networknt/schema/MinPropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index bd0c3e818..5d1428959 100644 --- a/src/main/java/com/networknt/schema/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java similarity index 93% rename from src/main/java/com/networknt/schema/MinimumValidator.java rename to src/main/java/com/networknt/schema/keyword/MinimumValidator.java index dc8d6b661..c84f2f019 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -14,9 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ThresholdMixin; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java similarity index 93% rename from src/main/java/com/networknt/schema/MultipleOfValidator.java rename to src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index 25ca4ce90..a682b5116 100644 --- a/src/main/java/com/networknt/schema/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java similarity index 92% rename from src/main/java/com/networknt/schema/NonValidationKeyword.java rename to src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index 5c00c8240..91e2118f7 100644 --- a/src/main/java/com/networknt/schema/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import java.util.Iterator; import java.util.Map.Entry; diff --git a/src/main/java/com/networknt/schema/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java similarity index 87% rename from src/main/java/com/networknt/schema/NotAllowedValidator.java rename to src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index 5b0b724ee..dae77ee8b 100644 --- a/src/main/java/com/networknt/schema/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/NotValidator.java rename to src/main/java/com/networknt/schema/keyword/NotValidator.java index 0e18af03c..cc6a3eb44 100644 --- a/src/main/java/com/networknt/schema/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java similarity index 94% rename from src/main/java/com/networknt/schema/OneOfValidator.java rename to src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 6374345a5..879930f65 100644 --- a/src/main/java/com/networknt/schema/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.ArrayList; import java.util.List; @@ -24,6 +24,16 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.DiscriminatorContext; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; /** * {@link KeywordValidator} for oneOf. diff --git a/src/main/java/com/networknt/schema/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java similarity index 91% rename from src/main/java/com/networknt/schema/PatternPropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 1ef9bf81e..11dea453e 100644 --- a/src/main/java/com/networknt/schema/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java similarity index 86% rename from src/main/java/com/networknt/schema/PatternValidator.java rename to src/main/java/com/networknt/schema/keyword/PatternValidator.java index 992958478..e2831ca2e 100644 --- a/src/main/java/com/networknt/schema/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -14,9 +14,18 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.FailFastAssertionException; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import com.networknt.schema.regex.RegularExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java similarity index 96% rename from src/main/java/com/networknt/schema/PrefixItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 0188f4f1c..be4113dc7 100644 --- a/src/main/java/com/networknt/schema/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -14,10 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; diff --git a/src/main/java/com/networknt/schema/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java similarity index 94% rename from src/main/java/com/networknt/schema/PropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index a454caf64..6042d744d 100644 --- a/src/main/java/com/networknt/schema/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -14,12 +14,18 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; diff --git a/src/main/java/com/networknt/schema/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java similarity index 91% rename from src/main/java/com/networknt/schema/PropertyNamesValidator.java rename to src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 320f9dae5..ce07bf892 100644 --- a/src/main/java/com/networknt/schema/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.ArrayList; import java.util.Iterator; @@ -24,6 +24,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PropertyNamesValidator.class); diff --git a/src/main/java/com/networknt/schema/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java similarity index 86% rename from src/main/java/com/networknt/schema/ReadOnlyValidator.java rename to src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index 5abdcf483..0e3ebfba4 100644 --- a/src/main/java/com/networknt/schema/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -14,12 +14,17 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; /** * {@link KeywordValidator} for readOnly. diff --git a/src/main/java/com/networknt/schema/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java similarity index 92% rename from src/main/java/com/networknt/schema/RecursiveRefValidator.java rename to src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 60c255dc2..6962720a2 100644 --- a/src/main/java/com/networknt/schema/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -14,9 +14,20 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.CachedSupplier; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.InvalidSchemaRefException; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java similarity index 93% rename from src/main/java/com/networknt/schema/RefValidator.java rename to src/main/java/com/networknt/schema/keyword/RefValidator.java index 73e16185f..2a75a55fd 100644 --- a/src/main/java/com/networknt/schema/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -14,9 +14,20 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.CachedSupplier; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.InvalidSchemaRefException; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -141,8 +152,8 @@ private static void copySchemaResources(ValidationContext validationContext, Jso private static String resolve(JsonSchema parentSchema, String refValue) { // $ref prevents a sibling $id from changing the base uri JsonSchema base = parentSchema; - if (parentSchema.getId() != null && parentSchema.parentSchema != null) { - base = parentSchema.parentSchema; + if (parentSchema.getId() != null && parentSchema.getParentSchema() != null) { + base = parentSchema.getParentSchema(); } return SchemaLocation.resolve(base.getSchemaLocation(), refValue); } diff --git a/src/main/java/com/networknt/schema/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java similarity index 91% rename from src/main/java/com/networknt/schema/RequiredValidator.java rename to src/main/java/com/networknt/schema/keyword/RequiredValidator.java index 350e36d73..283bca0af 100644 --- a/src/main/java/com/networknt/schema/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java similarity index 85% rename from src/main/java/com/networknt/schema/TrueValidator.java rename to src/main/java/com/networknt/schema/keyword/TrueValidator.java index ed7943207..ec41b30a1 100644 --- a/src/main/java/com/networknt/schema/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java similarity index 89% rename from src/main/java/com/networknt/schema/TypeValidator.java rename to src/main/java/com/networknt/schema/keyword/TypeValidator.java index cfb22da33..d5ca72dac 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -14,9 +14,16 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java similarity index 96% rename from src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index a7c6ed850..e68feb3e5 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -14,21 +14,26 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.annotation.JsonNodeAnnotation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static com.networknt.schema.keyword.VersionCode.MinV202012; + import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; -import static com.networknt.schema.VersionCode.MinV202012; - /** * {@link KeywordValidator} for unevaluatedItems. */ diff --git a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java similarity index 94% rename from src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java rename to src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index ac9e3dec6..3d7ab80c7 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java similarity index 88% rename from src/main/java/com/networknt/schema/UnionTypeValidator.java rename to src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 3649c76c7..28f537089 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -14,9 +14,20 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.ValidationContext; +import com.networknt.schema.Validator; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java similarity index 86% rename from src/main/java/com/networknt/schema/UniqueItemsValidator.java rename to src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index 19d371920..408482bb0 100644 --- a/src/main/java/com/networknt/schema/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -14,9 +14,15 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/UnknownKeywordFactory.java b/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java similarity index 92% rename from src/main/java/com/networknt/schema/UnknownKeywordFactory.java rename to src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java index 688330d18..f17d9c8d5 100644 --- a/src/main/java/com/networknt/schema/UnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -21,6 +21,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.networknt.schema.ValidationContext; + /** * Unknown keyword factory. *

diff --git a/src/main/java/com/networknt/schema/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java similarity index 97% rename from src/main/java/com/networknt/schema/ValidatorTypeCode.java rename to src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index c2513207a..5b0a783f9 100644 --- a/src/main/java/com/networknt/schema/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -14,9 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SpecVersion; +import com.networknt.schema.ValidationContext; import com.networknt.schema.SpecVersion.VersionFlag; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java similarity index 83% rename from src/main/java/com/networknt/schema/WriteOnlyValidator.java rename to src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index a42fc3016..c25475693 100644 --- a/src/main/java/com/networknt/schema/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -1,9 +1,14 @@ -package com.networknt.schema; +package com.networknt.schema.keyword; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.ValidationContext; /** * {@link KeywordValidator} for writeOnly. diff --git a/src/main/java/com/networknt/schema/oas/OpenApi30.java b/src/main/java/com/networknt/schema/oas/OpenApi30.java index 7c6e4e24f..4e34f056e 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi30.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi30.java @@ -2,13 +2,13 @@ import java.util.Arrays; -import com.networknt.schema.AnnotationKeyword; import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; -import com.networknt.schema.NonValidationKeyword; import com.networknt.schema.SchemaId; import com.networknt.schema.SpecVersion; -import com.networknt.schema.ValidatorTypeCode; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; /** * OpenAPI 3.0. diff --git a/src/main/java/com/networknt/schema/oas/OpenApi31.java b/src/main/java/com/networknt/schema/oas/OpenApi31.java index 69f1a50a1..0c8db320d 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi31.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi31.java @@ -6,10 +6,10 @@ import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; -import com.networknt.schema.NonValidationKeyword; import com.networknt.schema.SchemaId; import com.networknt.schema.SpecVersion; -import com.networknt.schema.ValidatorTypeCode; +import com.networknt.schema.keyword.NonValidationKeyword; +import com.networknt.schema.keyword.ValidatorTypeCode; /** * OpenAPI 3.1. diff --git a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java index 6d038d969..c8f54ebe9 100644 --- a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java +++ b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java @@ -15,12 +15,12 @@ */ package com.networknt.schema.utils; -import com.networknt.schema.DynamicRefValidator; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaRef; -import com.networknt.schema.KeywordValidator; -import com.networknt.schema.RecursiveRefValidator; -import com.networknt.schema.RefValidator; +import com.networknt.schema.keyword.DynamicRefValidator; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.keyword.RecursiveRefValidator; +import com.networknt.schema.keyword.RefValidator; /** * Utility methods for JsonSchemaRef. diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index acc96faf9..23dc711fc 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; import java.util.List; diff --git a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java index 496a4e6d8..b56033e34 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; import java.util.List; diff --git a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java index 08f9a9a7b..61ce47909 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java @@ -8,8 +8,8 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.keyword.KeywordValidator; public class DefaultKeywordWalkListenerRunner extends AbstractWalkListenerRunner { diff --git a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java index c04040345..a1beda793 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; import java.util.List; diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index b34fb9688..47e47ce70 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; /** * Encapsulation of Walk data that is passed into the {@link JsonSchemaWalkListener}. diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index dc800b1a1..69a6cecc0 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -4,7 +4,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; -import com.networknt.schema.KeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; import java.util.List; diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 2241bd77f..a4d137af7 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.serialization.JsonMapperFactory; import java.io.IOException; diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index d5e912094..f32c335ec 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -20,6 +20,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.AbstractKeywordValidator; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.KeywordValidator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 3abb9e4ef..b01537219 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -18,6 +18,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.keyword.AbstractKeyword; +import com.networknt.schema.keyword.AbstractKeywordValidator; +import com.networknt.schema.keyword.KeywordValidator; + import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index f2b397af9..41f0a20eb 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; class DisallowUnknownKeywordFactoryTest { @Test diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 1780a0959..c0a14e431 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; /** * Test ExclusiveMinimumValidator validator. diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index c85cc4a38..da19135c2 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.FormatKeyword; +import com.networknt.schema.keyword.KeywordValidator; class FormatKeywordFactoryTest { diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 57533907d..50203c27d 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index c174a858a..a9c96d8e0 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 2442702ec..8b10d8842 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; diff --git a/src/test/java/com/networknt/schema/Issue769ContainsTest.java b/src/test/java/com/networknt/schema/Issue769ContainsTest.java index 5be980c83..b344a7aeb 100644 --- a/src/test/java/com/networknt/schema/Issue769ContainsTest.java +++ b/src/test/java/com/networknt/schema/Issue769ContainsTest.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.keyword.ContainsValidator; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** *

Test class for issue #769

*

This test class asserts that correct messages are returned for contains, minContains et maxContains keywords

diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index e4b55bd92..e88dae5cf 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -4,6 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.keyword.AbstractKeywordValidator; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 41cec0ffd..11a866755 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -23,6 +23,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.BaseKeywordValidator; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.KeywordValidator; /** * Test for messages. diff --git a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java index a849be063..fa22835e5 100644 --- a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.keyword.NotAllowedValidator; +import com.networknt.schema.keyword.ValidatorTypeCode; + /** * This class test {@link NotAllowedValidator}, diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 2bf0a6794..0e8b6193d 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.PrefixItemsValidator; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 1159a57ab..2154c6185 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -1,6 +1,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.keyword.RecursiveRefValidator; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/networknt/schema/UnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/UnknownKeywordFactoryTest.java index bbcee921e..8f00ea7c0 100644 --- a/src/test/java/com/networknt/schema/UnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/UnknownKeywordFactoryTest.java @@ -19,6 +19,10 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.keyword.AnnotationKeyword; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.UnknownKeywordFactory; + class UnknownKeywordFactoryTest { @Test diff --git a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java index 8484378c0..5aa2cf020 100644 --- a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java +++ b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java @@ -19,6 +19,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import com.networknt.schema.keyword.ValidatorTypeCode; + import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 2b63e1654..e146de32a 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.output.OutputUnit; /** diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index 42e77d3f2..a5978ecc6 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -35,23 +35,23 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.InputFormat; -import com.networknt.schema.ItemsValidator; -import com.networknt.schema.ItemsValidator202012; import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.JsonSchemaRef; -import com.networknt.schema.PropertiesValidator; import com.networknt.schema.SchemaId; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.keyword.ItemsValidator; +import com.networknt.schema.keyword.ItemsValidator202012; +import com.networknt.schema.keyword.PropertiesValidator; +import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; import com.networknt.schema.utils.JsonSchemaRefs; import com.networknt.schema.Error; import com.networknt.schema.ValidationResult; -import com.networknt.schema.ValidatorTypeCode; /** * JsonSchemaWalkListenerTest. From fac1bbf28adbcf5d038be1cd3641aab5116eb2f6 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:31:31 +0800 Subject: [PATCH 09/74] Rename SpecVersion.VersionFlag to Specification.Version and refactor --- .../schema/DefaultJsonMetaSchemaFactory.java | 8 +- .../com/networknt/schema/JsonMetaSchema.java | 14 +-- .../java/com/networknt/schema/JsonSchema.java | 10 +- .../networknt/schema/JsonSchemaFactory.java | 24 ++--- .../com/networknt/schema/SpecVersion.java | 55 ----------- .../com/networknt/schema/Specification.java | 96 +++++++++++++++++++ ...java => SpecificationVersionDetector.java} | 37 ++++--- .../networknt/schema/ValidationContext.java | 4 +- .../com/networknt/schema/Version201909.java | 4 +- .../com/networknt/schema/Version202012.java | 4 +- .../java/com/networknt/schema/Version4.java | 4 +- .../java/com/networknt/schema/Version6.java | 4 +- .../java/com/networknt/schema/Version7.java | 4 +- .../format/BaseFormatJsonValidator.java | 12 +-- .../keyword/UnevaluatedItemsValidator.java | 4 +- .../schema/keyword/ValidatorTypeCode.java | 40 ++++---- .../com/networknt/schema/oas/OpenApi30.java | 4 +- .../com/networknt/schema/oas/OpenApi31.java | 6 +- .../networknt/schema/utils/JsonNodeUtil.java | 6 +- .../schema/AbstractJsonSchemaTest.java | 4 +- .../schema/AbstractJsonSchemaTestSuite.java | 16 ++-- .../AdditionalPropertiesValidatorTest.java | 6 +- .../networknt/schema/AllOfValidatorTest.java | 6 +- .../networknt/schema/AnyOfValidatorTest.java | 6 +- .../schema/BaseJsonSchemaValidatorTest.java | 14 +-- .../schema/CollectorContextTest.java | 12 +-- .../networknt/schema/ConstValidatorTest.java | 12 +-- .../schema/ContentSchemaValidatorTest.java | 4 +- .../networknt/schema/CustomMessageTest.java | 6 +- .../schema/CustomMetaSchemaTest.java | 2 +- .../com/networknt/schema/CustomUriTest.java | 2 +- .../schema/CyclicDependencyTest.java | 2 +- .../com/networknt/schema/DateTimeDSTTest.java | 2 +- .../DefaultJsonSchemaIdValidatorTest.java | 12 +-- .../schema/DependentRequiredTest.java | 2 +- ...allowUnknownJsonMetaSchemaFactoryTest.java | 8 +- .../DisallowUnknownKeywordFactoryTest.java | 4 +- .../schema/DiscriminatorValidatorTest.java | 20 ++-- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 6 +- .../networknt/schema/ErrorHandlerTest.java | 6 +- .../com/networknt/schema/ExampleTest.java | 6 +- .../schema/ExclusiveMinimumValidatorTest.java | 8 +- .../schema/FormatKeywordFactoryTest.java | 4 +- .../networknt/schema/FormatValidatorTest.java | 14 +-- .../com/networknt/schema/IfValidatorTest.java | 10 +- .../com/networknt/schema/Issue1091Test.java | 4 +- .../com/networknt/schema/Issue255Test.java | 2 +- .../com/networknt/schema/Issue285Test.java | 2 +- .../com/networknt/schema/Issue295Test.java | 2 +- .../com/networknt/schema/Issue313Test.java | 4 +- .../com/networknt/schema/Issue314Test.java | 2 +- .../com/networknt/schema/Issue327Test.java | 2 +- .../com/networknt/schema/Issue342Test.java | 2 +- .../com/networknt/schema/Issue347Test.java | 2 +- .../schema/Issue366FailFastTest.java | 2 +- .../schema/Issue366FailSlowTest.java | 2 +- .../com/networknt/schema/Issue375Test.java | 4 +- .../com/networknt/schema/Issue383Test.java | 2 +- .../com/networknt/schema/Issue396Test.java | 2 +- .../com/networknt/schema/Issue404Test.java | 2 +- .../com/networknt/schema/Issue406Test.java | 6 +- .../com/networknt/schema/Issue426Test.java | 2 +- .../com/networknt/schema/Issue428Test.java | 2 +- .../com/networknt/schema/Issue451Test.java | 2 +- .../com/networknt/schema/Issue456Test.java | 2 +- .../com/networknt/schema/Issue461Test.java | 2 +- .../com/networknt/schema/Issue467Test.java | 2 +- .../com/networknt/schema/Issue471Test.java | 2 +- .../com/networknt/schema/Issue475Test.java | 12 +-- .../com/networknt/schema/Issue493Test.java | 2 +- .../com/networknt/schema/Issue518Test.java | 2 +- .../com/networknt/schema/Issue532Test.java | 2 +- .../com/networknt/schema/Issue550Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 2 +- .../com/networknt/schema/Issue606Test.java | 2 +- .../com/networknt/schema/Issue619Test.java | 2 +- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue662Test.java | 2 +- .../com/networknt/schema/Issue664Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 4 +- .../com/networknt/schema/Issue668Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 4 +- .../com/networknt/schema/Issue724Test.java | 4 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue857Test.java | 4 +- .../com/networknt/schema/Issue877Test.java | 4 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 4 +- .../com/networknt/schema/Issue928Test.java | 12 +-- .../com/networknt/schema/Issue935Test.java | 4 +- .../com/networknt/schema/Issue936Test.java | 6 +- .../com/networknt/schema/Issue939Test.java | 4 +- .../com/networknt/schema/Issue940Test.java | 4 +- .../com/networknt/schema/Issue943Test.java | 4 +- .../com/networknt/schema/Issue994Test.java | 4 +- .../schema/ItemsValidator202012Test.java | 8 +- .../networknt/schema/ItemsValidatorTest.java | 18 ++-- .../schema/JsonSchemaFactoryTest.java | 4 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 2 +- .../schema/JsonSchemaPreloadTest.java | 6 +- .../com/networknt/schema/JsonSchemaTest.java | 4 +- .../schema/JsonSchemaTestSuiteExtrasTest.java | 12 +-- .../schema/JsonSchemaTestSuiteTest.java | 12 +-- .../schema/JsonWalkApplyDefaultsTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 4 +- .../java/com/networknt/schema/LocaleTest.java | 10 +- .../schema/MaximumValidatorTest.java | 2 +- .../com/networknt/schema/MessageTest.java | 4 +- .../schema/MetaSchemaValidationTest.java | 4 +- .../schema/MinimumValidatorTest.java | 2 +- .../schema/MultipleOfValidatorTest.java | 6 +- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 24 ++--- .../schema/OpenAPI30JsonSchemaTest.java | 2 +- .../networknt/schema/OutputFormatTest.java | 6 +- .../com/networknt/schema/OutputUnitTest.java | 22 ++--- .../schema/OverrideValidatorTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 4 +- .../PatternPropertiesValidatorTest.java | 10 +- .../schema/PatternValidatorTest.java | 4 +- .../schema/PrefixItemsValidatorTest.java | 14 +-- .../com/networknt/schema/PropertiesTest.java | 4 +- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 4 +- .../schema/ReadOnlyValidatorTest.java | 2 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 4 +- .../networknt/schema/RefValidatorTest.java | 14 +-- .../schema/RequiredValidatorTest.java | 10 +- .../java/com/networknt/schema/SampleTest.java | 12 +-- .../networknt/schema/SchemaLocationTest.java | 4 +- .../networknt/schema/SharedConfigTest.java | 2 +- ... => SpecificationVersionDetectorTest.java} | 20 ++-- .../networknt/schema/TypeValidatorTest.java | 12 +-- .../schema/UnevaluatedItemsTest.java | 4 +- .../schema/UnevaluatedItemsValidatorTest.java | 6 +- .../schema/UnevaluatedPropertiesTest.java | 4 +- .../UnevaluatedPropertiesValidatorTest.java | 12 +-- .../schema/UnknownMetaSchemaTest.java | 6 +- .../com/networknt/schema/UriMappingTest.java | 10 +- .../networknt/schema/V4JsonSchemaTest.java | 4 +- .../schema/ValidatorTypeCodeTest.java | 4 +- .../com/networknt/schema/VocabularyTest.java | 16 ++-- .../benchmark/NetworkntBasicRunner.java | 4 +- .../NetworkntTestSuite202012OptionalPerf.java | 4 +- .../NetworkntTestSuite202012RequiredPerf.java | 4 +- .../NetworkntTestSuiteOptionalBenchmark.java | 12 +-- .../NetworkntTestSuiteRequiredBenchmark.java | 12 +-- .../NetworkntTestSuiteTestCases.java | 6 +- .../schema/format/IriFormatTest.java | 16 ++-- .../schema/format/IriReferenceFormatTest.java | 16 ++-- .../schema/format/TimeFormatTest.java | 6 +- .../schema/format/UriFormatTest.java | 16 ++-- .../schema/format/UriReferenceFormatTest.java | 16 ++-- .../networknt/schema/oas/OpenApi30Test.java | 10 +- .../networknt/schema/oas/OpenApi31Test.java | 12 +-- .../resource/AllowSchemaLoaderTest.java | 4 +- .../resource/DisallowSchemaLoaderTest.java | 4 +- .../networknt/schema/utils/JsonNodesTest.java | 6 +- .../walk/JsonSchemaWalkListenerTest.java | 26 ++--- 164 files changed, 629 insertions(+), 593 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/SpecVersion.java create mode 100644 src/main/java/com/networknt/schema/Specification.java rename src/main/java/com/networknt/schema/{SpecVersionDetector.java => SpecificationVersionDetector.java} (73%) rename src/test/java/com/networknt/schema/{SpecVersionDetectorTest.java => SpecificationVersionDetectorTest.java} (74%) diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java index 2d62b9b3e..2a14c37a0 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java @@ -19,7 +19,7 @@ import java.util.Map.Entry; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Default {@link JsonMetaSchemaFactory}. @@ -28,7 +28,7 @@ public class DefaultJsonMetaSchemaFactory implements JsonMetaSchemaFactory { @Override public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { // Is it a well-known dialect? - return SpecVersionDetector.detectOptionalVersion(iri) + return Specification.Version.fromDialectId(iri) .map(JsonSchemaFactory::checkVersion) .map(JsonSchemaVersion::getInstance) .orElseGet(() -> { @@ -55,9 +55,9 @@ protected JsonMetaSchema.Builder loadMetaSchemaBuilder(String iri, JsonSchemaFac SchemaValidatorsConfig config) { JsonSchema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); JsonMetaSchema.Builder builder = JsonMetaSchema.builder(iri, schema.getValidationContext().getMetaSchema()); - VersionFlag specification = schema.getValidationContext().getMetaSchema().getSpecification(); + Version specification = schema.getValidationContext().getMetaSchema().getSpecification(); if (specification != null) { - if (specification.getVersionFlagValue() >= VersionFlag.V201909.getVersionFlagValue()) { + if (specification.getOrder() >= Version.DRAFT_2019_09.getOrder()) { // Process vocabularies JsonNode vocabulary = schema.getSchemaNode().get("$vocabulary"); if (vocabulary != null) { diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index db524ab60..a6fdedf3d 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -17,7 +17,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordFactory; @@ -61,7 +61,7 @@ public interface FormatKeywordFactory { public static class Builder { private String iri; private String idKeyword = "$id"; - private VersionFlag specification = null; + private Version specification = null; private final Map keywords = new HashMap<>(); private final Map formats = new HashMap<>(); private final Map vocabularies = new HashMap<>(); @@ -253,7 +253,7 @@ public Builder vocabularies(Consumer> customizer) { * @param specification the specification * @return the builder */ - public Builder specification(VersionFlag specification) { + public Builder specification(Version specification) { this.specification = specification; return this; } @@ -273,7 +273,7 @@ public JsonMetaSchema build() { // create builtin keywords with (custom) formats. Map keywords = this.keywords; if (this.specification != null) { - if (this.specification.getVersionFlagValue() >= SpecVersion.VersionFlag.V201909.getVersionFlagValue()) { + if (this.specification.getOrder() >= Specification.Version.DRAFT_2019_09.getOrder()) { keywords = new HashMap<>(this.keywords); for(Entry entry : this.vocabularies.entrySet()) { Vocabulary vocabulary = null; @@ -326,11 +326,11 @@ public Builder addFormats(Collection formats) { private final String idKeyword; private final Map keywords; private final Map vocabularies; - private final VersionFlag specification; + private final Version specification; private final Builder builder; - JsonMetaSchema(String iri, String idKeyword, Map keywords, Map vocabularies, VersionFlag specification, Builder builder) { + JsonMetaSchema(String iri, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { if (StringUtils.isBlank(iri)) { throw new IllegalArgumentException("iri must not be null or blank"); } @@ -461,7 +461,7 @@ public Map getVocabularies() { return this.vocabularies; } - public VersionFlag getSpecification() { + public Version getSpecification() { return this.specification; } diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index d77d6f1e4..ef275a4f1 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; @@ -40,7 +40,7 @@ /** * Used for creating a schema with validators for validating inputs. This is - * created using {@link JsonSchemaFactory#getInstance(VersionFlag, Consumer)} + * created using {@link JsonSchemaFactory#getInstance(Version, Consumer)} * and should be cached for performance. *

* This is the core of json constraint implementation. It parses json constraint @@ -51,7 +51,7 @@ * modified. */ public class JsonSchema implements Validator { - private static final long V201909_VALUE = VersionFlag.V201909.getVersionFlagValue(); + private static final long V201909_VALUE = Version.DRAFT_2019_09.getOrder(); private final String id; /** @@ -673,8 +673,8 @@ private List read(JsonNode schemaNode) { private long activeDialect() { return this.validationContext .activeDialect() - .map(VersionFlag::getVersionFlagValue) - .orElse(Long.MAX_VALUE); + .map(Version::getOrder) + .orElse(Integer.MAX_VALUE); } /** diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 0e2048b99..94a395481 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.resource.DefaultSchemaLoader; import com.networknt.schema.resource.SchemaLoader; import com.networknt.schema.resource.SchemaLoaders; @@ -43,7 +43,7 @@ /** * Factory for building {@link JsonSchema} instances. The factory should be - * typically be created using {@link #getInstance(VersionFlag, Consumer)} and + * typically be created using {@link #getInstance(Version, Consumer)} and * should be cached for performance. *

* JsonSchemaFactory instances are thread-safe provided its configuration is not @@ -251,7 +251,7 @@ public static Builder builder() { * @param versionFlag the default dialect * @return the factory */ - public static JsonSchemaFactory getInstance(SpecVersion.VersionFlag versionFlag) { + public static JsonSchemaFactory getInstance(Specification.Version versionFlag) { return getInstance(versionFlag, null); } @@ -263,7 +263,7 @@ public static JsonSchemaFactory getInstance(SpecVersion.VersionFlag versionFlag) * @param customizer to customize the factory * @return the factory */ - public static JsonSchemaFactory getInstance(SpecVersion.VersionFlag versionFlag, + public static JsonSchemaFactory getInstance(Specification.Version versionFlag, Consumer customizer) { JsonSchemaVersion jsonSchemaVersion = checkVersion(versionFlag); JsonMetaSchema metaSchema = jsonSchemaVersion.getInstance(); @@ -283,14 +283,14 @@ public static JsonSchemaFactory getInstance(SpecVersion.VersionFlag versionFlag, * @param versionFlag the schema dialect * @return the version */ - public static JsonSchemaVersion checkVersion(SpecVersion.VersionFlag versionFlag){ + public static JsonSchemaVersion checkVersion(Specification.Version versionFlag){ if (null == versionFlag) return null; switch (versionFlag) { - case V202012: return new Version202012(); - case V201909: return new Version201909(); - case V7: return new Version7(); - case V6: return new Version6(); - case V4: return new Version4(); + case DRAFT_2020_12: return new Version202012(); + case DRAFT_2019_09: return new Version201909(); + case DRAFT_7: return new Version7(); + case DRAFT_6: return new Version6(); + case DRAFT_4: return new Version4(); default: throw new IllegalArgumentException("Unsupported value" + versionFlag); } } @@ -822,8 +822,8 @@ private boolean isYaml(final SchemaLocation schemaUri) { */ static protected String normalizeMetaSchemaUri(String id) { boolean found = false; - for (VersionFlag flag : SpecVersion.VersionFlag.values()) { - if(flag.getId().equals(id)) { + for (Version flag : Specification.Version.values()) { + if(flag.getDialectId().equals(id)) { found = true; break; } diff --git a/src/main/java/com/networknt/schema/SpecVersion.java b/src/main/java/com/networknt/schema/SpecVersion.java deleted file mode 100644 index 3f02cd91a..000000000 --- a/src/main/java/com/networknt/schema/SpecVersion.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2020 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import java.util.Optional; - -public class SpecVersion { - - public enum VersionFlag { - - V4(1 << 0, SchemaId.V4), - V6(1 << 1, SchemaId.V6), - V7(1 << 2, SchemaId.V7), - V201909(1 << 3, SchemaId.V201909), - V202012(1 << 4, SchemaId.V202012); - - - private final long versionFlagValue; - private final String id; - - VersionFlag(long versionFlagValue, String id) { - this.versionFlagValue = versionFlagValue; - this.id = id; - } - - public String getId() { - return this.id; - } - - public long getVersionFlagValue() { - return this.versionFlagValue; - } - - public static Optional fromId(String id) { - for (VersionFlag v: VersionFlag.values()) { - if (v.id.equals(id)) return Optional.of(v); - } - return Optional.empty(); - } - } - -} diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java new file mode 100644 index 000000000..8e1ae61e2 --- /dev/null +++ b/src/main/java/com/networknt/schema/Specification.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import java.util.Optional; + +/** + * The JSON Schema specification which defines the standard dialects. + */ +public class Specification { + + /** + * The JSON Schema specification version. + */ + public enum Version { + /** + * Draft 4. + */ + DRAFT_4(4, SchemaId.V4), + /** + * Draft 6. + */ + DRAFT_6(6, SchemaId.V6), + /** + * Draft 7. + */ + DRAFT_7(7, SchemaId.V7), + /** + * Draft 2019-09. + */ + DRAFT_2019_09(8, SchemaId.V201909), + /** + * Draft 2020-12. + */ + DRAFT_2020_12(9, SchemaId.V202012); + + private final int order; + private final String dialectId; + + Version(int order, String dialectId) { + this.order = order; + this.dialectId = dialectId; + } + + /** + * Gets the dialect id used for the $schema keyword. The dialect id is an IRI + * that identifies the meta schema used to validate the dialect. + * + * @return the dialect id + */ + public String getDialectId() { + return this.dialectId; + } + + /** + * Gets the unique release order of the specification version used that + * indicates when the specification was released. Lower numbers indicate the + * specification was released earlier. + * + * @return the order when the specification was released + */ + public int getOrder() { + return this.order; + } + + /** + * Gets the specification version that matches the dialect id indicated by + * $schema keyword. The dialect id is an IRI that identifies the meta schema + * used to validate the dialect. + * + * @param dialectId the dialect id specified by $schema keyword + * @return the specification version if it matches the dialect id + */ + public static Optional fromDialectId(String dialectId) { + for (Version version : Version.values()) { + if (version.dialectId.equals(dialectId)) { + return Optional.of(version); + } + } + return Optional.empty(); + } + } +} diff --git a/src/main/java/com/networknt/schema/SpecVersionDetector.java b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java similarity index 73% rename from src/main/java/com/networknt/schema/SpecVersionDetector.java rename to src/main/java/com/networknt/schema/SpecificationVersionDetector.java index 219a2866b..adefbf91a 100644 --- a/src/main/java/com/networknt/schema/SpecVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java @@ -17,7 +17,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import java.nio.file.Path; import java.util.HashMap; @@ -33,20 +33,20 @@ * @author Subhajitdas298 * @since 25/06/20 */ -public final class SpecVersionDetector { +public final class SpecificationVersionDetector { - private static final Map supportedVersions = new HashMap<>(); + private static final Map supportedVersions = new HashMap<>(); private static final String SCHEMA_TAG = "$schema"; static { - supportedVersions.put("draft2019-09", VersionFlag.V201909); - supportedVersions.put("draft2020-12", VersionFlag.V202012); - supportedVersions.put("draft4", VersionFlag.V4); - supportedVersions.put("draft6", VersionFlag.V6); - supportedVersions.put("draft7", VersionFlag.V7); + supportedVersions.put("draft2019-09", Version.DRAFT_2019_09); + supportedVersions.put("draft2020-12", Version.DRAFT_2020_12); + supportedVersions.put("draft4", Version.DRAFT_4); + supportedVersions.put("draft6", Version.DRAFT_6); + supportedVersions.put("draft7", Version.DRAFT_7); } - private SpecVersionDetector() { + private SpecificationVersionDetector() { // Prevent instantiation of this utility class } @@ -57,7 +57,7 @@ private SpecVersionDetector() { * @param jsonNode JSON Node to read from * @return Spec version if present, otherwise throws an exception */ - public static VersionFlag detect(JsonNode jsonNode) { + public static Version detect(JsonNode jsonNode) { return detectOptionalVersion(jsonNode, true).orElseThrow( () -> new JsonSchemaException("'" + SCHEMA_TAG + "' tag is not present") ); @@ -71,17 +71,17 @@ public static VersionFlag detect(JsonNode jsonNode) { * @param throwIfUnsupported whether to throw an exception if the version is not supported * @return Spec version if present, otherwise empty */ - public static Optional detectOptionalVersion(JsonNode jsonNode, boolean throwIfUnsupported) { + public static Optional detectOptionalVersion(JsonNode jsonNode, boolean throwIfUnsupported) { return Optional.ofNullable(jsonNode.get(SCHEMA_TAG)).map(schemaTag -> { String schemaTagValue = schemaTag.asText(); String schemaUri = JsonSchemaFactory.normalizeMetaSchemaUri(schemaTagValue); if (throwIfUnsupported) { - return VersionFlag.fromId(schemaUri) + return Version.fromDialectId(schemaUri) .orElseThrow(() -> new JsonSchemaException("'" + schemaTagValue + "' is unrecognizable schema")); } else { - return VersionFlag.fromId(schemaUri).orElse(null); + return Version.fromDialectId(schemaUri).orElse(null); } }); } @@ -89,7 +89,7 @@ public static Optional detectOptionalVersion(JsonNode jsonNode, boo // For 2019-09 and later published drafts, implementations that are able to // detect the draft of each schema via $schema SHOULD be configured to do so - public static VersionFlag detectVersion(JsonNode jsonNode, Path specification, VersionFlag defaultVersion, boolean throwIfUnsupported) { + public static Version detectVersion(JsonNode jsonNode, Path specification, Version defaultVersion, boolean throwIfUnsupported) { return Stream.of( detectOptionalVersion(jsonNode, throwIfUnsupported), detectVersionFromPath(specification) @@ -103,16 +103,11 @@ public static VersionFlag detectVersion(JsonNode jsonNode, Path specification, V // For draft-07 and earlier, draft-next, and implementations unable to // detect via $schema, implementations MUST be configured to expect the // draft matching the test directory name - public static Optional detectVersionFromPath(Path path) { + public static Optional detectVersionFromPath(Path path) { return StreamSupport.stream(path.spliterator(), false) .map(Path::toString) - .map(supportedVersions::get) + .map(supportedVersions::get) .filter(Objects::nonNull) .findAny(); } - - public static Optional detectOptionalVersion(String schemaUri) { - return VersionFlag.fromId(schemaUri); - } - } diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index 729d06a9e..8e84d7400 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentMap; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.KeywordValidator; public class ValidationContext { @@ -107,7 +107,7 @@ public JsonMetaSchema getMetaSchema() { return this.metaSchema; } - public Optional activeDialect() { + public Optional activeDialect() { return Optional.of(this.metaSchema.getSpecification()); } } diff --git a/src/main/java/com/networknt/schema/Version201909.java b/src/main/java/com/networknt/schema/Version201909.java index d085b2c0a..a3cf4a6f0 100644 --- a/src/main/java/com/networknt/schema/Version201909.java +++ b/src/main/java/com/networknt/schema/Version201909.java @@ -30,10 +30,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V201909) + .specification(Specification.Version.DRAFT_2019_09) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V201909)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2019_09)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/Version202012.java b/src/main/java/com/networknt/schema/Version202012.java index d8e8caa79..29807dbb3 100644 --- a/src/main/java/com/networknt/schema/Version202012.java +++ b/src/main/java/com/networknt/schema/Version202012.java @@ -31,10 +31,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V202012) + .specification(Specification.Version.DRAFT_2020_12) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V202012)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/Version4.java b/src/main/java/com/networknt/schema/Version4.java index dcec9284d..f1d6b09de 100644 --- a/src/main/java/com/networknt/schema/Version4.java +++ b/src/main/java/com/networknt/schema/Version4.java @@ -17,10 +17,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V4) + .specification(Specification.Version.DRAFT_4) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V4)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/Version6.java b/src/main/java/com/networknt/schema/Version6.java index 8080fe993..a892dbf14 100644 --- a/src/main/java/com/networknt/schema/Version6.java +++ b/src/main/java/com/networknt/schema/Version6.java @@ -18,10 +18,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V6) + .specification(Specification.Version.DRAFT_6) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V6)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_6)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/Version7.java b/src/main/java/com/networknt/schema/Version7.java index e42c088ca..75c1d5af0 100644 --- a/src/main/java/com/networknt/schema/Version7.java +++ b/src/main/java/com/networknt/schema/Version7.java @@ -17,10 +17,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V7) + .specification(Specification.Version.DRAFT_7) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V7)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_7)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index 4cbd10183..ff373bc98 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -8,7 +8,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; @@ -19,8 +19,8 @@ public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evalu JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext) { super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - VersionFlag dialect = this.validationContext.getMetaSchema().getSpecification(); - if (dialect == null || dialect.getVersionFlagValue() < VersionFlag.V201909.getVersionFlagValue()) { + Version dialect = this.validationContext.getMetaSchema().getSpecification(); + if (dialect == null || dialect.getOrder() < Version.DRAFT_2019_09.getOrder()) { assertionsEnabled = true; } else { // Check vocabulary @@ -34,11 +34,11 @@ protected boolean isFormatAssertionVocabularyEnabled() { this.validationContext.getMetaSchema().getVocabularies()); } - protected boolean isFormatAssertionVocabularyEnabled(VersionFlag specification, Map vocabularies) { - if (VersionFlag.V202012.equals(specification)) { + protected boolean isFormatAssertionVocabularyEnabled(Version specification, Map vocabularies) { + if (Version.DRAFT_2020_12.equals(specification)) { String vocabulary = "https://json-schema.org/draft/2020-12/vocab/format-assertion"; return vocabularies.containsKey(vocabulary); // doesn't matter if it is true or false - } else if (VersionFlag.V201909.equals(specification)) { + } else if (Version.DRAFT_2019_09.equals(specification)) { String vocabulary = "https://json-schema.org/draft/2019-09/vocab/format"; return vocabularies.getOrDefault(vocabulary, false); } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index e68feb3e5..890e3fd60 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.annotation.JsonNodeAnnotation; import org.slf4j.Logger; @@ -43,7 +43,7 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { private final JsonSchema schema; private final boolean isMinV202012; - private static final VersionFlag DEFAULT_VERSION = VersionFlag.V201909; + private static final Version DEFAULT_VERSION = Version.DRAFT_2019_09; public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index 5b0a783f9..ed0ec75cc 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -20,9 +20,9 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.JsonSchema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SpecVersion; +import com.networknt.schema.Specification; import com.networknt.schema.ValidationContext; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import java.util.ArrayList; import java.util.Arrays; @@ -38,26 +38,26 @@ KeywordValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluat } enum VersionCode { - None(new SpecVersion.VersionFlag[] { }), - AllVersions(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V4, SpecVersion.VersionFlag.V6, SpecVersion.VersionFlag.V7, SpecVersion.VersionFlag.V201909, SpecVersion.VersionFlag.V202012 }), - MinV6(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V6, SpecVersion.VersionFlag.V7, SpecVersion.VersionFlag.V201909, SpecVersion.VersionFlag.V202012 }), - MinV6MaxV7(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V6, SpecVersion.VersionFlag.V7 }), - MinV7(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V7, SpecVersion.VersionFlag.V201909, SpecVersion.VersionFlag.V202012 }), - MaxV7(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V4, SpecVersion.VersionFlag.V6, SpecVersion.VersionFlag.V7 }), - MaxV201909(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V4, SpecVersion.VersionFlag.V6, SpecVersion.VersionFlag.V7, SpecVersion.VersionFlag.V201909 }), - MinV201909(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V201909, SpecVersion.VersionFlag.V202012 }), - MinV202012(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V202012 }), - V201909(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V201909 }), - V7(new SpecVersion.VersionFlag[] { SpecVersion.VersionFlag.V7 }); - - private final EnumSet versions; - - VersionCode(SpecVersion.VersionFlag[] versionFlags) { - this.versions = EnumSet.noneOf(VersionFlag.class); + None(new Specification.Version[] { }), + AllVersions(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), + MinV6(new Specification.Version[] { Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), + MinV6MaxV7(new Specification.Version[] { Specification.Version.DRAFT_6, Specification.Version.DRAFT_7 }), + MinV7(new Specification.Version[] { Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), + MaxV7(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7 }), + MaxV201909(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09 }), + MinV201909(new Specification.Version[] { Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), + MinV202012(new Specification.Version[] { Specification.Version.DRAFT_2020_12 }), + V201909(new Specification.Version[] { Specification.Version.DRAFT_2019_09 }), + V7(new Specification.Version[] { Specification.Version.DRAFT_7 }); + + private final EnumSet versions; + + VersionCode(Specification.Version[] versionFlags) { + this.versions = EnumSet.noneOf(Version.class); this.versions.addAll(Arrays.asList(versionFlags)); } - EnumSet getVersions() { + EnumSet getVersions() { return this.versions; } } @@ -138,7 +138,7 @@ public enum ValidatorTypeCode implements Keyword { this.versionCode = versionCode; } - public static List getKeywords(SpecVersion.VersionFlag versionFlag) { + public static List getKeywords(Specification.Version versionFlag) { final List result = new ArrayList<>(); for (ValidatorTypeCode keyword : values()) { if (keyword.getVersionCode().getVersions().contains(versionFlag)) { diff --git a/src/main/java/com/networknt/schema/oas/OpenApi30.java b/src/main/java/com/networknt/schema/oas/OpenApi30.java index 4e34f056e..703d068bf 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi30.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi30.java @@ -5,7 +5,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; import com.networknt.schema.SchemaId; -import com.networknt.schema.SpecVersion; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -21,7 +21,7 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V4) + .specification(Specification.Version.DRAFT_4) .idKeyword(ID) .formats(Formats.DEFAULT) .keywords(Arrays.asList( diff --git a/src/main/java/com/networknt/schema/oas/OpenApi31.java b/src/main/java/com/networknt/schema/oas/OpenApi31.java index 0c8db320d..1d42be34b 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi31.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi31.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; import com.networknt.schema.SchemaId; -import com.networknt.schema.SpecVersion; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -36,10 +36,10 @@ private static class Holder { private static final JsonMetaSchema INSTANCE; static { INSTANCE = JsonMetaSchema.builder(IRI) - .specification(SpecVersion.VersionFlag.V202012) + .specification(Specification.Version.DRAFT_2020_12) .idKeyword(ID) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V202012)) + .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index df2b91bc3..19366f376 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -8,12 +8,12 @@ import com.networknt.schema.JsonType; import com.networknt.schema.PathType; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; public class JsonNodeUtil { - private static final long V6_VALUE = VersionFlag.V6.getVersionFlagValue(); + private static final long V6_VALUE = Version.DRAFT_6.getOrder(); private static final String TYPE = "type"; private static final String ENUM = "enum"; @@ -120,7 +120,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Jso } private static long detectVersion(ValidationContext validationContext) { - return validationContext.activeDialect().orElse(VersionFlag.V4).getVersionFlagValue(); + return validationContext.activeDialect().orElse(Version.DRAFT_4).getOrder(); } /** diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index a4d137af7..6ee3bc172 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -22,7 +22,7 @@ abstract class AbstractJsonSchemaTest { private static final String SCHEMA = "$schema"; - private static final SpecVersion.VersionFlag DEFAULT_VERSION_FLAG = SpecVersion.VersionFlag.V202012; + private static final Specification.Version DEFAULT_VERSION_FLAG = Specification.Version.DRAFT_2020_12; private static final String ASSERT_MSG_KEYWORD = "Validation result should contain {0} keyword"; protected List validate(String dataPath) { @@ -60,7 +60,7 @@ private JsonNode getJsonNodeFromPath(String dataPath) { private JsonSchema getJsonSchema(JsonNode schemaNode) { return JsonSchemaFactory - .getInstance(SpecVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) + .getInstance(SpecificationVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) .getSchema(schemaNode); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index c46e1a9f5..b29e2810f 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -16,7 +16,7 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.regex.JDKRegularExpressionFactory; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; @@ -43,7 +43,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.networknt.schema.SpecVersionDetector.detectVersion; +import static com.networknt.schema.SpecificationVersionDetector.detectVersion; import static org.junit.jupiter.api.Assumptions.abort; import static org.junit.jupiter.api.DynamicContainer.dynamicContainer; import static org.junit.jupiter.api.DynamicTest.dynamicTest; @@ -139,7 +139,7 @@ private static Iterable unsupportedMetaSchema(TestCase te ); } - protected Stream createTests(VersionFlag defaultVersion, String basePath) { + protected Stream createTests(Version defaultVersion, String basePath) { return findTestCases(basePath) .stream() .peek(System.out::println) @@ -154,7 +154,7 @@ protected Optional reason(@SuppressWarnings("unused") Path path) { return Optional.empty(); } - private Stream buildContainers(VersionFlag defaultVersion, Path path) { + private Stream buildContainers(Version defaultVersion, Path path) { boolean disabled = !enabled(path); String reason = reason(path).orElse("Unknown"); return TestSource.loadFrom(path, disabled, reason) @@ -162,11 +162,11 @@ private Stream buildContainers(VersionFlag defaultVersion, Path pat .orElse(Stream.empty()); } - private Stream buildContainer(VersionFlag defaultVersion, TestSource testSource) { + private Stream buildContainer(Version defaultVersion, TestSource testSource) { return testSource.getTestCases().stream().map(testCase -> buildContainer(defaultVersion, testCase)); } - private DynamicNode buildContainer(VersionFlag defaultVersion, TestCase testCase) { + private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { try { JsonSchemaFactory validatorFactory = buildValidatorFactory(defaultVersion, testCase); @@ -182,7 +182,7 @@ private DynamicNode buildContainer(VersionFlag defaultVersion, TestCase testCase } } - private JsonSchemaFactory buildValidatorFactory(VersionFlag defaultVersion, TestCase testCase) { + private JsonSchemaFactory buildValidatorFactory(Version defaultVersion, TestCase testCase) { if (testCase.isDisabled()) return null; SchemaLoader schemaLoader = new SchemaLoader() { @Override @@ -201,7 +201,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - VersionFlag specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); + Version specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); JsonSchemaFactory base = JsonSchemaFactory.getInstance(specVersion); return JsonSchemaFactory .builder(base) diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index e22fd81b7..092215c29 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * AdditionalPropertiesValidatorTest. @@ -45,7 +45,7 @@ void messageFalse() { + " },\r\n" + " \"additionalProperties\": false\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -80,7 +80,7 @@ void messageSchema() { + " },\r\n" + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 164775c02..57b50b070 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class AllOfValidatorTest { @Test @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 41e874780..bb260dcac 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class AnyOfValidatorTest { @Test @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index 5650cd43d..71b831909 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -47,14 +47,14 @@ public static JsonNode getJsonNodeFromUrl(String url) throws IOException { } public static JsonSchema getJsonSchemaFromClasspath(String name) { - return getJsonSchemaFromClasspath(name, SpecVersion.VersionFlag.V4, null); + return getJsonSchemaFromClasspath(name, Specification.Version.DRAFT_4, null); } - public static JsonSchema getJsonSchemaFromClasspath(String name, SpecVersion.VersionFlag schemaVersion) { + public static JsonSchema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion) { return getJsonSchemaFromClasspath(name, schemaVersion, null); } - public static JsonSchema getJsonSchemaFromClasspath(String name, SpecVersion.VersionFlag schemaVersion, SchemaValidatorsConfig config) { + public static JsonSchema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(schemaVersion); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); @@ -65,23 +65,23 @@ public static JsonSchema getJsonSchemaFromClasspath(String name, SpecVersion.Ver } public static JsonSchema getJsonSchemaFromStringContent(String schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(schemaContent); } public static JsonSchema getJsonSchemaFromUrl(String uri) throws URISyntaxException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(SchemaLocation.of(uri)); } public static JsonSchema getJsonSchemaFromJsonNode(JsonNode jsonNode) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(jsonNode); } // Automatically detect version for given JsonNode public static JsonSchema getJsonSchemaFromJsonNodeAutomaticVersion(JsonNode jsonNode) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersionDetector.detect(jsonNode)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecificationVersionDetector.detect(jsonNode)); return factory.getSchema(jsonNode); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index f32c335ec..49b55b074 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -155,7 +155,7 @@ private void setupSchema() throws Exception { final JsonMetaSchema metaSchema = getJsonMetaSchema( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).metaSchema(metaSchema) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(metaSchema) .build(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().build(); this.jsonSchema = schemaFactory.getSchema(getSchemaString(), schemaValidatorsConfig); @@ -456,7 +456,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -504,7 +504,7 @@ public void run() { void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -522,7 +522,7 @@ void iterate() { void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -540,7 +540,7 @@ void iterateWalk() { void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 39de1a33b..8c6a7a1d3 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.i18n.ResourceBundleMessageSource; /** @@ -39,7 +39,7 @@ void localeMessageOthers() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -53,7 +53,7 @@ void localeMessageNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -65,7 +65,7 @@ void validOthers() { + " \"const\": \"aa\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -77,7 +77,7 @@ void validNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void invalidNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index fa41fc703..b00563d6d 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.serialization.JsonMapperFactory; @@ -54,7 +54,7 @@ void annotationCollection() throws JsonProcessingException { + " ]\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/CustomMessageTest.java b/src/test/java/com/networknt/schema/CustomMessageTest.java index 79f41b473..b0638baf7 100644 --- a/src/test/java/com/networknt/schema/CustomMessageTest.java +++ b/src/test/java/com/networknt/schema/CustomMessageTest.java @@ -1,6 +1,6 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; @@ -14,13 +14,13 @@ class CustomMessageTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09 - Custom Messages Enabled") Stream draft201909__customMessagesEnabled() { - return createTests(VersionFlag.V201909, "src/test/resources/schema/customMessageTests/custom-message-tests.json"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-tests.json"); } @TestFactory @DisplayName("Draft 2019-09 - Custom Messages Disabled") Stream draft201909__customMessagesDisabled() { - return createTests(VersionFlag.V201909, "src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index b01537219..34e2a822e 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -122,7 +122,7 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { .keyword(new EnumNamesKeyword()) .build(); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).metaSchema(metaSchema).build(); + final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).metaSchema(metaSchema).build(); final JsonSchema schema = validatorFactory.getSchema("{\n" + " \"$schema\":\n" + " \"https://github.com/networknt/json-schema-validator/tests/schemas/example01\",\n" + diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index 7c7f06cbf..da7f320fb 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -31,7 +31,7 @@ void customUri() throws Exception { } private JsonSchemaFactory buildJsonSchemaFactory() { - return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)) + return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) .schemaLoaders(schemaLoaders -> schemaLoaders.add(new CustomUriFetcher())).build(); } diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index c6bb016fa..108499268 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -11,7 +11,7 @@ class CyclicDependencyTest { void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .build(); String jsonObject = "{\n" + " \"element\": {\n" + diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index ae6570a4b..b620e8948 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -10,7 +10,7 @@ class DateTimeDSTTest { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index 32572efe7..bd2f6e69a 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Tests for the non-standard DefaultJsonSchemaIdValidator. @@ -35,9 +35,9 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config)); + () -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); try { - JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config); + JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } @@ -50,7 +50,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config)); + assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -60,7 +60,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config)); + assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -68,7 +68,7 @@ void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(VersionFlag.V202012) + assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"), config)); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 863d00bd5..4ebd4afb2 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -28,7 +28,7 @@ class DependentRequiredTest { " }" + "}"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); private static final JsonSchema schema = factory.getSchema(SCHEMA); private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java index 8560c2bab..1c6503f16 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Tests for DisallowUnknownJsonMetaSchemaFactory. @@ -37,14 +37,14 @@ class DisallowUnknownJsonMetaSchemaFactoryTest { + "}"; @Test void defaultHandling() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); } @Test void draft202012() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_7_SCHEMA)); @@ -52,7 +52,7 @@ void draft202012() { @Test void draft7() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder.metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_202012_SCHEMA)); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index 41f0a20eb..4c02eeb93 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; class DisallowUnknownKeywordFactoryTest { @@ -33,7 +33,7 @@ void shouldThrowForUnknownKeywords() { void getSchemaShouldThrowForUnknownKeywords() { JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); String schemaData = "{\r\n" + " \"equals\": \"world\"\r\n" diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 01120acbb..faaa3be6c 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test for discriminator. @@ -115,7 +115,7 @@ void discriminatorInArray() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -147,7 +147,7 @@ void anyOfWithConfigEnabledButNoDiscriminator() { + " \"intOrStringType\": 4\r\n" + " }"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -240,7 +240,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -333,7 +333,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -423,7 +423,7 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -519,7 +519,7 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -619,7 +619,7 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -674,7 +674,7 @@ void oneOfMissingDiscriminatorValue() { String inputData = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -770,7 +770,7 @@ void anyOfMissingDiscriminatorValue() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index f018b1c5f..09b8e4a1d 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -34,7 +34,7 @@ void durationFormatValidatorTest() throws IOException { final JsonNode validTargetNode = objectMapper.readTree("\"P1D\""); final JsonNode invalidTargetNode = objectMapper.readTree("\"INVALID_DURATION\""); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).build(); + final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).build(); final JsonSchema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(validTargetNode); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index 02fcc6897..fa7e45498 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * EnumValidator test. @@ -85,7 +85,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); @@ -105,7 +105,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index 8fd5a66f2..d8df75c50 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * ErrorHandlerTest. @@ -51,7 +51,7 @@ void errorMessage() { + " \"foo\": \"a\",\r\n" + " \"bar\": 2\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); @@ -81,7 +81,7 @@ void errorMessageUnionType() { String inputData = "{\r\n" + " \"keyword1\": 2\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 193c32e78..6ba932314 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -21,13 +21,13 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class ExampleTest { @Test void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -52,7 +52,7 @@ void exampleSchemaLocation() { @Test void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index c0a14e431..3f327ef2c 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; /** @@ -43,7 +43,7 @@ void draftV4ShouldHaveExclusiveMinimum() { "}"; JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV4()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V4, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":0}"; @@ -71,7 +71,7 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { "}"; JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V6, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder.metaSchema(metaSchema)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } @@ -90,7 +90,7 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { "}"; JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(metaSchema)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index da19135c2..5f14efcf5 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.KeywordValidator; @@ -43,7 +43,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void shouldUseFormatKeyword() { JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()) .formatKeywordFactory(CustomFormatKeyword::new).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); String schemaData = "{\r\n" + " \"format\": \"hello\"\r\n" diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index c4e512261..f76b46a85 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.params.provider.EnumSource; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.format.PatternFormat; import com.networknt.schema.output.OutputUnit; @@ -41,7 +41,7 @@ void unknownFormatNoVocab() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -54,7 +54,7 @@ void unknownFormatNoVocabStrictTrue() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -84,7 +84,7 @@ void unknownFormatAssertionsVocab() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) .getSchema(schemaData, config); @@ -98,7 +98,7 @@ void unknownFormatShouldCollectAnnotations() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -141,7 +141,7 @@ void formatAssertions(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { @@ -239,7 +239,7 @@ void draft7DisableFormat() { String schemaData = "{\r\n" + " \"format\":\"uri\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); }); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 50203c27d..c31f12859 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; @@ -48,7 +48,7 @@ void walkValidateThen() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -91,7 +91,7 @@ void walkValidateElse() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -134,7 +134,7 @@ void walkValidateNull() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -175,7 +175,7 @@ void walkNoValidate() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 542a01a2a..6383c63cf 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; class Issue1091Test { @@ -33,7 +33,7 @@ class Issue1091Test { void testHasAdjacentKeywordInEvaluationPath() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V4) + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4) .getSchema(SchemaLocation.of("classpath:schema/issue1091.json"), config); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index afac8731e..810c7443c 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -25,7 +25,7 @@ class Issue255Test { protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index c669d2f4e..01ecc36ba 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -13,7 +13,7 @@ class Issue285Test { private final ObjectMapper mapper = new ObjectMapper(); private final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("http://json-schema.org", "resource:") .mapPrefix("https://json-schema.org", "resource:")) diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index e77500216..81683c8bd 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -10,7 +10,7 @@ class Issue295Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 602c55f74..0ca63d1a8 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -11,12 +11,12 @@ class Issue313Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } protected JsonSchema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 21fe077ac..41b2c51f8 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -6,7 +6,7 @@ class Issue314Test { private static final JsonSchemaFactory FACTORY = - JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) + JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .metaSchema( JsonMetaSchema.builder( "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index e32fcd686..b17497c15 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -10,7 +10,7 @@ class Issue327Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index e5e869f0d..c9720c066 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -11,7 +11,7 @@ class Issue342Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index e988f1e88..527d2e2b7 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -11,7 +11,7 @@ class Issue347Test { @Test void failure() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 48f5fea76..4532add55 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -27,7 +27,7 @@ private void setupSchema() throws IOException { .typeLoose(false) .build(); JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index c306773fe..5b6078bc0 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -26,7 +26,7 @@ private void setupSchema() throws IOException { SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().typeLoose(false).build(); JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .build(); SchemaLocation uri = getSchema(); diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 94e07ec57..ff4b32d5e 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; @@ -28,7 +28,7 @@ class Issue375Test { protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index b7d817e87..696b60c8d 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -11,7 +11,7 @@ class Issue383Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index 26f4f6ff7..f5865e193 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -14,7 +14,7 @@ class Issue396Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 66c747a0f..565ce6472 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -10,7 +10,7 @@ class Issue404Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index e05da6a83..ae8ffabb2 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -14,7 +14,7 @@ class Issue406Test { @Test void testPreloadingNotHappening() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass Assertions.assertNotNull(schema); @@ -22,7 +22,7 @@ void testPreloadingNotHappening() { @Test void testPreloadingHappening() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(JsonSchemaException.class, new Executable() { @@ -36,7 +36,7 @@ public void execute() { @Test void testPreloadingHappeningForCircularDependency() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); final JsonSchema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 4d35ae4af..6ba3da5f2 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -13,7 +13,7 @@ */ class Issue426Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index e2067cd2e..c8661d08b 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -15,7 +15,7 @@ class Issue428Test { protected ObjectMapper mapper = new ObjectMapper(); protected JsonSchemaFactory validatorFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).build(); + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).build(); private void runTestFile(String testCaseFile) throws Exception { final SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + testCaseFile); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 2c0222210..023d1384c 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -21,7 +21,7 @@ class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .propertyWalkListener(new CountingWalker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index ff107d707..bed3fab8c 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -11,7 +11,7 @@ class Issue456Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index a9c96d8e0..53e779a8c 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -17,7 +17,7 @@ class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); protected JsonSchema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 8b10d8842..bc319e636 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -37,7 +37,7 @@ import com.networknt.schema.walk.WalkFlow; class Issue467Test { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); private static final String schemaPath = "/schema/issue467.json"; protected ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index 905320d59..3707b18e9 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -78,7 +78,7 @@ private Map convertErrorsToMap(List errors) { } private JsonSchema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 7907a462f..00ef47511 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -50,7 +50,7 @@ class Issue475Test { @Test void draft4() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V4, builder -> builder + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V4), config); @@ -64,7 +64,7 @@ void draft4() throws Exception { @Test void draft6() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V6, builder -> builder + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V6), config); @@ -78,7 +78,7 @@ void draft6() throws Exception { @Test void draft7() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V7), config); @@ -92,7 +92,7 @@ void draft7() throws Exception { @Test void draft201909() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V201909, builder -> builder + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V201909), config); @@ -106,7 +106,7 @@ void draft201909() throws Exception { @Test void draft202012() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V202012), config); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index 274558840..a30798330 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -18,7 +18,7 @@ class Issue493Test { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); private static final String schemaPath1 = "/schema/issue493.json"; private JsonNode getJsonNodeFromJsonData (String jsonFilePath) diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 541a9312f..8d631fc87 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -13,7 +13,7 @@ class Issue518Test { private static final JsonSchemaFactory FACTORY = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .metaSchema(igluMetaSchema) .build(); diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index eb49b68da..c1dd2da85 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -7,7 +7,7 @@ class Issue532Test { @Test void failure() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index 5b3c702d5..03acb7ba9 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -12,7 +12,7 @@ class Issue550Test { protected JsonSchema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index b689eca10..6dac57066 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -25,7 +25,7 @@ class Issue575Test { @BeforeAll static void init() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); String schemaPath = "/schema/issue575-2019-09.json"; InputStream schemaInputStream = Issue575Test.class.getResourceAsStream(schemaPath); schema = factory.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index 920f7a791..162721c80 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -11,7 +11,7 @@ void failure() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) .build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index f79314c0e..c0826279e 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -10,7 +10,7 @@ class Issue606Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index c25fab2c7..9282323b5 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -53,7 +53,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; - factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4, + factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index 1e691efcf..d322088d5 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -37,7 +37,7 @@ void testBinaryNode() throws Exception { // schema with data property of type string: InputStream schemaInputStream = getClass().getResourceAsStream("/draft7/issue650.json"); - JsonSchema schema = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7).getSchema(schemaInputStream); + JsonSchema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); // create model first: Issue650Test.Model model = new Issue650Test.Model(); diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index 41979d83c..bbe3f7e01 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -17,7 +17,7 @@ class Issue662Test extends BaseJsonSchemaValidatorTest { @BeforeAll static void setup() { - schema = getJsonSchemaFromClasspath(resource("schema.json"), SpecVersion.VersionFlag.V7); + schema = getJsonSchemaFromClasspath(resource("schema.json"), Specification.Version.DRAFT_7); } @Test diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index 88987cbeb..7655e53a2 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -14,7 +14,7 @@ class Issue664Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index 5ec0aab09..1bf4eeb09 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -13,7 +13,7 @@ class Issue665Test extends BaseJsonSchemaValidatorTest { @Test void testUrnUriAsLocalRef() throws IOException { - JsonSchema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", SpecVersion.VersionFlag.V7); + JsonSchema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", Specification.Version.DRAFT_7); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); List messages = schema.validate(getJsonNodeFromStringContent( @@ -24,7 +24,7 @@ void testUrnUriAsLocalRef() throws IOException { @Test void testUrnUriAsLocalRef_ExternalURN() { JsonSchemaFactory factory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .schemaMappers(schemaMappers -> { schemaMappers.mappings(Collections.singletonMap("urn:data", "classpath:draft7/urn/issue665_external_urn_subschema.json")); diff --git a/src/test/java/com/networknt/schema/Issue668Test.java b/src/test/java/com/networknt/schema/Issue668Test.java index bdecac7b3..edafc99e6 100644 --- a/src/test/java/com/networknt/schema/Issue668Test.java +++ b/src/test/java/com/networknt/schema/Issue668Test.java @@ -11,7 +11,7 @@ class Issue668Test { protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); YAMLMapper mapper = new YAMLMapper(); JsonNode node = mapper.readTree(schemaContent); return factory.getSchema(node); diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index fde91b5c6..38f5b6945 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -54,7 +54,7 @@ void testLocaleSwitch() throws JsonProcessingException { } private JsonSchema getSchema(SchemaValidatorsConfig config) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index b21445c7d..cb98df28e 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -81,7 +81,7 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin @MethodSource("errors") void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); JsonSchema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); @@ -114,7 +114,7 @@ static Stream specialCharacterTests() { void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().pathType(pathType).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909) + JsonSchema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 310e56e90..0bcc0661c 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -50,7 +50,7 @@ void test() throws JsonProcessingException { + " \"billing_address\" : \"my_billing_address\"\n" + "}\n"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config); + JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false); System.out.println(stringCollector.strings); diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index 44c9a047f..9496330aa 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -12,7 +12,7 @@ class Issue792 { @Test void test() throws JsonProcessingException { - JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); String schemaDef = "{\n" + diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 20220a311..3262c4be5 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -14,7 +14,7 @@ class Issue824Test { @Test void validate() throws JsonProcessingException { final JsonSchema v201909SpecSchema = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index 5dbb1c3b0..e9b398386 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue857Test { @Test @@ -49,7 +49,7 @@ void test() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 40fed4b46..b034cad9b 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; class Issue877Test { @@ -30,7 +30,7 @@ void test() throws Exception { + " \"unevaluatedProperties\": false\n" + "}"; - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index 9a932d2c2..a18e2abb6 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -15,7 +15,7 @@ class Issue898Test extends BaseJsonSchemaValidatorTest { void testMessagesWithSingleQuotes() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.FRENCH).build(); - JsonSchema schema = getJsonSchemaFromClasspath("schema/issue898.json", SpecVersion.VersionFlag.V202012, config); + JsonSchema schema = getJsonSchemaFromClasspath("schema/issue898.json", Specification.Version.DRAFT_2020_12, config); JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); List messages = schema.validate(node).stream() diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index 20d2239b1..49b866ac1 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -105,7 +105,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7) + JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) .getSchema(SchemaLocation.of("http://www.example.org"), JsonMapperFactory.getInstance().readTree(schema)); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index 2b70f0a30..975a02d15 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -7,7 +7,7 @@ class Issue928Test { private final ObjectMapper mapper = new ObjectMapper(); - private JsonSchemaFactory factoryFor(SpecVersion.VersionFlag version) { + private JsonSchemaFactory factoryFor(Specification.Version version) { return JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(version)) .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://example.org", "classpath:")) @@ -16,23 +16,23 @@ private JsonSchemaFactory factoryFor(SpecVersion.VersionFlag version) { @Test void test_07() { - test_spec(SpecVersion.VersionFlag.V7); + test_spec(Specification.Version.DRAFT_7); } @Test void test_201909() { - test_spec(SpecVersion.VersionFlag.V201909); + test_spec(Specification.Version.DRAFT_2019_09); } @Test void test_202012() { - test_spec(SpecVersion.VersionFlag.V202012); + test_spec(Specification.Version.DRAFT_2020_12); } - void test_spec(SpecVersion.VersionFlag specVersion) { + void test_spec(Specification.Version specVersion) { JsonSchemaFactory schemaFactory = factoryFor(specVersion); - String versionId = specVersion.getId(); + String versionId = specVersion.getDialectId(); String versionStr = versionId.substring(versionId.indexOf("draft") + 6, versionId.indexOf("/schema")); String baseUrl = String.format("https://example.org/schema/issue928-v%s.json", versionStr); diff --git a/src/test/java/com/networknt/schema/Issue935Test.java b/src/test/java/com/networknt/schema/Issue935Test.java index e604cf0b3..2da974055 100644 --- a/src/test/java/com/networknt/schema/Issue935Test.java +++ b/src/test/java/com/networknt/schema/Issue935Test.java @@ -19,13 +19,13 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue935Test { @Test void shouldThrowInvalidSchemaException() { String schema = "{ \"$schema\": \"0\" }"; assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schema)); + () -> JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schema)); } } diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index 27cca2005..f59a958b2 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue936Test { @Test @@ -31,9 +31,9 @@ void shouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config)); + () -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); try { - JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schema, config); + JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 104f2c70a..41732fe46 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue939Test { @Test @@ -48,7 +48,7 @@ void shouldNotThrowException() { + " }\r\n" + " }\r\n" + " }"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schema); + JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index 75b19a7a7..8002cd658 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue940Test { @Test @@ -31,7 +31,7 @@ void shouldNotThrowException() { + " \"greeting\": {}\r\n" + " }\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schema); + JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); } } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index d90bcbd7d..9d9b6dd9b 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class Issue943Test { @Test @@ -67,7 +67,7 @@ void test() { + " \"type\": \"Point\",\r\n" + " \"coordinates\": [1, 1]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index ae3e4eee6..a17371e65 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; class Issue994Test { @@ -46,7 +46,7 @@ void test() throws JsonProcessingException { }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)).getSchema(schemaNode); + .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)).getSchema(schemaNode); String inputData = "{\r\n" + " \"textValue\": \"hello\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 40510d1c1..1be21937d 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -44,7 +44,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -67,7 +67,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -106,7 +106,7 @@ void walkNullPrefixItems() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 9b2638cb0..a6c1be85d 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.JsonSchemaWalkListener; import com.networknt.schema.walk.WalkEvent; @@ -47,7 +47,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -74,7 +74,7 @@ void messageAdditionalItemsInvalid() { + " \"items\": [{}]," + " \"additionalItems\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -101,7 +101,7 @@ void messageAdditionalItemsFalseInvalid() { + " \"items\": [{}]," + " \"additionalItems\": false" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -124,7 +124,7 @@ void walk() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -160,7 +160,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -202,7 +202,7 @@ void walkNullTupleItemsAdditional() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -252,7 +252,7 @@ void walkTupleItemsAdditional() throws JsonProcessingException { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -306,7 +306,7 @@ void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { + " \"default\": \"additional\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java index 956352fef..a3fab9fe3 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Tests for JsonSchemaFactory. @@ -46,7 +46,7 @@ void concurrency() { + " { \"$ref\": \"https://json-schema.org/draft/2020-12/meta/core\" }\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index 7297fde18..ce21c4bf1 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -44,7 +44,7 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { } private JsonSchemaFactory buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { - return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012)) + return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) .metaSchema(JsonMetaSchema.getV202012()) diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index 23b900b31..d254dcde5 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test to control preloading of schemas. @@ -26,14 +26,14 @@ class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json"), config); } @Test void preloadSchemaRefMaxNestingDepth() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .preloadJsonSchemaRefMaxNestingDepth(20) .build(); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTest.java b/src/test/java/com/networknt/schema/JsonSchemaTest.java index fa6303fd5..d01d98dc7 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Tests for JsonSchemaFactory. @@ -55,7 +55,7 @@ void concurrency() throws Exception { String inputData = "{\r\n" + " \"name\": 1\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().preloadJsonSchema(false).build(); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java index f3f380007..c442e4848 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java @@ -1,6 +1,6 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; @@ -18,31 +18,31 @@ class JsonSchemaTestSuiteExtrasTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2020-12") Stream draft2022012() { - return createTests(VersionFlag.V202012, "src/test/resources/draft2020-12"); + return createTests(Version.DRAFT_2020_12, "src/test/resources/draft2020-12"); } @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(VersionFlag.V201909, "src/test/resources/draft2019-09"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/draft2019-09"); } @TestFactory @DisplayName("Draft 7") Stream draft7() { - return createTests(VersionFlag.V7, "src/test/resources/draft7"); + return createTests(Version.DRAFT_7, "src/test/resources/draft7"); } @TestFactory @DisplayName("Draft 6") Stream draft6() { - return createTests(VersionFlag.V6, "src/test/resources/draft6"); + return createTests(Version.DRAFT_6, "src/test/resources/draft6"); } @TestFactory @DisplayName("Draft 4") Stream draft4() { - return createTests(VersionFlag.V4, "src/test/resources/draft4"); + return createTests(Version.DRAFT_4, "src/test/resources/draft4"); } @Override diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java index 880c8e647..478b7628e 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; @DisplayName("JSON Schema Test Suite") class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { @@ -30,31 +30,31 @@ class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2020-12") Stream draft2022012() { - return createTests(VersionFlag.V202012, "src/test/suite/tests/draft2020-12"); + return createTests(Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12"); } @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(VersionFlag.V201909, "src/test/suite/tests/draft2019-09"); + return createTests(Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09"); } @TestFactory @DisplayName("Draft 7") Stream draft7() { - return createTests(VersionFlag.V7, "src/test/suite/tests/draft7"); + return createTests(Version.DRAFT_7, "src/test/suite/tests/draft7"); } @TestFactory @DisplayName("Draft 6") Stream draft6() { - return createTests(VersionFlag.V6, "src/test/suite/tests/draft6"); + return createTests(Version.DRAFT_6, "src/test/suite/tests/draft6"); } @TestFactory @DisplayName("Draft 4") Stream draft4() { - return createTests(VersionFlag.V4, "src/test/suite/tests/draft4"); + return createTests(Version.DRAFT_4, "src/test/suite/tests/draft4"); } @Override diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 866a0e30d..76617aa1a 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -120,7 +120,7 @@ void testIllegalArgumentException() { } private JsonSchema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { - JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().applyDefaultsStrategy(applyDefaultsStrategy).build(); return schemaFactory.getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json"), schemaValidatorsConfig); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index e88dae5cf..db204563a 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -46,7 +46,7 @@ private void setupSchema() { schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).metaSchema(metaSchema) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(metaSchema) .build(); this.jsonSchema = schemaFactory.getSchema(getSchema(), schemaValidatorsConfigBuilder.build()); // Create another Schema. @@ -129,7 +129,7 @@ void testWalkMissingNodeWithPropertiesSchemaShouldNotThrow() { + " }\n" + " }"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema(schemaContents); JsonNode missingNode = MissingNode.getInstance(); assertDoesNotThrow(() -> schema.walk(missingNode, true)); diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index ed4a74a2f..b7c8c61fd 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -28,13 +28,13 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.i18n.Locales; import com.networknt.schema.serialization.JsonMapperFactory; class LocaleTest { private JsonSchema getSchema(SchemaValidatorsConfig config) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema( "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); @@ -88,7 +88,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { + " \"$id\": \"https://www.example.com\",\r\n" + " \"type\": \"object\"\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7) + JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); @@ -96,7 +96,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { assertEquals("$: integer gefunden, object erwartet", messages.iterator().next().toString()); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ENGLISH).build(); - jsonSchema = JsonSchemaFactory.getInstance(VersionFlag.V7) + jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema), config); messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); @@ -154,7 +154,7 @@ void encoding() { + " \"type\": \"string\",\r\n" + " \"maxLength\": 5\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 5e5a9d544..452f3bc80 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -34,7 +34,7 @@ class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s, \"exclusiveMaximum\": true}"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); private static final ObjectMapper mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 11a866755..d547d5983 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -71,7 +71,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void message() { JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012().getIri(), JsonMetaSchema.getV202012()) .keyword(new EqualsKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); String schemaData = "{\r\n" + " \"type\": \"string\",\r\n" + " \"equals\": \"helloworld\"\r\n" diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 7a362cc13..e49cb6401 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -42,7 +42,7 @@ void oas31() throws IOException { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07"), config); diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 6a082c06d..6fc3b4b8a 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -38,7 +38,7 @@ class MinimumValidatorTest { private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s }"; private static final String NEGATIVE_MESSAGE_TEMPLATE = "Expecting validation errors, value %s is smaller than minimum %s"; private static final String POSITIVT_MESSAGE_TEMPLATE = "Expecting no validation errors, value %s is greater than minimum %s"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); private static ObjectMapper mapper; private static ObjectMapper bigDecimalMapper; diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 4689fe649..dcf7fd922 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test MultipleOfValidator validator. @@ -47,7 +47,7 @@ class MultipleOfValidatorTest { @Test void test() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; @@ -62,7 +62,7 @@ void test() { @Test void testTypeLoose() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":\"123.892\",\"value2\":\"123456.2934\",\"value3\":123.123}"; diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index e6eb3baeb..048729832 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -36,7 +36,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index ef167f9fc..0984b73b0 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * OneOfValidatorTest. @@ -64,7 +64,7 @@ void oneOfMultiple() { + " \"fox\" : \"test\",\r\n" + " \"world\" : \"test\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -105,7 +105,7 @@ void oneOfZero() { String inputData = "{\r\n" + " \"test\" : 1\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -137,7 +137,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -185,7 +185,7 @@ void invalidSwaggerIoExample() { + " type: integer"; JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -259,7 +259,7 @@ void fixedSwaggerIoExample() { + " - age"; JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -301,7 +301,7 @@ void oneOfDiscriminatorEnabled() { + " }\r\n" + " ]\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); String inputData = "{}"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -355,7 +355,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -374,7 +374,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - JsonSchema schema2 = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -443,7 +443,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -462,7 +462,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - JsonSchema schema2 = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, + JsonSchema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -489,7 +489,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); JsonSchema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 8017606ed..a1561e005 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -15,7 +15,7 @@ class OpenAPI30JsonSchemaTest { protected ObjectMapper mapper = new ObjectMapper(); protected JsonSchemaFactory validatorFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).build(); + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).build(); OpenAPI30JsonSchemaTest() { } diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 6b1008132..1ca8c0bf4 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -17,12 +17,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.utils.CachingSupplier; class OutputFormatTest { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); private static final String schemaPath1 = "/schema/output-format-schema.json"; private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { @@ -107,7 +107,7 @@ void customFormat() { + " }\n" + " }\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012) + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) .getSchema(schemaData, InputFormat.JSON, SchemaValidatorsConfig.builder().build()); String inputData = "{\n" + " \"type\": \"cat\",\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index b0cdfc2df..d50d449e7 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.params.provider.EnumSource; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.serialization.JsonMapperFactory; @@ -95,7 +95,7 @@ class OutputUnitTest { + "}"; @Test void annotationCollectionList() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); @@ -112,7 +112,7 @@ void annotationCollectionList() throws JsonProcessingException { @Test void annotationCollectionHierarchical() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); @@ -129,7 +129,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { @Test void annotationCollectionHierarchical2() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); @@ -178,7 +178,7 @@ void formatAnnotation(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -197,7 +197,7 @@ void formatAssertion(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -216,7 +216,7 @@ void typeUnion() { String typeSchema = "{\r\n" + " \"type\": [\"string\",\"array\"]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(typeSchema, config); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -265,7 +265,7 @@ void unevaluatedProperties() throws JsonProcessingException { + " \"unevaluatedProperties\": false\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); @@ -315,7 +315,7 @@ void anyOf() throws JsonProcessingException { + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); @@ -337,7 +337,7 @@ void listAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); @@ -352,7 +352,7 @@ void hierarchicalAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 37a456cbd..851c23eea 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -53,7 +53,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .builder(URI, JsonMetaSchema.getV201909()) .build(); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).metaSchema(validatorMetaSchema).build(); + final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); final JsonSchema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { @@ -70,7 +70,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .format(PatternFormat.of("email", "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "format.email")) .build(); - final JsonSchemaFactory overrideValidatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).metaSchema(overrideValidatorMetaSchema).build(); + final JsonSchemaFactory overrideValidatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(overrideValidatorMetaSchema).build(); final JsonSchema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); messages = overrideValidatorSchema.validate(targetNode, executionContext -> { diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 7796ef238..e4837d32d 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import java.io.InputStream; import java.util.HashMap; import java.util.List; @@ -12,7 +12,7 @@ class OverwritingCustomMessageBugTest { private JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 649ace3da..d42b6c8ee 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -17,7 +17,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.regex.JoniRegularExpressionFactory; @@ -41,7 +41,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); JsonSchema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); @@ -56,7 +56,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); JsonSchema schema = factory.getSchema("{\"patternProperties\":6}", config); JsonNode node = getJsonNodeFromStringContent(""); @@ -79,7 +79,7 @@ void message() { + " }\n" + " }\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\n" @@ -130,7 +130,7 @@ void annotation() { + " }\n" + " }\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\n" diff --git a/src/test/java/com/networknt/schema/PatternValidatorTest.java b/src/test/java/com/networknt/schema/PatternValidatorTest.java index ba77fa00b..7f4541ec9 100644 --- a/src/test/java/com/networknt/schema/PatternValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternValidatorTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * PatternValidatorTest. @@ -32,7 +32,7 @@ void failFast() { + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" + "}"; String inputData = "\"hello\""; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); assertFalse(result); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 0e8b6193d..be9bf88be 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.PrefixItemsValidator; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.JsonSchemaWalkListener; @@ -33,7 +33,7 @@ class PrefixItemsValidatorTest extends AbstractJsonSchemaTestSuite { */ @Test void testEmptyPrefixItemsException() { - Stream dynamicNodeStream = createTests(SpecVersion.VersionFlag.V7, "src/test/resources/prefixItemsException"); + Stream dynamicNodeStream = createTests(Specification.Version.DRAFT_7, "src/test/resources/prefixItemsException"); dynamicNodeStream.forEach( dynamicNode -> { assertThrows(JsonSchemaException.class, () -> { @@ -54,7 +54,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -80,7 +80,7 @@ void messageValid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1]"; @@ -99,7 +99,7 @@ void messageInvalidAdditionalItems() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}],\r\n" + " \"items\": false" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1, 2]"; @@ -130,7 +130,7 @@ void walkNull() { + " }\n" + " ]\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -183,7 +183,7 @@ void walkDefaults() throws JsonProcessingException { + " }\n" + " ]\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/PropertiesTest.java b/src/test/java/com/networknt/schema/PropertiesTest.java index 083a550ed..64ca99974 100644 --- a/src/test/java/com/networknt/schema/PropertiesTest.java +++ b/src/test/java/com/networknt/schema/PropertiesTest.java @@ -1,6 +1,6 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; @@ -14,7 +14,7 @@ class PropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(VersionFlag.V201909, "src/test/resources/draft2019-09/properties.json"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/draft2019-09/properties.json"); } } diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index e0a6c3ad9..0f5473d8f 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -12,7 +12,7 @@ class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 86db1f688..325010d3a 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * PropertyNamesValidatorTest. @@ -38,7 +38,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"propertyNames\": {\"maxLength\": 3}\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index df1785fe8..7613b5931 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -40,7 +40,7 @@ private JsonSchema loadJsonSchema(Boolean write) { } private JsonSchema getJsonSchema(Boolean write) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig schemaConfig = createSchemaConfig(write); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); return factory.getSchema(schema, schemaConfig); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 2154c6185..e5f503e0d 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -21,7 +21,7 @@ class RecursiveReferenceValidatorExceptionTest extends AbstractJsonSchemaTestSui void testInvalidRecursiveReference() { // Arrange String invalidSchemaJson = "{ \"$recursiveRef\": \"invalid\" }"; - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); JsonSchema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getMetaSchema(), diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index c88caf4f6..8832088c7 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -15,7 +15,7 @@ class RefTest { @Test void shouldLoadRelativeClasspathReference() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); String input = "{\r\n" @@ -38,7 +38,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { @Test void shouldLoadSchemaResource() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index bcc05c25a..585cda8c5 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Tests for RefValidator. @@ -40,7 +40,7 @@ void resolveSamePathDotSlash() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); @@ -59,7 +59,7 @@ void resolveSamePath() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); @@ -78,7 +78,7 @@ void resolveParent() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); @@ -97,7 +97,7 @@ void resolveComplex() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); JsonSchema jsonSchema = factory.getSchema(mainSchema); @@ -107,7 +107,7 @@ void resolveComplex() { @Test void classPathSlash() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" @@ -123,7 +123,7 @@ void classPathSlash() { @Test void classPathNoSlash() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 589e77202..316881908 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * RequiredValidatorTest. @@ -55,7 +55,7 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -99,7 +99,7 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -143,7 +143,7 @@ void validateRequestRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -181,7 +181,7 @@ void validateResponseRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); JsonSchema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index fe03bf0fc..c25e9a647 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -18,7 +18,7 @@ class SampleTest { @Test void schemaFromSchemaLocationMapping() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.schemaMappers( + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers( schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. @@ -40,7 +40,7 @@ void schemaFromSchemaLocationMapping() { void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); /* @@ -61,7 +61,7 @@ void schemaFromSchemaLocationContent() { @Test void schemaFromClasspath() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -82,7 +82,7 @@ void schemaFromClasspath() { @Test void schemaFromString() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -98,7 +98,7 @@ void schemaFromString() { @Test void schemaFromJsonNode() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); /* diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index 382881156..0e1575de7 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; class SchemaLocationTest { @@ -217,7 +217,7 @@ void documentFragment() { @Test void shouldLoadEscapedFragment() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); List result = schema.validate("1", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index 636b4fa44..a88c6a7df 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -30,7 +30,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void shouldCallAllKeywordListenerOnWalkStart() throws Exception { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); AllKeywordListener allKeywordListener = new AllKeywordListener(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/SpecVersionDetectorTest.java b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java similarity index 74% rename from src/test/java/com/networknt/schema/SpecVersionDetectorTest.java rename to src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java index 2c7804242..4afbbd7bb 100644 --- a/src/test/java/com/networknt/schema/SpecVersionDetectorTest.java +++ b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java @@ -13,23 +13,23 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -class SpecVersionDetectorTest { +class SpecificationVersionDetectorTest { private static final ObjectMapper mapper = new ObjectMapper(); @ParameterizedTest @CsvSource({ - "draft4, V4", - "draft6, V6", - "draft7, V7", - "draft2019-09, V201909", - "draft2020-12, V202012" + "draft4, DRAFT_4", + "draft6, DRAFT_6", + "draft7, DRAFT_7", + "draft2019-09, DRAFT_2019_09", + "draft2020-12, DRAFT_2020_12" }) - void detectVersion(String resourceDirectory, SpecVersion.VersionFlag expectedFlag) throws IOException { + void detectVersion(String resourceDirectory, Specification.Version expectedFlag) throws IOException { InputStream in = Thread.currentThread().getContextClassLoader() .getResourceAsStream(resourceDirectory + "/schemaTag.json"); JsonNode node = mapper.readTree(in); - SpecVersion.VersionFlag flag = SpecVersionDetector.detect(node); + Specification.Version flag = SpecificationVersionDetector.detect(node); assertEquals(expectedFlag, flag); } @@ -41,7 +41,7 @@ void detectVersion(String resourceDirectory, SpecVersion.VersionFlag expectedFla void detectInvalidSchemaVersion(String schemaPath, String expectedError) throws IOException { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(schemaPath); JsonNode node = mapper.readTree(in); - JsonSchemaException exception = assertThrows(JsonSchemaException.class, () -> SpecVersionDetector.detect(node)); + JsonSchemaException exception = assertThrows(JsonSchemaException.class, () -> SpecificationVersionDetector.detect(node)); assertEquals(expectedError, exception.getMessage()); } @@ -50,7 +50,7 @@ void detectOptionalSpecVersion() throws IOException { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream( "data/schemaTagMissing.json"); JsonNode node = mapper.readTree(in); - Optional flag = SpecVersionDetector.detectOptionalVersion(node, true); + Optional flag = SpecificationVersionDetector.detectOptionalVersion(node, true); assertEquals(Optional.empty(), flag); } } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index f84684977..2d3284569 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test TypeValidator validator. @@ -52,7 +52,7 @@ class TypeValidatorTest { @Test void testTypeLoose() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); JsonSchema schema = factory.getSchema(schemaData); String inputData = "{\r\n" @@ -101,7 +101,7 @@ void integer() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); @@ -130,7 +130,7 @@ void integerDraft4() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V4).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling @@ -145,7 +145,7 @@ void walkNull() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V4).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } @@ -173,7 +173,7 @@ void nullable() { + " \"nested\":null\r\n" + " }\r\n" + "}"; - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); + final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); final JsonSchema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() .nullableKeywordEnabled(false) .build()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java index 765440666..4ed55be2b 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java @@ -1,6 +1,6 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -13,7 +13,7 @@ class UnevaluatedItemsTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(VersionFlag.V201909, "src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index eee96813b..a91a56249 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * UnevaluatedItemsValidatorTest. @@ -43,7 +43,7 @@ void unevaluatedItemsFalse() { + " \"unevaluatedItems\" : false\r\n" + "}"; String inputData = "[1,2,3]"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -69,7 +69,7 @@ void unevaluatedItemsSchema() { + " \"unevaluatedItems\" : { \"type\" : \"string\" }\r\n" + "}"; String inputData = "[1,2,3]"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java index 61cf70426..9a677746d 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java @@ -1,6 +1,6 @@ package com.networknt.schema; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; @@ -14,7 +14,7 @@ class UnevaluatedPropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(VersionFlag.V201909, "src/test/resources/schema/unevaluatedTests/unevaluated-tests.json"); + return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 86c534bcf..eed3d4c46 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; /** @@ -61,7 +61,7 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key3\": \"value3\",\r\n" + " \"key4\": \"value4\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -116,7 +116,7 @@ void subschemaProcessing() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -144,7 +144,7 @@ void unevaluatedPropertiesSchema() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -189,7 +189,7 @@ void ref() { + " \"unevaluatedProperties\": false\r\n" + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } @@ -228,7 +228,7 @@ void nestedRef() { schemas.put("https://www.example.org/PrimaryDeviceConfiguration.json", primaryDeviceConfiguration); schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V201909, + .getInstance(Version.DRAFT_2019_09, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) .getSchema(schemaData); String inputData = "{ \"isPrimaryDevice\": true, \"roleName\": \"hello\" }"; diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index d838163cc..139346dae 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -21,7 +21,7 @@ void testSchema1() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); + JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); JsonSchema jsonSchema = factory.getSchema(schema1); List errors = jsonSchema.validate(jsonNode); @@ -35,7 +35,7 @@ void testSchema2() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); + JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); JsonSchema jsonSchema = factory.getSchema(schema2); List errors = jsonSchema.validate(jsonNode); @@ -48,7 +48,7 @@ void testSchema3() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).build(); + JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); JsonSchema jsonSchema = factory.getSchema(schema3); List errors = jsonSchema.validate(jsonNode); diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 030c1f4cd..a26c36f2a 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -80,7 +80,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - JsonSchemaFactory instance = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4, + JsonSchemaFactory instance = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -117,7 +117,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) + JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); JsonSchema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); @@ -147,7 +147,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4, + JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); @@ -165,7 +165,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } catch (Exception ex) { fail("Unexpected exception thrown"); } - instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) + instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); JsonSchema schema = instance.getSchema(example, config); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); @@ -174,7 +174,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) + JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index 427ee98e6..78f4470d6 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -37,7 +37,7 @@ class V4JsonSchemaTest { void testLoadingWithId() throws Exception { try (InputStream inputStream = new FileInputStream("src/test/resources/remotes/self_ref/selfRef.json")) { JsonNode schemaJson = mapper.readTree(inputStream); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); @SuppressWarnings("unused") JsonSchema schema = factory.getSchema(schemaJson); } @@ -90,7 +90,7 @@ private List validateFailingFastSchemaFor(final String schemaFileName, fi final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); return JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .build() .getSchema(schema, config) .validate(dataFile); diff --git a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java index 5aa2cf020..95497310a 100644 --- a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java +++ b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java @@ -39,13 +39,13 @@ void testFromValueMissing() { @Test void testIfThenElseNotInV4() { - List list = ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V4); + List list = ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("if"))); } @Test void testExclusiveMaximumNotInV4() { - List list = ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V4); + List list = ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("exclusiveMaximum"))); } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index e146de32a..2f5b5f50d 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.output.OutputUnit; @@ -59,7 +59,7 @@ void noValidation() { + " }\r\n" + "}"; JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) @@ -74,7 +74,7 @@ void noValidation() { // Set validation vocab schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/validation", @@ -83,7 +83,7 @@ void noValidation() { messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("minimum", messages.iterator().next().getKeyword()); - assertEquals(VersionFlag.V202012, schema.getValidationContext().activeDialect().get()); + assertEquals(Version.DRAFT_2020_12, schema.getValidationContext().activeDialect().get()); } @Test @@ -111,7 +111,7 @@ void noFormatValidation() { + " }\r\n" + "}"; JsonSchema schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) @@ -127,7 +127,7 @@ void noFormatValidation() { // Set format assertion vocab schema = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/format", @@ -163,7 +163,7 @@ void requiredUnknownVocabulary() { + " }\r\n" + "}"; JsonSchemaFactory factory = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); @@ -206,7 +206,7 @@ void customVocabulary() { .vocabularyFactory(vocabularyFactory) .build(); JsonSchemaFactory factory = JsonSchemaFactory - .getInstance(VersionFlag.V202012, + .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java index 9297804f6..7d34db50d 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Basic Benchmark. @@ -26,7 +26,7 @@ public class NetworkntBasicRunner implements Callable { public NetworkntBasicRunner() { ObjectMapper objectMapper = new ObjectMapper(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V4); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4); try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ObjectReader reader = objectMapper.reader(); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java index 1a2704c42..af95452e5 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java @@ -2,12 +2,12 @@ import java.util.concurrent.Callable; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; public class NetworkntTestSuite202012OptionalPerf { public static void main(String[] args) throws Exception { Callable runner = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - VersionFlag.V202012, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); + Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); runner.call(); } } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java index 7935441e0..ede2e752b 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java @@ -2,12 +2,12 @@ import java.util.concurrent.Callable; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; public class NetworkntTestSuite202012RequiredPerf { public static void main(String[] args) throws Exception { Callable runner = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - VersionFlag.V202012, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); + Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); runner.call(); } } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java index 9b3e5059a..2369ee2dc 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java @@ -18,7 +18,7 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; public class NetworkntTestSuiteOptionalBenchmark { public static final String VERSION_202012 = "2020-12"; @@ -33,17 +33,17 @@ public static class BenchmarkState { private String specification; private Callable draft202012Optional = new NetworkntTestSuiteRunner( - NetworkntTestSuiteTestCases.findTestCases(VersionFlag.V202012, "src/test/suite/tests/draft2020-12", + NetworkntTestSuiteTestCases.findTestCases(Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); private Callable draft201909Optional = new NetworkntTestSuiteRunner( - NetworkntTestSuiteTestCases.findTestCases(VersionFlag.V201909, "src/test/suite/tests/draft2019-09", + NetworkntTestSuiteTestCases.findTestCases(Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", TestCaseFilter.optionalType())); private Callable draft7Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V7, "src/test/suite/tests/draft7", TestCaseFilter.optionalType())); + .findTestCases(Version.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.optionalType())); private Callable draft6Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V6, "src/test/suite/tests/draft6", TestCaseFilter.optionalType())); + .findTestCases(Version.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.optionalType())); private Callable draft4Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V4, "src/test/suite/tests/draft4", TestCaseFilter.optionalType())); + .findTestCases(Version.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.optionalType())); private Callable getTestSuite() { switch (specification) { diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java index 08526aa39..8cf09366c 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java @@ -18,7 +18,7 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; public class NetworkntTestSuiteRequiredBenchmark { public static final String VERSION_202012 = "2020-12"; @@ -33,15 +33,15 @@ public static class BenchmarkState { private String specification; private Callable draft202012 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - VersionFlag.V202012, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); + Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); private Callable draft201909 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - VersionFlag.V201909, "src/test/suite/tests/draft2019-09", TestCaseFilter.requiredType())); + Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", TestCaseFilter.requiredType())); private Callable draft7 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V7, "src/test/suite/tests/draft7", TestCaseFilter.requiredType())); + .findTestCases(Version.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.requiredType())); private Callable draft6 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V6, "src/test/suite/tests/draft6", TestCaseFilter.requiredType())); + .findTestCases(Version.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.requiredType())); private Callable draft4 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(VersionFlag.V4, "src/test/suite/tests/draft4", TestCaseFilter.requiredType())); + .findTestCases(Version.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.requiredType())); private Callable getTestSuite() { switch (specification) { diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index af3aa3310..a8d2c7bcc 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -18,7 +18,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.SchemaLoader; @@ -38,11 +38,11 @@ private static List findTestCasePaths(String basePath, Predicate findTestCases(VersionFlag defaultVersion, String basePath) { + public static List findTestCases(Version defaultVersion, String basePath) { return findTestCases(defaultVersion, basePath, path -> true); } - public static List findTestCases(VersionFlag defaultVersion, String basePath, + public static List findTestCases(Version defaultVersion, String basePath, Predicate filter) { SchemaLoader schemaLoader = new SchemaLoader() { @Override diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index 1a91eb897..985db761c 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; class IriFormatTest { @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index 94e27201c..c2d1af171 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; class IriReferenceFormatTest { @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index e42976798..b34890b36 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; class TimeFormatTest { @@ -60,7 +60,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -89,7 +89,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index 2976f6cfa..4e4e3ad0f 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; class UriFormatTest { @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index d62bcd842..c283bfa16 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; class UriReferenceFormatTest { @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 4153831a2..c3f5600ed 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -32,7 +32,7 @@ import com.networknt.schema.PathType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; /** @@ -44,7 +44,7 @@ class OpenApi30Test { */ @Test void validateMetaSchema() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(OpenApi30.getInstance()) .defaultMetaSchemaIri(OpenApi30.getInstance().getIri()) .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); @@ -74,7 +74,7 @@ void validateMetaSchema() { */ @Test void jsonPointerWithNumberInFragment() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); JsonSchema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"), @@ -95,7 +95,7 @@ void exclusiveMaximum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMaximum\": true\r\n" + "}\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); JsonSchema schema = factory.getSchema(schemaData); assertFalse(schema.validate("100", InputFormat.JSON, OutputFormat.BOOLEAN)); @@ -112,7 +112,7 @@ void exclusiveMinimum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMinimum\": true\r\n" + "}\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); JsonSchema schema = factory.getSchema(schemaData); assertFalse(schema.validate("0", InputFormat.JSON, OutputFormat.BOOLEAN)); diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 058315330..387ba611a 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -27,7 +27,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; /** @@ -39,7 +39,7 @@ class OpenApi31Test { */ @Test void validateVocabulary() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); JsonSchema schema = factory @@ -68,7 +68,7 @@ void validateVocabulary() { */ @Test void validateMetaSchema() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); JsonSchema schema = factory @@ -98,7 +98,7 @@ void validateMetaSchema() { */ @Test void discriminatorOneOfMultipleMatchShouldFail() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); JsonSchema schema = factory @@ -118,7 +118,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { */ @Test void discriminatorOneOfNoMatchShouldFail() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); JsonSchema schema = factory @@ -140,7 +140,7 @@ void discriminatorOneOfNoMatchShouldFail() { */ @Test void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); JsonSchema schema = factory diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java index 331a96b15..a12212ca2 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test for AllowSchemaLoader. @@ -34,7 +34,7 @@ class AllowSchemaLoaderTest { @Test void integration() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .add(new AllowSchemaLoader(iri -> iri.toString().startsWith("classpath:"))))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, diff --git a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java index dde349e15..77645064f 100644 --- a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; /** * Test for DisallowSchemaLoader. @@ -32,7 +32,7 @@ class DisallowSchemaLoaderTest { @Test void integration() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.add(DisallowSchemaLoader.getInstance()))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 6d696b6ff..0d2317044 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -35,7 +35,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.serialization.JsonNodeReader; @@ -87,7 +87,7 @@ void jsonLocation() { String inputData = "{\r\n" + " \"startDate\": \"1\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, InputFormat.JSON, config); @@ -133,7 +133,7 @@ void yamlLocation() { + " minLength: 6\r\n"; String inputData = "---\r\n" + "startDate: '1'\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(schemaData, InputFormat.YAML, config); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index a5978ecc6..cb04d553c 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -42,7 +42,7 @@ import com.networknt.schema.SchemaId; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; @@ -104,7 +104,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -184,7 +184,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -269,7 +269,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -342,7 +342,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -391,7 +391,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909) + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09) .getSchema(SchemaLocation.of(SchemaId.V201909), config); String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" @@ -555,7 +555,7 @@ void applyDefaults() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -612,7 +612,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -669,7 +669,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); @@ -737,7 +737,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertFalse(result.getErrors().isEmpty()); @@ -807,7 +807,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); @@ -858,7 +858,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V201909).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -921,7 +921,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config); + JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); From ebb02ed36adeee4c1fecbd47ce3bf7da4e2b70a6 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:44:13 +0800 Subject: [PATCH 10/74] Rename SchemaId to DialectId --- .../schema/{SchemaId.java => DialectId.java} | 16 +++++++++------- .../com/networknt/schema/JsonSchemaFactory.java | 10 +++++----- .../java/com/networknt/schema/Specification.java | 10 +++++----- .../java/com/networknt/schema/Version201909.java | 2 +- .../java/com/networknt/schema/Version202012.java | 2 +- src/main/java/com/networknt/schema/Version4.java | 2 +- src/main/java/com/networknt/schema/Version6.java | 2 +- src/main/java/com/networknt/schema/Version7.java | 2 +- .../java/com/networknt/schema/oas/OpenApi30.java | 4 ++-- .../java/com/networknt/schema/oas/OpenApi31.java | 4 ++-- .../java/com/networknt/schema/ExampleTest.java | 8 ++++---- .../java/com/networknt/schema/Issue475Test.java | 10 +++++----- src/test/java/com/networknt/schema/RefTest.java | 8 ++++---- .../networknt/schema/UnknownMetaSchemaTest.java | 2 +- .../schema/resource/MetaSchemaMapperTest.java | 12 ++++++------ .../schema/walk/JsonSchemaWalkListenerTest.java | 4 ++-- 16 files changed, 50 insertions(+), 48 deletions(-) rename src/main/java/com/networknt/schema/{SchemaId.java => DialectId.java} (59%) diff --git a/src/main/java/com/networknt/schema/SchemaId.java b/src/main/java/com/networknt/schema/DialectId.java similarity index 59% rename from src/main/java/com/networknt/schema/SchemaId.java rename to src/main/java/com/networknt/schema/DialectId.java index 51ef06305..74af1b209 100644 --- a/src/main/java/com/networknt/schema/SchemaId.java +++ b/src/main/java/com/networknt/schema/DialectId.java @@ -16,33 +16,35 @@ package com.networknt.schema; /** - * Schema Identifier used in $schema. + * The dialect id is an IRI that points to the meta-schema that can be used to + * validate schemas written for that dialect. The dialect used for a particular + * schema is indicated using the $schema keyword. */ -public class SchemaId { +public class DialectId { /** * Draft 4. */ - public static final String V4 = "http://json-schema.org/draft-04/schema#"; + public static final String DRAFT_4 = "http://json-schema.org/draft-04/schema#"; /** * Draft 6. */ - public static final String V6 = "http://json-schema.org/draft-06/schema#"; + public static final String DRAFT_6 = "http://json-schema.org/draft-06/schema#"; /** * Draft 7. */ - public static final String V7 = "http://json-schema.org/draft-07/schema#"; + public static final String DRAFT_7 = "http://json-schema.org/draft-07/schema#"; /** * Draft 2019-09. */ - public static final String V201909 = "https://json-schema.org/draft/2019-09/schema"; + public static final String DRAFT_2019_09 = "https://json-schema.org/draft/2019-09/schema"; /** * Draft 2020-12. */ - public static final String V202012 = "https://json-schema.org/draft/2020-12/schema"; + public static final String DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema"; /** * OpenAPI 3.0. diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 94a395481..13502a4b9 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -832,15 +832,15 @@ static protected String normalizeMetaSchemaUri(String id) { if (id.contains("://json-schema.org/draft")) { // unnormalized $schema if (id.contains("/draft-07/")) { - id = SchemaId.V7; + id = DialectId.DRAFT_7; } else if (id.contains("/draft/2019-09/")) { - id = SchemaId.V201909; + id = DialectId.DRAFT_2019_09; } else if (id.contains("/draft/2020-12/")) { - id = SchemaId.V202012; + id = DialectId.DRAFT_2020_12; } else if (id.contains("/draft-04/")) { - id = SchemaId.V4; + id = DialectId.DRAFT_4; } else if (id.contains("/draft-06/")) { - id = SchemaId.V6; + id = DialectId.DRAFT_6; } } } diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java index 8e1ae61e2..84a0a0c67 100644 --- a/src/main/java/com/networknt/schema/Specification.java +++ b/src/main/java/com/networknt/schema/Specification.java @@ -29,23 +29,23 @@ public enum Version { /** * Draft 4. */ - DRAFT_4(4, SchemaId.V4), + DRAFT_4(4, DialectId.DRAFT_4), /** * Draft 6. */ - DRAFT_6(6, SchemaId.V6), + DRAFT_6(6, DialectId.DRAFT_6), /** * Draft 7. */ - DRAFT_7(7, SchemaId.V7), + DRAFT_7(7, DialectId.DRAFT_7), /** * Draft 2019-09. */ - DRAFT_2019_09(8, SchemaId.V201909), + DRAFT_2019_09(8, DialectId.DRAFT_2019_09), /** * Draft 2020-12. */ - DRAFT_2020_12(9, SchemaId.V202012); + DRAFT_2020_12(9, DialectId.DRAFT_2020_12); private final int order; private final String dialectId; diff --git a/src/main/java/com/networknt/schema/Version201909.java b/src/main/java/com/networknt/schema/Version201909.java index a3cf4a6f0..a9b87052b 100644 --- a/src/main/java/com/networknt/schema/Version201909.java +++ b/src/main/java/com/networknt/schema/Version201909.java @@ -11,7 +11,7 @@ * Draft 2019-09 dialect. */ public class Version201909 implements JsonSchemaVersion { - private static final String IRI = SchemaId.V201909; + private static final String IRI = DialectId.DRAFT_2019_09; private static final String ID = "$id"; private static final Map VOCABULARY; diff --git a/src/main/java/com/networknt/schema/Version202012.java b/src/main/java/com/networknt/schema/Version202012.java index 29807dbb3..2e9f51bd4 100644 --- a/src/main/java/com/networknt/schema/Version202012.java +++ b/src/main/java/com/networknt/schema/Version202012.java @@ -11,7 +11,7 @@ * Draft 2020-12 dialect. */ public class Version202012 implements JsonSchemaVersion { - private static final String IRI = SchemaId.V202012; + private static final String IRI = DialectId.DRAFT_2020_12; private static final String ID = "$id"; private static final Map VOCABULARY; diff --git a/src/main/java/com/networknt/schema/Version4.java b/src/main/java/com/networknt/schema/Version4.java index f1d6b09de..05e405d7a 100644 --- a/src/main/java/com/networknt/schema/Version4.java +++ b/src/main/java/com/networknt/schema/Version4.java @@ -10,7 +10,7 @@ * Draft 4 dialect. */ public class Version4 implements JsonSchemaVersion { - private static final String IRI = SchemaId.V4; + private static final String IRI = DialectId.DRAFT_4; private static final String ID = "id"; private static class Holder { diff --git a/src/main/java/com/networknt/schema/Version6.java b/src/main/java/com/networknt/schema/Version6.java index a892dbf14..a1718b192 100644 --- a/src/main/java/com/networknt/schema/Version6.java +++ b/src/main/java/com/networknt/schema/Version6.java @@ -10,7 +10,7 @@ * Draft 6 dialect. */ public class Version6 implements JsonSchemaVersion { - private static final String IRI = SchemaId.V6; + private static final String IRI = DialectId.DRAFT_6; // Draft 6 uses "$id" private static final String ID = "$id"; diff --git a/src/main/java/com/networknt/schema/Version7.java b/src/main/java/com/networknt/schema/Version7.java index 75c1d5af0..ad6e72197 100644 --- a/src/main/java/com/networknt/schema/Version7.java +++ b/src/main/java/com/networknt/schema/Version7.java @@ -10,7 +10,7 @@ * Draft 7 dialect. */ public class Version7 implements JsonSchemaVersion { - private static final String IRI = SchemaId.V7; + private static final String IRI = DialectId.DRAFT_7; private static final String ID = "$id"; private static class Holder { diff --git a/src/main/java/com/networknt/schema/oas/OpenApi30.java b/src/main/java/com/networknt/schema/oas/OpenApi30.java index 703d068bf..5b8af119d 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi30.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi30.java @@ -4,7 +4,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; -import com.networknt.schema.SchemaId; +import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; @@ -14,7 +14,7 @@ * OpenAPI 3.0. */ public class OpenApi30 { - private static final String IRI = SchemaId.OPENAPI_3_0; + private static final String IRI = DialectId.OPENAPI_3_0; private static final String ID = "id"; private static class Holder { diff --git a/src/main/java/com/networknt/schema/oas/OpenApi31.java b/src/main/java/com/networknt/schema/oas/OpenApi31.java index 1d42be34b..ff9e770f7 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi31.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi31.java @@ -6,7 +6,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.JsonMetaSchema; -import com.networknt.schema.SchemaId; +import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -15,7 +15,7 @@ * OpenAPI 3.1. */ public class OpenApi31 { - private static final String IRI = SchemaId.OPENAPI_3_1; + private static final String IRI = DialectId.OPENAPI_3_1; private static final String ID = "$id"; private static final Map VOCABULARY; diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 6ba932314..39d4f3631 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -40,13 +40,13 @@ void exampleSchemaLocation() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(SchemaId.V7, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getMetaSchema().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 JsonSchema refSchema = schema.getValidationContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); - assertEquals(SchemaId.V201909, refSchema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); } @Test @@ -63,12 +63,12 @@ void exampleClasspath() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(SchemaId.V7, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getMetaSchema().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 JsonSchema refSchema = schema.getValidationContext().getSchemaResources().get("classpath:schema/example-ref.json#"); - assertEquals(SchemaId.V201909, refSchema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); } } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 00ef47511..ca79bccd6 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -53,7 +53,7 @@ void draft4() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V4), config); + JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -67,7 +67,7 @@ void draft6() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V6), config); + JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -81,7 +81,7 @@ void draft7() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V7), config); + JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -95,7 +95,7 @@ void draft201909() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V201909), config); + JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -109,7 +109,7 @@ void draft202012() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(SchemaId.V202012), config); + JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 8832088c7..fd1496360 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -25,7 +25,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(SchemaId.V4, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getMetaSchema().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -48,7 +48,7 @@ void shouldLoadSchemaResource() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(SchemaId.V4, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getMetaSchema().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -59,8 +59,8 @@ void shouldLoadSchemaResource() throws JsonProcessingException { assertEquals("field1", error.getProperty()); JsonSchema driver = schema.getValidationContext().getSchemaResources().get("https://www.example.org/driver#"); JsonSchema common = schema.getValidationContext().getSchemaResources().get("https://www.example.org/common#"); - assertEquals(SchemaId.V4, driver.getValidationContext().getMetaSchema().getIri()); - assertEquals(SchemaId.V7, common.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, driver.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_7, common.getValidationContext().getMetaSchema().getIri()); } } diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index 139346dae..4bd7638f7 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -64,7 +64,7 @@ void testNormalize() throws JsonSchemaException { String uri02 = "http://json-schema.org/draft-07/schema#"; String uri03 = "http://json-schema.org/draft-07/schema?key=value"; String uri04 = "http://json-schema.org/draft-07/schema?key=value&key2=value2"; - String expected = SchemaId.V7; + String expected = DialectId.DRAFT_7; Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri01)); Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri02)); diff --git a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java b/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java index dd8980455..f0616f18b 100644 --- a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java +++ b/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.params.provider.EnumSource; import com.networknt.schema.AbsoluteIri; -import com.networknt.schema.SchemaId; +import com.networknt.schema.DialectId; /** * MetaSchemaMapperTest. @@ -33,11 +33,11 @@ class MetaSchemaMapperTest { enum MapInput { - V4(SchemaId.V4), - V6(SchemaId.V6), - V7(SchemaId.V7), - V201909(SchemaId.V201909), - V202012(SchemaId.V202012); + V4(DialectId.DRAFT_4), + V6(DialectId.DRAFT_6), + V7(DialectId.DRAFT_7), + V201909(DialectId.DRAFT_2019_09), + V202012(DialectId.DRAFT_2020_12); String iri; diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index cb04d553c..9c0191228 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -39,7 +39,7 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.JsonSchemaRef; -import com.networknt.schema.SchemaId; +import com.networknt.schema.DialectId; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -392,7 +392,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09) - .getSchema(SchemaLocation.of(SchemaId.V201909), config); + .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" + " \"type\": \"object\",\r\n" From f5abdc88a7a8c0f6f4dee049d043f6dc13e123a4 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:49:48 +0800 Subject: [PATCH 11/74] Rename JsonMetaSchema to Dialect --- .../schema/DefaultJsonMetaSchemaFactory.java | 10 ++--- .../{JsonMetaSchema.java => Dialect.java} | 33 ++++++++-------- .../DisallowUnknownJsonMetaSchemaFactory.java | 2 +- .../schema/JsonMetaSchemaFactory.java | 4 +- .../networknt/schema/JsonSchemaFactory.java | 38 +++++++++---------- .../networknt/schema/JsonSchemaVersion.java | 2 +- .../networknt/schema/ValidationContext.java | 8 ++-- .../com/networknt/schema/Version201909.java | 6 +-- .../com/networknt/schema/Version202012.java | 6 +-- .../java/com/networknt/schema/Version4.java | 6 +-- .../java/com/networknt/schema/Version6.java | 6 +-- .../java/com/networknt/schema/Version7.java | 6 +-- .../com/networknt/schema/oas/OpenApi30.java | 8 ++-- .../com/networknt/schema/oas/OpenApi31.java | 8 ++-- .../schema/CollectorContextTest.java | 14 +++---- .../schema/CustomMetaSchemaTest.java | 4 +- .../DisallowUnknownKeywordFactoryTest.java | 2 +- .../schema/ExclusiveMinimumValidatorTest.java | 6 +-- .../schema/FormatKeywordFactoryTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 8 ++-- .../com/networknt/schema/Issue314Test.java | 4 +- .../com/networknt/schema/Issue518Test.java | 6 +-- .../com/networknt/schema/Issue784Test.java | 4 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue832Test.java | 6 +-- .../com/networknt/schema/Issue994Test.java | 2 +- .../schema/JsonSchemaFactoryTest.java | 4 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 8 ++-- .../com/networknt/schema/MessageTest.java | 2 +- .../schema/OverrideValidatorTest.java | 8 ++-- .../com/networknt/schema/UriMappingTest.java | 4 +- .../java/com/networknt/schema/UrnTest.java | 2 +- .../com/networknt/schema/VocabularyTest.java | 4 +- 34 files changed, 120 insertions(+), 117 deletions(-) rename src/main/java/com/networknt/schema/{JsonMetaSchema.java => Dialect.java} (91%) diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java index 2a14c37a0..6bf9daa20 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java @@ -26,7 +26,7 @@ */ public class DefaultJsonMetaSchemaFactory implements JsonMetaSchemaFactory { @Override - public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + public Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { // Is it a well-known dialect? return Specification.Version.fromDialectId(iri) .map(JsonSchemaFactory::checkVersion) @@ -37,10 +37,10 @@ public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, }); } - protected JsonMetaSchema loadMetaSchema(String iri, JsonSchemaFactory schemaFactory, + protected Dialect loadMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { try { - JsonMetaSchema result = loadMetaSchemaBuilder(iri, schemaFactory, config).build(); + Dialect result = loadMetaSchemaBuilder(iri, schemaFactory, config).build(); return result; } catch (InvalidSchemaException e) { throw e; @@ -51,10 +51,10 @@ protected JsonMetaSchema loadMetaSchema(String iri, JsonSchemaFactory schemaFact } } - protected JsonMetaSchema.Builder loadMetaSchemaBuilder(String iri, JsonSchemaFactory schemaFactory, + protected Dialect.Builder loadMetaSchemaBuilder(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { JsonSchema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); - JsonMetaSchema.Builder builder = JsonMetaSchema.builder(iri, schema.getValidationContext().getMetaSchema()); + Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getMetaSchema()); Version specification = schema.getValidationContext().getMetaSchema().getSpecification(); if (specification != null) { if (specification.getOrder() >= Version.DRAFT_2019_09.getOrder()) { diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/Dialect.java similarity index 91% rename from src/main/java/com/networknt/schema/JsonMetaSchema.java rename to src/main/java/com/networknt/schema/Dialect.java index a6fdedf3d..38e3077ed 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/Dialect.java @@ -37,10 +37,13 @@ import java.util.function.Consumer; /** - * Represents a meta-schema which is uniquely identified by its IRI. + * A dialect represents the set of keywords and semantics that can be used to + * evaluate a schema. The dialect can be uniquely identified by its IRI which + * points to the meta-schema used to validate schemas written for that dialect. + * The dialect for a particular schema is indicated using the $schema keyword. */ -public class JsonMetaSchema { - private static final Logger logger = LoggerFactory.getLogger(JsonMetaSchema.class); +public class Dialect { + private static final Logger logger = LoggerFactory.getLogger(Dialect.class); /** * Factory for creating a format keyword. @@ -56,7 +59,7 @@ public interface FormatKeywordFactory { } /** - * Builder for {@link JsonMetaSchema}. + * Builder for {@link Dialect}. */ public static class Builder { private String iri; @@ -269,7 +272,7 @@ public Builder idKeyword(String idKeyword) { return this; } - public JsonMetaSchema build() { + public Dialect build() { // create builtin keywords with (custom) formats. Map keywords = this.keywords; if (this.specification != null) { @@ -298,7 +301,7 @@ public JsonMetaSchema build() { } } Map result = createKeywordsMap(keywords, this.formats); - return new JsonMetaSchema(this.iri, this.idKeyword, result, this.vocabularies, this.specification, this); + return new Dialect(this.iri, this.idKeyword, result, this.vocabularies, this.specification, this); } @Deprecated @@ -330,7 +333,7 @@ public Builder addFormats(Collection formats) { private final Builder builder; - JsonMetaSchema(String iri, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { + Dialect(String iri, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { if (StringUtils.isBlank(iri)) { throw new IllegalArgumentException("iri must not be null or blank"); } @@ -349,23 +352,23 @@ public Builder addFormats(Collection formats) { this.builder = builder; } - public static JsonMetaSchema getV4() { + public static Dialect getV4() { return new Version4().getInstance(); } - public static JsonMetaSchema getV6() { + public static Dialect getV6() { return new Version6().getInstance(); } - public static JsonMetaSchema getV7() { + public static Dialect getV7() { return new Version7().getInstance(); } - public static JsonMetaSchema getV201909() { + public static Dialect getV201909() { return new Version201909().getInstance(); } - public static JsonMetaSchema getV202012() { + public static Dialect getV202012() { return new Version202012().getInstance(); } @@ -394,7 +397,7 @@ public static Builder builder(String iri) { * @return a builder instance preconfigured to be the same as blueprint, but * with a different uri. */ - public static Builder builder(String iri, JsonMetaSchema blueprint) { + public static Builder builder(String iri, Dialect blueprint) { Builder builder = builder(blueprint); builder.iri = iri; return builder; @@ -406,7 +409,7 @@ public static Builder builder(String iri, JsonMetaSchema blueprint) { * @param blueprint the JsonMetaSchema to base your custom JsonMetaSchema on. * @return a builder instance preconfigured to be the same as blueprint */ - public static Builder builder(JsonMetaSchema blueprint) { + public static Builder builder(Dialect blueprint) { Map vocabularies = new HashMap<>(blueprint.getVocabularies()); return builder(blueprint.getIri()) .idKeyword(blueprint.idKeyword) @@ -533,7 +536,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - JsonMetaSchema other = (JsonMetaSchema) obj; + Dialect other = (Dialect) obj; return Objects.equals(iri, other.iri); } } diff --git a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java index 8f788166d..b3faed52a 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java @@ -21,7 +21,7 @@ */ public class DisallowUnknownJsonMetaSchemaFactory implements JsonMetaSchemaFactory { @Override - public JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + public Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { throw new InvalidSchemaException(Error.builder() .message("Unknown meta-schema ''{0}''. Only meta-schemas that are explicitly configured can be used.") .arguments(iri).build()); diff --git a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java index 31d7f1adb..87d5cb768 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java @@ -16,7 +16,7 @@ package com.networknt.schema; /** - * Factory for {@link JsonMetaSchema}. + * Factory for {@link Dialect}. */ @FunctionalInterface public interface JsonMetaSchemaFactory { @@ -28,5 +28,5 @@ public interface JsonMetaSchemaFactory { * @param config the config * @return the meta-schema */ - JsonMetaSchema getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config); + Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config); } diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 13502a4b9..d24b213c3 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -57,7 +57,7 @@ public static class Builder { private ObjectMapper yamlMapper = null; private JsonNodeReader jsonNodeReader = null; private String defaultMetaSchemaIri; - private final ConcurrentMap metaSchemas = new ConcurrentHashMap<>(); + private final ConcurrentMap metaSchemas = new ConcurrentHashMap<>(); private SchemaLoaders.Builder schemaLoadersBuilder = null; private SchemaMappers.Builder schemaMappersBuilder = null; private boolean enableSchemaCache = true; @@ -120,19 +120,19 @@ public Builder metaSchemaFactory(final JsonMetaSchemaFactory jsonMetaSchemaFacto return this; } - public Builder metaSchema(final JsonMetaSchema jsonMetaSchema) { + public Builder metaSchema(final Dialect jsonMetaSchema) { this.metaSchemas.put(normalizeMetaSchemaUri(jsonMetaSchema.getIri()), jsonMetaSchema); return this; } - public Builder metaSchemas(final Collection jsonMetaSchemas) { - for (JsonMetaSchema jsonMetaSchema : jsonMetaSchemas) { + public Builder metaSchemas(final Collection jsonMetaSchemas) { + for (Dialect jsonMetaSchema : jsonMetaSchemas) { metaSchema(jsonMetaSchema); } return this; } - public Builder metaSchemas(Consumer> customizer) { + public Builder metaSchemas(Consumer> customizer) { customizer.accept(this.metaSchemas); return this; } @@ -159,12 +159,12 @@ public Builder schemaMappers(Consumer schemaMappersBuilde } @Deprecated - public Builder addMetaSchema(final JsonMetaSchema jsonMetaSchema) { + public Builder addMetaSchema(final Dialect jsonMetaSchema) { return metaSchema(jsonMetaSchema); } @Deprecated - public Builder addMetaSchemas(final Collection jsonMetaSchemas) { + public Builder addMetaSchemas(final Collection jsonMetaSchemas) { return metaSchemas(jsonMetaSchemas); } @@ -190,7 +190,7 @@ public JsonSchemaFactory build() { private final SchemaLoaders.Builder schemaLoadersBuilder; private final SchemaMappers.Builder schemaMappersBuilder; private final SchemaLoader schemaLoader; - private final ConcurrentMap metaSchemas; + private final ConcurrentMap metaSchemas; private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; private final JsonMetaSchemaFactory metaSchemaFactory; @@ -205,7 +205,7 @@ private JsonSchemaFactory( String defaultMetaSchemaIri, SchemaLoaders.Builder schemaLoadersBuilder, SchemaMappers.Builder schemaMappersBuilder, - ConcurrentMap metaSchemas, + ConcurrentMap metaSchemas, boolean enableSchemaCache, JsonMetaSchemaFactory metaSchemaFactory) { this.metaSchemas = metaSchemas; @@ -266,7 +266,7 @@ public static JsonSchemaFactory getInstance(Specification.Version versionFlag) { public static JsonSchemaFactory getInstance(Specification.Version versionFlag, Consumer customizer) { JsonSchemaVersion jsonSchemaVersion = checkVersion(versionFlag); - JsonMetaSchema metaSchema = jsonSchemaVersion.getInstance(); + Dialect metaSchema = jsonSchemaVersion.getInstance(); JsonSchemaFactory.Builder builder = builder().defaultMetaSchemaIri(metaSchema.getIri()) .metaSchema(metaSchema); if (customizer != null) { @@ -384,7 +384,7 @@ private JsonSchema doCreate(ValidationContext validationContext, SchemaLocation * @return the validation context to use */ private ValidationContext withMetaSchema(ValidationContext validationContext, JsonNode schemaNode) { - JsonMetaSchema metaSchema = getMetaSchema(schemaNode, validationContext.getConfig()); + Dialect metaSchema = getMetaSchema(schemaNode, validationContext.getConfig()); if (metaSchema != null && !metaSchema.getIri().equals(validationContext.getMetaSchema().getIri())) { SchemaValidatorsConfig config = validationContext.getConfig(); if (metaSchema.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { @@ -415,7 +415,7 @@ protected SchemaLocation getSchemaLocation(SchemaLocation schemaLocation) { } protected ValidationContext createValidationContext(final JsonNode schemaNode, SchemaValidatorsConfig config) { - final JsonMetaSchema jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); + final Dialect jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); SchemaValidatorsConfig configResult = config; if (jsonMetaSchema.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { configResult = SchemaValidatorsConfig.builder(config) @@ -426,17 +426,17 @@ protected ValidationContext createValidationContext(final JsonNode schemaNode, S return new ValidationContext(jsonMetaSchema, this, configResult); } - private JsonMetaSchema getMetaSchema(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getMetaSchema(final JsonNode schemaNode, SchemaValidatorsConfig config) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && iriNode.isTextual()) { - JsonMetaSchema result = metaSchemas.computeIfAbsent(normalizeMetaSchemaUri(iriNode.textValue()), + Dialect result = metaSchemas.computeIfAbsent(normalizeMetaSchemaUri(iriNode.textValue()), id -> loadMetaSchema(id, config)); return result; } return null; } - private JsonMetaSchema getMetaSchemaOrDefault(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getMetaSchemaOrDefault(final JsonNode schemaNode, SchemaValidatorsConfig config) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && !iriNode.isNull() && !iriNode.isTextual()) { throw new JsonSchemaException("Unknown MetaSchema: " + iriNode); @@ -452,9 +452,9 @@ private JsonMetaSchema getMetaSchemaOrDefault(final JsonNode schemaNode, SchemaV * @param config the schema validators config * @return the meta-schema */ - public JsonMetaSchema getMetaSchema(String iri, SchemaValidatorsConfig config) { + public Dialect getMetaSchema(String iri, SchemaValidatorsConfig config) { String key = normalizeMetaSchemaUri(iri); - JsonMetaSchema result = metaSchemas.computeIfAbsent(key, id -> loadMetaSchema(id, config)); + Dialect result = metaSchemas.computeIfAbsent(key, id -> loadMetaSchema(id, config)); return result; } @@ -465,7 +465,7 @@ public JsonMetaSchema getMetaSchema(String iri, SchemaValidatorsConfig config) { * @param config the schema validators config * @return the meta-schema */ - protected JsonMetaSchema loadMetaSchema(String iri, SchemaValidatorsConfig config) { + protected Dialect loadMetaSchema(String iri, SchemaValidatorsConfig config) { return this.metaSchemaFactory != null ? this.metaSchemaFactory.getMetaSchema(iri, this, config) : DefaultJsonMetaSchemaFactory.getInstance().getMetaSchema(iri, this, config); } @@ -678,7 +678,7 @@ protected JsonSchema getMappedSchema(final SchemaLocation schemaUri, SchemaValid schemaNode = readTree(inputStream, InputFormat.JSON); } - final JsonMetaSchema jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); + final Dialect jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); JsonNodePath evaluationPath = new JsonNodePath(config.getPathType()); if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { diff --git a/src/main/java/com/networknt/schema/JsonSchemaVersion.java b/src/main/java/com/networknt/schema/JsonSchemaVersion.java index 47f9f6404..8ec99a806 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaVersion.java +++ b/src/main/java/com/networknt/schema/JsonSchemaVersion.java @@ -24,5 +24,5 @@ public interface JsonSchemaVersion { * * @return the instance */ - JsonMetaSchema getInstance(); + Dialect getInstance(); } diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index 8e84d7400..b999a8141 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -25,19 +25,19 @@ import com.networknt.schema.keyword.KeywordValidator; public class ValidationContext { - private final JsonMetaSchema metaSchema; + private final Dialect metaSchema; private final JsonSchemaFactory jsonSchemaFactory; private final SchemaValidatorsConfig config; private final ConcurrentMap schemaReferences; private final ConcurrentMap schemaResources; private final ConcurrentMap dynamicAnchors; - public ValidationContext(JsonMetaSchema metaSchema, + public ValidationContext(Dialect metaSchema, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config) { this(metaSchema, jsonSchemaFactory, config, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } - public ValidationContext(JsonMetaSchema metaSchema, JsonSchemaFactory jsonSchemaFactory, + public ValidationContext(Dialect metaSchema, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config, ConcurrentMap schemaReferences, ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { if (metaSchema == null) { @@ -103,7 +103,7 @@ public ConcurrentMap getDynamicAnchors() { return this.dynamicAnchors; } - public JsonMetaSchema getMetaSchema() { + public Dialect getMetaSchema() { return this.metaSchema; } diff --git a/src/main/java/com/networknt/schema/Version201909.java b/src/main/java/com/networknt/schema/Version201909.java index a9b87052b..68245bdee 100644 --- a/src/main/java/com/networknt/schema/Version201909.java +++ b/src/main/java/com/networknt/schema/Version201909.java @@ -27,9 +27,9 @@ public class Version201909 implements JsonSchemaVersion { } private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_2019_09) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -44,7 +44,7 @@ private static class Holder { } @Override - public JsonMetaSchema getInstance() { + public Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version202012.java b/src/main/java/com/networknt/schema/Version202012.java index 2e9f51bd4..2f45ee4ae 100644 --- a/src/main/java/com/networknt/schema/Version202012.java +++ b/src/main/java/com/networknt/schema/Version202012.java @@ -28,9 +28,9 @@ public class Version202012 implements JsonSchemaVersion { } private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_2020_12) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -45,7 +45,7 @@ private static class Holder { } @Override - public JsonMetaSchema getInstance() { + public Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version4.java b/src/main/java/com/networknt/schema/Version4.java index 05e405d7a..87776a7e7 100644 --- a/src/main/java/com/networknt/schema/Version4.java +++ b/src/main/java/com/networknt/schema/Version4.java @@ -14,9 +14,9 @@ public class Version4 implements JsonSchemaVersion { private static final String ID = "id"; private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_4) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -38,7 +38,7 @@ private static class Holder { } } - public JsonMetaSchema getInstance() { + public Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version6.java b/src/main/java/com/networknt/schema/Version6.java index a1718b192..50cdfe0e3 100644 --- a/src/main/java/com/networknt/schema/Version6.java +++ b/src/main/java/com/networknt/schema/Version6.java @@ -15,9 +15,9 @@ public class Version6 implements JsonSchemaVersion { private static final String ID = "$id"; private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_6) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -37,7 +37,7 @@ private static class Holder { } } - public JsonMetaSchema getInstance() { + public Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version7.java b/src/main/java/com/networknt/schema/Version7.java index ad6e72197..131a56726 100644 --- a/src/main/java/com/networknt/schema/Version7.java +++ b/src/main/java/com/networknt/schema/Version7.java @@ -14,9 +14,9 @@ public class Version7 implements JsonSchemaVersion { private static final String ID = "$id"; private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_7) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -39,7 +39,7 @@ private static class Holder { } @Override - public JsonMetaSchema getInstance() { + public Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/oas/OpenApi30.java b/src/main/java/com/networknt/schema/oas/OpenApi30.java index 5b8af119d..3fd9424a6 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi30.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi30.java @@ -3,7 +3,7 @@ import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.JsonMetaSchema; +import com.networknt.schema.Dialect; import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; @@ -18,9 +18,9 @@ public class OpenApi30 { private static final String ID = "id"; private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_4) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -67,7 +67,7 @@ private static class Holder { } } - public static JsonMetaSchema getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/oas/OpenApi31.java b/src/main/java/com/networknt/schema/oas/OpenApi31.java index ff9e770f7..87fbe2db0 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi31.java +++ b/src/main/java/com/networknt/schema/oas/OpenApi31.java @@ -5,7 +5,7 @@ import java.util.Map; import com.networknt.schema.Formats; -import com.networknt.schema.JsonMetaSchema; +import com.networknt.schema.Dialect; import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; @@ -33,9 +33,9 @@ public class OpenApi31 { } private static class Holder { - private static final JsonMetaSchema INSTANCE; + private static final Dialect INSTANCE; static { - INSTANCE = JsonMetaSchema.builder(IRI) + INSTANCE = Dialect.builder(IRI) .specification(Specification.Version.DRAFT_2020_12) .idKeyword(ID) .formats(Formats.DEFAULT) @@ -49,7 +49,7 @@ private static class Holder { } } - public static JsonMetaSchema getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 49b55b074..61565d271 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -121,8 +121,8 @@ void testCollectorGetAll() throws IOException { Assertions.assertEquals(((List) collectorContext.get(SAMPLE_COLLECTOR_OTHER)).size(), 3); } - private JsonMetaSchema getJsonMetaSchema(String uri) throws Exception { - JsonMetaSchema jsonMetaSchema = JsonMetaSchema.builder(uri, JsonMetaSchema.getV201909()) + private Dialect getJsonMetaSchema(String uri) throws Exception { + Dialect jsonMetaSchema = Dialect.builder(uri, Dialect.getV201909()) .keyword(new CustomKeyword()).keyword(new CustomKeyword1()).format(new Format() { @SuppressWarnings("unchecked") @@ -152,7 +152,7 @@ public String getErrorMessageDescription() { } private void setupSchema() throws Exception { - final JsonMetaSchema metaSchema = getJsonMetaSchema( + final Dialect metaSchema = getJsonMetaSchema( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); final JsonSchemaFactory schemaFactory = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(metaSchema) @@ -455,7 +455,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root @Test void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); + Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" @@ -503,7 +503,7 @@ public void run() { @Test void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); + Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" @@ -521,7 +521,7 @@ void iterate() { @Test void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); + Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" @@ -539,7 +539,7 @@ void iterateWalk() { @Test void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).keyword(new CollectKeyword()).build(); + Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 34e2a822e..98ceb7fe2 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -116,8 +116,8 @@ private List readStringList(JsonNode node) { @Test void customMetaSchemaWithIgnoredKeyword() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - final JsonMetaSchema metaSchema = JsonMetaSchema - .builder("https://github.com/networknt/json-schema-validator/tests/schemas/example01", JsonMetaSchema.getV4()) + final Dialect metaSchema = Dialect + .builder("https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialect.getV4()) // Generated UI uses enumNames to render Labels for enum values .keyword(new EnumNamesKeyword()) .build(); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index 4c02eeb93..c02a2a83f 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -31,7 +31,7 @@ void shouldThrowForUnknownKeywords() { @Test void getSchemaShouldThrowForUnknownKeywords() { - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()) + Dialect metaSchema = Dialect.builder(Dialect.getV202012()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 3f327ef2c..c5ab9113c 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -41,7 +41,7 @@ void draftV4ShouldHaveExclusiveMinimum() { " }" + " }" + "}"; - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV4()) + Dialect metaSchema = Dialect.builder(Dialect.getV4()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder.metaSchema(metaSchema)); @@ -69,7 +69,7 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { " }" + " }" + "}"; - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV6()) + Dialect metaSchema = Dialect.builder(Dialect.getV6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder.metaSchema(metaSchema)); @@ -88,7 +88,7 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { " }" + " }" + "}"; - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV7()) + Dialect metaSchema = Dialect.builder(Dialect.getV7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(metaSchema)); diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index 5f14efcf5..d50690fe2 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -41,7 +41,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath @Test void shouldUseFormatKeyword() { - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()) + Dialect metaSchema = Dialect.builder(Dialect.getV202012()) .formatKeywordFactory(CustomFormatKeyword::new).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index f76b46a85..ce6368832 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -157,8 +157,8 @@ void formatAssertions(FormatInput formatInput) { @SuppressWarnings("deprecation") @Test void patternFormatDeprecated() { - JsonMetaSchema customMetaSchema = JsonMetaSchema - .builder("https://www.example.com/schema", JsonMetaSchema.getV7()) + Dialect customMetaSchema = Dialect + .builder("https://www.example.com/schema", Dialect.getV7()) .formats(formats -> { PatternFormat format = new PatternFormat("custom", "test", "must be test"); formats.put(format.getName(), format); @@ -206,8 +206,8 @@ public String getName() { @Test void shouldAllowNumberFormat() { - JsonMetaSchema customMetaSchema = JsonMetaSchema - .builder("https://www.example.com/schema", JsonMetaSchema.getV7()) + Dialect customMetaSchema = Dialect + .builder("https://www.example.com/schema", Dialect.getV7()) .formats(formats -> { CustomNumberFormat format = new CustomNumberFormat(new BigDecimal("12345")); formats.put(format.getName(), format); diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 41b2c51f8..3c948b92d 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -8,9 +8,9 @@ class Issue314Test { private static final JsonSchemaFactory FACTORY = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .metaSchema( - JsonMetaSchema.builder( + Dialect.builder( "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", - JsonMetaSchema.getV7()) + Dialect.getV7()) .build()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 8d631fc87..817c7bf36 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -6,9 +6,9 @@ import java.io.InputStream; class Issue518Test { - private static final JsonMetaSchema igluMetaSchema = - JsonMetaSchema - .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", JsonMetaSchema.getV7()) + private static final Dialect igluMetaSchema = + Dialect + .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialect.getV7()) .build(); private static final JsonSchemaFactory FACTORY = diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 71b8e1852..042b14dfd 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -61,8 +61,8 @@ private List validate(JsonSchema jsonSchema, String myDateTimeContent) th } private JsonSchema createSchema(boolean useCustomDateFormat) { - JsonMetaSchema overrideDateTimeValidator =JsonMetaSchema - .builder(JsonMetaSchema.getV7().getIri(), JsonMetaSchema.getV7()) + Dialect overrideDateTimeValidator =Dialect + .builder(Dialect.getV7().getIri(), Dialect.getV7()) .formats(formats -> { if (useCustomDateFormat) { CustomDateTimeFormat format = new CustomDateTimeFormat(); diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 3262c4be5..5fc6507fc 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -18,7 +18,7 @@ void validate() throws JsonProcessingException { .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() - .getSchema(SchemaLocation.of(JsonMetaSchema.getV201909().getIri())); + .getSchema(SchemaLocation.of(Dialect.getV201909().getIri())); final JsonNode invalidSchema = new ObjectMapper().readTree( "{"+ " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\","+ diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 4d6afea33..1bd2ea33b 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -33,9 +33,9 @@ private JsonSchemaFactory buildV7PlusNoFormatSchemaFactory() { formats = new ArrayList<>(); formats.add(new NoMatchFormat()); - JsonMetaSchema jsonMetaSchema = JsonMetaSchema.builder( - JsonMetaSchema.getV7().getIri(), - JsonMetaSchema.getV7()) + Dialect jsonMetaSchema = Dialect.builder( + Dialect.getV7().getIri(), + Dialect.getV7()) .formats(formats) .build(); return new JsonSchemaFactory.Builder().defaultMetaSchemaIri(jsonMetaSchema.getIri()).metaSchema(jsonMetaSchema).build(); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index a17371e65..ada8902a9 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -41,7 +41,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012()).vocabularies(vocabularies -> { + Dialect metaSchema = Dialect.builder(Dialect.getV202012()).vocabularies(vocabularies -> { vocabularies.remove(Vocabulary.V202012_VALIDATION.getIri()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java index a3fab9fe3..6a99474aa 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java @@ -50,7 +50,7 @@ void concurrency() { .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); - JsonMetaSchema[] instance = new JsonMetaSchema[1]; + Dialect[] instance = new Dialect[1]; CountDownLatch latch = new CountDownLatch(1); List threads = new ArrayList<>(); for (int i = 0; i < 50; ++i) { @@ -62,7 +62,7 @@ public void run() { } catch (InterruptedException e) { throw new RuntimeException(e); } - JsonMetaSchema metaSchema = factory.getMetaSchema("https://www.example.com/no-validation-no-format/schema", config); + Dialect metaSchema = factory.getMetaSchema("https://www.example.com/no-validation-no-format/schema", config); synchronized(instance) { if (instance[0] == null) { instance[0] = metaSchema; diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index ce21c4bf1..f5ed46614 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -47,7 +47,7 @@ private JsonSchemaFactory buildJsonSchemaFactory(CustomURIFetcher uriFetcher, bo return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) - .metaSchema(JsonMetaSchema.getV202012()) + .metaSchema(Dialect.getV202012()) .build(); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index db204563a..12c8abaec 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -38,7 +38,7 @@ void setup() { } private void setupSchema() { - final JsonMetaSchema metaSchema = getJsonMetaSchema(); + final Dialect metaSchema = getJsonMetaSchema(); // Create Schema. SchemaValidatorsConfig.Builder schemaValidatorsConfigBuilder = SchemaValidatorsConfig.builder(); schemaValidatorsConfigBuilder.keywordWalkListener(new AllKeywordListener()); @@ -57,9 +57,9 @@ private void setupSchema() { this.jsonSchema1 = schemaFactory.getSchema(getSchema(), schemaValidatorsConfig1Builder.build()); } - private JsonMetaSchema getJsonMetaSchema() { - return JsonMetaSchema.builder( - "https://github.com/networknt/json-schema-validator/tests/schemas/example01", JsonMetaSchema.getV201909()) + private Dialect getJsonMetaSchema() { + return Dialect.builder( + "https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialect.getV201909()) .keyword(new CustomKeyword()).build(); } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index d547d5983..3a5c2e076 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -69,7 +69,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath @Test void message() { - JsonMetaSchema metaSchema = JsonMetaSchema.builder(JsonMetaSchema.getV202012().getIri(), JsonMetaSchema.getV202012()) + Dialect metaSchema = Dialect.builder(Dialect.getV202012().getIri(), Dialect.getV202012()) .keyword(new EqualsKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 851c23eea..188132f36 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -49,8 +49,8 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { " \"timestamp\": \"bad\"\n" + "}"); // Use Default EmailValidator - final JsonMetaSchema validatorMetaSchema = JsonMetaSchema - .builder(URI, JsonMetaSchema.getV201909()) + final Dialect validatorMetaSchema = Dialect + .builder(URI, Dialect.getV201909()) .build(); final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); @@ -65,8 +65,8 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { assertTrue(messages.stream().anyMatch(it -> it.getInstanceLocation().getName(-1).equals("timestamp"))); // Override EmailValidator - final JsonMetaSchema overrideValidatorMetaSchema = JsonMetaSchema - .builder(URI, JsonMetaSchema.getV201909()) + final Dialect overrideValidatorMetaSchema = Dialect + .builder(URI, Dialect.getV201909()) .format(PatternFormat.of("email", "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "format.email")) .build(); diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index a26c36f2a..bfb146112 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -47,7 +47,7 @@ class UriMappingTest { @Test void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - JsonMetaSchema draftV4 = JsonMetaSchema.getV4(); + Dialect draftV4 = Dialect.getV4(); Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) @@ -98,7 +98,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { fail("Unexpected exception thrown", ex); } URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - JsonMetaSchema draftV4 = JsonMetaSchema.getV4(); + Dialect draftV4 = Dialect.getV4(); Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index dbf29283e..4e2613d65 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -25,7 +25,7 @@ void testURNToURI() throws Exception { InputStream is = null; try { is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); - JsonMetaSchema draftV7 = JsonMetaSchema.getV7(); + Dialect draftV7 = Dialect.getV7(); JsonSchemaFactory.Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV7.getIri()) .metaSchema(draftV7) diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 2f5b5f50d..d87c5031c 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -201,8 +201,8 @@ void customVocabulary() { return null; }; - JsonMetaSchema metaSchema = JsonMetaSchema - .builder(JsonMetaSchema.getV202012().getIri(), JsonMetaSchema.getV202012()) + Dialect metaSchema = Dialect + .builder(Dialect.getV202012().getIri(), Dialect.getV202012()) .vocabularyFactory(vocabularyFactory) .build(); JsonSchemaFactory factory = JsonSchemaFactory From a053b8022aebe17a7352e5c7c94d5e11fa00d90c Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:35:40 +0800 Subject: [PATCH 12/74] Refactor dialect and add dialects --- .../schema/DefaultJsonMetaSchemaFactory.java | 2 +- .../DisallowUnknownJsonMetaSchemaFactory.java | 2 + .../schema/JsonMetaSchemaFactory.java | 2 + .../networknt/schema/JsonSchemaFactory.java | 38 +++++---- .../networknt/schema/JsonSchemaVersion.java | 2 + .../com/networknt/schema/Specification.java | 2 + .../networknt/schema/ValidationContext.java | 21 ++--- .../schema/{ => dialect}/Dialect.java | 60 +++---------- .../schema/{ => dialect}/DialectId.java | 2 +- .../networknt/schema/dialect/Dialects.java | 85 +++++++++++++++++++ .../Draft201909.java} | 9 +- .../Draft202012.java} | 9 +- .../{Version4.java => dialect/Draft4.java} | 8 +- .../{Version6.java => dialect/Draft6.java} | 8 +- .../{Version7.java => dialect/Draft7.java} | 9 +- .../schema/{oas => dialect}/OpenApi30.java | 4 +- .../schema/{oas => dialect}/OpenApi31.java | 4 +- .../schema/CollectorContextTest.java | 24 +++--- .../schema/CustomMetaSchemaTest.java | 8 +- .../DisallowUnknownKeywordFactoryTest.java | 6 +- .../com/networknt/schema/ExampleTest.java | 1 + .../schema/ExclusiveMinimumValidatorTest.java | 14 +-- .../schema/FormatKeywordFactoryTest.java | 6 +- .../networknt/schema/FormatValidatorTest.java | 6 +- .../com/networknt/schema/Issue314Test.java | 5 +- .../com/networknt/schema/Issue475Test.java | 1 + .../com/networknt/schema/Issue518Test.java | 5 +- .../com/networknt/schema/Issue784Test.java | 6 +- .../com/networknt/schema/Issue824Test.java | 3 +- .../com/networknt/schema/Issue832Test.java | 7 +- .../com/networknt/schema/Issue994Test.java | 6 +- .../schema/JsonSchemaFactoryTest.java | 7 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 3 +- .../com/networknt/schema/JsonWalkTest.java | 8 +- .../com/networknt/schema/MessageTest.java | 6 +- .../schema/OverrideValidatorTest.java | 6 +- .../java/com/networknt/schema/RefTest.java | 1 + .../schema/UnknownMetaSchemaTest.java | 2 + .../com/networknt/schema/UriMappingTest.java | 6 +- .../java/com/networknt/schema/UrnTest.java | 5 +- .../com/networknt/schema/VocabularyTest.java | 8 +- .../networknt/schema/oas/OpenApi30Test.java | 1 + .../networknt/schema/oas/OpenApi31Test.java | 1 + .../schema/resource/MetaSchemaMapperTest.java | 2 +- .../walk/JsonSchemaWalkListenerTest.java | 2 +- 45 files changed, 268 insertions(+), 155 deletions(-) rename src/main/java/com/networknt/schema/{ => dialect}/Dialect.java (90%) rename src/main/java/com/networknt/schema/{ => dialect}/DialectId.java (94%) create mode 100644 src/main/java/com/networknt/schema/dialect/Dialects.java rename src/main/java/com/networknt/schema/{Version201909.java => dialect/Draft201909.java} (90%) rename src/main/java/com/networknt/schema/{Version202012.java => dialect/Draft202012.java} (90%) rename src/main/java/com/networknt/schema/{Version4.java => dialect/Draft4.java} (90%) rename src/main/java/com/networknt/schema/{Version6.java => dialect/Draft6.java} (89%) rename src/main/java/com/networknt/schema/{Version7.java => dialect/Draft7.java} (90%) rename src/main/java/com/networknt/schema/{oas => dialect}/OpenApi30.java (94%) rename src/main/java/com/networknt/schema/{oas => dialect}/OpenApi31.java (92%) diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java index 6bf9daa20..6f123ba55 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; /** * Default {@link JsonMetaSchemaFactory}. @@ -30,7 +31,6 @@ public Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, Schema // Is it a well-known dialect? return Specification.Version.fromDialectId(iri) .map(JsonSchemaFactory::checkVersion) - .map(JsonSchemaVersion::getInstance) .orElseGet(() -> { // Custom meta schema return loadMetaSchema(iri, schemaFactory, config); diff --git a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java index b3faed52a..ff4a75170 100644 --- a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java @@ -15,6 +15,8 @@ */ package com.networknt.schema; +import com.networknt.schema.dialect.Dialect; + /** * A {@link JsonMetaSchemaFactory} that does not meta-schemas that aren't * explicitly configured in the {@link JsonSchemaFactory}. diff --git a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java index 87d5cb768..d8f664b90 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java @@ -15,6 +15,8 @@ */ package com.networknt.schema; +import com.networknt.schema.dialect.Dialect; + /** * Factory for {@link Dialect}. */ diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index d24b213c3..51dca955d 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -19,6 +19,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.DialectId; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.DefaultSchemaLoader; import com.networknt.schema.resource.SchemaLoader; import com.networknt.schema.resource.SchemaLoaders; @@ -265,10 +268,9 @@ public static JsonSchemaFactory getInstance(Specification.Version versionFlag) { */ public static JsonSchemaFactory getInstance(Specification.Version versionFlag, Consumer customizer) { - JsonSchemaVersion jsonSchemaVersion = checkVersion(versionFlag); - Dialect metaSchema = jsonSchemaVersion.getInstance(); - JsonSchemaFactory.Builder builder = builder().defaultMetaSchemaIri(metaSchema.getIri()) - .metaSchema(metaSchema); + Dialect dialect = checkVersion(versionFlag); + JsonSchemaFactory.Builder builder = builder().defaultMetaSchemaIri(dialect.getIri()) + .metaSchema(dialect); if (customizer != null) { customizer.accept(builder); } @@ -280,18 +282,18 @@ public static JsonSchemaFactory getInstance(Specification.Version versionFlag, *

* This throws an {@link IllegalArgumentException} for an unsupported value. * - * @param versionFlag the schema dialect + * @param version the schema specification version * @return the version */ - public static JsonSchemaVersion checkVersion(Specification.Version versionFlag){ - if (null == versionFlag) return null; - switch (versionFlag) { - case DRAFT_2020_12: return new Version202012(); - case DRAFT_2019_09: return new Version201909(); - case DRAFT_7: return new Version7(); - case DRAFT_6: return new Version6(); - case DRAFT_4: return new Version4(); - default: throw new IllegalArgumentException("Unsupported value" + versionFlag); + public static Dialect checkVersion(Specification.Version version){ + if (null == version) return null; + switch (version) { + case DRAFT_2020_12: return Dialects.getDraft202012(); + case DRAFT_2019_09: return Dialects.getDraft201909(); + case DRAFT_7: return Dialects.getDraft7(); + case DRAFT_6: return Dialects.getDraft6(); + case DRAFT_4: return Dialects.getDraft4(); + default: throw new IllegalArgumentException("Unsupported value" + version); } } @@ -384,16 +386,16 @@ private JsonSchema doCreate(ValidationContext validationContext, SchemaLocation * @return the validation context to use */ private ValidationContext withMetaSchema(ValidationContext validationContext, JsonNode schemaNode) { - Dialect metaSchema = getMetaSchema(schemaNode, validationContext.getConfig()); - if (metaSchema != null && !metaSchema.getIri().equals(validationContext.getMetaSchema().getIri())) { + Dialect dialect = getMetaSchema(schemaNode, validationContext.getConfig()); + if (dialect != null && !dialect.getIri().equals(validationContext.getMetaSchema().getIri())) { SchemaValidatorsConfig config = validationContext.getConfig(); - if (metaSchema.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { + if (dialect.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { config = SchemaValidatorsConfig.builder(config) .discriminatorKeywordEnabled(true) .nullableKeywordEnabled(true) .build(); } - return new ValidationContext(metaSchema, validationContext.getJsonSchemaFactory(), config, + return new ValidationContext(dialect, validationContext.getJsonSchemaFactory(), config, validationContext.getSchemaReferences(), validationContext.getSchemaResources(), validationContext.getDynamicAnchors()); } diff --git a/src/main/java/com/networknt/schema/JsonSchemaVersion.java b/src/main/java/com/networknt/schema/JsonSchemaVersion.java index 8ec99a806..df3809820 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaVersion.java +++ b/src/main/java/com/networknt/schema/JsonSchemaVersion.java @@ -15,6 +15,8 @@ */ package com.networknt.schema; +import com.networknt.schema.dialect.Dialect; + /** * Json schema version. */ diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java index 84a0a0c67..be5e8c82b 100644 --- a/src/main/java/com/networknt/schema/Specification.java +++ b/src/main/java/com/networknt/schema/Specification.java @@ -17,6 +17,8 @@ import java.util.Optional; +import com.networknt.schema.dialect.DialectId; + /** * The JSON Schema specification which defines the standard dialects. */ diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index b999a8141..c0a874f77 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -22,31 +22,32 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; import com.networknt.schema.keyword.KeywordValidator; public class ValidationContext { - private final Dialect metaSchema; + private final Dialect dialect; private final JsonSchemaFactory jsonSchemaFactory; private final SchemaValidatorsConfig config; private final ConcurrentMap schemaReferences; private final ConcurrentMap schemaResources; private final ConcurrentMap dynamicAnchors; - public ValidationContext(Dialect metaSchema, + public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config) { - this(metaSchema, jsonSchemaFactory, config, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + this(dialect, jsonSchemaFactory, config, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } - public ValidationContext(Dialect metaSchema, JsonSchemaFactory jsonSchemaFactory, + public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config, ConcurrentMap schemaReferences, ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { - if (metaSchema == null) { + if (dialect == null) { throw new IllegalArgumentException("JsonMetaSchema must not be null"); } if (jsonSchemaFactory == null) { throw new IllegalArgumentException("JsonSchemaFactory must not be null"); } - this.metaSchema = metaSchema; + this.dialect = dialect; this.jsonSchemaFactory = jsonSchemaFactory; // The deprecated SchemaValidatorsConfig constructor needs to remain until removed this.config = config == null ? new SchemaValidatorsConfig() : config; @@ -61,11 +62,11 @@ public JsonSchema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluati public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword /* keyword */, JsonNode schemaNode, JsonSchema parentSchema) { - return this.metaSchema.newValidator(this, schemaLocation, evaluationPath, keyword, schemaNode, parentSchema); + return this.dialect.newValidator(this, schemaLocation, evaluationPath, keyword, schemaNode, parentSchema); } public String resolveSchemaId(JsonNode schemaNode) { - return this.metaSchema.readId(schemaNode); + return this.dialect.readId(schemaNode); } public JsonSchemaFactory getJsonSchemaFactory() { @@ -104,10 +105,10 @@ public ConcurrentMap getDynamicAnchors() { } public Dialect getMetaSchema() { - return this.metaSchema; + return this.dialect; } public Optional activeDialect() { - return Optional.of(this.metaSchema.getSpecification()); + return Optional.of(this.dialect.getSpecification()); } } diff --git a/src/main/java/com/networknt/schema/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java similarity index 90% rename from src/main/java/com/networknt/schema/Dialect.java rename to src/main/java/com/networknt/schema/dialect/Dialect.java index 38e3077ed..0e6683490 100644 --- a/src/main/java/com/networknt/schema/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -14,9 +14,21 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.dialect; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.Format; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.Specification; +import com.networknt.schema.ValidationContext; +import com.networknt.schema.Vocabularies; +import com.networknt.schema.Vocabulary; +import com.networknt.schema.VocabularyFactory; import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.Keyword; @@ -303,26 +315,6 @@ public Dialect build() { Map result = createKeywordsMap(keywords, this.formats); return new Dialect(this.iri, this.idKeyword, result, this.vocabularies, this.specification, this); } - - @Deprecated - public Builder addKeyword(Keyword keyword) { - return keyword(keyword); - } - - @Deprecated - public Builder addKeywords(Collection keywords) { - return keywords(keywords); - } - - @Deprecated - public Builder addFormat(Format format) { - return format(format); - } - - @Deprecated - public Builder addFormats(Collection formats) { - return formats(formats); - } } private final String iri; @@ -352,34 +344,8 @@ public Builder addFormats(Collection formats) { this.builder = builder; } - public static Dialect getV4() { - return new Version4().getInstance(); - } - - public static Dialect getV6() { - return new Version6().getInstance(); - } - - public static Dialect getV7() { - return new Version7().getInstance(); - } - - public static Dialect getV201909() { - return new Version201909().getInstance(); - } - - public static Dialect getV202012() { - return new Version202012().getInstance(); - } - /** * Create a builder without keywords or formats. - *

- * Use {@link #getV4()} for the Draft 4 Metaschema, or if you need a builder based on Draft4, use - * - * - * JsonMetaSchema.builder("http://your-metaschema-iri", JsonMetaSchema.getV4()).build(); - * * * @param iri the IRI of the metaschema that will be defined via this builder. * @return a builder instance without any keywords or formats - usually not what one needs. diff --git a/src/main/java/com/networknt/schema/DialectId.java b/src/main/java/com/networknt/schema/dialect/DialectId.java similarity index 94% rename from src/main/java/com/networknt/schema/DialectId.java rename to src/main/java/com/networknt/schema/dialect/DialectId.java index 74af1b209..d5e910c6e 100644 --- a/src/main/java/com/networknt/schema/DialectId.java +++ b/src/main/java/com/networknt/schema/dialect/DialectId.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.dialect; /** * The dialect id is an IRI that points to the meta-schema that can be used to diff --git a/src/main/java/com/networknt/schema/dialect/Dialects.java b/src/main/java/com/networknt/schema/dialect/Dialects.java new file mode 100644 index 000000000..9095565e7 --- /dev/null +++ b/src/main/java/com/networknt/schema/dialect/Dialects.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.dialect; + +/** + * The dialects. + */ +public class Dialects { + /** + * Draft 4. + * + * @return the Draft 4 dialect + */ + public static Dialect getDraft4() { + return Draft4.getInstance(); + } + + /** + * Draft 6. + * + * @return the Draft 6 dialect + */ + public static Dialect getDraft6() { + return Draft6.getInstance(); + } + + /** + * Draft 7. + * + * @return the Draft 7 dialect + */ + public static Dialect getDraft7() { + return Draft7.getInstance(); + } + + /** + * Draft 2019-09. + * + * @return the Draft 2019-09 dialect + */ + public static Dialect getDraft201909() { + return Draft201909.getInstance(); + } + + /** + * Draft 2020-12. + * + * @return the Draft 2020-12 dialect + */ + public static Dialect getDraft202012() { + return Draft202012.getInstance(); + } + + /** + * OpenAPI 3.0. + * + * @return the OpenAPI 3.0 dialect + */ + public static Dialect getOpenApi30() { + return OpenApi30.getInstance(); + } + + /** + * OpenAPI 3.1. + * + * @return the OpenAPI 3.1 dialect + */ + public static Dialect getOpenApi31() { + return OpenApi31.getInstance(); + } +} diff --git a/src/main/java/com/networknt/schema/Version201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java similarity index 90% rename from src/main/java/com/networknt/schema/Version201909.java rename to src/main/java/com/networknt/schema/dialect/Draft201909.java index 68245bdee..53370e146 100644 --- a/src/main/java/com/networknt/schema/Version201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -1,16 +1,18 @@ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import com.networknt.schema.Formats; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; /** * Draft 2019-09 dialect. */ -public class Version201909 implements JsonSchemaVersion { +public class Draft201909 { private static final String IRI = DialectId.DRAFT_2019_09; private static final String ID = "$id"; private static final Map VOCABULARY; @@ -43,8 +45,7 @@ private static class Holder { } } - @Override - public Dialect getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java similarity index 90% rename from src/main/java/com/networknt/schema/Version202012.java rename to src/main/java/com/networknt/schema/dialect/Draft202012.java index 2f45ee4ae..c79e421d5 100644 --- a/src/main/java/com/networknt/schema/Version202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -1,16 +1,18 @@ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import com.networknt.schema.Formats; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; /** * Draft 2020-12 dialect. */ -public class Version202012 implements JsonSchemaVersion { +public class Draft202012 { private static final String IRI = DialectId.DRAFT_2020_12; private static final String ID = "$id"; private static final Map VOCABULARY; @@ -44,8 +46,7 @@ private static class Holder { } } - @Override - public Dialect getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java similarity index 90% rename from src/main/java/com/networknt/schema/Version4.java rename to src/main/java/com/networknt/schema/dialect/Draft4.java index 87776a7e7..12fa1b6e9 100644 --- a/src/main/java/com/networknt/schema/Version4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -1,7 +1,9 @@ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Arrays; +import com.networknt.schema.Formats; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -9,7 +11,7 @@ /** * Draft 4 dialect. */ -public class Version4 implements JsonSchemaVersion { +public class Draft4 { private static final String IRI = DialectId.DRAFT_4; private static final String ID = "id"; @@ -38,7 +40,7 @@ private static class Holder { } } - public Dialect getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java similarity index 89% rename from src/main/java/com/networknt/schema/Version6.java rename to src/main/java/com/networknt/schema/dialect/Draft6.java index 50cdfe0e3..3964cf362 100644 --- a/src/main/java/com/networknt/schema/Version6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -1,7 +1,9 @@ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Arrays; +import com.networknt.schema.Formats; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -9,7 +11,7 @@ /** * Draft 6 dialect. */ -public class Version6 implements JsonSchemaVersion { +public class Draft6 { private static final String IRI = DialectId.DRAFT_6; // Draft 6 uses "$id" private static final String ID = "$id"; @@ -37,7 +39,7 @@ private static class Holder { } } - public Dialect getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/Version7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java similarity index 90% rename from src/main/java/com/networknt/schema/Version7.java rename to src/main/java/com/networknt/schema/dialect/Draft7.java index 131a56726..2936be4b0 100644 --- a/src/main/java/com/networknt/schema/Version7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -1,7 +1,9 @@ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Arrays; +import com.networknt.schema.Formats; +import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -9,7 +11,7 @@ /** * Draft 7 dialect. */ -public class Version7 implements JsonSchemaVersion { +public class Draft7 { private static final String IRI = DialectId.DRAFT_7; private static final String ID = "$id"; @@ -38,8 +40,7 @@ private static class Holder { } } - @Override - public Dialect getInstance() { + public static Dialect getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/oas/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java similarity index 94% rename from src/main/java/com/networknt/schema/oas/OpenApi30.java rename to src/main/java/com/networknt/schema/dialect/OpenApi30.java index 3fd9424a6..13677893d 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -1,10 +1,8 @@ -package com.networknt.schema.oas; +package com.networknt.schema.dialect; import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.Dialect; -import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; diff --git a/src/main/java/com/networknt/schema/oas/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java similarity index 92% rename from src/main/java/com/networknt/schema/oas/OpenApi31.java rename to src/main/java/com/networknt/schema/dialect/OpenApi31.java index 87fbe2db0..652513c7d 100644 --- a/src/main/java/com/networknt/schema/oas/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -1,12 +1,10 @@ -package com.networknt.schema.oas; +package com.networknt.schema.dialect; import java.util.Collections; import java.util.HashMap; import java.util.Map; import com.networknt.schema.Formats; -import com.networknt.schema.Dialect; -import com.networknt.schema.DialectId; import com.networknt.schema.Specification; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 61565d271..29c68e932 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -122,7 +124,7 @@ void testCollectorGetAll() throws IOException { } private Dialect getJsonMetaSchema(String uri) throws Exception { - Dialect jsonMetaSchema = Dialect.builder(uri, Dialect.getV201909()) + Dialect jsonMetaSchema = Dialect.builder(uri, Dialects.getDraft201909()) .keyword(new CustomKeyword()).keyword(new CustomKeyword1()).format(new Format() { @SuppressWarnings("unchecked") @@ -152,10 +154,10 @@ public String getErrorMessageDescription() { } private void setupSchema() throws Exception { - final Dialect metaSchema = getJsonMetaSchema( + final Dialect dialect = getJsonMetaSchema( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(metaSchema) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) .build(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().build(); this.jsonSchema = schemaFactory.getSchema(getSchemaString(), schemaValidatorsConfig); @@ -455,8 +457,8 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root @Test void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -503,8 +505,8 @@ public void run() { @Test void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -521,8 +523,8 @@ void iterate() { @Test void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -539,8 +541,8 @@ void iterateWalk() { @Test void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); - Dialect metaSchema = Dialect.builder(Dialect.getV202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); JsonSchema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 98ceb7fe2..7895fb144 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AbstractKeyword; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.KeywordValidator; @@ -116,13 +118,13 @@ private List readStringList(JsonNode node) { @Test void customMetaSchemaWithIgnoredKeyword() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - final Dialect metaSchema = Dialect - .builder("https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialect.getV4()) + final Dialect dialect = Dialect + .builder("https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialects.getDraft4()) // Generated UI uses enumNames to render Labels for enum values .keyword(new EnumNamesKeyword()) .build(); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).metaSchema(metaSchema).build(); + final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).metaSchema(dialect).build(); final JsonSchema schema = validatorFactory.getSchema("{\n" + " \"$schema\":\n" + " \"https://github.com/networknt/json-schema-validator/tests/schemas/example01\",\n" + diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index c02a2a83f..c8fcb65e6 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -20,6 +20,8 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; class DisallowUnknownKeywordFactoryTest { @@ -31,10 +33,10 @@ void shouldThrowForUnknownKeywords() { @Test void getSchemaShouldThrowForUnknownKeywords() { - Dialect metaSchema = Dialect.builder(Dialect.getV202012()) + Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(metaSchema)); + builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"equals\": \"world\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 39d4f3631..0469b7a8e 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DialectId; class ExampleTest { @Test diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index c5ab9113c..87436f981 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -23,6 +23,8 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; /** @@ -41,10 +43,10 @@ void draftV4ShouldHaveExclusiveMinimum() { " }" + " }" + "}"; - Dialect metaSchema = Dialect.builder(Dialect.getV4()) + Dialect dialect = Dialect.builder(Dialects.getDraft4()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4, - builder -> builder.metaSchema(metaSchema)); + builder -> builder.metaSchema(dialect)); JsonSchema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":0}"; String validData = "{\"value1\":0.1}"; @@ -69,10 +71,10 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { " }" + " }" + "}"; - Dialect metaSchema = Dialect.builder(Dialect.getV6()) + Dialect dialect = Dialect.builder(Dialects.getDraft6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_6, - builder -> builder.metaSchema(metaSchema)); + builder -> builder.metaSchema(dialect)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } @@ -88,10 +90,10 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { " }" + " }" + "}"; - Dialect metaSchema = Dialect.builder(Dialect.getV7()) + Dialect dialect = Dialect.builder(Dialects.getDraft7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, - builder -> builder.metaSchema(metaSchema)); + builder -> builder.metaSchema(dialect)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index d50690fe2..dbb1a3479 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.KeywordValidator; @@ -41,10 +43,10 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath @Test void shouldUseFormatKeyword() { - Dialect metaSchema = Dialect.builder(Dialect.getV202012()) + Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .formatKeywordFactory(CustomFormatKeyword::new).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(metaSchema)); + builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"format\": \"hello\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index ce6368832..f080ef136 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -29,6 +29,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.format.PatternFormat; import com.networknt.schema.output.OutputUnit; @@ -158,7 +160,7 @@ void formatAssertions(FormatInput formatInput) { @Test void patternFormatDeprecated() { Dialect customMetaSchema = Dialect - .builder("https://www.example.com/schema", Dialect.getV7()) + .builder("https://www.example.com/schema", Dialects.getDraft7()) .formats(formats -> { PatternFormat format = new PatternFormat("custom", "test", "must be test"); formats.put(format.getName(), format); @@ -207,7 +209,7 @@ public String getName() { @Test void shouldAllowNumberFormat() { Dialect customMetaSchema = Dialect - .builder("https://www.example.com/schema", Dialect.getV7()) + .builder("https://www.example.com/schema", Dialects.getDraft7()) .formats(formats -> { CustomNumberFormat format = new CustomNumberFormat(new BigDecimal("12345")); formats.put(format.getName(), format); diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 3c948b92d..7701661c9 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -4,13 +4,16 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; + class Issue314Test { private static final JsonSchemaFactory FACTORY = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) .metaSchema( Dialect.builder( "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", - Dialect.getV7()) + Dialects.getDraft7()) .build()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index ca79bccd6..6f3a833b5 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DialectId; import com.networknt.schema.serialization.JsonMapperFactory; /** diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 817c7bf36..24cecf4fd 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -3,12 +3,15 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; + import java.io.InputStream; class Issue518Test { private static final Dialect igluMetaSchema = Dialect - .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialect.getV7()) + .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialects.getDraft7()) .build(); private static final JsonSchemaFactory FACTORY = diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 042b14dfd..33f257009 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import org.junit.jupiter.api.Test; @@ -61,8 +63,8 @@ private List validate(JsonSchema jsonSchema, String myDateTimeContent) th } private JsonSchema createSchema(boolean useCustomDateFormat) { - Dialect overrideDateTimeValidator =Dialect - .builder(Dialect.getV7().getIri(), Dialect.getV7()) + Dialect overrideDateTimeValidator = Dialect + .builder(Dialects.getDraft7().getIri(), Dialects.getDraft7()) .formats(formats -> { if (useCustomDateFormat) { CustomDateTimeFormat format = new CustomDateTimeFormat(); diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 5fc6507fc..24b9621b6 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialects; class Issue824Test { @Test @@ -18,7 +19,7 @@ void validate() throws JsonProcessingException { .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() - .getSchema(SchemaLocation.of(Dialect.getV201909().getIri())); + .getSchema(SchemaLocation.of(Dialects.getDraft201909().getIri())); final JsonNode invalidSchema = new ObjectMapper().readTree( "{"+ " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\","+ diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 1bd2ea33b..6b85cbe00 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -2,6 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,8 +37,8 @@ private JsonSchemaFactory buildV7PlusNoFormatSchemaFactory() { formats.add(new NoMatchFormat()); Dialect jsonMetaSchema = Dialect.builder( - Dialect.getV7().getIri(), - Dialect.getV7()) + Dialects.getDraft7().getIri(), + Dialects.getDraft7()) .formats(formats) .build(); return new JsonSchemaFactory.Builder().defaultMetaSchemaIri(jsonMetaSchema.getIri()).metaSchema(jsonMetaSchema).build(); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index ada8902a9..6b8bc4528 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.serialization.JsonMapperFactory; class Issue994Test { @@ -41,12 +43,12 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - Dialect metaSchema = Dialect.builder(Dialect.getV202012()).vocabularies(vocabularies -> { + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).vocabularies(vocabularies -> { vocabularies.remove(Vocabulary.V202012_VALIDATION.getIri()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); JsonSchema schema = JsonSchemaFactory - .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)).getSchema(schemaNode); + .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)).getSchema(schemaNode); String inputData = "{\r\n" + " \"textValue\": \"hello\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java index 6a99474aa..48ddaa907 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; /** * Tests for JsonSchemaFactory. @@ -62,13 +63,13 @@ public void run() { } catch (InterruptedException e) { throw new RuntimeException(e); } - Dialect metaSchema = factory.getMetaSchema("https://www.example.com/no-validation-no-format/schema", config); + Dialect dialect = factory.getMetaSchema("https://www.example.com/no-validation-no-format/schema", config); synchronized(instance) { if (instance[0] == null) { - instance[0] = metaSchema; + instance[0] = dialect; } // Ensure references are the same despite concurrency - if (!(instance[0] == metaSchema)) { + if (!(instance[0] == dialect)) { failed.set(true); } } diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index f5ed46614..f953d0274 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.SchemaLoader; @@ -47,7 +48,7 @@ private JsonSchemaFactory buildJsonSchemaFactory(CustomURIFetcher uriFetcher, bo return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) - .metaSchema(Dialect.getV202012()) + .metaSchema(Dialects.getDraft202012()) .build(); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 12c8abaec..d2af0f981 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -38,7 +40,7 @@ void setup() { } private void setupSchema() { - final Dialect metaSchema = getJsonMetaSchema(); + final Dialect dialect = getJsonMetaSchema(); // Create Schema. SchemaValidatorsConfig.Builder schemaValidatorsConfigBuilder = SchemaValidatorsConfig.builder(); schemaValidatorsConfigBuilder.keywordWalkListener(new AllKeywordListener()); @@ -46,7 +48,7 @@ private void setupSchema() { schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(metaSchema) + .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) .build(); this.jsonSchema = schemaFactory.getSchema(getSchema(), schemaValidatorsConfigBuilder.build()); // Create another Schema. @@ -59,7 +61,7 @@ private void setupSchema() { private Dialect getJsonMetaSchema() { return Dialect.builder( - "https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialect.getV201909()) + "https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialects.getDraft201909()) .keyword(new CustomKeyword()).build(); } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 3a5c2e076..bb5f23216 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -69,9 +71,9 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath @Test void message() { - Dialect metaSchema = Dialect.builder(Dialect.getV202012().getIri(), Dialect.getV202012()) + Dialect dialect = Dialect.builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) .keyword(new EqualsKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(metaSchema)); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"type\": \"string\",\r\n" + " \"equals\": \"helloworld\"\r\n" diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 188132f36..500323a8a 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -19,6 +19,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.format.PatternFormat; import org.junit.jupiter.api.Test; @@ -50,7 +52,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { "}"); // Use Default EmailValidator final Dialect validatorMetaSchema = Dialect - .builder(URI, Dialect.getV201909()) + .builder(URI, Dialects.getDraft201909()) .build(); final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); @@ -66,7 +68,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { // Override EmailValidator final Dialect overrideValidatorMetaSchema = Dialect - .builder(URI, Dialect.getV201909()) + .builder(URI, Dialects.getDraft201909()) .format(PatternFormat.of("email", "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "format.email")) .build(); diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index fd1496360..b75b429ef 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import com.networknt.schema.dialect.DialectId; class RefTest { private static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder().build(); diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index 4bd7638f7..c257d08fa 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.DialectId; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index bfb146112..564138274 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -29,6 +29,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.JsonSchemaFactory.Builder; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.MapSchemaMapper; import com.networknt.schema.resource.SchemaLoader; @@ -47,7 +49,7 @@ class UriMappingTest { @Test void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - Dialect draftV4 = Dialect.getV4(); + Dialect draftV4 = Dialects.getDraft4(); Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) @@ -98,7 +100,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { fail("Unexpected exception thrown", ex); } URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - Dialect draftV4 = Dialect.getV4(); + Dialect draftV4 = Dialects.getDraft4(); Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 4e2613d65..afbd4012e 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -1,6 +1,9 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; + import org.junit.jupiter.api.Test; import java.io.IOException; @@ -25,7 +28,7 @@ void testURNToURI() throws Exception { InputStream is = null; try { is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); - Dialect draftV7 = Dialect.getV7(); + Dialect draftV7 = Dialects.getDraft7(); JsonSchemaFactory.Builder builder = JsonSchemaFactory.builder() .defaultMetaSchemaIri(draftV7.getIri()) .metaSchema(draftV7) diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index d87c5031c..9391081b8 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -26,6 +26,8 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.output.OutputUnit; @@ -201,13 +203,13 @@ void customVocabulary() { return null; }; - Dialect metaSchema = Dialect - .builder(Dialect.getV202012().getIri(), Dialect.getV202012()) + Dialect dialect = Dialect + .builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) .vocabularyFactory(vocabularyFactory) .build(); JsonSchemaFactory factory = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(metaSchema).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.metaSchema(dialect).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); JsonSchema schema = factory.getSchema(schemaData); diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index c3f5600ed..5b52bfc03 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -33,6 +33,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.OpenApi30; import com.networknt.schema.Error; /** diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 387ba611a..5e18a1479 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -28,6 +28,7 @@ import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.OpenApi31; import com.networknt.schema.Error; /** diff --git a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java b/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java index f0616f18b..aa7a61e13 100644 --- a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java +++ b/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.params.provider.EnumSource; import com.networknt.schema.AbsoluteIri; -import com.networknt.schema.DialectId; +import com.networknt.schema.dialect.DialectId; /** * MetaSchemaMapperTest. diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index 9c0191228..ff3d49d66 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -39,10 +39,10 @@ import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.JsonSchemaRef; -import com.networknt.schema.DialectId; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DialectId; import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; From ef784d947cc8a921e26ab9049f05a318846a3bfb Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:14:57 +0800 Subject: [PATCH 13/74] Rename JsonMetaSchemaFactory to DialectRegistry --- .../DisallowUnknownJsonMetaSchemaFactory.java | 44 ----------------- .../schema/JsonMetaSchemaFactory.java | 34 -------------- .../networknt/schema/JsonSchemaFactory.java | 14 +++--- .../DefaultDialectRegistry.java} | 40 ++++++++-------- .../schema/dialect/DialectRegistry.java | 40 ++++++++++++++++ .../DisallowUnknownDialectFactory.java | 47 +++++++++++++++++++ ...=> DisallowUnknownDialectFactoryTest.java} | 7 +-- .../networknt/schema/oas/OpenApi30Test.java | 4 +- .../networknt/schema/oas/OpenApi31Test.java | 10 ++-- 9 files changed, 127 insertions(+), 113 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java delete mode 100644 src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java rename src/main/java/com/networknt/schema/{DefaultJsonMetaSchemaFactory.java => dialect/DefaultDialectRegistry.java} (59%) create mode 100644 src/main/java/com/networknt/schema/dialect/DialectRegistry.java create mode 100644 src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java rename src/test/java/com/networknt/schema/{DisallowUnknownJsonMetaSchemaFactoryTest.java => DisallowUnknownDialectFactoryTest.java} (90%) diff --git a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java deleted file mode 100644 index ff4a75170..000000000 --- a/src/main/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import com.networknt.schema.dialect.Dialect; - -/** - * A {@link JsonMetaSchemaFactory} that does not meta-schemas that aren't - * explicitly configured in the {@link JsonSchemaFactory}. - */ -public class DisallowUnknownJsonMetaSchemaFactory implements JsonMetaSchemaFactory { - @Override - public Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { - throw new InvalidSchemaException(Error.builder() - .message("Unknown meta-schema ''{0}''. Only meta-schemas that are explicitly configured can be used.") - .arguments(iri).build()); - } - - private static class Holder { - private static final DisallowUnknownJsonMetaSchemaFactory INSTANCE = new DisallowUnknownJsonMetaSchemaFactory(); - } - - /** - * Gets the instance of {@link DisallowUnknownJsonMetaSchemaFactory}. - * - * @return the json meta schema factory - */ - public static DisallowUnknownJsonMetaSchemaFactory getInstance() { - return Holder.INSTANCE; - } -} diff --git a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java deleted file mode 100644 index d8f664b90..000000000 --- a/src/main/java/com/networknt/schema/JsonMetaSchemaFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import com.networknt.schema.dialect.Dialect; - -/** - * Factory for {@link Dialect}. - */ -@FunctionalInterface -public interface JsonMetaSchemaFactory { - /** - * Gets the meta-schema given the IRI. - * - * @param iri the meta-schema IRI - * @param schemaFactory the schema factory - * @param config the config - * @return the meta-schema - */ - Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config); -} diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 51dca955d..179f33376 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -19,8 +19,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DefaultDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.DialectId; +import com.networknt.schema.dialect.DialectRegistry; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.DefaultSchemaLoader; import com.networknt.schema.resource.SchemaLoader; @@ -64,7 +66,7 @@ public static class Builder { private SchemaLoaders.Builder schemaLoadersBuilder = null; private SchemaMappers.Builder schemaMappersBuilder = null; private boolean enableSchemaCache = true; - private JsonMetaSchemaFactory metaSchemaFactory = null; + private DialectRegistry metaSchemaFactory = null; /** * Sets the json node reader to read the data. @@ -118,7 +120,7 @@ public Builder defaultMetaSchemaIri(final String defaultMetaSchemaIri) { return this; } - public Builder metaSchemaFactory(final JsonMetaSchemaFactory jsonMetaSchemaFactory) { + public Builder metaSchemaFactory(final DialectRegistry jsonMetaSchemaFactory) { this.metaSchemaFactory = jsonMetaSchemaFactory; return this; } @@ -196,7 +198,7 @@ public JsonSchemaFactory build() { private final ConcurrentMap metaSchemas; private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; - private final JsonMetaSchemaFactory metaSchemaFactory; + private final DialectRegistry metaSchemaFactory; private static final List DEFAULT_SCHEMA_LOADERS = SchemaLoaders.builder().build(); private static final List DEFAULT_SCHEMA_MAPPERS = SchemaMappers.builder().build(); @@ -210,7 +212,7 @@ private JsonSchemaFactory( SchemaMappers.Builder schemaMappersBuilder, ConcurrentMap metaSchemas, boolean enableSchemaCache, - JsonMetaSchemaFactory metaSchemaFactory) { + DialectRegistry metaSchemaFactory) { this.metaSchemas = metaSchemas; if (defaultMetaSchemaIri == null || defaultMetaSchemaIri.trim().isEmpty()) { throw new IllegalArgumentException("defaultMetaSchemaIri must not be null or empty"); @@ -468,8 +470,8 @@ public Dialect getMetaSchema(String iri, SchemaValidatorsConfig config) { * @return the meta-schema */ protected Dialect loadMetaSchema(String iri, SchemaValidatorsConfig config) { - return this.metaSchemaFactory != null ? this.metaSchemaFactory.getMetaSchema(iri, this, config) - : DefaultJsonMetaSchemaFactory.getInstance().getMetaSchema(iri, this, config); + return this.metaSchemaFactory != null ? this.metaSchemaFactory.getDialect(iri, this, config) + : DefaultDialectRegistry.getInstance().getDialect(iri, this, config); } JsonNode readTree(String content, InputFormat inputFormat) throws IOException { diff --git a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java similarity index 59% rename from src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java rename to src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index 6f123ba55..ddb06c3d8 100644 --- a/src/main/java/com/networknt/schema/DefaultJsonMetaSchemaFactory.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -13,45 +13,47 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.dialect; import java.util.Map; import java.util.Map.Entry; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.Specification; import com.networknt.schema.Specification.Version; -import com.networknt.schema.dialect.Dialect; /** - * Default {@link JsonMetaSchemaFactory}. + * Default {@link DialectRegistry}. */ -public class DefaultJsonMetaSchemaFactory implements JsonMetaSchemaFactory { +public class DefaultDialectRegistry implements DialectRegistry { @Override - public Dialect getMetaSchema(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { // Is it a well-known dialect? - return Specification.Version.fromDialectId(iri) - .map(JsonSchemaFactory::checkVersion) - .orElseGet(() -> { - // Custom meta schema - return loadMetaSchema(iri, schemaFactory, config); - }); + return Specification.Version.fromDialectId(dialectId).map(JsonSchemaFactory::checkVersion).orElseGet(() -> { + // Custom dialect + return loadDialect(dialectId, schemaFactory, config); + }); } - protected Dialect loadMetaSchema(String iri, JsonSchemaFactory schemaFactory, - SchemaValidatorsConfig config) { + protected Dialect loadDialect(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { try { - Dialect result = loadMetaSchemaBuilder(iri, schemaFactory, config).build(); + Dialect result = loadDialectBuilder(iri, schemaFactory, config).build(); return result; } catch (InvalidSchemaException e) { throw e; } catch (Exception e) { - Error error = Error.builder() - .message("Failed to load meta-schema ''{0}''").arguments(iri).build(); + Error error = Error.builder().message("Failed to load dialect ''{0}''").arguments(iri).build(); throw new InvalidSchemaException(error, e); } } - protected Dialect.Builder loadMetaSchemaBuilder(String iri, JsonSchemaFactory schemaFactory, + protected Dialect.Builder loadDialectBuilder(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { JsonSchema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getMetaSchema()); @@ -72,10 +74,10 @@ protected Dialect.Builder loadMetaSchemaBuilder(String iri, JsonSchemaFactory sc } private static class Holder { - private static final DefaultJsonMetaSchemaFactory INSTANCE = new DefaultJsonMetaSchemaFactory(); + private static final DefaultDialectRegistry INSTANCE = new DefaultDialectRegistry(); } - public static DefaultJsonMetaSchemaFactory getInstance() { + public static DefaultDialectRegistry getInstance() { return Holder.INSTANCE; } } diff --git a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java new file mode 100644 index 000000000..418c14d2b --- /dev/null +++ b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema.dialect; + +import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaValidatorsConfig; + +/** + * Registry for {@link Dialect} that can be retrieved using the dialect id which + * is the IRI that indicates the meta-schema that can be used to validate the + * schema conforms to the dialect. + */ +@FunctionalInterface +public interface DialectRegistry { + /** + * Gets the dialect given the dialect id which is the IRI that indicates the + * meta-schema that can be used to validate the schema conforms to the dialect. + * + * @param dialectId the dialect id of the dialect which IRI that indicates + * the meta-schema that can be used to validate the schema + * conforms to the dialect + * @param schemaFactory the schema factory + * @param config the config + * @return the dialect + */ + Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config); +} diff --git a/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java b/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java new file mode 100644 index 000000000..16eb75e50 --- /dev/null +++ b/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema.dialect; + +import com.networknt.schema.Error; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaValidatorsConfig; + +/** + * A {@link DialectRegistry} that does not meta-schemas that aren't + * explicitly configured in the {@link JsonSchemaFactory}. + */ +public class DisallowUnknownDialectFactory implements DialectRegistry { + @Override + public Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + throw new InvalidSchemaException(Error.builder() + .message("Unknown dialect ''{0}''. Only dialects that are explicitly configured can be used.") + .arguments(dialectId).build()); + } + + private static class Holder { + private static final DisallowUnknownDialectFactory INSTANCE = new DisallowUnknownDialectFactory(); + } + + /** + * Gets the instance of {@link DisallowUnknownDialectFactory}. + * + * @return the json meta schema factory + */ + public static DisallowUnknownDialectFactory getInstance() { + return Holder.INSTANCE; + } +} diff --git a/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java similarity index 90% rename from src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java rename to src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java index 1c6503f16..ff507adae 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownJsonMetaSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java @@ -21,11 +21,12 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DisallowUnknownDialectFactory; /** * Tests for DisallowUnknownJsonMetaSchemaFactory. */ -class DisallowUnknownJsonMetaSchemaFactoryTest { +class DisallowUnknownDialectFactoryTest { private static final String DRAFT_202012_SCHEMA = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"type\": \"object\"\r\n" @@ -45,7 +46,7 @@ void defaultHandling() { @Test void draft202012() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_7_SCHEMA)); } @@ -53,7 +54,7 @@ void draft202012() { @Test void draft7() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, - builder -> builder.metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_202012_SCHEMA)); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 5b52bfc03..35c2abef7 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.DisallowUnknownJsonMetaSchemaFactory; import com.networknt.schema.InputFormat; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; @@ -33,6 +32,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DisallowUnknownDialectFactory; import com.networknt.schema.dialect.OpenApi30; import com.networknt.schema.Error; @@ -48,7 +48,7 @@ void validateMetaSchema() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(OpenApi30.getInstance()) .defaultMetaSchemaIri(OpenApi30.getInstance().getIri()) - .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); JsonSchema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/requestBody/content/application~1json/schema")); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 5e18a1479..55d590e51 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.DisallowUnknownJsonMetaSchemaFactory; import com.networknt.schema.InputFormat; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.DisallowUnknownDialectFactory; import com.networknt.schema.dialect.OpenApi31; import com.networknt.schema.Error; @@ -71,7 +71,7 @@ void validateVocabulary() { void validateMetaSchema() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); JsonSchema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -101,7 +101,7 @@ void validateMetaSchema() { void discriminatorOneOfMultipleMatchShouldFail() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); JsonSchema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -121,7 +121,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { void discriminatorOneOfNoMatchShouldFail() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); JsonSchema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -143,7 +143,7 @@ void discriminatorOneOfNoMatchShouldFail() { void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownJsonMetaSchemaFactory.getInstance())); + .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); JsonSchema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" From 24e1770ead93c00c0e05cdf455d4fa6ed3157530 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:37:15 +0800 Subject: [PATCH 14/74] Rename JsonSchema to Schema --- .../com/networknt/schema/ErrorMessages.java | 4 +- .../networknt/schema/JsonSchemaFactory.java | 58 +++++++------- .../com/networknt/schema/JsonSchemaRef.java | 6 +- .../com/networknt/schema/OutputFormat.java | 14 ++-- .../schema/{JsonSchema.java => Schema.java} | 76 +++++++++---------- .../networknt/schema/ValidationContext.java | 20 ++--- .../dialect/DefaultDialectRegistry.java | 4 +- .../com/networknt/schema/dialect/Dialect.java | 4 +- .../format/BaseFormatJsonValidator.java | 4 +- .../AdditionalPropertiesValidator.java | 6 +- .../schema/keyword/AllOfValidator.java | 12 +-- .../schema/keyword/AnnotationKeyword.java | 6 +- .../schema/keyword/AnyOfValidator.java | 10 +-- .../schema/keyword/BaseKeywordValidator.java | 24 +++--- .../schema/keyword/ConstValidator.java | 4 +- .../schema/keyword/ContainsValidator.java | 8 +- .../keyword/ContentEncodingValidator.java | 4 +- .../keyword/ContentMediaTypeValidator.java | 4 +- .../schema/keyword/DependenciesValidator.java | 8 +- .../schema/keyword/DependentRequired.java | 4 +- .../schema/keyword/DependentSchemas.java | 10 +-- .../keyword/DiscriminatorValidator.java | 18 ++--- .../schema/keyword/DynamicRefValidator.java | 26 +++---- .../schema/keyword/EnumValidator.java | 4 +- .../keyword/ExclusiveMaximumValidator.java | 4 +- .../keyword/ExclusiveMinimumValidator.java | 4 +- .../schema/keyword/FalseValidator.java | 4 +- .../schema/keyword/FormatKeyword.java | 4 +- .../schema/keyword/FormatValidator.java | 4 +- .../networknt/schema/keyword/IfValidator.java | 16 ++-- .../schema/keyword/ItemsValidator.java | 22 +++--- .../schema/keyword/ItemsValidator202012.java | 12 +-- .../com/networknt/schema/keyword/Keyword.java | 4 +- .../schema/keyword/KeywordValidator.java | 4 +- .../schema/keyword/MaxItemsValidator.java | 4 +- .../schema/keyword/MaxLengthValidator.java | 4 +- .../keyword/MaxPropertiesValidator.java | 4 +- .../schema/keyword/MaximumValidator.java | 4 +- .../schema/keyword/MinItemsValidator.java | 4 +- .../schema/keyword/MinLengthValidator.java | 4 +- .../keyword/MinMaxContainsValidator.java | 4 +- .../keyword/MinPropertiesValidator.java | 4 +- .../schema/keyword/MinimumValidator.java | 4 +- .../schema/keyword/MultipleOfValidator.java | 4 +- .../schema/keyword/NonValidationKeyword.java | 8 +- .../schema/keyword/NotAllowedValidator.java | 4 +- .../schema/keyword/NotValidator.java | 6 +- .../schema/keyword/OneOfValidator.java | 12 +-- .../keyword/PatternPropertiesValidator.java | 8 +- .../schema/keyword/PatternValidator.java | 4 +- .../schema/keyword/PrefixItemsValidator.java | 12 +-- .../schema/keyword/PropertiesValidator.java | 20 ++--- .../keyword/PropertyNamesValidator.java | 6 +- .../schema/keyword/ReadOnlyValidator.java | 4 +- .../schema/keyword/RecursiveRefValidator.java | 24 +++--- .../schema/keyword/RefValidator.java | 32 ++++---- .../schema/keyword/RequiredValidator.java | 4 +- .../schema/keyword/TrueValidator.java | 4 +- .../schema/keyword/TypeValidator.java | 4 +- .../keyword/UnevaluatedItemsValidator.java | 6 +- .../UnevaluatedPropertiesValidator.java | 6 +- .../schema/keyword/UnionTypeValidator.java | 8 +- .../schema/keyword/UniqueItemsValidator.java | 4 +- .../schema/keyword/ValidatorTypeCode.java | 8 +- .../schema/keyword/WriteOnlyValidator.java | 4 +- .../HierarchicalOutputUnitFormatter.java | 4 +- .../networknt/schema/utils/JsonNodeUtil.java | 8 +- .../schema/utils/JsonSchemaRefs.java | 4 +- .../walk/AbstractWalkListenerRunner.java | 4 +- .../walk/DefaultItemWalkListenerRunner.java | 6 +- .../DefaultKeywordWalkListenerRunner.java | 6 +- .../DefaultPropertyWalkListenerRunner.java | 6 +- .../com/networknt/schema/walk/WalkEvent.java | 8 +- .../schema/walk/WalkListenerRunner.java | 6 +- .../schema/AbstractJsonSchemaTest.java | 4 +- .../schema/AbstractJsonSchemaTestSuite.java | 6 +- .../AdditionalPropertiesValidatorTest.java | 4 +- .../networknt/schema/AllOfValidatorTest.java | 2 +- .../networknt/schema/AnyOfValidatorTest.java | 2 +- .../schema/BaseJsonSchemaValidatorTest.java | 14 ++-- .../schema/CollectorContextTest.java | 18 ++--- .../networknt/schema/ConstValidatorTest.java | 10 +-- .../schema/ContentSchemaValidatorTest.java | 2 +- .../schema/CustomMetaSchemaTest.java | 4 +- .../com/networknt/schema/CustomUriTest.java | 2 +- .../schema/CyclicDependencyTest.java | 2 +- .../com/networknt/schema/DateTimeDSTTest.java | 4 +- .../schema/DependentRequiredTest.java | 2 +- .../schema/DiscriminatorValidatorTest.java | 18 ++--- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 4 +- .../networknt/schema/ErrorHandlerTest.java | 4 +- .../com/networknt/schema/ExampleTest.java | 8 +- .../schema/ExclusiveMinimumValidatorTest.java | 2 +- .../schema/FormatKeywordFactoryTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 16 ++-- .../com/networknt/schema/IfValidatorTest.java | 8 +- .../com/networknt/schema/Issue1091Test.java | 2 +- .../com/networknt/schema/Issue255Test.java | 4 +- .../com/networknt/schema/Issue285Test.java | 6 +- .../com/networknt/schema/Issue295Test.java | 4 +- .../com/networknt/schema/Issue313Test.java | 8 +- .../com/networknt/schema/Issue314Test.java | 2 +- .../com/networknt/schema/Issue327Test.java | 4 +- .../com/networknt/schema/Issue342Test.java | 4 +- .../schema/Issue366FailFastTest.java | 2 +- .../schema/Issue366FailSlowTest.java | 2 +- .../com/networknt/schema/Issue375Test.java | 4 +- .../com/networknt/schema/Issue383Test.java | 4 +- .../com/networknt/schema/Issue396Test.java | 4 +- .../com/networknt/schema/Issue404Test.java | 4 +- .../com/networknt/schema/Issue406Test.java | 6 +- .../com/networknt/schema/Issue426Test.java | 4 +- .../com/networknt/schema/Issue428Test.java | 2 +- .../com/networknt/schema/Issue451Test.java | 4 +- .../com/networknt/schema/Issue456Test.java | 6 +- .../com/networknt/schema/Issue461Test.java | 4 +- .../com/networknt/schema/Issue467Test.java | 4 +- .../com/networknt/schema/Issue471Test.java | 4 +- .../com/networknt/schema/Issue475Test.java | 10 +-- .../com/networknt/schema/Issue493Test.java | 8 +- .../com/networknt/schema/Issue518Test.java | 2 +- .../com/networknt/schema/Issue550Test.java | 6 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 2 +- .../com/networknt/schema/Issue606Test.java | 4 +- .../com/networknt/schema/Issue619Test.java | 24 +++--- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue662Test.java | 2 +- .../com/networknt/schema/Issue664Test.java | 4 +- .../com/networknt/schema/Issue665Test.java | 4 +- .../com/networknt/schema/Issue668Test.java | 4 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 4 +- .../com/networknt/schema/Issue724Test.java | 2 +- .../com/networknt/schema/Issue784Test.java | 8 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue832Test.java | 2 +- .../com/networknt/schema/Issue877Test.java | 2 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 2 +- .../com/networknt/schema/Issue928Test.java | 4 +- .../com/networknt/schema/Issue939Test.java | 2 +- .../com/networknt/schema/Issue940Test.java | 2 +- .../com/networknt/schema/Issue943Test.java | 2 +- .../com/networknt/schema/Issue994Test.java | 2 +- .../schema/ItemsValidator202012Test.java | 6 +- .../networknt/schema/ItemsValidatorTest.java | 16 ++-- .../schema/JsonWalkApplyDefaultsTest.java | 14 ++-- .../com/networknt/schema/JsonWalkTest.java | 8 +- .../java/com/networknt/schema/LocaleTest.java | 8 +- .../schema/MaximumValidatorTest.java | 10 +-- .../com/networknt/schema/MessageTest.java | 6 +- .../schema/MetaSchemaValidationTest.java | 2 +- .../schema/MinimumValidatorTest.java | 10 +-- .../schema/MultipleOfValidatorTest.java | 6 +- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 20 ++--- .../schema/OpenAPI30JsonSchemaTest.java | 2 +- .../networknt/schema/OutputFormatTest.java | 6 +- .../com/networknt/schema/OutputUnitTest.java | 20 ++--- .../schema/OverrideValidatorTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 4 +- .../PatternPropertiesValidatorTest.java | 8 +- .../schema/PatternValidatorTest.java | 2 +- .../schema/PrefixItemsValidatorTest.java | 10 +-- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 2 +- .../schema/ReadOnlyValidatorTest.java | 6 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 8 +- .../networknt/schema/RefValidatorTest.java | 12 +-- .../schema/RequiredValidatorTest.java | 8 +- .../java/com/networknt/schema/SampleTest.java | 10 +-- .../networknt/schema/SchemaLocationTest.java | 2 +- .../{JsonSchemaTest.java => SchemaTest.java} | 4 +- .../com/networknt/schema/SelfRefTest.java | 2 +- .../networknt/schema/SharedConfigTest.java | 4 +- .../networknt/schema/TypeValidatorTest.java | 12 +-- .../schema/UnevaluatedItemsValidatorTest.java | 4 +- .../UnevaluatedPropertiesValidatorTest.java | 10 +-- .../schema/UnknownMetaSchemaTest.java | 6 +- .../com/networknt/schema/UriMappingTest.java | 14 ++-- .../java/com/networknt/schema/UrnTest.java | 2 +- .../networknt/schema/V4JsonSchemaTest.java | 2 +- .../com/networknt/schema/VocabularyTest.java | 6 +- .../benchmark/NetworkntBasicRunner.java | 4 +- .../benchmark/NetworkntTestSuiteTestCase.java | 8 +- .../NetworkntTestSuiteTestCases.java | 4 +- .../schema/format/IriFormatTest.java | 16 ++-- .../schema/format/IriReferenceFormatTest.java | 16 ++-- .../schema/format/TimeFormatTest.java | 6 +- .../schema/format/UriFormatTest.java | 16 ++-- .../schema/format/UriReferenceFormatTest.java | 16 ++-- .../networknt/schema/oas/OpenApi30Test.java | 10 +-- .../networknt/schema/oas/OpenApi31Test.java | 12 +-- .../resource/AllowSchemaLoaderTest.java | 4 +- .../networknt/schema/utils/JsonNodesTest.java | 6 +- .../walk/JsonSchemaWalkListenerTest.java | 34 ++++----- 200 files changed, 736 insertions(+), 736 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchema.java => Schema.java} (95%) rename src/test/java/com/networknt/schema/{JsonSchemaTest.java => SchemaTest.java} (95%) diff --git a/src/main/java/com/networknt/schema/ErrorMessages.java b/src/main/java/com/networknt/schema/ErrorMessages.java index 3cda00848..aaff9bf2a 100644 --- a/src/main/java/com/networknt/schema/ErrorMessages.java +++ b/src/main/java/com/networknt/schema/ErrorMessages.java @@ -18,7 +18,7 @@ public class ErrorMessages { * @param keyword the keyword * @return the custom error message */ - public static Map getErrorMessage(JsonSchema parentSchema, String errorMessageKeyword, + public static Map getErrorMessage(Schema parentSchema, String errorMessageKeyword, String keyword) { final JsonNode message = getMessageNode(errorMessageKeyword, parentSchema.schemaNode, parentSchema, keyword); if (message != null) { @@ -39,7 +39,7 @@ public static Map getErrorMessage(JsonSchema parentSchema, Strin return Collections.emptyMap(); } - protected static JsonNode getMessageNode(String errorMessageKeyword, JsonNode schemaNode, JsonSchema parentSchema, + protected static JsonNode getMessageNode(String errorMessageKeyword, JsonNode schemaNode, Schema parentSchema, String pname) { if (schemaNode.get(errorMessageKeyword) != null && schemaNode.get(errorMessageKeyword).get(pname) != null) { return schemaNode.get(errorMessageKeyword); diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 179f33376..ba27165e0 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -47,7 +47,7 @@ import java.util.function.Consumer; /** - * Factory for building {@link JsonSchema} instances. The factory should be + * Factory for building {@link Schema} instances. The factory should be * typically be created using {@link #getInstance(Version, Consumer)} and * should be cached for performance. *

@@ -196,7 +196,7 @@ public JsonSchemaFactory build() { private final SchemaMappers.Builder schemaMappersBuilder; private final SchemaLoader schemaLoader; private final ConcurrentMap metaSchemas; - private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); + private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; private final DialectRegistry metaSchemaFactory; @@ -333,9 +333,9 @@ public static Builder builder(final JsonSchemaFactory blueprint) { * @param config the config to use * @return the schema */ - protected JsonSchema newJsonSchema(final SchemaLocation schemaUri, final JsonNode schemaNode, final SchemaValidatorsConfig config) { + protected Schema newJsonSchema(final SchemaLocation schemaUri, final JsonNode schemaNode, final SchemaValidatorsConfig config) { final ValidationContext validationContext = createValidationContext(schemaNode, config); - JsonSchema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), + Schema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), new JsonNodePath(validationContext.getConfig().getPathType()), schemaNode, null, false); preload(jsonSchema, config); return jsonSchema; @@ -347,7 +347,7 @@ protected JsonSchema newJsonSchema(final SchemaLocation schemaUri, final JsonNod * @param jsonSchema the schema to preload * @param config containing the configuration option */ - private void preload(JsonSchema jsonSchema, SchemaValidatorsConfig config) { + private void preload(Schema jsonSchema, SchemaValidatorsConfig config) { if (config.isPreloadJsonSchema()) { try { /* @@ -365,12 +365,12 @@ private void preload(JsonSchema jsonSchema, SchemaValidatorsConfig config) { } } - public JsonSchema create(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema) { + public Schema create(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { return doCreate(validationContext, schemaLocation, evaluationPath, schemaNode, parentSchema, false); } - private JsonSchema doCreate(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, boolean suppressSubSchemaRetrieval) { - return JsonSchema.from(withMetaSchema(validationContext, schemaNode), schemaLocation, evaluationPath, + private Schema doCreate(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { + return Schema.from(withMetaSchema(validationContext, schemaNode), schemaLocation, evaluationPath, schemaNode, parentSchema, suppressSubSchemaRetrieval); } @@ -509,7 +509,7 @@ ObjectMapper getObjectMapper(InputFormat inputFormat) { * @param config the config * @return the schema */ - public JsonSchema getSchema(final String schema, final SchemaValidatorsConfig config) { + public Schema getSchema(final String schema, final SchemaValidatorsConfig config) { return getSchema(schema, InputFormat.JSON, config); } @@ -524,7 +524,7 @@ public JsonSchema getSchema(final String schema, final SchemaValidatorsConfig co * @param config the config * @return the schema */ - public JsonSchema getSchema(final String schema, InputFormat inputFormat, final SchemaValidatorsConfig config) { + public Schema getSchema(final String schema, InputFormat inputFormat, final SchemaValidatorsConfig config) { try { final JsonNode schemaNode = readTree(schema, inputFormat); return newJsonSchema(null, schemaNode, config); @@ -544,7 +544,7 @@ public JsonSchema getSchema(final String schema, InputFormat inputFormat, final * @param schema the schema data as a string * @return the schema */ - public JsonSchema getSchema(final String schema) { + public Schema getSchema(final String schema) { return getSchema(schema, createSchemaValidatorsConfig()); } @@ -558,7 +558,7 @@ public JsonSchema getSchema(final String schema) { * @param inputFormat input format * @return the schema */ - public JsonSchema getSchema(final String schema, InputFormat inputFormat) { + public Schema getSchema(final String schema, InputFormat inputFormat) { return getSchema(schema, inputFormat, createSchemaValidatorsConfig()); } @@ -572,7 +572,7 @@ public JsonSchema getSchema(final String schema, InputFormat inputFormat) { * @param config the config * @return the schema */ - public JsonSchema getSchema(final InputStream schemaStream, final SchemaValidatorsConfig config) { + public Schema getSchema(final InputStream schemaStream, final SchemaValidatorsConfig config) { return getSchema(schemaStream, InputFormat.JSON, config); } @@ -587,7 +587,7 @@ public JsonSchema getSchema(final InputStream schemaStream, final SchemaValidato * @param config the config * @return the schema */ - public JsonSchema getSchema(final InputStream schemaStream, InputFormat inputFormat, final SchemaValidatorsConfig config) { + public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat, final SchemaValidatorsConfig config) { try { final JsonNode schemaNode = readTree(schemaStream, inputFormat); return newJsonSchema(null, schemaNode, config); @@ -606,7 +606,7 @@ public JsonSchema getSchema(final InputStream schemaStream, InputFormat inputFor * @param schemaStream the input stream with the schema data * @return the schema */ - public JsonSchema getSchema(final InputStream schemaStream) { + public Schema getSchema(final InputStream schemaStream) { return getSchema(schemaStream, createSchemaValidatorsConfig()); } @@ -617,8 +617,8 @@ public JsonSchema getSchema(final InputStream schemaStream) { * @param config the config * @return the schema */ - public JsonSchema getSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { - JsonSchema schema = loadSchema(schemaUri, config); + public Schema getSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { + Schema schema = loadSchema(schemaUri, config); preload(schema, config); return schema; } @@ -630,12 +630,12 @@ public JsonSchema getSchema(final SchemaLocation schemaUri, final SchemaValidato * @param config the config * @return the schema */ - public JsonSchema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { + public Schema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { if (enableSchemaCache) { // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. // The getMapperSchema potentially recurses to call back to getSchema again - JsonSchema cachedUriSchema = schemaCache.get(schemaUri); + Schema cachedUriSchema = schemaCache.get(schemaUri); if (cachedUriSchema == null) { synchronized (this) { // acquire lock on shared factory object to prevent deadlock cachedUriSchema = schemaCache.get(schemaUri); @@ -670,7 +670,7 @@ protected SchemaValidatorsConfig createSchemaValidatorsConfig() { return new SchemaValidatorsConfig(); } - protected JsonSchema getMappedSchema(final SchemaLocation schemaUri, SchemaValidatorsConfig config) { + protected Schema getMappedSchema(final SchemaLocation schemaUri, SchemaValidatorsConfig config) { try (InputStream inputStream = this.schemaLoader.getSchema(schemaUri.getAbsoluteIri()).getInputStream()) { if (inputStream == null) { throw new IOException("Cannot load schema at " + schemaUri); @@ -693,7 +693,7 @@ protected JsonSchema getMappedSchema(final SchemaLocation schemaUri, SchemaValid // Schema with fragment pointing to sub schema final ValidationContext validationContext = createValidationContext(schemaNode, config); SchemaLocation documentLocation = new SchemaLocation(schemaUri.getAbsoluteIri()); - JsonSchema document = doCreate(validationContext, documentLocation, evaluationPath, schemaNode, null, false); + Schema document = doCreate(validationContext, documentLocation, evaluationPath, schemaNode, null, false); return document.getRefSchema(schemaUri.getFragment()); } } catch (IOException e) { @@ -710,7 +710,7 @@ protected JsonSchema getMappedSchema(final SchemaLocation schemaUri, SchemaValid * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. * @return the schema */ - public JsonSchema getSchema(final URI schemaUri) { + public Schema getSchema(final URI schemaUri) { return getSchema(SchemaLocation.of(schemaUri.toString()), createSchemaValidatorsConfig()); } @@ -722,7 +722,7 @@ public JsonSchema getSchema(final URI schemaUri) { * @param config the config * @return the schema */ - public JsonSchema getSchema(final URI schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { + public Schema getSchema(final URI schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { return newJsonSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, config); } @@ -733,7 +733,7 @@ public JsonSchema getSchema(final URI schemaUri, final JsonNode jsonNode, final * @param jsonNode the node * @return the schema */ - public JsonSchema getSchema(final URI schemaUri, final JsonNode jsonNode) { + public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { return newJsonSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, createSchemaValidatorsConfig()); } @@ -743,7 +743,7 @@ public JsonSchema getSchema(final URI schemaUri, final JsonNode jsonNode) { * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. * @return the schema */ - public JsonSchema getSchema(final SchemaLocation schemaUri) { + public Schema getSchema(final SchemaLocation schemaUri) { return getSchema(schemaUri, createSchemaValidatorsConfig()); } @@ -755,7 +755,7 @@ public JsonSchema getSchema(final SchemaLocation schemaUri) { * @param config the config * @return the schema */ - public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { + public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { return newJsonSchema(schemaUri, jsonNode, config); } @@ -766,7 +766,7 @@ public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonN * @param jsonNode the node * @return the schema */ - public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { + public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { return newJsonSchema(schemaUri, jsonNode, createSchemaValidatorsConfig()); } @@ -783,7 +783,7 @@ public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonN * @param config the config * @return the schema */ - public JsonSchema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfig config) { + public Schema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfig config) { return newJsonSchema(null, jsonNode, config); } @@ -799,7 +799,7 @@ public JsonSchema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfi * @param jsonNode the node * @return the schema */ - public JsonSchema getSchema(final JsonNode jsonNode) { + public Schema getSchema(final JsonNode jsonNode) { return newJsonSchema(null, jsonNode, createSchemaValidatorsConfig()); } diff --git a/src/main/java/com/networknt/schema/JsonSchemaRef.java b/src/main/java/com/networknt/schema/JsonSchemaRef.java index c4d4cf4ca..fc26a462e 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaRef.java +++ b/src/main/java/com/networknt/schema/JsonSchemaRef.java @@ -22,13 +22,13 @@ */ public class JsonSchemaRef { - private final Supplier schemaSupplier; + private final Supplier schemaSupplier; - public JsonSchemaRef(Supplier schema) { + public JsonSchemaRef(Supplier schema) { this.schemaSupplier = schema; } - public JsonSchema getSchema() { + public Schema getSchema() { return this.schemaSupplier.get(); } } diff --git a/src/main/java/com/networknt/schema/OutputFormat.java b/src/main/java/com/networknt/schema/OutputFormat.java index fd1ef5edc..601a7b32d 100644 --- a/src/main/java/com/networknt/schema/OutputFormat.java +++ b/src/main/java/com/networknt/schema/OutputFormat.java @@ -49,7 +49,7 @@ default void customize(ExecutionContext executionContext, ValidationContext vali * * @return the result */ - T format(JsonSchema jsonSchema, + T format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext); /** @@ -95,7 +95,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public java.util.List format(JsonSchema jsonSchema, + public java.util.List format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return executionContext.getErrors(); } @@ -112,7 +112,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public OutputFlag format(JsonSchema jsonSchema, + public OutputFlag format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return new OutputFlag(executionContext.getErrors().isEmpty()); } @@ -129,7 +129,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public java.lang.Boolean format(JsonSchema jsonSchema, + public java.lang.Boolean format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return executionContext.getErrors().isEmpty(); } @@ -159,7 +159,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public OutputUnit format(JsonSchema jsonSchema, + public OutputUnit format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return ListOutputUnitFormatter.format(executionContext.getErrors(), executionContext, validationContext, this.errorMapper); @@ -190,7 +190,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public OutputUnit format(JsonSchema jsonSchema, + public OutputUnit format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return HierarchicalOutputUnitFormatter.format(jsonSchema, executionContext.getErrors(), executionContext, validationContext, this.errorMapper); @@ -208,7 +208,7 @@ public void customize(ExecutionContext executionContext, ValidationContext valid } @Override - public ValidationResult format(JsonSchema jsonSchema,ExecutionContext executionContext, ValidationContext validationContext) { + public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, ValidationContext validationContext) { return new ValidationResult(executionContext); } } diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/Schema.java similarity index 95% rename from src/main/java/com/networknt/schema/JsonSchema.java rename to src/main/java/com/networknt/schema/Schema.java index ef275a4f1..407e942db 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -50,7 +50,7 @@ * JsonSchema instances are thread-safe provided its configuration is not * modified. */ -public class JsonSchema implements Validator { +public class Schema implements Validator { private static final long V201909_VALUE = Version.DRAFT_2019_09.getOrder(); private final String id; @@ -63,13 +63,13 @@ public class JsonSchema implements Validator { private TypeValidator typeValidator = null; protected final JsonNode schemaNode; - protected final JsonSchema parentSchema; + protected final Schema parentSchema; protected final SchemaLocation schemaLocation; protected final ValidationContext validationContext; protected final boolean suppressSubSchemaRetrieval; protected final JsonNodePath evaluationPath; - protected final JsonSchema evaluationParentSchema; + protected final Schema evaluationParentSchema; public JsonNode getSchemaNode() { return this.schemaNode; @@ -79,7 +79,7 @@ public SchemaLocation getSchemaLocation() { return this.schemaLocation; } - public JsonSchema getParentSchema() { + public Schema getParentSchema() { return parentSchema; } @@ -91,18 +91,18 @@ public JsonNodePath getEvaluationPath() { return evaluationPath; } - public JsonSchema getEvaluationParentSchema() { + public Schema getEvaluationParentSchema() { if (this.evaluationParentSchema != null) { return this.evaluationParentSchema; } return getParentSchema(); } - protected JsonSchema fetchSubSchemaNode(ValidationContext validationContext) { + protected Schema fetchSubSchemaNode(ValidationContext validationContext) { return this.suppressSubSchemaRetrieval ? null : obtainSubSchemaNode(this.schemaNode, validationContext); } - private static JsonSchema obtainSubSchemaNode(final JsonNode schemaNode, final ValidationContext validationContext) { + private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final ValidationContext validationContext) { final JsonNode node = schemaNode.get("id"); if (node == null) { @@ -163,8 +163,8 @@ protected JsonNodePath atRoot() { return new JsonNodePath(this.validationContext.getConfig().getPathType()); } - static JsonSchema from(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval) { - return new JsonSchema(validationContext, schemaLocation, evaluationPath, schemaNode, parent, suppressSubSchemaRetrieval); + static Schema from(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { + return new Schema(validationContext, schemaLocation, evaluationPath, schemaNode, parent, suppressSubSchemaRetrieval); } private boolean hasNoFragment(SchemaLocation schemaLocation) { @@ -206,8 +206,8 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc } } - private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, - JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval) { + private Schema(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, + JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { /* super(resolve(schemaLocation, schemaNode, parent == null, validationContext), evaluationPath, schemaNode, parent, null, null, validationContext, suppressSubSchemaRetrieval); @@ -279,7 +279,7 @@ private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLoc * @param evaluationParentSchema the evaluation parent schema * @param errorMessage the error message */ - protected JsonSchema( + protected Schema( /* Below from JsonSchema */ List validators, boolean validatorsLoaded, @@ -290,10 +290,10 @@ protected JsonSchema( boolean suppressSubSchemaRetrieval, JsonNode schemaNode, ValidationContext validationContext, - JsonSchema parentSchema, + Schema parentSchema, SchemaLocation schemaLocation, JsonNodePath evaluationPath, - JsonSchema evaluationParentSchema, + Schema evaluationParentSchema, Map errorMessage) { // super(suppressSubSchemaRetrieval, schemaNode, validationContext, errorMessageType, keyword, // parentSchema, schemaLocation, evaluationPath, evaluationParentSchema, errorMessage); @@ -323,7 +323,7 @@ protected JsonSchema( * @param refEvaluationPath the ref evaluation path * @return the schema */ - public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath refEvaluationPath) { + public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluationPath) { ValidationContext validationContext = new ValidationContext(this.getValidationContext().getMetaSchema(), this.getValidationContext().getJsonSchemaFactory(), refEvaluationParentSchema.validationContext.getConfig(), @@ -331,13 +331,13 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref refEvaluationParentSchema.getValidationContext().getSchemaResources(), refEvaluationParentSchema.getValidationContext().getDynamicAnchors()); JsonNodePath evaluationPath = refEvaluationPath; - JsonSchema evaluationParentSchema = refEvaluationParentSchema; + Schema evaluationParentSchema = refEvaluationParentSchema; // Validator state is reset due to the changes in evaluation path boolean validatorsLoaded = false; TypeValidator typeValidator = null; List validators = null; - return new JsonSchema( + return new Schema( /* Below from JsonSchema */ validators, validatorsLoaded, @@ -352,7 +352,7 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref evaluationParentSchema, /* errorMessage */ null); } - public JsonSchema withConfig(SchemaValidatorsConfig config) { + public Schema withConfig(SchemaValidatorsConfig config) { if (this.getValidationContext().getMetaSchema().getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { config = SchemaValidatorsConfig.builder(config) @@ -369,7 +369,7 @@ public JsonSchema withConfig(SchemaValidatorsConfig config) { boolean validatorsLoaded = false; TypeValidator typeValidator = null; List validators = null; - return new JsonSchema( + return new Schema( /* Below from JsonSchema */ validators, validatorsLoaded, @@ -401,7 +401,7 @@ public ValidationContext getValidationContext() { * @return JsonNode */ public JsonNode getRefSchemaNode(String ref) { - JsonSchema schema = findSchemaResourceRoot(); + Schema schema = findSchemaResourceRoot(); JsonNode node = schema.getSchemaNode(); String jsonPointer = ref; @@ -428,7 +428,7 @@ public JsonNode getRefSchemaNode(String ref) { return node; } - public JsonSchema getRefSchema(JsonNodePath fragment) { + public Schema getRefSchema(JsonNodePath fragment) { if (PathType.JSON_POINTER.equals(fragment.getPathType())) { // Json Pointer return getSubSchema(fragment); @@ -436,7 +436,7 @@ public JsonSchema getRefSchema(JsonNodePath fragment) { // Anchor String base = this.getSchemaLocation().getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() : ""; String anchor = base + "#" + fragment; - JsonSchema result = this.validationContext.getSchemaResources().get(anchor); + Schema result = this.validationContext.getSchemaResources().get(anchor); if (result == null) { result = this.validationContext.getDynamicAnchors().get(anchor); } @@ -453,10 +453,10 @@ public JsonSchema getRefSchema(JsonNodePath fragment) { * @param fragment the json pointer fragment * @return the schema */ - public JsonSchema getSubSchema(JsonNodePath fragment) { - JsonSchema document = findSchemaResourceRoot(); - JsonSchema parent = document; - JsonSchema subSchema = null; + public Schema getSubSchema(JsonNodePath fragment) { + Schema document = findSchemaResourceRoot(); + Schema parent = document; + Schema subSchema = null; JsonNode parentNode = parent.getSchemaNode(); SchemaLocation schemaLocation = document.getSchemaLocation(); JsonNodePath evaluationPath = document.getEvaluationPath(); @@ -504,7 +504,7 @@ public JsonSchema getSubSchema(JsonNodePath fragment) { * * See test for draft4\extra\classpath\schema.json */ - JsonSchema found = document.findSchemaResourceRoot().fetchSubSchemaNode(this.validationContext); + Schema found = document.findSchemaResourceRoot().fetchSubSchemaNode(this.validationContext); if (found != null) { found = found.getSubSchema(fragment); } @@ -532,8 +532,8 @@ protected JsonNode getNode(JsonNode node, Object propertyOrIndex) { return JsonNodes.get(node, propertyOrIndex); } - public JsonSchema findLexicalRoot() { - JsonSchema ancestor = this; + public Schema findLexicalRoot() { + Schema ancestor = this; while (ancestor.getId() == null) { if (null == ancestor.getParentSchema()) break; ancestor = ancestor.getParentSchema(); @@ -548,8 +548,8 @@ public JsonSchema findLexicalRoot() { * * @return the root of the schema */ - public JsonSchema findSchemaResourceRoot() { - JsonSchema ancestor = this; + public Schema findSchemaResourceRoot() { + Schema ancestor = this; while (!ancestor.isSchemaResourceRoot()) { ancestor = ancestor.getParentSchema(); } @@ -579,16 +579,16 @@ public String getId() { return this.id; } - public JsonSchema findAncestor() { - JsonSchema ancestor = this; + public Schema findAncestor() { + Schema ancestor = this; if (this.getParentSchema() != null) { ancestor = this.getParentSchema().findAncestor(); } return ancestor; } - private JsonNode handleNullNode(String ref, JsonSchema schema) { - JsonSchema subSchema = schema.fetchSubSchemaNode(this.validationContext); + private JsonNode handleNullNode(String ref, Schema schema) { + Schema subSchema = schema.fetchSubSchemaNode(this.validationContext); if (subSchema != null) { return subSchema.getRefSchemaNode(ref); } @@ -1401,12 +1401,12 @@ public List getValidators() { } /** - * Initializes the validators' {@link com.networknt.schema.JsonSchema} instances. - * For avoiding issues with concurrency, in 1.0.49 the {@link com.networknt.schema.JsonSchema} instances affiliated with + * Initializes the validators' {@link com.networknt.schema.Schema} instances. + * For avoiding issues with concurrency, in 1.0.49 the {@link com.networknt.schema.Schema} instances affiliated with * validators were modified to no more preload the schema and lazy loading is used instead. *

This comes with the issue that this way you cannot rely on validating important schema features, in particular * $ref resolution at instantiation from {@link com.networknt.schema.JsonSchemaFactory}.

- *

By calling initializeValidators you can enforce preloading of the {@link com.networknt.schema.JsonSchema} + *

By calling initializeValidators you can enforce preloading of the {@link com.networknt.schema.Schema} * instances of the validators.

*/ public void initializeValidators() { diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index c0a874f77..b636a1c67 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -29,9 +29,9 @@ public class ValidationContext { private final Dialect dialect; private final JsonSchemaFactory jsonSchemaFactory; private final SchemaValidatorsConfig config; - private final ConcurrentMap schemaReferences; - private final ConcurrentMap schemaResources; - private final ConcurrentMap dynamicAnchors; + private final ConcurrentMap schemaReferences; + private final ConcurrentMap schemaResources; + private final ConcurrentMap dynamicAnchors; public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config) { @@ -39,8 +39,8 @@ public ValidationContext(Dialect dialect, } public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, - SchemaValidatorsConfig config, ConcurrentMap schemaReferences, - ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { + SchemaValidatorsConfig config, ConcurrentMap schemaReferences, + ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { if (dialect == null) { throw new IllegalArgumentException("JsonMetaSchema must not be null"); } @@ -56,12 +56,12 @@ public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, this.dynamicAnchors = dynamicAnchors; } - public JsonSchema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema) { + public Schema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { return getJsonSchemaFactory().create(this, schemaLocation, evaluationPath, schemaNode, parentSchema); } public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, - String keyword /* keyword */, JsonNode schemaNode, JsonSchema parentSchema) { + String keyword /* keyword */, JsonNode schemaNode, Schema parentSchema) { return this.dialect.newValidator(this, schemaLocation, evaluationPath, keyword, schemaNode, parentSchema); } @@ -82,7 +82,7 @@ public SchemaValidatorsConfig getConfig() { * * @return the schema references */ - public ConcurrentMap getSchemaReferences() { + public ConcurrentMap getSchemaReferences() { return this.schemaReferences; } @@ -91,7 +91,7 @@ public ConcurrentMap getSchemaReferences() { * * @return the schema resources */ - public ConcurrentMap getSchemaResources() { + public ConcurrentMap getSchemaResources() { return this.schemaResources; } @@ -100,7 +100,7 @@ public ConcurrentMap getSchemaResources() { * * @return the dynamic anchors */ - public ConcurrentMap getDynamicAnchors() { + public ConcurrentMap getDynamicAnchors() { return this.dynamicAnchors; } diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index ddb06c3d8..c46ca1c00 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; @@ -55,7 +55,7 @@ protected Dialect loadDialect(String iri, JsonSchemaFactory schemaFactory, Schem protected Dialect.Builder loadDialectBuilder(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { - JsonSchema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); + Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getMetaSchema()); Version specification = schema.getValidationContext().getMetaSchema().getSpecification(); if (specification != null) { diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 0e6683490..beb072fb4 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -21,7 +21,7 @@ import com.networknt.schema.Format; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; @@ -446,7 +446,7 @@ public Version getSpecification() { * @return the validator */ public KeywordValidator newValidator(ValidationContext validationContext, SchemaLocation schemaLocation, - JsonNodePath evaluationPath, String keyword, JsonNode schemaNode, JsonSchema parentSchema) { + JsonNodePath evaluationPath, String keyword, JsonNode schemaNode, Schema parentSchema) { try { Keyword kw = this.keywords.get(keyword); if (kw == null) { diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index ff373bc98..9427a2ddb 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.Specification.Version; @@ -16,7 +16,7 @@ public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, Keyword keyword, + Schema parentSchema, Keyword keyword, ValidationContext validationContext) { super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); Version dialect = this.validationContext.getMetaSchema().getSpecification(); diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index b2ab75a8c..fa2cdb32f 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -44,13 +44,13 @@ public class AdditionalPropertiesValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AdditionalPropertiesValidator.class); private final boolean allowAdditionalProperties; - private final JsonSchema additionalPropertiesSchema; + private final Schema additionalPropertiesSchema; private final Set allowedProperties; private final List patternProperties; private Boolean hasUnevaluatedPropertiesValidator; - public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, + public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isBoolean()) { diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index d2a6080ab..f08b2eff7 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -39,9 +39,9 @@ public class AllOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AllOfValidator.class); - private final List schemas; + private final List schemas; - public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); @@ -67,7 +67,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { debug(logger, executionContext, node, rootNode, instanceLocation); - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); } else { @@ -93,7 +93,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo final String discriminatorPropertyValue = discriminatorNode == null ? null : discriminatorNode.textValue(); - final JsonSchema jsonSchema = this.parentSchema; + final Schema jsonSchema = this.parentSchema; DiscriminatorValidator.checkDiscriminatorMatch(currentDiscriminatorContext, discriminator, discriminatorPropertyValue, jsonSchema); } @@ -110,7 +110,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root validate(executionContext, node, rootNode, instanceLocation, true); return; } - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { // Walk through the schema schema.walk(executionContext, node, rootNode, instanceLocation, false); } diff --git a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java index 61e04643f..b4ff720c4 100644 --- a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -30,7 +30,7 @@ public class AnnotationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext, Keyword keyword) { + Schema parentSchema, ValidationContext validationContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); } @@ -63,7 +63,7 @@ public AnnotationKeyword(String keyword) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); } } diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 547bd163f..1f33c54d9 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -40,11 +40,11 @@ public class AnyOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(AnyOfValidator.class); private static final String DISCRIMINATOR_REMARK = "and the discriminator-selected candidate schema didn't pass validation"; - private final List schemas; + private final List schemas; private Boolean canShortCircuit = null; - public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); @@ -85,7 +85,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo boolean failFast = executionContext.isFailFast(); try { executionContext.setFailFast(false); - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { errors.clear(); TypeValidator typeValidator = schema.getTypeValidator(); if (typeValidator != null) { @@ -185,7 +185,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root validate(executionContext, node, rootNode, instanceLocation, true); return; } - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { schema.walk(executionContext, node, rootNode, instanceLocation, false); } } diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 6257adadc..eccc5b7b5 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ErrorMessages; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -36,13 +36,13 @@ public abstract class BaseKeywordValidator extends AbstractKeywordValidator { protected final ValidationContext validationContext; - protected final JsonSchema parentSchema; + protected final Schema parentSchema; protected final Map errorMessage; - protected final JsonSchema evaluationParentSchema; + protected final Schema evaluationParentSchema; public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, - JsonSchema parentSchema, ValidationContext validationContext, + Schema parentSchema, ValidationContext validationContext, JsonNodePath evaluationPath) { super(keyword, schemaNode, schemaLocation, evaluationPath); this.validationContext = validationContext; @@ -73,9 +73,9 @@ protected BaseKeywordValidator( JsonNode schemaNode, SchemaLocation schemaLocation, ValidationContext validationContext, - JsonSchema parentSchema, + Schema parentSchema, JsonNodePath evaluationPath, - JsonSchema evaluationParentSchema, + Schema evaluationParentSchema, Map errorMessage) { super(keyword, schemaNode, schemaLocation, evaluationPath); this.validationContext = validationContext; @@ -116,7 +116,7 @@ public static void debug(Logger logger, ExecutionContext executionContext, JsonN * * @return the parent schema */ - public JsonSchema getParentSchema() { + public Schema getParentSchema() { return this.parentSchema; } @@ -125,10 +125,10 @@ public JsonSchema getParentSchema() { *

* This is the dynamic parent schema when following references. * - * @see JsonSchema#fromRef(JsonSchema, JsonNodePath) + * @see Schema#fromRef(Schema, JsonNodePath) * @return the evaluation parent schema */ - public JsonSchema getEvaluationParentSchema() { + public Schema getEvaluationParentSchema() { if (this.evaluationParentSchema != null) { return this.evaluationParentSchema; } @@ -143,8 +143,8 @@ protected String getNodeFieldType() { return null; } - protected void preloadJsonSchemas(final Collection schemas) { - for (final JsonSchema schema : schemas) { + protected void preloadJsonSchemas(final Collection schemas) { + for (final Schema schema : schemas) { schema.initializeValidators(); } } @@ -163,7 +163,7 @@ protected void preloadJsonSchemas(final Collection schemas) { * @return true if found */ protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { - JsonSchema schema = getEvaluationParentSchema(); + Schema schema = getEvaluationParentSchema(); while (schema != null) { for (KeywordValidator validator : schema.getValidators()) { if (keyword.equals(validator.getKeyword())) { diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index f8e828eb5..1f2b00f34 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -32,7 +32,7 @@ public class ConstValidator extends BaseKeywordValidator implements KeywordValid private static final Logger logger = LoggerFactory.getLogger(ConstValidator.class); public ConstValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 6a8d3146e..d951b4509 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -43,7 +43,7 @@ public class ContainsValidator extends BaseKeywordValidator { private static final String CONTAINS_MAX = "contains.max"; private static final String CONTAINS_MIN = "contains.min"; - private final JsonSchema schema; + private final Schema schema; private final boolean isMinV201909; private final Integer min; @@ -51,7 +51,7 @@ public class ContainsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first @@ -186,7 +186,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void preloadJsonSchema() { - Optional.ofNullable(this.schema).ifPresent(JsonSchema::initializeValidators); + Optional.ofNullable(this.schema).ifPresent(Schema::initializeValidators); collectAnnotations(); // cache the flag } diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 12a868c96..6c496f67d 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -50,7 +50,7 @@ public class ContentEncodingValidator extends BaseKeywordValidator { * @param validationContext the validation context */ public ContentEncodingValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.contentEncoding = schemaNode.textValue(); diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 775091452..b44098ece 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -55,7 +55,7 @@ public class ContentMediaTypeValidator extends BaseKeywordValidator { * @param validationContext the validation context */ public ContentMediaTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 73824d975..6e4fd87c0 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ public class DependenciesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DependenciesValidator.class); private final Map> propertyDeps = new HashMap<>(); - private final Map schemaDeps = new HashMap<>(); + private final Map schemaDeps = new HashMap<>(); /** * Constructor. @@ -45,7 +45,7 @@ public class DependenciesValidator extends BaseKeywordValidator implements Keywo * @param parentSchema the parent schema * @param validationContext the validation context */ - public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); @@ -83,7 +83,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } } } - JsonSchema schema = schemaDeps.get(pname); + Schema schema = schemaDeps.get(pname); if (schema != null) { schema.validate(executionContext, node, rootNode, instanceLocation); } diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 1beb00dd8..e1bf2b220 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -35,7 +35,7 @@ public class DependentRequired extends BaseKeywordValidator implements KeywordVa private static final Logger logger = LoggerFactory.getLogger(DependentRequired.class); private final Map> propertyDependencies = new HashMap<>(); - public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 944e4c9ea..37b58fee3 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -33,9 +33,9 @@ */ public class DependentSchemas extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(DependentSchemas.class); - private final Map schemaDependencies = new HashMap<>(); + private final Map schemaDependencies = new HashMap<>(); - public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); @@ -61,7 +61,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); - JsonSchema schema = this.schemaDependencies.get(pname); + Schema schema = this.schemaDependencies.get(pname); if (schema != null) { if(!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); @@ -83,7 +83,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root validate(executionContext, node, rootNode, instanceLocation, true); return; } - for (JsonSchema schema : this.schemaDependencies.values()) { + for (Schema schema : this.schemaDependencies.values()) { schema.walk(executionContext, node, rootNode, instanceLocation, false); } } diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index d03bd0951..cd112a005 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -27,7 +27,7 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -40,7 +40,7 @@ public class DiscriminatorValidator extends BaseKeywordValidator { private final Map mapping; public DiscriminatorValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; @@ -89,18 +89,18 @@ public Map getMapping() { } /** - * Checks based on the current {@link DiscriminatorContext} whether the provided {@link JsonSchema} a match against + * Checks based on the current {@link DiscriminatorContext} whether the provided {@link Schema} a match against * the current discriminator. * * @param currentDiscriminatorContext the currently active {@link DiscriminatorContext} * @param discriminator the discriminator to use for the check * @param discriminatorPropertyValue the value of the discriminator/propertyName field - * @param jsonSchema the {@link JsonSchema} to check + * @param jsonSchema the {@link Schema} to check */ public static void checkDiscriminatorMatch(final DiscriminatorContext currentDiscriminatorContext, final ObjectNode discriminator, final String discriminatorPropertyValue, - final JsonSchema jsonSchema) { + final Schema jsonSchema) { if (discriminatorPropertyValue == null) { currentDiscriminatorContext.markIgnore(); return; @@ -136,7 +136,7 @@ && noExplicitDiscriminatorKeyOverride(discriminatorMapping, jsonSchema)) { */ public static void registerAndMergeDiscriminator(final DiscriminatorContext currentDiscriminatorContext, final ObjectNode discriminator, - final JsonSchema schema, + final Schema schema, final JsonNodePath instanceLocation) { final JsonNode discriminatorOnSchema = schema.getSchemaNode().get("discriminator"); if (null != discriminatorOnSchema && null != currentDiscriminatorContext @@ -176,7 +176,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr private static void checkForImplicitDiscriminatorMappingMatch(final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, - final JsonSchema schema) { + final Schema schema) { if (schema.getSchemaLocation().getFragment().getName(-1).equals(discriminatorPropertyValue)) { currentDiscriminatorContext.markMatch(); } @@ -185,7 +185,7 @@ private static void checkForImplicitDiscriminatorMappingMatch(final Discriminato private static void checkForExplicitDiscriminatorMappingMatch(final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, final JsonNode discriminatorMapping, - final JsonSchema schema) { + final Schema schema) { final Iterator> explicitMappings = discriminatorMapping.fields(); while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); @@ -199,7 +199,7 @@ private static void checkForExplicitDiscriminatorMappingMatch(final Discriminato } private static boolean noExplicitDiscriminatorKeyOverride(final JsonNode discriminatorMapping, - final JsonSchema parentSchema) { + final Schema parentSchema) { final Iterator> explicitMappings = discriminatorMapping.fields(); while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index a5462464f..5200e7230 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; @@ -41,17 +41,17 @@ public class DynamicRefValidator extends BaseKeywordValidator { protected final JsonSchemaRef schema; - public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, JsonNodePath evaluationPath) { String ref = resolve(parentSchema, refValue); return new JsonSchemaRef(getSupplier(() -> { - JsonSchema refSchema = validationContext.getDynamicAnchors().get(ref); + Schema refSchema = validationContext.getDynamicAnchors().get(ref); if (refSchema == null) { // This is a $dynamicRef without a matching $dynamicAnchor // A $dynamicRef without a matching $dynamicAnchor in the same schema resource // behaves like a normal $ref to $anchor @@ -62,7 +62,7 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val } } else { // Check parents - JsonSchema base = parentSchema; + Schema base = parentSchema; int index = ref.indexOf("#"); String anchor = ref.substring(index); String absoluteIri = ref.substring(0, index); @@ -72,7 +72,7 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val if (!baseAbsoluteIri.equals(absoluteIri)) { absoluteIri = baseAbsoluteIri; String parentRef = SchemaLocation.resolve(base.getSchemaLocation(), anchor); - JsonSchema parentRefSchema = validationContext.getDynamicAnchors().get(parentRef); + Schema parentRefSchema = validationContext.getDynamicAnchors().get(parentRef); if (parentRefSchema != null) { refSchema = parentRefSchema; } @@ -91,9 +91,9 @@ static Supplier getSupplier(Supplier supplier, boolean cache) { return cache ? new CachedSupplier<>(supplier) : supplier; } - private static String resolve(JsonSchema parentSchema, String refValue) { + private static String resolve(Schema parentSchema, String refValue) { // $ref prevents a sibling $id from changing the base uri - JsonSchema base = parentSchema; + Schema base = parentSchema; if (parentSchema.getId() != null && parentSchema.getParentSchema() != null) { base = parentSchema.getParentSchema(); } @@ -103,7 +103,7 @@ private static String resolve(JsonSchema parentSchema, String refValue) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -120,7 +120,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -131,7 +131,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (node == null) { // Check for circular dependency SchemaLocation schemaLocation = refSchema.getSchemaLocation(); - JsonSchema check = refSchema; + Schema check = refSchema; boolean circularDependency = false; while (check.getEvaluationParentSchema() != null) { check = check.getEvaluationParentSchema(); @@ -153,7 +153,7 @@ public JsonSchemaRef getSchemaRef() { @Override public void preloadJsonSchema() { - JsonSchema jsonSchema = null; + Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); } catch (JsonSchemaException e) { @@ -166,7 +166,7 @@ public void preloadJsonSchema() { // The rest of the cycles will load at execution time depending on the input // data SchemaLocation schemaLocation = jsonSchema.getSchemaLocation(); - JsonSchema check = jsonSchema; + Schema check = jsonSchema; boolean circularDependency = false; int depth = 0; while (check.getEvaluationParentSchema() != null) { diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 48e4d6d94..5639a40f7 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.node.NullNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -53,7 +53,7 @@ static String asText(JsonNode node) { return node.asText(); } - public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 7f64cce96..55736dfc9 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -41,7 +41,7 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMaximum value is not a number"); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 346f0effe..ae78c6c76 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -45,7 +45,7 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMinimum value is not a number"); diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index fc3b583c0..0b3b2a299 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -33,7 +33,7 @@ public class FalseValidator extends BaseKeywordValidator implements KeywordValid private final String reason; - public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 62d43924f..47f954fbb 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Format; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -52,7 +52,7 @@ Collection getFormats() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { Format format = null; if (schemaNode != null && schemaNode.isTextual()) { String formatName = schemaNode.textValue(); diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index 6d8e9faf2..08957f8af 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Format; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.format.BaseFormatJsonValidator; @@ -39,7 +39,7 @@ public class FormatValidator extends BaseFormatJsonValidator implements KeywordV private final Format format; public FormatValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext, Format format, + Schema parentSchema, ValidationContext validationContext, Format format, Keyword keyword) { super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); this.format = format; diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 9f422686b..ded4720f8 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -37,16 +37,16 @@ public class IfValidator extends BaseKeywordValidator { private static final List KEYWORDS = Arrays.asList("if", "then", "else"); - private final JsonSchema ifSchema; - private final JsonSchema thenSchema; - private final JsonSchema elseSchema; + private final Schema ifSchema; + private final Schema thenSchema; + private final Schema elseSchema; - public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - JsonSchema foundIfSchema = null; - JsonSchema foundThenSchema = null; - JsonSchema foundElseSchema = null; + Schema foundIfSchema = null; + Schema foundThenSchema = null; + Schema foundElseSchema = null; for (final String keyword : KEYWORDS) { final JsonNode node = parentSchema.getSchemaNode().get(keyword); diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 5c43a456f..6f12e1e95 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -39,10 +39,10 @@ public class ItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ItemsValidator.class); private static final String PROPERTY_ADDITIONAL_ITEMS = "additionalItems"; - private final JsonSchema schema; - private final List tupleSchema; + private final Schema schema; + private final List tupleSchema; private final Boolean additionalItems; - private final JsonSchema additionalSchema; + private final Schema additionalSchema; private Boolean hasUnevaluatedItemsValidator = null; @@ -50,13 +50,13 @@ public class ItemsValidator extends BaseKeywordValidator { private final SchemaLocation additionalItemsSchemaLocation; private final JsonNode additionalItemsSchemaNode; - public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); Boolean additionalItems = null; - JsonSchema foundSchema = null; - JsonSchema foundAdditionalSchema = null; + Schema foundSchema = null; + Schema foundAdditionalSchema = null; JsonNode additionalItemsSchemaNode = null; if (schemaNode.isObject() || schemaNode.isBoolean()) { @@ -320,7 +320,7 @@ else if (this.tupleSchema != null) { } } - private static JsonNode getDefaultNode(JsonSchema schema) { + private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); @@ -331,7 +331,7 @@ private static JsonNode getDefaultNode(JsonSchema schema) { return result; } - private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema, JsonNode node, JsonNode rootNode, + private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, String keyword) { boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, node, rootNode, instanceLocation, walkSchema, this); @@ -344,11 +344,11 @@ private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema } - public List getTupleSchema() { + public List getTupleSchema() { return this.tupleSchema; } - public JsonSchema getSchema() { + public Schema getSchema() { return this.schema; } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 83033a2eb..bfb2366fb 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -36,14 +36,14 @@ public class ItemsValidator202012 extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ItemsValidator202012.class); - private final JsonSchema schema; + private final Schema schema; private final int prefixCount; private final boolean additionalItems; private Boolean hasUnevaluatedItemsValidator = null; public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); @@ -140,7 +140,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } } - private static JsonNode getDefaultNode(JsonSchema schema) { + private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); @@ -151,7 +151,7 @@ private static JsonNode getDefaultNode(JsonSchema schema) { return result; } - private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema, JsonNode node, JsonNode rootNode, + private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( @@ -178,7 +178,7 @@ private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema //@formatter:on } - public JsonSchema getSchema() { + public Schema getSchema() { return this.schema; } diff --git a/src/main/java/com/networknt/schema/keyword/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java index 62989e17e..598359279 100644 --- a/src/main/java/com/networknt/schema/keyword/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -47,5 +47,5 @@ public interface Keyword { * @throws Exception the exception */ KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception; + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception; } diff --git a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java index 0727f7896..632f4860a 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java @@ -24,10 +24,10 @@ */ public interface KeywordValidator extends Validator { /** - * In case the {@link com.networknt.schema.keyword.KeywordValidator} has a related {@link com.networknt.schema.JsonSchema} or several + * In case the {@link com.networknt.schema.keyword.KeywordValidator} has a related {@link com.networknt.schema.Schema} or several * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. * - * @throws JsonSchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.JsonSchema} or nested schemas + * @throws JsonSchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.Schema} or nested schemas * are invalid (like $ref not resolving) * @since 1.0.54 */ diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index a23fc4fa4..88ee59e3b 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -35,7 +35,7 @@ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordVa private final int max; - public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 70fd7a1ec..6bf510ba7 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -36,7 +36,7 @@ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordV private final int maxLength; - public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index 21e5ab879..70e7d3036 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ public class MaxPropertiesValidator extends BaseKeywordValidator implements Keyw private final int max; - public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, + public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index a389fd177..106ea1596 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -45,7 +45,7 @@ public class MaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("maximum value is not a number"); diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index e076b7919..d8bab517e 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ public class MinItemsValidator extends BaseKeywordValidator implements KeywordVa private int min = 0; - public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index eac2b9b4d..c5dbb873f 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -36,7 +36,7 @@ public class MinLengthValidator extends BaseKeywordValidator implements KeywordV private int minLength; - public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 7a9881bc2..bef4f7f2d 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -20,7 +20,7 @@ public class MinMaxContainsValidator extends BaseKeywordValidator { private final Set analysis; - public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, + public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index 5d1428959..25db5aaf7 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ public class MinPropertiesValidator extends BaseKeywordValidator implements Keyw protected final int min; - public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, + public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index c84f2f019..3fa1c8c2a 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -48,7 +48,7 @@ public class MinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isNumber()) { diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index a682b5116..31168fa28 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; @@ -38,7 +38,7 @@ public class MultipleOfValidator extends BaseKeywordValidator implements Keyword private final BigDecimal divisor; public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.divisor = getDivisor(schemaNode); } diff --git a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index 91e2118f7..bb00e6d68 100644 --- a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -33,7 +33,7 @@ public class NonValidationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext, Keyword keyword) { + Schema parentSchema, ValidationContext validationContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); String id = validationContext.resolveSchemaId(schemaNode); String anchor = validationContext.getMetaSchema().readAnchor(schemaNode); @@ -46,7 +46,7 @@ public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, Jso for (Iterator> field = schemaNode.fields(); field.hasNext(); ) { Entry property = field.next(); SchemaLocation location = schemaLocation.append(property.getKey()); - JsonSchema schema = validationContext.newSchema(location, evaluationPath.append(property.getKey()), + Schema schema = validationContext.newSchema(location, evaluationPath.append(property.getKey()), property.getValue(), parentSchema); validationContext.getSchemaReferences().put(location.toString(), schema); } @@ -65,7 +65,7 @@ public NonValidationKeyword(String keyword) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); } } diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index dae77ee8b..db5eb4300 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -36,7 +36,7 @@ public class NotAllowedValidator extends BaseKeywordValidator implements Keyword private final List fieldNames; - public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index cc6a3eb44..005f591fc 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -35,9 +35,9 @@ public class NotValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(NotValidator.class); - private final JsonSchema schema; + private final Schema schema; - public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 879930f65..da73571e5 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -28,7 +28,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -41,11 +41,11 @@ public class OneOfValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(OneOfValidator.class); - private final List schemas; + private final List schemas; private Boolean canShortCircuit = null; - public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); @@ -98,7 +98,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } } executionContext.setFailFast(false); - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { schemaErrors.clear(); if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); @@ -237,7 +237,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); } else { - for (JsonSchema schema : this.schemas) { + for (Schema schema : this.schemas) { schema.walk(executionContext, node, rootNode, instanceLocation, false); } } @@ -245,7 +245,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root @Override public void preloadJsonSchema() { - for (JsonSchema schema: this.schemas) { + for (Schema schema: this.schemas) { schema.initializeValidators(); } canShortCircuit(); // cache the flag diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 11dea453e..d1ba77232 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -36,11 +36,11 @@ public class PatternPropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "patternProperties"; private static final Logger logger = LoggerFactory.getLogger(PatternPropertiesValidator.class); - private final Map schemas = new IdentityHashMap<>(); + private final Map schemas = new IdentityHashMap<>(); private Boolean hasUnevaluatedPropertiesValidator = null; - public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, + public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isObject()) { @@ -67,7 +67,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode while (names.hasNext()) { String name = names.next(); JsonNode n = node.get(name); - for (Map.Entry entry : schemas.entrySet()) { + for (Map.Entry entry : schemas.entrySet()) { if (entry.getKey().matches(name)) { JsonNodePath path = instanceLocation.append(name); int currentErrors = executionContext.getErrors().size(); diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index e2831ca2e..4298ef28c 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.FailFastAssertionException; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -37,7 +37,7 @@ public class PatternValidator extends BaseKeywordValidator { private final String pattern; private final RegularExpression compiledPattern; - public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index be4113dc7..156982678 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -39,11 +39,11 @@ public class PrefixItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PrefixItemsValidator.class); - private final List tupleSchema; + private final List tupleSchema; private Boolean hasUnevaluatedItemsValidator = null; - public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { @@ -139,7 +139,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } } - private static JsonNode getDefaultNode(JsonSchema schema) { + private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); @@ -156,7 +156,7 @@ private void doWalk(ExecutionContext executionContext, int i, shouldValidateSchema); } - private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema, JsonNode node, JsonNode rootNode, + private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( @@ -183,7 +183,7 @@ private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema //@formatter:on } - public List getTupleSchema() { + public List getTupleSchema() { return this.tupleSchema; } diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 6042d744d..977530afe 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -46,11 +46,11 @@ public class PropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "properties"; private static final Logger logger = LoggerFactory.getLogger(PropertiesValidator.class); - private final Map schemas = new LinkedHashMap<>(); + private final Map schemas = new LinkedHashMap<>(); private Boolean hasUnevaluatedPropertiesValidator; - public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); @@ -72,7 +72,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo Set matchedInstancePropertyNames = null; boolean collectAnnotations = collectAnnotations() || collectAnnotations(executionContext); - for (Entry entry : this.schemas.entrySet()) { + for (Entry entry : this.schemas.entrySet()) { JsonNode propertyNode = node.get(entry.getKey()); if (propertyNode != null) { JsonNodePath path = instanceLocation.append(entry.getKey()); @@ -121,7 +121,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root instanceLocation, true); } else { WalkListenerRunner propertyWalkListenerRunner = this.validationContext.getConfig().getPropertyWalkListenerRunner(); - for (Map.Entry entry : this.schemas.entrySet()) { + for (Map.Entry entry : this.schemas.entrySet()) { walkSchema(executionContext, entry, node, rootNode, instanceLocation, shouldValidateSchema, propertyWalkListenerRunner); } } @@ -139,7 +139,7 @@ private boolean hasUnevaluatedPropertiesValidator() { } private void applyPropertyDefaults(ObjectNode node) { - for (Map.Entry entry : this.schemas.entrySet()) { + for (Map.Entry entry : this.schemas.entrySet()) { JsonNode propertyNode = node.get(entry.getKey()); JsonNode defaultNode = getDefaultNode(entry.getValue()); @@ -154,7 +154,7 @@ private void applyPropertyDefaults(ObjectNode node) { } } - private static JsonNode getDefaultNode(JsonSchema schema) { + private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); @@ -165,9 +165,9 @@ private static JsonNode getDefaultNode(JsonSchema schema) { return result; } - private void walkSchema(ExecutionContext executionContext, Map.Entry entry, JsonNode node, + private void walkSchema(ExecutionContext executionContext, Map.Entry entry, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, WalkListenerRunner propertyWalkListenerRunner) { - JsonSchema propertySchema = entry.getValue(); + Schema propertySchema = entry.getValue(); JsonNode propertyNode = (node == null ? null : node.get(entry.getKey())); JsonNodePath path = instanceLocation.append(entry.getKey()); boolean executeWalk = propertyWalkListenerRunner.runPreWalkListeners(executionContext, @@ -186,7 +186,7 @@ private void walkSchema(ExecutionContext executionContext, Map.Entry getSchemas() { + public Map getSchemas() { return this.schemas; } diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index ce07bf892..549ca1ed9 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -27,14 +27,14 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(PropertyNamesValidator.class); - private final JsonSchema innerSchema; - public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + private final Schema innerSchema; + public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); innerSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index 0e3ebfba4..06de6b57c 100644 --- a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ public class ReadOnlyValidator extends BaseKeywordValidator { private final boolean readOnly; - public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.readOnly = validationContext.getConfig().isReadOnly(); diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 6962720a2..3a3592099 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; @@ -41,7 +41,7 @@ public class RecursiveRefValidator extends BaseKeywordValidator { protected final JsonSchemaRef schema; - public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); @@ -56,7 +56,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, JsonNodePath evaluationPath) { return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, validationContext, refValue, evaluationPath), validationContext.getConfig().isCacheRefs())); } @@ -65,11 +65,11 @@ static Supplier getSupplier(Supplier supplier, boolean cache) { return cache ? new CachedSupplier<>(supplier) : supplier; } - static JsonSchema getSchema(JsonSchema parentSchema, ValidationContext validationContext, String refValue, + static Schema getSchema(Schema parentSchema, ValidationContext validationContext, String refValue, JsonNodePath evaluationPath) { - JsonSchema refSchema = parentSchema.findSchemaResourceRoot(); // Get the document - JsonSchema current = refSchema; - JsonSchema check = null; + Schema refSchema = parentSchema.findSchemaResourceRoot(); // Get the document + Schema current = refSchema; + Schema check = null; String base = null; String baseCheck = null; if (refSchema != null) @@ -98,7 +98,7 @@ static JsonSchema getSchema(JsonSchema parentSchema, ValidationContext validatio @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -115,7 +115,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -126,7 +126,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (node == null) { // Check for circular dependency SchemaLocation schemaLocation = refSchema.getSchemaLocation(); - JsonSchema check = refSchema; + Schema check = refSchema; boolean circularDependency = false; while (check.getEvaluationParentSchema() != null) { check = check.getEvaluationParentSchema(); @@ -148,7 +148,7 @@ public JsonSchemaRef getSchemaRef() { @Override public void preloadJsonSchema() { - JsonSchema jsonSchema = null; + Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); } catch (JsonSchemaException e) { @@ -161,7 +161,7 @@ public void preloadJsonSchema() { // The rest of the cycles will load at execution time depending on the input // data SchemaLocation schemaLocation = jsonSchema.getSchemaLocation(); - JsonSchema check = jsonSchema; + Schema check = jsonSchema; boolean circularDependency = false; int depth = 0; while (check.getEvaluationParentSchema() != null) { diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 2a75a55fd..8f509f1e8 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; @@ -43,13 +43,13 @@ public class RefValidator extends BaseKeywordValidator { private static final String REF_CURRENT = "#"; - public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, JsonNodePath evaluationPath) { // The evaluationPath is used to derive the keywordLocation final String refValueOriginal = refValue; @@ -70,7 +70,7 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val SchemaLocation schemaLocation = SchemaLocation.of(schemaUriFinal); // This should retrieve schemas regardless of the protocol that is in the uri. return new JsonSchemaRef(getSupplier(() -> { - JsonSchema schemaResource = validationContext.getSchemaResources().get(schemaUriFinal); + Schema schemaResource = validationContext.getSchemaResources().get(schemaUriFinal); if (schemaResource == null) { schemaResource = validationContext.getJsonSchemaFactory().loadSchema(schemaLocation, validationContext.getConfig()); if (schemaResource != null) { @@ -85,7 +85,7 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val } else { String newRefValue = refValue.substring(index); String find = schemaLocation.getAbsoluteIri() + newRefValue; - JsonSchema findSchemaResource = validationContext.getSchemaResources().get(find); + Schema findSchemaResource = validationContext.getSchemaResources().get(find); if (findSchemaResource == null) { findSchemaResource = validationContext.getDynamicAnchors().get(find); } @@ -106,7 +106,7 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val String absoluteIri = resolve(parentSchema, refValue); // Schema resource needs to update the parent and evaluation path return new JsonSchemaRef(getSupplier(() -> { - JsonSchema schemaResource = validationContext.getSchemaResources().get(absoluteIri); + Schema schemaResource = validationContext.getSchemaResources().get(absoluteIri); if (schemaResource == null) { schemaResource = validationContext.getDynamicAnchors().get(absoluteIri); } @@ -134,7 +134,7 @@ static Supplier getSupplier(Supplier supplier, boolean cache) { return cache ? new CachedSupplier<>(supplier) : supplier; } - private static void copySchemaResources(ValidationContext validationContext, JsonSchema schemaResource) { + private static void copySchemaResources(ValidationContext validationContext, Schema schemaResource) { if (!schemaResource.getValidationContext().getSchemaResources().isEmpty()) { validationContext.getSchemaResources() .putAll(schemaResource.getValidationContext().getSchemaResources()); @@ -149,16 +149,16 @@ private static void copySchemaResources(ValidationContext validationContext, Jso } } - private static String resolve(JsonSchema parentSchema, String refValue) { + private static String resolve(Schema parentSchema, String refValue) { // $ref prevents a sibling $id from changing the base uri - JsonSchema base = parentSchema; + Schema base = parentSchema; if (parentSchema.getId() != null && parentSchema.getParentSchema() != null) { base = parentSchema.getParentSchema(); } return SchemaLocation.resolve(base.getSchemaLocation(), refValue); } - private static JsonSchema getJsonSchema(JsonSchema parent, + private static Schema getJsonSchema(Schema parent, ValidationContext validationContext, String refValue, String refValueOriginal, @@ -169,7 +169,7 @@ private static JsonSchema getJsonSchema(JsonSchema parent, // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. // The getSubSchema potentially recurses to call back to getJsonSchema again - JsonSchema result = validationContext.getSchemaReferences().get(schemaReference); + Schema result = validationContext.getSchemaReferences().get(schemaReference); if (result == null) { synchronized (validationContext.getJsonSchemaFactory()) { // acquire lock on shared factory object to prevent deadlock result = validationContext.getSchemaReferences().get(schemaReference); @@ -187,7 +187,7 @@ private static JsonSchema getJsonSchema(JsonSchema parent, @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, executionContext, node, rootNode, instanceLocation); - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -204,7 +204,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. - JsonSchema refSchema = this.schema.getSchema(); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") @@ -215,7 +215,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (node == null) { // Check for circular dependency SchemaLocation schemaLocation = refSchema.getSchemaLocation(); - JsonSchema check = refSchema; + Schema check = refSchema; boolean circularDependency = false; while (check.getEvaluationParentSchema() != null) { check = check.getEvaluationParentSchema(); @@ -237,7 +237,7 @@ public JsonSchemaRef getSchemaRef() { @Override public void preloadJsonSchema() { - JsonSchema jsonSchema = null; + Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); } catch (JsonSchemaException e) { @@ -250,7 +250,7 @@ public void preloadJsonSchema() { // The rest of the cycles will load at execution time depending on the input // data SchemaLocation schemaLocation = jsonSchema.getSchemaLocation(); - JsonSchema check = jsonSchema; + Schema check = jsonSchema; boolean circularDependency = false; int depth = 0; while (check.getEvaluationParentSchema() != null) { diff --git a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java index 283bca0af..cadd03958 100644 --- a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -36,7 +36,7 @@ public class RequiredValidator extends BaseKeywordValidator implements KeywordVa private final List fieldNames; - public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index ec41b30a1..448b61d08 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -31,7 +31,7 @@ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(TrueValidator.class); - public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index d5ca72dac..3ba3edc8e 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -37,7 +37,7 @@ public class TypeValidator extends BaseKeywordValidator { private final JsonType schemaType; private final UnionTypeValidator unionTypeValidator; - public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 890e3fd60..614ee45f7 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.Specification.Version; @@ -40,13 +40,13 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UnevaluatedItemsValidator.class); - private final JsonSchema schema; + private final Schema schema; private final boolean isMinV202012; private static final Version DEFAULT_VERSION = Version.DRAFT_2019_09; public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); isMinV202012 = MinV202012.getVersions().contains(validationContext.activeDialect().orElse(DEFAULT_VERSION)); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 3d7ab80c7..c18943764 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -37,9 +37,9 @@ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(UnevaluatedPropertiesValidator.class); - private final JsonSchema schema; + private final Schema schema; - public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 28f537089..8900ca994 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -43,7 +43,7 @@ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordV private final List schemas; private final String error; - public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); @@ -119,8 +119,8 @@ public void preloadJsonSchema() { for (final Validator validator : schemas) { if (validator instanceof KeywordValidator) { ((KeywordValidator) validator).preloadJsonSchema(); - } else if (validator instanceof JsonSchema) { - ((JsonSchema) validator).initializeValidators(); + } else if (validator instanceof Schema) { + ((Schema) validator).initializeValidators(); } } } diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index 408482bb0..fe84bd772 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -37,7 +37,7 @@ public class UniqueItemsValidator extends BaseKeywordValidator implements Keywor private final boolean unique; - public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index ed0ec75cc..7ce83b99b 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; import com.networknt.schema.ValidationContext; @@ -34,7 +34,7 @@ @FunctionalInterface interface ValidatorFactory { KeywordValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext); + Schema parentSchema, ValidationContext validationContext); } enum VersionCode { @@ -80,7 +80,7 @@ public enum ValidatorTypeCode implements Keyword { EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), FALSE("false", FalseValidator::new, VersionCode.MinV6), FORMAT("format", null, VersionCode.MaxV7) { - @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, @@ -158,7 +158,7 @@ public static ValidatorTypeCode fromValue(String value) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) { + Schema parentSchema, ValidationContext validationContext) { if (this.validatorFactory == null) { throw new UnsupportedOperationException("No suitable validator for " + getValue()); } diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index c25475693..5d8edb87c 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; @@ -18,7 +18,7 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private final boolean writeOnly; - public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.writeOnly = validationContext.getConfig().isWriteOnly(); diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index a197e7aee..c7f1e2bf0 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -28,7 +28,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.ValidationContext; import com.networknt.schema.Error; @@ -108,7 +108,7 @@ public static OutputUnit format(OutputUnit root, OutputUnitData data, JsonNodePa return root; } - public static OutputUnit format(JsonSchema jsonSchema, List errors, + public static OutputUnit format(Schema jsonSchema, List errors, ExecutionContext executionContext, ValidationContext validationContext, Function errorMapper) { OutputUnit root = new OutputUnit(); diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 19366f376..ae7398e10 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -4,7 +4,7 @@ import java.util.Collection; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.PathType; import com.networknt.schema.SchemaValidatorsConfig; @@ -65,7 +65,7 @@ public static boolean isNodeNullable(JsonNode schema, SchemaValidatorsConfig con return false; } - public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, JsonSchema parentSchema, ValidationContext validationContext) { + public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, ValidationContext validationContext) { SchemaValidatorsConfig config = validationContext.getConfig(); JsonType nodeType = TypeFactory.getValueNodeType(node, config); // in the case that node type is not the same as schema type, try to convert node to the @@ -85,7 +85,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Jso if (nodeType == JsonType.NULL) { if (parentSchema != null && config.isNullableKeywordEnabled()) { - JsonSchema grandParentSchema = parentSchema.getParentSchema(); + Schema grandParentSchema = parentSchema.getParentSchema(); if (grandParentSchema != null && JsonNodeUtil.isNodeNullable(grandParentSchema.getSchemaNode()) || JsonNodeUtil.isNodeNullable(parentSchema.getSchemaNode())) { return true; @@ -142,7 +142,7 @@ public static boolean isNumber(JsonNode node, SchemaValidatorsConfig config) { return false; } - private static boolean isEnumObjectSchema(JsonSchema jsonSchema) { + private static boolean isEnumObjectSchema(Schema jsonSchema) { // There are three conditions for enum object schema // 1. The current schema contains key "type", and the value is object // 2. The current schema contains key "enum", and the value is an array diff --git a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java index c8f54ebe9..279dcfc5f 100644 --- a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java +++ b/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java @@ -15,7 +15,7 @@ */ package com.networknt.schema.utils; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.keyword.DynamicRefValidator; import com.networknt.schema.keyword.KeywordValidator; @@ -33,7 +33,7 @@ public class JsonSchemaRefs { * @param schema the schema * @return the ref */ - public static JsonSchemaRef from(JsonSchema schema) { + public static JsonSchemaRef from(Schema schema) { for (KeywordValidator validator : schema.getValidators()) { if (validator instanceof RefValidator) { return ((RefValidator) validator).getSchemaRef(); diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index 23dc711fc..fe45f9276 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -12,7 +12,7 @@ public abstract class AbstractWalkListenerRunner implements WalkListenerRunner { protected WalkEvent constructWalkEvent(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { return WalkEvent.builder().executionContext(executionContext).instanceLocation(instanceLocation) .keyword(keyword).instanceNode(instanceNode) .rootNode(rootNode).schema(schema).validator(validator).build(); diff --git a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java index b56033e34..d562eacbc 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -19,7 +19,7 @@ public DefaultItemWalkListenerRunner(List itemWalkListen @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(itemWalkListeners, walkEvent); @@ -27,7 +27,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, List errors) { + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); runPostWalkListeners(itemWalkListeners, walkEvent, errors); diff --git a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java index 61ce47909..6b99c77e9 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java @@ -7,7 +7,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.keyword.KeywordValidator; @@ -21,7 +21,7 @@ public DefaultKeywordWalkListenerRunner(Map @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { + JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { boolean continueRunningListenersAndWalk = true; WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); // Run Listeners that are setup only for this keyword. @@ -38,7 +38,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); // Run Listeners that are setup only for this keyword. diff --git a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java index a1beda793..576b6fe35 100644 --- a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -19,14 +19,14 @@ public DefaultPropertyWalkListenerRunner(List propertyWa @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator) { + JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(propertyWalkListeners, walkEvent); } @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, JsonNodePath instanceLocation, - JsonSchema schema, KeywordValidator validator, List errors) { + Schema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); runPostWalkListeners(propertyWalkListeners, walkEvent, errors); diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index 47e47ce70..fa19b332f 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; /** @@ -12,7 +12,7 @@ public class WalkEvent { private ExecutionContext executionContext; - private JsonSchema schema; + private Schema schema; private String keyword; private JsonNode rootNode; private JsonNode instanceNode; @@ -38,7 +38,7 @@ public ExecutionContext getExecutionContext() { * * @return the schema */ - public JsonSchema getSchema() { + public Schema getSchema() { return schema; } @@ -110,7 +110,7 @@ public WalkEventBuilder executionContext(ExecutionContext executionContext) { return this; } - public WalkEventBuilder schema(JsonSchema schema) { + public WalkEventBuilder schema(Schema schema) { walkEvent.schema = schema; return this; } diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index 69a6cecc0..a534b0ef5 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -12,9 +12,9 @@ public interface WalkListenerRunner { boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator); + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator); void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, KeywordValidator validator, List errors); + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 6ee3bc172..99b49749c 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -40,7 +40,7 @@ protected void assertValidatorType(String filename, ValidatorTypeCode validatorT protected abstract String getDataTestFolder(); - private JsonSchema getJsonSchemaFromDataNode(JsonNode dataNode) { + private Schema getJsonSchemaFromDataNode(JsonNode dataNode) { return Optional.ofNullable(dataNode.get(SCHEMA)) .map(JsonNode::textValue) .map(this::getJsonNodeFromPath) @@ -58,7 +58,7 @@ private JsonNode getJsonNodeFromPath(String dataPath) { } } - private JsonSchema getJsonSchema(JsonNode schemaNode) { + private Schema getJsonSchema(JsonNode schemaNode) { return JsonSchemaFactory .getInstance(SpecificationVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) .getSchema(schemaNode); diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index b29e2810f..825e892e2 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -54,7 +54,7 @@ private static String toForwardSlashPath(Path file) { return file.toString().replace('\\', '/'); } - private static void executeTest(JsonSchema schema, TestSpec testSpec) { + private static void executeTest(Schema schema, TestSpec testSpec) { List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, validationContext) -> { if (testSpec.getTestCase().getSource().getPath().getParent().toString().endsWith("format")) { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); @@ -241,7 +241,7 @@ private DynamicNode buildTest(JsonSchemaFactory validatorFactory, TestSpec testS } } SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + toForwardSlashPath(testSpec.getTestCase().getSpecification())); - JsonSchema schema = validatorFactory.getSchema(testCaseFileUri, testSpec.getTestCase().getSchema(), configBuilder.build()); + Schema schema = validatorFactory.getSchema(testCaseFileUri, testSpec.getTestCase().getSchema(), configBuilder.build()); return dynamicTest(testSpec.getDescription(), () -> executeAndReset(schema, testSpec)); } @@ -254,7 +254,7 @@ private void abortAndReset(String reason) { } } - private void executeAndReset(JsonSchema schema, TestSpec testSpec) { + private void executeAndReset(Schema schema, TestSpec testSpec) { try { executeTest(schema, testSpec); } finally { diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 092215c29..43eb38d7f 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -47,7 +47,7 @@ void messageFalse() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" @@ -82,7 +82,7 @@ void messageSchema() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 57b50b070..857ee688e 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -60,7 +60,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema(schemaContents); + Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index bb260dcac..656aca695 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -60,7 +60,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema(schemaContents); + Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index 71b831909..97e6cf725 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -46,15 +46,15 @@ public static JsonNode getJsonNodeFromUrl(String url) throws IOException { return mapper.readTree(new URL(url)); } - public static JsonSchema getJsonSchemaFromClasspath(String name) { + public static Schema getJsonSchemaFromClasspath(String name) { return getJsonSchemaFromClasspath(name, Specification.Version.DRAFT_4, null); } - public static JsonSchema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion) { + public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion) { return getJsonSchemaFromClasspath(name, schemaVersion, null); } - public static JsonSchema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { + public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(schemaVersion); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); @@ -64,23 +64,23 @@ public static JsonSchema getJsonSchemaFromClasspath(String name, Specification.V return factory.getSchema(is, config); } - public static JsonSchema getJsonSchemaFromStringContent(String schemaContent) { + public static Schema getJsonSchemaFromStringContent(String schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(schemaContent); } - public static JsonSchema getJsonSchemaFromUrl(String uri) throws URISyntaxException { + public static Schema getJsonSchemaFromUrl(String uri) throws URISyntaxException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(SchemaLocation.of(uri)); } - public static JsonSchema getJsonSchemaFromJsonNode(JsonNode jsonNode) { + public static Schema getJsonSchemaFromJsonNode(JsonNode jsonNode) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(jsonNode); } // Automatically detect version for given JsonNode - public static JsonSchema getJsonSchemaFromJsonNodeAutomaticVersion(JsonNode jsonNode) { + public static Schema getJsonSchemaFromJsonNodeAutomaticVersion(JsonNode jsonNode) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecificationVersionDetector.detect(jsonNode)); return factory.getSchema(jsonNode); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 29c68e932..8cb674163 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -46,9 +46,9 @@ class CollectorContextTest { private static final String SAMPLE_COLLECTOR_OTHER = "sampleCollectorOther"; - private JsonSchema jsonSchema; + private Schema jsonSchema; - private JsonSchema jsonSchemaForCombine; + private Schema jsonSchemaForCombine; @BeforeEach void setup() throws Exception { @@ -270,7 +270,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } @@ -340,7 +340,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator1(schemaLocation, evaluationPath, schemaNode); } @@ -419,7 +419,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isBoolean()) { return new CollectValidator(schemaLocation, evaluationPath, schemaNode); } @@ -459,7 +459,7 @@ void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); - JsonSchema schema = factory.getSchema("{\n" + Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); Exception[] instance = new Exception[1]; @@ -507,7 +507,7 @@ void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); - JsonSchema schema = factory.getSchema("{\n" + Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); for (int i = 0; i < 50; ++i) { @@ -525,7 +525,7 @@ void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); - JsonSchema schema = factory.getSchema("{\n" + Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); for (int i = 0; i < 50; ++i) { @@ -543,7 +543,7 @@ void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); - JsonSchema schema = factory.getSchema("{\n" + Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); for (int i = 0; i < 50; ++i) { diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 8c6a7a1d3..8389c021b 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -39,7 +39,7 @@ void localeMessageOthers() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -53,7 +53,7 @@ void localeMessageNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -65,7 +65,7 @@ void validOthers() { + " \"const\": \"aa\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -77,7 +77,7 @@ void validNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void invalidNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index b00563d6d..eaae8622e 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -56,7 +56,7 @@ void annotationCollection() throws JsonProcessingException { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "\"helloworld\""; diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 7895fb144..a04fa1b30 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -86,7 +86,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { /* * You can access the schema node here to read data from your keyword */ @@ -125,7 +125,7 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { .build(); final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).metaSchema(dialect).build(); - final JsonSchema schema = validatorFactory.getSchema("{\n" + + final Schema schema = validatorFactory.getSchema("{\n" + " \"$schema\":\n" + " \"https://github.com/networknt/json-schema-validator/tests/schemas/example01\",\n" + " \"enum\": [\"foo\", \"bar\"],\n" + diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index da7f320fb..f87801c4e 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -18,7 +18,7 @@ class CustomUriTest { void customUri() throws Exception { /* Given */ final JsonSchemaFactory factory = buildJsonSchemaFactory(); - final JsonSchema schema = factory.getSchema( + final Schema schema = factory.getSchema( "{\"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\"type\": \"object\",\"additionalProperties\": false,\"properties\": {\"customAnyOf\": {\"anyOf\": [{\"type\": \"null\"},{\"$ref\": \"custom:date\"}]},\"customOneOf\": {\"oneOf\": [{\"type\": \"null\"},{\"$ref\": \"custom:date\"}]}}}"); final ObjectMapper mapper = new ObjectMapper(); final JsonNode value = mapper.readTree("{\"customAnyOf\": null,\"customOneOf\": null}"); diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index 108499268..d3ab52c7a 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -33,7 +33,7 @@ void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = schemaFactory.getSchema(SchemaLocation.of("resource:/draft4/issue258/Master.json"), config); + Schema schema = schemaFactory.getSchema(SchemaLocation.of("resource:/draft4/issue258/Master.json"), config); assertEquals(0, schema.validate(new ObjectMapper().readTree(jsonObject)).size()); } diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index b620e8948..27e835a70 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -9,7 +9,7 @@ import java.util.List; class DateTimeDSTTest { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -25,7 +25,7 @@ void shouldWorkV7() throws Exception { String schemaPath = "/schema/dateTimeArray.json"; String dataPath = "/data/dstTimes.json"; // Contains 2020 DST changes for various countries InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 4ebd4afb2..509a49bb4 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -29,7 +29,7 @@ class DependentRequiredTest { "}"; private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); - private static final JsonSchema schema = factory.getSchema(SCHEMA); + private static final Schema schema = factory.getSchema(SCHEMA); private static final ObjectMapper mapper = new ObjectMapper(); @Test diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index faaa3be6c..9c6f119ec 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -117,7 +117,7 @@ void discriminatorInArray() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -149,7 +149,7 @@ void anyOfWithConfigEnabledButNoDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -242,7 +242,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -335,7 +335,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -425,7 +425,7 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -521,7 +521,7 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -621,7 +621,7 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -676,7 +676,7 @@ void oneOfMissingDiscriminatorValue() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); List list = messages.stream().collect(Collectors.toList()); @@ -772,7 +772,7 @@ void anyOfMissingDiscriminatorValue() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); assertEquals("required", list.get(0).getKeyword()); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 09b8e4a1d..6189e1e81 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -35,7 +35,7 @@ void durationFormatValidatorTest() throws IOException { final JsonNode invalidTargetNode = objectMapper.readTree("\"INVALID_DURATION\""); final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).build(); - final JsonSchema validatorSchema = validatorFactory.getSchema(schema); + final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(validTargetNode); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index fa7e45498..0f15e63f3 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -85,7 +85,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); @@ -105,7 +105,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index d8df75c50..db8126e51 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -51,7 +51,7 @@ void errorMessage() { + " \"foo\": \"a\",\r\n" + " \"bar\": 2\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); @@ -81,7 +81,7 @@ void errorMessageUnionType() { String inputData = "{\r\n" + " \"keyword1\": 2\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 0469b7a8e..fc388934f 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -32,7 +32,7 @@ void exampleSchemaLocation() { builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json"), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json"), config); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -46,7 +46,7 @@ void exampleSchemaLocation() { assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 - JsonSchema refSchema = schema.getValidationContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); + Schema refSchema = schema.getValidationContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); } @@ -55,7 +55,7 @@ void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -69,7 +69,7 @@ void exampleClasspath() { assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 - JsonSchema refSchema = schema.getValidationContext().getSchemaResources().get("classpath:schema/example-ref.json#"); + Schema refSchema = schema.getValidationContext().getSchemaResources().get("classpath:schema/example-ref.json#"); assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); } } diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 87436f981..78b2f7f91 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -47,7 +47,7 @@ void draftV4ShouldHaveExclusiveMinimum() { .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder.metaSchema(dialect)); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":0}"; String validData = "{\"value1\":0.1}"; diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index dbb1a3479..9e0d77ca3 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -36,7 +36,7 @@ public CustomFormatKeyword(Map formats) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { throw new IllegalArgumentException(); } } diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index f080ef136..0527af659 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -43,7 +43,7 @@ void unknownFormatNoVocab() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -56,7 +56,7 @@ void unknownFormatNoVocabStrictTrue() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -85,7 +85,7 @@ void unknownFormatAssertionsVocab() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) @@ -100,7 +100,7 @@ void unknownFormatShouldCollectAnnotations() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -145,7 +145,7 @@ void formatAssertions(FormatInput formatInput) { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -174,7 +174,7 @@ void patternFormatDeprecated() { + " \"format\": \"custom\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -223,7 +223,7 @@ void shouldAllowNumberFormat() { + " \"format\": \"custom-number\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("123451", InputFormat.JSON, executionConfiguration -> { executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -241,7 +241,7 @@ void draft7DisableFormat() { String schemaData = "{\r\n" + " \"format\":\"uri\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); }); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index c31f12859..d118bb856 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -67,7 +67,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, true); assertFalse(result.getErrors().isEmpty()); @@ -110,7 +110,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"hello\"", InputFormat.JSON, true); assertFalse(result.getErrors().isEmpty()); @@ -153,7 +153,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); @@ -194,7 +194,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, false); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 6383c63cf..18385ae20 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -33,7 +33,7 @@ class Issue1091Test { void testHasAdjacentKeywordInEvaluationPath() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4) + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4) .getSchema(SchemaLocation.of("classpath:schema/issue1091.json"), config); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index 810c7443c..e732bf037 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -24,7 +24,7 @@ import java.util.List; class Issue255Test { - protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -40,7 +40,7 @@ void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() throws Ex String schemaPath = "/draft2019-09/issue255.json"; String dataPath = "/data/issue255.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContent(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContent(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index 01ecc36ba..1c6402a13 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -56,7 +56,7 @@ class Issue285Test { // The result is as expected, and we get a validation error. @Test void nestedValidation() throws IOException { - JsonSchema jsonSchema = schemaFactory.getSchema(schemaStr); + Schema jsonSchema = schemaFactory.getSchema(schemaStr); List errors = jsonSchema.validate(mapper.readTree(person)); System.err.println("\n" + Arrays.toString(errors.toArray())); @@ -97,7 +97,7 @@ void nestedValidation() throws IOException { @Test void nestedTypeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); - JsonSchema jsonSchema = schemaFactory.getSchema(uri); + Schema jsonSchema = schemaFactory.getSchema(uri); List errors = jsonSchema.validate(mapper.readTree(invalidNestedSchema)); System.err.println("\n" + Arrays.toString(errors.toArray())); @@ -120,7 +120,7 @@ void nestedTypeValidation() throws IOException { @Test void typeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); - JsonSchema jsonSchema = schemaFactory.getSchema(uri); + Schema jsonSchema = schemaFactory.getSchema(uri); List errors = jsonSchema.validate(mapper.readTree(invalidSchema)); System.err.println("\n" + Arrays.toString(errors.toArray())); diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index 81683c8bd..0c899f96c 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -9,7 +9,7 @@ import java.util.List; class Issue295Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -25,7 +25,7 @@ void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue295-v7.json"; String dataPath = "/data/issue295.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 0ca63d1a8..b565dcc0e 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -10,12 +10,12 @@ import java.util.List; class Issue313Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } - protected JsonSchema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } @@ -32,7 +32,7 @@ void shouldFailV201909() throws Exception { String schemaPath = "/schema/issue313-2019-09.json"; String dataPath = "/data/issue313.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV201909(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV201909(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); @@ -44,7 +44,7 @@ void shouldFailV7() throws Exception { String schemaPath = "/schema/issue313-v7.json"; String dataPath = "/data/issue313.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 7701661c9..7470f2178 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -21,7 +21,7 @@ class Issue314Test { void testNormalizeHttpOnly() { String schemaPath = "/schema/issue314-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = FACTORY.getSchema(schemaInputStream); + Schema schema = FACTORY.getSchema(schemaInputStream); Assertions.assertNotNull(schema); } diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index b17497c15..e55c22146 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -9,7 +9,7 @@ import java.util.List; class Issue327Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -25,7 +25,7 @@ void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue327-v7.json"; String dataPath = "/data/issue327.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index c9720c066..1f0bcb3a8 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; class Issue342Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -26,7 +26,7 @@ void propertyNameEnumShouldFailV7() throws Exception { String schemaPath = "/schema/issue342-v7.json"; String dataPath = "/data/issue342.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 4532add55..888492fba 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -18,7 +18,7 @@ void setup() throws IOException { setupSchema(); } - JsonSchema jsonSchema; + Schema jsonSchema; ObjectMapper objectMapper = new ObjectMapper(); private void setupSchema() throws IOException { diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 5b6078bc0..4808cddba 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -19,7 +19,7 @@ void setup() throws IOException { setupSchema(); } - JsonSchema jsonSchema; + Schema jsonSchema; ObjectMapper objectMapper = new ObjectMapper(); private void setupSchema() throws IOException { diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index ff4b32d5e..bb9dba669 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test; class Issue375Test { - protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } @@ -42,7 +42,7 @@ void shouldFailAndShowValidationValuesWithError() throws Exception { String schemaPath = "/draft2019-09/issue375.json"; String dataPath = "/data/issue375.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContent(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContent(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index 696b60c8d..58ec6e7c8 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; class Issue383Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -26,7 +26,7 @@ void nestedOneOfsShouldStillMatchV7() throws Exception { String schemaPath = "/schema/issue383-v7.json"; String dataPath = "/data/issue383.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index f5865e193..9470c96f7 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; class Issue396Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -29,7 +29,7 @@ void testComplexPropertyNamesV7() throws Exception { String schemaPath = "/schema/issue396-v7.json"; String dataPath = "/data/issue396.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 565ce6472..bc9da2a1f 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -9,7 +9,7 @@ import java.util.List; class Issue404Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -25,7 +25,7 @@ void expectObjectNotIntegerV7() throws Exception { String schemaPath = "/schema/issue404-v7.json"; String dataPath = "/data/issue404.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index ae8ffabb2..da4f5b459 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -15,7 +15,7 @@ class Issue406Test { @Test void testPreloadingNotHappening() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); + final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass Assertions.assertNotNull(schema); } @@ -23,7 +23,7 @@ void testPreloadingNotHappening() { @Test void testPreloadingHappening() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); + final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(JsonSchemaException.class, new Executable() { @Override @@ -37,7 +37,7 @@ public void execute() { @Test void testPreloadingHappeningForCircularDependency() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - final JsonSchema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); + final Schema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); } } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 6ba3da5f2..ad00a62db 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -12,7 +12,7 @@ * Validating custom message */ class Issue426Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -27,7 +27,7 @@ void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue426-v7.json"; String dataPath = "/data/issue426.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index c8661d08b..ea6ae9017 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -38,7 +38,7 @@ private void runTestFile(String testCaseFile) throws Exception { SchemaValidatorsConfig.Builder configBuilder = SchemaValidatorsConfig.builder(); configBuilder.typeLoose(typeLooseNode != null && typeLooseNode.asBoolean()); configBuilder.discriminatorKeywordEnabled(false); - JsonSchema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); + Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); List errors = new ArrayList(schema.validate(node)); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 023d1384c..57f28f4c1 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -20,7 +20,7 @@ class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .propertyWalkListener(new CountingWalker()) @@ -56,7 +56,7 @@ void shouldWalkAnyOfPropertiesWithWithPayload() throws Exception { private void walk(JsonNode data, boolean shouldValidate) { String schemaPath = "/schema/issue451-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); CollectorContext collectorContext = schema.walk(data, shouldValidate).getCollectorContext(); diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index bed3fab8c..123290119 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -10,7 +10,7 @@ class Issue456Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -26,7 +26,7 @@ void shouldWorkT2() throws Exception { String dataPath = "/data/issue456-T2.json"; // String dataT3Path = "/data/issue456-T3.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); @@ -38,7 +38,7 @@ void shouldWorkT3() throws Exception { String schemaPath = "/schema/issue456-v7.json"; String dataPath = "/data/issue456-T3.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 53e779a8c..6386e7f45 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -16,7 +16,7 @@ class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); - protected JsonSchema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { + protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) @@ -26,7 +26,7 @@ protected JsonSchema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) @Test void shouldWalkWithValidation() throws IOException { - JsonSchema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); + Schema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); JsonNode data = mapper.readTree(Issue461Test.class.getResource("/data/issue461-v7.json")); ValidationResult result = schema.walk(data, true); Assertions.assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index bc319e636..5ed6c7f1f 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -59,7 +59,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaInputStream, config); + Schema schema = factory.getSchema(schemaInputStream, config); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); ValidationResult result = schema.walk(data, true); assertEquals(new HashSet<>(Arrays.asList("/properties", "/properties/tags/items/0/properties")), @@ -84,7 +84,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaInputStream, config); + Schema schema = factory.getSchema(schemaInputStream, config); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); ValidationResult result = schema.walk(data, true); assertEquals( diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index 3707b18e9..dce82fd70 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -65,7 +65,7 @@ void shouldFailV201909_with_frIT() throws Exception { private Map validate() throws Exception { InputStream schemaInputStream = Issue471Test.class.getResourceAsStream(SCHEMA_PATH); - JsonSchema schema = getJsonSchemaFromStreamContentV201909(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV201909(schemaInputStream); InputStream dataInputStream = Issue471Test.class.getResourceAsStream(DATA_PATH); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); @@ -77,7 +77,7 @@ private Map convertErrorsToMap(List errors) { return errors.stream().collect(Collectors.toMap(m -> m.getInstanceLocation().toString(), Error::getMessage)); } - private JsonSchema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { + private Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 6f3a833b5..f2ca31cdb 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -54,7 +54,7 @@ void draft4() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -68,7 +68,7 @@ void draft6() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -82,7 +82,7 @@ void draft7() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -96,7 +96,7 @@ void draft201909() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -110,7 +110,7 @@ void draft202012() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index a30798330..b5e0599a7 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -35,7 +35,7 @@ void testValidJson1 () throws Exception { InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); - JsonSchema schema = factory.getSchema(schemaInputStream); + Schema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-valid-1.json"); List errors = schema.validate(node); Assertions.assertTrue(errors.isEmpty()); @@ -47,7 +47,7 @@ void testValidJson2 () throws Exception { InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); - JsonSchema schema = factory.getSchema(schemaInputStream); + Schema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-valid-2.json"); List errors = schema.validate(node); Assertions.assertTrue(errors.isEmpty()); @@ -59,7 +59,7 @@ void testInvalidJson1 () throws Exception { InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); - JsonSchema schema = factory.getSchema(schemaInputStream); + Schema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-invalid-1.json"); List errors = schema.validate(node); Assertions.assertEquals(2, errors.size()); @@ -79,7 +79,7 @@ void testInvalidJson2 () throws Exception { InputStream schemaInputStream = Issue493Test.class.getResourceAsStream(schemaPath1); - JsonSchema schema = factory.getSchema(schemaInputStream); + Schema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/issue493-invalid-2.json"); List errors = schema.validate(node); Assertions.assertEquals(3, errors.size()); diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 24cecf4fd..e18baed9d 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -24,7 +24,7 @@ class Issue518Test { void testPreservingEmptyFragmentSuffix() { String schemaPath = "/schema/issue518-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = FACTORY.getSchema(schemaInputStream); + Schema schema = FACTORY.getSchema(schemaInputStream); Assertions.assertNotNull(schema); } diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index 03acb7ba9..cfce65200 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -10,7 +10,7 @@ class Issue550Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(String schemaPath) { + protected Schema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); @@ -27,7 +27,7 @@ protected JsonNode getJsonNodeFromStreamContent(String dataPath) throws Exceptio void testValidationMessageDoContainSchemaPath() throws Exception { String schemaPath = "/schema/issue500_1-v7.json"; String dataPath = "/data/issue500_1.json"; - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaPath); + Schema schema = getJsonSchemaFromStreamContentV7(schemaPath); JsonNode node = getJsonNodeFromStreamContent(dataPath); List errors = schema.validate(node); @@ -41,7 +41,7 @@ void testValidationMessageDoContainSchemaPath() throws Exception { void testValidationMessageDoContainSchemaPathForOneOf() throws Exception { String schemaPath = "/schema/issue500_2-v7.json"; String dataPath = "/data/issue500_2.json"; - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaPath); + Schema schema = getJsonSchemaFromStreamContentV7(schemaPath); JsonNode node = getJsonNodeFromStreamContent(dataPath); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index 6dac57066..ff1e96bf0 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -21,7 +21,7 @@ * updated to version 1.7.0 or later. */ class Issue575Test { - private static JsonSchema schema; + private static Schema schema; @BeforeAll static void init() { diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index 162721c80..c0ae8c6e9 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -12,7 +12,7 @@ void failure() { .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) .build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); + Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { schema.walk(objectMapper.readTree("{}"), false); diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index c0826279e..1a50540f6 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -9,7 +9,7 @@ import java.util.List; class Issue606Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -25,7 +25,7 @@ void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue606-v7.json"; String dataPath = "/data/issue606.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index 9282323b5..399276f1c 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -62,7 +62,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void bundledSchemaLoadsAndValidatesCorrectly_Ref() { - JsonSchema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json\" }"); + Schema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json\" }"); assertTrue(referencingRootSchema.validate(one).isEmpty()); assertTrue(referencingRootSchema.validate(two).isEmpty()); @@ -71,7 +71,7 @@ void bundledSchemaLoadsAndValidatesCorrectly_Ref() { @Test void bundledSchemaLoadsAndValidatesCorrectly_Uri() throws Exception { - JsonSchema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json")); + Schema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json")); assertTrue(rootSchema.validate(one).isEmpty()); assertTrue(rootSchema.validate(two).isEmpty()); @@ -80,7 +80,7 @@ void bundledSchemaLoadsAndValidatesCorrectly_Uri() throws Exception { @Test void uriWithEmptyFragment_Ref() { - JsonSchema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#\" }"); + Schema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#\" }"); assertTrue(referencingRootSchema.validate(one).isEmpty()); assertTrue(referencingRootSchema.validate(two).isEmpty()); @@ -89,7 +89,7 @@ void uriWithEmptyFragment_Ref() { @Test void uriWithEmptyFragment_Uri() throws Exception { - JsonSchema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#")); + Schema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#")); assertTrue(rootSchema.validate(one).isEmpty()); assertTrue(rootSchema.validate(two).isEmpty()); @@ -98,7 +98,7 @@ void uriWithEmptyFragment_Uri() throws Exception { @Test void uriThatPointsToTwoShouldOnlyValidateTwo_Ref() { - JsonSchema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/two\" }"); + Schema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/two\" }"); assertFalse(referencingTwoSchema.validate(one).isEmpty()); assertTrue(referencingTwoSchema.validate(two).isEmpty()); @@ -107,7 +107,7 @@ void uriThatPointsToTwoShouldOnlyValidateTwo_Ref() { @Test void uriThatPointsToOneShouldOnlyValidateOne_Uri() throws Exception { - JsonSchema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/one")); + Schema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/one")); assertTrue(oneSchema.validate(one).isEmpty()); assertFalse(oneSchema.validate(two).isEmpty()); @@ -116,7 +116,7 @@ void uriThatPointsToOneShouldOnlyValidateOne_Uri() throws Exception { @Test void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Ref() { - JsonSchema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/refToOne\" }"); + Schema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/refToOne\" }"); assertTrue(referencingTwoSchema.validate(one).isEmpty()); assertFalse(referencingTwoSchema.validate(two).isEmpty()); @@ -125,7 +125,7 @@ void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Ref() { @Test void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Uri() throws Exception { - JsonSchema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/refToOne")); + Schema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/refToOne")); assertTrue(oneSchema.validate(one).isEmpty()); assertFalse(oneSchema.validate(two).isEmpty()); @@ -137,7 +137,7 @@ void uriThatPointsToSchemaWithIdThatHasDifferentUri_Ref() throws Exception { JsonNode oneArray = getJsonNodeFromStringContent("[[1]]"); JsonNode textArray = getJsonNodeFromStringContent("[[\"a\"]]"); - JsonSchema schemaWithIdFromRef = factory.getSchema("{ \"$ref\": \"resource:tests/draft4/refRemote.json#/3/schema\" }"); + Schema schemaWithIdFromRef = factory.getSchema("{ \"$ref\": \"resource:tests/draft4/refRemote.json#/3/schema\" }"); assertTrue(schemaWithIdFromRef.validate(oneArray).isEmpty()); assertFalse(schemaWithIdFromRef.validate(textArray).isEmpty()); } @@ -147,14 +147,14 @@ void uriThatPointsToSchemaWithIdThatHasDifferentUri_Uri() throws Exception { JsonNode oneArray = getJsonNodeFromStringContent("[[1]]"); JsonNode textArray = getJsonNodeFromStringContent("[[\"a\"]]"); - JsonSchema schemaWithIdFromUri = factory.getSchema(SchemaLocation.of("resource:tests/draft4/refRemote.json#/3/schema")); + Schema schemaWithIdFromUri = factory.getSchema(SchemaLocation.of("resource:tests/draft4/refRemote.json#/3/schema")); assertTrue(schemaWithIdFromUri.validate(oneArray).isEmpty()); assertFalse(schemaWithIdFromUri.validate(textArray).isEmpty()); } @Test void uriThatPointsToSchemaThatDoesNotExistShouldFail_Ref() { - JsonSchema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:data/schema-that-does-not-exist.json#/definitions/something\" }"); + Schema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:data/schema-that-does-not-exist.json#/definitions/something\" }"); assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); } @@ -166,7 +166,7 @@ void uriThatPointsToSchemaThatDoesNotExistShouldFail_Uri() { @Test void uriThatPointsToNodeThatDoesNotExistShouldFail_Ref() { - JsonSchema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/node-that-does-not-exist\" }"); + Schema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/node-that-does-not-exist\" }"); assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); } diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index d322088d5..c5d7e2fb3 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -37,7 +37,7 @@ void testBinaryNode() throws Exception { // schema with data property of type string: InputStream schemaInputStream = getClass().getResourceAsStream("/draft7/issue650.json"); - JsonSchema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); + Schema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); // create model first: Issue650Test.Model model = new Issue650Test.Model(); diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index bbe3f7e01..07ebdd0a7 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -13,7 +13,7 @@ class Issue662Test extends BaseJsonSchemaValidatorTest { private static final String RESOURCE_PREFIX = "issues/662/"; - private static JsonSchema schema; + private static Schema schema; @BeforeAll static void setup() { diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index 7655e53a2..a1045fbec 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; class Issue664Test { - protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -28,7 +28,7 @@ void shouldHaveFullSchemaPaths() throws Exception { String schemaPath = "/schema/issue664-v7.json"; String dataPath = "/data/issue664.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errorSchemaPaths = schema.validate(node).stream().map(Error::getSchemaLocation) diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index 1bf4eeb09..945e27760 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -13,7 +13,7 @@ class Issue665Test extends BaseJsonSchemaValidatorTest { @Test void testUrnUriAsLocalRef() throws IOException { - JsonSchema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", Specification.Version.DRAFT_7); + Schema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", Specification.Version.DRAFT_7); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); List messages = schema.validate(getJsonNodeFromStringContent( @@ -33,7 +33,7 @@ void testUrnUriAsLocalRef_ExternalURN() { try (InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("draft7/urn/issue665_external_urn_ref.json")) { - JsonSchema schema = factory.getSchema(is); + Schema schema = factory.getSchema(is); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); List messages = schema.validate(getJsonNodeFromStringContent( diff --git a/src/test/java/com/networknt/schema/Issue668Test.java b/src/test/java/com/networknt/schema/Issue668Test.java index edafc99e6..259385cee 100644 --- a/src/test/java/com/networknt/schema/Issue668Test.java +++ b/src/test/java/com/networknt/schema/Issue668Test.java @@ -10,7 +10,7 @@ import java.io.InputStream; class Issue668Test { - protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { + protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); YAMLMapper mapper = new YAMLMapper(); JsonNode node = mapper.readTree(schemaContent); @@ -27,7 +27,7 @@ void shouldHandleReferencesToYaml() throws Exception { String schemaPath = "/schema/issue668.yml"; String dataPath = "/data/issue668.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContent(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContent(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); MatcherAssert.assertThat(schema.validate(node), Matchers.empty()); diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index 38f5b6945..86b911f0f 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -53,7 +53,7 @@ void testLocaleSwitch() throws JsonProcessingException { verify(config2, "/foo: integer trouvé, string attendu"); } - private JsonSchema getSchema(SchemaValidatorsConfig config) { + private Schema getSchema(SchemaValidatorsConfig config) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index cb98df28e..841b7b4be 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -82,7 +82,7 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); - JsonSchema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); + Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); for (String expectedPath: expectedMessagePaths) { @@ -114,7 +114,7 @@ static Stream specialCharacterTests() { void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().pathType(pathType).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09) + Schema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 0bcc0661c..4d6762c7a 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -50,7 +50,7 @@ void test() throws JsonProcessingException { + " \"billing_address\" : \"my_billing_address\"\n" + "}\n"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false); System.out.println(stringCollector.strings); diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 33f257009..a1a1ea67d 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -37,7 +37,7 @@ public String getErrorMessageDescription() { @Test void allowToOverrideDataTime() throws IOException { - JsonSchema jsonSchema = createSchema(true); + Schema jsonSchema = createSchema(true); // Custom validator checks for FOO_BAR assertEquals(0, validate(jsonSchema, FOO_BAR).size()); @@ -48,7 +48,7 @@ void allowToOverrideDataTime() throws IOException { @Test void useDefaultValidatorIfNotOverriden() throws IOException { - JsonSchema jsonSchema = createSchema(false); + Schema jsonSchema = createSchema(false); // Default validator fails with FOO_BAR assertEquals(1, validate(jsonSchema, FOO_BAR).size()); @@ -58,11 +58,11 @@ void useDefaultValidatorIfNotOverriden() throws IOException { } - private List validate(JsonSchema jsonSchema, String myDateTimeContent) throws JsonProcessingException { + private List validate(Schema jsonSchema, String myDateTimeContent) throws JsonProcessingException { return jsonSchema.validate(new ObjectMapper().readTree(" { \"my-date-time\": \"" + myDateTimeContent + "\" } ")); } - private JsonSchema createSchema(boolean useCustomDateFormat) { + private Schema createSchema(boolean useCustomDateFormat) { Dialect overrideDateTimeValidator = Dialect .builder(Dialects.getDraft7().getIri(), Dialects.getDraft7()) .formats(formats -> { diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index 9496330aa..74d6c64aa 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -30,7 +30,7 @@ void test() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(false).failFast(true).build(); - JsonSchema jsonSchema = schemaFactory.getSchema(schemaDef, config); + Schema jsonSchema = schemaFactory.getSchema(schemaDef, config); JsonNode jsonNode = new ObjectMapper().readTree("{\"field\": \"pattern-violation\"}"); assertEquals(1, jsonSchema.validate(jsonNode).size()); diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 24b9621b6..44393b20e 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -14,7 +14,7 @@ class Issue824Test { @Test void validate() throws JsonProcessingException { - final JsonSchema v201909SpecSchema = JsonSchemaFactory + final Schema v201909SpecSchema = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 6b85cbe00..e9d9ece44 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -55,7 +55,7 @@ void testV7WithNonMatchingCustomFormat() throws IOException { String dataPath = "/data/issue832.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); JsonSchemaFactory factory = buildV7PlusNoFormatSchemaFactory(); - JsonSchema schema = factory.getSchema(schemaInputStream); + Schema schema = factory.getSchema(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index b034cad9b..2d78d22a4 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -31,7 +31,7 @@ void test() throws Exception { + "}"; JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); - JsonSchema schema = jsonSchemaFactory.getSchema(schemaData); + Schema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); assertEquals(0, result.getErrors().size()); diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index a18e2abb6..ac0811e6e 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -15,7 +15,7 @@ class Issue898Test extends BaseJsonSchemaValidatorTest { void testMessagesWithSingleQuotes() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.FRENCH).build(); - JsonSchema schema = getJsonSchemaFromClasspath("schema/issue898.json", Specification.Version.DRAFT_2020_12, config); + Schema schema = getJsonSchemaFromClasspath("schema/issue898.json", Specification.Version.DRAFT_2020_12, config); JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); List messages = schema.validate(node).stream() diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index 49b866ac1..c1b162a56 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -105,7 +105,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) + Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) .getSchema(SchemaLocation.of("http://www.example.org"), JsonMapperFactory.getInstance().readTree(schema)); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index 975a02d15..8a7dfb319 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -38,13 +38,13 @@ void test_spec(Specification.Version specVersion) { String baseUrl = String.format("https://example.org/schema/issue928-v%s.json", versionStr); System.out.println("baseUrl: " + baseUrl); - JsonSchema byPointer = schemaFactory.getSchema( + Schema byPointer = schemaFactory.getSchema( SchemaLocation.of(baseUrl + "#/definitions/example")); Assertions.assertEquals(byPointer.validate(mapper.valueToTree("A")).size(), 0); Assertions.assertEquals(byPointer.validate(mapper.valueToTree("Z")).size(), 1); - JsonSchema byAnchor = schemaFactory.getSchema( + Schema byAnchor = schemaFactory.getSchema( SchemaLocation.of(baseUrl + "#example")); Assertions.assertEquals( diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 41732fe46..43b9c53f5 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -48,7 +48,7 @@ void shouldNotThrowException() { + " }\r\n" + " }\r\n" + " }"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index 8002cd658..e32a96e87 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -31,7 +31,7 @@ void shouldNotThrowException() { + " \"greeting\": {}\r\n" + " }\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); } } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index 9d9b6dd9b..e1a188d48 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -70,7 +70,7 @@ void test() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); assertTrue(schema.validate(inputData, InputFormat.JSON).isEmpty()); String badData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index 6b8bc4528..110dc1777 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -47,7 +47,7 @@ void test() throws JsonProcessingException { vocabularies.remove(Vocabulary.V202012_VALIDATION.getIri()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)).getSchema(schemaNode); String inputData = "{\r\n" + " \"textValue\": \"hello\"\r\n" diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 1be21937d..2bacd0995 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -46,7 +46,7 @@ void messageInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -84,7 +84,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); @@ -123,7 +123,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index a6c1be85d..910d00428 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -49,7 +49,7 @@ void messageInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -76,7 +76,7 @@ void messageAdditionalItemsInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -103,7 +103,7 @@ void messageAdditionalItemsFalseInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -141,7 +141,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true); assertTrue(result.getErrors().isEmpty()); @@ -177,7 +177,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); @@ -219,7 +219,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); @@ -269,7 +269,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); ValidationResult result = schema.walk(input, true); assertTrue(result.getErrors().isEmpty()); @@ -327,7 +327,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); ValidationResult result = schema.walk(input, true); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 76617aa1a..4332735e6 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -21,7 +21,7 @@ class JsonWalkApplyDefaultsTest { void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); + Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema); if (shouldValidateSchema) { assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), @@ -42,7 +42,7 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { void testApplyDefaults2() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, false)); + Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, false)); ValidationResult result = jsonSchema.walk(inputNode, true); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", @@ -59,7 +59,7 @@ void testApplyDefaults2() throws IOException { void testApplyDefaults1() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, false, false)); + Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, false, false)); ValidationResult result = jsonSchema.walk(inputNode, true); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_null: null found, integer expected", @@ -82,18 +82,18 @@ void testApplyDefaults0(String method) throws IOException { List errors; switch (method) { case "walkWithEmptyStrategy": { - JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(false, false, false)); + Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(false, false, false)); errors = jsonSchema.walk(inputNode, true).getErrors(); break; } case "walkWithNoDefaults": { // same empty strategy, but tests for NullPointerException - JsonSchema jsonSchema = createSchema(null); + Schema jsonSchema = createSchema(null); errors = jsonSchema.walk(inputNode, true).getErrors(); break; } case "validateWithApplyAllDefaults": { - JsonSchema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); + Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); errors = jsonSchema.validate(inputNode); break; } @@ -119,7 +119,7 @@ void testIllegalArgumentException() { } } - private JsonSchema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { + private Schema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().applyDefaultsStrategy(applyDefaultsStrategy).build(); return schemaFactory.getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json"), schemaValidatorsConfig); diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index d2af0f981..d548c072c 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -26,9 +26,9 @@ class JsonWalkTest { - private JsonSchema jsonSchema; + private Schema jsonSchema; - private JsonSchema jsonSchema1; + private Schema jsonSchema1; private static final String SAMPLE_WALK_COLLECTOR_TYPE = "sampleWalkCollectorType"; @@ -132,7 +132,7 @@ void testWalkMissingNodeWithPropertiesSchemaShouldNotThrow() { + " }"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema(schemaContents); + Schema schema = factory.getSchema(schemaContents); JsonNode missingNode = MissingNode.getInstance(); assertDoesNotThrow(() -> schema.walk(missingNode, true)); } @@ -152,7 +152,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException { + Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index b7c8c61fd..e59766dc2 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -33,7 +33,7 @@ import com.networknt.schema.serialization.JsonMapperFactory; class LocaleTest { - private JsonSchema getSchema(SchemaValidatorsConfig config) { + private Schema getSchema(SchemaValidatorsConfig config) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema( "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", @@ -51,7 +51,7 @@ private JsonSchema getSchema(SchemaValidatorsConfig config) { void executionContextLocale() throws JsonMappingException, JsonProcessingException { JsonNode rootNode = new ObjectMapper().readTree(" { \"foo\": 123 } "); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema jsonSchema = getSchema(config); + Schema jsonSchema = getSchema(config); Locale locale = Locales.findSupported("it;q=0.9,fr;q=1.0"); // fr ExecutionContext executionContext = jsonSchema.createExecutionContext(); @@ -88,7 +88,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { + " \"$id\": \"https://www.example.com\",\r\n" + " \"type\": \"object\"\r\n" + "}"; - JsonSchema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) + Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); @@ -154,7 +154,7 @@ void encoding() { + " \"type\": \"string\",\r\n" + " \"maxLength\": 5\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 452f3bc80..95cb8b20b 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -187,7 +187,7 @@ void negativeDoubleOverflowTest() throws IOException { String schema = format(NUMBER, maximum); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); // Schema and document parsed with just double - JsonSchema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Maximum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", maximum, value)); @@ -226,7 +226,7 @@ void doubleValueCoarsing() throws IOException { String content = "1.7976931348623158e+308"; JsonNode doc = mapper.readTree(content); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); @@ -258,7 +258,7 @@ void doubleValueCoarsingExceedRange() throws IOException { String content = "1.7976931348623160e+308"; JsonNode doc = mapper.readTree(content); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); @@ -296,7 +296,7 @@ private static void expectNoMessages(String[][] values, String schemaTemplate, O String schema = format(schemaTemplate, maximum); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - JsonSchema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); @@ -316,7 +316,7 @@ private static void expectSomeMessages(String[][] values, String schemaTemplate, String value = aTestCycle[1]; String schema = format(schemaTemplate, maximum); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper2.readTree(value); List messages = v.validate(doc); diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index bb5f23216..32733bf26 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -37,7 +37,7 @@ static class EqualsValidator extends BaseKeywordValidator { private final String value; EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - JsonSchema parentSchema, Keyword keyword, + Schema parentSchema, Keyword keyword, ValidationContext validationContext) { super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); this.value = schemaNode.textValue(); @@ -63,7 +63,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, - JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) + JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, validationContext); } @@ -78,7 +78,7 @@ void message() { + " \"type\": \"string\",\r\n" + " \"equals\": \"helloworld\"\r\n" + "}"; - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate("\"helloworlda\"", InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("$: must be equal to 'helloworld'", messages.iterator().next().toString()); diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index e49cb6401..36ede36d9 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -41,7 +41,7 @@ void oas31() throws IOException { try (InputStream input = MetaSchemaValidationTest.class.getResourceAsStream("/schema/oas/3.1/petstore.json")) { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 6fc3b4b8a..ef23de443 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -175,7 +175,7 @@ void negativeDoubleOverflowTest() throws IOException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); // Schema and document parsed with just double - JsonSchema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Minimum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", minimum, value)); @@ -218,7 +218,7 @@ void doubleValueCoarsing() throws IOException { String content = "-1.7976931348623158e+308"; JsonNode doc = mapper.readTree(content); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); @@ -248,7 +248,7 @@ void doubleValueCoarsingExceedRange() throws IOException { String content = "-1.7976931348623160e+308"; JsonNode doc = mapper.readTree(content); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); List messages = v.validate(doc); assertTrue(messages.isEmpty(), "Validation should succeed as by default double values are used by mapper"); @@ -270,7 +270,7 @@ private void expectSomeMessages(String[][] values, String number, ObjectMapper m String value = aTestCycle[1]; String schema = format(number, minimum); - JsonSchema v = factory.getSchema(mapper.readTree(schema)); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper2.readTree(value); List messages = v.validate(doc); @@ -289,7 +289,7 @@ private void expectNoMessages(String[][] values, String integer, ObjectMapper ma String schema = format(integer, minimum); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - JsonSchema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema), config); JsonNode doc = bigIntegerMapper.readTree(value); List messages = v.validate(doc); diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index dcf7fd922..0771565d1 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -48,7 +48,7 @@ class MultipleOfValidatorTest { @Test void test() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; @@ -63,7 +63,7 @@ void test() { @Test void testTypeLoose() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":\"123.892\",\"value2\":\"123456.2934\",\"value3\":123.123}"; String validTypeLooseInputData = "{\"value1\":\"123.89\",\"value2\":\"123456.29\",\"value3\":123.12}"; @@ -81,7 +81,7 @@ void testTypeLoose() { // With type loose this has 3 multipleOf errors SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - JsonSchema typeLoose = factory.getSchema(schemaData, config); + Schema typeLoose = factory.getSchema(schemaData, config); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index 048729832..30f2ce20b 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -37,7 +37,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema(schemaContents); + Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 0984b73b0..ebabc8ddc 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -64,7 +64,7 @@ void oneOfMultiple() { + " \"fox\" : \"test\",\r\n" + " \"world\" : \"test\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -105,7 +105,7 @@ void oneOfZero() { String inputData = "{\r\n" + " \"test\" : 1\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -184,7 +184,7 @@ void invalidSwaggerIoExample() { + " age:\r\n" + " type: integer"; - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) @@ -258,7 +258,7 @@ void fixedSwaggerIoExample() { + " - hunts\r\n" + " - age"; - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) @@ -301,7 +301,7 @@ void oneOfDiscriminatorEnabled() { + " }\r\n" + " ]\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); String inputData = "{}"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -355,7 +355,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -374,7 +374,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - JsonSchema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -443,7 +443,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -462,7 +462,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - JsonSchema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -490,7 +490,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); - JsonSchema schema = factory.getSchema(schemaContents); + Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index a1561e005..36a673624 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -41,7 +41,7 @@ private void runTestFile(String testCaseFile) throws Exception { SchemaValidatorsConfig.Builder configBuilder = SchemaValidatorsConfig.builder(); configBuilder.typeLoose(typeLooseNode != null && typeLooseNode.asBoolean()); configBuilder.discriminatorKeywordEnabled(true); - JsonSchema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); + Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); List errors = new ArrayList(schema.validate(node)); diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 1ca8c0bf4..7d724d1e0 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -36,7 +36,7 @@ private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { void testInvalidJson() throws Exception { InputStream schemaInputStream = OutputFormatTest.class.getResourceAsStream(schemaPath1); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaInputStream, config); + Schema schema = factory.getSchema(schemaInputStream, config); JsonNode node = getJsonNodeFromJsonData("/data/output-format-input.json"); List errors = schema.validate(node); Assertions.assertEquals(3, errors.size()); @@ -84,7 +84,7 @@ private Error format(Error message) { } @Override - public java.util.List format(JsonSchema jsonSchema, + public java.util.List format(Schema jsonSchema, ExecutionContext executionContext, ValidationContext validationContext) { return executionContext.getErrors().stream().map(this::format).collect(Collectors.toCollection(ArrayList::new)); } @@ -107,7 +107,7 @@ void customFormat() { + " }\n" + " }\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) .getSchema(schemaData, InputFormat.JSON, SchemaValidatorsConfig.builder().build()); String inputData = "{\n" + " \"type\": \"cat\",\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index d50d449e7..b8ce8dfc0 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -97,7 +97,7 @@ class OutputUnitTest { void annotationCollectionList() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = inputData1; @@ -114,7 +114,7 @@ void annotationCollectionList() throws JsonProcessingException { void annotationCollectionHierarchical() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = inputData1; @@ -131,7 +131,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { void annotationCollectionHierarchical2() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = inputData2; @@ -180,7 +180,7 @@ void formatAnnotation(FormatInput formatInput) { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -199,7 +199,7 @@ void formatAssertion(FormatInput formatInput) { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -218,7 +218,7 @@ void typeUnion() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(typeSchema, config); + Schema schema = factory.getSchema(typeSchema, config); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -268,7 +268,7 @@ void unevaluatedProperties() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); // The following checks if the heirarchical output format is correct with multiple unevaluated properties String inputData = "{\r\n" @@ -317,7 +317,7 @@ void anyOf() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\": \"hello\",\r\n" @@ -339,7 +339,7 @@ void listAssertionMapper() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); assertFalse(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); @@ -354,7 +354,7 @@ void hierarchicalAssertionMapper() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); assertFalse(outputUnit.isValid()); Object assertion = outputUnit.getErrors().get("type"); diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 500323a8a..344b1d7fb 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -56,7 +56,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .build(); final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); - final JsonSchema validatorSchema = validatorFactory.getSchema(schema); + final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); @@ -73,7 +73,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .build(); final JsonSchemaFactory overrideValidatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(overrideValidatorMetaSchema).build(); - final JsonSchema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); + final Schema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); messages = overrideValidatorSchema.validate(targetNode, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index e4837d32d..187ccd7f1 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; class OverwritingCustomMessageBugTest { - private JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + private Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); return factory.getSchema(schemaContent); } @@ -36,7 +36,7 @@ private List validate() throws Exception { String schemaPath = "/schema/OverwritingCustomMessageBug.json"; String dataPath = "/data/OverwritingCustomMessageBug.json"; InputStream schemaInputStream = OverwritingCustomMessageBugTest.class.getResourceAsStream(schemaPath); - JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); + Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); InputStream dataInputStream = OverwritingCustomMessageBugTest.class.getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); return schema.validate(node); diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index d42b6c8ee..bf70cad88 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -42,7 +42,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); - JsonSchema schema = factory.getSchema("{\"patternProperties\":6}"); + Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); List errors = schema.validate(node); @@ -57,7 +57,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); - JsonSchema schema = factory.getSchema("{\"patternProperties\":6}", config); + Schema schema = factory.getSchema("{\"patternProperties\":6}", config); JsonNode node = getJsonNodeFromStringContent(""); List errors = schema.validate(node); @@ -81,7 +81,7 @@ void message() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" + " \"valid_array\": [\"array1_value\", \"array2_value\"],\n" + " \"valid_string\": \"string_value\",\n" @@ -132,7 +132,7 @@ void annotation() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" + " \"test\": 5\n" + "}"; diff --git a/src/test/java/com/networknt/schema/PatternValidatorTest.java b/src/test/java/com/networknt/schema/PatternValidatorTest.java index 7f4541ec9..4578b6ffd 100644 --- a/src/test/java/com/networknt/schema/PatternValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternValidatorTest.java @@ -32,7 +32,7 @@ void failFast() { + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" + "}"; String inputData = "\"hello\""; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); assertFalse(result); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index be9bf88be..220db5114 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -56,7 +56,7 @@ void messageInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -82,7 +82,7 @@ void messageValid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1]"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -101,7 +101,7 @@ void messageInvalidAdditionalItems() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1, 2]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -147,7 +147,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); @@ -204,7 +204,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null]"); ValidationResult result = schema.walk(input, true); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 0f5473d8f..6d75f2c5e 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -18,7 +18,7 @@ void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exceptio .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .build(); - JsonSchema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}", schemaValidatorsConfig); + Schema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}", schemaValidatorsConfig); JsonNode node = getJsonNodeFromStringContent("{\"foo\": \"bar\"}"); ValidationResult result = schema.walk(node, true); Assertions.assertEquals(result.getErrors().size(), 1); diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 325010d3a..0d71a9832 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -40,7 +40,7 @@ void messageInvalid() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\": {},\r\n" + " \"foobar\": {}\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 7613b5931..82618082c 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -32,14 +32,14 @@ void givenConfigWriteTrueWhenReadOnlyTrueThenDenies() throws IOException { errors.stream().map(e -> e.toString()).collect(Collectors.toList()).get(0)); } - private JsonSchema loadJsonSchema(Boolean write) { - JsonSchema schema = this.getJsonSchema(write); + private Schema loadJsonSchema(Boolean write) { + Schema schema = this.getJsonSchema(write); schema.initializeValidators(); return schema; } - private JsonSchema getJsonSchema(Boolean write) { + private Schema getJsonSchema(Boolean write) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig schemaConfig = createSchemaConfig(write); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index e5f503e0d..66d8b82db 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -22,7 +22,7 @@ void testInvalidRecursiveReference() { // Arrange String invalidSchemaJson = "{ \"$recursiveRef\": \"invalid\" }"; JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); - JsonSchema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); + Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getMetaSchema(), jsonSchemaFactory, null); diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index b75b429ef..290e5361f 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -18,7 +18,7 @@ class RefTest { void shouldLoadRelativeClasspathReference() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -41,7 +41,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { void shouldLoadSchemaResource() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -58,8 +58,8 @@ void shouldLoadSchemaResource() throws JsonProcessingException { assertEquals("/properties/DriverProperties/properties/CommonProperties/$ref/required", error.getEvaluationPath().toString()); assertEquals("field1", error.getProperty()); - JsonSchema driver = schema.getValidationContext().getSchemaResources().get("https://www.example.org/driver#"); - JsonSchema common = schema.getValidationContext().getSchemaResources().get("https://www.example.org/common#"); + Schema driver = schema.getValidationContext().getSchemaResources().get("https://www.example.org/driver#"); + Schema common = schema.getValidationContext().getSchemaResources().get("https://www.example.org/common#"); assertEquals(DialectId.DRAFT_4, driver.getValidationContext().getMetaSchema().getIri()); assertEquals(DialectId.DRAFT_7, common.getValidationContext().getMetaSchema().getIri()); diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 585cda8c5..1432836bf 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -43,7 +43,7 @@ void resolveSamePathDotSlash() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); - JsonSchema jsonSchema = factory.getSchema(mainSchema); + Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -62,7 +62,7 @@ void resolveSamePath() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); - JsonSchema jsonSchema = factory.getSchema(mainSchema); + Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -81,7 +81,7 @@ void resolveParent() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); - JsonSchema jsonSchema = factory.getSchema(mainSchema); + Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -100,7 +100,7 @@ void resolveComplex() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); - JsonSchema jsonSchema = factory.getSchema(mainSchema); + Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); assertEquals(1, messages.size()); } @@ -108,7 +108,7 @@ void resolveComplex() { @Test void classPathSlash() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); - JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" + " \"ids\": {\r\n" @@ -124,7 +124,7 @@ void classPathSlash() { @Test void classPathNoSlash() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); - JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" + " \"ids\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 316881908..0d0f62380 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -57,7 +57,7 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" @@ -101,7 +101,7 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" @@ -145,7 +145,7 @@ void validateRequestRequired() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"amount\":10,\r\n" + " \"description\":\"world\"\r\n" @@ -183,7 +183,7 @@ void validateResponseRequired() { + "}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" + " \"description\":\"world\",\r\n" + " \"name\":\"hello\"\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index c25e9a647..9c0c9e1f0 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -23,7 +23,7 @@ void schemaFromSchemaLocationMapping() { /* * This should be cached for performance. */ - JsonSchema schemaFromSchemaLocation = factory + Schema schemaFromSchemaLocation = factory .getSchema(SchemaLocation.of("https://www.example.com/schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not @@ -46,7 +46,7 @@ void schemaFromSchemaLocationContent() { /* * This should be cached for performance. */ - JsonSchema schemaFromSchemaLocation = factory + Schema schemaFromSchemaLocation = factory .getSchema(SchemaLocation.of("https://www.example.com/schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not @@ -68,7 +68,7 @@ void schemaFromClasspath() { * Loading from using the retrieval IRI is not recommended as it may cause * confusing when resolving relative $ref when $id is also used. */ - JsonSchema schemaFromClasspath = factory.getSchema(SchemaLocation.of("classpath:schema/example-ref.json")); + Schema schemaFromClasspath = factory.getSchema(SchemaLocation.of("classpath:schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not * thrown. You check if there are issues with ref resolving using @@ -89,7 +89,7 @@ void schemaFromString() { * Loading from a String is not recommended as there is no base IRI to use for * resolving relative $ref. */ - JsonSchema schemaFromString = factory + Schema schemaFromString = factory .getSchema("{\"enum\":[1, 2, 3, 4]}"); List errors = schemaFromString.validate("7", InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); @@ -110,7 +110,7 @@ void schemaFromJsonNode() throws JsonProcessingException { * Note that the V202012 from the factory is the default version if $schema is not * specified. As $schema is specified in the data, V6 is used. */ - JsonSchema schemaFromNode = factory.getSchema(schemaNode); + Schema schemaFromNode = factory.getSchema(schemaNode); /* * By default all schemas are preloaded eagerly but ref resolve failures are not * thrown. You check if there are issues with ref resolving using diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index 0e1575de7..403a43bf4 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -218,7 +218,7 @@ void documentFragment() { @Test void shouldLoadEscapedFragment() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); - JsonSchema schema = factory.getSchema(SchemaLocation + Schema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); List result = schema.validate("1", InputFormat.JSON); assertFalse(result.isEmpty()); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java similarity index 95% rename from src/test/java/com/networknt/schema/JsonSchemaTest.java rename to src/test/java/com/networknt/schema/SchemaTest.java index d01d98dc7..e3dcfb60f 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -30,7 +30,7 @@ /** * Tests for JsonSchemaFactory. */ -class JsonSchemaTest { +class SchemaTest { @Test void concurrency() throws Exception { String schemaData = "{\r\n" @@ -59,7 +59,7 @@ void concurrency() throws Exception { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().preloadJsonSchema(false).build(); - JsonSchema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData, config); Exception[] instance = new Exception[1]; CountDownLatch latch = new CountDownLatch(1); List threads = new ArrayList<>(); diff --git a/src/test/java/com/networknt/schema/SelfRefTest.java b/src/test/java/com/networknt/schema/SelfRefTest.java index 5c328f77a..75ae08d9e 100644 --- a/src/test/java/com/networknt/schema/SelfRefTest.java +++ b/src/test/java/com/networknt/schema/SelfRefTest.java @@ -26,7 +26,7 @@ class SelfRefTest extends BaseJsonSchemaValidatorTest { @Disabled("This test currently is failing because of a StackOverflow caused by a recursive $ref.") @Test() void testSelfRef() throws Exception { - JsonSchema node = getJsonSchemaFromClasspath("selfRef.json"); + Schema node = getJsonSchemaFromClasspath("selfRef.json"); System.out.println("node = " + node); } } \ No newline at end of file diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index a88c6a7df..99d51e5e2 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -42,11 +42,11 @@ void shouldCallAllKeywordListenerOnWalkStart() throws Exception { // depending on this line the test either passes or fails: // - if this line is executed, then it passes // - if this line is not executed (just comment it) - it fails - JsonSchema firstSchema = factory.getSchema(draft07Schema); + Schema firstSchema = factory.getSchema(draft07Schema); firstSchema.walk(new ObjectMapper().readTree("{ \"id\": 123 }"), true); // note that only second schema takes overridden schemaValidatorsConfig - JsonSchema secondSchema = factory.getSchema(draft07Schema, schemaValidatorsConfig); + Schema secondSchema = factory.getSchema(draft07Schema, schemaValidatorsConfig); secondSchema.walk(new ObjectMapper().readTree("{ \"id\": 123 }"), true); Assertions.assertTrue(allKeywordListener.wasCalled); diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 2d3284569..1e1892078 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -53,7 +53,7 @@ class TypeValidatorTest { @Test void testTypeLoose() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"array_of_integers\": 1,\r\n" @@ -79,7 +79,7 @@ void testTypeLoose() { // With type loose this has 0 type errors as any item can also be interpreted as an array of 1 item SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - JsonSchema typeLoose = factory.getSchema(schemaData, config); + Schema typeLoose = factory.getSchema(schemaData, config); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); @@ -101,7 +101,7 @@ void integer() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); @@ -130,7 +130,7 @@ void integerDraft4() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling @@ -145,7 +145,7 @@ void walkNull() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } @@ -174,7 +174,7 @@ void nullable() { + " }\r\n" + "}"; final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); - final JsonSchema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() + final Schema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() .nullableKeywordEnabled(false) .build()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index a91a56249..e9b7bb5d5 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -43,7 +43,7 @@ void unevaluatedItemsFalse() { + " \"unevaluatedItems\" : false\r\n" + "}"; String inputData = "[1,2,3]"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -69,7 +69,7 @@ void unevaluatedItemsSchema() { + " \"unevaluatedItems\" : { \"type\" : \"string\" }\r\n" + "}"; String inputData = "[1,2,3]"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index eed3d4c46..48871738e 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -61,7 +61,7 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key3\": \"value3\",\r\n" + " \"key4\": \"value4\"\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -116,7 +116,7 @@ void subschemaProcessing() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -144,7 +144,7 @@ void unevaluatedPropertiesSchema() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -189,7 +189,7 @@ void ref() { + " \"unevaluatedProperties\": false\r\n" + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } @@ -227,7 +227,7 @@ void nestedRef() { Map schemas = new HashMap<>(); schemas.put("https://www.example.org/PrimaryDeviceConfiguration.json", primaryDeviceConfiguration); schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2019_09, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) .getSchema(schemaData); diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index c257d08fa..a590c233c 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -24,7 +24,7 @@ void testSchema1() throws IOException { JsonNode jsonNode = mapper.readTree(this.json); JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); - JsonSchema jsonSchema = factory.getSchema(schema1); + Schema jsonSchema = factory.getSchema(schema1); List errors = jsonSchema.validate(jsonNode); for(Error error:errors) { @@ -38,7 +38,7 @@ void testSchema2() throws IOException { JsonNode jsonNode = mapper.readTree(this.json); JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); - JsonSchema jsonSchema = factory.getSchema(schema2); + Schema jsonSchema = factory.getSchema(schema2); List errors = jsonSchema.validate(jsonNode); for(Error error:errors) { @@ -51,7 +51,7 @@ void testSchema3() throws IOException { JsonNode jsonNode = mapper.readTree(this.json); JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); - JsonSchema jsonSchema = factory.getSchema(schema3); + Schema jsonSchema = factory.getSchema(schema3); List errors = jsonSchema.validate(jsonNode); for(Error error:errors) { diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 564138274..f03e3f556 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -55,7 +55,7 @@ void testBuilderUriMappingUri() throws IOException { .metaSchema(draftV4) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); JsonSchemaFactory instance = builder.build(); - JsonSchema schema = instance.getSchema(SchemaLocation.of( + Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); assertEquals(0, schema.validate(mapper.readTree(mappings)).size()); } @@ -87,7 +87,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error try { - JsonSchema schema = instance.getSchema(example); + Schema schema = instance.getSchema(example); schema.validate(mapper.createObjectNode()); fail("Expected exception not thrown"); } catch (JsonSchemaException ex) { @@ -106,7 +106,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { .metaSchema(draftV4) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); instance = builder.build(); - JsonSchema schema = instance.getSchema(example); + Schema schema = instance.getSchema(example); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); } @@ -121,7 +121,7 @@ void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); - JsonSchema schema = instance.getSchema(SchemaLocation.of( + Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); assertEquals(0, schema.validate(mapper.readTree(mappings)).size()); } @@ -155,7 +155,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error try { - JsonSchema schema = instance.getSchema(example, config); + Schema schema = instance.getSchema(example, config); schema.validate(mapper.createObjectNode()); fail("Expected exception not thrown"); } catch (JsonSchemaException ex) { @@ -169,7 +169,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); - JsonSchema schema = instance.getSchema(example, config); + Schema schema = instance.getSchema(example, config); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); } @@ -179,7 +179,7 @@ void testMappingsForRef() throws IOException { JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), + Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), config); assertEquals(0, schema.validate(mapper.readTree("[]")).size()); } diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index afbd4012e..0c7768af1 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -35,7 +35,7 @@ void testURNToURI() throws Exception { .schemaMappers(schemaMappers -> schemaMappers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) ); JsonSchemaFactory instance = builder.build(); - JsonSchema schema = instance.getSchema(is); + Schema schema = instance.getSchema(is); assertEquals(0, schema.validate(mapper.readTree(urlTestData)).size()); } catch( Exception e) { e.printStackTrace(); diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index 78f4470d6..0320cdb67 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -39,7 +39,7 @@ void testLoadingWithId() throws Exception { JsonNode schemaJson = mapper.readTree(inputStream); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); @SuppressWarnings("unused") - JsonSchema schema = factory.getSchema(schemaJson); + Schema schema = factory.getSchema(schemaJson); } } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 9391081b8..14843378e 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -60,7 +60,7 @@ void noValidation() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -112,7 +112,7 @@ void noFormatValidation() { + " }\r\n" + " }\r\n" + "}"; - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -212,7 +212,7 @@ void customVocabulary() { builder -> builder.metaSchema(dialect).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); OutputUnit outputUnit = schema.validate("{}", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java index 7d34db50d..5e5209eeb 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.Specification.Version; @@ -20,7 +20,7 @@ */ public class NetworkntBasicRunner implements Callable { private static final Logger logger = LoggerFactory.getLogger(NetworkntBasicRunner.class); - private JsonSchema jsonSchema; + private Schema jsonSchema; private JsonNode schemas; private List schemaNames; diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCase.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCase.java index 450572408..16345e080 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCase.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCase.java @@ -1,20 +1,20 @@ package com.networknt.schema.benchmark; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.suite.TestCase; public class NetworkntTestSuiteTestCase { - private final JsonSchema schema; + private final Schema schema; private final TestCase testCase; private final Boolean formatAssertionsEnabled; - public NetworkntTestSuiteTestCase(JsonSchema schema, TestCase testCase, Boolean formatAssertionsEnabled) { + public NetworkntTestSuiteTestCase(Schema schema, TestCase testCase, Boolean formatAssertionsEnabled) { this.schema = schema; this.testCase = testCase; this.formatAssertionsEnabled = formatAssertionsEnabled; } - public JsonSchema getSchema() { + public Schema getSchema() { return schema; } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index a8d2c7bcc..3a689793c 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -14,7 +14,7 @@ import java.util.stream.Stream; import com.networknt.schema.AbsoluteIri; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; @@ -66,7 +66,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { for (TestCase testCase : testSource.getTestCases()) { SchemaLocation testCaseFileUri = SchemaLocation .of("classpath:" + toForwardSlashPath(testCase.getSpecification())); - JsonSchema schema = JsonSchemaFactory + Schema schema = JsonSchemaFactory .getInstance(defaultVersion, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) .getSchema(testCaseFileUri, testCase.getSchema(), SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index 985db761c..3ddf487e5 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index c2d1af171..778186eac 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index b34890b36..5b4b8f45b 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -60,7 +60,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -89,7 +89,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index 4e4e3ad0f..6732be4b5 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index c283bfa16..707827df1 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 35c2abef7..ea7f34dd2 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.OutputFormat; import com.networknt.schema.PathType; @@ -49,7 +49,7 @@ void validateMetaSchema() { builder -> builder.metaSchema(OpenApi30.getInstance()) .defaultMetaSchemaIri(OpenApi30.getInstance().getIri()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - JsonSchema schema = factory.getSchema(SchemaLocation.of( + Schema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/requestBody/content/application~1json/schema")); String input = "{\r\n" + " \"petType\": \"dog\",\r\n" @@ -77,7 +77,7 @@ void validateMetaSchema() { void jsonPointerWithNumberInFragment() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); - JsonSchema schema = factory.getSchema(SchemaLocation.of( + Schema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"), SchemaValidatorsConfig.builder().pathType(PathType.JSON_PATH).build()); assertNotNull(schema); @@ -98,7 +98,7 @@ void exclusiveMaximum() { + "}\r\n"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("100", InputFormat.JSON, OutputFormat.BOOLEAN)); } @@ -115,7 +115,7 @@ void exclusiveMinimum() { + "}\r\n"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); - JsonSchema schema = factory.getSchema(schemaData); + Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("0", InputFormat.JSON, OutputFormat.BOOLEAN)); } } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 55d590e51..851ebcc38 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; @@ -43,7 +43,7 @@ void validateVocabulary() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); - JsonSchema schema = factory + Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" + " \"petType\": \"dog\",\r\n" @@ -72,7 +72,7 @@ void validateMetaSchema() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - JsonSchema schema = factory + Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" + " \"petType\": \"dog\",\r\n" @@ -102,7 +102,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - JsonSchema schema = factory + Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" + " \"petType\": \"dog\",\r\n" @@ -122,7 +122,7 @@ void discriminatorOneOfNoMatchShouldFail() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - JsonSchema schema = factory + Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" + " \"petType\": \"lizard\",\r\n" @@ -144,7 +144,7 @@ void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - JsonSchema schema = factory + Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" + " \"petType\": \"dog\",\r\n" diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java index a12212ca2..8ef02d89c 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; @@ -41,7 +41,7 @@ void integration() { () -> factory.getSchema(SchemaLocation.of("http://www.example.org/schema"))); assertEquals("http://www.example.org/schema", invalidSchemaException.getError().getArguments()[0].toString()); - JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json")); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json")); assertNotNull(schema); } diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 0d2317044..27d7dcbdd 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -32,7 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -90,7 +90,7 @@ void jsonLocation() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, InputFormat.JSON, config); + Schema schema = factory.getSchema(schemaData, InputFormat.JSON, config); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -136,7 +136,7 @@ void yamlLocation() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - JsonSchema schema = factory.getSchema(schemaData, InputFormat.YAML, config); + Schema schema = factory.getSchema(schemaData, InputFormat.YAML, config); List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index ff3d49d66..7409198d2 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -36,7 +36,7 @@ import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.InputFormat; import com.networknt.schema.JsonNodePath; -import com.networknt.schema.JsonSchema; +import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; @@ -104,7 +104,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -184,7 +184,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -269,7 +269,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -342,7 +342,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -391,7 +391,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09) + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09) .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" @@ -555,7 +555,7 @@ void applyDefaults() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -591,7 +591,7 @@ void applyDefaultsWithWalker() throws JsonProcessingException { public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { - JsonSchema schema = walkEvent.getSchema(); + Schema schema = walkEvent.getSchema(); JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); if (schemaRef != null) { schema = schemaRef.getSchema(); @@ -612,7 +612,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -648,7 +648,7 @@ void applyInvalidDefaultsWithWalker() throws JsonProcessingException { public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { - JsonSchema schema = walkEvent.getSchema(); + Schema schema = walkEvent.getSchema(); JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); if (schemaRef != null) { schema = schemaRef.getSchema(); @@ -669,7 +669,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); @@ -720,7 +720,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { if (propertyNode == null) { // Get the schema PropertiesValidator propertiesValidator = walkEvent.getValidator(); - JsonSchema propertySchema = propertiesValidator.getSchemas().get(requiredProperty); + Schema propertySchema = propertiesValidator.getSchemas().get(requiredProperty); JsonSchemaRef schemaRef = JsonSchemaRefs.from(propertySchema); if (schemaRef != null) { propertySchema = schemaRef.getSchema(); @@ -737,7 +737,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertFalse(result.getErrors().isEmpty()); @@ -780,7 +780,7 @@ void generateDataWithWalker() throws JsonProcessingException { public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { - JsonSchema schema = walkEvent.getSchema(); + Schema schema = walkEvent.getSchema(); JsonSchemaRef schemaRef = null; do { schemaRef = JsonSchemaRefs.from(schema); @@ -807,7 +807,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); @@ -858,7 +858,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -921,7 +921,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - JsonSchema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); From 59635374095f413dbd528e073be2489259bc02d7 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:46:58 +0800 Subject: [PATCH 15/74] Rename JsonSchemaFactory to SchemaRegistry --- .../java/com/networknt/schema/Schema.java | 4 +-- ...SchemaFactory.java => SchemaRegistry.java} | 24 ++++++++--------- .../schema/SpecificationVersionDetector.java | 2 +- .../networknt/schema/ValidationContext.java | 8 +++--- .../dialect/DefaultDialectRegistry.java | 10 +++---- .../schema/dialect/DialectRegistry.java | 4 +-- .../DisallowUnknownDialectFactory.java | 6 ++--- .../schema/AbstractJsonSchemaTest.java | 2 +- .../schema/AbstractJsonSchemaTestSuite.java | 10 +++---- .../AdditionalPropertiesValidatorTest.java | 4 +-- .../networknt/schema/AllOfValidatorTest.java | 4 +-- .../networknt/schema/AnyOfValidatorTest.java | 4 +-- .../schema/BaseJsonSchemaValidatorTest.java | 10 +++---- .../schema/CollectorContextTest.java | 12 ++++----- .../networknt/schema/ConstValidatorTest.java | 10 +++---- .../schema/ContentSchemaValidatorTest.java | 2 +- .../schema/CustomMetaSchemaTest.java | 2 +- .../com/networknt/schema/CustomUriTest.java | 6 ++--- .../schema/CyclicDependencyTest.java | 4 +-- .../com/networknt/schema/DateTimeDSTTest.java | 2 +- .../DefaultJsonSchemaIdValidatorTest.java | 10 +++---- .../schema/DependentRequiredTest.java | 2 +- .../DisallowUnknownDialectFactoryTest.java | 6 ++--- .../DisallowUnknownKeywordFactoryTest.java | 2 +- .../schema/DiscriminatorValidatorTest.java | 18 ++++++------- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 4 +-- .../networknt/schema/ErrorHandlerTest.java | 4 +-- .../com/networknt/schema/ExampleTest.java | 4 +-- .../schema/ExclusiveMinimumValidatorTest.java | 6 ++--- .../schema/FormatKeywordFactoryTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 16 ++++++------ .../com/networknt/schema/IfValidatorTest.java | 8 +++--- .../com/networknt/schema/Issue1091Test.java | 2 +- .../com/networknt/schema/Issue255Test.java | 2 +- .../com/networknt/schema/Issue285Test.java | 4 +-- .../com/networknt/schema/Issue295Test.java | 2 +- .../com/networknt/schema/Issue313Test.java | 4 +-- .../com/networknt/schema/Issue314Test.java | 4 +-- .../com/networknt/schema/Issue327Test.java | 2 +- .../com/networknt/schema/Issue342Test.java | 2 +- .../com/networknt/schema/Issue347Test.java | 2 +- .../schema/Issue366FailFastTest.java | 4 +-- .../schema/Issue366FailSlowTest.java | 4 +-- .../com/networknt/schema/Issue375Test.java | 2 +- .../com/networknt/schema/Issue383Test.java | 2 +- .../com/networknt/schema/Issue396Test.java | 2 +- .../com/networknt/schema/Issue404Test.java | 2 +- .../com/networknt/schema/Issue406Test.java | 6 ++--- .../com/networknt/schema/Issue426Test.java | 2 +- .../com/networknt/schema/Issue428Test.java | 4 +-- .../com/networknt/schema/Issue451Test.java | 2 +- .../com/networknt/schema/Issue456Test.java | 2 +- .../com/networknt/schema/Issue461Test.java | 2 +- .../com/networknt/schema/Issue467Test.java | 2 +- .../com/networknt/schema/Issue471Test.java | 2 +- .../com/networknt/schema/Issue475Test.java | 10 +++---- .../com/networknt/schema/Issue493Test.java | 2 +- .../com/networknt/schema/Issue518Test.java | 6 ++--- .../com/networknt/schema/Issue532Test.java | 2 +- .../com/networknt/schema/Issue550Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 2 +- .../com/networknt/schema/Issue606Test.java | 2 +- .../com/networknt/schema/Issue619Test.java | 4 +-- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue664Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 4 +-- .../com/networknt/schema/Issue668Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 4 +-- .../com/networknt/schema/Issue724Test.java | 2 +- .../com/networknt/schema/Issue784Test.java | 2 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 4 +-- .../com/networknt/schema/Issue832Test.java | 6 ++--- .../com/networknt/schema/Issue857Test.java | 2 +- .../com/networknt/schema/Issue877Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 2 +- .../com/networknt/schema/Issue928Test.java | 8 +++--- .../com/networknt/schema/Issue935Test.java | 2 +- .../com/networknt/schema/Issue936Test.java | 4 +-- .../com/networknt/schema/Issue939Test.java | 2 +- .../com/networknt/schema/Issue940Test.java | 2 +- .../com/networknt/schema/Issue943Test.java | 2 +- .../com/networknt/schema/Issue994Test.java | 2 +- .../schema/ItemsValidator202012Test.java | 6 ++--- .../networknt/schema/ItemsValidatorTest.java | 16 ++++++------ .../schema/JsonSchemaFactoryUriCacheTest.java | 6 ++--- .../schema/JsonSchemaPreloadTest.java | 4 +-- .../schema/JsonWalkApplyDefaultsTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 6 ++--- .../java/com/networknt/schema/LocaleTest.java | 8 +++--- .../schema/MaximumValidatorTest.java | 2 +- .../com/networknt/schema/MessageTest.java | 2 +- .../schema/MetaSchemaValidationTest.java | 2 +- .../schema/MinimumValidatorTest.java | 2 +- .../schema/MultipleOfValidatorTest.java | 4 +-- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 22 ++++++++-------- .../schema/OpenAPI30JsonSchemaTest.java | 4 +-- .../networknt/schema/OutputFormatTest.java | 4 +-- .../com/networknt/schema/OutputUnitTest.java | 20 +++++++------- .../schema/OverrideValidatorTest.java | 4 +-- .../OverwritingCustomMessageBugTest.java | 2 +- .../PatternPropertiesValidatorTest.java | 8 +++--- .../schema/PatternValidatorTest.java | 2 +- .../schema/PrefixItemsValidatorTest.java | 10 +++---- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 2 +- .../schema/ReadOnlyValidatorTest.java | 2 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 4 +-- .../networknt/schema/RefValidatorTest.java | 12 ++++----- .../schema/RequiredValidatorTest.java | 8 +++--- .../java/com/networknt/schema/SampleTest.java | 10 +++---- .../networknt/schema/SchemaLocationTest.java | 2 +- ...ctoryTest.java => SchemaRegistryTest.java} | 4 +-- .../java/com/networknt/schema/SchemaTest.java | 2 +- .../networknt/schema/SharedConfigTest.java | 2 +- .../networknt/schema/TypeValidatorTest.java | 10 +++---- .../schema/UnevaluatedItemsValidatorTest.java | 4 +-- .../UnevaluatedPropertiesValidatorTest.java | 10 +++---- .../schema/UnknownMetaSchemaTest.java | 14 +++++----- .../com/networknt/schema/UriMappingTest.java | 18 ++++++------- .../java/com/networknt/schema/UrnTest.java | 4 +-- .../networknt/schema/V4JsonSchemaTest.java | 6 ++--- .../com/networknt/schema/VocabularyTest.java | 12 ++++----- .../benchmark/NetworkntBasicRunner.java | 4 +-- .../NetworkntTestSuiteTestCases.java | 4 +-- .../schema/format/IriFormatTest.java | 16 ++++++------ .../schema/format/IriReferenceFormatTest.java | 16 ++++++------ .../schema/format/TimeFormatTest.java | 6 ++--- .../schema/format/UriFormatTest.java | 16 ++++++------ .../schema/format/UriReferenceFormatTest.java | 16 ++++++------ .../networknt/schema/oas/OpenApi30Test.java | 10 +++---- .../networknt/schema/oas/OpenApi31Test.java | 12 ++++----- .../resource/AllowSchemaLoaderTest.java | 4 +-- .../resource/DisallowSchemaLoaderTest.java | 4 +-- .../networknt/schema/utils/JsonNodesTest.java | 6 ++--- .../walk/JsonSchemaWalkListenerTest.java | 26 +++++++++---------- 141 files changed, 388 insertions(+), 388 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchemaFactory.java => SchemaRegistry.java} (97%) rename src/test/java/com/networknt/schema/{JsonSchemaFactoryTest.java => SchemaRegistryTest.java} (92%) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 407e942db..8fdf89b8b 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -40,7 +40,7 @@ /** * Used for creating a schema with validators for validating inputs. This is - * created using {@link JsonSchemaFactory#getInstance(Version, Consumer)} + * created using {@link SchemaRegistry#getInstance(Version, Consumer)} * and should be cached for performance. *

* This is the core of json constraint implementation. It parses json constraint @@ -1405,7 +1405,7 @@ public List getValidators() { * For avoiding issues with concurrency, in 1.0.49 the {@link com.networknt.schema.Schema} instances affiliated with * validators were modified to no more preload the schema and lazy loading is used instead. *

This comes with the issue that this way you cannot rely on validating important schema features, in particular - * $ref resolution at instantiation from {@link com.networknt.schema.JsonSchemaFactory}.

+ * $ref resolution at instantiation from {@link com.networknt.schema.SchemaRegistry}.

*

By calling initializeValidators you can enforce preloading of the {@link com.networknt.schema.Schema} * instances of the validators.

*/ diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/SchemaRegistry.java similarity index 97% rename from src/main/java/com/networknt/schema/JsonSchemaFactory.java rename to src/main/java/com/networknt/schema/SchemaRegistry.java index ba27165e0..56e4e6cdf 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -54,8 +54,8 @@ * JsonSchemaFactory instances are thread-safe provided its configuration is not * modified. */ -public class JsonSchemaFactory { - private static final Logger logger = LoggerFactory.getLogger(JsonSchemaFactory.class); +public class SchemaRegistry { + private static final Logger logger = LoggerFactory.getLogger(SchemaRegistry.class); public static class Builder { private ObjectMapper jsonMapper = null; @@ -173,8 +173,8 @@ public Builder addMetaSchemas(final Collection jsonMetaSchema return metaSchemas(jsonMetaSchemas); } - public JsonSchemaFactory build() { - return new JsonSchemaFactory( + public SchemaRegistry build() { + return new SchemaRegistry( jsonMapper, yamlMapper, jsonNodeReader, @@ -203,7 +203,7 @@ public JsonSchemaFactory build() { private static final List DEFAULT_SCHEMA_LOADERS = SchemaLoaders.builder().build(); private static final List DEFAULT_SCHEMA_MAPPERS = SchemaMappers.builder().build(); - private JsonSchemaFactory( + private SchemaRegistry( ObjectMapper jsonMapper, ObjectMapper yamlMapper, JsonNodeReader jsonNodeReader, @@ -241,7 +241,7 @@ public SchemaLoader getSchemaLoader() { /** * Builder without keywords or formats. * - * Typically {@link #builder(JsonSchemaFactory)} is what is required. + * Typically {@link #builder(SchemaRegistry)} is what is required. * * @return a builder instance without any keywords or formats - usually not what one needs. */ @@ -256,7 +256,7 @@ public static Builder builder() { * @param versionFlag the default dialect * @return the factory */ - public static JsonSchemaFactory getInstance(Specification.Version versionFlag) { + public static SchemaRegistry getInstance(Specification.Version versionFlag) { return getInstance(versionFlag, null); } @@ -268,10 +268,10 @@ public static JsonSchemaFactory getInstance(Specification.Version versionFlag) { * @param customizer to customize the factory * @return the factory */ - public static JsonSchemaFactory getInstance(Specification.Version versionFlag, - Consumer customizer) { + public static SchemaRegistry getInstance(Specification.Version versionFlag, + Consumer customizer) { Dialect dialect = checkVersion(versionFlag); - JsonSchemaFactory.Builder builder = builder().defaultMetaSchemaIri(dialect.getIri()) + SchemaRegistry.Builder builder = builder().defaultMetaSchemaIri(dialect.getIri()) .metaSchema(dialect); if (customizer != null) { customizer.accept(builder); @@ -300,7 +300,7 @@ public static Dialect checkVersion(Specification.Version version){ } /** - * Builder from an existing {@link JsonSchemaFactory}. + * Builder from an existing {@link SchemaRegistry}. *

* * JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)); @@ -309,7 +309,7 @@ public static Dialect checkVersion(Specification.Version version){ * @param blueprint the existing factory * @return the builder */ - public static Builder builder(final JsonSchemaFactory blueprint) { + public static Builder builder(final SchemaRegistry blueprint) { Builder builder = builder() .metaSchemas(blueprint.metaSchemas.values()) .defaultMetaSchemaIri(blueprint.defaultMetaSchemaIri) diff --git a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java index adefbf91a..a91118b4e 100644 --- a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java @@ -75,7 +75,7 @@ public static Optional detectOptionalVersion(JsonNode jsonNode, boolean return Optional.ofNullable(jsonNode.get(SCHEMA_TAG)).map(schemaTag -> { String schemaTagValue = schemaTag.asText(); - String schemaUri = JsonSchemaFactory.normalizeMetaSchemaUri(schemaTagValue); + String schemaUri = SchemaRegistry.normalizeMetaSchemaUri(schemaTagValue); if (throwIfUnsupported) { return Version.fromDialectId(schemaUri) diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index b636a1c67..f48ba8b05 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -27,18 +27,18 @@ public class ValidationContext { private final Dialect dialect; - private final JsonSchemaFactory jsonSchemaFactory; + private final SchemaRegistry jsonSchemaFactory; private final SchemaValidatorsConfig config; private final ConcurrentMap schemaReferences; private final ConcurrentMap schemaResources; private final ConcurrentMap dynamicAnchors; public ValidationContext(Dialect dialect, - JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config) { + SchemaRegistry jsonSchemaFactory, SchemaValidatorsConfig config) { this(dialect, jsonSchemaFactory, config, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } - public ValidationContext(Dialect dialect, JsonSchemaFactory jsonSchemaFactory, + public ValidationContext(Dialect dialect, SchemaRegistry jsonSchemaFactory, SchemaValidatorsConfig config, ConcurrentMap schemaReferences, ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { if (dialect == null) { @@ -69,7 +69,7 @@ public String resolveSchemaId(JsonNode schemaNode) { return this.dialect.readId(schemaNode); } - public JsonSchemaFactory getJsonSchemaFactory() { + public SchemaRegistry getJsonSchemaFactory() { return this.jsonSchemaFactory; } diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index c46ca1c00..b17843f25 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -22,7 +22,7 @@ import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification; @@ -33,15 +33,15 @@ */ public class DefaultDialectRegistry implements DialectRegistry { @Override - public Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { // Is it a well-known dialect? - return Specification.Version.fromDialectId(dialectId).map(JsonSchemaFactory::checkVersion).orElseGet(() -> { + return Specification.Version.fromDialectId(dialectId).map(SchemaRegistry::checkVersion).orElseGet(() -> { // Custom dialect return loadDialect(dialectId, schemaFactory, config); }); } - protected Dialect loadDialect(String iri, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { try { Dialect result = loadDialectBuilder(iri, schemaFactory, config).build(); return result; @@ -53,7 +53,7 @@ protected Dialect loadDialect(String iri, JsonSchemaFactory schemaFactory, Schem } } - protected Dialect.Builder loadDialectBuilder(String iri, JsonSchemaFactory schemaFactory, + protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getMetaSchema()); diff --git a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java index 418c14d2b..d86140ee7 100644 --- a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java @@ -15,7 +15,7 @@ */ package com.networknt.schema.dialect; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; /** @@ -36,5 +36,5 @@ public interface DialectRegistry { * @param config the config * @return the dialect */ - Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config); + Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config); } diff --git a/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java b/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java index 16eb75e50..dac7d7825 100644 --- a/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java +++ b/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java @@ -17,16 +17,16 @@ import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; /** * A {@link DialectRegistry} that does not meta-schemas that aren't - * explicitly configured in the {@link JsonSchemaFactory}. + * explicitly configured in the {@link SchemaRegistry}. */ public class DisallowUnknownDialectFactory implements DialectRegistry { @Override - public Dialect getDialect(String dialectId, JsonSchemaFactory schemaFactory, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { throw new InvalidSchemaException(Error.builder() .message("Unknown dialect ''{0}''. Only dialects that are explicitly configured can be used.") .arguments(dialectId).build()); diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 99b49749c..0cd94b4af 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -59,7 +59,7 @@ private JsonNode getJsonNodeFromPath(String dataPath) { } private Schema getJsonSchema(JsonNode schemaNode) { - return JsonSchemaFactory + return SchemaRegistry .getInstance(SpecificationVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) .getSchema(schemaNode); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 825e892e2..cc40fd572 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -168,7 +168,7 @@ private Stream buildContainer(Version defaultVersion, TestSource te private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { try { - JsonSchemaFactory validatorFactory = buildValidatorFactory(defaultVersion, testCase); + SchemaRegistry validatorFactory = buildValidatorFactory(defaultVersion, testCase); return dynamicContainer(testCase.getDisplayName(), testCase.getTests().stream().map(testSpec -> { return buildTest(validatorFactory, testSpec); @@ -182,7 +182,7 @@ private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { } } - private JsonSchemaFactory buildValidatorFactory(Version defaultVersion, TestCase testCase) { + private SchemaRegistry buildValidatorFactory(Version defaultVersion, TestCase testCase) { if (testCase.isDisabled()) return null; SchemaLoader schemaLoader = new SchemaLoader() { @Override @@ -202,8 +202,8 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; Version specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); - JsonSchemaFactory base = JsonSchemaFactory.getInstance(specVersion); - return JsonSchemaFactory + SchemaRegistry base = SchemaRegistry.getInstance(specVersion); + return SchemaRegistry .builder(base) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://", "http://") @@ -212,7 +212,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { .build(); } - private DynamicNode buildTest(JsonSchemaFactory validatorFactory, TestSpec testSpec) { + private DynamicNode buildTest(SchemaRegistry validatorFactory, TestSpec testSpec) { if (testSpec.isDisabled()) { return dynamicTest(testSpec.getDescription(), () -> abortAndReset(testSpec.getReason())); } diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 43eb38d7f..aa6518c30 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -45,7 +45,7 @@ void messageFalse() { + " },\r\n" + " \"additionalProperties\": false\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -80,7 +80,7 @@ void messageSchema() { + " },\r\n" + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 857ee688e..2109cce58 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 656aca695..3b9c7c1b5 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index 97e6cf725..0f1959dd4 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -55,7 +55,7 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi } public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(schemaVersion); + SchemaRegistry factory = SchemaRegistry.getInstance(schemaVersion); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); if (config == null) { @@ -65,23 +65,23 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi } public static Schema getJsonSchemaFromStringContent(String schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(schemaContent); } public static Schema getJsonSchemaFromUrl(String uri) throws URISyntaxException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(SchemaLocation.of(uri)); } public static Schema getJsonSchemaFromJsonNode(JsonNode jsonNode) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); return factory.getSchema(jsonNode); } // Automatically detect version for given JsonNode public static Schema getJsonSchemaFromJsonNodeAutomaticVersion(JsonNode jsonNode) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecificationVersionDetector.detect(jsonNode)); + SchemaRegistry factory = SchemaRegistry.getInstance(SpecificationVersionDetector.detect(jsonNode)); return factory.getSchema(jsonNode); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 8cb674163..c0b9ab0cb 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -156,8 +156,8 @@ public String getErrorMessageDescription() { private void setupSchema() throws Exception { final Dialect dialect = getJsonMetaSchema( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); - final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) + final SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) .build(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().build(); this.jsonSchema = schemaFactory.getSchema(getSchemaString(), schemaValidatorsConfig); @@ -458,7 +458,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -506,7 +506,7 @@ public void run() { void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -524,7 +524,7 @@ void iterate() { void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -542,7 +542,7 @@ void iterateWalk() { void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 8389c021b..6ee457c2c 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -39,7 +39,7 @@ void localeMessageOthers() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -53,7 +53,7 @@ void localeMessageNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -65,7 +65,7 @@ void validOthers() { + " \"const\": \"aa\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -77,7 +77,7 @@ void validNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void invalidNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index eaae8622e..412e196ad 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -54,7 +54,7 @@ void annotationCollection() throws JsonProcessingException { + " ]\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index a04fa1b30..6d664d0a6 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -124,7 +124,7 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { .keyword(new EnumNamesKeyword()) .build(); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).metaSchema(dialect).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).metaSchema(dialect).build(); final Schema schema = validatorFactory.getSchema("{\n" + " \"$schema\":\n" + " \"https://github.com/networknt/json-schema-validator/tests/schemas/example01\",\n" + diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index f87801c4e..67328de1d 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -17,7 +17,7 @@ class CustomUriTest { @Test void customUri() throws Exception { /* Given */ - final JsonSchemaFactory factory = buildJsonSchemaFactory(); + final SchemaRegistry factory = buildJsonSchemaFactory(); final Schema schema = factory.getSchema( "{\"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\"type\": \"object\",\"additionalProperties\": false,\"properties\": {\"customAnyOf\": {\"anyOf\": [{\"type\": \"null\"},{\"$ref\": \"custom:date\"}]},\"customOneOf\": {\"oneOf\": [{\"type\": \"null\"},{\"$ref\": \"custom:date\"}]}}}"); final ObjectMapper mapper = new ObjectMapper(); @@ -30,8 +30,8 @@ void customUri() throws Exception { assertThat(errors.isEmpty(), is(true)); } - private JsonSchemaFactory buildJsonSchemaFactory() { - return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) + private SchemaRegistry buildJsonSchemaFactory() { + return SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) .schemaLoaders(schemaLoaders -> schemaLoaders.add(new CustomUriFetcher())).build(); } diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index d3ab52c7a..9bae93f0f 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -10,8 +10,8 @@ class CyclicDependencyTest { @Test void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { - JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) + SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) .build(); String jsonObject = "{\n" + " \"element\": {\n" + diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index 27e835a70..d193a332e 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -10,7 +10,7 @@ class DateTimeDSTTest { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index bd2f6e69a..8700fc864 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -35,9 +35,9 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); try { - JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } @@ -50,7 +50,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -60,7 +60,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -68,7 +68,7 @@ void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) + assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12) .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"), config)); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 509a49bb4..6dd21ac38 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -28,7 +28,7 @@ class DependentRequiredTest { " }" + "}"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); private static final Schema schema = factory.getSchema(SCHEMA); private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java index ff507adae..e4f6114df 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java @@ -38,14 +38,14 @@ class DisallowUnknownDialectFactoryTest { + "}"; @Test void defaultHandling() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); } @Test void draft202012() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_7_SCHEMA)); @@ -53,7 +53,7 @@ void draft202012() { @Test void draft7() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_202012_SCHEMA)); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index c8fcb65e6..7b55692e3 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -35,7 +35,7 @@ void shouldThrowForUnknownKeywords() { void getSchemaShouldThrowForUnknownKeywords() { Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"equals\": \"world\"\r\n" diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 9c6f119ec..82325a759 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -115,7 +115,7 @@ void discriminatorInArray() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -147,7 +147,7 @@ void anyOfWithConfigEnabledButNoDiscriminator() { + " \"intOrStringType\": 4\r\n" + " }"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -240,7 +240,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -333,7 +333,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -423,7 +423,7 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -519,7 +519,7 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -619,7 +619,7 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -674,7 +674,7 @@ void oneOfMissingDiscriminatorValue() { String inputData = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -770,7 +770,7 @@ void anyOfMissingDiscriminatorValue() { + " }\r\n" + "]"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 6189e1e81..34a356b30 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -34,7 +34,7 @@ void durationFormatValidatorTest() throws IOException { final JsonNode validTargetNode = objectMapper.readTree("\"P1D\""); final JsonNode invalidTargetNode = objectMapper.readTree("\"INVALID_DURATION\""); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).build(); final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(validTargetNode); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index 0f15e63f3..1c10a9f6a 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -85,7 +85,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); @@ -105,7 +105,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index db8126e51..78428af30 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -51,7 +51,7 @@ void errorMessage() { + " \"foo\": \"a\",\r\n" + " \"bar\": 2\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); @@ -81,7 +81,7 @@ void errorMessageUnionType() { String inputData = "{\r\n" + " \"keyword1\": 2\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index fc388934f..e725088e5 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -28,7 +28,7 @@ class ExampleTest { @Test void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -53,7 +53,7 @@ void exampleSchemaLocation() { @Test void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 78b2f7f91..9077c9fad 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -45,7 +45,7 @@ void draftV4ShouldHaveExclusiveMinimum() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft4()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_4, builder -> builder.metaSchema(dialect)); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":0}"; @@ -73,7 +73,7 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_6, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_6, builder -> builder.metaSchema(dialect)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } @@ -92,7 +92,7 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(dialect)); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index 9e0d77ca3..58b3f575f 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -45,7 +45,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void shouldUseFormatKeyword() { Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .formatKeywordFactory(CustomFormatKeyword::new).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"format\": \"hello\"\r\n" diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 0527af659..3c42a7795 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -43,7 +43,7 @@ void unknownFormatNoVocab() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -56,7 +56,7 @@ void unknownFormatNoVocabStrictTrue() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -85,7 +85,7 @@ void unknownFormatAssertionsVocab() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) @@ -100,7 +100,7 @@ void unknownFormatShouldCollectAnnotations() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -143,7 +143,7 @@ void formatAssertions(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { @@ -167,7 +167,7 @@ void patternFormatDeprecated() { }) .build(); - JsonSchemaFactory factory = new JsonSchemaFactory.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) + SchemaRegistry factory = new SchemaRegistry.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) .metaSchema(customMetaSchema).build(); String formatSchema = "{\r\n" + " \"type\": \"string\",\r\n" @@ -216,7 +216,7 @@ void shouldAllowNumberFormat() { }) .build(); - JsonSchemaFactory factory = new JsonSchemaFactory.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) + SchemaRegistry factory = new SchemaRegistry.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) .metaSchema(customMetaSchema).build(); String formatSchema = "{\r\n" + " \"type\": \"number\",\r\n" @@ -241,7 +241,7 @@ void draft7DisableFormat() { String schemaData = "{\r\n" + " \"format\":\"uri\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); }); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index d118bb856..3f26d6fba 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -48,7 +48,7 @@ void walkValidateThen() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -91,7 +91,7 @@ void walkValidateElse() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -134,7 +134,7 @@ void walkValidateNull() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -175,7 +175,7 @@ void walkNoValidate() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 18385ae20..e914322d2 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -33,7 +33,7 @@ class Issue1091Test { void testHasAdjacentKeywordInEvaluationPath() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4) + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4) .getSchema(SchemaLocation.of("classpath:schema/issue1091.json"), config); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index e732bf037..0164e5864 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -25,7 +25,7 @@ class Issue255Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index 1c6402a13..1a9209f33 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -12,8 +12,8 @@ class Issue285Test { private final ObjectMapper mapper = new ObjectMapper(); - private final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) + private final SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("http://json-schema.org", "resource:") .mapPrefix("https://json-schema.org", "resource:")) diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index 0c899f96c..ee9aa0238 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -10,7 +10,7 @@ class Issue295Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index b565dcc0e..62adbd4f9 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -11,12 +11,12 @@ class Issue313Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } protected Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 7470f2178..dc549b5ca 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -8,8 +8,8 @@ import com.networknt.schema.dialect.Dialects; class Issue314Test { - private static final JsonSchemaFactory FACTORY = - JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) + private static final SchemaRegistry FACTORY = + SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) .metaSchema( Dialect.builder( "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index e55c22146..e7c621c8e 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -10,7 +10,7 @@ class Issue327Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 1f0bcb3a8..ef823ab37 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -11,7 +11,7 @@ class Issue342Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index 527d2e2b7..aa228bab6 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -11,7 +11,7 @@ class Issue347Test { @Test void failure() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 888492fba..63f6d63b8 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -26,8 +26,8 @@ private void setupSchema() throws IOException { .failFast(true) .typeLoose(false) .build(); - JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 4808cddba..556951896 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -25,8 +25,8 @@ void setup() throws IOException { private void setupSchema() throws IOException { SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().typeLoose(false).build(); - JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) + SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) .build(); SchemaLocation uri = getSchema(); diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index bb9dba669..266888053 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -28,7 +28,7 @@ class Issue375Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index 58ec6e7c8..7a7fc6b0d 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -11,7 +11,7 @@ class Issue383Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index 9470c96f7..e506e7ef5 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -14,7 +14,7 @@ class Issue396Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index bc9da2a1f..6c9a75feb 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -10,7 +10,7 @@ class Issue404Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index da4f5b459..643898785 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -14,7 +14,7 @@ class Issue406Test { @Test void testPreloadingNotHappening() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass Assertions.assertNotNull(schema); @@ -22,7 +22,7 @@ void testPreloadingNotHappening() { @Test void testPreloadingHappening() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(JsonSchemaException.class, new Executable() { @@ -36,7 +36,7 @@ public void execute() { @Test void testPreloadingHappeningForCircularDependency() { - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index ad00a62db..2b8805a01 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -13,7 +13,7 @@ */ class Issue426Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index ea6ae9017..51dfdc20b 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -14,8 +14,8 @@ class Issue428Test { protected ObjectMapper mapper = new ObjectMapper(); - protected JsonSchemaFactory validatorFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).build(); + protected SchemaRegistry validatorFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).build(); private void runTestFile(String testCaseFile) throws Exception { final SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + testCaseFile); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 57f28f4c1..04f110d63 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -21,7 +21,7 @@ class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .propertyWalkListener(new CountingWalker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index 123290119..245ef2261 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -11,7 +11,7 @@ class Issue456Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 6386e7f45..8b6f11ddd 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -17,7 +17,7 @@ class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 5ed6c7f1f..354abb986 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -37,7 +37,7 @@ import com.networknt.schema.walk.WalkFlow; class Issue467Test { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); private static final String schemaPath = "/schema/issue467.json"; protected ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index dce82fd70..0c2da6423 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -78,7 +78,7 @@ private Map convertErrorsToMap(List errors) { } private Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index f2ca31cdb..3f653b9fb 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -51,7 +51,7 @@ class Issue475Test { @Test void draft4() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_4, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); @@ -65,7 +65,7 @@ void draft4() throws Exception { @Test void draft6() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_6, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); @@ -79,7 +79,7 @@ void draft6() throws Exception { @Test void draft7() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); @@ -93,7 +93,7 @@ void draft7() throws Exception { @Test void draft201909() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); @@ -107,7 +107,7 @@ void draft201909() throws Exception { @Test void draft202012() throws Exception { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index b5e0599a7..39dd07cf3 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -18,7 +18,7 @@ class Issue493Test { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); private static final String schemaPath1 = "/schema/issue493.json"; private JsonNode getJsonNodeFromJsonData (String jsonFilePath) diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index e18baed9d..7642ca57c 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -14,9 +14,9 @@ class Issue518Test { .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialects.getDraft7()) .build(); - private static final JsonSchemaFactory FACTORY = - JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) + private static final SchemaRegistry FACTORY = + SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) .metaSchema(igluMetaSchema) .build(); diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index c1dd2da85..72356140d 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -7,7 +7,7 @@ class Issue532Test { @Test void failure() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index cfce65200..c83e513cb 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -12,7 +12,7 @@ class Issue550Test { protected Schema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index ff1e96bf0..04621bccb 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -25,7 +25,7 @@ class Issue575Test { @BeforeAll static void init() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); String schemaPath = "/schema/issue575-2019-09.json"; InputStream schemaInputStream = Issue575Test.class.getResourceAsStream(schemaPath); schema = factory.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index c0ae8c6e9..2d37c9e85 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -11,7 +11,7 @@ void failure() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) .build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index 1a50540f6..947eaf3d6 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -10,7 +10,7 @@ class Issue606Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index 399276f1c..bce1bc06e 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -32,7 +32,7 @@ class Issue619Test { - private JsonSchemaFactory factory; + private SchemaRegistry factory; private JsonNode one; private JsonNode two; private JsonNode three; @@ -53,7 +53,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; - factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, + factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index c5d7e2fb3..850f26ef3 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -37,7 +37,7 @@ void testBinaryNode() throws Exception { // schema with data property of type string: InputStream schemaInputStream = getClass().getResourceAsStream("/draft7/issue650.json"); - Schema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); + Schema schema = SchemaRegistry.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); // create model first: Issue650Test.Model model = new Issue650Test.Model(); diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index a1045fbec..019829cd5 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -14,7 +14,7 @@ class Issue664Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index 945e27760..873c92c6d 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -23,8 +23,8 @@ void testUrnUriAsLocalRef() throws IOException { @Test void testUrnUriAsLocalRef_ExternalURN() { - JsonSchemaFactory factory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)) + SchemaRegistry factory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) .schemaMappers(schemaMappers -> { schemaMappers.mappings(Collections.singletonMap("urn:data", "classpath:draft7/urn/issue665_external_urn_subschema.json")); diff --git a/src/test/java/com/networknt/schema/Issue668Test.java b/src/test/java/com/networknt/schema/Issue668Test.java index 259385cee..05593352c 100644 --- a/src/test/java/com/networknt/schema/Issue668Test.java +++ b/src/test/java/com/networknt/schema/Issue668Test.java @@ -11,7 +11,7 @@ class Issue668Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); YAMLMapper mapper = new YAMLMapper(); JsonNode node = mapper.readTree(schemaContent); return factory.getSchema(node); diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index 86b911f0f..d83c8f68d 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -54,7 +54,7 @@ void testLocaleSwitch() throws JsonProcessingException { } private Schema getSchema(SchemaValidatorsConfig config) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index 841b7b4be..ecc2d67f5 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -81,7 +81,7 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin @MethodSource("errors") void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); @@ -114,7 +114,7 @@ static Stream specialCharacterTests() { void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().pathType(pathType).build(); - Schema schema = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09) + Schema schema = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 4d6762c7a..6a085e0f2 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -50,7 +50,7 @@ void test() throws JsonProcessingException { + " \"billing_address\" : \"my_billing_address\"\n" + "}\n"; - Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false); System.out.println(stringCollector.strings); diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index a1a1ea67d..a25728242 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -73,7 +73,7 @@ private Schema createSchema(boolean useCustomDateFormat) { }) .build(); - return new JsonSchemaFactory + return new SchemaRegistry .Builder() .defaultMetaSchemaIri(overrideDateTimeValidator.getIri()) .metaSchema(overrideDateTimeValidator) diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index 74d6c64aa..ba9091768 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -12,7 +12,7 @@ class Issue792 { @Test void test() throws JsonProcessingException { - JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry schemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); String schemaDef = "{\n" + diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 44393b20e..aa30dc5ae 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -14,8 +14,8 @@ class Issue824Test { @Test void validate() throws JsonProcessingException { - final Schema v201909SpecSchema = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)) + final Schema v201909SpecSchema = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index e9d9ece44..f3bcf0675 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -31,7 +31,7 @@ public String getErrorMessageDescription() { } } - private JsonSchemaFactory buildV7PlusNoFormatSchemaFactory() { + private SchemaRegistry buildV7PlusNoFormatSchemaFactory() { List formats; formats = new ArrayList<>(); formats.add(new NoMatchFormat()); @@ -41,7 +41,7 @@ private JsonSchemaFactory buildV7PlusNoFormatSchemaFactory() { Dialects.getDraft7()) .formats(formats) .build(); - return new JsonSchemaFactory.Builder().defaultMetaSchemaIri(jsonMetaSchema.getIri()).metaSchema(jsonMetaSchema).build(); + return new SchemaRegistry.Builder().defaultMetaSchemaIri(jsonMetaSchema.getIri()).metaSchema(jsonMetaSchema).build(); } protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws IOException { @@ -54,7 +54,7 @@ void testV7WithNonMatchingCustomFormat() throws IOException { String schemaPath = "/schema/issue832-v7.json"; String dataPath = "/data/issue832.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - JsonSchemaFactory factory = buildV7PlusNoFormatSchemaFactory(); + SchemaRegistry factory = buildV7PlusNoFormatSchemaFactory(); Schema schema = factory.getSchema(schemaInputStream); InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index e9b398386..e80c3442f 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -49,7 +49,7 @@ void test() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 2d78d22a4..75dd84e91 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -30,7 +30,7 @@ void test() throws Exception { + " \"unevaluatedProperties\": false\n" + "}"; - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); Schema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index c1b162a56..5768723bc 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -105,7 +105,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) .getSchema(SchemaLocation.of("http://www.example.org"), JsonMapperFactory.getInstance().readTree(schema)); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index 8a7dfb319..5dc894fb8 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -7,9 +7,9 @@ class Issue928Test { private final ObjectMapper mapper = new ObjectMapper(); - private JsonSchemaFactory factoryFor(Specification.Version version) { - return JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(version)) + private SchemaRegistry factoryFor(Specification.Version version) { + return SchemaRegistry + .builder(SchemaRegistry.getInstance(version)) .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://example.org", "classpath:")) .build(); } @@ -30,7 +30,7 @@ void test_202012() { } void test_spec(Specification.Version specVersion) { - JsonSchemaFactory schemaFactory = factoryFor(specVersion); + SchemaRegistry schemaFactory = factoryFor(specVersion); String versionId = specVersion.getDialectId(); String versionStr = versionId.substring(versionId.indexOf("draft") + 6, versionId.indexOf("/schema")); diff --git a/src/test/java/com/networknt/schema/Issue935Test.java b/src/test/java/com/networknt/schema/Issue935Test.java index 2da974055..b23c1118d 100644 --- a/src/test/java/com/networknt/schema/Issue935Test.java +++ b/src/test/java/com/networknt/schema/Issue935Test.java @@ -26,6 +26,6 @@ class Issue935Test { void shouldThrowInvalidSchemaException() { String schema = "{ \"$schema\": \"0\" }"; assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schema)); + () -> SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schema)); } } diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index f59a958b2..56ca42fa1 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -31,9 +31,9 @@ void shouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); try { - JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 43b9c53f5..941542d04 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -48,7 +48,7 @@ void shouldNotThrowException() { + " }\r\n" + " }\r\n" + " }"; - Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index e32a96e87..592f9c8ae 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -31,7 +31,7 @@ void shouldNotThrowException() { + " \"greeting\": {}\r\n" + " }\r\n" + "}"; - Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); } } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index e1a188d48..b39255a05 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -67,7 +67,7 @@ void test() { + " \"type\": \"Point\",\r\n" + " \"coordinates\": [1, 1]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index 110dc1777..dd1d398c4 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -47,7 +47,7 @@ void test() throws JsonProcessingException { vocabularies.remove(Vocabulary.V202012_VALIDATION.getIri()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)).getSchema(schemaNode); String inputData = "{\r\n" + " \"textValue\": \"hello\"\r\n" diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 2bacd0995..58ce4a7ba 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -44,7 +44,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -67,7 +67,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -106,7 +106,7 @@ void walkNullPrefixItems() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 910d00428..a40e609ee 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -47,7 +47,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -74,7 +74,7 @@ void messageAdditionalItemsInvalid() { + " \"items\": [{}]," + " \"additionalItems\": {\"type\": \"integer\"}" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -101,7 +101,7 @@ void messageAdditionalItemsFalseInvalid() { + " \"items\": [{}]," + " \"additionalItems\": false" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -124,7 +124,7 @@ void walk() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -160,7 +160,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -202,7 +202,7 @@ void walkNullTupleItemsAdditional() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -252,7 +252,7 @@ void walkTupleItemsAdditional() throws JsonProcessingException { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -306,7 +306,7 @@ void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { + " \"default\": \"additional\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index f953d0274..106b293c3 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -32,7 +32,7 @@ void cacheDisabled() throws JsonProcessingException { private void runCacheTest(boolean enableCache) throws JsonProcessingException { CustomURIFetcher fetcher = new CustomURIFetcher(); - JsonSchemaFactory factory = buildJsonSchemaFactory(fetcher, enableCache); + SchemaRegistry factory = buildJsonSchemaFactory(fetcher, enableCache); SchemaLocation schemaUri = SchemaLocation.of("cache:uri_mapping/schema1.json"); String schema = "{ \"$schema\": \"https://json-schema.org/draft/2020-12/schema\", \"title\": \"json-object-with-schema\", \"type\": \"string\" }"; fetcher.addResource(schemaUri.getAbsoluteIri(), schema); @@ -44,8 +44,8 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { assertEquals(objectMapper.readTree(enableCache ? schema : modifiedSchema), factory.getSchema(schemaUri, SchemaValidatorsConfig.builder().build()).schemaNode); } - private JsonSchemaFactory buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { - return JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12)) + private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { + return SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) .metaSchema(Dialects.getDraft202012()) diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index d254dcde5..7eb05d5d8 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -26,14 +26,14 @@ class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json"), config); } @Test void preloadSchemaRefMaxNestingDepth() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .preloadJsonSchemaRefMaxNestingDepth(20) .build(); diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 4332735e6..7a3f4b97e 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -120,7 +120,7 @@ void testIllegalArgumentException() { } private Schema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { - JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry schemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().applyDefaultsStrategy(applyDefaultsStrategy).build(); return schemaFactory.getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json"), schemaValidatorsConfig); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index d548c072c..441ecad52 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -47,8 +47,8 @@ private void setupSchema() { schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); - final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) + final SchemaRegistry schemaFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) .build(); this.jsonSchema = schemaFactory.getSchema(getSchema(), schemaValidatorsConfigBuilder.build()); // Create another Schema. @@ -131,7 +131,7 @@ void testWalkMissingNodeWithPropertiesSchemaShouldNotThrow() { + " }\n" + " }"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); JsonNode missingNode = MissingNode.getInstance(); assertDoesNotThrow(() -> schema.walk(missingNode, true)); diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index e59766dc2..002a883f3 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -34,7 +34,7 @@ class LocaleTest { private Schema getSchema(SchemaValidatorsConfig config) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); return factory.getSchema( "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); @@ -88,7 +88,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { + " \"$id\": \"https://www.example.com\",\r\n" + " \"type\": \"object\"\r\n" + "}"; - Schema jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); @@ -96,7 +96,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { assertEquals("$: integer gefunden, object erwartet", messages.iterator().next().toString()); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ENGLISH).build(); - jsonSchema = JsonSchemaFactory.getInstance(Version.DRAFT_7) + jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema), config); messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); @@ -154,7 +154,7 @@ void encoding() { + " \"type\": \"string\",\r\n" + " \"maxLength\": 5\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 95cb8b20b..a034fbe1d 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -34,7 +34,7 @@ class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s, \"exclusiveMaximum\": true}"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); private static final ObjectMapper mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 32733bf26..0856a5afb 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -73,7 +73,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void message() { Dialect dialect = Dialect.builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) .keyword(new EqualsKeyword()).build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); String schemaData = "{\r\n" + " \"type\": \"string\",\r\n" + " \"equals\": \"helloworld\"\r\n" diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 36ede36d9..be3301fc2 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -41,7 +41,7 @@ void oas31() throws IOException { try (InputStream input = MetaSchemaValidationTest.class.getResourceAsStream("/schema/oas/3.1/petstore.json")) { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index ef23de443..237500a9a 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -38,7 +38,7 @@ class MinimumValidatorTest { private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s }"; private static final String NEGATIVE_MESSAGE_TEMPLATE = "Expecting validation errors, value %s is smaller than minimum %s"; private static final String POSITIVT_MESSAGE_TEMPLATE = "Expecting no validation errors, value %s is greater than minimum %s"; - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); private static ObjectMapper mapper; private static ObjectMapper bigDecimalMapper; diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 0771565d1..0d0e3571f 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -47,7 +47,7 @@ class MultipleOfValidatorTest { @Test void test() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; @@ -62,7 +62,7 @@ void test() { @Test void testTypeLoose() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":\"123.892\",\"value2\":\"123456.2934\",\"value3\":123.123}"; diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index 30f2ce20b..a87c82103 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -36,7 +36,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index ebabc8ddc..846357a58 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -64,7 +64,7 @@ void oneOfMultiple() { + " \"fox\" : \"test\",\r\n" + " \"world\" : \"test\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -105,7 +105,7 @@ void oneOfZero() { String inputData = "{\r\n" + " \"test\" : 1\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -137,7 +137,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -184,7 +184,7 @@ void invalidSwaggerIoExample() { + " age:\r\n" + " type: integer"; - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) @@ -258,7 +258,7 @@ void fixedSwaggerIoExample() { + " - hunts\r\n" + " - age"; - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) @@ -301,7 +301,7 @@ void oneOfDiscriminatorEnabled() { + " }\r\n" + " ]\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); String inputData = "{}"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -355,7 +355,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -374,7 +374,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -443,7 +443,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -462,7 +462,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -489,7 +489,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 36a673624..92b34de47 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -14,8 +14,8 @@ class OpenAPI30JsonSchemaTest { protected ObjectMapper mapper = new ObjectMapper(); - protected JsonSchemaFactory validatorFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)).build(); + protected SchemaRegistry validatorFactory = SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).build(); OpenAPI30JsonSchemaTest() { } diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 7d724d1e0..e573e5c72 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -22,7 +22,7 @@ class OutputFormatTest { - private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); + private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); private static final String schemaPath1 = "/schema/output-format-schema.json"; private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { @@ -107,7 +107,7 @@ void customFormat() { + " }\n" + " }\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12) + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12) .getSchema(schemaData, InputFormat.JSON, SchemaValidatorsConfig.builder().build()); String inputData = "{\n" + " \"type\": \"cat\",\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index b8ce8dfc0..38f23fe8e 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -95,7 +95,7 @@ class OutputUnitTest { + "}"; @Test void annotationCollectionList() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -112,7 +112,7 @@ void annotationCollectionList() throws JsonProcessingException { @Test void annotationCollectionHierarchical() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -129,7 +129,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { @Test void annotationCollectionHierarchical2() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -178,7 +178,7 @@ void formatAnnotation(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -197,7 +197,7 @@ void formatAssertion(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -216,7 +216,7 @@ void typeUnion() { String typeSchema = "{\r\n" + " \"type\": [\"string\",\"array\"]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(typeSchema, config); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -265,7 +265,7 @@ void unevaluatedProperties() throws JsonProcessingException { + " \"unevaluatedProperties\": false\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -315,7 +315,7 @@ void anyOf() throws JsonProcessingException { + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -337,7 +337,7 @@ void listAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); @@ -352,7 +352,7 @@ void hierarchicalAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 344b1d7fb..fa5a848e1 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -55,7 +55,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .builder(URI, Dialects.getDraft201909()) .build(); - final JsonSchemaFactory validatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { @@ -72,7 +72,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .format(PatternFormat.of("email", "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "format.email")) .build(); - final JsonSchemaFactory overrideValidatorFactory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(overrideValidatorMetaSchema).build(); + final SchemaRegistry overrideValidatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(overrideValidatorMetaSchema).build(); final Schema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); messages = overrideValidatorSchema.validate(targetNode, executionContext -> { diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 187ccd7f1..51600d3cf 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -12,7 +12,7 @@ class OverwritingCustomMessageBugTest { private Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index bf70cad88..9345ab977 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -41,7 +41,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); @@ -56,7 +56,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}", config); JsonNode node = getJsonNodeFromStringContent(""); @@ -79,7 +79,7 @@ void message() { + " }\n" + " }\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" @@ -130,7 +130,7 @@ void annotation() { + " }\n" + " }\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" diff --git a/src/test/java/com/networknt/schema/PatternValidatorTest.java b/src/test/java/com/networknt/schema/PatternValidatorTest.java index 4578b6ffd..b3854609b 100644 --- a/src/test/java/com/networknt/schema/PatternValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternValidatorTest.java @@ -32,7 +32,7 @@ void failFast() { + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" + "}"; String inputData = "\"hello\""; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); assertFalse(result); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 220db5114..ad393d060 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -54,7 +54,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -80,7 +80,7 @@ void messageValid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1]"; @@ -99,7 +99,7 @@ void messageInvalidAdditionalItems() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}],\r\n" + " \"items\": false" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1, 2]"; @@ -130,7 +130,7 @@ void walkNull() { + " }\n" + " ]\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -183,7 +183,7 @@ void walkDefaults() throws JsonProcessingException { + " }\n" + " ]\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 6d75f2c5e..1ccf1d270 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -12,7 +12,7 @@ class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 0d71a9832..0c1a6cf83 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -38,7 +38,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"propertyNames\": {\"maxLength\": 3}\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 82618082c..0ea223702 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -40,7 +40,7 @@ private Schema loadJsonSchema(Boolean write) { } private Schema getJsonSchema(Boolean write) { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig schemaConfig = createSchemaConfig(write); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); return factory.getSchema(schema, schemaConfig); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 66d8b82db..67513d842 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -21,7 +21,7 @@ class RecursiveReferenceValidatorExceptionTest extends AbstractJsonSchemaTestSui void testInvalidRecursiveReference() { // Arrange String invalidSchemaJson = "{ \"$recursiveRef\": \"invalid\" }"; - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getMetaSchema(), diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 290e5361f..d1b3217d2 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -16,7 +16,7 @@ class RefTest { @Test void shouldLoadRelativeClasspathReference() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); String input = "{\r\n" @@ -39,7 +39,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { @Test void shouldLoadSchemaResource() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 1432836bf..e08070ce0 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -40,7 +40,7 @@ void resolveSamePathDotSlash() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -59,7 +59,7 @@ void resolveSamePath() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -78,7 +78,7 @@ void resolveParent() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -97,7 +97,7 @@ void resolveComplex() { + " \"type\": \"integer\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -107,7 +107,7 @@ void resolveComplex() { @Test void classPathSlash() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" @@ -123,7 +123,7 @@ void classPathSlash() { @Test void classPathNoSlash() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 0d0f62380..64c772a72 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -55,7 +55,7 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -99,7 +99,7 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -143,7 +143,7 @@ void validateRequestRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -181,7 +181,7 @@ void validateResponseRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index 9c0c9e1f0..f00062e18 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -18,7 +18,7 @@ class SampleTest { @Test void schemaFromSchemaLocationMapping() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers( + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers( schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. @@ -40,7 +40,7 @@ void schemaFromSchemaLocationMapping() { void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); /* @@ -61,7 +61,7 @@ void schemaFromSchemaLocationContent() { @Test void schemaFromClasspath() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -82,7 +82,7 @@ void schemaFromClasspath() { @Test void schemaFromString() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -98,7 +98,7 @@ void schemaFromString() { @Test void schemaFromJsonNode() throws JsonProcessingException { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); /* diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index 403a43bf4..c59731199 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -217,7 +217,7 @@ void documentFragment() { @Test void shouldLoadEscapedFragment() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); Schema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); List result = schema.validate("1", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java b/src/test/java/com/networknt/schema/SchemaRegistryTest.java similarity index 92% rename from src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java rename to src/test/java/com/networknt/schema/SchemaRegistryTest.java index 48ddaa907..bdcaa39d8 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/SchemaRegistryTest.java @@ -31,7 +31,7 @@ /** * Tests for JsonSchemaFactory. */ -class JsonSchemaFactoryTest { +class SchemaRegistryTest { @Test void concurrency() { String metaSchemaData = "{\r\n" @@ -47,7 +47,7 @@ void concurrency() { + " { \"$ref\": \"https://json-schema.org/draft/2020-12/meta/core\" }\r\n" + " ]\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index e3dcfb60f..80aa6dabd 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -55,7 +55,7 @@ void concurrency() throws Exception { String inputData = "{\r\n" + " \"name\": 1\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().preloadJsonSchema(false).build(); diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index 99d51e5e2..d1f4f1fdb 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -30,7 +30,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void shouldCallAllKeywordListenerOnWalkStart() throws Exception { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); AllKeywordListener allKeywordListener = new AllKeywordListener(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 1e1892078..93f038f73 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -52,7 +52,7 @@ class TypeValidatorTest { @Test void testTypeLoose() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" @@ -101,7 +101,7 @@ void integer() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); @@ -130,7 +130,7 @@ void integerDraft4() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling @@ -145,7 +145,7 @@ void walkNull() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4).getSchema(schemaData); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } @@ -173,7 +173,7 @@ void nullable() { + " \"nested\":null\r\n" + " }\r\n" + "}"; - final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); final Schema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() .nullableKeywordEnabled(false) .build()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index e9b7bb5d5..e21facd8e 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -43,7 +43,7 @@ void unevaluatedItemsFalse() { + " \"unevaluatedItems\" : false\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -69,7 +69,7 @@ void unevaluatedItemsSchema() { + " \"unevaluatedItems\" : { \"type\" : \"string\" }\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 48871738e..e5461a492 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -61,7 +61,7 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key3\": \"value3\",\r\n" + " \"key4\": \"value4\"\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -116,7 +116,7 @@ void subschemaProcessing() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -144,7 +144,7 @@ void unevaluatedPropertiesSchema() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -189,7 +189,7 @@ void ref() { + " \"unevaluatedProperties\": false\r\n" + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } @@ -227,7 +227,7 @@ void nestedRef() { Map schemas = new HashMap<>(); schemas.put("https://www.example.org/PrimaryDeviceConfiguration.json", primaryDeviceConfiguration); schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2019_09, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) .getSchema(schemaData); diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index a590c233c..e61532689 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -23,7 +23,7 @@ void testSchema1() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema1); List errors = jsonSchema.validate(jsonNode); @@ -37,7 +37,7 @@ void testSchema2() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema2); List errors = jsonSchema.validate(jsonNode); @@ -50,7 +50,7 @@ void testSchema3() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema3); List errors = jsonSchema.validate(jsonNode); @@ -68,10 +68,10 @@ void testNormalize() throws JsonSchemaException { String uri04 = "http://json-schema.org/draft-07/schema?key=value&key2=value2"; String expected = DialectId.DRAFT_7; - Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri01)); - Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri02)); - Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri03)); - Assertions.assertEquals(expected, JsonSchemaFactory.normalizeMetaSchemaUri(uri04)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri01)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri02)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri03)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri04)); } } diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index f03e3f556..3cc6f38bf 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.JsonSchemaFactory.Builder; +import com.networknt.schema.SchemaRegistry.Builder; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; @@ -50,11 +50,11 @@ class UriMappingTest { void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); Dialect draftV4 = Dialects.getDraft4(); - Builder builder = JsonSchemaFactory.builder() + Builder builder = SchemaRegistry.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); - JsonSchemaFactory instance = builder.build(); + SchemaRegistry instance = builder.build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); assertEquals(0, schema.validate(mapper.readTree(mappings)).size()); @@ -82,7 +82,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - JsonSchemaFactory instance = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -101,7 +101,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); Dialect draftV4 = Dialects.getDraft4(); - Builder builder = JsonSchemaFactory.builder() + Builder builder = SchemaRegistry.builder() .defaultMetaSchemaIri(draftV4.getIri()) .metaSchema(draftV4) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); @@ -119,7 +119,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); @@ -149,7 +149,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); @@ -167,7 +167,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } catch (Exception ex) { fail("Unexpected exception thrown"); } - instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) + instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(example, config); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); @@ -176,7 +176,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); - JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 0c7768af1..edddfa86b 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -29,12 +29,12 @@ void testURNToURI() throws Exception { try { is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); Dialect draftV7 = Dialects.getDraft7(); - JsonSchemaFactory.Builder builder = JsonSchemaFactory.builder() + SchemaRegistry.Builder builder = SchemaRegistry.builder() .defaultMetaSchemaIri(draftV7.getIri()) .metaSchema(draftV7) .schemaMappers(schemaMappers -> schemaMappers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) ); - JsonSchemaFactory instance = builder.build(); + SchemaRegistry instance = builder.build(); Schema schema = instance.getSchema(is); assertEquals(0, schema.validate(mapper.readTree(urlTestData)).size()); } catch( Exception e) { diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index 0320cdb67..1a40a4faa 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -37,7 +37,7 @@ class V4JsonSchemaTest { void testLoadingWithId() throws Exception { try (InputStream inputStream = new FileInputStream("src/test/resources/remotes/self_ref/selfRef.json")) { JsonNode schemaJson = mapper.readTree(inputStream); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); @SuppressWarnings("unused") Schema schema = factory.getSchema(schemaJson); } @@ -89,8 +89,8 @@ private List validateFailingFastSchemaFor(final String schemaFileName, fi final JsonNode schema = getJsonNodeFromResource(objectMapper, schemaFileName); final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - return JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(Specification.Version.DRAFT_4)) + return SchemaRegistry + .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) .build() .getSchema(schema, config) .validate(dataFile); diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 14843378e..de0b3c959 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -60,7 +60,7 @@ void noValidation() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -75,7 +75,7 @@ void noValidation() { assertEquals(0, messages.size()); // Set validation vocab - schema = JsonSchemaFactory + schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -112,7 +112,7 @@ void noFormatValidation() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -128,7 +128,7 @@ void noFormatValidation() { assertEquals(0, messages.size()); // Set format assertion vocab - schema = JsonSchemaFactory + schema = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -164,7 +164,7 @@ void requiredUnknownVocabulary() { + " }\r\n" + " }\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory + SchemaRegistry factory = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", @@ -207,7 +207,7 @@ void customVocabulary() { .builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) .vocabularyFactory(vocabularyFactory) .build(); - JsonSchemaFactory factory = JsonSchemaFactory + SchemaRegistry factory = SchemaRegistry .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java index 5e5209eeb..2223fa1c0 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.Specification.Version; /** @@ -26,7 +26,7 @@ public class NetworkntBasicRunner implements Callable { public NetworkntBasicRunner() { ObjectMapper objectMapper = new ObjectMapper(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_4); try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ObjectReader reader = objectMapper.reader(); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index 3a689793c..8b98d83c2 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -15,7 +15,7 @@ import com.networknt.schema.AbsoluteIri; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; @@ -66,7 +66,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { for (TestCase testCase : testSource.getTestCases()) { SchemaLocation testCaseFileUri = SchemaLocation .of("classpath:" + toForwardSlashPath(testCase.getSpecification())); - Schema schema = JsonSchemaFactory + Schema schema = SchemaRegistry .getInstance(defaultVersion, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) .getSchema(testCaseFileUri, testCase.getSchema(), SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index 3ddf487e5..698eed527 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -24,7 +24,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index 778186eac..7722f1012 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -24,7 +24,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index 5b4b8f45b..8916c8ecd 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.params.provider.EnumSource; import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -60,7 +60,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -89,7 +89,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index 6732be4b5..bf6035aa5 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -24,7 +24,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index 707827df1..a44a4c13f 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -24,7 +24,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index ea7f34dd2..e4e48d49f 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -26,7 +26,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.OutputFormat; import com.networknt.schema.PathType; import com.networknt.schema.SchemaLocation; @@ -45,7 +45,7 @@ class OpenApi30Test { */ @Test void validateMetaSchema() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder.metaSchema(OpenApi30.getInstance()) .defaultMetaSchemaIri(OpenApi30.getInstance().getIri()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); @@ -75,7 +75,7 @@ void validateMetaSchema() { */ @Test void jsonPointerWithNumberInFragment() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); Schema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"), @@ -96,7 +96,7 @@ void exclusiveMaximum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMaximum\": true\r\n" + "}\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("100", InputFormat.JSON, OutputFormat.BOOLEAN)); @@ -113,7 +113,7 @@ void exclusiveMinimum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMinimum\": true\r\n" + "}\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_7, builder -> builder + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("0", InputFormat.JSON, OutputFormat.BOOLEAN)); diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 851ebcc38..294cbb0d3 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -24,7 +24,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.DisallowUnknownDialectFactory; @@ -40,7 +40,7 @@ class OpenApi31Test { */ @Test void validateVocabulary() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); Schema schema = factory @@ -69,7 +69,7 @@ void validateVocabulary() { */ @Test void validateMetaSchema() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); Schema schema = factory @@ -99,7 +99,7 @@ void validateMetaSchema() { */ @Test void discriminatorOneOfMultipleMatchShouldFail() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); Schema schema = factory @@ -119,7 +119,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { */ @Test void discriminatorOneOfNoMatchShouldFail() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); Schema schema = factory @@ -141,7 +141,7 @@ void discriminatorOneOfNoMatchShouldFail() { */ @Test void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(OpenApi31.getInstance()) .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); Schema schema = factory diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java index 8ef02d89c..f19c06247 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; @@ -34,7 +34,7 @@ class AllowSchemaLoaderTest { @Test void integration() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .add(new AllowSchemaLoader(iri -> iri.toString().startsWith("classpath:"))))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, diff --git a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java index 77645064f..9c92fcc93 100644 --- a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; @@ -32,7 +32,7 @@ class DisallowSchemaLoaderTest { @Test void integration() { - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.add(DisallowSchemaLoader.getInstance()))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 27d7dcbdd..dd8240ec3 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -33,7 +33,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -87,7 +87,7 @@ void jsonLocation() { String inputData = "{\r\n" + " \"startDate\": \"1\"\r\n" + "}"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, InputFormat.JSON, config); @@ -133,7 +133,7 @@ void yamlLocation() { + " minLength: 6\r\n"; String inputData = "---\r\n" + "startDate: '1'\r\n"; - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, InputFormat.YAML, config); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index 7409198d2..fe90d2f05 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -37,7 +37,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; @@ -104,7 +104,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -184,7 +184,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -269,7 +269,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -342,7 +342,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -391,7 +391,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09) + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09) .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" @@ -555,7 +555,7 @@ void applyDefaults() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -612,7 +612,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -669,7 +669,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); @@ -737,7 +737,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertFalse(result.getErrors().isEmpty()); @@ -807,7 +807,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); @@ -858,7 +858,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -921,7 +921,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - Schema schema = JsonSchemaFactory.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); From c49ed41589657a56fb5ff27aaecbbf481c531ab1 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:55:47 +0800 Subject: [PATCH 16/74] Refactor SchemaRegistry --- .../java/com/networknt/schema/Schema.java | 2 +- .../com/networknt/schema/SchemaRegistry.java | 326 ++++++------------ .../com/networknt/schema/Specification.java | 54 +++ .../schema/SpecificationVersionDetector.java | 2 +- ...Factory.java => BasicDialectRegistry.java} | 39 +-- .../dialect/DefaultDialectRegistry.java | 13 +- .../schema/dialect/DialectRegistry.java | 13 +- .../serialization/BasicJsonNodeReader.java | 65 ++++ .../schema/AbstractJsonSchemaTest.java | 2 +- .../schema/AbstractJsonSchemaTestSuite.java | 2 +- .../AdditionalPropertiesValidatorTest.java | 4 +- .../networknt/schema/AllOfValidatorTest.java | 4 +- .../networknt/schema/AnyOfValidatorTest.java | 4 +- .../schema/BaseJsonSchemaValidatorTest.java | 10 +- .../schema/CollectorContextTest.java | 13 +- .../networknt/schema/ConstValidatorTest.java | 10 +- .../schema/ContentSchemaValidatorTest.java | 2 +- .../schema/CustomMetaSchemaTest.java | 2 +- .../com/networknt/schema/CustomUriTest.java | 2 +- .../schema/CyclicDependencyTest.java | 2 +- .../com/networknt/schema/DateTimeDSTTest.java | 2 +- .../DefaultJsonSchemaIdValidatorTest.java | 10 +- .../schema/DependentRequiredTest.java | 2 +- .../DisallowUnknownDialectFactoryTest.java | 61 ---- .../DisallowUnknownKeywordFactoryTest.java | 4 +- .../schema/DiscriminatorValidatorTest.java | 18 +- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 4 +- .../networknt/schema/ErrorHandlerTest.java | 4 +- .../com/networknt/schema/ExampleTest.java | 4 +- .../schema/ExclusiveMinimumValidatorTest.java | 10 +- .../schema/FormatKeywordFactoryTest.java | 4 +- .../networknt/schema/FormatValidatorTest.java | 22 +- .../com/networknt/schema/IfValidatorTest.java | 8 +- .../com/networknt/schema/Issue1091Test.java | 2 +- .../com/networknt/schema/Issue255Test.java | 2 +- .../com/networknt/schema/Issue285Test.java | 2 +- .../com/networknt/schema/Issue295Test.java | 2 +- .../com/networknt/schema/Issue313Test.java | 4 +- .../com/networknt/schema/Issue314Test.java | 10 +- .../com/networknt/schema/Issue327Test.java | 2 +- .../com/networknt/schema/Issue342Test.java | 2 +- .../com/networknt/schema/Issue347Test.java | 2 +- .../schema/Issue366FailFastTest.java | 2 +- .../schema/Issue366FailSlowTest.java | 2 +- .../com/networknt/schema/Issue375Test.java | 2 +- .../com/networknt/schema/Issue383Test.java | 2 +- .../com/networknt/schema/Issue396Test.java | 2 +- .../com/networknt/schema/Issue404Test.java | 2 +- .../com/networknt/schema/Issue406Test.java | 6 +- .../com/networknt/schema/Issue426Test.java | 2 +- .../com/networknt/schema/Issue428Test.java | 2 +- .../com/networknt/schema/Issue451Test.java | 2 +- .../com/networknt/schema/Issue456Test.java | 2 +- .../com/networknt/schema/Issue461Test.java | 2 +- .../com/networknt/schema/Issue467Test.java | 2 +- .../com/networknt/schema/Issue471Test.java | 2 +- .../com/networknt/schema/Issue475Test.java | 10 +- .../com/networknt/schema/Issue493Test.java | 2 +- .../com/networknt/schema/Issue518Test.java | 9 +- .../com/networknt/schema/Issue532Test.java | 2 +- .../com/networknt/schema/Issue550Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 2 +- .../com/networknt/schema/Issue606Test.java | 2 +- .../com/networknt/schema/Issue619Test.java | 2 +- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue664Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 2 +- .../com/networknt/schema/Issue668Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 4 +- .../com/networknt/schema/Issue724Test.java | 2 +- .../com/networknt/schema/Issue784Test.java | 6 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue832Test.java | 4 +- .../com/networknt/schema/Issue857Test.java | 2 +- .../com/networknt/schema/Issue877Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 2 +- .../com/networknt/schema/Issue928Test.java | 2 +- .../com/networknt/schema/Issue935Test.java | 2 +- .../com/networknt/schema/Issue936Test.java | 4 +- .../com/networknt/schema/Issue939Test.java | 2 +- .../com/networknt/schema/Issue940Test.java | 2 +- .../com/networknt/schema/Issue943Test.java | 2 +- .../com/networknt/schema/Issue994Test.java | 3 +- .../schema/ItemsValidator202012Test.java | 6 +- .../networknt/schema/ItemsValidatorTest.java | 16 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 5 +- .../schema/JsonSchemaPreloadTest.java | 4 +- .../schema/JsonWalkApplyDefaultsTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 6 +- .../java/com/networknt/schema/LocaleTest.java | 8 +- .../schema/MaximumValidatorTest.java | 2 +- .../com/networknt/schema/MessageTest.java | 3 +- .../schema/MetaSchemaValidationTest.java | 2 +- .../schema/MinimumValidatorTest.java | 2 +- .../schema/MultipleOfValidatorTest.java | 4 +- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 22 +- .../schema/OpenAPI30JsonSchemaTest.java | 2 +- .../networknt/schema/OutputFormatTest.java | 4 +- .../com/networknt/schema/OutputUnitTest.java | 20 +- .../schema/OverrideValidatorTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 2 +- .../PatternPropertiesValidatorTest.java | 8 +- .../schema/PatternValidatorTest.java | 2 +- .../schema/PrefixItemsValidatorTest.java | 10 +- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 2 +- .../schema/ReadOnlyValidatorTest.java | 2 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 4 +- .../networknt/schema/RefValidatorTest.java | 12 +- .../schema/RequiredValidatorTest.java | 8 +- .../java/com/networknt/schema/SampleTest.java | 10 +- .../networknt/schema/SchemaLocationTest.java | 2 +- .../networknt/schema/SchemaRegistryTest.java | 4 +- .../java/com/networknt/schema/SchemaTest.java | 2 +- .../networknt/schema/SharedConfigTest.java | 2 +- .../networknt/schema/TypeValidatorTest.java | 10 +- .../schema/UnevaluatedItemsValidatorTest.java | 4 +- .../UnevaluatedPropertiesValidatorTest.java | 10 +- .../schema/UnknownMetaSchemaTest.java | 14 +- .../com/networknt/schema/UriMappingTest.java | 19 +- .../java/com/networknt/schema/UrnTest.java | 5 +- .../networknt/schema/V4JsonSchemaTest.java | 4 +- .../com/networknt/schema/VocabularyTest.java | 19 +- .../benchmark/NetworkntBasicRunner.java | 2 +- .../NetworkntTestSuiteTestCases.java | 2 +- .../schema/format/IriFormatTest.java | 14 +- .../schema/format/IriReferenceFormatTest.java | 14 +- .../schema/format/TimeFormatTest.java | 4 +- .../schema/format/UriFormatTest.java | 14 +- .../schema/format/UriReferenceFormatTest.java | 14 +- .../networknt/schema/oas/OpenApi30Test.java | 18 +- .../networknt/schema/oas/OpenApi31Test.java | 21 +- .../resource/AllowSchemaLoaderTest.java | 2 +- .../resource/DisallowSchemaLoaderTest.java | 2 +- .../networknt/schema/utils/JsonNodesTest.java | 4 +- .../walk/JsonSchemaWalkListenerTest.java | 24 +- 142 files changed, 598 insertions(+), 682 deletions(-) rename src/main/java/com/networknt/schema/dialect/{DisallowUnknownDialectFactory.java => BasicDialectRegistry.java} (60%) create mode 100644 src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java delete mode 100644 src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 8fdf89b8b..e57c4e122 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -40,7 +40,7 @@ /** * Used for creating a schema with validators for validating inputs. This is - * created using {@link SchemaRegistry#getInstance(Version, Consumer)} + * created using {@link SchemaRegistry#withDefaultDialect(Version, Consumer)} * and should be cached for performance. *

* This is the core of json constraint implementation. It parses json constraint diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 56e4e6cdf..731072be2 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -17,21 +17,19 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.DefaultDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.dialect.DialectRegistry; -import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.DefaultSchemaLoader; import com.networknt.schema.resource.SchemaLoader; import com.networknt.schema.resource.SchemaLoaders; import com.networknt.schema.resource.SchemaMapper; import com.networknt.schema.resource.SchemaMappers; -import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.serialization.BasicJsonNodeReader; import com.networknt.schema.serialization.JsonNodeReader; -import com.networknt.schema.serialization.YamlMapperFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,34 +37,34 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; /** - * Factory for building {@link Schema} instances. The factory should be - * typically be created using {@link #getInstance(Version, Consumer)} and - * should be cached for performance. + * Registry for loading and registering {@link Schema} instances. *

- * JsonSchemaFactory instances are thread-safe provided its configuration is not + * This can be created with {@link #withDefaultDialect(Version)} or + * {@link #withDialect(Dialect)}. + *

+ * The registry should be cached for performance. + *

+ * A different registry should be used when loading unrelated schemas. + *

+ * SchemaRegistry instances are thread-safe provided its configuration is not * modified. */ public class SchemaRegistry { private static final Logger logger = LoggerFactory.getLogger(SchemaRegistry.class); public static class Builder { - private ObjectMapper jsonMapper = null; - private ObjectMapper yamlMapper = null; + private String defaultDialectId; + private DialectRegistry dialectRegistry = null; private JsonNodeReader jsonNodeReader = null; - private String defaultMetaSchemaIri; - private final ConcurrentMap metaSchemas = new ConcurrentHashMap<>(); private SchemaLoaders.Builder schemaLoadersBuilder = null; private SchemaMappers.Builder schemaMappersBuilder = null; private boolean enableSchemaCache = true; - private DialectRegistry metaSchemaFactory = null; /** * Sets the json node reader to read the data. @@ -83,62 +81,13 @@ public Builder jsonNodeReader(JsonNodeReader jsonNodeReader) { return this; } - /** - * Sets the json mapper to read the data. - *

- * If the object reader is set this will not be used. - *

- * This is deprecated use an object reader instead. - * - * @param jsonMapper the json mapper - * @return the builder - */ - @Deprecated - public Builder jsonMapper(final ObjectMapper jsonMapper) { - this.jsonMapper = jsonMapper; - return this; - } - - /** - * Sets the yaml mapper to read the data. - *

- * If the object reader is set this will not be used. - *

- * This is deprecated use an object reader instead. - * - * @param yamlMapper the yaml mapper - * @return the builder - */ - @Deprecated - public Builder yamlMapper(final ObjectMapper yamlMapper) { - this.yamlMapper = yamlMapper; - return this; - } - - public Builder defaultMetaSchemaIri(final String defaultMetaSchemaIri) { - this.defaultMetaSchemaIri = defaultMetaSchemaIri; + public Builder defaultDialectId(final String defaultDialectId) { + this.defaultDialectId = defaultDialectId; return this; } - public Builder metaSchemaFactory(final DialectRegistry jsonMetaSchemaFactory) { - this.metaSchemaFactory = jsonMetaSchemaFactory; - return this; - } - - public Builder metaSchema(final Dialect jsonMetaSchema) { - this.metaSchemas.put(normalizeMetaSchemaUri(jsonMetaSchema.getIri()), jsonMetaSchema); - return this; - } - - public Builder metaSchemas(final Collection jsonMetaSchemas) { - for (Dialect jsonMetaSchema : jsonMetaSchemas) { - metaSchema(jsonMetaSchema); - } - return this; - } - - public Builder metaSchemas(Consumer> customizer) { - customizer.accept(this.metaSchemas); + public Builder dialectRegistry(final DialectRegistry dialectRegistry) { + this.dialectRegistry = dialectRegistry; return this; } @@ -163,75 +112,49 @@ public Builder schemaMappers(Consumer schemaMappersBuilde return this; } - @Deprecated - public Builder addMetaSchema(final Dialect jsonMetaSchema) { - return metaSchema(jsonMetaSchema); - } - - @Deprecated - public Builder addMetaSchemas(final Collection jsonMetaSchemas) { - return metaSchemas(jsonMetaSchemas); - } - public SchemaRegistry build() { return new SchemaRegistry( - jsonMapper, - yamlMapper, - jsonNodeReader, - defaultMetaSchemaIri, + jsonNodeReader != null ? jsonNodeReader : BasicJsonNodeReader.getInstance(), + defaultDialectId, schemaLoadersBuilder, schemaMappersBuilder, - metaSchemas, enableSchemaCache, - metaSchemaFactory + dialectRegistry ); } } - private final ObjectMapper jsonMapper; - private final ObjectMapper yamlMapper; private final JsonNodeReader jsonNodeReader; - private final String defaultMetaSchemaIri; + private final String defaultDialectId; private final SchemaLoaders.Builder schemaLoadersBuilder; private final SchemaMappers.Builder schemaMappersBuilder; private final SchemaLoader schemaLoader; - private final ConcurrentMap metaSchemas; private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; - private final DialectRegistry metaSchemaFactory; + private final DialectRegistry dialectRegistry; private static final List DEFAULT_SCHEMA_LOADERS = SchemaLoaders.builder().build(); private static final List DEFAULT_SCHEMA_MAPPERS = SchemaMappers.builder().build(); private SchemaRegistry( - ObjectMapper jsonMapper, - ObjectMapper yamlMapper, JsonNodeReader jsonNodeReader, - String defaultMetaSchemaIri, + String defaultDialectId, SchemaLoaders.Builder schemaLoadersBuilder, SchemaMappers.Builder schemaMappersBuilder, - ConcurrentMap metaSchemas, boolean enableSchemaCache, - DialectRegistry metaSchemaFactory) { - this.metaSchemas = metaSchemas; - if (defaultMetaSchemaIri == null || defaultMetaSchemaIri.trim().isEmpty()) { - throw new IllegalArgumentException("defaultMetaSchemaIri must not be null or empty"); - } else if (metaSchemas == null || metaSchemas.isEmpty()) { - throw new IllegalArgumentException("Json Meta Schemas must not be null or empty"); - } else if (this.metaSchemas.get(normalizeMetaSchemaUri(defaultMetaSchemaIri)) == null) { - throw new IllegalArgumentException("Meta Schema for default Meta Schema URI must be provided"); + DialectRegistry dialectRegistry) { + if (defaultDialectId == null || defaultDialectId.trim().isEmpty()) { + throw new IllegalArgumentException("defaultDialectId must not be null or empty"); } - this.jsonMapper = jsonMapper; - this.yamlMapper = yamlMapper; this.jsonNodeReader = jsonNodeReader; - this.defaultMetaSchemaIri = defaultMetaSchemaIri; + this.defaultDialectId = defaultDialectId; this.schemaLoadersBuilder = schemaLoadersBuilder; this.schemaMappersBuilder = schemaMappersBuilder; this.schemaLoader = new DefaultSchemaLoader( schemaLoadersBuilder != null ? schemaLoadersBuilder.build() : DEFAULT_SCHEMA_LOADERS, schemaMappersBuilder != null ? schemaMappersBuilder.build() : DEFAULT_SCHEMA_MAPPERS); this.enableSchemaCache = enableSchemaCache; - this.metaSchemaFactory = metaSchemaFactory; + this.dialectRegistry = dialectRegistry != null ? dialectRegistry : new DefaultDialectRegistry(); } public SchemaLoader getSchemaLoader() { @@ -240,39 +163,57 @@ public SchemaLoader getSchemaLoader() { /** * Builder without keywords or formats. + *

+ * Typically {@link #builder(SchemaRegistry)} or + * {@link #withDefaultDialect(Version)} or {@link #withDialect(Dialect)} would be used instead. * - * Typically {@link #builder(SchemaRegistry)} is what is required. - * - * @return a builder instance without any keywords or formats - usually not what one needs. + * @return a builder instance without any keywords or formats - usually not what + * one needs. */ public static Builder builder() { return new Builder(); } /** - * Creates a factory with a default schema dialect. The schema dialect will only - * be used if the input does not specify a $schema. + * Creates a new schema registry with a default schema dialect. The schema dialect + * will only be used if the input does not specify a $schema. * - * @param versionFlag the default dialect + * @param specificationVersion the default dialect id corresponding to the + * specification version used when the schema does + * not specify the $schema keyword * @return the factory */ - public static SchemaRegistry getInstance(Specification.Version versionFlag) { - return getInstance(versionFlag, null); + public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion) { + return withDefaultDialect(specificationVersion, null); } /** - * Creates a factory with a default schema dialect. The schema dialect will only - * be used if the input does not specify a $schema. + * Creates a new schema registry with a default schema dialect. The schema dialect + * will only be used if the input does not specify a $schema. * - * @param versionFlag the default dialect - * @param customizer to customize the factory + * @param specificationVersion the default dialect id corresponding to the + * specification version used when the schema does + * not specify the $schema keyword + * @param customizer to customize the factory * @return the factory */ - public static SchemaRegistry getInstance(Specification.Version versionFlag, + public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion, Consumer customizer) { - Dialect dialect = checkVersion(versionFlag); - SchemaRegistry.Builder builder = builder().defaultMetaSchemaIri(dialect.getIri()) - .metaSchema(dialect); + Dialect dialect = Specification.getDialect(specificationVersion); + return withDefaultDialectId(dialect.getIri(), customizer); + } + + /** + * Creates a new schema registry with a default schema dialect. The schema dialect + * will only be used if the input does not specify a $schema. + * + * @param dialect the default dialect id used when the schema does not + * specify the $schema keyword + * @param customizer to customize the factory + * @return the factory + */ + public static SchemaRegistry withDefaultDialectId(String dialectId, Consumer customizer) { + SchemaRegistry.Builder builder = builder().defaultDialectId(dialectId); if (customizer != null) { customizer.accept(builder); } @@ -280,30 +221,24 @@ public static SchemaRegistry getInstance(Specification.Version versionFlag, } /** - * Gets the json schema version to get the meta schema. + * Gets a new schema registry that supports a specific dialect only. *

- * This throws an {@link IllegalArgumentException} for an unsupported value. + * Schemas that do not specify dialect using $schema will use the dialect. * - * @param version the schema specification version - * @return the version + * @param dialect the dialect + * @return the schema registry */ - public static Dialect checkVersion(Specification.Version version){ - if (null == version) return null; - switch (version) { - case DRAFT_2020_12: return Dialects.getDraft202012(); - case DRAFT_2019_09: return Dialects.getDraft201909(); - case DRAFT_7: return Dialects.getDraft7(); - case DRAFT_6: return Dialects.getDraft6(); - case DRAFT_4: return Dialects.getDraft4(); - default: throw new IllegalArgumentException("Unsupported value" + version); - } + public static SchemaRegistry withDialect(Dialect dialect) { + SchemaRegistry.Builder builder = builder().defaultDialectId(dialect.getIri()) + .dialectRegistry(new BasicDialectRegistry(dialect)); + return builder.build(); } /** * Builder from an existing {@link SchemaRegistry}. *

* - * JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)); + * SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)); * * * @param blueprint the existing factory @@ -311,10 +246,7 @@ public static Dialect checkVersion(Specification.Version version){ */ public static Builder builder(final SchemaRegistry blueprint) { Builder builder = builder() - .metaSchemas(blueprint.metaSchemas.values()) - .defaultMetaSchemaIri(blueprint.defaultMetaSchemaIri) - .jsonMapper(blueprint.jsonMapper) - .yamlMapper(blueprint.yamlMapper) + .defaultDialectId(blueprint.defaultDialectId) .jsonNodeReader(blueprint.jsonNodeReader); if (blueprint.schemaLoadersBuilder != null) { builder.schemaLoadersBuilder = SchemaLoaders.builder().with(blueprint.schemaLoadersBuilder); @@ -326,14 +258,14 @@ public static Builder builder(final SchemaRegistry blueprint) { } /** - * Creates a json schema from initial input. + * Creates a schema from initial input. * * @param schemaUri the schema location * @param schemaNode the schema data node * @param config the config to use * @return the schema */ - protected Schema newJsonSchema(final SchemaLocation schemaUri, final JsonNode schemaNode, final SchemaValidatorsConfig config) { + protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schemaNode, final SchemaValidatorsConfig config) { final ValidationContext validationContext = createValidationContext(schemaNode, config); Schema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), new JsonNodePath(validationContext.getConfig().getPathType()), schemaNode, null, false); @@ -344,16 +276,16 @@ protected Schema newJsonSchema(final SchemaLocation schemaUri, final JsonNode sc /** * Preloads the json schema if the configuration option is set. * - * @param jsonSchema the schema to preload + * @param schema the schema to preload * @param config containing the configuration option */ - private void preload(Schema jsonSchema, SchemaValidatorsConfig config) { + private void preload(Schema schema, SchemaValidatorsConfig config) { if (config.isPreloadJsonSchema()) { try { /* * Attempt to preload and resolve $refs for performance. */ - jsonSchema.initializeValidators(); + schema.initializeValidators(); } catch (Exception e) { /* * Do nothing here to allow the schema to be cached even if the remote $ref @@ -370,7 +302,7 @@ public Schema create(ValidationContext validationContext, SchemaLocation schemaL } private Schema doCreate(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { - return Schema.from(withMetaSchema(validationContext, schemaNode), schemaLocation, evaluationPath, + return Schema.from(withDialect(validationContext, schemaNode), schemaLocation, evaluationPath, schemaNode, parentSchema, suppressSubSchemaRetrieval); } @@ -387,8 +319,8 @@ private Schema doCreate(ValidationContext validationContext, SchemaLocation sche * @param schemaNode the schema node * @return the validation context to use */ - private ValidationContext withMetaSchema(ValidationContext validationContext, JsonNode schemaNode) { - Dialect dialect = getMetaSchema(schemaNode, validationContext.getConfig()); + private ValidationContext withDialect(ValidationContext validationContext, JsonNode schemaNode) { + Dialect dialect = getDialect(schemaNode, validationContext.getConfig()); if (dialect != null && !dialect.getIri().equals(validationContext.getMetaSchema().getIri())) { SchemaValidatorsConfig config = validationContext.getConfig(); if (dialect.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { @@ -419,84 +351,52 @@ protected SchemaLocation getSchemaLocation(SchemaLocation schemaLocation) { } protected ValidationContext createValidationContext(final JsonNode schemaNode, SchemaValidatorsConfig config) { - final Dialect jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); + final Dialect dialect = getDialectOrDefault(schemaNode, config); SchemaValidatorsConfig configResult = config; - if (jsonMetaSchema.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { + if (dialect.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { configResult = SchemaValidatorsConfig.builder(config) .discriminatorKeywordEnabled(true) .nullableKeywordEnabled(true) .build(); } - return new ValidationContext(jsonMetaSchema, this, configResult); + return new ValidationContext(dialect, this, configResult); } - private Dialect getMetaSchema(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getDialect(final JsonNode schemaNode, SchemaValidatorsConfig config) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && iriNode.isTextual()) { - Dialect result = metaSchemas.computeIfAbsent(normalizeMetaSchemaUri(iriNode.textValue()), - id -> loadMetaSchema(id, config)); - return result; + return getDialect(iriNode.textValue(), config); } return null; } - private Dialect getMetaSchemaOrDefault(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getDialectOrDefault(final JsonNode schemaNode, SchemaValidatorsConfig config) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && !iriNode.isNull() && !iriNode.isTextual()) { - throw new JsonSchemaException("Unknown MetaSchema: " + iriNode); + throw new JsonSchemaException("Unknown dialect: " + iriNode); } - final String iri = iriNode == null || iriNode.isNull() ? defaultMetaSchemaIri : iriNode.textValue(); - return getMetaSchema(iri, config); + final String iri = iriNode == null || iriNode.isNull() ? defaultDialectId : iriNode.textValue(); + return getDialect(iri, config); } /** - * Gets the meta-schema that is available to the factory. + * Gets the dialect that is available to the registry. * - * @param iri the IRI of the meta-schema - * @param config the schema validators config + * @param dialectId the IRI of the meta-schema + * @param config the schema validators config * @return the meta-schema */ - public Dialect getMetaSchema(String iri, SchemaValidatorsConfig config) { - String key = normalizeMetaSchemaUri(iri); - Dialect result = metaSchemas.computeIfAbsent(key, id -> loadMetaSchema(id, config)); - return result; - } - - /** - * Loads the meta-schema from the configured meta-schema factory. - * - * @param iri the IRI of the meta-schema - * @param config the schema validators config - * @return the meta-schema - */ - protected Dialect loadMetaSchema(String iri, SchemaValidatorsConfig config) { - return this.metaSchemaFactory != null ? this.metaSchemaFactory.getDialect(iri, this, config) - : DefaultDialectRegistry.getInstance().getDialect(iri, this, config); + public Dialect getDialect(String dialectId, SchemaValidatorsConfig config) { + String key = normalizeDialectId(dialectId); + return dialectRegistry.getDialect(key, this, config); } JsonNode readTree(String content, InputFormat inputFormat) throws IOException { - if (this.jsonNodeReader == null) { - return getObjectMapper(inputFormat).readTree(content); - } else { - return this.jsonNodeReader.readTree(content, inputFormat); - } + return this.jsonNodeReader.readTree(content, inputFormat); } JsonNode readTree(InputStream content, InputFormat inputFormat) throws IOException { - if (this.jsonNodeReader == null) { - return getObjectMapper(inputFormat).readTree(content); - } else { - return this.jsonNodeReader.readTree(content, inputFormat); - } - } - - ObjectMapper getObjectMapper(InputFormat inputFormat) { - if (InputFormat.JSON.equals(inputFormat)) { - return getJsonMapper(); - } else if (InputFormat.YAML.equals(inputFormat)) { - return getYamlMapper(); - } - throw new IllegalArgumentException("Unsupported input format "+inputFormat); + return this.jsonNodeReader.readTree(content, inputFormat); } /** @@ -527,7 +427,7 @@ public Schema getSchema(final String schema, final SchemaValidatorsConfig config public Schema getSchema(final String schema, InputFormat inputFormat, final SchemaValidatorsConfig config) { try { final JsonNode schemaNode = readTree(schema, inputFormat); - return newJsonSchema(null, schemaNode, config); + return newSchema(null, schemaNode, config); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); throw new JsonSchemaException(ioe); @@ -590,7 +490,7 @@ public Schema getSchema(final InputStream schemaStream, final SchemaValidatorsCo public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat, final SchemaValidatorsConfig config) { try { final JsonNode schemaNode = readTree(schemaStream, inputFormat); - return newJsonSchema(null, schemaNode, config); + return newSchema(null, schemaNode, config); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); throw new JsonSchemaException(ioe); @@ -637,7 +537,7 @@ public Schema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsC // The getMapperSchema potentially recurses to call back to getSchema again Schema cachedUriSchema = schemaCache.get(schemaUri); if (cachedUriSchema == null) { - synchronized (this) { // acquire lock on shared factory object to prevent deadlock + synchronized (this) { // acquire lock on shared registry object to prevent deadlock cachedUriSchema = schemaCache.get(schemaUri); if (cachedUriSchema == null) { cachedUriSchema = getMappedSchema(schemaUri, config); @@ -652,14 +552,6 @@ public Schema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsC return getMappedSchema(schemaUri, config); } - ObjectMapper getYamlMapper() { - return this.yamlMapper != null ? this.yamlMapper : YamlMapperFactory.getInstance(); - } - - ObjectMapper getJsonMapper() { - return this.jsonMapper != null ? this.jsonMapper : JsonMapperFactory.getInstance(); - } - /** * Creates a schema validators config. * @@ -682,12 +574,12 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri, SchemaValidator schemaNode = readTree(inputStream, InputFormat.JSON); } - final Dialect jsonMetaSchema = getMetaSchemaOrDefault(schemaNode, config); + final Dialect dialect = getDialectOrDefault(schemaNode, config); JsonNodePath evaluationPath = new JsonNodePath(config.getPathType()); if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { // Schema without fragment - ValidationContext validationContext = new ValidationContext(jsonMetaSchema, this, config); + ValidationContext validationContext = new ValidationContext(dialect, this, config); return doCreate(validationContext, schemaUri, evaluationPath, schemaNode, null, true /* retrieved via id, resolving will not change anything */); } else { // Schema with fragment pointing to sub schema @@ -723,7 +615,7 @@ public Schema getSchema(final URI schemaUri) { * @return the schema */ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newJsonSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, config); + return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, config); } /** @@ -734,7 +626,7 @@ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode, final Sche * @return the schema */ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { - return newJsonSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, createSchemaValidatorsConfig()); + return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, createSchemaValidatorsConfig()); } /** @@ -756,7 +648,7 @@ public Schema getSchema(final SchemaLocation schemaUri) { * @return the schema */ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newJsonSchema(schemaUri, jsonNode, config); + return newSchema(schemaUri, jsonNode, config); } /** @@ -767,7 +659,7 @@ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode, * @return the schema */ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { - return newJsonSchema(schemaUri, jsonNode, createSchemaValidatorsConfig()); + return newSchema(schemaUri, jsonNode, createSchemaValidatorsConfig()); } /** @@ -784,7 +676,7 @@ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) * @return the schema */ public Schema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newJsonSchema(null, jsonNode, config); + return newSchema(null, jsonNode, config); } /** @@ -800,7 +692,7 @@ public Schema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfig co * @return the schema */ public Schema getSchema(final JsonNode jsonNode) { - return newJsonSchema(null, jsonNode, createSchemaValidatorsConfig()); + return newSchema(null, jsonNode, createSchemaValidatorsConfig()); } private boolean isYaml(final SchemaLocation schemaUri) { @@ -824,7 +716,7 @@ private boolean isYaml(final SchemaLocation schemaUri) { * @param id the $schema identifier * @return the normalized uri */ - static protected String normalizeMetaSchemaUri(String id) { + static protected String normalizeDialectId(String id) { boolean found = false; for (Version flag : Specification.Version.values()) { if(flag.getDialectId().equals(id)) { diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java index be5e8c82b..fc7f5fbf3 100644 --- a/src/main/java/com/networknt/schema/Specification.java +++ b/src/main/java/com/networknt/schema/Specification.java @@ -17,7 +17,9 @@ import java.util.Optional; +import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.DialectId; +import com.networknt.schema.dialect.Dialects; /** * The JSON Schema specification which defines the standard dialects. @@ -95,4 +97,56 @@ public static Optional fromDialectId(String dialectId) { return Optional.empty(); } } + + /** + * Gets the dialect given the specification version. + * + * @param version the schema specification version + * @return the dialect or null if not found + */ + public static Dialect getDialect(Specification.Version version) { + if (null == version) { + return null; + } + switch (version) { + case DRAFT_2020_12: + return Dialects.getDraft202012(); + case DRAFT_2019_09: + return Dialects.getDraft201909(); + case DRAFT_7: + return Dialects.getDraft7(); + case DRAFT_6: + return Dialects.getDraft6(); + case DRAFT_4: + return Dialects.getDraft4(); + default: + return null; + } + } + + /** + * Gets the dialect given the dialect id. + * + * @param version the schema specification version + * @return the dialect or null if not found + */ + public static Dialect getDialect(String dialectId) { + if (null == dialectId) { + return null; + } + switch (dialectId) { + case DialectId.DRAFT_2020_12: + return Dialects.getDraft202012(); + case DialectId.DRAFT_2019_09: + return Dialects.getDraft201909(); + case DialectId.DRAFT_7: + return Dialects.getDraft7(); + case DialectId.DRAFT_6: + return Dialects.getDraft6(); + case DialectId.DRAFT_4: + return Dialects.getDraft4(); + default: + return null; + } + } } diff --git a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java index a91118b4e..9a91af1e4 100644 --- a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java @@ -75,7 +75,7 @@ public static Optional detectOptionalVersion(JsonNode jsonNode, boolean return Optional.ofNullable(jsonNode.get(SCHEMA_TAG)).map(schemaTag -> { String schemaTagValue = schemaTag.asText(); - String schemaUri = SchemaRegistry.normalizeMetaSchemaUri(schemaTagValue); + String schemaUri = SchemaRegistry.normalizeDialectId(schemaTagValue); if (throwIfUnsupported) { return Version.fromDialectId(schemaUri) diff --git a/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java similarity index 60% rename from src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java rename to src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java index dac7d7825..8199c8028 100644 --- a/src/main/java/com/networknt/schema/dialect/DisallowUnknownDialectFactory.java +++ b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 the original author or authors. + * Copyright (c) 2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,33 +15,32 @@ */ package com.networknt.schema.dialect; +import java.util.function.Function; + import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaValidatorsConfig; -/** - * A {@link DialectRegistry} that does not meta-schemas that aren't - * explicitly configured in the {@link SchemaRegistry}. - */ -public class DisallowUnknownDialectFactory implements DialectRegistry { - @Override - public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { - throw new InvalidSchemaException(Error.builder() - .message("Unknown dialect ''{0}''. Only dialects that are explicitly configured can be used.") - .arguments(dialectId).build()); +public class BasicDialectRegistry implements DialectRegistry { + private Function dialects; + + public BasicDialectRegistry(Function dialects) { + this.dialects = dialects; } - private static class Holder { - private static final DisallowUnknownDialectFactory INSTANCE = new DisallowUnknownDialectFactory(); + public BasicDialectRegistry(Dialect dialect) { + this.dialects = dialectId -> dialect.getIri().equals(dialectId) ? dialect : null; } - /** - * Gets the instance of {@link DisallowUnknownDialectFactory}. - * - * @return the json meta schema factory - */ - public static DisallowUnknownDialectFactory getInstance() { - return Holder.INSTANCE; + @Override + public Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry, SchemaValidatorsConfig config) { + Dialect dialect = dialects.apply(dialectId); + if (dialect != null) { + return dialect; + } + throw new InvalidSchemaException(Error.builder() + .message("Unknown dialect ''{0}''. Only dialects that are explicitly configured can be used.") + .arguments(dialectId).build()); } } diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index b17843f25..355169c1f 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -17,6 +17,8 @@ import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; @@ -32,13 +34,16 @@ * Default {@link DialectRegistry}. */ public class DefaultDialectRegistry implements DialectRegistry { + private final ConcurrentMap dialects = new ConcurrentHashMap<>(); + @Override public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { // Is it a well-known dialect? - return Specification.Version.fromDialectId(dialectId).map(SchemaRegistry::checkVersion).orElseGet(() -> { - // Custom dialect - return loadDialect(dialectId, schemaFactory, config); - }); + Dialect dialect = Specification.getDialect(dialectId); + if (dialect != null) { + return dialect; + } + return dialects.computeIfAbsent(dialectId, id -> loadDialect(id, schemaFactory, config)); } protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { diff --git a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java index d86140ee7..15283749e 100644 --- a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java @@ -29,12 +29,13 @@ public interface DialectRegistry { * Gets the dialect given the dialect id which is the IRI that indicates the * meta-schema that can be used to validate the schema conforms to the dialect. * - * @param dialectId the dialect id of the dialect which IRI that indicates - * the meta-schema that can be used to validate the schema - * conforms to the dialect - * @param schemaFactory the schema factory - * @param config the config + * @param dialectId the dialect id of the dialect which IRI that indicates + * the meta-schema that can be used to validate the schema + * conforms to the dialect + * @param schemaRegistry the schema registry to fetch and load unknown dialect's + * meta-schema + * @param config the config * @return the dialect */ - Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config); + Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry, SchemaValidatorsConfig config); } diff --git a/src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java b/src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java new file mode 100644 index 000000000..e90509169 --- /dev/null +++ b/src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.serialization; + +import java.io.IOException; +import java.io.InputStream; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.InputFormat; + +/** + * BasicJsonNodeReader. + */ +public class BasicJsonNodeReader implements JsonNodeReader { + private static class Holder { + private static final BasicJsonNodeReader INSTANCE = new BasicJsonNodeReader(); + } + + public static BasicJsonNodeReader getInstance() { + return Holder.INSTANCE; + } + + protected BasicJsonNodeReader() { + } + + @Override + public JsonNode readTree(String content, InputFormat inputFormat) throws IOException { + return getObjectMapper(inputFormat).readTree(content); + } + + @Override + public JsonNode readTree(InputStream content, InputFormat inputFormat) throws IOException { + return getObjectMapper(inputFormat).readTree(content); + } + + /** + * Gets the object mapper for the input format. + * + * @param inputFormat the input format + * @return the object mapper + */ + protected ObjectMapper getObjectMapper(InputFormat inputFormat) { + if (InputFormat.JSON.equals(inputFormat)) { + return JsonMapperFactory.getInstance(); + } else if (InputFormat.YAML.equals(inputFormat)) { + return YamlMapperFactory.getInstance(); + } + throw new IllegalArgumentException("Unsupported input format "+inputFormat); + } +} diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 0cd94b4af..e9a18c76b 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -60,7 +60,7 @@ private JsonNode getJsonNodeFromPath(String dataPath) { private Schema getJsonSchema(JsonNode schemaNode) { return SchemaRegistry - .getInstance(SpecificationVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) + .withDefaultDialect(SpecificationVersionDetector.detectOptionalVersion(schemaNode, false).orElse(DEFAULT_VERSION_FLAG)) .getSchema(schemaNode); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index cc40fd572..43b58edbe 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -202,7 +202,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; Version specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); - SchemaRegistry base = SchemaRegistry.getInstance(specVersion); + SchemaRegistry base = SchemaRegistry.withDefaultDialect(specVersion); return SchemaRegistry .builder(base) .schemaMappers(schemaMappers -> schemaMappers diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index aa6518c30..6c6cdbde7 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -45,7 +45,7 @@ void messageFalse() { + " },\r\n" + " \"additionalProperties\": false\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -80,7 +80,7 @@ void messageSchema() { + " },\r\n" + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 2109cce58..f4a878f9a 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 3b9c7c1b5..5d25de103 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -33,7 +33,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +59,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index 0f1959dd4..4564107e2 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -55,7 +55,7 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi } public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.getInstance(schemaVersion); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(schemaVersion); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); if (config == null) { @@ -65,23 +65,23 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi } public static Schema getJsonSchemaFromStringContent(String schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); return factory.getSchema(schemaContent); } public static Schema getJsonSchemaFromUrl(String uri) throws URISyntaxException { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); return factory.getSchema(SchemaLocation.of(uri)); } public static Schema getJsonSchemaFromJsonNode(JsonNode jsonNode) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); return factory.getSchema(jsonNode); } // Automatically detect version for given JsonNode public static Schema getJsonSchemaFromJsonNodeAutomaticVersion(JsonNode jsonNode) { - SchemaRegistry factory = SchemaRegistry.getInstance(SpecificationVersionDetector.detect(jsonNode)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersionDetector.detect(jsonNode)); return factory.getSchema(jsonNode); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index c0b9ab0cb..bfcd7e501 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AbstractKeywordValidator; @@ -156,9 +155,7 @@ public String getErrorMessageDescription() { private void setupSchema() throws Exception { final Dialect dialect = getJsonMetaSchema( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); - final SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) - .build(); + final SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().build(); this.jsonSchema = schemaFactory.getSchema(getSchemaString(), schemaValidatorsConfig); this.jsonSchemaForCombine = schemaFactory.getSchema(getSchemaStringMultipleProperties(), schemaValidatorsConfig); @@ -458,7 +455,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root void concurrency() throws Exception { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -506,7 +503,7 @@ public void run() { void iterate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -524,7 +521,7 @@ void iterate() { void iterateWalk() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); @@ -542,7 +539,7 @@ void iterateWalk() { void iterateWalkValidate() { CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" + " \"collect\": true\n" + "}"); diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 6ee457c2c..4b0bb887a 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -39,7 +39,7 @@ void localeMessageOthers() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -53,7 +53,7 @@ void localeMessageNumber() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -65,7 +65,7 @@ void validOthers() { + " \"const\": \"aa\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -77,7 +77,7 @@ void validNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void invalidNumber() { + " \"const\": 1234.56789\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index 412e196ad..4c5c06fb8 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -54,7 +54,7 @@ void annotationCollection() throws JsonProcessingException { + " ]\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 6d664d0a6..8029eee63 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -124,7 +124,7 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { .keyword(new EnumNamesKeyword()) .build(); - final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).metaSchema(dialect).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.withDialect(dialect); final Schema schema = validatorFactory.getSchema("{\n" + " \"$schema\":\n" + " \"https://github.com/networknt/json-schema-validator/tests/schemas/example01\",\n" + diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index 67328de1d..4e850e46e 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -31,7 +31,7 @@ void customUri() throws Exception { } private SchemaRegistry buildJsonSchemaFactory() { - return SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) + return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) .schemaLoaders(schemaLoaders -> schemaLoaders.add(new CustomUriFetcher())).build(); } diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index 9bae93f0f..55b0aca3a 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -11,7 +11,7 @@ class CyclicDependencyTest { void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .build(); String jsonObject = "{\n" + " \"element\": {\n" + diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index d193a332e..d22d412db 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -10,7 +10,7 @@ class DateTimeDSTTest { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index 8700fc864..5bed18c2d 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -35,9 +35,9 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); try { - SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } @@ -50,7 +50,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -60,7 +60,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); } @Test @@ -68,7 +68,7 @@ void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.getInstance(Version.DRAFT_2020_12) + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12) .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"), config)); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 6dd21ac38..9ee613efc 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -28,7 +28,7 @@ class DependentRequiredTest { " }" + "}"; - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); private static final Schema schema = factory.getSchema(SCHEMA); private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java deleted file mode 100644 index e4f6114df..000000000 --- a/src/test/java/com/networknt/schema/DisallowUnknownDialectFactoryTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.junit.jupiter.api.Test; - -import com.networknt.schema.Specification.Version; -import com.networknt.schema.dialect.DisallowUnknownDialectFactory; - -/** - * Tests for DisallowUnknownJsonMetaSchemaFactory. - */ -class DisallowUnknownDialectFactoryTest { - private static final String DRAFT_202012_SCHEMA = "{\r\n" - + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" - + " \"type\": \"object\"\r\n" - + "}"; - - private static final String DRAFT_7_SCHEMA = "{\r\n" - + " \"$schema\": \"http://json-schema.org/draft-07/schema#\",\r\n" - + " \"type\": \"object\"\r\n" - + "}"; - @Test - void defaultHandling() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); - assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); - assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); - } - - @Test - void draft202012() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - assertDoesNotThrow(() -> factory.getSchema(DRAFT_202012_SCHEMA)); - assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_7_SCHEMA)); - } - - @Test - void draft7() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, - builder -> builder.metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); - assertDoesNotThrow(() -> factory.getSchema(DRAFT_7_SCHEMA)); - assertThrows(InvalidSchemaException.class, () -> factory.getSchema(DRAFT_202012_SCHEMA)); - } -} diff --git a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java index 7b55692e3..7169a9586 100644 --- a/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/DisallowUnknownKeywordFactoryTest.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; @@ -35,8 +34,7 @@ void shouldThrowForUnknownKeywords() { void getSchemaShouldThrowForUnknownKeywords() { Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); String schemaData = "{\r\n" + " \"equals\": \"world\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 82325a759..53a781b9c 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -115,7 +115,7 @@ void discriminatorInArray() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -147,7 +147,7 @@ void anyOfWithConfigEnabledButNoDiscriminator() { + " \"intOrStringType\": 4\r\n" + " }"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -240,7 +240,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -333,7 +333,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -423,7 +423,7 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -519,7 +519,7 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -619,7 +619,7 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -674,7 +674,7 @@ void oneOfMissingDiscriminatorValue() { String inputData = "{}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); @@ -770,7 +770,7 @@ void anyOfMissingDiscriminatorValue() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); Schema schema = factory.getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 34a356b30..5fd2f7c6c 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -34,7 +34,7 @@ void durationFormatValidatorTest() throws IOException { final JsonNode validTargetNode = objectMapper.readTree("\"P1D\""); final JsonNode invalidTargetNode = objectMapper.readTree("\"INVALID_DURATION\""); - final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)).build(); final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(validTargetNode); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index 1c10a9f6a..4c824085f 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -85,7 +85,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); @@ -105,7 +105,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index 78428af30..c23e07a3d 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -51,7 +51,7 @@ void errorMessage() { + " \"foo\": \"a\",\r\n" + " \"bar\": 2\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); @@ -81,7 +81,7 @@ void errorMessageUnionType() { String inputData = "{\r\n" + " \"keyword1\": 2\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index e725088e5..68fc6c82e 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -28,7 +28,7 @@ class ExampleTest { @Test void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -53,7 +53,7 @@ void exampleSchemaLocation() { @Test void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 9077c9fad..6cb2a180b 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.DisallowUnknownKeywordFactory; @@ -45,8 +44,7 @@ void draftV4ShouldHaveExclusiveMinimum() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft4()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_4, - builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":0}"; String validData = "{\"value1\":0.1}"; @@ -73,8 +71,7 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_6, - builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } @@ -92,8 +89,7 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { "}"; Dialect dialect = Dialect.builder(Dialects.getDraft7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, - builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); } } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index 58b3f575f..55725008d 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.FormatKeyword; @@ -45,8 +44,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void shouldUseFormatKeyword() { Dialect dialect = Dialect.builder(Dialects.getDraft202012()) .formatKeywordFactory(CustomFormatKeyword::new).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); String schemaData = "{\r\n" + " \"format\": \"hello\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 3c42a7795..f6f20d27c 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -43,7 +43,7 @@ void unknownFormatNoVocab() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -56,7 +56,7 @@ void unknownFormatNoVocabStrictTrue() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); }); @@ -86,7 +86,7 @@ void unknownFormatAssertionsVocab() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) .getSchema(schemaData, config); @@ -100,7 +100,7 @@ void unknownFormatShouldCollectAnnotations() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); @@ -143,7 +143,7 @@ void formatAssertions(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { @@ -159,7 +159,7 @@ void formatAssertions(FormatInput formatInput) { @SuppressWarnings("deprecation") @Test void patternFormatDeprecated() { - Dialect customMetaSchema = Dialect + Dialect customDialect = Dialect .builder("https://www.example.com/schema", Dialects.getDraft7()) .formats(formats -> { PatternFormat format = new PatternFormat("custom", "test", "must be test"); @@ -167,8 +167,7 @@ void patternFormatDeprecated() { }) .build(); - SchemaRegistry factory = new SchemaRegistry.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) - .metaSchema(customMetaSchema).build(); + SchemaRegistry factory = SchemaRegistry.withDialect(customDialect); String formatSchema = "{\r\n" + " \"type\": \"string\",\r\n" + " \"format\": \"custom\"\r\n" @@ -208,7 +207,7 @@ public String getName() { @Test void shouldAllowNumberFormat() { - Dialect customMetaSchema = Dialect + Dialect customDialect = Dialect .builder("https://www.example.com/schema", Dialects.getDraft7()) .formats(formats -> { CustomNumberFormat format = new CustomNumberFormat(new BigDecimal("12345")); @@ -216,8 +215,7 @@ void shouldAllowNumberFormat() { }) .build(); - SchemaRegistry factory = new SchemaRegistry.Builder().defaultMetaSchemaIri(customMetaSchema.getIri()) - .metaSchema(customMetaSchema).build(); + SchemaRegistry factory = SchemaRegistry.withDialect(customDialect); String formatSchema = "{\r\n" + " \"type\": \"number\",\r\n" + " \"format\": \"custom-number\"\r\n" @@ -241,7 +239,7 @@ void draft7DisableFormat() { String schemaData = "{\r\n" + " \"format\":\"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); }); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 3f26d6fba..20fe50fb6 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -48,7 +48,7 @@ void walkValidateThen() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -91,7 +91,7 @@ void walkValidateElse() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -134,7 +134,7 @@ void walkValidateNull() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override @@ -175,7 +175,7 @@ void walkNoValidate() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { @Override diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index e914322d2..1116d820d 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -33,7 +33,7 @@ class Issue1091Test { void testHasAdjacentKeywordInEvaluationPath() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4) + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4) .getSchema(SchemaLocation.of("classpath:schema/issue1091.json"), config); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index 0164e5864..2d35c11b4 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -25,7 +25,7 @@ class Issue255Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index 1a9209f33..3c07271c6 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -13,7 +13,7 @@ class Issue285Test { private final ObjectMapper mapper = new ObjectMapper(); private final SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("http://json-schema.org", "resource:") .mapPrefix("https://json-schema.org", "resource:")) diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index ee9aa0238..eacd60330 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -10,7 +10,7 @@ class Issue295Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 62adbd4f9..012034cc9 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -11,12 +11,12 @@ class Issue313Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } protected Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index dc549b5ca..44bdfd1d3 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -8,20 +8,18 @@ import com.networknt.schema.dialect.Dialects; class Issue314Test { - private static final SchemaRegistry FACTORY = - SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) - .metaSchema( + private static final SchemaRegistry REGISTRY = + SchemaRegistry.withDialect( Dialect.builder( "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialects.getDraft7()) - .build()) - .build(); + .build()); @Test void testNormalizeHttpOnly() { String schemaPath = "/schema/issue314-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - Schema schema = FACTORY.getSchema(schemaInputStream); + Schema schema = REGISTRY.getSchema(schemaInputStream); Assertions.assertNotNull(schema); } diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index e7c621c8e..e8a71c904 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -10,7 +10,7 @@ class Issue327Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index ef823ab37..da6412a13 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -11,7 +11,7 @@ class Issue342Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index aa228bab6..2a598187e 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -11,7 +11,7 @@ class Issue347Test { @Test void failure() { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 63f6d63b8..33db63070 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -27,7 +27,7 @@ private void setupSchema() throws IOException { .typeLoose(false) .build(); SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 556951896..002bf4726 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -26,7 +26,7 @@ private void setupSchema() throws IOException { SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().typeLoose(false).build(); SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)) .build(); SchemaLocation uri = getSchema(); diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 266888053..eb029b16c 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -28,7 +28,7 @@ class Issue375Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index 7a7fc6b0d..c826b8f19 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -11,7 +11,7 @@ class Issue383Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index e506e7ef5..1ccaeb24c 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -14,7 +14,7 @@ class Issue396Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 6c9a75feb..d02fce56a 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -10,7 +10,7 @@ class Issue404Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index 643898785..d356bcc32 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -14,7 +14,7 @@ class Issue406Test { @Test void testPreloadingNotHappening() { - final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass Assertions.assertNotNull(schema); @@ -22,7 +22,7 @@ void testPreloadingNotHappening() { @Test void testPreloadingHappening() { - final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(JsonSchemaException.class, new Executable() { @@ -36,7 +36,7 @@ public void execute() { @Test void testPreloadingHappeningForCircularDependency() { - final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 2b8805a01..cc7496675 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -13,7 +13,7 @@ */ class Issue426Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index 51dfdc20b..29f755d24 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -15,7 +15,7 @@ class Issue428Test { protected ObjectMapper mapper = new ObjectMapper(); protected SchemaRegistry validatorFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).build(); + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)).build(); private void runTestFile(String testCaseFile) throws Exception { final SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + testCaseFile); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 04f110d63..114a67b2a 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -21,7 +21,7 @@ class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .propertyWalkListener(new CountingWalker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index 245ef2261..88301babb 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -11,7 +11,7 @@ class Issue456Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 8b6f11ddd..67e8c61b9 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -17,7 +17,7 @@ class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) .build(); diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 354abb986..83c459549 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -37,7 +37,7 @@ import com.networknt.schema.walk.WalkFlow; class Issue467Test { - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); private static final String schemaPath = "/schema/issue467.json"; protected ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index 0c2da6423..d80b686b4 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -78,7 +78,7 @@ private Map convertErrorsToMap(List errors) { } private Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 3f653b9fb..be6210021 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -51,7 +51,7 @@ class Issue475Test { @Test void draft4() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_4, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); @@ -65,7 +65,7 @@ void draft4() throws Exception { @Test void draft6() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_6, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); @@ -79,7 +79,7 @@ void draft6() throws Exception { @Test void draft7() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); @@ -93,7 +93,7 @@ void draft7() throws Exception { @Test void draft201909() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2019_09, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); @@ -107,7 +107,7 @@ void draft201909() throws Exception { @Test void draft202012() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index 39dd07cf3..54652d8fe 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -18,7 +18,7 @@ class Issue493Test { - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); private static final String schemaPath1 = "/schema/issue493.json"; private JsonNode getJsonNodeFromJsonData (String jsonFilePath) diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 7642ca57c..f96aeed1c 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -14,17 +14,14 @@ class Issue518Test { .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", Dialects.getDraft7()) .build(); - private static final SchemaRegistry FACTORY = - SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) - .metaSchema(igluMetaSchema) - .build(); + private static final SchemaRegistry REGISTRY = + SchemaRegistry.withDialect(igluMetaSchema); @Test void testPreservingEmptyFragmentSuffix() { String schemaPath = "/schema/issue518-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); - Schema schema = FACTORY.getSchema(schemaInputStream); + Schema schema = REGISTRY.getSchema(schemaInputStream); Assertions.assertNotNull(schema); } diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index 72356140d..81f12349e 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -7,7 +7,7 @@ class Issue532Test { @Test void failure() { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index c83e513cb..1b53dff91 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -12,7 +12,7 @@ class Issue550Test { protected Schema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index 04621bccb..c29dc1ca1 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -25,7 +25,7 @@ class Issue575Test { @BeforeAll static void init() { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); String schemaPath = "/schema/issue575-2019-09.json"; InputStream schemaInputStream = Issue575Test.class.getResourceAsStream(schemaPath); schema = factory.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index 2d37c9e85..f5a23fb32 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -11,7 +11,7 @@ void failure() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) .build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index 947eaf3d6..1cd34832c 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -10,7 +10,7 @@ class Issue606Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index bce1bc06e..4f12ce8ae 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -53,7 +53,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; - factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4, + factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index 850f26ef3..a24c8fe46 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -37,7 +37,7 @@ void testBinaryNode() throws Exception { // schema with data property of type string: InputStream schemaInputStream = getClass().getResourceAsStream("/draft7/issue650.json"); - Schema schema = SchemaRegistry.getInstance(Specification.Version.DRAFT_7).getSchema(schemaInputStream); + Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7).getSchema(schemaInputStream); // create model first: Issue650Test.Model model = new Issue650Test.Model(); diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index 019829cd5..d1da7ffb2 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -14,7 +14,7 @@ class Issue664Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index 873c92c6d..e5443ad93 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -24,7 +24,7 @@ void testUrnUriAsLocalRef() throws IOException { @Test void testUrnUriAsLocalRef_ExternalURN() { SchemaRegistry factory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)) .schemaMappers(schemaMappers -> { schemaMappers.mappings(Collections.singletonMap("urn:data", "classpath:draft7/urn/issue665_external_urn_subschema.json")); diff --git a/src/test/java/com/networknt/schema/Issue668Test.java b/src/test/java/com/networknt/schema/Issue668Test.java index 05593352c..7e1474c4c 100644 --- a/src/test/java/com/networknt/schema/Issue668Test.java +++ b/src/test/java/com/networknt/schema/Issue668Test.java @@ -11,7 +11,7 @@ class Issue668Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); YAMLMapper mapper = new YAMLMapper(); JsonNode node = mapper.readTree(schemaContent); return factory.getSchema(node); diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index d83c8f68d..d692cc4cc 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -54,7 +54,7 @@ void testLocaleSwitch() throws JsonProcessingException { } private Schema getSchema(SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index ecc2d67f5..e9bafbe4b 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -81,7 +81,7 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin @MethodSource("errors") void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); @@ -114,7 +114,7 @@ static Stream specialCharacterTests() { void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().pathType(pathType).build(); - Schema schema = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09) + Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 6a085e0f2..5a16f60d2 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -50,7 +50,7 @@ void test() throws JsonProcessingException { + " \"billing_address\" : \"my_billing_address\"\n" + "}\n"; - Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false); System.out.println(stringCollector.strings); diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index a25728242..242bad787 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -73,11 +73,7 @@ private Schema createSchema(boolean useCustomDateFormat) { }) .build(); - return new SchemaRegistry - .Builder() - .defaultMetaSchemaIri(overrideDateTimeValidator.getIri()) - .metaSchema(overrideDateTimeValidator) - .build() + return SchemaRegistry.withDialect(overrideDateTimeValidator) .getSchema(Issue784Test.class.getResourceAsStream("/issue784/schema.json")); } } diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index ba9091768..3598bc534 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -12,7 +12,7 @@ class Issue792 { @Test void test() throws JsonProcessingException { - SchemaRegistry schemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); String schemaDef = "{\n" + diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index aa30dc5ae..4cff7303b 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -15,7 +15,7 @@ class Issue824Test { @Test void validate() throws JsonProcessingException { final Schema v201909SpecSchema = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index f3bcf0675..53b18b0cd 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -36,12 +36,12 @@ private SchemaRegistry buildV7PlusNoFormatSchemaFactory() { formats = new ArrayList<>(); formats.add(new NoMatchFormat()); - Dialect jsonMetaSchema = Dialect.builder( + Dialect dialect = Dialect.builder( Dialects.getDraft7().getIri(), Dialects.getDraft7()) .formats(formats) .build(); - return new SchemaRegistry.Builder().defaultMetaSchemaIri(jsonMetaSchema.getIri()).metaSchema(jsonMetaSchema).build(); + return SchemaRegistry.withDialect(dialect); } protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws IOException { diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index e80c3442f..84aca49ab 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -49,7 +49,7 @@ void test() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 75dd84e91..70d1bbd5b 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -30,7 +30,7 @@ void test() throws Exception { + " \"unevaluatedProperties\": false\n" + "}"; - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index 5768723bc..fa29ad126 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -105,7 +105,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) .getSchema(SchemaLocation.of("http://www.example.org"), JsonMapperFactory.getInstance().readTree(schema)); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index 5dc894fb8..fdd45e5bc 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -9,7 +9,7 @@ class Issue928Test { private SchemaRegistry factoryFor(Specification.Version version) { return SchemaRegistry - .builder(SchemaRegistry.getInstance(version)) + .builder(SchemaRegistry.withDefaultDialect(version)) .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://example.org", "classpath:")) .build(); } diff --git a/src/test/java/com/networknt/schema/Issue935Test.java b/src/test/java/com/networknt/schema/Issue935Test.java index b23c1118d..16d1cfdea 100644 --- a/src/test/java/com/networknt/schema/Issue935Test.java +++ b/src/test/java/com/networknt/schema/Issue935Test.java @@ -26,6 +26,6 @@ class Issue935Test { void shouldThrowInvalidSchemaException() { String schema = "{ \"$schema\": \"0\" }"; assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schema)); + () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schema)); } } diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index 56ca42fa1..308db2790 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -31,9 +31,9 @@ void shouldThrowInvalidSchemaException() { .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); try { - SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 941542d04..ee2e72e7a 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -48,7 +48,7 @@ void shouldNotThrowException() { + " }\r\n" + " }\r\n" + " }"; - Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index 592f9c8ae..352127948 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -31,7 +31,7 @@ void shouldNotThrowException() { + " \"greeting\": {}\r\n" + " }\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); } } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index b39255a05..334b9aa57 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -67,7 +67,7 @@ void test() { + " \"type\": \"Point\",\r\n" + " \"coordinates\": [1, 1]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index dd1d398c4..0a3313f70 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.serialization.JsonMapperFactory; @@ -48,7 +47,7 @@ void test() throws JsonProcessingException { }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)).getSchema(schemaNode); + .withDialect(dialect).getSchema(schemaNode); String inputData = "{\r\n" + " \"textValue\": \"hello\"\r\n" + "}"; diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 58ce4a7ba..b1814efdf 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -44,7 +44,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -67,7 +67,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -106,7 +106,7 @@ void walkNullPrefixItems() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index a40e609ee..714efbfd9 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -47,7 +47,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -74,7 +74,7 @@ void messageAdditionalItemsInvalid() { + " \"items\": [{}]," + " \"additionalItems\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -101,7 +101,7 @@ void messageAdditionalItemsFalseInvalid() { + " \"items\": [{}]," + " \"additionalItems\": false" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[ null, 2, 3, \"foo\" ]"; @@ -124,7 +124,7 @@ void walk() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -160,7 +160,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -202,7 +202,7 @@ void walkNullTupleItemsAdditional() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -252,7 +252,7 @@ void walkTupleItemsAdditional() throws JsonProcessingException { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -306,7 +306,7 @@ void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { + " \"default\": \"additional\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index 106b293c3..2b9e25f49 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.SchemaLoader; @@ -45,10 +46,10 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { } private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { - return SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12)) + return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) - .metaSchema(Dialects.getDraft202012()) + .dialectRegistry(new BasicDialectRegistry(Dialects.getDraft202012())) .build(); } diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index 7eb05d5d8..03223e0fd 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -26,14 +26,14 @@ class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json"), config); } @Test void preloadSchemaRefMaxNestingDepth() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .preloadJsonSchemaRefMaxNestingDepth(20) .build(); diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 7a3f4b97e..387c28567 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -120,7 +120,7 @@ void testIllegalArgumentException() { } private Schema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { - SchemaRegistry schemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().applyDefaultsStrategy(applyDefaultsStrategy).build(); return schemaFactory.getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json"), schemaValidatorsConfig); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 441ecad52..111cf8fe4 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -47,9 +47,7 @@ private void setupSchema() { schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); - final SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(dialect) - .build(); + final SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); this.jsonSchema = schemaFactory.getSchema(getSchema(), schemaValidatorsConfigBuilder.build()); // Create another Schema. SchemaValidatorsConfig.Builder schemaValidatorsConfig1Builder = SchemaValidatorsConfig.builder(); @@ -131,7 +129,7 @@ void testWalkMissingNodeWithPropertiesSchemaShouldNotThrow() { + " }\n" + " }"; - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); JsonNode missingNode = MissingNode.getInstance(); assertDoesNotThrow(() -> schema.walk(missingNode, true)); diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index 002a883f3..6b2bc88ae 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -34,7 +34,7 @@ class LocaleTest { private Schema getSchema(SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); return factory.getSchema( "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); @@ -88,7 +88,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { + " \"$id\": \"https://www.example.com\",\r\n" + " \"type\": \"object\"\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); @@ -96,7 +96,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { assertEquals("$: integer gefunden, object erwartet", messages.iterator().next().toString()); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ENGLISH).build(); - jsonSchema = SchemaRegistry.getInstance(Version.DRAFT_7) + jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema), config); messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); @@ -154,7 +154,7 @@ void encoding() { + " \"type\": \"string\",\r\n" + " \"maxLength\": 5\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index a034fbe1d..6378023c6 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -34,7 +34,7 @@ class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s, \"exclusiveMaximum\": true}"; - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); private static final ObjectMapper mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 0856a5afb..4cd22aa82 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.BaseKeywordValidator; @@ -73,7 +72,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath void message() { Dialect dialect = Dialect.builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) .keyword(new EqualsKeyword()).build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.metaSchema(dialect)); + SchemaRegistry factory = SchemaRegistry.withDialect(dialect); String schemaData = "{\r\n" + " \"type\": \"string\",\r\n" + " \"equals\": \"helloworld\"\r\n" diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index be3301fc2..864900bb7 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -42,7 +42,7 @@ void oas31() throws IOException { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07"), config); diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 237500a9a..02a0f1207 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -38,7 +38,7 @@ class MinimumValidatorTest { private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s }"; private static final String NEGATIVE_MESSAGE_TEMPLATE = "Expecting validation errors, value %s is smaller than minimum %s"; private static final String POSITIVT_MESSAGE_TEMPLATE = "Expecting no validation errors, value %s is greater than minimum %s"; - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); private static ObjectMapper mapper; private static ObjectMapper bigDecimalMapper; diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 0d0e3571f..3c00c6322 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -47,7 +47,7 @@ class MultipleOfValidatorTest { @Test void test() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; @@ -62,7 +62,7 @@ void test() { @Test void testTypeLoose() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":\"123.892\",\"value2\":\"123456.2934\",\"value3\":123.123}"; diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index a87c82103..3d5461841 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -36,7 +36,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 846357a58..66693aa6a 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -64,7 +64,7 @@ void oneOfMultiple() { + " \"fox\" : \"test\",\r\n" + " \"world\" : \"test\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -105,7 +105,7 @@ void oneOfZero() { String inputData = "{\r\n" + " \"test\" : 1\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -137,7 +137,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -185,7 +185,7 @@ void invalidSwaggerIoExample() { + " type: integer"; Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -259,7 +259,7 @@ void fixedSwaggerIoExample() { + " - age"; Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -301,7 +301,7 @@ void oneOfDiscriminatorEnabled() { + " }\r\n" + " ]\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); String inputData = "{}"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -355,7 +355,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -374,7 +374,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -443,7 +443,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); // Valid String inputData = "{\r\n" @@ -462,7 +462,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, + Schema schema2 = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); @@ -489,7 +489,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 92b34de47..a0895494f 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -15,7 +15,7 @@ class OpenAPI30JsonSchemaTest { protected ObjectMapper mapper = new ObjectMapper(); protected SchemaRegistry validatorFactory = SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)).build(); + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)).build(); OpenAPI30JsonSchemaTest() { } diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index e573e5c72..9c92ba6d6 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -22,7 +22,7 @@ class OutputFormatTest { - private static final SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); private static final String schemaPath1 = "/schema/output-format-schema.json"; private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { @@ -107,7 +107,7 @@ void customFormat() { + " }\n" + " }\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12) + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12) .getSchema(schemaData, InputFormat.JSON, SchemaValidatorsConfig.builder().build()); String inputData = "{\n" + " \"type\": \"cat\",\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index 38f23fe8e..f880b0a74 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -95,7 +95,7 @@ class OutputUnitTest { + "}"; @Test void annotationCollectionList() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -112,7 +112,7 @@ void annotationCollectionList() throws JsonProcessingException { @Test void annotationCollectionHierarchical() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -129,7 +129,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { @Test void annotationCollectionHierarchical2() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -178,7 +178,7 @@ void formatAnnotation(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -197,7 +197,7 @@ void formatAssertion(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -216,7 +216,7 @@ void typeUnion() { String typeSchema = "{\r\n" + " \"type\": [\"string\",\"array\"]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(typeSchema, config); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { @@ -265,7 +265,7 @@ void unevaluatedProperties() throws JsonProcessingException { + " \"unevaluatedProperties\": false\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -315,7 +315,7 @@ void anyOf() throws JsonProcessingException { + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); @@ -337,7 +337,7 @@ void listAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); @@ -352,7 +352,7 @@ void hierarchicalAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(formatSchema, config); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index fa5a848e1..0098643ef 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -55,7 +55,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .builder(URI, Dialects.getDraft201909()) .build(); - final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(validatorMetaSchema).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.withDialect(validatorMetaSchema); final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { @@ -72,7 +72,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { .format(PatternFormat.of("email", "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "format.email")) .build(); - final SchemaRegistry overrideValidatorFactory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_2019_09)).metaSchema(overrideValidatorMetaSchema).build(); + final SchemaRegistry overrideValidatorFactory = SchemaRegistry.withDialect(overrideValidatorMetaSchema); final Schema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); messages = overrideValidatorSchema.validate(targetNode, executionContext -> { diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 51600d3cf..88ced482c 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -12,7 +12,7 @@ class OverwritingCustomMessageBugTest { private Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 9345ab977..06148477f 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -41,7 +41,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); @@ -56,7 +56,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}", config); JsonNode node = getJsonNodeFromStringContent(""); @@ -79,7 +79,7 @@ void message() { + " }\n" + " }\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" @@ -130,7 +130,7 @@ void annotation() { + " }\n" + " }\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\n" diff --git a/src/test/java/com/networknt/schema/PatternValidatorTest.java b/src/test/java/com/networknt/schema/PatternValidatorTest.java index b3854609b..499d1a8e5 100644 --- a/src/test/java/com/networknt/schema/PatternValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternValidatorTest.java @@ -32,7 +32,7 @@ void failFast() { + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" + "}"; String inputData = "\"hello\""; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); assertFalse(result); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index ad393d060..c447d1aa1 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -54,7 +54,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[1, \"x\"]"; @@ -80,7 +80,7 @@ void messageValid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1]"; @@ -99,7 +99,7 @@ void messageInvalidAdditionalItems() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}],\r\n" + " \"items\": false" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "[\"x\", 1, 1, 2]"; @@ -130,7 +130,7 @@ void walkNull() { + " }\n" + " ]\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -183,7 +183,7 @@ void walkDefaults() throws JsonProcessingException { + " }\n" + " ]\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListener(new JsonSchemaWalkListener() { diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 1ccf1d270..769c70eb7 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -12,7 +12,7 @@ class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 0c1a6cf83..b9fa26f35 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -38,7 +38,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"propertyNames\": {\"maxLength\": 3}\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 0ea223702..7e9bf405f 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -40,7 +40,7 @@ private Schema loadJsonSchema(Boolean write) { } private Schema getJsonSchema(Boolean write) { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig schemaConfig = createSchemaConfig(write); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); return factory.getSchema(schema, schemaConfig); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 67513d842..1825c4d20 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -21,7 +21,7 @@ class RecursiveReferenceValidatorExceptionTest extends AbstractJsonSchemaTestSui void testInvalidRecursiveReference() { // Arrange String invalidSchemaJson = "{ \"$recursiveRef\": \"invalid\" }"; - SchemaRegistry jsonSchemaFactory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getMetaSchema(), diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index d1b3217d2..28c12216b 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -16,7 +16,7 @@ class RefTest { @Test void shouldLoadRelativeClasspathReference() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); String input = "{\r\n" @@ -39,7 +39,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { @Test void shouldLoadSchemaResource() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index e08070ce0..401b6f30e 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -40,7 +40,7 @@ void resolveSamePathDotSlash() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -59,7 +59,7 @@ void resolveSamePath() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -78,7 +78,7 @@ void resolveParent() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -97,7 +97,7 @@ void resolveComplex() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -107,7 +107,7 @@ void resolveComplex() { @Test void classPathSlash() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" @@ -123,7 +123,7 @@ void classPathSlash() { @Test void classPathNoSlash() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 64c772a72..214988dc8 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -55,7 +55,7 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -99,7 +99,7 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -143,7 +143,7 @@ void validateRequestRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" @@ -181,7 +181,7 @@ void validateResponseRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); Schema schema = factory.getSchema(schemaData, config); String inputData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index f00062e18..5bbc8339e 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -18,7 +18,7 @@ class SampleTest { @Test void schemaFromSchemaLocationMapping() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaMappers( + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers( schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. @@ -40,7 +40,7 @@ void schemaFromSchemaLocationMapping() { void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); /* @@ -61,7 +61,7 @@ void schemaFromSchemaLocationContent() { @Test void schemaFromClasspath() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -82,7 +82,7 @@ void schemaFromClasspath() { @Test void schemaFromString() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); /* * This should be cached for performance. * @@ -98,7 +98,7 @@ void schemaFromString() { @Test void schemaFromJsonNode() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); /* diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index c59731199..8823bb5c9 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -217,7 +217,7 @@ void documentFragment() { @Test void shouldLoadEscapedFragment() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); List result = schema.validate("1", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/SchemaRegistryTest.java b/src/test/java/com/networknt/schema/SchemaRegistryTest.java index bdcaa39d8..0e9ff2bf5 100644 --- a/src/test/java/com/networknt/schema/SchemaRegistryTest.java +++ b/src/test/java/com/networknt/schema/SchemaRegistryTest.java @@ -47,7 +47,7 @@ void concurrency() { + " { \"$ref\": \"https://json-schema.org/draft/2020-12/meta/core\" }\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); @@ -63,7 +63,7 @@ public void run() { } catch (InterruptedException e) { throw new RuntimeException(e); } - Dialect dialect = factory.getMetaSchema("https://www.example.com/no-validation-no-format/schema", config); + Dialect dialect = factory.getDialect("https://www.example.com/no-validation-no-format/schema", config); synchronized(instance) { if (instance[0] == null) { instance[0] = dialect; diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index 80aa6dabd..e84e3fac0 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -55,7 +55,7 @@ void concurrency() throws Exception { String inputData = "{\r\n" + " \"name\": 1\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().preloadJsonSchema(false).build(); diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index d1f4f1fdb..734fcf146 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -30,7 +30,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void shouldCallAllKeywordListenerOnWalkStart() throws Exception { - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); AllKeywordListener allKeywordListener = new AllKeywordListener(); SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 93f038f73..3e2fa3f2c 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -52,7 +52,7 @@ class TypeValidatorTest { @Test void testTypeLoose() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" @@ -101,7 +101,7 @@ void integer() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); @@ -130,7 +130,7 @@ void integerDraft4() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling @@ -145,7 +145,7 @@ void walkNull() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4).getSchema(schemaData); ValidationResult result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } @@ -173,7 +173,7 @@ void nullable() { + " \"nested\":null\r\n" + " }\r\n" + "}"; - final SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); final Schema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() .nullableKeywordEnabled(false) .build()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index e21facd8e..c7072cd31 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -43,7 +43,7 @@ void unevaluatedItemsFalse() { + " \"unevaluatedItems\" : false\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -69,7 +69,7 @@ void unevaluatedItemsSchema() { + " \"unevaluatedItems\" : { \"type\" : \"string\" }\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index e5461a492..82710b4a7 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -61,7 +61,7 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key3\": \"value3\",\r\n" + " \"key4\": \"value4\"\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -116,7 +116,7 @@ void subschemaProcessing() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -144,7 +144,7 @@ void unevaluatedPropertiesSchema() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -189,7 +189,7 @@ void ref() { + " \"unevaluatedProperties\": false\r\n" + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } @@ -228,7 +228,7 @@ void nestedRef() { schemas.put("https://www.example.org/PrimaryDeviceConfiguration.json", primaryDeviceConfiguration); schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2019_09, + .withDefaultDialect(Version.DRAFT_2019_09, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) .getSchema(schemaData); String inputData = "{ \"isPrimaryDevice\": true, \"roleName\": \"hello\" }"; diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index e61532689..4d007bff3 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -23,7 +23,7 @@ void testSchema1() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema1); List errors = jsonSchema.validate(jsonNode); @@ -37,7 +37,7 @@ void testSchema2() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema2); List errors = jsonSchema.validate(jsonNode); @@ -50,7 +50,7 @@ void testSchema3() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema3); List errors = jsonSchema.validate(jsonNode); @@ -68,10 +68,10 @@ void testNormalize() throws JsonSchemaException { String uri04 = "http://json-schema.org/draft-07/schema?key=value&key2=value2"; String expected = DialectId.DRAFT_7; - Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri01)); - Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri02)); - Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri03)); - Assertions.assertEquals(expected, SchemaRegistry.normalizeMetaSchemaUri(uri04)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeDialectId(uri01)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeDialectId(uri02)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeDialectId(uri03)); + Assertions.assertEquals(expected, SchemaRegistry.normalizeDialectId(uri04)); } } diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 3cc6f38bf..ff15c965a 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.SchemaRegistry.Builder; +import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; @@ -51,8 +52,8 @@ void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); Dialect draftV4 = Dialects.getDraft4(); Builder builder = SchemaRegistry.builder() - .defaultMetaSchemaIri(draftV4.getIri()) - .metaSchema(draftV4) + .defaultDialectId(draftV4.getIri()) + .dialectRegistry(new BasicDialectRegistry(draftV4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); SchemaRegistry instance = builder.build(); Schema schema = instance.getSchema(SchemaLocation.of( @@ -82,7 +83,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - SchemaRegistry instance = SchemaRegistry.getInstance(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -102,8 +103,8 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); Dialect draftV4 = Dialects.getDraft4(); Builder builder = SchemaRegistry.builder() - .defaultMetaSchemaIri(draftV4.getIri()) - .metaSchema(draftV4) + .defaultDialectId(draftV4.getIri()) + .dialectRegistry(new BasicDialectRegistry(draftV4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); instance = builder.build(); Schema schema = instance.getSchema(example); @@ -119,7 +120,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); @@ -149,7 +150,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); @@ -167,7 +168,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } catch (Exception ex) { fail("Unexpected exception thrown"); } - instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) + instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(example, config); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); @@ -176,7 +177,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index edddfa86b..78b533cb9 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -1,6 +1,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; @@ -30,8 +31,8 @@ void testURNToURI() throws Exception { is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); Dialect draftV7 = Dialects.getDraft7(); SchemaRegistry.Builder builder = SchemaRegistry.builder() - .defaultMetaSchemaIri(draftV7.getIri()) - .metaSchema(draftV7) + .defaultDialectId(draftV7.getIri()) + .dialectRegistry(new BasicDialectRegistry(draftV7)) .schemaMappers(schemaMappers -> schemaMappers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) ); SchemaRegistry instance = builder.build(); diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index 1a40a4faa..f36da0916 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -37,7 +37,7 @@ class V4JsonSchemaTest { void testLoadingWithId() throws Exception { try (InputStream inputStream = new FileInputStream("src/test/resources/remotes/self_ref/selfRef.json")) { JsonNode schemaJson = mapper.readTree(inputStream); - SchemaRegistry factory = SchemaRegistry.getInstance(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); @SuppressWarnings("unused") Schema schema = factory.getSchema(schemaJson); } @@ -90,7 +90,7 @@ private List validateFailingFastSchemaFor(final String schemaFileName, fi final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); return SchemaRegistry - .builder(SchemaRegistry.getInstance(Specification.Version.DRAFT_4)) + .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .build() .getSchema(schema, config) .validate(dataFile); diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index de0b3c959..8bdb65e44 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AnnotationKeyword; @@ -61,7 +62,7 @@ void noValidation() { + " }\r\n" + "}"; Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) @@ -76,7 +77,7 @@ void noValidation() { // Set validation vocab schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/validation", @@ -113,7 +114,7 @@ void noFormatValidation() { + " }\r\n" + "}"; Schema schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) @@ -126,10 +127,10 @@ void noFormatValidation() { List messages = schema.validate(inputDataNoValidation, InputFormat.JSON, executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); assertEquals(0, messages.size()); - + // Set format assertion vocab schema = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/format", @@ -165,7 +166,7 @@ void requiredUnknownVocabulary() { + " }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, + .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); @@ -204,12 +205,12 @@ void customVocabulary() { }; Dialect dialect = Dialect - .builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) + .builder("https://www.example.com/no-validation-no-format/schema", Dialects.getDraft202012()) .vocabularyFactory(vocabularyFactory) .build(); SchemaRegistry factory = SchemaRegistry - .getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(dialect).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + .withDefaultDialect(Version.DRAFT_2020_12, + builder -> builder.dialectRegistry(new BasicDialectRegistry(dialect)).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); Schema schema = factory.getSchema(schemaData); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java index 2223fa1c0..c47f0e4c4 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java @@ -26,7 +26,7 @@ public class NetworkntBasicRunner implements Callable { public NetworkntBasicRunner() { ObjectMapper objectMapper = new ObjectMapper(); - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_4); try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ObjectReader reader = objectMapper.reader(); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index 8b98d83c2..609b08778 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -67,7 +67,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { SchemaLocation testCaseFileUri = SchemaLocation .of("classpath:" + toForwardSlashPath(testCase.getSpecification())); Schema schema = SchemaRegistry - .getInstance(defaultVersion, + .withDefaultDialect(defaultVersion, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) .getSchema(testCaseFileUri, testCase.getSchema(), SchemaValidatorsConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()).build()); diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index 698eed527..a6acbbae9 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index 7722f1012..b28c03a12 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index 8916c8ecd..2804c9d8d 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -60,7 +60,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -89,7 +89,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index bf6035aa5..d0c00774e 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index a44a4c13f..bd03f1791 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -37,7 +37,7 @@ void uriShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -50,7 +50,7 @@ void queryWithBracketsShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -63,7 +63,7 @@ void queryWithEncodedBracketsShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +76,7 @@ void iriShouldFail() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -89,7 +89,7 @@ void noAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -101,7 +101,7 @@ void noSchemeNoAuthorityShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -113,7 +113,7 @@ void noPathShouldPass() { + "}"; SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); List messages = schema.validate("\"about:\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index e4e48d49f..0cec999b2 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -31,9 +31,7 @@ import com.networknt.schema.PathType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.Specification.Version; -import com.networknt.schema.dialect.DisallowUnknownDialectFactory; -import com.networknt.schema.dialect.OpenApi30; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.Error; /** @@ -45,10 +43,7 @@ class OpenApi30Test { */ @Test void validateMetaSchema() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, - builder -> builder.metaSchema(OpenApi30.getInstance()) - .defaultMetaSchemaIri(OpenApi30.getInstance().getIri()) - .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30()); Schema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/requestBody/content/application~1json/schema")); String input = "{\r\n" @@ -75,8 +70,7 @@ void validateMetaSchema() { */ @Test void jsonPointerWithNumberInFragment() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder - .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30()); Schema schema = factory.getSchema(SchemaLocation.of( "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"), SchemaValidatorsConfig.builder().pathType(PathType.JSON_PATH).build()); @@ -96,8 +90,7 @@ void exclusiveMaximum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMaximum\": true\r\n" + "}\r\n"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder - .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30()); Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("100", InputFormat.JSON, OutputFormat.BOOLEAN)); } @@ -113,8 +106,7 @@ void exclusiveMinimum() { + " \"maximum\": 100,\r\n" + " \"exclusiveMinimum\": true\r\n" + "}\r\n"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_7, builder -> builder - .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30()); Schema schema = factory.getSchema(schemaData); assertFalse(schema.validate("0", InputFormat.JSON, OutputFormat.BOOLEAN)); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index 294cbb0d3..b488947c4 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -27,8 +27,7 @@ import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; -import com.networknt.schema.dialect.DisallowUnknownDialectFactory; -import com.networknt.schema.dialect.OpenApi31; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.Error; /** @@ -40,7 +39,7 @@ class OpenApi31Test { */ @Test void validateVocabulary() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); Schema schema = factory @@ -69,9 +68,7 @@ void validateVocabulary() { */ @Test void validateMetaSchema() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -99,9 +96,7 @@ void validateMetaSchema() { */ @Test void discriminatorOneOfMultipleMatchShouldFail() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -119,9 +114,7 @@ void discriminatorOneOfMultipleMatchShouldFail() { */ @Test void discriminatorOneOfNoMatchShouldFail() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" @@ -141,9 +134,7 @@ void discriminatorOneOfNoMatchShouldFail() { */ @Test void discriminatorOneOfOneMatchWrongDiscriminatorShouldSucceed() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, - builder -> builder.metaSchema(OpenApi31.getInstance()) - .metaSchemaFactory(DisallowUnknownDialectFactory.getInstance())); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java index f19c06247..2b50198c6 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java @@ -34,7 +34,7 @@ class AllowSchemaLoaderTest { @Test void integration() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .add(new AllowSchemaLoader(iri -> iri.toString().startsWith("classpath:"))))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, diff --git a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java index 9c92fcc93..cba2728fd 100644 --- a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java @@ -32,7 +32,7 @@ class DisallowSchemaLoaderTest { @Test void integration() { - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.add(DisallowSchemaLoader.getInstance()))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index dd8240ec3..4400e35aa 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -87,7 +87,7 @@ void jsonLocation() { String inputData = "{\r\n" + " \"startDate\": \"1\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, InputFormat.JSON, config); @@ -133,7 +133,7 @@ void yamlLocation() { + " minLength: 6\r\n"; String inputData = "---\r\n" + "startDate: '1'\r\n"; - SchemaRegistry factory = SchemaRegistry.getInstance(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = factory.getSchema(schemaData, InputFormat.YAML, config); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index fe90d2f05..d18525bb9 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -104,7 +104,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -184,7 +184,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -269,7 +269,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -342,7 +342,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -391,7 +391,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09) + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09) .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" @@ -555,7 +555,7 @@ void applyDefaults() throws JsonProcessingException { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -612,7 +612,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -669,7 +669,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); @@ -737,7 +737,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertFalse(result.getErrors().isEmpty()); @@ -807,7 +807,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); ValidationResult result = schema.walk(inputNode, true); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); @@ -858,7 +858,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2019_09).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); @@ -921,7 +921,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListener(listener) .propertyWalkListener(listener) .build(); - Schema schema = SchemaRegistry.getInstance(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); ValidationResult result = schema.walk(null, true); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); From fb6f6b1b42ba0acf2b3cf768fbf43d8c5e03993d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:08:11 +0800 Subject: [PATCH 17/74] Rename SchemaValidatorsConfig to SchemaRegistryConfig and move from ValidationContext to SchemaRegistry and refactor Rename JsonSchemaWalkerListener to SchemaWalkerListener Rename DefaultItemWalkListenerRunner to ItemWalkListenerRunner Rename DefaultKeywordWalkListenerRunner to KeywordWalkListenerRunner Rename DefaultPropertyWalkListenerRunner to PropertyWalkListenerRunner Shift walk configuration to WalkConfig --- .../networknt/schema/AbstractCollector.java | 29 - .../schema/ApplyDefaultsStrategy.java | 2 +- .../java/com/networknt/schema/Collector.java | 46 - .../networknt/schema/CollectorContext.java | 146 +- .../com/networknt/schema/ExecutionConfig.java | 248 ++- .../networknt/schema/ExecutionContext.java | 51 +- .../schema/ExecutionContextCustomizer.java | 4 +- .../java/com/networknt/schema/Format.java | 2 +- .../com/networknt/schema/OutputFormat.java | 46 +- .../java/com/networknt/schema/Schema.java | 250 ++- .../com/networknt/schema/SchemaRegistry.java | 254 +-- .../schema/SchemaRegistryConfig.java | 584 +++++++ .../schema/SchemaValidatorsConfig.java | 1411 ----------------- .../com/networknt/schema/Specification.java | 2 +- .../com/networknt/schema/TypeFactory.java | 2 +- .../networknt/schema/ValidationContext.java | 106 +- .../schema/dialect/BasicDialectRegistry.java | 3 +- .../dialect/DefaultDialectRegistry.java | 18 +- .../com/networknt/schema/dialect/Dialect.java | 6 +- .../schema/dialect/DialectRegistry.java | 4 +- .../format/BaseFormatJsonValidator.java | 8 +- .../schema/format/DurationFormat.java | 2 +- .../AdditionalPropertiesValidator.java | 6 - .../schema/keyword/AllOfValidator.java | 11 +- .../schema/keyword/AnyOfValidator.java | 18 +- .../schema/keyword/BaseKeywordValidator.java | 32 +- .../schema/keyword/ConstValidator.java | 7 - .../schema/keyword/ContainsValidator.java | 8 +- .../keyword/ContentEncodingValidator.java | 8 +- .../keyword/ContentMediaTypeValidator.java | 8 +- .../schema/keyword/DependenciesValidator.java | 6 - .../schema/keyword/DependentRequired.java | 6 - .../schema/keyword/DependentSchemas.java | 6 - .../schema/keyword/DynamicRefValidator.java | 13 +- .../schema/keyword/EnumValidator.java | 13 +- .../keyword/ExclusiveMaximumValidator.java | 9 +- .../keyword/ExclusiveMinimumValidator.java | 9 +- .../schema/keyword/FalseValidator.java | 6 - .../schema/keyword/FormatValidator.java | 4 +- .../networknt/schema/keyword/IfValidator.java | 7 +- .../schema/keyword/ItemsValidator.java | 18 +- .../schema/keyword/ItemsValidator202012.java | 13 +- .../schema/keyword/MaxItemsValidator.java | 10 +- .../schema/keyword/MaxLengthValidator.java | 9 +- .../keyword/MaxPropertiesValidator.java | 7 +- .../schema/keyword/MaximumValidator.java | 8 +- .../schema/keyword/MinItemsValidator.java | 9 +- .../schema/keyword/MinLengthValidator.java | 9 +- .../keyword/MinPropertiesValidator.java | 7 +- .../schema/keyword/MinimumValidator.java | 8 +- .../schema/keyword/MultipleOfValidator.java | 11 +- .../schema/keyword/NonValidationKeyword.java | 4 +- .../schema/keyword/NotAllowedValidator.java | 7 +- .../schema/keyword/NotValidator.java | 7 +- .../schema/keyword/OneOfValidator.java | 17 +- .../keyword/PatternPropertiesValidator.java | 6 +- .../schema/keyword/PatternValidator.java | 4 +- .../schema/keyword/PrefixItemsValidator.java | 13 +- .../schema/keyword/PropertiesValidator.java | 20 +- .../keyword/PropertyNamesValidator.java | 6 +- .../schema/keyword/ReadOnlyValidator.java | 8 +- .../schema/keyword/RecursiveRefValidator.java | 15 +- .../schema/keyword/RefValidator.java | 25 +- .../schema/keyword/RequiredValidator.java | 11 +- .../schema/keyword/TrueValidator.java | 7 +- .../schema/keyword/TypeValidator.java | 8 +- .../keyword/UnevaluatedItemsValidator.java | 7 +- .../UnevaluatedPropertiesValidator.java | 19 +- .../schema/keyword/UnionTypeValidator.java | 9 +- .../schema/keyword/UniqueItemsValidator.java | 7 +- .../schema/keyword/WriteOnlyValidator.java | 8 +- .../HierarchicalOutputUnitFormatter.java | 6 +- .../schema/regex/RegularExpression.java | 2 +- .../networknt/schema/utils/JsonNodeUtil.java | 12 +- .../walk/AbstractWalkListenerRunner.java | 8 +- .../walk/DefaultItemWalkListenerRunner.java | 36 - .../DefaultKeywordWalkListenerRunner.java | 52 - .../DefaultPropertyWalkListenerRunner.java | 35 - .../schema/walk/ItemWalkListenerRunner.java | 79 + .../walk/KeywordWalkListenerRunner.java | 106 ++ .../walk/PropertyWalkListenerRunner.java | 79 + .../com/networknt/schema/walk/WalkConfig.java | 198 +++ .../com/networknt/schema/walk/WalkEvent.java | 2 +- ...emaWalkListener.java => WalkListener.java} | 2 +- .../schema/AbstractJsonSchemaTestSuite.java | 68 +- .../AdditionalPropertiesValidatorTest.java | 6 +- .../schema/BaseJsonSchemaValidatorTest.java | 9 +- .../schema/CollectorContextTest.java | 185 ++- .../networknt/schema/ConstValidatorTest.java | 18 +- .../schema/ContentSchemaValidatorTest.java | 7 +- .../schema/CustomMetaSchemaTest.java | 2 +- .../schema/CyclicDependencyTest.java | 3 +- .../DefaultJsonSchemaIdValidatorTest.java | 20 +- .../schema/DependentRequiredTest.java | 2 +- .../schema/DiscriminatorValidatorTest.java | 47 +- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 6 +- .../networknt/schema/ErrorHandlerTest.java | 10 +- .../com/networknt/schema/ExampleTest.java | 14 +- .../networknt/schema/FormatValidatorTest.java | 41 +- .../com/networknt/schema/IfValidatorTest.java | 67 +- .../com/networknt/schema/Issue1091Test.java | 6 +- .../com/networknt/schema/Issue342Test.java | 4 +- .../schema/Issue366FailFastTest.java | 7 +- .../schema/Issue366FailSlowTest.java | 8 +- .../com/networknt/schema/Issue375Test.java | 6 +- .../com/networknt/schema/Issue426Test.java | 3 +- .../com/networknt/schema/Issue428Test.java | 10 +- .../com/networknt/schema/Issue451Test.java | 20 +- .../com/networknt/schema/Issue461Test.java | 20 +- .../com/networknt/schema/Issue467Test.java | 30 +- .../com/networknt/schema/Issue475Test.java | 15 +- .../com/networknt/schema/Issue493Test.java | 10 +- .../com/networknt/schema/Issue532Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 11 +- .../com/networknt/schema/Issue662Test.java | 4 +- .../com/networknt/schema/Issue686Test.java | 20 +- .../com/networknt/schema/Issue687Test.java | 12 +- .../com/networknt/schema/Issue724Test.java | 16 +- .../java/com/networknt/schema/Issue792.java | 8 +- .../com/networknt/schema/Issue857Test.java | 6 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue936Test.java | 6 +- .../com/networknt/schema/Issue943Test.java | 3 +- .../schema/ItemsValidator202012Test.java | 33 +- .../networknt/schema/ItemsValidatorTest.java | 104 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 4 +- .../schema/JsonSchemaPreloadTest.java | 12 +- .../schema/JsonWalkApplyDefaultsTest.java | 44 +- .../com/networknt/schema/JsonWalkTest.java | 57 +- .../java/com/networknt/schema/LocaleTest.java | 88 +- .../schema/MaximumValidatorTest.java | 15 +- .../com/networknt/schema/MessageTest.java | 2 +- .../schema/MetaSchemaValidationTest.java | 6 +- .../schema/MinimumValidatorTest.java | 14 +- .../schema/MultipleOfValidatorTest.java | 5 +- .../networknt/schema/OneOfValidatorTest.java | 22 +- .../schema/OpenAPI30JsonSchemaTest.java | 12 +- .../networknt/schema/OutputFormatTest.java | 5 +- .../com/networknt/schema/OutputUnitTest.java | 78 +- .../schema/OverrideValidatorTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 7 +- .../PatternPropertiesValidatorTest.java | 24 +- .../schema/PrefixItemsValidatorTest.java | 61 +- .../schema/PropertiesValidatorTest.java | 12 +- .../schema/PropertyNamesValidatorTest.java | 3 +- .../schema/ReadOnlyValidatorTest.java | 22 +- ...ursiveReferenceValidatorExceptionTest.java | 4 +- .../java/com/networknt/schema/RefTest.java | 14 +- .../schema/RequiredValidatorTest.java | 28 +- .../java/com/networknt/schema/SampleTest.java | 10 +- .../networknt/schema/SchemaRegistryTest.java | 3 +- .../java/com/networknt/schema/SchemaTest.java | 7 +- .../schema/SchemaValidatorsConfigTest.java | 97 -- .../networknt/schema/SharedConfigTest.java | 20 +- .../com/networknt/schema/TypeFactoryTest.java | 22 +- .../networknt/schema/TypeValidatorTest.java | 12 +- .../schema/UnevaluatedItemsValidatorTest.java | 16 +- .../UnevaluatedPropertiesValidatorTest.java | 8 +- .../com/networknt/schema/UriMappingTest.java | 10 +- .../networknt/schema/V4JsonSchemaTest.java | 8 +- .../com/networknt/schema/VocabularyTest.java | 8 +- .../benchmark/NetworkntTestSuiteRunner.java | 16 +- .../NetworkntTestSuiteTestCases.java | 10 +- .../schema/format/IriFormatTest.java | 36 +- .../schema/format/IriReferenceFormatTest.java | 43 +- .../schema/format/TimeFormatTest.java | 13 +- .../schema/format/UriFormatTest.java | 39 +- .../schema/format/UriReferenceFormatTest.java | 36 +- .../networknt/schema/oas/OpenApi30Test.java | 9 +- .../com/networknt/schema/suite/TestSpec.java | 6 +- .../networknt/schema/utils/JsonNodesTest.java | 11 +- ...istenerTest.java => WalkListenerTest.java} | 161 +- 174 files changed, 2766 insertions(+), 3588 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/AbstractCollector.java delete mode 100644 src/main/java/com/networknt/schema/Collector.java create mode 100644 src/main/java/com/networknt/schema/SchemaRegistryConfig.java delete mode 100644 src/main/java/com/networknt/schema/SchemaValidatorsConfig.java delete mode 100644 src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java delete mode 100644 src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java delete mode 100644 src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java create mode 100644 src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java create mode 100644 src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java create mode 100644 src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java create mode 100644 src/main/java/com/networknt/schema/walk/WalkConfig.java rename src/main/java/com/networknt/schema/walk/{JsonSchemaWalkListener.java => WalkListener.java} (86%) delete mode 100644 src/test/java/com/networknt/schema/SchemaValidatorsConfigTest.java rename src/test/java/com/networknt/schema/walk/{JsonSchemaWalkListenerTest.java => WalkListenerTest.java} (87%) diff --git a/src/main/java/com/networknt/schema/AbstractCollector.java b/src/main/java/com/networknt/schema/AbstractCollector.java deleted file mode 100644 index 3a45d81d0..000000000 --- a/src/main/java/com/networknt/schema/AbstractCollector.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -/** - * Base collector. - * - * @param the type - */ -public abstract class AbstractCollector implements Collector { - - @Override - public void combine(Object object) { - // Do nothing. This is the default Implementation. - } -} diff --git a/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java b/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java index 391a160a0..514e11ede 100644 --- a/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java +++ b/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java @@ -1,7 +1,7 @@ package com.networknt.schema; public class ApplyDefaultsStrategy { - static final ApplyDefaultsStrategy EMPTY_APPLY_DEFAULTS_STRATEGY = new ApplyDefaultsStrategy(false, false, false); + public static final ApplyDefaultsStrategy EMPTY_APPLY_DEFAULTS_STRATEGY = new ApplyDefaultsStrategy(false, false, false); private final boolean applyPropertyDefaults; private final boolean applyPropertyDefaultsIfNull; diff --git a/src/main/java/com/networknt/schema/Collector.java b/src/main/java/com/networknt/schema/Collector.java deleted file mode 100644 index f3e84f00b..000000000 --- a/src/main/java/com/networknt/schema/Collector.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema; - -/** - * Basic interface that allows the implementers to collect the information and - * return it. - * - * @param element - */ -public interface Collector { - - - /** - * This method should be called by the intermediate touch points that want to - * combine the data being collected by this collector. This is an optional - * method and could be used when the same collector is used for collecting data - * at multiple touch points or accumulating data at same touch point. - * @param object Object - */ - void combine(Object object); - - /** - * Final method called by the framework that returns the actual collected data. - * If the collector is not accumulating data or being used to collect data at - * multiple touch points, only this method can be implemented. - * @return E element - */ - E collect(); - - -} diff --git a/src/main/java/com/networknt/schema/CollectorContext.java b/src/main/java/com/networknt/schema/CollectorContext.java index 53e439faa..73bd1f33a 100644 --- a/src/main/java/com/networknt/schema/CollectorContext.java +++ b/src/main/java/com/networknt/schema/CollectorContext.java @@ -17,136 +17,86 @@ import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; +import java.util.function.Function; /** - * Context for holding the output returned by the {@link Collector} - * implementations. + * Context for holding data which can be set by custom walkers or validators and + * can be retrieved later from the execution context. */ public class CollectorContext { /** - * Map for holding the name and {@link Collector} or a simple Object. + * Map for the data. */ - private final Map collectorMap; - - /** - * Map for holding the name and {@link Collector} class collect method output. - */ - private final Map collectorLoadMap; + private final Map data; /** * Default constructor will use an unsynchronized HashMap to store data. This is * suitable if the collector context is not shared with multiple threads. */ public CollectorContext() { - this(new HashMap<>(), new HashMap<>()); + this(new HashMap<>()); } - /** - * Constructor that creates the context using the specified instances to store - * data. - *

- * If for instance the collector context needs to be shared with multiple - * threads a ConcurrentHashMap can be used. - * - * @param collectorMap the collector map - * @param collectorLoadMap the collector load map - */ - public CollectorContext(Map collectorMap, Map collectorLoadMap) { - this.collectorMap = collectorMap; - this.collectorLoadMap = collectorLoadMap; - } - - /** - * Adds a collector with give name. Preserving this method for backward - * compatibility. - * - * @param element - * @param name String - * @param collector Collector - */ - public void add(String name, Collector collector) { - this.collectorMap.put(name, collector); + /** + * Constructor that creates the context using the specified instances to store + * data. + *

+ * If for instance the collector context needs to be shared with multiple + * threads a ConcurrentHashMap can be used. + *

+ * It is however more likely that the data will only be used after the walk or + * validation is complete rather then during processing. + * + * @param data the data map + */ + public CollectorContext(Map data) { + this.data = data; } /** - * Adds a collector or a simple object with give name. + * Sets data associated with a given key. * - * @param element - * @param object Object - * @param name String + * @param the return type + * @param key the key + * @param value the value + * @return the previous value */ - public void add(String name, Object object) { - this.collectorMap.put(name, object); + @SuppressWarnings("unchecked") + public T put(Object key, Object value) { + return (T) this.data.put(key, value); } /** - * Gets the data associated with a given name. Please note if you are collecting - * {@link Collector} instances you should wait till the validation is complete - * to gather all data. - *

- * When {@link CollectorContext} is used to collect {@link Collector} instances - * for a particular key, this method will return the {@link Collector} instance - * as long as {@link #loadCollectors} method is not called. Once - * the {@link #loadCollectors} method is called this method will - * return the actual data collected by collector. - * - * @param name String - * @return Object - */ - public Object get(String name) { - Object object = this.collectorMap.get(name); - if (object instanceof Collector && (this.collectorLoadMap.get(name) != null)) { - return this.collectorLoadMap.get(name); - } - return this.collectorMap.get(name); - } - - /** - * Gets the collector map. + * Gets the data associated with a given key. * - * @return the collector map + * @param the return type + * @param key the key + * @return the value */ - public Map getCollectorMap() { - return this.collectorMap; + @SuppressWarnings("unchecked") + public T get(Object key) { + return (T) this.data.get(key); } /** - * Returns all the collected data. Please look into {@link #get(String)} method for more details. - * @return Map - */ - public Map getAll() { - Map mergedMap = new HashMap<>(); - mergedMap.putAll(this.collectorMap); - mergedMap.putAll(this.collectorLoadMap); - return mergedMap; - } - - /** - * Combines data with Collector identified by the given name. + * Computes the value if absent. * - * @param name String - * @param data Object + * @param the return type + * @param key the key + * @param mappingFunction the mapping function + * @return the value */ - public void combineWithCollector(String name, Object data) { - Object object = this.collectorMap.get(name); - if (object instanceof Collector) { - Collector collector = (Collector) object; - collector.combine(data); - } + @SuppressWarnings("unchecked") + public T computeIfAbsent(Object key, Function mappingFunction) { + return (T) this.data.computeIfAbsent(key, mappingFunction); } /** - * Loads data from all collectors. + * Gets the data map. + * + * @return the data map */ - public void loadCollectors() { - Set> entrySet = this.collectorMap.entrySet(); - for (Entry entry : entrySet) { - if (entry.getValue() instanceof Collector) { - Collector collector = (Collector) entry.getValue(); - this.collectorLoadMap.put(entry.getKey(), collector.collect()); - } - } + public Map getData() { + return this.data; } } diff --git a/src/main/java/com/networknt/schema/ExecutionConfig.java b/src/main/java/com/networknt/schema/ExecutionConfig.java index e4f83ee0f..0c84b1826 100644 --- a/src/main/java/com/networknt/schema/ExecutionConfig.java +++ b/src/main/java/com/networknt/schema/ExecutionConfig.java @@ -24,10 +24,18 @@ * Configuration per execution. */ public class ExecutionConfig { + private static class Holder { + private static final ExecutionConfig INSTANCE = ExecutionConfig.builder().build(); + } + + public static ExecutionConfig getInstance() { + return Holder.INSTANCE; + } + /** * The locale to use for formatting messages. */ - private Locale locale = Locale.ROOT; + private final Locale locale; /** * Determines if annotation collection is enabled. @@ -35,7 +43,7 @@ public class ExecutionConfig { * This does not affect annotation collection required for evaluating keywords * such as unevaluatedItems or unevaluatedProperties and only affects reporting. */ - private boolean annotationCollectionEnabled = false; + private final boolean annotationCollectionEnabled; /** * If annotation collection is enabled, determine which annotations to collect. @@ -43,43 +51,50 @@ public class ExecutionConfig { * This does not affect annotation collection required for evaluating keywords * such as unevaluatedItems or unevaluatedProperties and only affects reporting. */ - private Predicate annotationCollectionFilter = keyword -> false; + private final Predicate annotationCollectionFilter; /** * Since Draft 2019-09 format assertions are not enabled by default. */ - private Boolean formatAssertionsEnabled = null; + private final Boolean formatAssertionsEnabled; /** * Determine if the validation execution can fail fast. */ - private boolean failFast = false; + private final boolean failFast; /** - * Determine if debugging features such that logging are switched on. - *

- * This is turned off by default. This is present because the library attempts - * to log debug logs at each validation node and the logger evaluation on - * whether the logger is turned on is impacting performance. + * When set to true assumes that schema is used to validate incoming data from + * an API. */ - private boolean debugEnabled = false; + private final Boolean readOnly; /** - * Gets the locale to use for formatting messages. - * - * @return the locale + * When set to true assumes that schema is used to validate outgoing data from + * an API. */ - public Locale getLocale() { - return locale; + private final Boolean writeOnly; + + protected ExecutionConfig(Locale locale, boolean annotationCollectionEnabled, + Predicate annotationCollectionFilter, Boolean formatAssertionsEnabled, boolean failFast, + Boolean readOnly, Boolean writeOnly) { + super(); + this.locale = locale; + this.annotationCollectionEnabled = annotationCollectionEnabled; + this.annotationCollectionFilter = annotationCollectionFilter; + this.formatAssertionsEnabled = formatAssertionsEnabled; + this.failFast = failFast; + this.readOnly = readOnly; + this.writeOnly = writeOnly; } /** - * Sets the locale to use for formatting messages. + * Gets the locale to use for formatting messages. * - * @param locale the locale + * @return the locale */ - public void setLocale(Locale locale) { - this.locale = Objects.requireNonNull(locale, "Locale must not be null"); + public Locale getLocale() { + return locale; } /** @@ -97,15 +112,6 @@ public Boolean getFormatAssertionsEnabled() { return formatAssertionsEnabled; } - /** - * Sets the format assertion enabled flag. - * - * @param formatAssertionsEnabled the format assertions enabled flag - */ - public void setFormatAssertionsEnabled(Boolean formatAssertionsEnabled) { - this.formatAssertionsEnabled = formatAssertionsEnabled; - } - /** * Return if fast fail is enabled. * @@ -115,15 +121,6 @@ public boolean isFailFast() { return failFast; } - /** - * Sets whether fast fail is enabled. - * - * @param failFast true to fast fail - */ - public void setFailFast(boolean failFast) { - this.failFast = failFast; - } - /** * Return if annotation collection is enabled. *

@@ -139,21 +136,6 @@ public boolean isAnnotationCollectionEnabled() { return annotationCollectionEnabled; } - /** - * Sets whether the annotation collection is enabled. - *

- * This does not affect annotation collection required for evaluating keywords - * such as unevaluatedItems or unevaluatedProperties and only affects reporting. - *

- * The annotations to collect can be customized using the annotation collection - * predicate. - * - * @param annotationCollectionEnabled true to enable annotation collection - */ - public void setAnnotationCollectionEnabled(boolean annotationCollectionEnabled) { - this.annotationCollectionEnabled = annotationCollectionEnabled; - } - /** * Gets the predicate to determine if annotation collection is allowed for a * particular keyword. This only has an effect if annotation collection is @@ -173,37 +155,155 @@ public Predicate getAnnotationCollectionFilter() { } /** - * Predicate to determine if annotation collection is allowed for a particular - * keyword. This only has an effect if annotation collection is enabled. - *

- * The default value is to not collect any annotation keywords if annotation - * collection is enabled. - *

- * This does not affect annotation collection required for evaluating keywords - * such as unevaluatedItems or unevaluatedProperties and only affects reporting. + * Returns the value of the read only flag. * - * @param annotationCollectionFilter the predicate accepting the keyword + * @return the value of read only flag or null if not set */ - public void setAnnotationCollectionFilter(Predicate annotationCollectionFilter) { - this.annotationCollectionFilter = Objects.requireNonNull(annotationCollectionFilter, - "annotationCollectionFilter must not be null"); + public Boolean getReadOnly() { + return this.readOnly; } /** - * Gets if debugging features such as logging is switched on. + * Returns the value of the write only flag. * - * @return true if debug is enabled + * @return the value of the write only flag or null if not set */ - public boolean isDebugEnabled() { - return debugEnabled; + public Boolean getWriteOnly() { + return this.writeOnly; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(ExecutionConfig config) { + Builder copy = new Builder(); + copy.locale = config.locale; + copy.annotationCollectionEnabled = config.annotationCollectionEnabled; + copy.annotationCollectionFilter = config.annotationCollectionFilter; + copy.formatAssertionsEnabled = config.formatAssertionsEnabled; + copy.failFast = config.failFast; + copy.readOnly = config.readOnly; + copy.writeOnly = config.writeOnly; + return copy; } /** - * Sets if debugging features such as logging is switched on. - * - * @param debugEnabled true to enable debug + * Builder for {@link ExecutionConfig}. + */ + public static class Builder extends BuilderSupport { + + @Override + protected Builder self() { + return this; + } + } + + /** + * Builder for {@link ExecutionConfig}. */ - public void setDebugEnabled(boolean debugEnabled) { - this.debugEnabled = debugEnabled; + public static abstract class BuilderSupport { + protected Locale locale = Locale.ROOT; + protected boolean annotationCollectionEnabled = false; + protected Predicate annotationCollectionFilter = keyword -> false; + protected Boolean formatAssertionsEnabled = null; + protected boolean failFast = false; + protected Boolean readOnly = null; + protected Boolean writeOnly = null; + + protected abstract T self(); + + /** + * Sets the locale to use for formatting messages. + * + * @param locale the locale + * @return the builder + */ + public T locale(Locale locale) { + this.locale = locale; + return self(); + } + + /** + * Sets whether the annotation collection is enabled. + *

+ * This does not affect annotation collection required for evaluating keywords + * such as unevaluatedItems or unevaluatedProperties and only affects reporting. + *

+ * The annotations to collect can be customized using the annotation collection + * predicate. + * + * @param annotationCollectionEnabled true to enable annotation collection + * @return the builder + */ + public T annotationCollectionEnabled(boolean annotationCollectionEnabled) { + this.annotationCollectionEnabled = annotationCollectionEnabled; + return self(); + } + + /** + * Predicate to determine if annotation collection is allowed for a particular + * keyword. This only has an effect if annotation collection is enabled. + *

+ * The default value is to not collect any annotation keywords if annotation + * collection is enabled. + *

+ * This does not affect annotation collection required for evaluating keywords + * such as unevaluatedItems or unevaluatedProperties and only affects reporting. + * + * @param annotationCollectionFilter the predicate accepting the keyword + * @return the builder + */ + public T annotationCollectionFilter(Predicate annotationCollectionFilter) { + this.annotationCollectionFilter = annotationCollectionFilter; + return self(); + } + + /** + * Sets the format assertion enabled flag. + * + * @param formatAssertionsEnabled the format assertions enabled flag + * @return the builder + */ + public T formatAssertionsEnabled(Boolean formatAssertionsEnabled) { + this.formatAssertionsEnabled = formatAssertionsEnabled; + return self(); + } + + /** + * Sets whether fast fail is enabled. + * + * @param failFast true to fast fail + * @return the builder + */ + public T failFast(boolean failFast) { + this.failFast = failFast; + return self(); + } + + public T readOnly(Boolean readOnly) { + this.readOnly = readOnly; + return self(); + } + + public T writeOnly(Boolean writeOnly) { + this.writeOnly = writeOnly; + return self(); + } + + /** + * Builds the {@link ExecutionConfig}. + * + * @return the execution configuration + */ + public ExecutionConfig build() { + Locale locale = this.locale; + if (locale == null) { + locale = Locale.getDefault(); + } + Objects.requireNonNull(annotationCollectionFilter, "annotationCollectionFilter must not be null"); + return new ExecutionConfig(locale, annotationCollectionEnabled, annotationCollectionFilter, + formatAssertionsEnabled, failFast, readOnly, writeOnly); + } } } diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 75ede6b46..95c38baf6 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -18,17 +18,21 @@ import com.networknt.schema.annotation.JsonNodeAnnotations; import com.networknt.schema.result.JsonNodeResults; +import com.networknt.schema.walk.WalkConfig; import java.util.ArrayList; import java.util.List; import java.util.Stack; +import java.util.function.Consumer; /** * Stores the execution context for the validation run. */ public class ExecutionContext { private ExecutionConfig executionConfig; + private WalkConfig walkConfig = null; private CollectorContext collectorContext = null; + private Stack discriminatorContexts = null; private JsonNodeAnnotations annotations = null; private JsonNodeResults results = null; @@ -45,7 +49,7 @@ public class ExecutionContext { * Creates an execution context. */ public ExecutionContext() { - this(new ExecutionConfig(), null); + this(ExecutionConfig.getInstance(), null); } /** @@ -54,7 +58,7 @@ public ExecutionContext() { * @param collectorContext the collector context */ public ExecutionContext(CollectorContext collectorContext) { - this(new ExecutionConfig(), collectorContext); + this(ExecutionConfig.getInstance(), collectorContext); } /** @@ -77,6 +81,27 @@ public ExecutionContext(ExecutionConfig executionConfig, CollectorContext collec this.executionConfig = executionConfig; } + /** + * Sets the walk configuration. + * + * @param walkConfig the walk configuration + */ + public void setWalkConfig(WalkConfig walkConfig) { + this.walkConfig = walkConfig; + } + + /** + * Gets the walk configuration. + * + * @return the walk configuration + */ + public WalkConfig getWalkConfig() { + if (this.walkConfig == null) { + this.walkConfig = WalkConfig.getInstance(); + } + return this.walkConfig; + } + /** * Gets the collector context. * @@ -191,4 +216,26 @@ public void addError(Error error) { public void setErrors(List errors) { this.errors = errors; } + + /** + * Customize the execution configuration. + * + * @param customizer the customizer + */ + public void executionConfig(Consumer customizer) { + ExecutionConfig.Builder builder = ExecutionConfig.builder(this.getExecutionConfig()); + customizer.accept(builder); + this.executionConfig = builder.build(); + } + + /** + * Customize the walk configuration. + * + * @param customizer the customizer + */ + public void walkConfig(Consumer customizer) { + WalkConfig.Builder builder = WalkConfig.builder(this.getWalkConfig()); + customizer.accept(builder); + this.walkConfig = builder.build(); + } } diff --git a/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java b/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java index edaa94953..0f67d3f9e 100644 --- a/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java +++ b/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java @@ -27,7 +27,7 @@ public interface ExecutionContextCustomizer { * The validation context should only be used for reference as it is shared. * * @param executionContext the execution context - * @param validationContext the validation context for reference + * @param schemaContext the schema context for reference */ - void customize(ExecutionContext executionContext, ValidationContext validationContext); + void customize(ExecutionContext executionContext, ValidationContext schemaContext); } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/Format.java index ba3246a60..a05e1b2e6 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/Format.java @@ -99,7 +99,7 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * @return true if matches */ default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, JsonNode value) { - JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return true; } diff --git a/src/main/java/com/networknt/schema/OutputFormat.java b/src/main/java/com/networknt/schema/OutputFormat.java index 601a7b32d..750789961 100644 --- a/src/main/java/com/networknt/schema/OutputFormat.java +++ b/src/main/java/com/networknt/schema/OutputFormat.java @@ -35,9 +35,9 @@ public interface OutputFormat { * The validation context should only be used for reference as it is shared. * * @param executionContext the execution context - * @param validationContext the validation context for reference + * @param schemaContext the schema context for reference */ - default void customize(ExecutionContext executionContext, ValidationContext validationContext) { + default void customize(ExecutionContext executionContext, ValidationContext schemaContext) { } /** @@ -45,12 +45,12 @@ default void customize(ExecutionContext executionContext, ValidationContext vali * * @param jsonSchema the schema * @param executionContext the execution context - * @param validationContext the validation context + * @param schemaContext the schema context * * @return the result */ T format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext); + ExecutionContext executionContext, ValidationContext schemaContext); /** * The Default output format. @@ -90,9 +90,9 @@ T format(Schema jsonSchema, */ class Default implements OutputFormat> { @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(false); - } + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + executionContext.executionConfig(executionConfig -> executionConfig.annotationCollectionEnabled(false)); + } @Override public java.util.List format(Schema jsonSchema, @@ -106,10 +106,10 @@ public java.util.List format(Schema jsonSchema, */ class Flag implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(false); - executionContext.getExecutionConfig().setFailFast(true); - } + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + executionContext.executionConfig( + executionConfig -> executionConfig.annotationCollectionEnabled(false).failFast(true)); + } @Override public OutputFlag format(Schema jsonSchema, @@ -123,14 +123,14 @@ public OutputFlag format(Schema jsonSchema, */ class Boolean implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(false); - executionContext.getExecutionConfig().setFailFast(true); + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + executionContext.executionConfig( + executionConfig -> executionConfig.annotationCollectionEnabled(false).failFast(true)); } @Override public java.lang.Boolean format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { + ExecutionContext executionContext, ValidationContext schemaContext) { return executionContext.getErrors().isEmpty(); } } @@ -155,13 +155,13 @@ public List(Function errorMapper) { } @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { } @Override public OutputUnit format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { - return ListOutputUnitFormatter.format(executionContext.getErrors(), executionContext, validationContext, + ExecutionContext executionContext, ValidationContext schemaContext) { + return ListOutputUnitFormatter.format(executionContext.getErrors(), executionContext, schemaContext, this.errorMapper); } } @@ -186,14 +186,14 @@ public Hierarchical(Function errorMapper) { } @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { } @Override public OutputUnit format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { + ExecutionContext executionContext, ValidationContext schemaContext) { return HierarchicalOutputUnitFormatter.format(jsonSchema, executionContext.getErrors(), executionContext, - validationContext, this.errorMapper); + schemaContext, this.errorMapper); } } @@ -204,11 +204,11 @@ public OutputUnit format(Schema jsonSchema, */ class Result implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext validationContext) { + public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { } @Override - public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, ValidationContext validationContext) { + public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, ValidationContext schemaContext) { return new ValidationResult(executionContext); } } diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index e57c4e122..f72c594ff 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -40,8 +40,8 @@ /** * Used for creating a schema with validators for validating inputs. This is - * created using {@link SchemaRegistry#withDefaultDialect(Version, Consumer)} - * and should be cached for performance. + * created using SchemaRegistry#withDefaultDialect(Version, Consumer) and should + * be cached for performance. *

* This is the core of json constraint implementation. It parses json constraint * file and generates JsonValidators. The class is thread safe, once it is @@ -117,10 +117,8 @@ private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final Valid if (text == null) { return null; } - final SchemaLocation schemaLocation = SchemaLocation.of(node.textValue()); - - return validationContext.getJsonSchemaFactory().getSchema(schemaLocation, validationContext.getConfig()); + return validationContext.getSchemaRegistry().getSchema(schemaLocation); } public static class JsonNodePathLegacy { private static final JsonNodePath INSTANCE = new JsonNodePath(PathType.LEGACY); @@ -153,14 +151,14 @@ public void validate(ExecutionContext executionContext, JsonNode node) { * @return The path. */ protected JsonNodePath atRoot() { - if (this.validationContext.getConfig().getPathType().equals(PathType.JSON_POINTER)) { + if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_POINTER)) { return JsonNodePathJsonPointer.getInstance(); - } else if (this.validationContext.getConfig().getPathType().equals(PathType.LEGACY)) { + } else if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.LEGACY)) { return JsonNodePathLegacy.getInstance(); - } else if (this.validationContext.getConfig().getPathType().equals(PathType.JSON_PATH)) { + } else if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_PATH)) { return JsonNodePathJsonPath.getInstance(); } - return new JsonNodePath(this.validationContext.getConfig().getPathType()); + return new JsonNodePath(this.validationContext.getSchemaRegistryConfig().getPathType()); } static Schema from(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { @@ -184,18 +182,18 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc resolve = id.substring(0, fragment); } SchemaLocation result = !"".equals(resolve) ? schemaLocation.resolve(resolve) : schemaLocation; - JsonSchemaIdValidator validator = validationContext.getConfig().getSchemaIdValidator(); + JsonSchemaIdValidator validator = validationContext.getSchemaRegistryConfig().getSchemaIdValidator(); if (validator != null) { if (!validator.validate(id, rootSchema, schemaLocation, result, validationContext)) { - SchemaLocation idSchemaLocation = schemaLocation.append(validationContext.getMetaSchema().getIdKeyword()); + SchemaLocation idSchemaLocation = schemaLocation.append(validationContext.getDialect().getIdKeyword()); Error error = Error.builder() .messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) - .arguments(id, validationContext.getMetaSchema().getIdKeyword(), idSchemaLocation) + .arguments(id, validationContext.getDialect().getIdKeyword(), idSchemaLocation) .schemaLocation(idSchemaLocation) .schemaNode(schemaNode) - .messageFormatter(args -> validationContext.getConfig().getMessageSource().getMessage( - ValidatorTypeCode.ID.getValue(), validationContext.getConfig().getLocale(), args)) + .messageFormatter(args -> validationContext.getSchemaRegistryConfig().getMessageSource().getMessage( + ValidatorTypeCode.ID.getValue(), validationContext.getSchemaRegistryConfig().getLocale(), args)) .build(); throw new InvalidSchemaException(error); } @@ -243,7 +241,7 @@ private Schema(ValidationContext validationContext, SchemaLocation schemaLocatio this.id = null; } } - String anchor = this.validationContext.getMetaSchema().readAnchor(this.schemaNode); + String anchor = this.validationContext.getDialect().readAnchor(this.schemaNode); if (anchor != null) { String absoluteIri = this.schemaLocation.getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() @@ -251,7 +249,7 @@ private Schema(ValidationContext validationContext, SchemaLocation schemaLocatio this.validationContext.getSchemaResources() .putIfAbsent(absoluteIri + "#" + anchor, this); } - String dynamicAnchor = this.validationContext.getMetaSchema().readDynamicAnchor(schemaNode); + String dynamicAnchor = this.validationContext.getDialect().readDynamicAnchor(schemaNode); if (dynamicAnchor != null) { String absoluteIri = this.schemaLocation.getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() @@ -324,9 +322,8 @@ protected Schema( * @return the schema */ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluationPath) { - ValidationContext validationContext = new ValidationContext(this.getValidationContext().getMetaSchema(), - this.getValidationContext().getJsonSchemaFactory(), - refEvaluationParentSchema.validationContext.getConfig(), + ValidationContext validationContext = new ValidationContext(this.getValidationContext().getDialect(), + this.getValidationContext().getSchemaRegistry(), refEvaluationParentSchema.getValidationContext().getSchemaReferences(), refEvaluationParentSchema.getValidationContext().getSchemaResources(), refEvaluationParentSchema.getValidationContext().getDynamicAnchors()); @@ -352,43 +349,43 @@ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluati evaluationParentSchema, /* errorMessage */ null); } - public Schema withConfig(SchemaValidatorsConfig config) { - if (this.getValidationContext().getMetaSchema().getKeywords().containsKey("discriminator") - && !config.isDiscriminatorKeywordEnabled()) { - config = SchemaValidatorsConfig.builder(config) - .discriminatorKeywordEnabled(true) - .nullableKeywordEnabled(true) - .build(); - } - if (!this.getValidationContext().getConfig().equals(config)) { - ValidationContext validationContext = new ValidationContext(this.getValidationContext().getMetaSchema(), - this.getValidationContext().getJsonSchemaFactory(), config, - this.getValidationContext().getSchemaReferences(), - this.getValidationContext().getSchemaResources(), - this.getValidationContext().getDynamicAnchors()); - boolean validatorsLoaded = false; - TypeValidator typeValidator = null; - List validators = null; - return new Schema( - /* Below from JsonSchema */ - validators, - validatorsLoaded, - recursiveAnchor, - typeValidator, - id, - /* Below from BaseJsonValidator */ - suppressSubSchemaRetrieval, - schemaNode, - validationContext, - parentSchema, - schemaLocation, - evaluationPath, - evaluationParentSchema, - /* errorMessage */ null); - - } - return this; - } +// public Schema withConfig(SchemaValidatorsConfig config) { +// if (this.getValidationContext().getMetaSchema().getKeywords().containsKey("discriminator") +// && !config.isDiscriminatorKeywordEnabled()) { +// config = SchemaValidatorsConfig.builder(config) +// .discriminatorKeywordEnabled(true) +// .nullableKeywordEnabled(true) +// .build(); +// } +// if (!this.getValidationContext().getSchemaRegistryConfig().equals(config)) { +// ValidationContext validationContext = new ValidationContext(this.getValidationContext().getMetaSchema(), +// this.getValidationContext().getSchemaRegistry(), config, +// this.getValidationContext().getSchemaReferences(), +// this.getValidationContext().getSchemaResources(), +// this.getValidationContext().getDynamicAnchors()); +// boolean validatorsLoaded = false; +// TypeValidator typeValidator = null; +// List validators = null; +// return new Schema( +// /* Below from JsonSchema */ +// validators, +// validatorsLoaded, +// recursiveAnchor, +// typeValidator, +// id, +// /* Below from BaseJsonValidator */ +// suppressSubSchemaRetrieval, +// schemaNode, +// validationContext, +// parentSchema, +// schemaLocation, +// evaluationPath, +// evaluationParentSchema, +// /* errorMessage */ null); +// +// } +// return this; +// } public ValidationContext getValidationContext() { return this.validationContext; @@ -703,7 +700,7 @@ private long activeDialect() { @Override public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, JsonNodePath instanceLocation) { - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { ObjectNode discriminator = (ObjectNode) schemaNode.get("discriminator"); if (null != discriminator && null != executionContext.getCurrentDiscriminatorContext()) { executionContext.getCurrentDiscriminatorContext().registerDiscriminator(schemaLocation, @@ -715,7 +712,7 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN v.validate(executionContext, jsonNode, rootNode, instanceLocation); } - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { ObjectNode discriminator = (ObjectNode) this.schemaNode.get("discriminator"); if (null != discriminator) { final DiscriminatorContext discriminatorContext = executionContext @@ -757,7 +754,7 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param rootNode the root node @@ -774,7 +771,7 @@ public List validate(JsonNode rootNode) { * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param rootNode the root node @@ -791,7 +788,7 @@ public List validate(JsonNode rootNode, ExecutionContextCustomizer execut * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param rootNode the root node @@ -809,7 +806,7 @@ public List validate(JsonNode rootNode, Consumer execut * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -828,7 +825,7 @@ public T validate(JsonNode rootNode, OutputFormat format) { * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -848,7 +845,7 @@ public T validate(JsonNode rootNode, OutputFormat format, ExecutionContex * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -868,7 +865,7 @@ public T validate(JsonNode rootNode, OutputFormat format, Consumer - * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param input the input @@ -887,7 +884,7 @@ public List validate(String input, InputFormat inputFormat) { * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param input the input @@ -906,7 +903,7 @@ public List validate(String input, InputFormat inputFormat, ExecutionCont * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param input the input @@ -925,7 +922,7 @@ public List validate(String input, InputFormat inputFormat, Consumer - * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -945,7 +942,7 @@ public T validate(String input, InputFormat inputFormat, OutputFormat for * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -966,7 +963,7 @@ public T validate(String input, InputFormat inputFormat, OutputFormat for * Note that since Draft 2019-09 by default format generates only annotations * and not assertions. *

- * Use {@link ExecutionConfig#setFormatAssertionsEnabled(Boolean)} to override + * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override * the default. * * @param the result type @@ -1026,68 +1023,12 @@ public T validate(ExecutionContext executionContext, JsonNode node, OutputFo */ private JsonNode deserialize(String input, InputFormat inputFormat) { try { - return this.getValidationContext().getJsonSchemaFactory().readTree(input, inputFormat); + return this.getValidationContext().getSchemaRegistry().readTree(input, inputFormat); } catch (IOException e) { throw new IllegalArgumentException("Invalid input", e); } } - /** - * Deprecated. Initialize the CollectorContext externally and call loadCollectors when done. - *

- * @param executionContext ExecutionContext - * @param node JsonNode - * @return ValidationResult - */ - @Deprecated - public ValidationResult validateAndCollect(ExecutionContext executionContext, JsonNode node) { - return validateAndCollect(executionContext, node, node, atRoot()); - } - - /** - * Deprecated. Initialize the CollectorContext externally and call loadCollectors when done. - *

- * This method both validates and collects the data in a CollectorContext. - * Unlike others this methods cleans and removes everything from collector - * context before returning. - * @param executionContext ExecutionContext - * @param jsonNode JsonNode - * @param rootNode JsonNode - * @param instanceLocation JsonNodePath - * - * @return ValidationResult - */ - @Deprecated - private ValidationResult validateAndCollect(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, JsonNodePath instanceLocation) { - // Validate. - validate(executionContext, jsonNode, rootNode, instanceLocation); - - // Get the config. - SchemaValidatorsConfig config = this.validationContext.getConfig(); - - // When walk is called in series of nested call we don't want to load the collectors every time. Leave to the API to decide when to call collectors. - if (config.doLoadCollectors()) { - // Get the collector context. - CollectorContext collectorContext = executionContext.getCollectorContext(); - - // Load all the data from collectors into the context. - collectorContext.loadCollectors(); - } - // Collect errors and collector context into validation result. - return new ValidationResult(executionContext); - } - - /** - * Deprecated. Initialize the CollectorContext externally and call loadCollectors when done. - * - * @param node JsonNode - * @return ValidationResult - */ - @Deprecated - public ValidationResult validateAndCollect(JsonNode node) { - return validateAndCollect(createExecutionContext(), node, node, atRoot()); - } - /************************ END OF VALIDATE METHODS **********************************/ /*********************** START OF WALK METHODS **********************************/ @@ -1251,6 +1192,30 @@ public ValidationResult walk(JsonNode node, boolean validate) { return walk(createExecutionContext(), node, validate); } + /** + * Walk the JSON node. + * + * @param node the input + * @param validate true to validate the input against the schema + * @param executionCustomizer the customizer + * @return the validation result + */ + public ValidationResult walk(JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer) { + return walk(createExecutionContext(), node, validate, executionCustomizer); + } + + /** + * Walk the JSON node. + * + * @param node the input + * @param validate true to validate the input against the schema + * @param executionCustomizer the customizer + * @return the validation result + */ + public ValidationResult walk(JsonNode node, boolean validate, Consumer executionCustomizer) { + return walk(createExecutionContext(), node, validate, executionCustomizer); + } + /** * Walk the JSON node. * @@ -1263,7 +1228,7 @@ public ValidationResult walk(JsonNode node, boolean validate) { public T walk(JsonNode node, OutputFormat outputFormat, boolean validate) { return walk(createExecutionContext(), node, outputFormat, validate, (ExecutionContextCustomizer) null); } - + /** * Walk the input. * @@ -1333,19 +1298,7 @@ private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode nod executionCustomizer.customize(executionContext, this.validationContext); } // Walk through the schema. - walk(executionContext, node, rootNode, instanceLocation, validate); - - // Get the config. - SchemaValidatorsConfig config = this.validationContext.getConfig(); - // When walk is called in series of nested call we don't want to load the collectors every time. Leave to the API to decide when to call collectors. - /* When doLoadCollectors is removed after the deprecation period the following block should be removed */ - if (config.doLoadCollectors()) { - // Get the collector context. - CollectorContext collectorContext = executionContext.getCollectorContext(); - - // Load all the data from collectors into the context. - collectorContext.loadCollectors(); - } + walk(executionContext, node, rootNode, instanceLocation, validate); return format.format(this, executionContext, this.validationContext); } @@ -1359,14 +1312,14 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root try { // Call all the pre-walk listeners. If at least one of the pre walk listeners // returns SKIP, then skip the walk. - if (this.validationContext.getConfig().getKeywordWalkListenerRunner().runPreWalkListeners(executionContext, + if (executionContext.getWalkConfig().getKeywordWalkListenerRunner().runPreWalkListeners(executionContext, evaluationPathWithKeyword.getName(-1), node, rootNode, instanceLocation, this, validator)) { validator.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } } finally { // Call all the post-walk listeners. - this.validationContext.getConfig().getKeywordWalkListenerRunner().runPostWalkListeners(executionContext, + executionContext.getWalkConfig().getKeywordWalkListenerRunner().runPostWalkListeners(executionContext, evaluationPathWithKeyword.getName(-1), node, rootNode, instanceLocation, this, validator, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size())); @@ -1433,13 +1386,12 @@ public boolean isRecursiveAnchor() { * @return the execution context */ public ExecutionContext createExecutionContext() { - SchemaValidatorsConfig config = validationContext.getConfig(); + SchemaRegistryConfig config = validationContext.getSchemaRegistryConfig(); // Copy execution config defaults from validation config - ExecutionConfig executionConfig = new ExecutionConfig(); - executionConfig.setLocale(config.getLocale()); - executionConfig.setFormatAssertionsEnabled(config.getFormatAssertionsEnabled()); - executionConfig.setFailFast(config.isFailFast()); - + ExecutionConfig executionConfig = ExecutionConfig.builder() + .locale(config.getLocale()) + .formatAssertionsEnabled(config.getFormatAssertionsEnabled()) + .failFast(config.isFailFast()).build(); ExecutionContext executionContext = new ExecutionContext(executionConfig); if(config.getExecutionContextCustomizer() != null) { config.getExecutionContextCustomizer().customize(executionContext, validationContext); diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 731072be2..a1e2c6d2b 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -45,8 +45,7 @@ /** * Registry for loading and registering {@link Schema} instances. *

- * This can be created with {@link #withDefaultDialect(Version)} or - * {@link #withDialect(Dialect)}. + * This can be created with withDefaultDialect(Version) or withDialect(Dialect). *

* The registry should be cached for performance. *

@@ -65,6 +64,7 @@ public static class Builder { private SchemaLoaders.Builder schemaLoadersBuilder = null; private SchemaMappers.Builder schemaMappersBuilder = null; private boolean enableSchemaCache = true; + private SchemaRegistryConfig schemaRegistryConfig = null; /** * Sets the json node reader to read the data. @@ -112,6 +112,11 @@ public Builder schemaMappers(Consumer schemaMappersBuilde return this; } + public Builder schemaRegistryConfig(SchemaRegistryConfig schemaRegistryConfig) { + this.schemaRegistryConfig = schemaRegistryConfig; + return this; + } + public SchemaRegistry build() { return new SchemaRegistry( jsonNodeReader != null ? jsonNodeReader : BasicJsonNodeReader.getInstance(), @@ -119,7 +124,8 @@ public SchemaRegistry build() { schemaLoadersBuilder, schemaMappersBuilder, enableSchemaCache, - dialectRegistry + dialectRegistry, + schemaRegistryConfig ); } } @@ -132,6 +138,7 @@ public SchemaRegistry build() { private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; private final DialectRegistry dialectRegistry; + private final SchemaRegistryConfig schemaRegistryConfig; private static final List DEFAULT_SCHEMA_LOADERS = SchemaLoaders.builder().build(); private static final List DEFAULT_SCHEMA_MAPPERS = SchemaMappers.builder().build(); @@ -142,7 +149,8 @@ private SchemaRegistry( SchemaLoaders.Builder schemaLoadersBuilder, SchemaMappers.Builder schemaMappersBuilder, boolean enableSchemaCache, - DialectRegistry dialectRegistry) { + DialectRegistry dialectRegistry, + SchemaRegistryConfig schemaRegistryConfig) { if (defaultDialectId == null || defaultDialectId.trim().isEmpty()) { throw new IllegalArgumentException("defaultDialectId must not be null or empty"); } @@ -155,6 +163,7 @@ private SchemaRegistry( schemaMappersBuilder != null ? schemaMappersBuilder.build() : DEFAULT_SCHEMA_MAPPERS); this.enableSchemaCache = enableSchemaCache; this.dialectRegistry = dialectRegistry != null ? dialectRegistry : new DefaultDialectRegistry(); + this.schemaRegistryConfig = schemaRegistryConfig != null ? schemaRegistryConfig : SchemaRegistryConfig.getInstance(); } public SchemaLoader getSchemaLoader() { @@ -194,7 +203,7 @@ public static SchemaRegistry withDefaultDialect(Specification.Version specificat * @param specificationVersion the default dialect id corresponding to the * specification version used when the schema does * not specify the $schema keyword - * @param customizer to customize the factory + * @param customizer to customize the registry * @return the factory */ public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion, @@ -207,9 +216,9 @@ public static SchemaRegistry withDefaultDialect(Specification.Version specificat * Creates a new schema registry with a default schema dialect. The schema dialect * will only be used if the input does not specify a $schema. * - * @param dialect the default dialect id used when the schema does not + * @param dialectId the default dialect id used when the schema does not * specify the $schema keyword - * @param customizer to customize the factory + * @param customizer to customize the registry * @return the factory */ public static SchemaRegistry withDefaultDialectId(String dialectId, Consumer customizer) { @@ -229,8 +238,24 @@ public static SchemaRegistry withDefaultDialectId(String dialectId, Consumer + * Schemas that do not specify dialect using $schema will use the dialect. + * + * @param dialect the dialect + * @param customizer to customize the registry + * @return the schema registry + */ + public static SchemaRegistry withDialect(Dialect dialect, Consumer customizer) { SchemaRegistry.Builder builder = builder().defaultDialectId(dialect.getIri()) .dialectRegistry(new BasicDialectRegistry(dialect)); + if (customizer != null) { + customizer.accept(builder); + } return builder.build(); } @@ -262,14 +287,13 @@ public static Builder builder(final SchemaRegistry blueprint) { * * @param schemaUri the schema location * @param schemaNode the schema data node - * @param config the config to use * @return the schema */ - protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schemaNode, final SchemaValidatorsConfig config) { - final ValidationContext validationContext = createValidationContext(schemaNode, config); + protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schemaNode) { + final ValidationContext validationContext = createValidationContext(schemaNode); Schema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), - new JsonNodePath(validationContext.getConfig().getPathType()), schemaNode, null, false); - preload(jsonSchema, config); + new JsonNodePath(validationContext.getSchemaRegistryConfig().getPathType()), schemaNode, null, false); + preload(jsonSchema); return jsonSchema; } @@ -279,8 +303,8 @@ protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schema * @param schema the schema to preload * @param config containing the configuration option */ - private void preload(Schema schema, SchemaValidatorsConfig config) { - if (config.isPreloadJsonSchema()) { + private void preload(Schema schema) { + if (this.getSchemaRegistryConfig().isPreloadJsonSchema()) { try { /* * Attempt to preload and resolve $refs for performance. @@ -320,16 +344,9 @@ private Schema doCreate(ValidationContext validationContext, SchemaLocation sche * @return the validation context to use */ private ValidationContext withDialect(ValidationContext validationContext, JsonNode schemaNode) { - Dialect dialect = getDialect(schemaNode, validationContext.getConfig()); - if (dialect != null && !dialect.getIri().equals(validationContext.getMetaSchema().getIri())) { - SchemaValidatorsConfig config = validationContext.getConfig(); - if (dialect.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { - config = SchemaValidatorsConfig.builder(config) - .discriminatorKeywordEnabled(true) - .nullableKeywordEnabled(true) - .build(); - } - return new ValidationContext(dialect, validationContext.getJsonSchemaFactory(), config, + Dialect dialect = getDialect(schemaNode, validationContext.getSchemaRegistryConfig()); + if (dialect != null && !dialect.getIri().equals(validationContext.getDialect().getIri())) { + return new ValidationContext(dialect, validationContext.getSchemaRegistry(), validationContext.getSchemaReferences(), validationContext.getSchemaResources(), validationContext.getDynamicAnchors()); } @@ -350,45 +367,37 @@ protected SchemaLocation getSchemaLocation(SchemaLocation schemaLocation) { return schemaLocation != null ? schemaLocation : SchemaLocation.DOCUMENT; } - protected ValidationContext createValidationContext(final JsonNode schemaNode, SchemaValidatorsConfig config) { - final Dialect dialect = getDialectOrDefault(schemaNode, config); - SchemaValidatorsConfig configResult = config; - if (dialect.getKeywords().containsKey("discriminator") && !config.isDiscriminatorKeywordEnabled()) { - configResult = SchemaValidatorsConfig.builder(config) - .discriminatorKeywordEnabled(true) - .nullableKeywordEnabled(true) - .build(); - } - return new ValidationContext(dialect, this, configResult); + protected ValidationContext createValidationContext(final JsonNode schemaNode) { + final Dialect dialect = getDialectOrDefault(schemaNode); + return new ValidationContext(dialect, this); } - private Dialect getDialect(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getDialect(final JsonNode schemaNode, SchemaRegistryConfig config) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && iriNode.isTextual()) { - return getDialect(iriNode.textValue(), config); + return getDialect(iriNode.textValue()); } return null; } - private Dialect getDialectOrDefault(final JsonNode schemaNode, SchemaValidatorsConfig config) { + private Dialect getDialectOrDefault(final JsonNode schemaNode) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && !iriNode.isNull() && !iriNode.isTextual()) { throw new JsonSchemaException("Unknown dialect: " + iriNode); } final String iri = iriNode == null || iriNode.isNull() ? defaultDialectId : iriNode.textValue(); - return getDialect(iri, config); + return getDialect(iri); } /** * Gets the dialect that is available to the registry. * * @param dialectId the IRI of the meta-schema - * @param config the schema validators config * @return the meta-schema */ - public Dialect getDialect(String dialectId, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId) { String key = normalizeDialectId(dialectId); - return dialectRegistry.getDialect(key, this, config); + return dialectRegistry.getDialect(key, this); } JsonNode readTree(String content, InputFormat inputFormat) throws IOException { @@ -406,11 +415,10 @@ JsonNode readTree(InputStream content, InputFormat inputFormat) throws IOExcepti * resolving references to the absolute IRI. * * @param schema the schema data as a string - * @param config the config * @return the schema */ - public Schema getSchema(final String schema, final SchemaValidatorsConfig config) { - return getSchema(schema, InputFormat.JSON, config); + public Schema getSchema(final String schema) { + return getSchema(schema, InputFormat.JSON); } /** @@ -421,47 +429,18 @@ public Schema getSchema(final String schema, final SchemaValidatorsConfig config * * @param schema the schema data as a string * @param inputFormat input format - * @param config the config * @return the schema */ - public Schema getSchema(final String schema, InputFormat inputFormat, final SchemaValidatorsConfig config) { + public Schema getSchema(final String schema, InputFormat inputFormat) { try { final JsonNode schemaNode = readTree(schema, inputFormat); - return newSchema(null, schemaNode, config); + return newSchema(null, schemaNode); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); throw new JsonSchemaException(ioe); } } - - /** - * Gets the schema. - *

- * Using this is not recommended as there is potentially no base IRI for - * resolving references to the absolute IRI. - * - * @param schema the schema data as a string - * @return the schema - */ - public Schema getSchema(final String schema) { - return getSchema(schema, createSchemaValidatorsConfig()); - } - - /** - * Gets the schema. - *

- * Using this is not recommended as there is potentially no base IRI for - * resolving references to the absolute IRI. - * - * @param schema the schema data as a string - * @param inputFormat input format - * @return the schema - */ - public Schema getSchema(final String schema, InputFormat inputFormat) { - return getSchema(schema, inputFormat, createSchemaValidatorsConfig()); - } - /** * Gets the schema. *

@@ -469,11 +448,10 @@ public Schema getSchema(final String schema, InputFormat inputFormat) { * resolving references to the absolute IRI. * * @param schemaStream the input stream with the schema data - * @param config the config * @return the schema */ - public Schema getSchema(final InputStream schemaStream, final SchemaValidatorsConfig config) { - return getSchema(schemaStream, InputFormat.JSON, config); + public Schema getSchema(final InputStream schemaStream) { + return getSchema(schemaStream, InputFormat.JSON); } /** @@ -484,42 +462,27 @@ public Schema getSchema(final InputStream schemaStream, final SchemaValidatorsCo * * @param schemaStream the input stream with the schema data * @param inputFormat input format - * @param config the config * @return the schema */ - public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat, final SchemaValidatorsConfig config) { + public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat) { try { final JsonNode schemaNode = readTree(schemaStream, inputFormat); - return newSchema(null, schemaNode, config); + return newSchema(null, schemaNode); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); throw new JsonSchemaException(ioe); } } - /** - * Gets the schema. - *

- * Using this is not recommended as there is potentially no base IRI for - * resolving references to the absolute IRI. - * - * @param schemaStream the input stream with the schema data - * @return the schema - */ - public Schema getSchema(final InputStream schemaStream) { - return getSchema(schemaStream, createSchemaValidatorsConfig()); - } - /** * Gets the schema. * * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. - * @param config the config * @return the schema */ - public Schema getSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { - Schema schema = loadSchema(schemaUri, config); - preload(schema, config); + public Schema getSchema(final SchemaLocation schemaUri) { + Schema schema = loadSchema(schemaUri); + preload(schema); return schema; } @@ -527,10 +490,9 @@ public Schema getSchema(final SchemaLocation schemaUri, final SchemaValidatorsCo * Loads the schema. * * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. - * @param config the config * @return the schema */ - public Schema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsConfig config) { + public Schema loadSchema(final SchemaLocation schemaUri) { if (enableSchemaCache) { // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. @@ -540,29 +502,19 @@ public Schema loadSchema(final SchemaLocation schemaUri, final SchemaValidatorsC synchronized (this) { // acquire lock on shared registry object to prevent deadlock cachedUriSchema = schemaCache.get(schemaUri); if (cachedUriSchema == null) { - cachedUriSchema = getMappedSchema(schemaUri, config); + cachedUriSchema = getMappedSchema(schemaUri); if (cachedUriSchema != null) { schemaCache.put(schemaUri, cachedUriSchema); } } } } - return cachedUriSchema.withConfig(config); + return cachedUriSchema; } - return getMappedSchema(schemaUri, config); - } - - /** - * Creates a schema validators config. - * - * @return the schema validators config - */ - protected SchemaValidatorsConfig createSchemaValidatorsConfig() { - // Remain as constructor until constructor is removed - return new SchemaValidatorsConfig(); + return getMappedSchema(schemaUri); } - protected Schema getMappedSchema(final SchemaLocation schemaUri, SchemaValidatorsConfig config) { + protected Schema getMappedSchema(final SchemaLocation schemaUri) { try (InputStream inputStream = this.schemaLoader.getSchema(schemaUri.getAbsoluteIri()).getInputStream()) { if (inputStream == null) { throw new IOException("Cannot load schema at " + schemaUri); @@ -574,16 +526,16 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri, SchemaValidator schemaNode = readTree(inputStream, InputFormat.JSON); } - final Dialect dialect = getDialectOrDefault(schemaNode, config); - JsonNodePath evaluationPath = new JsonNodePath(config.getPathType()); + final Dialect dialect = getDialectOrDefault(schemaNode); + JsonNodePath evaluationPath = new JsonNodePath(getSchemaRegistryConfig().getPathType()); if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { // Schema without fragment - ValidationContext validationContext = new ValidationContext(dialect, this, config); + ValidationContext validationContext = new ValidationContext(dialect, this); return doCreate(validationContext, schemaUri, evaluationPath, schemaNode, null, true /* retrieved via id, resolving will not change anything */); } else { // Schema with fragment pointing to sub schema - final ValidationContext validationContext = createValidationContext(schemaNode, config); + final ValidationContext validationContext = createValidationContext(schemaNode); SchemaLocation documentLocation = new SchemaLocation(schemaUri.getAbsoluteIri()); Schema document = doCreate(validationContext, documentLocation, evaluationPath, schemaNode, null, false); return document.getRefSchema(schemaUri.getFragment()); @@ -603,19 +555,7 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri, SchemaValidator * @return the schema */ public Schema getSchema(final URI schemaUri) { - return getSchema(SchemaLocation.of(schemaUri.toString()), createSchemaValidatorsConfig()); - } - - /** - * Gets the schema. - * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. - * @param jsonNode the node - * @param config the config - * @return the schema - */ - public Schema getSchema(final URI schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, config); + return getSchema(SchemaLocation.of(schemaUri.toString())); } /** @@ -626,17 +566,7 @@ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode, final Sche * @return the schema */ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { - return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode, createSchemaValidatorsConfig()); - } - - /** - * Gets the schema. - * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. - * @return the schema - */ - public Schema getSchema(final SchemaLocation schemaUri) { - return getSchema(schemaUri, createSchemaValidatorsConfig()); + return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode); } /** @@ -644,55 +574,35 @@ public Schema getSchema(final SchemaLocation schemaUri) { * * @param schemaUri the base absolute IRI * @param jsonNode the node - * @param config the config - * @return the schema - */ - public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newSchema(schemaUri, jsonNode, config); - } - - /** - * Gets the schema. - * - * @param schemaUri the base absolute IRI - * @param jsonNode the node * @return the schema */ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { - return newSchema(schemaUri, jsonNode, createSchemaValidatorsConfig()); + return newSchema(schemaUri, jsonNode); } - + /** * Gets the schema. *

* Using this is not recommended as there is potentially no base IRI for * resolving references to the absolute IRI. *

- * Prefer {@link #getSchema(SchemaLocation, JsonNode, SchemaValidatorsConfig)} + * Prefer {@link #getSchema(SchemaLocation, JsonNode)} * instead to ensure the base IRI if no id is present. * * @param jsonNode the node - * @param config the config * @return the schema */ - public Schema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfig config) { - return newSchema(null, jsonNode, config); + public Schema getSchema(final JsonNode jsonNode) { + return newSchema(null, jsonNode); } /** - * Gets the schema. - *

- * Using this is not recommended as there is potentially no base IRI for - * resolving references to the absolute IRI. - *

- * Prefer {@link #getSchema(SchemaLocation, JsonNode)} instead to ensure the - * base IRI if no id is present. - * - * @param jsonNode the node - * @return the schema + * Gets the schema registry config. + * + * @return the schema registry config */ - public Schema getSchema(final JsonNode jsonNode) { - return newSchema(null, jsonNode, createSchemaValidatorsConfig()); + public SchemaRegistryConfig getSchemaRegistryConfig() { + return this.schemaRegistryConfig; } private boolean isYaml(final SchemaLocation schemaUri) { diff --git a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java new file mode 100644 index 000000000..4e463f6b1 --- /dev/null +++ b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java @@ -0,0 +1,584 @@ +/* + * Copyright (c) 2016 Network New Technologies Inc. + * + * Licensed under the Apache LicenseBuilder Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema; + +import com.networknt.schema.i18n.DefaultMessageSource; +import com.networknt.schema.i18n.MessageSource; +import com.networknt.schema.regex.ECMAScriptRegularExpressionFactory; +import com.networknt.schema.regex.JDKRegularExpressionFactory; +import com.networknt.schema.regex.RegularExpressionFactory; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; + +/** + * Configuration for SchemaRegistry that applies to all the schemas its + * validators that is managed by the SchemaRegistry. + */ +public class SchemaRegistryConfig { + private static class Holder { + private static final SchemaRegistryConfig INSTANCE = SchemaRegistryConfig.builder().build(); + } + + /** + * Gets the default config instance. + * + * @return the config + */ + public static SchemaRegistryConfig getInstance() { + return Holder.INSTANCE; + } + + public static final int DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH = 40; + + /** + * The execution context customizer that runs by default for all schemas. + */ + private final ExecutionContextCustomizer executionContextCustomizer; + + /** + * Controls if schemas loaded from refs will be cached and reused for subsequent runs. + */ + private final boolean cacheRefs; + + /** + * When set to true, "messages" provided in schema are used for forming validation errors + * else default messages are used + */ + private final String errorMessageKeyword; + + /** + * When set to true, validator process is stop immediately when a very first + * validation error is discovered. + */ + private final boolean failFast; + + /** + * Since Draft 2019-09 format assertions are not enabled by default. + */ + private final Boolean formatAssertionsEnabled; + + /** + * When set to true, use Java-specific semantics rather than native JavaScript + * semantics + */ + private final boolean javaSemantics; + + /** + * The Locale to consider when loading validation messages from the default resource bundle. + */ + private final Locale locale; + + /** + * When set to true, can interpret round doubles as integers + */ + private final boolean losslessNarrowing; + + /** + * The message source to use for generating localised messages. + */ + private final MessageSource messageSource; + + /** + * The approach used to generate paths in reported messages, logs and errors. Default is the legacy "JSONPath-like" approach. + */ + private final PathType pathType; + + /** + * Controls if the schema will automatically be preloaded. + */ + private final boolean preloadJsonSchema; + + /** + * Controls the max depth of the evaluation path to preload when preloading refs. + */ + private final int preloadJsonSchemaRefMaxNestingDepth; + + /** + * Used to create {@link com.networknt.schema.regex.RegularExpression}. + */ + private final RegularExpressionFactory regularExpressionFactory; + + /** + * Used to validate the acceptable $id values. + */ + private final JsonSchemaIdValidator schemaIdValidator; + + /** + * Contains a mapping of how strict a keyword's validators should be. + * Defaults to {@literal true}. + *

+ * Each validator has its own understanding of what constitutes strict + * and permissive. + */ + private final Map strictness; + + /** + * when validate type, if TYPE_LOOSE = true, will try to convert string to + * different types to match the type defined in schema. + */ + private boolean typeLoose; + + protected SchemaRegistryConfig(boolean cacheRefs, + String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, + Boolean formatAssertionsEnabled, + boolean javaSemantics, + Locale locale, boolean losslessNarrowing, + MessageSource messageSource, PathType pathType, + boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, + RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, + Map strictness, boolean typeLoose) { + super(); + this.cacheRefs = cacheRefs; + this.errorMessageKeyword = errorMessageKeyword; + this.executionContextCustomizer = executionContextCustomizer; + this.failFast = failFast; + this.formatAssertionsEnabled = formatAssertionsEnabled; + this.javaSemantics = javaSemantics; + this.locale = locale; + this.losslessNarrowing = losslessNarrowing; + this.messageSource = messageSource; + this.pathType = pathType; + this.preloadJsonSchema = preloadJsonSchema; + this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; + this.regularExpressionFactory = regularExpressionFactory; + this.schemaIdValidator = schemaIdValidator; + this.strictness = strictness; + this.typeLoose = typeLoose; + } + + public ExecutionContextCustomizer getExecutionContextCustomizer() { + return this.executionContextCustomizer; + } + + /** + * 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. + * + * @return the format assertions enabled flag + */ + public Boolean getFormatAssertionsEnabled() { + return formatAssertionsEnabled; + } + + /** + * 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 + * {@link com.networknt.schema.ExecutionConfig}. + * + * @return The locale. + */ + public Locale getLocale() { + if (this.locale == null) { + // This should not be cached as it can be changed using Locale#setDefault(Locale) + return Locale.getDefault(); + } + return this.locale; + } + + /** + * Get the message source to use for generating localised messages. + * + * @return the message source + */ + public MessageSource getMessageSource() { + if (this.messageSource == null) { + return DefaultMessageSource.getInstance(); + } + return this.messageSource; + } + + /** + * Get the approach used to generate paths in messages, logs and errors. + * + * @return The path generation approach. + */ + public PathType getPathType() { + return this.pathType; + } + + /** + * Gets the max depth of the evaluation path to preload when preloading refs. + * + * @return the max depth to preload + */ + public int getPreloadJsonSchemaRefMaxNestingDepth() { + return preloadJsonSchemaRefMaxNestingDepth; + } + + /** + * 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. + * + * @return the factory + */ + public RegularExpressionFactory getRegularExpressionFactory() { + return regularExpressionFactory; + } + + /** + * Gets the schema id validator to validate $id. + * + * @return the validator + */ + public JsonSchemaIdValidator getSchemaIdValidator() { + return schemaIdValidator; + } + + /** + * Gets if schemas loaded from refs will be cached and reused for subsequent + * runs. + * + * @return true if schemas loaded from refs should be cached + */ + public boolean isCacheRefs() { + return cacheRefs; + } + + public String getErrorMessageKeyword() { + return this.errorMessageKeyword; + } + + public boolean isFailFast() { + return this.failFast; + } + + public boolean isJavaSemantics() { + return this.javaSemantics; + } + + public boolean isLosslessNarrowing() { + return this.losslessNarrowing; + } + + /** + * Gets if the schema should be preloaded. + * + * @return true if it should be preloaded + */ + public boolean isPreloadJsonSchema() { + return preloadJsonSchema; + } + + /** + * 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. + * + * @param keyword the keyword to adjust (not null) + * @return Whether to perform a strict validation. + */ + public boolean isStrict(String keyword) { + return isStrict(keyword, Boolean.TRUE); + } + + /** + * Determines if the validator should perform strict checking. + * + * @param keyword the keyword + * @param defaultValue the default value + * @return whether to perform a strict validation + */ + public boolean isStrict(String keyword, Boolean defaultValue) { + return this.strictness.getOrDefault(Objects.requireNonNull(keyword, "keyword cannot be null"), defaultValue); + } + + /** + * Returns whether types are interpreted in a loose manner. + *

+ * If set to true, a single value can be interpreted as a size 1 array. Strings + * may also be interpreted as number, integer or boolean. + * + * @return true if type are interpreted in a loose manner + */ + public boolean isTypeLoose() { + return this.typeLoose; + } + + /** + * Creates a builder. + * + * @return the builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Copies values from a configuration to a new builder. + * + * @param config the configuration + * @return the builder + */ + public static Builder builder(SchemaRegistryConfig config) { + Builder builder = new Builder(); + builder.cacheRefs = config.cacheRefs; + builder.errorMessageKeyword = config.errorMessageKeyword; + builder.executionContextCustomizer = config.executionContextCustomizer; + builder.failFast = config.failFast; + builder.formatAssertionsEnabled = config.formatAssertionsEnabled; + builder.javaSemantics = config.javaSemantics; + builder.locale = config.locale; + builder.losslessNarrowing = config.losslessNarrowing; + builder.messageSource = config.messageSource; + builder.pathType = config.pathType; + builder.preloadJsonSchema = config.preloadJsonSchema; + builder.preloadJsonSchemaRefMaxNestingDepth = config.preloadJsonSchemaRefMaxNestingDepth; + builder.regularExpressionFactory = config.regularExpressionFactory; + builder.schemaIdValidator = config.schemaIdValidator; + builder.strictness = config.strictness; + builder.typeLoose = config.typeLoose; + return builder; + } + + /** + * Builder for {@link SchemaRegistryConfig}. + */ + public static class Builder extends BuilderSupport { + @Override + protected Builder self() { + return this; + } + } + + /** + * Builder for {@link SchemaRegistryConfig}. + */ + public static abstract class BuilderSupport { + protected boolean cacheRefs = true; + protected String errorMessageKeyword = null; + protected ExecutionContextCustomizer executionContextCustomizer = null; + protected boolean failFast = false; + protected Boolean formatAssertionsEnabled = null; + protected boolean javaSemantics = false; + protected Locale locale = null; // This must be null to use Locale.getDefault() as the default can be changed + protected boolean losslessNarrowing = false; + protected MessageSource messageSource = null; + protected PathType pathType = PathType.JSON_POINTER; + protected boolean preloadJsonSchema = true; + protected int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH; + protected RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance(); + protected JsonSchemaIdValidator schemaIdValidator = JsonSchemaIdValidator.DEFAULT; + protected Map strictness = new HashMap<>(0); + protected boolean typeLoose = false; + + protected abstract T self(); + + /** + * Sets if schemas loaded from refs will be cached and reused for subsequent runs. + *

+ * Defaults to true. + * + * @param cacheRefs true to cache + * @return the builder + */ + public T cacheRefs(boolean cacheRefs) { + this.cacheRefs = cacheRefs; + return self(); + } + /** + * Sets the error message keyword for setting custom messages in the schema. + *

+ * Defaults to null meaning custom messages are not enabled. + * + * @param errorMessageKeyword to use for custom messages in the schema + * @return the builder + */ + public T errorMessageKeyword(String errorMessageKeyword) { + this.errorMessageKeyword = errorMessageKeyword; + return self(); + } + /** + * Sets the execution context customizer that is run before each run. + * + * @param executionContextCustomizer the customizer + * @return the builder + */ + public T executionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer) { + this.executionContextCustomizer = executionContextCustomizer; + return self(); + } + + /** + * Sets if the validation should immediately return once a validation error has + * occurred. This can improve performance if inputs are invalid but cannot + * return all error messages to the caller. + *

+ * Defaults to false. + * + * @param failFast true to enable + * @return the builder + */ + public T failFast(boolean failFast) { + this.failFast = failFast; + return self(); + } + + /** + * Sets if format assertions are enabled. If format assertions are not enabled + * the format keyword will behave like an annotation and not attempt to validate + * if the inputs are valid. + *

+ * Defaults to not enabling format assertions for Draft 2019-09 and above and + * enabling format assertions for Draft 7 and below. + * + * @param formatAssertionsEnabled true to enable + * @return the builder + */ + public T formatAssertionsEnabled(Boolean formatAssertionsEnabled) { + this.formatAssertionsEnabled = formatAssertionsEnabled; + return self(); + } + + public T javaSemantics(boolean javaSemantics) { + this.javaSemantics = javaSemantics; + return self(); + } + + /** + * Set the locale to consider when generating localized messages. + *

+ * Note that this locale is set on a schema registry basis. To configure the + * schema on a per execution basis use + * {@link com.networknt.schema.ExecutionConfig.Builder#locale(Locale)}. + *

+ * Defaults to use {@link Locale#getDefault()}. + * + * @param locale The locale. + * @return the builder + */ + public T locale(Locale locale) { + this.locale = locale; + return self(); + } + + public T losslessNarrowing(boolean losslessNarrowing) { + this.losslessNarrowing = losslessNarrowing; + return self(); + } + /** + * Sets the message source to use for generating localised messages. + * + * @param messageSource the message source + * @return the builder + */ + public T messageSource(MessageSource messageSource) { + this.messageSource = messageSource; + return self(); + } + /** + * Sets the path type to use when reporting the instance location of errors. + *

+ * Defaults to {@link PathType#JSON_POINTER}. + * + * @param pathType the path type + * @return the path type + */ + public T pathType(PathType pathType) { + this.pathType = pathType; + return self(); + } + /** + * Sets if the schema should be preloaded. + *

+ * Defaults to true. + * + * @param preloadJsonSchema true to preload + * @return the builder + */ + public T preloadJsonSchema(boolean preloadJsonSchema) { + this.preloadJsonSchema = preloadJsonSchema; + return self(); + } + /** + * Sets the max depth of the evaluation path to preload when preloading refs. + *

+ * Defaults to 40. + * + * @param preloadJsonSchemaRefMaxNestingDepth to preload + * @return the builder + */ + public T preloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) { + this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; + return self(); + } + /** + * Sets the regular expression factory. + *

+ * Defaults to the {@link JDKRegularExpressionFactory} + *

+ * The {@link ECMAScriptRegularExpressionFactory} requires the inclusion of + * optional org.jruby.joni:joni or org.graalvm.js:js dependencies. + * + * @see JDKRegularExpressionFactory + * @see ECMAScriptRegularExpressionFactory + * @param regularExpressionFactory the factory + * @return the builder + */ + public T regularExpressionFactory(RegularExpressionFactory regularExpressionFactory) { + this.regularExpressionFactory = regularExpressionFactory; + return self(); + } + /** + * Sets the schema id validator to use. + *

+ * Defaults to {@link JsonSchemaIdValidator#DEFAULT}. + * + * @param schemaIdValidator the builder + * @return the builder + */ + public T schemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { + this.schemaIdValidator = schemaIdValidator; + return self(); + } + public T strict(Map strict) { + this.strictness = strict; + return self(); + } + public T strict(String keyword, boolean strict) { + this.strictness.put(Objects.requireNonNull(keyword, "keyword cannot be null"), strict); + return self(); + } + public T typeLoose(boolean typeLoose) { + this.typeLoose = typeLoose; + return self(); + } + public SchemaRegistryConfig build() { + return new SchemaRegistryConfig(cacheRefs, errorMessageKeyword, + executionContextCustomizer, failFast, formatAssertionsEnabled, + javaSemantics, locale, losslessNarrowing, messageSource, + pathType, preloadJsonSchema, preloadJsonSchemaRefMaxNestingDepth, + regularExpressionFactory, schemaIdValidator, strictness, typeLoose + ); + } + + } +} diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java deleted file mode 100644 index 3046bd514..000000000 --- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java +++ /dev/null @@ -1,1411 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache LicenseBuilder Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema; - -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.i18n.DefaultMessageSource; -import com.networknt.schema.i18n.MessageSource; -import com.networknt.schema.keyword.KeywordValidator; -import com.networknt.schema.regex.ECMAScriptRegularExpressionFactory; -import com.networknt.schema.regex.JDKRegularExpressionFactory; -import com.networknt.schema.regex.RegularExpressionFactory; -import com.networknt.schema.walk.DefaultItemWalkListenerRunner; -import com.networknt.schema.walk.DefaultKeywordWalkListenerRunner; -import com.networknt.schema.walk.DefaultPropertyWalkListenerRunner; -import com.networknt.schema.walk.JsonSchemaWalkListener; -import com.networknt.schema.walk.WalkListenerRunner; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.function.Consumer; - -/** - * Configuration for validators. - */ -public class SchemaValidatorsConfig { - // This is just a constant for listening to all Keywords. - public static final String ALL_KEYWORD_WALK_LISTENER_KEY = "com.networknt.AllKeywordWalkListener"; - - public static final int DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH = 40; - - /** - * 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 ApplyDefaultsStrategy applyDefaultsStrategy = ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; - - /** - * Controls if schemas loaded from refs will be cached and reused for subsequent runs. - */ - private boolean cacheRefs = true; - - /** - * When set to true, "messages" provided in schema are used for forming validation errors - * else default messages are used - */ - private String errorMessageKeyword = "message"; - - private ExecutionContextCustomizer executionContextCustomizer; - - /** - * When set to true, validator process is stop immediately when a very first - * validation error is discovered. - */ - private boolean failFast; - - /** - * Since Draft 2019-09 format assertions are not enabled by default. - */ - private Boolean formatAssertionsEnabled = null; - - /** - * 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 field - *

- * If 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. - */ - private boolean nullableKeywordEnabled = true; - - private final WalkListenerRunner itemWalkListenerRunner; - - private final List itemWalkListeners; - - /** - * When set to true, use Java-specific semantics rather than native JavaScript - * semantics - */ - private boolean javaSemantics; - - private final WalkListenerRunner keywordWalkListenerRunner; - - private final Map> keywordWalkListenersMap; - - /** - * The Locale to consider when loading validation messages from the default resource bundle. - */ - private Locale locale; - - /** - * When set to true, can interpret round doubles as integers - */ - private boolean losslessNarrowing; - - /** - * The message source to use for generating localised messages. - */ - private MessageSource messageSource; - - /** - * When set to true, support for discriminators is enabled for validations of - * oneOf, anyOf and allOf as described on GitHub. - */ - private boolean discriminatorKeywordEnabled = false; - - /** - * The approach used to generate paths in reported messages, logs and errors. Default is the legacy "JSONPath-like" approach. - */ - private PathType pathType = PathType.DEFAULT; - - /** - * Controls if the schema will automatically be preloaded. - */ - private boolean preloadJsonSchema = true; - - /** - * Controls the max depth of the evaluation path to preload when preloading refs. - */ - private int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH; - - private final WalkListenerRunner propertyWalkListenerRunner; - - private final List propertyWalkListeners; - - /** - * When set to true assumes that schema is used to validate incoming data from an API. - */ - private Boolean readOnly = null; - - /** - * Used to create {@link com.networknt.schema.regex.RegularExpression}. - */ - private RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance(); - - /** - * Used to validate the acceptable $id values. - */ - private JsonSchemaIdValidator schemaIdValidator = JsonSchemaIdValidator.DEFAULT; - - /** - * Contains a mapping of how strict a keyword's validators should be. - * Defaults to {@literal true}. - *

- * Each validator has its own understanding of what constitutes strict - * and permissive. - */ - private final Map strictness; - - /** - * when validate type, if TYPE_LOOSE = true, will try to convert string to - * different types to match the type defined in schema. - */ - private boolean typeLoose; - - /** - * When set to true assumes that schema is used to validate outgoing data from an API. - */ - private Boolean writeOnly = null; - - /** - * Constructor to create an instance. - *

- * This is deprecated in favor of using the builder - * {@link SchemaValidatorsConfig#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 - *
- */ - @Deprecated - public SchemaValidatorsConfig() { - this.strictness = new HashMap<>(0); - - this.keywordWalkListenersMap = new HashMap<>(); - this.propertyWalkListeners = new ArrayList<>(); - this.itemWalkListeners = new ArrayList<>(); - - this.itemWalkListenerRunner = new DefaultItemWalkListenerRunner(getArrayItemWalkListeners()); - this.keywordWalkListenerRunner = new DefaultKeywordWalkListenerRunner(getKeywordWalkListenersMap()); - this.propertyWalkListenerRunner = new DefaultPropertyWalkListenerRunner(getPropertyWalkListeners()); - } - - SchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, - String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, - Boolean formatAssertionsEnabled, boolean nullableKeywordEnabled, - List itemWalkListeners, boolean javaSemantics, - Map> keywordWalkListenersMap, Locale locale, boolean losslessNarrowing, - MessageSource messageSource, boolean discriminatorKeywordEnabled, PathType pathType, - boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, - List propertyWalkListeners, Boolean readOnly, - RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, - Map strictness, boolean typeLoose, Boolean writeOnly) { - super(); - this.applyDefaultsStrategy = applyDefaultsStrategy; - this.cacheRefs = cacheRefs; - this.errorMessageKeyword = errorMessageKeyword; - this.executionContextCustomizer = executionContextCustomizer; - this.failFast = failFast; - this.formatAssertionsEnabled = formatAssertionsEnabled; - this.nullableKeywordEnabled = nullableKeywordEnabled; - this.itemWalkListeners = itemWalkListeners; - this.javaSemantics = javaSemantics; - this.keywordWalkListenersMap = keywordWalkListenersMap; - this.locale = locale; - this.losslessNarrowing = losslessNarrowing; - this.messageSource = messageSource; - this.discriminatorKeywordEnabled = discriminatorKeywordEnabled; - this.pathType = pathType; - this.preloadJsonSchema = preloadJsonSchema; - this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; - this.propertyWalkListeners = propertyWalkListeners; - this.readOnly = readOnly; - this.regularExpressionFactory = regularExpressionFactory; - this.schemaIdValidator = schemaIdValidator; - this.strictness = strictness; - this.typeLoose = typeLoose; - this.writeOnly = writeOnly; - - this.itemWalkListenerRunner = new DefaultItemWalkListenerRunner(getArrayItemWalkListeners()); - this.keywordWalkListenerRunner = new DefaultKeywordWalkListenerRunner(getKeywordWalkListenersMap()); - this.propertyWalkListenerRunner = new DefaultPropertyWalkListenerRunner(getPropertyWalkListeners()); - } - - public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener) { - this.itemWalkListeners.add(itemWalkListener); - } - - public void addItemWalkListeners(List itemWalkListeners) { - this.itemWalkListeners.addAll(itemWalkListeners); - } - - public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener) { - if (this.keywordWalkListenersMap.get(ALL_KEYWORD_WALK_LISTENER_KEY) == null) { - List keywordWalkListeners = new ArrayList<>(); - this.keywordWalkListenersMap.put(ALL_KEYWORD_WALK_LISTENER_KEY, keywordWalkListeners); - } - this.keywordWalkListenersMap.get(ALL_KEYWORD_WALK_LISTENER_KEY).add(keywordWalkListener); - } - - public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener) { - if (this.keywordWalkListenersMap.get(keyword) == null) { - List keywordWalkListeners = new ArrayList<>(); - this.keywordWalkListenersMap.put(keyword, keywordWalkListeners); - } - this.keywordWalkListenersMap.get(keyword).add(keywordWalkListener); - } - - public void addKeywordWalkListeners(List keywordWalkListeners) { - if (this.keywordWalkListenersMap.get(ALL_KEYWORD_WALK_LISTENER_KEY) == null) { - List ikeywordWalkListeners = new ArrayList<>(); - this.keywordWalkListenersMap.put(ALL_KEYWORD_WALK_LISTENER_KEY, ikeywordWalkListeners); - } - this.keywordWalkListenersMap.get(ALL_KEYWORD_WALK_LISTENER_KEY).addAll(keywordWalkListeners); - } - - public void addKeywordWalkListeners(String keyword, List keywordWalkListeners) { - if (this.keywordWalkListenersMap.get(keyword) == null) { - List ikeywordWalkListeners = new ArrayList<>(); - this.keywordWalkListenersMap.put(keyword, ikeywordWalkListeners); - } - this.keywordWalkListenersMap.get(keyword).addAll(keywordWalkListeners); - } - - public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener) { - this.propertyWalkListeners.add(propertyWalkListener); - } - - public void addPropertyWalkListeners(List propertyWalkListeners) { - this.propertyWalkListeners.addAll(propertyWalkListeners); - } - - public ApplyDefaultsStrategy getApplyDefaultsStrategy() { - return this.applyDefaultsStrategy; - } - - public List getArrayItemWalkListeners() { - return this.itemWalkListeners; - } - - public ExecutionContextCustomizer getExecutionContextCustomizer() { - return this.executionContextCustomizer; - } - - /** - * 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. - * - * @return the format assertions enabled flag - */ - public Boolean getFormatAssertionsEnabled() { - return formatAssertionsEnabled; - } - - public WalkListenerRunner getItemWalkListenerRunner() { - return this.itemWalkListenerRunner; - } - - WalkListenerRunner getKeywordWalkListenerRunner() { - return this.keywordWalkListenerRunner; - } - - public Map> getKeywordWalkListenersMap() { - return this.keywordWalkListenersMap; - } - - /** - * 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 - * {@link com.networknt.schema.ExecutionConfig}. - * - * @return The locale. - */ - public Locale getLocale() { - if (this.locale == null) { - // This should not be cached as it can be changed using Locale#setDefault(Locale) - return Locale.getDefault(); - } - return this.locale; - } - - /** - * Get the message source to use for generating localised messages. - * - * @return the message source - */ - public MessageSource getMessageSource() { - if (this.messageSource == null) { - return DefaultMessageSource.getInstance(); - } - return this.messageSource; - } - - /** - * Get the approach used to generate paths in messages, logs and errors. - * - * @return The path generation approach. - */ - public PathType getPathType() { - return this.pathType; - } - - /** - * Gets the max depth of the evaluation path to preload when preloading refs. - * - * @return the max depth to preload - */ - public int getPreloadJsonSchemaRefMaxNestingDepth() { - return preloadJsonSchemaRefMaxNestingDepth; - } - - public WalkListenerRunner getPropertyWalkListenerRunner() { - return this.propertyWalkListenerRunner; - } - - public List getPropertyWalkListeners() { - return this.propertyWalkListeners; - } - - /** - * 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. - * - * @return the factory - */ - public RegularExpressionFactory getRegularExpressionFactory() { - return regularExpressionFactory; - } - - /** - * Gets the schema id validator to validate $id. - * - * @return the validator - */ - public JsonSchemaIdValidator getSchemaIdValidator() { - return schemaIdValidator; - } - - /** - * Gets if schemas loaded from refs will be cached and reused for subsequent - * runs. - * - * @return true if schemas loaded from refs should be cached - */ - public boolean isCacheRefs() { - return cacheRefs; - } - - @Deprecated - public boolean isCustomMessageSupported() { - return this.errorMessageKeyword != null; - } - - public String getErrorMessageKeyword() { - return this.errorMessageKeyword; - } - - /** - * 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. - * - * @return true if ECMA-262 compliant - */ - public boolean isEcma262Validator() { - return !(this.regularExpressionFactory instanceof JDKRegularExpressionFactory); - } - - public boolean isFailFast() { - return this.failFast; - } - - /** - * Deprecated use {{@link #isNullableKeywordEnabled()} instead. - * - * @return true if the nullable keyword is enabled - */ - @Deprecated - public boolean isHandleNullableField() { - return isNullableKeywordEnabled(); - } - - /** - * Gets if the nullable keyword is enabled. - * - * @return true if the nullable keyword is enabled - */ - public boolean isNullableKeywordEnabled() { - return this.nullableKeywordEnabled; - } - - public boolean isJavaSemantics() { - return this.javaSemantics; - } - - public boolean isLosslessNarrowing() { - return this.losslessNarrowing; - } - - /** - * Indicates whether OpenAPI 3 style discriminators should be supported - *

- * Deprecated use {{@link #isDiscriminatorKeywordEnabled()} instead. - * - * @return true in case discriminators are enabled - * @since 1.0.51 - */ - @Deprecated - public boolean isOpenAPI3StyleDiscriminators() { - return isDiscriminatorKeywordEnabled(); - } - - /** - * Gets if the discriminator keyword is enabled. - * - * @return true if the discriminator keyword is enabled - */ - public boolean isDiscriminatorKeywordEnabled() { - return this.discriminatorKeywordEnabled; - } - - /** - * Gets if the schema should be preloaded. - * - * @return true if it should be preloaded - */ - public boolean isPreloadJsonSchema() { - return preloadJsonSchema; - } - - public boolean isReadOnly() { - return null != this.readOnly && this.readOnly; - } - - public Boolean getReadOnly() { - return this.readOnly; - } - - /** - * 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. - * - * @param keyword the keyword to adjust (not null) - * @return Whether to perform a strict validation. - */ - public boolean isStrict(String keyword) { - return isStrict(keyword, Boolean.TRUE); - } - - /** - * Determines if the validator should perform strict checking. - * - * @param keyword the keyword - * @param defaultValue the default value - * @return whether to perform a strict validation - */ - public boolean isStrict(String keyword, Boolean defaultValue) { - return this.strictness.getOrDefault(Objects.requireNonNull(keyword, "keyword cannot be null"), defaultValue); - } - - /** - * - * @return true if type loose is used. - */ - public boolean isTypeLoose() { - return this.typeLoose; - } - - public boolean isWriteOnly() { - return null != this.writeOnly && this.writeOnly; - } - - public Boolean getWriteOnly() { - return this.writeOnly; - } - - public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) { - this.applyDefaultsStrategy = applyDefaultsStrategy != null ? applyDefaultsStrategy - : ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; - } - - /** - * 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. - * - * @param cacheRefs true to cache - */ - public void setCacheRefs(boolean cacheRefs) { - this.cacheRefs = cacheRefs; - } - - /** - * Sets whether custom error messages in the schema are used. - *

- * This is deprecated in favor of setting the error message keyword to use. - * - * @param customMessageSupported true to use message as the error message keyword - */ - @Deprecated - public void setCustomMessageSupported(boolean customMessageSupported) { - this.errorMessageKeyword = customMessageSupported ? "message" : null; - } - - /** - * 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. - * - * @param ecma262Validator true if ECMA-262 compliant - */ - public void setEcma262Validator(boolean ecma262Validator) { - this.regularExpressionFactory = ecma262Validator ? ECMAScriptRegularExpressionFactory.getInstance() - : JDKRegularExpressionFactory.getInstance(); - } - - public void setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer) { - this.executionContextCustomizer = executionContextCustomizer; - } - - /** - * When enabled, - * {@link KeywordValidator#validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)} - * doesn't return any {@link java.util.Set}<{@link Error}>, - * instead a {@link JsonSchemaException} is thrown as soon as a validation - * errors is discovered. - * - * @param failFast boolean - */ - public void setFailFast(final boolean failFast) { - this.failFast = failFast; - } - - /** - * 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). - * - * @param formatAssertionsEnabled the format assertions enabled flag - */ - @Deprecated - public void setFormatAssertionsEnabled(Boolean formatAssertionsEnabled) { - this.formatAssertionsEnabled = formatAssertionsEnabled; - } - - public void setHandleNullableField(boolean handleNullableField) { - this.nullableKeywordEnabled = handleNullableField; - } - - public void setJavaSemantics(boolean javaSemantics) { - this.javaSemantics = javaSemantics; - } - - /** - * 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 - * {@link com.networknt.schema.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). - * - * @param locale The locale. - */ - @Deprecated - public void setLocale(Locale locale) { - this.locale = locale; - } - - public void setLosslessNarrowing(boolean losslessNarrowing) { - this.losslessNarrowing = losslessNarrowing; - } - - /** - * Set the message source to use for generating localised messages. - * - * @param messageSource the message source - */ - public void setMessageSource(MessageSource messageSource) { - this.messageSource = messageSource; - } - - /** - * 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. 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. 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 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 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.
  • - *
  • 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
  • - *
- * - * @param openAPI3StyleDiscriminators whether discriminators should be used. - * Defaults to false - * @since 1.0.51 - */ - public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators) { - this.discriminatorKeywordEnabled = openAPI3StyleDiscriminators; - } - - /** - * Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY). - * - * @param pathType The path generation approach. - */ - public void setPathType(PathType pathType) { - this.pathType = pathType; - } - - /** - * Sets if the schema should be preloaded. - * - * @param preloadJsonSchema true to preload - */ - public void setPreloadJsonSchema(boolean preloadJsonSchema) { - this.preloadJsonSchema = preloadJsonSchema; - } - - /** - * Sets the max depth of the evaluation path to preload when preloading refs. - * - * @param preloadJsonSchemaRefMaxNestingDepth the max depth to preload - */ - public void setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) { - this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - /** - * 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. - * - * @see JDKRegularExpressionFactory - * @see ECMAScriptRegularExpressionFactory - * @param regularExpressionFactory the factory - */ - public void setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory) { - this.regularExpressionFactory = regularExpressionFactory; - } - - /** - * Sets the schema id validator to validate $id. - * - * @param schemaIdValidator the validator - */ - public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { - this.schemaIdValidator = schemaIdValidator; - } - - /** - * Alters the strictness of validations for a specific keyword. When set to - * {@literal true}, instructs the keyword's validators to perform strict - * validation. Otherwise, a validator may perform a more permissive check. - * - * @param keyword The keyword to adjust (not null) - * @param strict Whether to perform strict validations - */ - public void setStrict(String keyword, boolean strict) { - this.strictness.put(Objects.requireNonNull(keyword, "keyword cannot be null"), strict); - } - - public void setTypeLoose(boolean typeLoose) { - this.typeLoose = typeLoose; - } - - public void setWriteOnly(boolean writeOnly) { - this.writeOnly = writeOnly; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(SchemaValidatorsConfig config) { - Builder builder = new Builder(); - builder.applyDefaultsStrategy = config.applyDefaultsStrategy; - builder.cacheRefs = config.cacheRefs; - builder.errorMessageKeyword = config.errorMessageKeyword; - builder.executionContextCustomizer = config.executionContextCustomizer; - builder.failFast = config.failFast; - builder.formatAssertionsEnabled = config.formatAssertionsEnabled; - builder.nullableKeywordEnabled = config.nullableKeywordEnabled; - builder.itemWalkListeners = config.itemWalkListeners; - builder.javaSemantics = config.javaSemantics; - builder.keywordWalkListeners = config.keywordWalkListenersMap; - builder.locale = config.locale; - builder.losslessNarrowing = config.losslessNarrowing; - builder.messageSource = config.messageSource; - builder.discriminatorKeywordEnabled = config.discriminatorKeywordEnabled; - builder.pathType = config.pathType; - builder.preloadJsonSchema = config.preloadJsonSchema; - builder.preloadJsonSchemaRefMaxNestingDepth = config.preloadJsonSchemaRefMaxNestingDepth; - builder.propertyWalkListeners = config.propertyWalkListeners; - builder.readOnly = config.readOnly; - builder.regularExpressionFactory = config.regularExpressionFactory; - builder.schemaIdValidator = config.schemaIdValidator; - builder.strictness = config.strictness; - builder.typeLoose = config.typeLoose; - builder.writeOnly = config.writeOnly; - return builder; - } - - /** - * Builder for {@link SchemaValidatorsConfig}. - */ - public static class Builder { - private ApplyDefaultsStrategy applyDefaultsStrategy = ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; - private boolean cacheRefs = true; - private String errorMessageKeyword = null; - private ExecutionContextCustomizer executionContextCustomizer = null; - private boolean failFast = false; - private Boolean formatAssertionsEnabled = null; - private boolean nullableKeywordEnabled = false; - private List itemWalkListeners = new ArrayList<>(); - private boolean javaSemantics = false; - private Map> keywordWalkListeners = new HashMap<>(); - private Locale locale = null; // This must be null to use Locale.getDefault() as the default can be changed - private boolean losslessNarrowing = false; - private MessageSource messageSource = null; - private boolean discriminatorKeywordEnabled = false; - private PathType pathType = PathType.JSON_POINTER; - private boolean preloadJsonSchema = true; - private int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH; - private List propertyWalkListeners = new ArrayList<>(); - private Boolean readOnly = null; - private RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance(); - private JsonSchemaIdValidator schemaIdValidator = JsonSchemaIdValidator.DEFAULT; - private Map strictness = new HashMap<>(0); - private boolean typeLoose = false; - private Boolean writeOnly = null; - - /** - * Sets the strategy the walker uses to sets nodes to the default value. - *

- * Defaults to {@link ApplyDefaultsStrategy#EMPTY_APPLY_DEFAULTS_STRATEGY}. - * - * @param applyDefaultsStrategy the strategy - * @return the builder - */ - public Builder applyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) { - this.applyDefaultsStrategy = applyDefaultsStrategy != null ? applyDefaultsStrategy - : ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; - return this; - } - /** - * Sets if schemas loaded from refs will be cached and reused for subsequent runs. - *

- * Defaults to true. - * - * @param cacheRefs true to cache - * @return the builder - */ - public Builder cacheRefs(boolean cacheRefs) { - this.cacheRefs = cacheRefs; - return this; - } - /** - * Sets the error message keyword for setting custom messages in the schema. - *

- * Defaults to null meaning custom messages are not enabled. - * - * @param errorMessageKeyword to use for custom messages in the schema - * @return the builder - */ - public Builder errorMessageKeyword(String errorMessageKeyword) { - this.errorMessageKeyword = errorMessageKeyword; - return this; - } - /** - * Sets the execution context customizer that is run before each run. - * - * @param executionContextCustomizer the customizer - * @return the builder - */ - public Builder executionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer) { - this.executionContextCustomizer = executionContextCustomizer; - return this; - } - - /** - * Sets if the validation should immediately return once a validation error has - * occurred. This can improve performance if inputs are invalid but cannot - * return all error messages to the caller. - *

- * Defaults to false. - * - * @param failFast true to enable - * @return the builder - */ - public Builder failFast(boolean failFast) { - this.failFast = failFast; - return this; - } - - /** - * Sets if format assertions are enabled. If format assertions are not enabled - * the format keyword will behave like an annotation and not attempt to validate - * if the inputs are valid. - *

- * Defaults to not enabling format assertions for Draft 2019-09 and above and - * enabling format assertions for Draft 7 and below. - * - * @param formatAssertionsEnabled true to enable - * @return the builder - */ - public Builder formatAssertionsEnabled(Boolean formatAssertionsEnabled) { - this.formatAssertionsEnabled = formatAssertionsEnabled; - return this; - } - - /** - * Sets if the nullable keyword is enabled. - * - * @param nullableKeywordEnabled true to enable - * @return the builder - */ - public Builder nullableKeywordEnabled(boolean nullableKeywordEnabled) { - this.nullableKeywordEnabled = nullableKeywordEnabled; - return this; - } - public Builder itemWalkListeners(List itemWalkListeners) { - this.itemWalkListeners = itemWalkListeners; - return this; - } - public Builder javaSemantics(boolean javaSemantics) { - this.javaSemantics = javaSemantics; - return this; - } - public Builder keywordWalkListeners(Map> keywordWalkListeners) { - this.keywordWalkListeners = keywordWalkListeners; - return this; - } - /** - * 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 - * {@link com.networknt.schema.ExecutionConfig#setLocale(Locale)}. - *

- * Defaults to use {@link Locale#getDefault()}. - * - * @param locale The locale. - * @return the builder - */ - public Builder locale(Locale locale) { - this.locale = locale; - return this; - } - public Builder losslessNarrowing(boolean losslessNarrowing) { - this.losslessNarrowing = losslessNarrowing; - return this; - } - /** - * Sets the message source to use for generating localised messages. - * - * @param messageSource the message source - * @return the builder - */ - public Builder messageSource(MessageSource messageSource) { - this.messageSource = messageSource; - return this; - } - /** - * Sets if the discriminator keyword is enabled. - *

- * Defaults to false. - * - * @param discriminatorKeywordEnabled true to enable - * @return the builder - */ - public Builder discriminatorKeywordEnabled(boolean discriminatorKeywordEnabled) { - this.discriminatorKeywordEnabled = discriminatorKeywordEnabled; - return this; - } - /** - * Sets the path type to use when reporting the instance location of errors. - *

- * Defaults to {@link PathType#JSON_POINTER}. - * - * @param pathType the path type - * @return the path type - */ - public Builder pathType(PathType pathType) { - this.pathType = pathType; - return this; - } - /** - * Sets if the schema should be preloaded. - *

- * Defaults to true. - * - * @param preloadJsonSchema true to preload - * @return the builder - */ - public Builder preloadJsonSchema(boolean preloadJsonSchema) { - this.preloadJsonSchema = preloadJsonSchema; - return this; - } - /** - * Sets the max depth of the evaluation path to preload when preloading refs. - *

- * Defaults to 40. - * - * @param preloadJsonSchemaRefMaxNestingDepth to preload - * @return the builder - */ - public Builder preloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) { - this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; - return this; - } - public Builder propertyWalkListeners(List propertyWalkListeners) { - this.propertyWalkListeners = propertyWalkListeners; - return this; - } - public Builder readOnly(Boolean readOnly) { - this.readOnly = readOnly; - return this; - } - /** - * Sets the regular expression factory. - *

- * Defaults to the {@link JDKRegularExpressionFactory} - *

- * The {@link ECMAScriptRegularExpressionFactory} requires the inclusion of - * optional org.jruby.joni:joni or org.graalvm.js:js dependencies. - * - * @see JDKRegularExpressionFactory - * @see ECMAScriptRegularExpressionFactory - * @param regularExpressionFactory the factory - * @return the builder - */ - public Builder regularExpressionFactory(RegularExpressionFactory regularExpressionFactory) { - this.regularExpressionFactory = regularExpressionFactory; - return this; - } - /** - * Sets the schema id validator to use. - *

- * Defaults to {@link JsonSchemaIdValidator#DEFAULT}. - * - * @param schemaIdValidator the builder - * @return the builder - */ - public Builder schemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { - this.schemaIdValidator = schemaIdValidator; - return this; - } - public Builder strict(Map strict) { - this.strictness = strict; - return this; - } - public Builder typeLoose(boolean typeLoose) { - this.typeLoose = typeLoose; - return this; - } - public Builder writeOnly(Boolean writeOnly) { - this.writeOnly = writeOnly; - return this; - } - public SchemaValidatorsConfig build() { - return new ImmutableSchemaValidatorsConfig(applyDefaultsStrategy, cacheRefs, errorMessageKeyword, - executionContextCustomizer, failFast, formatAssertionsEnabled, nullableKeywordEnabled, - itemWalkListeners, javaSemantics, keywordWalkListeners, locale, losslessNarrowing, messageSource, - discriminatorKeywordEnabled, pathType, preloadJsonSchema, preloadJsonSchemaRefMaxNestingDepth, - propertyWalkListeners, readOnly, regularExpressionFactory, schemaIdValidator, strictness, typeLoose, - writeOnly); - } - public Builder strict(String keyword, boolean strict) { - this.strictness.put(Objects.requireNonNull(keyword, "keyword cannot be null"), strict); - return this; - } - public Builder keywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener) { - this.keywordWalkListeners.computeIfAbsent(keyword, key -> new ArrayList<>()).add(keywordWalkListener); - return this; - } - public Builder keywordWalkListener(JsonSchemaWalkListener keywordWalkListener) { - return keywordWalkListener(ALL_KEYWORD_WALK_LISTENER_KEY, keywordWalkListener); - } - public Builder keywordWalkListeners(Consumer>> keywordWalkListeners) { - keywordWalkListeners.accept(this.keywordWalkListeners); - return this; - } - public Builder propertyWalkListener(JsonSchemaWalkListener propertyWalkListener) { - this.propertyWalkListeners.add(propertyWalkListener); - return this; - } - public Builder propertyWalkListeners(Consumer> propertyWalkListeners) { - propertyWalkListeners.accept(this.propertyWalkListeners); - return this; - } - public Builder itemWalkListener(JsonSchemaWalkListener itemWalkListener) { - this.itemWalkListeners.add(itemWalkListener); - return this; - } - public Builder itemWalkListeners(Consumer> itemWalkListeners) { - itemWalkListeners.accept(this.itemWalkListeners); - return this; - } - } - - /** - * {@link SchemaValidatorsConfig} that throws on mutators or deprecated methods. - *

- * The {@link SchemaValidatorsConfig} will be made immutable in a future breaking release. - */ - public static class ImmutableSchemaValidatorsConfig extends SchemaValidatorsConfig { - public ImmutableSchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, - String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, - Boolean formatAssertionsEnabled, boolean handleNullableField, - List itemWalkListeners, boolean javaSemantics, - Map> keywordWalkListenersMap, Locale locale, - boolean losslessNarrowing, MessageSource messageSource, boolean openAPI3StyleDiscriminators, - PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, - List propertyWalkListeners, Boolean readOnly, - RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, - Map strictness, boolean typeLoose, Boolean writeOnly) { - super(applyDefaultsStrategy, cacheRefs, errorMessageKeyword, executionContextCustomizer, failFast, - formatAssertionsEnabled, handleNullableField, itemWalkListeners, javaSemantics, keywordWalkListenersMap, locale, - losslessNarrowing, messageSource, openAPI3StyleDiscriminators, pathType, preloadJsonSchema, - preloadJsonSchemaRefMaxNestingDepth, propertyWalkListeners, readOnly, regularExpressionFactory, - schemaIdValidator, strictness, typeLoose, writeOnly); - } - - @Override - public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener) { - throw new UnsupportedOperationException(); - } - - @Override - public void addItemWalkListeners(List itemWalkListeners) { - throw new UnsupportedOperationException(); - } - - @Override - public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener) { - throw new UnsupportedOperationException(); - } - - @Override - public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener) { - throw new UnsupportedOperationException(); - } - - @Override - public void addKeywordWalkListeners(List keywordWalkListeners) { - throw new UnsupportedOperationException(); - } - - @Override - public void addKeywordWalkListeners(String keyword, List keywordWalkListeners) { - throw new UnsupportedOperationException(); - } - - @Override - public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener) { - throw new UnsupportedOperationException(); - } - - @Override - public void addPropertyWalkListeners(List propertyWalkListeners) { - throw new UnsupportedOperationException(); - } - - @Override - public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public void setCacheRefs(boolean cacheRefs) { - throw new UnsupportedOperationException(); - } - - @Override - public void setCustomMessageSupported(boolean customMessageSupported) { - throw new UnsupportedOperationException(); - } - - @Override - public void setEcma262Validator(boolean ecma262Validator) { - throw new UnsupportedOperationException(); - } - - @Override - public void setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer) { - throw new UnsupportedOperationException(); - } - - @Override - public void setFailFast(boolean failFast) { - throw new UnsupportedOperationException(); - } - - @Override - public void setFormatAssertionsEnabled(Boolean formatAssertionsEnabled) { - throw new UnsupportedOperationException(); - } - - @Override - public void setHandleNullableField(boolean handleNullableField) { - throw new UnsupportedOperationException(); - } - - @Override - public void setJavaSemantics(boolean javaSemantics) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLocale(Locale locale) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLosslessNarrowing(boolean losslessNarrowing) { - throw new UnsupportedOperationException(); - } - - @Override - public void setMessageSource(MessageSource messageSource) { - throw new UnsupportedOperationException(); - } - - @Override - public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators) { - throw new UnsupportedOperationException(); - } - - @Override - public void setPathType(PathType pathType) { - throw new UnsupportedOperationException(); - } - - @Override - public void setPreloadJsonSchema(boolean preloadJsonSchema) { - throw new UnsupportedOperationException(); - } - - @Override - public void setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) { - throw new UnsupportedOperationException(); - } - - @Override - public void setReadOnly(boolean readOnly) { - throw new UnsupportedOperationException(); - } - - @Override - public void setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { - throw new UnsupportedOperationException(); - } - - @Override - public void setStrict(String keyword, boolean strict) { - throw new UnsupportedOperationException(); - } - - @Override - public void setTypeLoose(boolean typeLoose) { - throw new UnsupportedOperationException(); - } - - @Override - public void setWriteOnly(boolean writeOnly) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLoadCollectors(boolean loadCollectors) { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig disableUnevaluatedAnalysis() { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig disableUnevaluatedItems() { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig disableUnevaluatedProperties() { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig enableUnevaluatedAnalysis() { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig enableUnevaluatedItems() { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaValidatorsConfig enableUnevaluatedProperties() { - throw new UnsupportedOperationException(); - } - } - - /* Below are deprecated for removal */ - @Deprecated - private boolean loadCollectors = true; - - /** - * Use {@code isReadOnly} or {@code isWriteOnly} - * @return true if schema is used to write data - */ - @Deprecated - public boolean isWriteMode() { - return null == this.writeOnly || this.writeOnly; - } - - /** - * Sets if collectors are to be loaded. - *

- * This is deprecated in favor of the caller calling {@link CollectorContext#loadCollectors()} manually. - * - * @param loadCollectors to load collectors - */ - @Deprecated - public void setLoadCollectors(boolean loadCollectors) { - this.loadCollectors = loadCollectors; - } - - /** - * Gets if collectors are to be loaded. - * - * @return if collectors are to be loader - */ - @Deprecated - public boolean doLoadCollectors() { - return this.loadCollectors; - } - - @Deprecated - public SchemaValidatorsConfig disableUnevaluatedAnalysis() { - return this; - } - - @Deprecated - public SchemaValidatorsConfig disableUnevaluatedItems() { - return this; - } - - @Deprecated - public SchemaValidatorsConfig disableUnevaluatedProperties() { - return this; - } - - @Deprecated - public SchemaValidatorsConfig enableUnevaluatedAnalysis() { - return this; - } - - @Deprecated - public SchemaValidatorsConfig enableUnevaluatedItems() { - return this; - } - - @Deprecated - public SchemaValidatorsConfig enableUnevaluatedProperties() { - return this; - } - - @Deprecated - public boolean isUnevaluatedItemsAnalysisDisabled() { - return false; - } - - @Deprecated - public boolean isUnevaluatedItemsAnalysisEnabled() { - return !isUnevaluatedItemsAnalysisDisabled(); - } - - @Deprecated - public boolean isUnevaluatedPropertiesAnalysisDisabled() { - return false; - } - - @Deprecated - public boolean isUnevaluatedPropertiesAnalysisEnabled() { - return !isUnevaluatedPropertiesAnalysisDisabled(); - } -} diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java index fc7f5fbf3..05f68a444 100644 --- a/src/main/java/com/networknt/schema/Specification.java +++ b/src/main/java/com/networknt/schema/Specification.java @@ -127,7 +127,7 @@ public static Dialect getDialect(Specification.Version version) { /** * Gets the dialect given the dialect id. * - * @param version the schema specification version + * @param dialectId the schema specification version * @return the dialect or null if not found */ public static Dialect getDialect(String dialectId) { diff --git a/src/main/java/com/networknt/schema/TypeFactory.java b/src/main/java/com/networknt/schema/TypeFactory.java index cb986053d..2401e89bf 100644 --- a/src/main/java/com/networknt/schema/TypeFactory.java +++ b/src/main/java/com/networknt/schema/TypeFactory.java @@ -74,7 +74,7 @@ public static JsonType getSchemaNodeType(JsonNode node) { * @param config the config * @return the json type */ - public static JsonType getValueNodeType(JsonNode node, SchemaValidatorsConfig config) { + public static JsonType getValueNodeType(JsonNode node, SchemaRegistryConfig config) { if (node == null) { // This returns JsonType.UNKNOWN to be consistent with the behavior when // JsonNodeType.MISSING diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index f48ba8b05..484b695af 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -27,37 +27,97 @@ public class ValidationContext { private final Dialect dialect; - private final SchemaRegistry jsonSchemaFactory; - private final SchemaValidatorsConfig config; + private final SchemaRegistry schemaRegistry; private final ConcurrentMap schemaReferences; private final ConcurrentMap schemaResources; private final ConcurrentMap dynamicAnchors; + + /** + * When set to true, support for discriminators is enabled for validations of + * oneOf, anyOf and allOf as described on GitHub. + * + * 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. 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. 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 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 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.
  • + *
  • 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
  • + *
+ * + * @param openAPI3StyleDiscriminators whether discriminators should be used. + * Defaults to false + * @since 1.0.51 + */ + private final boolean discriminatorKeywordEnabled; + + /** + * 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 field + *

+ * If 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. + */ + private final boolean nullableKeywordEnabled; public ValidationContext(Dialect dialect, - SchemaRegistry jsonSchemaFactory, SchemaValidatorsConfig config) { - this(dialect, jsonSchemaFactory, config, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + SchemaRegistry schemaRegistry) { + this(dialect, schemaRegistry, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } - - public ValidationContext(Dialect dialect, SchemaRegistry jsonSchemaFactory, - SchemaValidatorsConfig config, ConcurrentMap schemaReferences, + + public ValidationContext(Dialect dialect, SchemaRegistry schemaRegistry, + ConcurrentMap schemaReferences, ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { if (dialect == null) { - throw new IllegalArgumentException("JsonMetaSchema must not be null"); + throw new IllegalArgumentException("Dialect must not be null"); } - if (jsonSchemaFactory == null) { - throw new IllegalArgumentException("JsonSchemaFactory must not be null"); + if (schemaRegistry == null) { + throw new IllegalArgumentException("SchemaRegistry must not be null"); } this.dialect = dialect; - this.jsonSchemaFactory = jsonSchemaFactory; - // The deprecated SchemaValidatorsConfig constructor needs to remain until removed - this.config = config == null ? new SchemaValidatorsConfig() : config; + this.schemaRegistry = schemaRegistry; this.schemaReferences = schemaReferences; this.schemaResources = schemaResources; this.dynamicAnchors = dynamicAnchors; + + if (dialect.getKeywords().containsKey("discriminator")) { + this.discriminatorKeywordEnabled = true; + } else { + this.discriminatorKeywordEnabled = false; + } + + if (dialect.getKeywords().containsKey("nullable")) { + this.nullableKeywordEnabled = true; + } else { + this.nullableKeywordEnabled = false; + } } public Schema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { - return getJsonSchemaFactory().create(this, schemaLocation, evaluationPath, schemaNode, parentSchema); + return getSchemaRegistry().create(this, schemaLocation, evaluationPath, schemaNode, parentSchema); } public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, @@ -69,12 +129,12 @@ public String resolveSchemaId(JsonNode schemaNode) { return this.dialect.readId(schemaNode); } - public SchemaRegistry getJsonSchemaFactory() { - return this.jsonSchemaFactory; + public SchemaRegistry getSchemaRegistry() { + return this.schemaRegistry; } - public SchemaValidatorsConfig getConfig() { - return this.config; + public SchemaRegistryConfig getSchemaRegistryConfig() { + return this.schemaRegistry.getSchemaRegistryConfig(); } /** @@ -104,11 +164,19 @@ public ConcurrentMap getDynamicAnchors() { return this.dynamicAnchors; } - public Dialect getMetaSchema() { + public Dialect getDialect() { return this.dialect; } public Optional activeDialect() { return Optional.of(this.dialect.getSpecification()); } + + public boolean isDiscriminatorKeywordEnabled() { + return discriminatorKeywordEnabled; + } + + public boolean isNullableKeywordEnabled() { + return nullableKeywordEnabled; + } } diff --git a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java index 8199c8028..c9bfe5964 100644 --- a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java @@ -20,7 +20,6 @@ import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; public class BasicDialectRegistry implements DialectRegistry { private Function dialects; @@ -34,7 +33,7 @@ public BasicDialectRegistry(Dialect dialect) { } @Override - public Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry) { Dialect dialect = dialects.apply(dialectId); if (dialect != null) { return dialect; diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index 355169c1f..4194120ad 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -26,7 +26,6 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification; import com.networknt.schema.Specification.Version; @@ -37,18 +36,18 @@ public class DefaultDialectRegistry implements DialectRegistry { private final ConcurrentMap dialects = new ConcurrentHashMap<>(); @Override - public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { + public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory) { // Is it a well-known dialect? Dialect dialect = Specification.getDialect(dialectId); if (dialect != null) { return dialect; } - return dialects.computeIfAbsent(dialectId, id -> loadDialect(id, schemaFactory, config)); + return dialects.computeIfAbsent(dialectId, id -> loadDialect(id, schemaFactory)); } - protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory, SchemaValidatorsConfig config) { + protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory) { try { - Dialect result = loadDialectBuilder(iri, schemaFactory, config).build(); + Dialect result = loadDialectBuilder(iri, schemaFactory).build(); return result; } catch (InvalidSchemaException e) { throw e; @@ -58,11 +57,10 @@ protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory, SchemaVa } } - protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory, - SchemaValidatorsConfig config) { - Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri), config); - Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getMetaSchema()); - Version specification = schema.getValidationContext().getMetaSchema().getSpecification(); + protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory) { + Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri)); + Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getDialect()); + Version specification = schema.getValidationContext().getDialect().getSpecification(); if (specification != null) { if (specification.getOrder() >= Version.DRAFT_2019_09.getOrder()) { // Process vocabularies diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index beb072fb4..19002fd1c 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -450,14 +450,14 @@ public KeywordValidator newValidator(ValidationContext validationContext, Schema try { Keyword kw = this.keywords.get(keyword); if (kw == null) { - if (keyword.equals(validationContext.getConfig().getErrorMessageKeyword())) { + if (keyword.equals(validationContext.getSchemaRegistryConfig().getErrorMessageKeyword())) { return null; } - if (validationContext.getConfig().isNullableKeywordEnabled() && "nullable".equals(keyword)) { + if (validationContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) { return null; } if (ValidatorTypeCode.DISCRIMINATOR.getValue().equals(keyword) - && validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + && validationContext.isDiscriminatorKeywordEnabled()) { return ValidatorTypeCode.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext); } diff --git a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java index 15283749e..4c1d7d883 100644 --- a/src/main/java/com/networknt/schema/dialect/DialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DialectRegistry.java @@ -16,7 +16,6 @@ package com.networknt.schema.dialect; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; /** * Registry for {@link Dialect} that can be retrieved using the dialect id which @@ -34,8 +33,7 @@ public interface DialectRegistry { * conforms to the dialect * @param schemaRegistry the schema registry to fetch and load unknown dialect's * meta-schema - * @param config the config * @return the dialect */ - Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry, SchemaValidatorsConfig config); + Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry); } diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index 9427a2ddb..be2d33512 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -19,19 +19,19 @@ public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evalu Schema parentSchema, Keyword keyword, ValidationContext validationContext) { super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - Version dialect = this.validationContext.getMetaSchema().getSpecification(); + Version dialect = this.validationContext.getDialect().getSpecification(); if (dialect == null || dialect.getOrder() < Version.DRAFT_2019_09.getOrder()) { assertionsEnabled = true; } else { // Check vocabulary assertionsEnabled = isFormatAssertionVocabularyEnabled(dialect, - this.validationContext.getMetaSchema().getVocabularies()); + this.validationContext.getDialect().getVocabularies()); } } protected boolean isFormatAssertionVocabularyEnabled() { - return isFormatAssertionVocabularyEnabled(this.validationContext.getMetaSchema().getSpecification(), - this.validationContext.getMetaSchema().getVocabularies()); + return isFormatAssertionVocabularyEnabled(this.validationContext.getDialect().getSpecification(), + this.validationContext.getDialect().getVocabularies()); } protected boolean isFormatAssertionVocabularyEnabled(Version specification, Map vocabularies) { diff --git a/src/main/java/com/networknt/schema/format/DurationFormat.java b/src/main/java/com/networknt/schema/format/DurationFormat.java index ca8d0e1fb..9fc33df6d 100644 --- a/src/main/java/com/networknt/schema/format/DurationFormat.java +++ b/src/main/java/com/networknt/schema/format/DurationFormat.java @@ -32,7 +32,7 @@ public boolean matches(ExecutionContext executionContext, ValidationContext vali } protected boolean isStrictValidation(ValidationContext validationContext) { - return validationContext.getConfig().isStrict(DURATION); + return validationContext.getSchemaRegistryConfig().isStrict(DURATION); } @Override diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index fa2cdb32f..52ec1a352 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -25,9 +25,6 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -41,8 +38,6 @@ * {@link KeywordValidator} for additionalProperties. */ public class AdditionalPropertiesValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(AdditionalPropertiesValidator.class); - private final boolean allowAdditionalProperties; private final Schema additionalPropertiesSchema; private final Set allowedProperties; @@ -93,7 +88,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); if (!node.isObject()) { // ignore no object return; diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index f08b2eff7..ccc7b2382 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -30,21 +30,16 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for allOf. */ public class AllOfValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(AllOfValidator.class); - private final List schemas; public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -65,15 +60,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); - for (Schema schema : this.schemas) { if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); } else { schema.walk(executionContext, node, rootNode, instanceLocation, true); } - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { final Iterator arrayElements = this.schemaNode.elements(); while (arrayElements.hasNext()) { final ObjectNode allOfEntry = (ObjectNode) arrayElements.next(); diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 1f33c54d9..767fa0e93 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -28,16 +28,12 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for anyOf. */ public class AnyOfValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(AnyOfValidator.class); private static final String DISCRIMINATOR_REMARK = "and the discriminator-selected candidate schema didn't pass validation"; private final List schemas; @@ -47,7 +43,7 @@ public class AnyOfValidator extends BaseKeywordValidator { public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -70,9 +66,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); - - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { executionContext.enterDiscriminatorContext(new DiscriminatorContext(), instanceLocation); } int numberOfValidSubSchemas = 0; @@ -113,13 +107,13 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo numberOfValidSubSchemas++; } - if (errors.isEmpty() && (!this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) + if (errors.isEmpty() && (!this.validationContext.isDiscriminatorKeywordEnabled()) && canShortCircuit() && canShortCircuit(executionContext)) { // Clear all errors. Note that this is checked in finally. allErrors = null; executionContext.setErrors(existingErrors); return; - } else if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + } else if (this.validationContext.isDiscriminatorKeywordEnabled()) { DiscriminatorContext currentDiscriminatorContext = executionContext.getCurrentDiscriminatorContext(); if (currentDiscriminatorContext.isDiscriminatorMatchFound() || currentDiscriminatorContext.isDiscriminatorIgnore()) { @@ -153,7 +147,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { executionContext.setFailFast(failFast); } - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled() + if (this.validationContext.isDiscriminatorKeywordEnabled() && executionContext.getCurrentDiscriminatorContext().isActive() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) @@ -165,7 +159,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { return; } } finally { - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { executionContext.leaveDiscriminatorContextImmediately(instanceLocation); } } diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index eccc5b7b5..7ef55b917 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -18,15 +18,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ErrorMessages; -import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; - import java.util.Collection; import java.util.Map; @@ -48,9 +45,9 @@ public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation this.validationContext = validationContext; this.parentSchema = parentSchema; - if (keyword != null && parentSchema != null && validationContext.getConfig().getErrorMessageKeyword() != null) { + if (keyword != null && parentSchema != null && validationContext.getSchemaRegistryConfig().getErrorMessageKeyword() != null) { this.errorMessage = ErrorMessages.getErrorMessage(parentSchema, - validationContext.getConfig().getErrorMessageKeyword(), keyword.getValue()); + validationContext.getSchemaRegistryConfig().getErrorMessageKeyword(), keyword.getValue()); } else { this.errorMessage = null; } @@ -86,29 +83,6 @@ protected BaseKeywordValidator( this.evaluationParentSchema = evaluationParentSchema; } - protected static boolean equals(double n1, double n2) { - return Math.abs(n1 - n2) < 1e-12; - } - - public static void debug(Logger logger, ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { - //logger.debug("validate( {}, {}, {})", node, rootNode, instanceLocation); - // The below is equivalent to the above but as there are more than 2 arguments - // the var-arg method is used and an array needs to be allocated even if debug - // is not enabled - if (executionContext.getExecutionConfig().isDebugEnabled() && logger.isDebugEnabled()) { - StringBuilder builder = new StringBuilder(); - builder.append("validate( "); - builder.append(node.toString()); - builder.append(", "); - builder.append(rootNode.toString()); - builder.append(", "); - builder.append(instanceLocation.toString()); - builder.append(")"); - logger.debug(builder.toString()); - } - } - /** * Gets the parent schema. *

@@ -182,7 +156,7 @@ protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { protected MessageSourceError.Builder error() { return MessageSourceError - .builder(this.validationContext.getConfig().getMessageSource(), this.errorMessage) + .builder(this.validationContext.getSchemaRegistryConfig().getMessageSource(), this.errorMessage) .schemaNode(this.schemaNode).schemaLocation(this.schemaLocation).evaluationPath(this.evaluationPath) .keyword(this.getKeyword()).messageKey(this.getKeyword()); } diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index 1f2b00f34..449c7087f 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -22,23 +22,16 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for const. */ public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ConstValidator.class); - public ConstValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - if (schemaNode.isNumber() && node.isNumber()) { if (schemaNode.decimalValue().compareTo(node.decimalValue()) != 0) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index d951b4509..1574f66ec 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -25,9 +25,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import static com.networknt.schema.keyword.VersionCode.MinV201909; import java.util.ArrayList; @@ -39,7 +36,6 @@ * {@link KeywordValidator} for contains. */ public class ContainsValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ContainsValidator.class); private static final String CONTAINS_MAX = "contains.max"; private static final String CONTAINS_MIN = "contains.min"; @@ -57,7 +53,7 @@ public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes // slightly. - this.isMinV201909 = MinV201909.getVersions().contains(this.validationContext.getMetaSchema().getSpecification()); + this.isMinV201909 = MinV201909.getVersions().contains(this.validationContext.getDialect().getSpecification()); Integer currentMax = null; Integer currentMin = null; @@ -86,8 +82,6 @@ public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - // ignores non-arrays int actual = 0, i = 0; List indexes = new ArrayList<>(); // for the annotation diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 6c496f67d..050c3c9e9 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -25,9 +25,6 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Base64; /** @@ -37,7 +34,6 @@ * errors. */ public class ContentEncodingValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ContentEncodingValidator.class); private final String contentEncoding; /** @@ -72,10 +68,8 @@ private boolean matches(String value) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - // Ignore non-strings - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index b44098ece..477f652cd 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -20,9 +20,6 @@ import java.util.Base64; import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; @@ -40,7 +37,6 @@ * Note that since 2019-09 this keyword only generates annotations and not errors. */ public class ContentMediaTypeValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ContentMediaTypeValidator.class); private static final String PATTERN_STRING = "(application|audio|font|example|image|message|model|multipart|text|video|x-(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+))/([0-9A-Za-z!#$%&'*+.^_`|~-]+)((?:[ \t]*;[ \t]*[0-9A-Za-z!#$%&'*+.^_`|~-]+=(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+|\"(?:[^\"\\\\]|\\.)*\"))*)"; private static final Pattern PATTERN = Pattern.compile(PATTERN_STRING); private final String contentMediaType; @@ -95,10 +91,8 @@ else if (!PATTERN.matcher(this.contentMediaType).matches()) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - // Ignore non-strings - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 6e4fd87c0..5a1a24fed 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -23,16 +23,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for dependencies. */ public class DependenciesValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(DependenciesValidator.class); private final Map> propertyDeps = new HashMap<>(); private final Map schemaDeps = new HashMap<>(); @@ -69,8 +65,6 @@ public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluat } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); List deps = propertyDeps.get(pname); diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index e1bf2b220..4e149d1d9 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -23,16 +23,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for dependentRequired. */ public class DependentRequired extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(DependentRequired.class); private final Map> propertyDependencies = new HashMap<>(); public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -53,8 +49,6 @@ public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationP } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); List dependencies = propertyDependencies.get(pname); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 37b58fee3..73cd8c0ac 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -23,16 +23,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for dependentSchemas. */ public class DependentSchemas extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(DependentSchemas.class); private final Map schemaDependencies = new HashMap<>(); public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -57,8 +53,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); - for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); Schema schema = this.schemaDependencies.get(pname); diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 5200e7230..daa6de84b 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -28,17 +28,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.function.Supplier; /** * {@link KeywordValidator} that resolves $dynamicRef. */ public class DynamicRefValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(DynamicRefValidator.class); - protected final JsonSchemaRef schema; public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -84,7 +79,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat refSchema = refSchema.fromRef(parentSchema, evaluationPath); } return refSchema; - }, validationContext.getConfig().isCacheRefs())); + }, validationContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { @@ -102,7 +97,6 @@ private static String resolve(Schema parentSchema, String refValue) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) @@ -116,7 +110,6 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { - debug(logger, executionContext, node, rootNode, instanceLocation); // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. @@ -177,8 +170,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 5639a40f7..54d2566d6 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -28,9 +28,6 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.util.Collections; import java.util.HashSet; @@ -40,8 +37,6 @@ * {@link KeywordValidator} for enum. */ public class EnumValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(EnumValidator.class); - private final Set nodes; private final String error; @@ -79,7 +74,7 @@ public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, } // check if the parent schema declares the fields as nullable - if (validationContext.getConfig().isNullableKeywordEnabled()) { + if (validationContext.isNullableKeywordEnabled()) { JsonNode nullable = parentSchema.getSchemaNode().get("nullable"); if (nullable != null && nullable.asBoolean()) { nodes.add(NullNode.getInstance()); @@ -98,14 +93,12 @@ public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - if (node.isNumber()) { node = processNumberNode(node); } else if (node.isArray()) { node = processArrayNode((ArrayNode) node); } - if (!nodes.contains(node) && !( this.validationContext.getConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { + if (!nodes.contains(node) && !( this.validationContext.getSchemaRegistryConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(error).build()); @@ -118,7 +111,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode * @param node JsonNode to check */ private boolean isTypeLooseContainsInEnum(JsonNode node) { - if (TypeFactory.getValueNodeType(node, this.validationContext.getConfig()) == JsonType.STRING) { + if (TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()) == JsonType.STRING) { String nodeText = node.textValue(); for (JsonNode n : nodes) { String value = n.asText(); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 55736dfc9..cdf6e8f24 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -27,9 +27,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.math.BigInteger; @@ -37,8 +34,6 @@ * {@link KeywordValidator} for exclusiveMaximum. */ public class ExclusiveMaximumValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ExclusiveMaximumValidator.class); - private final ThresholdMixin typedMaximum; public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -104,9 +99,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - - if (!JsonNodeUtil.isNumber(node, validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, validationContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index ae78c6c76..7d1cbccea 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -27,9 +27,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.math.BigInteger; @@ -37,8 +34,6 @@ * {@link KeywordValidator} for exclusiveMinimum. */ public class ExclusiveMinimumValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ExclusiveMinimumValidator.class); - /** * In order to limit number of `if` statements in `validate` method, all the * logic of picking the right comparison is abstracted into a mixin. @@ -111,9 +106,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - - if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index 0b3b2a299..e2bfda60d 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -22,15 +22,10 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for false. */ public class FalseValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(FalseValidator.class); - private final String reason; public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -39,7 +34,6 @@ public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); // For the false validator, it is always not valid executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index 08957f8af..a77b087ef 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -58,7 +58,7 @@ protected Object getAnnotationValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + /* * Annotations must be collected even if the format is unknown according to the specification. */ @@ -137,6 +137,6 @@ protected boolean createUnknownFormatAssertions(ExecutionContext executionContex * @return whether to perform strict handling */ protected boolean isStrict(ExecutionContext executionContext) { - return this.validationContext.getConfig().isStrict(getKeyword(), Boolean.FALSE); + return this.validationContext.getSchemaRegistryConfig().isStrict(getKeyword(), Boolean.FALSE); } } diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index ded4720f8..5d007ed69 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -24,17 +24,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for if. */ public class IfValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(IfValidator.class); - private static final List KEYWORDS = Arrays.asList("if", "then", "else"); private final Schema ifSchema; @@ -71,7 +66,7 @@ public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, J @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + boolean ifConditionPassed = false; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 6f12e1e95..3291ec66d 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -27,16 +27,12 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for items V4 to V2019-09. */ public class ItemsValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ItemsValidator.class); private static final String PROPERTY_ADDITIONAL_ITEMS = "additionalItems"; private final Schema schema; @@ -93,9 +89,9 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - if (!node.isArray() && !this.validationContext.getConfig().isTypeLoose()) { + if (!node.isArray() && !this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { // ignores non-arrays return; } @@ -235,7 +231,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root int count = Math.max(1, node.size()); ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { defaultNode = getDefaultNode(this.schema); } for (int i = 0; i < count; i++) { @@ -260,7 +256,7 @@ else if (this.tupleSchema != null) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; JsonNode n = arrayNode.get(i); - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { defaultNode = getDefaultNode(this.tupleSchema.get(i)); } if (n != null) { @@ -287,7 +283,7 @@ else if (this.tupleSchema != null) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; JsonNode n = arrayNode.get(i); - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { defaultNode = getDefaultNode(this.additionalSchema); } if (n != null) { @@ -333,13 +329,13 @@ private static JsonNode getDefaultNode(Schema schema) { private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, String keyword) { - boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, + boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, node, rootNode, instanceLocation, walkSchema, this); int currentErrors = executionContext.getErrors().size(); if (executeWalk) { walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners(executionContext, keyword, node, rootNode, + executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners(executionContext, keyword, node, rootNode, instanceLocation, walkSchema, this, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size())); } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index bfb2366fb..09930b5bb 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -27,15 +27,10 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for items from V2012-12. */ public class ItemsValidator202012 extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(ItemsValidator202012.class); - private final Schema schema; private final int prefixCount; private final boolean additionalItems; @@ -68,7 +63,7 @@ public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluati @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // ignores non-arrays if (node.isArray()) { @@ -106,7 +101,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (node instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() && this.schema != null) { defaultNode = getDefaultNode(this.schema); } @@ -154,7 +149,7 @@ private static JsonNode getDefaultNode(Schema schema) { private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off - boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( + boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, ValidatorTypeCode.ITEMS.getValue(), node, @@ -166,7 +161,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js if (executeWalk) { walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners( + executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, ValidatorTypeCode.ITEMS.getValue(), node, diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index 88ee59e3b..4f26cae53 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -23,16 +23,10 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for maxItems. */ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordValidator { - - private static final Logger logger = LoggerFactory.getLogger(MaxItemsValidator.class); - private final int max; public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -45,7 +39,7 @@ public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (node.isArray()) { if (node.size() > this.max) { @@ -53,7 +47,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.max, node.size()).build()); } - } else if (this.validationContext.getConfig().isTypeLoose()) { + } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { if (1 > this.max) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 6bf510ba7..865561ba4 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -25,15 +25,10 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for maxLength. */ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MaxLengthValidator.class); - private final int maxLength; public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -46,9 +41,9 @@ public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { // ignore no-string typs return; diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index 70e7d3036..c2a03d776 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -23,15 +23,10 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator}for maxProperties. */ public class MaxPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MaxPropertiesValidator.class); - private final int max; public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, @@ -45,7 +40,7 @@ public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evalua } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (node.isObject()) { if (node.size() > max) { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 106ea1596..d455497df 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -27,9 +27,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.math.BigInteger; @@ -37,7 +34,6 @@ * {@link KeywordValidator} for maxmimum. */ public class MaximumValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MaximumValidator.class); private static final String PROPERTY_EXCLUSIVE_MAXIMUM = "exclusiveMaximum"; private final boolean excludeEqual; @@ -116,9 +112,9 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index d8bab517e..877621c32 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -23,15 +23,10 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for minItems. */ public class MinItemsValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MinItemsValidator.class); - private int min = 0; public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -42,7 +37,7 @@ public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (node.isArray()) { if (node.size() < min) { @@ -51,7 +46,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .arguments(min, node.size()) .build()); } - } else if (this.validationContext.getConfig().isTypeLoose()) { + } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { if (1 < min) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index c5dbb873f..f4c3df7f9 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -25,15 +25,10 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for minLength. */ public class MinLengthValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MinLengthValidator.class); - private int minLength; public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -45,9 +40,9 @@ public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { // ignore non-string types return; diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index 25db5aaf7..4a968ad57 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -23,15 +23,10 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for minProperties. */ public class MinPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MinPropertiesValidator.class); - protected final int min; public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, @@ -45,7 +40,7 @@ public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evalua } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (node.isObject()) { if (node.size() < min) { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index 3fa1c8c2a..f893e03be 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -27,9 +27,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.math.BigInteger; @@ -37,7 +34,6 @@ * {@link KeywordValidator} for minimum. */ public class MinimumValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MinimumValidator.class); private static final String PROPERTY_EXCLUSIVE_MINIMUM = "exclusiveMinimum"; private final boolean excludeEqual; @@ -123,9 +119,9 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index 31168fa28..7da805246 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -24,17 +24,12 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; /** * {@link KeywordValidator} for multipleOf. */ public class MultipleOfValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(MultipleOfValidator.class); - private final BigDecimal divisor; public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, @@ -45,7 +40,7 @@ public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (this.divisor != null) { BigDecimal dividend = getDividend(node); if (dividend != null) { @@ -88,8 +83,8 @@ protected BigDecimal getDividend(JsonNode node) { // convert to BigDecimal since double type is not accurate enough to do the // division and multiple return node.isBigDecimal() ? node.decimalValue() : BigDecimal.valueOf(node.doubleValue()); - } else if (this.validationContext.getConfig().isTypeLoose() - && JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { + } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose() + && JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { // handling for type loose return new BigDecimal(node.textValue()); } diff --git a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index bb00e6d68..204ce60b1 100644 --- a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -36,8 +36,8 @@ public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, Jso Schema parentSchema, ValidationContext validationContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); String id = validationContext.resolveSchemaId(schemaNode); - String anchor = validationContext.getMetaSchema().readAnchor(schemaNode); - String dynamicAnchor = validationContext.getMetaSchema().readDynamicAnchor(schemaNode); + String anchor = validationContext.getDialect().readAnchor(schemaNode); + String dynamicAnchor = validationContext.getDialect().readDynamicAnchor(schemaNode); if (id != null || anchor != null || dynamicAnchor != null) { // Used to register schema resources with $id validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index db5eb4300..331235b49 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -23,17 +23,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for notAllowed. */ public class NotAllowedValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(NotAllowedValidator.class); - private final List fieldNames; public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -50,7 +45,7 @@ public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + for (String fieldName : fieldNames) { JsonNode propertyNode = node.get(fieldName); diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index 005f591fc..3b26f658d 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -24,17 +24,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for not. */ public class NotValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(NotValidator.class); - private final Schema schema; public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -51,7 +46,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index da73571e5..21d6589d0 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -19,9 +19,6 @@ import java.util.ArrayList; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.DiscriminatorContext; @@ -39,8 +36,6 @@ * {@link KeywordValidator} for oneOf. */ public class OneOfValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(OneOfValidator.class); - private final List schemas; private Boolean canShortCircuit = null; @@ -48,7 +43,7 @@ public class OneOfValidator extends BaseKeywordValidator { public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -71,7 +66,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); + int numberOfValidSchema = 0; int index = 0; List indexes = null; @@ -84,7 +79,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo boolean addMessages = true; try { DiscriminatorValidator discriminator = null; - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { DiscriminatorContext discriminatorContext = new DiscriminatorContext(); executionContext.enterDiscriminatorContext(discriminatorContext, instanceLocation); @@ -121,7 +116,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo break; } - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { // The discriminator will cause all messages other than the one with the // matching discriminator to be discarded. Note that the discriminator cannot // affect the actual validation result. @@ -169,7 +164,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo index++; } - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled() + if (this.validationContext.isDiscriminatorKeywordEnabled() && (discriminator != null || executionContext.getCurrentDiscriminatorContext().isActive()) && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorMatchFound() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { @@ -184,7 +179,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo // Restore flag executionContext.setFailFast(failFast); - if (this.validationContext.getConfig().isDiscriminatorKeywordEnabled()) { + if (this.validationContext.isDiscriminatorKeywordEnabled()) { executionContext.leaveDiscriminatorContextImmediately(instanceLocation); } } diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index d1ba77232..3e0040b48 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -25,9 +25,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** @@ -35,7 +32,6 @@ */ public class PatternPropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "patternProperties"; - private static final Logger logger = LoggerFactory.getLogger(PatternPropertiesValidator.class); private final Map schemas = new IdentityHashMap<>(); private Boolean hasUnevaluatedPropertiesValidator = null; @@ -56,7 +52,7 @@ public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath ev } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (!node.isObject()) { return; diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index 4298ef28c..c0290e79b 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -56,9 +56,9 @@ private boolean matches(String value) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 156982678..3fada33c9 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -27,9 +27,6 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.List; @@ -37,8 +34,6 @@ * {@link KeywordValidator} for prefixItems. */ public class PrefixItemsValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(PrefixItemsValidator.class); - private final List tupleSchema; private Boolean hasUnevaluatedItemsValidator = null; @@ -61,7 +56,7 @@ public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluati @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // ignores non-arrays if (node.isArray()) { int count = Math.min(node.size(), this.tupleSchema.size()); @@ -99,7 +94,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root int count = this.tupleSchema.size(); for (int i = 0; i < count; ++i) { JsonNode n = node.get(i); - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { JsonNode defaultNode = getDefaultNode(this.tupleSchema.get(i)); if (n != null) { // Defaults only set if array index is explicitly null @@ -159,7 +154,7 @@ private void doWalk(ExecutionContext executionContext, int i, private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off - boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( + boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, ValidatorTypeCode.PREFIX_ITEMS.getValue(), node, @@ -171,7 +166,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js if (executeWalk) { walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners( + executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, ValidatorTypeCode.PREFIX_ITEMS.getValue(), node, diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 977530afe..3e75ec153 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -29,9 +29,6 @@ import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -45,7 +42,6 @@ */ public class PropertiesValidator extends BaseKeywordValidator { public static final String PROPERTY = "properties"; - private static final Logger logger = LoggerFactory.getLogger(PropertiesValidator.class); private final Map schemas = new LinkedHashMap<>(); private Boolean hasUnevaluatedPropertiesValidator; @@ -68,7 +64,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - debug(logger, executionContext, node, rootNode, instanceLocation); + Set matchedInstancePropertyNames = null; boolean collectAnnotations = collectAnnotations() || collectAnnotations(executionContext); @@ -87,7 +83,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo entry.getValue().validate(executionContext, propertyNode, rootNode, path); } else { // check if walker is enabled. If it is enabled it is upto the walker implementation to decide about the validation. - walkSchema(executionContext, entry, node, rootNode, instanceLocation, true, this.validationContext.getConfig().getPropertyWalkListenerRunner()); + walkSchema(executionContext, entry, node, rootNode, instanceLocation, true, executionContext.getWalkConfig().getPropertyWalkListenerRunner()); } } else { if (walk) { @@ -96,7 +92,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo // null. // The actual walk needs to be skipped as the validators assume that node is not // null. - walkSchema(executionContext, entry, node, rootNode, instanceLocation, true, this.validationContext.getConfig().getPropertyWalkListenerRunner()); + walkSchema(executionContext, entry, node, rootNode, instanceLocation, true, executionContext.getWalkConfig().getPropertyWalkListenerRunner()); } } } @@ -112,15 +108,15 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { - if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyPropertyDefaults() && null != node + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyPropertyDefaults() && null != node && node.getNodeType() == JsonNodeType.OBJECT) { - applyPropertyDefaults((ObjectNode) node); + applyPropertyDefaults((ObjectNode) node, executionContext); } if (shouldValidateSchema) { validate(executionContext, node == null ? MissingNode.getInstance() : node, rootNode, instanceLocation, true); } else { - WalkListenerRunner propertyWalkListenerRunner = this.validationContext.getConfig().getPropertyWalkListenerRunner(); + WalkListenerRunner propertyWalkListenerRunner = executionContext.getWalkConfig().getPropertyWalkListenerRunner(); for (Map.Entry entry : this.schemas.entrySet()) { walkSchema(executionContext, entry, node, rootNode, instanceLocation, shouldValidateSchema, propertyWalkListenerRunner); } @@ -138,7 +134,7 @@ private boolean hasUnevaluatedPropertiesValidator() { return hasUnevaluatedPropertiesValidator; } - private void applyPropertyDefaults(ObjectNode node) { + private void applyPropertyDefaults(ObjectNode node, ExecutionContext executionContext) { for (Map.Entry entry : this.schemas.entrySet()) { JsonNode propertyNode = node.get(entry.getKey()); @@ -146,7 +142,7 @@ private void applyPropertyDefaults(ObjectNode node) { if (defaultNode == null) { continue; } - boolean applyDefault = propertyNode == null || (propertyNode.isNull() && this.validationContext.getConfig() + boolean applyDefault = propertyNode == null || (propertyNode.isNull() && executionContext.getWalkConfig() .getApplyDefaultsStrategy().shouldApplyPropertyDefaultsIfNull()); if (applyDefault) { node.set(entry.getKey(), defaultNode); diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 549ca1ed9..817a5051c 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -19,9 +19,6 @@ import java.util.Iterator; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import com.networknt.schema.Error; @@ -32,7 +29,6 @@ import com.networknt.schema.ValidationContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(PropertyNamesValidator.class); private final Schema innerSchema; public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); @@ -40,7 +36,7 @@ public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evalua } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + List existingErrors = executionContext.getErrors(); List schemaErrors = new ArrayList<>(); diff --git a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index 06de6b57c..da2fdf222 100644 --- a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -32,19 +32,15 @@ public class ReadOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ReadOnlyValidator.class); - private final boolean readOnly; - public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - - this.readOnly = validationContext.getConfig().isReadOnly(); logger.debug("Loaded ReadOnlyValidator for property {} as {}", parentSchema, "read mode"); } @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - if (this.readOnly) { + + if (Boolean.TRUE.equals(executionContext.getExecutionConfig().getReadOnly())) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .build()); diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 3a3592099..b80bf4ff7 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -28,17 +28,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.function.Supplier; /** * {@link KeywordValidator} that resolves $recursiveRef. */ public class RecursiveRefValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(RecursiveRefValidator.class); - protected final JsonSchemaRef schema; public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -58,7 +53,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, JsonNodePath evaluationPath) { - return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, validationContext, refValue, evaluationPath), validationContext.getConfig().isCacheRefs())); + return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, validationContext, refValue, evaluationPath), validationContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { @@ -97,7 +92,7 @@ static Schema getSchema(Schema parentSchema, ValidationContext validationContext @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.RECURSIVE_REF.getValue()) @@ -111,7 +106,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. @@ -172,8 +167,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 8f509f1e8..5b0179014 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -28,17 +28,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.function.Supplier; /** * {@link KeywordValidator} that resolves $ref. */ public class RefValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(RefValidator.class); - protected final JsonSchemaRef schema; private static final String REF_CURRENT = "#"; @@ -72,7 +67,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat return new JsonSchemaRef(getSupplier(() -> { Schema schemaResource = validationContext.getSchemaResources().get(schemaUriFinal); if (schemaResource == null) { - schemaResource = validationContext.getJsonSchemaFactory().loadSchema(schemaLocation, validationContext.getConfig()); + schemaResource = validationContext.getSchemaRegistry().loadSchema(schemaLocation); if (schemaResource != null) { copySchemaResources(validationContext, schemaResource); } @@ -100,7 +95,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat } return schemaResource.fromRef(parentSchema, evaluationPath); } - }, validationContext.getConfig().isCacheRefs())); + }, validationContext.getSchemaRegistryConfig().isCacheRefs())); } else if (SchemaLocation.Fragment.isAnchorFragment(refValue)) { String absoluteIri = resolve(parentSchema, refValue); @@ -117,17 +112,17 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat return null; } return schemaResource.fromRef(parentSchema, evaluationPath); - }, validationContext.getConfig().isCacheRefs())); + }, validationContext.getSchemaRegistryConfig().isCacheRefs())); } if (refValue.equals(REF_CURRENT)) { return new JsonSchemaRef( getSupplier(() -> parentSchema.findSchemaResourceRoot().fromRef(parentSchema, evaluationPath), - validationContext.getConfig().isCacheRefs())); + validationContext.getSchemaRegistryConfig().isCacheRefs())); } return new JsonSchemaRef(getSupplier( () -> getJsonSchema(parentSchema, validationContext, refValue, refValueOriginal, evaluationPath) .fromRef(parentSchema, evaluationPath), - validationContext.getConfig().isCacheRefs())); + validationContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { @@ -171,7 +166,7 @@ private static Schema getJsonSchema(Schema parent, // The getSubSchema potentially recurses to call back to getJsonSchema again Schema result = validationContext.getSchemaReferences().get(schemaReference); if (result == null) { - synchronized (validationContext.getJsonSchemaFactory()) { // acquire lock on shared factory object to prevent deadlock + synchronized (validationContext.getSchemaRegistry()) { // acquire lock on shared factory object to prevent deadlock result = validationContext.getSchemaReferences().get(schemaReference); if (result == null) { result = parent.getSubSchema(fragment); @@ -186,7 +181,7 @@ private static Schema getJsonSchema(Schema parent, @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.REF.getValue()) @@ -200,7 +195,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. @@ -261,8 +256,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java index cadd03958..55e467fe6 100644 --- a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -23,17 +23,12 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.*; /** * {@link KeywordValidator} for required. */ public class RequiredValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(RequiredValidator.class); - private final List fieldNames; public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -49,7 +44,7 @@ public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (!node.isObject()) { return; @@ -59,8 +54,8 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonNode propertyNode = node.get(fieldName); if (propertyNode == null) { - Boolean readOnly = this.validationContext.getConfig().getReadOnly(); - Boolean writeOnly = this.validationContext.getConfig().getWriteOnly(); + Boolean readOnly = executionContext.getExecutionConfig().getReadOnly(); + Boolean writeOnly = executionContext.getExecutionConfig().getWriteOnly(); if (Boolean.TRUE.equals(readOnly)) { JsonNode readOnlyNode = getFieldKeyword(fieldName, "readOnly"); if (readOnlyNode != null && readOnlyNode.booleanValue()) { diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index 448b61d08..b74b7937d 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -22,21 +22,16 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * {@link KeywordValidator} for true. */ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(TrueValidator.class); - public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + // For the true validator, it is always valid which means there is no Error. } } diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index 3ba3edc8e..f4671b2b4 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -25,15 +25,11 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; import com.networknt.schema.utils.JsonNodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * {@link KeywordValidator} for type. */ public class TypeValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(TypeValidator.class); - private final JsonType schemaType; private final UnionTypeValidator unionTypeValidator; @@ -57,7 +53,7 @@ public boolean equalsToSchemaType(JsonNode node) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (this.schemaType == JsonType.UNION) { this.unionTypeValidator.validate(executionContext, node, rootNode, instanceLocation); @@ -65,7 +61,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (!equalsToSchemaType(node)) { - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(nodeType.toString(), this.schemaType.toString()).build()); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 614ee45f7..b178ac4f7 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -25,9 +25,6 @@ import com.networknt.schema.Specification.Version; import com.networknt.schema.annotation.JsonNodeAnnotation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import static com.networknt.schema.keyword.VersionCode.MinV202012; import java.util.*; @@ -38,8 +35,6 @@ * {@link KeywordValidator} for unevaluatedItems. */ public class UnevaluatedItemsValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(UnevaluatedItemsValidator.class); - private final Schema schema; private final boolean isMinV202012; @@ -63,7 +58,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode return; } - debug(logger, executionContext, node, rootNode, instanceLocation); + /* * Keywords renamed in 2020-12 * diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index c18943764..688f599f0 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -16,6 +16,14 @@ package com.networknt.schema.keyword; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; @@ -24,19 +32,10 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - /** * {@link KeywordValidator} for unevaluatedProperties. */ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(UnevaluatedPropertiesValidator.class); - private final Schema schema; public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -55,7 +54,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode return; } - debug(logger, executionContext, node, rootNode, instanceLocation); + // Get all the valid adjacent annotations Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 8900ca994..5c85a9b6a 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -28,9 +28,6 @@ import com.networknt.schema.ValidationContext; import com.networknt.schema.Validator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.List; @@ -38,8 +35,6 @@ * {@link KeywordValidator} for type union. */ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(UnionTypeValidator.class); - private final List schemas; private final String error; @@ -77,9 +72,9 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluation } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + - JsonType nodeType = TypeFactory.getValueNodeType(node, validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, validationContext.getSchemaRegistryConfig()); boolean valid = false; diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index fe84bd772..36937c83f 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -23,9 +23,6 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.HashSet; import java.util.Set; @@ -33,8 +30,6 @@ * {@link KeywordValidator} for uniqueItems. */ public class UniqueItemsValidator extends BaseKeywordValidator implements KeywordValidator { - private static final Logger logger = LoggerFactory.getLogger(UniqueItemsValidator.class); - private final boolean unique; public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { @@ -47,7 +42,7 @@ public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluati } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); + if (unique) { Set set = new HashSet<>(); diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index 5d8edb87c..28cf5c300 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -16,19 +16,15 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); - private final boolean writeOnly; - public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - - this.writeOnly = validationContext.getConfig().isWriteOnly(); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); } @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - debug(logger, executionContext, node, rootNode, instanceLocation); - if (this.writeOnly) { + + if (Boolean.TRUE.equals(executionContext.getExecutionConfig().getWriteOnly())) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .build()); diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index c7f1e2bf0..8b3d4b9ce 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -114,13 +114,13 @@ public static OutputUnit format(Schema jsonSchema, List errors, OutputUnit root = new OutputUnit(); root.setValid(errors.isEmpty()); - root.setInstanceLocation(validationContext.getConfig().getPathType().getRoot()); - root.setEvaluationPath(validationContext.getConfig().getPathType().getRoot()); + root.setInstanceLocation(validationContext.getSchemaRegistryConfig().getPathType().getRoot()); + root.setEvaluationPath(validationContext.getSchemaRegistryConfig().getPathType().getRoot()); root.setSchemaLocation(jsonSchema.getSchemaLocation().toString()); OutputUnitData data = OutputUnitData.from(errors, executionContext, errorMapper); - return format(root, data, new JsonNodePath(validationContext.getConfig().getPathType())); + return format(root, data, new JsonNodePath(validationContext.getSchemaRegistryConfig().getPathType())); } /** diff --git a/src/main/java/com/networknt/schema/regex/RegularExpression.java b/src/main/java/com/networknt/schema/regex/RegularExpression.java index 8a3140bed..90669897f 100644 --- a/src/main/java/com/networknt/schema/regex/RegularExpression.java +++ b/src/main/java/com/networknt/schema/regex/RegularExpression.java @@ -11,7 +11,7 @@ public interface RegularExpression { static RegularExpression compile(String regex, ValidationContext validationContext) { if (null == regex) return s -> true; - return validationContext.getConfig().getRegularExpressionFactory().getRegularExpression(regex); + return validationContext.getSchemaRegistryConfig().getRegularExpressionFactory().getRegularExpression(regex); } } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index ae7398e10..f13ac2184 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -7,7 +7,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.PathType; -import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.TypeFactory; import com.networknt.schema.ValidationContext; @@ -57,16 +57,16 @@ public static boolean isNodeNullable(JsonNode schema){ } //Check to see if a JsonNode is nullable with checking the isHandleNullableField - public static boolean isNodeNullable(JsonNode schema, SchemaValidatorsConfig config){ + public static boolean isNodeNullable(JsonNode schema, ValidationContext validationContext) { // check if the parent schema declares the fields as nullable - if (config.isNullableKeywordEnabled()) { + if (validationContext.isNullableKeywordEnabled()) { return isNodeNullable(schema); } return false; } public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, ValidationContext validationContext) { - SchemaValidatorsConfig config = validationContext.getConfig(); + SchemaRegistryConfig config = validationContext.getSchemaRegistryConfig(); JsonType nodeType = TypeFactory.getValueNodeType(node, config); // in the case that node type is not the same as schema type, try to convert node to the // same type of schema. In REST API, query parameters, path parameters and headers are all @@ -84,7 +84,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch } if (nodeType == JsonType.NULL) { - if (parentSchema != null && config.isNullableKeywordEnabled()) { + if (parentSchema != null && validationContext.isNullableKeywordEnabled()) { Schema grandParentSchema = parentSchema.getParentSchema(); if (grandParentSchema != null && JsonNodeUtil.isNodeNullable(grandParentSchema.getSchemaNode()) || JsonNodeUtil.isNodeNullable(parentSchema.getSchemaNode())) { @@ -131,7 +131,7 @@ private static long detectVersion(ValidationContext validationContext) { * @param config the SchemaValidatorsConfig to depend on * @return boolean to indicate if it is a number */ - public static boolean isNumber(JsonNode node, SchemaValidatorsConfig config) { + public static boolean isNumber(JsonNode node, SchemaRegistryConfig config) { if (node.isNumber()) { return true; } else if (config.isTypeLoose()) { diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index fe45f9276..4de62f764 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -18,10 +18,10 @@ protected WalkEvent constructWalkEvent(ExecutionContext executionContext, String .rootNode(rootNode).schema(schema).validator(validator).build(); } - protected boolean runPreWalkListeners(List walkListeners, WalkEvent walkEvent) { + protected boolean runPreWalkListeners(List walkListeners, WalkEvent walkEvent) { boolean continueToWalkMethod = true; if (walkListeners != null) { - for (JsonSchemaWalkListener walkListener : walkListeners) { + for (WalkListener walkListener : walkListeners) { WalkFlow walkFlow = walkListener.onWalkStart(walkEvent); if (WalkFlow.SKIP.equals(walkFlow) || WalkFlow.ABORT.equals(walkFlow)) { continueToWalkMethod = false; @@ -34,10 +34,10 @@ protected boolean runPreWalkListeners(List walkListeners return continueToWalkMethod; } - protected void runPostWalkListeners(List walkListeners, WalkEvent walkEvent, + protected void runPostWalkListeners(List walkListeners, WalkEvent walkEvent, List errors) { if (walkListeners != null) { - for (JsonSchemaWalkListener walkListener : walkListeners) { + for (WalkListener walkListener : walkListeners) { walkListener.onWalkEnd(walkEvent, errors); } } diff --git a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java deleted file mode 100644 index d562eacbc..000000000 --- a/src/main/java/com/networknt/schema/walk/DefaultItemWalkListenerRunner.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.networknt.schema.walk; - -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; -import com.networknt.schema.Schema; -import com.networknt.schema.keyword.KeywordValidator; -import com.networknt.schema.Error; - -import java.util.List; - -public class DefaultItemWalkListenerRunner extends AbstractWalkListenerRunner { - - private final List itemWalkListeners; - - public DefaultItemWalkListenerRunner(List itemWalkListeners) { - this.itemWalkListeners = itemWalkListeners; - } - - @Override - public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { - WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, - schema, validator); - return runPreWalkListeners(itemWalkListeners, walkEvent); - } - - @Override - public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { - WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, - schema, validator); - runPostWalkListeners(itemWalkListeners, walkEvent, errors); - } - -} \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java deleted file mode 100644 index 6b99c77e9..000000000 --- a/src/main/java/com/networknt/schema/walk/DefaultKeywordWalkListenerRunner.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.networknt.schema.walk; - -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Error; -import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; -import com.networknt.schema.Schema; -import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.keyword.KeywordValidator; - -public class DefaultKeywordWalkListenerRunner extends AbstractWalkListenerRunner { - - private final Map> keywordWalkListenersMap; - - public DefaultKeywordWalkListenerRunner(Map> keywordWalkListenersMap) { - this.keywordWalkListenersMap = keywordWalkListenersMap; - } - - @Override - public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { - boolean continueRunningListenersAndWalk = true; - WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - // Run Listeners that are setup only for this keyword. - List currentKeywordListeners = keywordWalkListenersMap.get(keyword); - continueRunningListenersAndWalk = runPreWalkListeners(currentKeywordListeners, keywordWalkEvent); - if (continueRunningListenersAndWalk) { - // Run Listeners that are setup for all keywords. - List allKeywordListeners = keywordWalkListenersMap - .get(SchemaValidatorsConfig.ALL_KEYWORD_WALK_LISTENER_KEY); - runPreWalkListeners(allKeywordListeners, keywordWalkEvent); - } - return continueRunningListenersAndWalk; - } - - @Override - public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, - List errors) { - WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - // Run Listeners that are setup only for this keyword. - List currentKeywordListeners = keywordWalkListenersMap.get(keyword); - runPostWalkListeners(currentKeywordListeners, keywordWalkEvent, errors); - // Run Listeners that are setup for all keywords. - List allKeywordListeners = keywordWalkListenersMap - .get(SchemaValidatorsConfig.ALL_KEYWORD_WALK_LISTENER_KEY); - runPostWalkListeners(allKeywordListeners, keywordWalkEvent, errors); - } -} diff --git a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java deleted file mode 100644 index 576b6fe35..000000000 --- a/src/main/java/com/networknt/schema/walk/DefaultPropertyWalkListenerRunner.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.networknt.schema.walk; - -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; -import com.networknt.schema.Schema; -import com.networknt.schema.keyword.KeywordValidator; -import com.networknt.schema.Error; - -import java.util.List; - -public class DefaultPropertyWalkListenerRunner extends AbstractWalkListenerRunner { - - private final List propertyWalkListeners; - - public DefaultPropertyWalkListenerRunner(List propertyWalkListeners) { - this.propertyWalkListeners = propertyWalkListeners; - } - - @Override - public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, - JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { - WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - return runPreWalkListeners(propertyWalkListeners, walkEvent); - } - - @Override - public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, JsonNode rootNode, JsonNodePath instanceLocation, - Schema schema, KeywordValidator validator, List errors) { - WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); - runPostWalkListeners(propertyWalkListeners, walkEvent, errors); - - } - -} diff --git a/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java new file mode 100644 index 000000000..ceb1a145a --- /dev/null +++ b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.walk; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.Schema; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.Error; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +/** + * A {@link WalkListenerRunner} for walking items. + */ +public class ItemWalkListenerRunner extends AbstractWalkListenerRunner { + + private final List itemWalkListeners; + + public ItemWalkListenerRunner(List itemWalkListeners) { + this.itemWalkListeners = itemWalkListeners; + } + + @Override + public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, + schema, validator); + return runPreWalkListeners(itemWalkListeners, walkEvent); + } + + @Override + public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { + WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, + schema, validator); + runPostWalkListeners(itemWalkListeners, walkEvent, errors); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private List itemWalkListeners = new ArrayList<>(); + + public Builder itemWalkListener(WalkListener itemWalkListener) { + this.itemWalkListeners.add(itemWalkListener); + return this; + } + + public Builder itemWalkListeners(Consumer> itemWalkListeners) { + itemWalkListeners.accept(this.itemWalkListeners); + return this; + } + + public ItemWalkListenerRunner build() { + return new ItemWalkListenerRunner(itemWalkListeners); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java new file mode 100644 index 000000000..aba9ef4fe --- /dev/null +++ b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.walk; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.Schema; +import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.keyword.KeywordValidator; + +/** + * A {@link WalkListenerRunner} for walking keywords. + */ +public class KeywordWalkListenerRunner extends AbstractWalkListenerRunner { + private final List allKeywordWalkListeners; + private final Map> keywordWalkListenersMap; + + public KeywordWalkListenerRunner(List allKeywordWalkListeners, + Map> keywordWalkListenersMap) { + this.allKeywordWalkListeners = allKeywordWalkListeners; + this.keywordWalkListenersMap = keywordWalkListenersMap; + } + + @Override + public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + boolean continueRunningListenersAndWalk = true; + WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, + instanceLocation, schema, validator); + // Run Listeners that are setup only for this keyword. + List currentKeywordListeners = keywordWalkListenersMap.get(keyword); + continueRunningListenersAndWalk = runPreWalkListeners(currentKeywordListeners, keywordWalkEvent); + if (continueRunningListenersAndWalk) { + // Run Listeners that are setup for all keywords. + runPreWalkListeners(allKeywordWalkListeners, keywordWalkEvent); + } + return continueRunningListenersAndWalk; + } + + @Override + public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + List errors) { + WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, + instanceLocation, schema, validator); + // Run Listeners that are setup only for this keyword. + List currentKeywordListeners = keywordWalkListenersMap.get(keyword); + runPostWalkListeners(currentKeywordListeners, keywordWalkEvent, errors); + // Run Listeners that are setup for all keywords. + runPostWalkListeners(allKeywordWalkListeners, keywordWalkEvent, errors); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Map> keywordWalkListeners = new HashMap<>(); + private List allKeywordWalkListeners = new ArrayList<>(); + + public Builder keywordWalkListener(String keyword, WalkListener keywordWalkListener) { + this.keywordWalkListeners.computeIfAbsent(keyword, key -> new ArrayList<>()).add(keywordWalkListener); + return this; + } + + public Builder keywordWalkListener(Keyword keyword, WalkListener keywordWalkListener) { + return keywordWalkListener(keyword.getValue(), keywordWalkListener); + } + + public Builder keywordWalkListener(WalkListener keywordWalkListener) { + allKeywordWalkListeners.add(keywordWalkListener); + return this; + } + + public Builder keywordWalkListeners(Consumer>> keywordWalkListeners) { + keywordWalkListeners.accept(this.keywordWalkListeners); + return this; + } + + public KeywordWalkListenerRunner build() { + return new KeywordWalkListenerRunner(allKeywordWalkListeners, keywordWalkListeners); + } + } +} diff --git a/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java new file mode 100644 index 000000000..cea2388d9 --- /dev/null +++ b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.walk; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.Schema; +import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.Error; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +/** + * A {@link WalkListenerRunner} for walking properties. + */ +public class PropertyWalkListenerRunner extends AbstractWalkListenerRunner { + + private final List propertyWalkListeners; + + public PropertyWalkListenerRunner(List propertyWalkListeners) { + this.propertyWalkListeners = propertyWalkListeners; + } + + @Override + public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, + schema, validator); + return runPreWalkListeners(propertyWalkListeners, walkEvent); + } + + @Override + public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + List errors) { + WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, + schema, validator); + runPostWalkListeners(propertyWalkListeners, walkEvent, errors); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private List propertyWalkListeners = new ArrayList<>(); + + public Builder propertyWalkListener(WalkListener propertyWalkListener) { + this.propertyWalkListeners.add(propertyWalkListener); + return this; + } + + public Builder propertyWalkListeners(Consumer> propertyWalkListeners) { + propertyWalkListeners.accept(this.propertyWalkListeners); + return this; + } + + public PropertyWalkListenerRunner build() { + return new PropertyWalkListenerRunner(propertyWalkListeners); + } + } +} diff --git a/src/main/java/com/networknt/schema/walk/WalkConfig.java b/src/main/java/com/networknt/schema/walk/WalkConfig.java new file mode 100644 index 000000000..9b8349259 --- /dev/null +++ b/src/main/java/com/networknt/schema/walk/WalkConfig.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.walk; + +import java.util.List; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ApplyDefaultsStrategy; +import com.networknt.schema.Error; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonNodePath; +import com.networknt.schema.Schema; +import com.networknt.schema.keyword.KeywordValidator; + +/** + * Configuration used when walking a schema. + */ +public class WalkConfig { + private static class Holder { + private static final WalkConfig INSTANCE = WalkConfig.builder().build(); + } + + public static WalkConfig getInstance() { + return Holder.INSTANCE; + } + + /** + * {@link WalkListenerRunner} that performs no operations but indicates that it + * should walk. + */ + public static class NoOpWalkListenerRunner implements WalkListenerRunner { + private static class Holder { + private static final NoOpWalkListenerRunner INSTANCE = new NoOpWalkListenerRunner(); + } + + public static NoOpWalkListenerRunner getInstance() { + return Holder.INSTANCE; + } + + @Override + public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + // Always walk + return true; + } + + @Override + public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, + JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + List errors) { + } + } + + /** + * 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 final ApplyDefaultsStrategy applyDefaultsStrategy; + + private final WalkListenerRunner itemWalkListenerRunner; + + private final WalkListenerRunner keywordWalkListenerRunner; + + private final WalkListenerRunner propertyWalkListenerRunner; + + WalkConfig(ApplyDefaultsStrategy applyDefaultsStrategy, WalkListenerRunner itemWalkListenerRunner, + WalkListenerRunner keywordWalkListenerRunner, WalkListenerRunner propertyWalkListenerRunner) { + super(); + this.applyDefaultsStrategy = applyDefaultsStrategy; + this.itemWalkListenerRunner = itemWalkListenerRunner; + this.keywordWalkListenerRunner = keywordWalkListenerRunner; + this.propertyWalkListenerRunner = propertyWalkListenerRunner; + } + + /** + * Gets the strategy for applying defaults. + * + * @return the strategy for applying defaults + */ + public ApplyDefaultsStrategy getApplyDefaultsStrategy() { + return this.applyDefaultsStrategy; + } + + /** + * Gets the property walk listener runner. + * + * @return the property walk listener runner + */ + + public WalkListenerRunner getPropertyWalkListenerRunner() { + return this.propertyWalkListenerRunner; + } + + /** + * Gets the item walk listener runner. + * + * @return the item walk listener runner + */ + public WalkListenerRunner getItemWalkListenerRunner() { + return this.itemWalkListenerRunner; + } + + /** + * Gets the keyword walk listener runner. + * + * @return the keyword walk listener runner + */ + public WalkListenerRunner getKeywordWalkListenerRunner() { + return this.keywordWalkListenerRunner; + } + + /** + * Creates a new builder for {@link WalkConfig}. + * + * @return the builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Creates a new builder for {@link WalkConfig} and copies the configuration. + * + * @param config the configuration to copy + * @return the builder + */ + public static Builder builder(WalkConfig config) { + Builder builder = new Builder(); + builder.applyDefaultsStrategy = config.applyDefaultsStrategy; + builder.itemWalkListenerRunner = config.itemWalkListenerRunner; + builder.keywordWalkListenerRunner = config.keywordWalkListenerRunner; + builder.propertyWalkListenerRunner = config.propertyWalkListenerRunner; + return builder; + } + + /** + * Builder for {@link WalkConfig}. + */ + public static class Builder { + private ApplyDefaultsStrategy applyDefaultsStrategy = null; + private WalkListenerRunner itemWalkListenerRunner = null; + private WalkListenerRunner keywordWalkListenerRunner = null; + private WalkListenerRunner propertyWalkListenerRunner = null; + + /** + * Sets the strategy the walker uses to sets nodes to the default value. + *

+ * Defaults to {@link ApplyDefaultsStrategy#EMPTY_APPLY_DEFAULTS_STRATEGY}. + * + * @param applyDefaultsStrategy the strategy + * @return the builder + */ + public Builder applyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) { + this.applyDefaultsStrategy = applyDefaultsStrategy; + return this; + } + + public Builder itemWalkListenerRunner(WalkListenerRunner itemWalkListenerRunner) { + this.itemWalkListenerRunner = itemWalkListenerRunner; + return this; + } + + public Builder keywordWalkListenerRunner(WalkListenerRunner keywordWalkListenerRunner) { + this.keywordWalkListenerRunner = keywordWalkListenerRunner; + return this; + } + + public Builder propertyWalkListenerRunner(WalkListenerRunner propertyWalkListenerRunner) { + this.propertyWalkListenerRunner = propertyWalkListenerRunner; + return this; + } + + public WalkConfig build() { + return new WalkConfig( + applyDefaultsStrategy != null ? applyDefaultsStrategy + : ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY, + itemWalkListenerRunner != null ? itemWalkListenerRunner : NoOpWalkListenerRunner.getInstance(), + keywordWalkListenerRunner != null ? keywordWalkListenerRunner + : NoOpWalkListenerRunner.getInstance(), + propertyWalkListenerRunner != null ? propertyWalkListenerRunner + : NoOpWalkListenerRunner.getInstance()); + } + } +} diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index fa19b332f..059dee63c 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -7,7 +7,7 @@ import com.networknt.schema.keyword.KeywordValidator; /** - * Encapsulation of Walk data that is passed into the {@link JsonSchemaWalkListener}. + * Encapsulation of Walk data that is passed into the {@link WalkListener}. */ public class WalkEvent { diff --git a/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java b/src/main/java/com/networknt/schema/walk/WalkListener.java similarity index 86% rename from src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java rename to src/main/java/com/networknt/schema/walk/WalkListener.java index 9d18261c9..e1ac73dc5 100644 --- a/src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java +++ b/src/main/java/com/networknt/schema/walk/WalkListener.java @@ -9,7 +9,7 @@ * Listener class that captures walkStart and walkEnd events. * */ -public interface JsonSchemaWalkListener { +public interface WalkListener { WalkFlow onWalkStart(WalkEvent walkEvent); diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 43b58edbe..27ae16609 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -56,9 +56,19 @@ private static String toForwardSlashPath(Path file) { private static void executeTest(Schema schema, TestSpec testSpec) { List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, validationContext) -> { - if (testSpec.getTestCase().getSource().getPath().getParent().toString().endsWith("format")) { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); - } + executionContext.executionConfig(executionConfig -> { + if (testSpec.getConfig() != null) { + if (testSpec.getConfig().containsKey("readOnly")) { + executionConfig.readOnly((Boolean) testSpec.getConfig().get("readOnly")); + } + if (testSpec.getConfig().containsKey("writeOnly")) { + executionConfig.writeOnly((Boolean) testSpec.getConfig().get("writeOnly")); + } + } + if (testSpec.getTestCase().getSource().getPath().getParent().toString().endsWith("format")) { + executionConfig.formatAssertionsEnabled(true); + } + }); }); if (testSpec.isValid()) { @@ -168,10 +178,26 @@ private Stream buildContainer(Version defaultVersion, TestSource te private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { try { - SchemaRegistry validatorFactory = buildValidatorFactory(defaultVersion, testCase); - return dynamicContainer(testCase.getDisplayName(), testCase.getTests().stream().map(testSpec -> { - return buildTest(validatorFactory, testSpec); + // Configure the schemaValidator to set typeLoose's value based on the test file, + // if test file do not contains typeLoose flag, use default value: false. + @SuppressWarnings("deprecation") boolean typeLoose = testSpec.isTypeLoose(); + + SchemaRegistryConfig.Builder configBuilder = SchemaRegistryConfig.builder(); + configBuilder.typeLoose(typeLoose); + configBuilder.regularExpressionFactory( + TestSpec.RegexKind.JDK == testSpec.getRegex() ? JDKRegularExpressionFactory.getInstance() + : JoniRegularExpressionFactory.getInstance()); + testSpec.getStrictness().forEach(configBuilder::strict); + + if (testSpec.getConfig() != null) { + if (testSpec.getConfig().containsKey("isCustomMessageSupported")) { + configBuilder.errorMessageKeyword( + (Boolean) testSpec.getConfig().get("isCustomMessageSupported") ? "message" : null); + } + } + SchemaRegistry schemaRegistry = buildSchemaRegistry(defaultVersion, testCase, configBuilder.build()); + return buildTest(schemaRegistry, testSpec); })); } catch (JsonSchemaException e) { String msg = e.getMessage(); @@ -182,7 +208,7 @@ private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { } } - private SchemaRegistry buildValidatorFactory(Version defaultVersion, TestCase testCase) { + private SchemaRegistry buildSchemaRegistry(Version defaultVersion, TestCase testCase, SchemaRegistryConfig schemaRegistryConfig) { if (testCase.isDisabled()) return null; SchemaLoader schemaLoader = new SchemaLoader() { @Override @@ -208,7 +234,8 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://", "http://") .mapPrefix("http://json-schema.org", "resource:")) - .schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)) + .schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)) + .schemaRegistryConfig(schemaRegistryConfig) .build(); } @@ -217,31 +244,8 @@ private DynamicNode buildTest(SchemaRegistry validatorFactory, TestSpec testSpec return dynamicTest(testSpec.getDescription(), () -> abortAndReset(testSpec.getReason())); } - // Configure the schemaValidator to set typeLoose's value based on the test file, - // if test file do not contains typeLoose flag, use default value: false. - @SuppressWarnings("deprecation") boolean typeLoose = testSpec.isTypeLoose(); - - SchemaValidatorsConfig.Builder configBuilder = SchemaValidatorsConfig.builder(); - configBuilder.typeLoose(typeLoose); - configBuilder.regularExpressionFactory( - TestSpec.RegexKind.JDK == testSpec.getRegex() ? JDKRegularExpressionFactory.getInstance() - : JoniRegularExpressionFactory.getInstance()); - testSpec.getStrictness().forEach(configBuilder::strict); - - if (testSpec.getConfig() != null) { - if (testSpec.getConfig().containsKey("isCustomMessageSupported")) { - configBuilder.errorMessageKeyword( - (Boolean) testSpec.getConfig().get("isCustomMessageSupported") ? "message" : null); - } - if (testSpec.getConfig().containsKey("readOnly")) { - configBuilder.readOnly((Boolean) testSpec.getConfig().get("readOnly")); - } - if (testSpec.getConfig().containsKey("writeOnly")) { - configBuilder.writeOnly((Boolean) testSpec.getConfig().get("writeOnly")); - } - } SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + toForwardSlashPath(testSpec.getTestCase().getSpecification())); - Schema schema = validatorFactory.getSchema(testCaseFileUri, testSpec.getTestCase().getSchema(), configBuilder.build()); + Schema schema = validatorFactory.getSchema(testCaseFileUri, testSpec.getTestCase().getSchema()); return dynamicTest(testSpec.getDescription(), () -> executeAndReset(schema, testSpec)); } diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 6c6cdbde7..375cdd0a8 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -46,8 +46,7 @@ void messageFalse() { + " \"additionalProperties\": false\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" @@ -81,8 +80,7 @@ void messageSchema() { + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index 4564107e2..b2def6495 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -54,14 +54,11 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi return getJsonSchemaFromClasspath(name, schemaVersion, null); } - public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(schemaVersion); + public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaRegistryConfig config) { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(schemaVersion, builder -> builder.schemaRegistryConfig(config)); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); - if (config == null) { - return factory.getSchema(is); - } - return factory.getSchema(is, config); + return factory.getSchema(is); } public static Schema getJsonSchemaFromStringContent(String schemaContent) { diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index bfcd7e501..51395f8a9 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -38,12 +38,17 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BiConsumer; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collector; class CollectorContextTest { - - private static final String SAMPLE_COLLECTOR = "sampleCollector"; - - private static final String SAMPLE_COLLECTOR_OTHER = "sampleCollectorOther"; + enum Data { + SAMPLE_COLLECTOR, + SAMPLE_COLLECTOR_OTHER + } private Schema jsonSchema; @@ -54,12 +59,11 @@ void setup() throws Exception { setupSchema(); } - @SuppressWarnings("unchecked") @Test void testCollectorContextWithKeyword() throws Exception { ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); Assertions.assertEquals(0, validationResult.getErrors().size()); - List contextValues = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); + List contextValues = validationResult.getCollectorContext().get(Data.SAMPLE_COLLECTOR); contextValues.sort(null); Assertions.assertEquals(0, validationResult.getErrors().size()); Assertions.assertEquals(2, contextValues.size()); @@ -67,7 +71,6 @@ void testCollectorContextWithKeyword() throws Exception { Assertions.assertEquals(contextValues.get(1), "actual_value_added_to_context2"); } - @SuppressWarnings("unchecked") @Test void testCollectorContextWithMultipleThreads() throws Exception { @@ -98,45 +101,41 @@ void testCollectorContextWithMultipleThreads() throws Exception { Assertions.assertEquals(0, validationResult2.getErrors().size()); Assertions.assertEquals(0, validationResult3.getErrors().size()); - List contextValue1 = (List) validationResult1.getCollectorContext().get(SAMPLE_COLLECTOR); - List contextValue2 = (List) validationResult2.getCollectorContext().get(SAMPLE_COLLECTOR); - List contextValue3 = (List) validationResult3.getCollectorContext().get(SAMPLE_COLLECTOR); + List contextValue1 = validationResult1.getCollectorContext().get(Data.SAMPLE_COLLECTOR); + List contextValue2 = validationResult2.getCollectorContext().get(Data.SAMPLE_COLLECTOR); + List contextValue3 = validationResult3.getCollectorContext().get(Data.SAMPLE_COLLECTOR); Assertions.assertEquals(contextValue1.get(0), "actual_value_added_to_context1"); Assertions.assertEquals(contextValue2.get(0), "actual_value_added_to_context2"); Assertions.assertEquals(contextValue3.get(0), "actual_value_added_to_context3"); } - @SuppressWarnings("unchecked") @Test void testCollectorGetAll() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ExecutionContext executionContext = jsonSchemaForCombine.createExecutionContext(); - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); jsonSchemaForCombine.validate(executionContext, objectMapper .readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }")); ValidationResult validationResult = new ValidationResult(executionContext); CollectorContext collectorContext = validationResult.getCollectorContext(); - collectorContext.loadCollectors(); - Assertions.assertEquals(((List) collectorContext.get(SAMPLE_COLLECTOR)).size(), 1); - Assertions.assertEquals(((List) collectorContext.get(SAMPLE_COLLECTOR_OTHER)).size(), 3); + List sampleCollector = collectorContext.get(Data.SAMPLE_COLLECTOR); + List sampleCollectorOther = collectorContext.get(Data.SAMPLE_COLLECTOR_OTHER); + Assertions.assertEquals(sampleCollector.size(), 1); + Assertions.assertEquals(sampleCollectorOther.size(), 3); } - - private Dialect getJsonMetaSchema(String uri) throws Exception { - Dialect jsonMetaSchema = Dialect.builder(uri, Dialects.getDraft201909()) - .keyword(new CustomKeyword()).keyword(new CustomKeyword1()).format(new Format() { - @SuppressWarnings("unchecked") - @Override - public boolean matches(ExecutionContext executionContext, String value) { - CollectorContext collectorContext = executionContext.getCollectorContext(); - if (collectorContext.get(SAMPLE_COLLECTOR) == null) { - collectorContext.add(SAMPLE_COLLECTOR, new ArrayList()); - } - List returnList = (List) collectorContext.get(SAMPLE_COLLECTOR); - returnList.add(value); - return true; - } + private Dialect getDialect(String uri) throws Exception { + Dialect dialect = Dialect.builder(uri, Dialects.getDraft201909()) + .keyword(new CustomKeyword()).keyword(new CustomKeyword1()).format(new Format() { + @Override + public boolean matches(ExecutionContext executionContext, String value) { + CollectorContext collectorContext = executionContext.getCollectorContext(); + List returnList = collectorContext.computeIfAbsent(Data.SAMPLE_COLLECTOR, + key -> new ArrayList()); + returnList.add(value); + return true; + } @Override public String getName() { @@ -149,16 +148,15 @@ public String getErrorMessageDescription() { return null; } }).build(); - return jsonMetaSchema; + return dialect; } private void setupSchema() throws Exception { - final Dialect dialect = getJsonMetaSchema( + final Dialect dialect = getDialect( "https://github.com/networknt/json-schema-validator/tests/schemas/example01"); final SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().build(); - this.jsonSchema = schemaFactory.getSchema(getSchemaString(), schemaValidatorsConfig); - this.jsonSchemaForCombine = schemaFactory.getSchema(getSchemaStringMultipleProperties(), schemaValidatorsConfig); + this.jsonSchema = schemaFactory.getSchema(getSchemaString()); + this.jsonSchemaForCombine = schemaFactory.getSchema(getSchemaStringMultipleProperties()); } private String getSchemaString() { @@ -282,47 +280,67 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath * document again just for gathering this kind of information. */ private class CustomValidator extends AbstractKeywordValidator { + private final CustomCollector customCollector = new CustomCollector(); public CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { super(new CustomKeyword(), schemaNode, schemaLocation, evaluationPath); } - @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { - CollectorContext collectorContext = executionContext.getCollectorContext(); - CustomCollector customCollector = (CustomCollector) collectorContext.getCollectorMap().computeIfAbsent(SAMPLE_COLLECTOR, - key -> new CustomCollector()); - customCollector.combine(node.textValue()); - } + @Override + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + JsonNodePath instanceLocation) { + CollectorContext collectorContext = executionContext.getCollectorContext(); + List result = collectorContext.computeIfAbsent(Data.SAMPLE_COLLECTOR, + key -> customCollector.supplier().get()); + customCollector.accumulator().accept(result, node); + } @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { // Ignore this method for testing. } } - - private class CustomCollector extends AbstractCollector> { - - List returnList = new ArrayList(); - + private class CustomCollector implements Collector, List> { private Map referenceMap = null; public CustomCollector() { - referenceMap = getDatasourceMap(); + this(getDatasourceMap()); } - - @Override - public List collect() { - return returnList; - } - - @Override - public void combine(Object object) { - synchronized (returnList) { - returnList.add(referenceMap.get((String) object)); - } + + public CustomCollector(Map referenceMap) { + this.referenceMap = referenceMap; } + @Override + public Supplier> supplier() { + return ArrayList::new; + } + + @Override + public BiConsumer, JsonNode> accumulator() { + return (returnList, instanceNode) -> { + synchronized (returnList) { + returnList.add(referenceMap.get(instanceNode.textValue())); + } + }; + } + + @Override + public BinaryOperator> combiner() { + return (left, right) -> { + left.addAll(right); + return left; + }; + } + + @Override + public Function, List> finisher() { + return Function.identity(); + } + + @Override + public Set characteristics() { + return Collections.unmodifiableSet(EnumSet.of(Characteristics.IDENTITY_FINISH)); + } } /** @@ -358,15 +376,15 @@ public CustomValidator1(SchemaLocation schemaLocation, JsonNodePath evaluationPa super(new CustomKeyword(), schemaNode,schemaLocation, evaluationPath); } - @SuppressWarnings("unchecked") @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + JsonNodePath instanceLocation) { // Get an instance of collector context. CollectorContext collectorContext = executionContext.getCollectorContext(); // If collector type is not added to context add one. - List returnList = (List) collectorContext.getCollectorMap() - .computeIfAbsent(SAMPLE_COLLECTOR_OTHER, key -> new ArrayList()); - synchronized(returnList) { + List returnList = collectorContext.computeIfAbsent(Data.SAMPLE_COLLECTOR_OTHER, + key -> new ArrayList()); + synchronized (returnList) { returnList.add(node.textValue()); } } @@ -381,11 +399,10 @@ private ValidationResult validate(String jsonData) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ExecutionContext executionContext = this.jsonSchema.createExecutionContext(); this.jsonSchema.validate(executionContext, objectMapper.readTree(jsonData)); - executionContext.getCollectorContext().loadCollectors(); return new ValidationResult(executionContext); } - private Map getDatasourceMap() { + protected static Map getDatasourceMap() { Map map = new HashMap(); map.put("sample1", "actual_value_added_to_context1"); map.put("sample2", "actual_value_added_to_context2"); @@ -396,16 +413,14 @@ private Map getDatasourceMap() { @Test void constructor() { CollectorContext context = new CollectorContext(); - assertTrue(context.getCollectorMap().isEmpty()); - assertTrue(context.getAll().isEmpty()); + assertTrue(context.getData().isEmpty()); } @Test void constructorWithMap() { - ConcurrentHashMap collectorMap = new ConcurrentHashMap<>(); - ConcurrentHashMap collectorLoadMap = new ConcurrentHashMap<>(); - CollectorContext context = new CollectorContext(collectorMap, collectorLoadMap); - assertSame(collectorMap, context.getCollectorMap()); + ConcurrentHashMap data = new ConcurrentHashMap<>(); + CollectorContext context = new CollectorContext(data); + assertSame(data, context.getData()); } private class CollectKeyword implements Keyword { @@ -433,7 +448,7 @@ private class CollectValidator extends AbstractKeywordValidator { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { // Get an instance of collector context. CollectorContext collectorContext = executionContext.getCollectorContext(); - AtomicInteger count = (AtomicInteger) collectorContext.getCollectorMap().computeIfAbsent("collect", + AtomicInteger count = collectorContext.computeIfAbsent("collect", (key) -> new AtomicInteger(0)); count.incrementAndGet(); } @@ -443,7 +458,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root JsonNodePath instanceLocation, boolean shouldValidateSchema) { if (!shouldValidateSchema) { CollectorContext collectorContext = executionContext.getCollectorContext(); - AtomicInteger count = (AtomicInteger) collectorContext.getCollectorMap().computeIfAbsent("collect", + AtomicInteger count = (AtomicInteger) collectorContext.getData().computeIfAbsent("collect", (key) -> new AtomicInteger(0)); count.incrementAndGet(); } @@ -453,7 +468,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root @Test void concurrency() throws Exception { - CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" @@ -494,14 +509,13 @@ public void run() { if (instance[0] != null) { throw instance[0]; } - collectorContext.loadCollectors(); - AtomicInteger result = (AtomicInteger) collectorContext.get("collect"); + AtomicInteger result = collectorContext.get("collect"); assertEquals(50, result.get()); } @Test void iterate() { - CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" @@ -512,14 +526,13 @@ void iterate() { executionContext.setCollectorContext(collectorContext); }); } - collectorContext.loadCollectors(); - AtomicInteger result = (AtomicInteger) collectorContext.get("collect"); + AtomicInteger result = collectorContext.get("collect"); assertEquals(50, result.get()); } @Test void iterateWalk() { - CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" @@ -530,14 +543,13 @@ void iterateWalk() { executionContext.setCollectorContext(collectorContext); }); } - collectorContext.loadCollectors(); - AtomicInteger result = (AtomicInteger) collectorContext.get("collect"); + AtomicInteger result = collectorContext.get("collect"); assertEquals(50, result.get()); } @Test void iterateWalkValidate() { - CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); + CollectorContext collectorContext = new CollectorContext(new ConcurrentHashMap<>()); Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(new CollectKeyword()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); Schema schema = factory.getSchema("{\n" @@ -548,8 +560,7 @@ void iterateWalkValidate() { executionContext.setCollectorContext(collectorContext); }); } - collectorContext.loadCollectors(); - AtomicInteger result = (AtomicInteger) collectorContext.get("collect"); + AtomicInteger result = collectorContext.get("collect"); assertEquals(50, result.get()); } diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index 4b0bb887a..ed711a62d 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -36,10 +36,10 @@ void localeMessageOthers() { String schemaData = "{\r\n" + " \"const\": \"aa\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -50,10 +50,10 @@ void localeMessageNumber() { String schemaData = "{\r\n" + " \"const\": 1\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -64,8 +64,8 @@ void validOthers() { String schemaData = "{\r\n" + " \"const\": \"aa\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,8 +76,7 @@ void validNumber() { String schemaData = "{\r\n" + " \"const\": 1234.56789\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -88,8 +87,7 @@ void invalidNumber() { String schemaData = "{\r\n" + " \"const\": 1234.56789\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index 4c5c06fb8..0d60571c1 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -55,14 +55,13 @@ void annotationCollection() throws JsonProcessingException { + " }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "\"helloworld\""; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":true,\"details\":[{\"valid\":true,\"evaluationPath\":\"\",\"schemaLocation\":\"#\",\"instanceLocation\":\"\",\"annotations\":{\"contentMediaType\":\"application/jwt\",\"contentSchema\":{\"type\":\"array\",\"minItems\":2,\"prefixItems\":[{\"const\":{\"typ\":\"JWT\",\"alg\":\"HS256\"}},{\"type\":\"object\",\"required\":[\"iss\",\"exp\"],\"properties\":{\"iss\":{\"type\":\"string\"},\"exp\":{\"type\":\"integer\"}}}]}}}]}"; diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 8029eee63..c067e438c 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -136,6 +136,6 @@ void customMetaSchemaWithIgnoredKeyword() throws IOException { assertEquals(1, messages.size()); Error message = messages.iterator().next(); - assertEquals("$: enumName is Foo !", message.toString()); + assertEquals(": enumName is Foo !", message.toString()); } } diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index 55b0aca3a..d403b47f5 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -32,8 +32,7 @@ void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { " ]\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = schemaFactory.getSchema(SchemaLocation.of("resource:/draft4/issue258/Master.json"), config); + Schema schema = schemaFactory.getSchema(SchemaLocation.of("resource:/draft4/issue258/Master.json")); assertEquals(0, schema.validate(new ObjectMapper().readTree(jsonObject)).size()); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index 5bed18c2d..af82e38e2 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -31,13 +31,13 @@ class DefaultJsonSchemaIdValidatorTest { void givenRelativeIdShouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); try { - SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } @@ -47,28 +47,28 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"#0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @Test void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"/base\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @Test void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12) - .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"), config)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"))); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 9ee613efc..6dd69a2e8 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -47,7 +47,7 @@ void shouldReturnErrorMessageForObjectWithoutDependentRequiredField() throws IOE assertThat( messages.stream().map(Error::toString).collect(Collectors.toList()), - contains("$: has a missing property 'requiredWhenOptionalPresent' which is dependent required because 'optional' is present")); + contains(": has a missing property 'requiredWhenOptionalPresent' which is dependent required because 'optional' is present")); } @Test diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 53a781b9c..b70feac2a 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialects; /** * Test for discriminator. @@ -115,9 +115,8 @@ void discriminatorInArray() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -147,9 +146,8 @@ void anyOfWithConfigEnabledButNoDiscriminator() { + " \"intOrStringType\": 4\r\n" + " }"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -240,9 +238,8 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -333,9 +330,8 @@ void discriminatorInArrayInvalidDiscriminatorPropertyOneOf() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); } @@ -423,9 +419,8 @@ void discriminatorInArrayOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -519,9 +514,8 @@ void discriminatorInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -619,9 +613,8 @@ void discriminatorMappingInOneOfShouldOnlyReportErrorsInMatchingDiscriminator() + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); // Only the oneOf and the error in the BedRoom discriminator is reported // the mismatch in Kitchen is not reported @@ -674,9 +667,8 @@ void oneOfMissingDiscriminatorValue() { String inputData = "{}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); List list = messages.stream().collect(Collectors.toList()); @@ -770,9 +762,8 @@ void anyOfMissingDiscriminatorValue() { + " }\r\n" + "]"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); assertEquals("required", list.get(0).getKeyword()); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 5fd2f7c6c..44c423dac 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -41,7 +41,7 @@ void durationFormatValidatorTest() throws IOException { assertEquals(0, messages.size()); messages = validatorSchema.validate(invalidTargetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index 4c824085f..b31824415 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -85,8 +85,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().build()); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); Error message = messages.get(0); @@ -105,8 +104,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().build()); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); Error message = messages.get(0); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index c23e07a3d..2b3e9a81e 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -51,8 +51,10 @@ void errorMessage() { + " \"foo\": \"a\",\r\n" + " \"bar\": 2\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("errorMessage").build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); assertEquals("/foo", messages.get(0).getInstanceLocation().toString()); @@ -81,8 +83,8 @@ void errorMessageUnionType() { String inputData = "{\r\n" + " \"keyword1\": 2\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().errorMessageKeyword("errorMessage").build()); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("errorMessage").build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); assertEquals("/keyword1", messages.get(0).getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 68fc6c82e..ce914bfd5 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -31,8 +31,7 @@ void exampleSchemaLocation() { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json"), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -41,21 +40,20 @@ void exampleSchemaLocation() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getDialect().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 Schema refSchema = schema.getValidationContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getDialect().getIri()); } @Test void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -64,12 +62,12 @@ void exampleClasspath() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getDialect().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 Schema refSchema = schema.getValidationContext().getSchemaResources().get("classpath:schema/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getDialect().getIri()); } } diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index f6f20d27c..3f4f56dbb 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -45,7 +45,7 @@ void unknownFormatNoVocab() { + "}"; Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertEquals(0, messages.size()); } @@ -55,10 +55,10 @@ void unknownFormatNoVocabStrictTrue() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().strict("format", true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().strict("format", true).build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertEquals(1, messages.size()); assertEquals("format.unknown", messages.iterator().next().getMessageKey()); @@ -84,12 +84,11 @@ void unknownFormatAssertionsVocab() { + " \"$schema\": \"https://www.example.com/format-assertion/schema\",\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); Schema schema = SchemaRegistry .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) - .getSchema(schemaData, config); + .getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("format.unknown", messages.iterator().next().getMessageKey()); @@ -101,10 +100,11 @@ void unknownFormatShouldCollectAnnotations() { + " \"format\":\"unknown\"\r\n" + "}"; Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); - OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, + executionContext -> { + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); assertEquals("unknown", outputUnit.getAnnotations().get("format")); assertTrue(outputUnit.isValid()); // as no assertion vocab and assertions not enabled } @@ -144,10 +144,9 @@ void formatAssertions(FormatInput formatInput) { + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); + executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertFalse(messages.isEmpty()); } @@ -172,10 +171,9 @@ void patternFormatDeprecated() { + " \"type\": \"string\",\r\n" + " \"format\": \"custom\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); + executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertFalse(messages.isEmpty()); assertEquals(": does not match the custom pattern must be test", messages.iterator().next().toString()); @@ -190,7 +188,7 @@ static class CustomNumberFormat implements Format { @Override public boolean matches(ExecutionContext executionContext, ValidationContext validationContext, JsonNode value) { - JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getSchemaRegistryConfig()); if (nodeType != JsonType.NUMBER && nodeType != JsonType.INTEGER) { return true; } @@ -220,15 +218,14 @@ void shouldAllowNumberFormat() { + " \"type\": \"number\",\r\n" + " \"format\": \"custom-number\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); List messages = schema.validate("123451", InputFormat.JSON, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); + executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertFalse(messages.isEmpty()); assertEquals(": does not match the custom-number pattern ", messages.iterator().next().toString()); messages = schema.validate("12345", InputFormat.JSON, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); + executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertTrue(messages.isEmpty()); @@ -241,7 +238,7 @@ void draft7DisableFormat() { + "}"; Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(false); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(false)); }); assertEquals(0, messages.size()); } diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 20fe50fb6..5e5ff72c6 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -26,7 +26,9 @@ import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.ValidatorTypeCode; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -48,9 +50,8 @@ void walkValidateThen() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -61,18 +62,21 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) .build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); - @SuppressWarnings("unchecked") - List types = (List) result.getExecutionContext().getCollectorContext().get("types"); + List types = result.getExecutionContext().getCollectorContext().get("types"); assertEquals(1, types.size()); assertEquals("", types.get(0).getInstanceLocation().toString()); assertEquals("/then", types.get(0).getSchema().getEvaluationPath().toString()); @@ -91,9 +95,8 @@ void walkValidateElse() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -104,14 +107,18 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) .build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk("\"hello\"", InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk("\"hello\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -134,9 +141,8 @@ void walkValidateNull() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -147,14 +153,18 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) .build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -175,9 +185,8 @@ void walkNoValidate() { + " \"type\": \"number\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -188,14 +197,18 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List types = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) .build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, false); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, false, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 1116d820d..099e77278 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -31,10 +31,10 @@ class Issue1091Test { @Test @Disabled // Disabled as this test takes quite long to run for ci void testHasAdjacentKeywordInEvaluationPath() throws Exception { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().cacheRefs(false).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4) - .getSchema(SchemaLocation.of("classpath:schema/issue1091.json"), config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) + .getSchema(SchemaLocation.of("classpath:schema/issue1091.json")); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index da6412a13..3c75d1d70 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -32,7 +32,7 @@ void propertyNameEnumShouldFailV7() throws Exception { List errors = schema.validate(node); Assertions.assertEquals(1, errors.size()); final Error error = errors.iterator().next(); - Assertions.assertEquals("$", error.getInstanceLocation().toString()); - Assertions.assertEquals("$: property 'z' name is not valid: does not have a value in the enumeration [\"a\", \"b\", \"c\"]", error.toString()); + Assertions.assertEquals("", error.getInstanceLocation().toString()); + Assertions.assertEquals(": property 'z' name is not valid: does not have a value in the enumeration [\"a\", \"b\", \"c\"]", error.toString()); } } diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 33db63070..121a2f8bf 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -22,17 +22,16 @@ void setup() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); private void setupSchema() throws IOException { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder() .failFast(true) .typeLoose(false) .build(); - SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); JsonNode testCases = objectMapper.readValue(in, JsonNode.class); - this.jsonSchema = schemaFactory.getSchema(uri, testCases, schemaValidatorsConfig); + this.jsonSchema = schemaFactory.getSchema(uri, testCases); } protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception { diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 002bf4726..18163f8c2 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -24,16 +24,14 @@ void setup() throws IOException { private void setupSchema() throws IOException { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().typeLoose(false).build(); - SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)) - .build(); + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().typeLoose(false).build(); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); JsonNode testCases = objectMapper.readValue(in, JsonNode.class); - this.jsonSchema = schemaFactory.getSchema(uri, testCases, schemaValidatorsConfig); + this.jsonSchema = schemaFactory.getSchema(uri, testCases); } protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception { diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index eb029b16c..8f6ee999b 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -52,9 +52,9 @@ void shouldFailAndShowValidationValuesWithError() throws Exception { } List expectedMessages = Arrays.asList( - "$.fields: property 'longName123' name is not valid: must be at most 5 characters long", - "$.fields: property 'longName123' name is not valid: does not match the regex pattern ^[a-zA-Z]+$", - "$.fields: property 'a' name is not valid: must be at least 3 characters long"); + "/fields: property 'longName123' name is not valid: must be at most 5 characters long", + "/fields: property 'longName123' name is not valid: does not match the regex pattern ^[a-zA-Z]+$", + "/fields: property 'a' name is not valid: must be at least 3 characters long"); MatcherAssert.assertThat(errorMessages, Matchers.containsInAnyOrder(expectedMessages.toArray())); } } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index cc7496675..65724aa3e 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -13,7 +13,8 @@ */ class Issue426Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("message").build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index 29f755d24..e61ff943c 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -14,8 +14,6 @@ class Issue428Test { protected ObjectMapper mapper = new ObjectMapper(); - protected SchemaRegistry validatorFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)).build(); private void runTestFile(String testCaseFile) throws Exception { final SchemaLocation testCaseFileUri = SchemaLocation.of("classpath:" + testCaseFile); @@ -35,10 +33,12 @@ private void runTestFile(String testCaseFile) throws Exception { JsonNode typeLooseNode = test.get("isTypeLoose"); // Configure the schemaValidator to set typeLoose's value based on the test file, // if test file do not contains typeLoose flag, use default value: true. - SchemaValidatorsConfig.Builder configBuilder = SchemaValidatorsConfig.builder(); + SchemaRegistryConfig.Builder configBuilder = SchemaRegistryConfig.builder(); configBuilder.typeLoose(typeLooseNode != null && typeLooseNode.asBoolean()); - configBuilder.discriminatorKeywordEnabled(false); - Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); + SchemaRegistryConfig config = configBuilder.build(); + + SchemaRegistry validatorFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema")); List errors = new ArrayList(schema.validate(node)); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 114a67b2a..051130f39 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -2,7 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.PropertyWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; import org.junit.jupiter.api.Assertions; @@ -19,13 +21,11 @@ class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; - + protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); - SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() - .propertyWalkListener(new CountingWalker()) - .build(); - return factory.getSchema(schemaContent, svc); + return factory.getSchema(schemaContent); } protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception { @@ -58,7 +58,9 @@ private void walk(JsonNode data, boolean shouldValidate) { InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); Schema schema = getJsonSchemaFromStreamContentV7(schemaInputStream); - CollectorContext collectorContext = schema.walk(data, shouldValidate).getCollectorContext(); + WalkConfig walkConfig = WalkConfig.builder().propertyWalkListenerRunner( + PropertyWalkListenerRunner.builder().propertyWalkListener(new CountingWalker()).build()).build(); + CollectorContext collectorContext = schema.walk(data, shouldValidate, executionContext -> executionContext.setWalkConfig(walkConfig)).getCollectorContext(); Map collector = (Map) collectorContext.get(COLLECTOR_ID); Assertions.assertEquals(2, @@ -68,7 +70,7 @@ private void walk(JsonNode data, boolean shouldValidate) { } - private static class CountingWalker implements JsonSchemaWalkListener { + private static class CountingWalker implements WalkListener { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { SchemaLocation path = walkEvent.getSchema().getSchemaLocation(); @@ -86,7 +88,7 @@ private Map collector(ExecutionContext executionContext) { Map collector = (Map) executionContext.getCollectorContext().get(COLLECTOR_ID); if(collector == null) { collector = new HashMap<>(); - executionContext.getCollectorContext().add(COLLECTOR_ID, collector); + executionContext.getCollectorContext().put(COLLECTOR_ID, collector); } return collector; diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 67e8c61b9..458866637 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -4,7 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.serialization.JsonMapperFactory; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; import org.junit.jupiter.api.Assertions; @@ -18,24 +20,28 @@ class Issue461Test { protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); - SchemaValidatorsConfig svc = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) - .build(); - return factory.getSchema(schemaUri, svc); + return factory.getSchema(schemaUri); } @Test void shouldWalkWithValidation() throws IOException { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) + .build(); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + Schema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); JsonNode data = mapper.readTree(Issue461Test.class.getResource("/data/issue461-v7.json")); - ValidationResult result = schema.walk(data, true); + ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); Assertions.assertTrue(result.getErrors().isEmpty()); } /** * Example NOP walker */ - private static class Walker implements JsonSchemaWalkListener { + private static class Walker implements WalkListener { @Override public WalkFlow onWalkStart(final WalkEvent walkEvent) { return WalkFlow.CONTINUE; diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 83c459549..427e5644b 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -32,12 +32,14 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.keyword.ValidatorTypeCode; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.PropertyWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; class Issue467Test { - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); private static final String schemaPath = "/schema/issue467.json"; protected ObjectMapper mapper = new ObjectMapper(); @@ -46,8 +48,8 @@ class Issue467Test { void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); - final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { properties.add(walkEvent.getSchema().getEvaluationPath().append(walkEvent.getKeyword())); @@ -59,9 +61,13 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); - Schema schema = factory.getSchema(schemaInputStream, config); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); - ValidationResult result = schema.walk(data, true); + ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals(new HashSet<>(Arrays.asList("/properties", "/properties/tags/items/0/properties")), properties.stream().map(Object::toString).collect(Collectors.toSet())); assertEquals(1, result.getErrors().size()); @@ -71,8 +77,8 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { void shouldWalkPropertiesWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); - final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .propertyWalkListener(new JsonSchemaWalkListener() { + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() + .propertyWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { properties.add(walkEvent.getSchema().getEvaluationPath()); @@ -84,9 +90,13 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { } }) .build(); - Schema schema = factory.getSchema(schemaInputStream, config); + WalkConfig walkConfig = WalkConfig.builder() + .propertyWalkListenerRunner(propertyWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); - ValidationResult result = schema.walk(data, true); + ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals( new HashSet<>(Arrays.asList("/properties/tags", "/properties/tags/items/0/properties/category", "/properties/tags/items/0/properties/value")), properties.stream().map(Object::toString).collect(Collectors.toSet())); diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index be6210021..8d4d6aba1 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -53,8 +53,7 @@ class Issue475Test { void draft4() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -67,8 +66,7 @@ void draft4() throws Exception { void draft6() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -81,8 +79,7 @@ void draft6() throws Exception { void draft7() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -95,8 +92,7 @@ void draft7() throws Exception { void draft201909() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); @@ -109,8 +105,7 @@ void draft201909() throws Exception { void draft202012() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12), config); + Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); assertEquals(2, assertions.size()); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index 54652d8fe..b4f7ab83e 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -69,8 +69,8 @@ void testInvalidJson1 () allErrorMessages.add(vm.toString()); }); assertThat(allErrorMessages, - Matchers.containsInAnyOrder("$.parameters[0].value: string found, integer expected", - "$.parameters[0].value: does not match the regex pattern ^\\{\\{.+\\}\\}$")); + Matchers.containsInAnyOrder("/parameters/0/value: string found, integer expected", + "/parameters/0/value: does not match the regex pattern ^\\{\\{.+\\}\\}$")); } @Test @@ -89,9 +89,9 @@ void testInvalidJson2 () allErrorMessages.add(vm.toString()); }); assertThat(allErrorMessages, Matchers.containsInAnyOrder( - "$.parameters[1].value: string found, integer expected", - "$.parameters[1].value: does not match the regex pattern ^\\{\\{.+\\}\\}$", - "$.parameters[1]: must be valid to one and only one schema, but 0 are valid" + "/parameters/1/value: string found, integer expected", + "/parameters/1/value: does not match the regex pattern ^\\{\\{.+\\}\\}$", + "/parameters/1: must be valid to one and only one schema, but 0 are valid" )); } } diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index 81f12349e..d82283c4c 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -11,6 +11,6 @@ void failure() { JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); - assertEquals("Unknown MetaSchema: true", ex.getMessage()); + assertEquals("Unknown dialect: true", ex.getMessage()); } } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index c29dc1ca1..22e09467c 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -122,7 +122,7 @@ static Stream invalidTimeRepresentations() { @MethodSource("invalidTimeRepresentations") void testInvalidTimeRepresentations(String jsonObject) throws JsonProcessingException { List errors = schema.validate(new ObjectMapper().readTree(jsonObject), OutputFormat.DEFAULT, (executionContext, validationContext) -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); Assertions.assertFalse(errors.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index f5a23fb32..0c4b207c5 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -1,6 +1,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.walk.WalkConfig; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -8,14 +10,13 @@ class Issue604Test { @Test void failure() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) - .build(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); - Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); + Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }"); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { - schema.walk(objectMapper.readTree("{}"), false); + schema.walk(objectMapper.readTree("{}"), false, executionContext -> executionContext.setWalkConfig(walkConfig)); }); } diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index 07ebdd0a7..f911de7df 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -48,9 +48,9 @@ void testCorrectErrorForInvalidValue() throws IOException { // Omitting the 'object found, null expected' message also provides the misleading impression that the // object is required when leaving it empty is a possible option assertTrue(errorMessages - .contains("$.properties.optionalObject.anyOf[0].type = $.optionalObject: object found, null expected")); + .contains("/properties/optionalObject/anyOf/0/type = /optionalObject: object found, null expected")); assertTrue(errorMessages.contains( - "$.properties.optionalObject.anyOf[1].properties.value.enum = $.optionalObject.value: does not have a value in the enumeration [\"one\", \"two\"]")); + "/properties/optionalObject/anyOf/1/properties/value/enum = /optionalObject/value: does not have a value in the enumeration [\"one\", \"two\"]")); } private static String resource(String name) { diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index d692cc4cc..32045742f 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -18,13 +18,13 @@ class Issue686Test { @Test void testDefaults() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); assertEquals(DefaultMessageSource.getInstance(), config.getMessageSource()); } @Test void testValidationWithDefaultBundleAndLocale() throws JsonProcessingException { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); ResourceBundle resourceBundle = ResourceBundle.getBundle(DefaultMessageSource.BUNDLE_BASE_NAME, Locale.getDefault()); String expectedMessage = new MessageFormat(resourceBundle.getString("type")).format(new String[] {"integer", "string"}); verify(config, "/foo: " + expectedMessage); @@ -32,13 +32,13 @@ void testValidationWithDefaultBundleAndLocale() throws JsonProcessingException { @Test void testValidationWithDefaultBundleAndCustomLocale() throws JsonProcessingException { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ITALIAN).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.ITALIAN).build(); verify(config, "/foo: integer trovato, string previsto"); } @Test void testValidationWithCustomBundle() throws JsonProcessingException { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .messageSource(new ResourceBundleMessageSource("issue686/translations")) .locale(Locale.FRENCH) .build(); @@ -47,18 +47,18 @@ void testValidationWithCustomBundle() throws JsonProcessingException { @Test void testLocaleSwitch() throws JsonProcessingException { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ITALIAN).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.ITALIAN).build(); verify(config, "/foo: integer trovato, string previsto"); - SchemaValidatorsConfig config2 = SchemaValidatorsConfig.builder().locale(Locale.FRENCH).build(); + SchemaRegistryConfig config2 = SchemaRegistryConfig.builder().locale(Locale.FRENCH).build(); verify(config2, "/foo: integer trouvé, string attendu"); } - private Schema getSchema(SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); - return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", config); + private Schema getSchema(SchemaRegistryConfig config) { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); + return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }"); } - private void verify(SchemaValidatorsConfig config, String expectedMessage) throws JsonProcessingException { + private void verify(SchemaRegistryConfig config, String expectedMessage) throws JsonProcessingException { List messages = getSchema(config).validate(new ObjectMapper().readTree(" { \"foo\": 123 } ")); assertEquals(1, messages.size()); assertEquals(expectedMessage, messages.iterator().next().toString()); diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index e9bafbe4b..9811273c4 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -80,9 +80,9 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin @ParameterizedTest @MethodSource("errors") void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().pathType(pathType).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); - Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath), config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(pathType).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); + Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath)); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); for (String expectedPath: expectedMessagePaths) { @@ -113,8 +113,8 @@ static Stream specialCharacterTests() { @MethodSource("specialCharacterTests") void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().pathType(pathType).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09) + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().pathType(pathType).build(); + Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + @@ -123,7 +123,7 @@ void testSpecialCharacters(PathType pathType, String propertyName, String expect " \"type\": \"boolean\"\n" + " }\n" + " }\n" + - "}"), schemaValidatorsConfig); + "}")); List errors = schema.validate(mapper.readTree("{\""+propertyName+"\": 1}")); assertEquals(1, errors.size()); assertEquals(expectedPath, errors.iterator().next().getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index 5a16f60d2..b663d356c 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -22,7 +24,7 @@ class Issue724Test { @Test void test() throws JsonProcessingException { StringCollector stringCollector = new StringCollector(); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().keywordWalkListener(stringCollector).build(); + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder().keywordWalkListener(stringCollector).build(); String schema = "{\n" @@ -49,15 +51,17 @@ void test() throws JsonProcessingException { + " \"credit_card\" : \"my_credit_card\",\n" + " \"billing_address\" : \"my_billing_address\"\n" + "}\n"; - - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); - jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema); + jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false, executionContext -> executionContext.setWalkConfig(walkConfig)); System.out.println(stringCollector.strings); assertLinesMatch(Arrays.asList("my_credit_card", "my_billing_address"), stringCollector.strings); } - static class StringCollector implements JsonSchemaWalkListener { + static class StringCollector implements WalkListener { final List strings = new ArrayList<>(); @Override diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index 3598bc534..fd0d6ce2b 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -12,7 +12,9 @@ class Issue792 { @Test void test() throws JsonProcessingException { - SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(false).failFast(true).build(); + + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); String schemaDef = "{\n" + @@ -28,9 +30,7 @@ void test() throws JsonProcessingException { " }\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(false).failFast(true).build(); - - Schema jsonSchema = schemaFactory.getSchema(schemaDef, config); + Schema jsonSchema = schemaFactory.getSchema(schemaDef); JsonNode jsonNode = new ObjectMapper().readTree("{\"field\": \"pattern-violation\"}"); assertEquals(1, jsonSchema.validate(jsonNode).size()); diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index 84aca49ab..ffe38783e 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -48,9 +48,9 @@ void test() { + " \"id\": \"4\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - List result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().failFast(true).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + List result = factory.getSchema(schema).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index ac0811e6e..ca31033f6 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -13,7 +13,7 @@ class Issue898Test extends BaseJsonSchemaValidatorTest { @Test void testMessagesWithSingleQuotes() throws Exception { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.FRENCH).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.FRENCH).build(); Schema schema = getJsonSchemaFromClasspath("schema/issue898.json", Specification.Version.DRAFT_2020_12, config); JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index 308db2790..c22dfd0ea 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -27,13 +27,13 @@ class Issue936Test { void shouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config)); + () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); try { - SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema, config); + SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index 334b9aa57..4402626ad 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -69,8 +69,7 @@ void test() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); assertTrue(schema.validate(inputData, InputFormat.JSON).isEmpty()); String badData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index b1814efdf..459fdbf0a 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -26,7 +26,9 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.ItemWalkListenerRunner; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -45,8 +47,7 @@ void messageInvalid() { + " \"items\": {\"type\": \"integer\"}" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -67,8 +68,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -79,13 +79,17 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -106,8 +110,7 @@ void walkNullPrefixItems() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -118,13 +121,17 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 714efbfd9..746654b49 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -29,7 +29,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.ItemWalkListenerRunner; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -48,8 +50,7 @@ void messageInvalid() { + " \"items\": {\"type\": \"integer\"}" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -75,8 +76,7 @@ void messageAdditionalItemsInvalid() { + " \"additionalItems\": {\"type\": \"integer\"}" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -102,8 +102,7 @@ void messageAdditionalItemsFalseInvalid() { + " \"additionalItems\": false" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -124,8 +123,8 @@ void walk() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -136,13 +135,15 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -160,8 +161,8 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -172,13 +173,15 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -202,8 +205,8 @@ void walkNullTupleItemsAdditional() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -214,13 +217,15 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -252,8 +257,8 @@ void walkTupleItemsAdditional() throws JsonProcessingException { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -264,14 +269,17 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); - ValidationResult result = schema.walk(input, true); + ValidationResult result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -306,30 +314,28 @@ void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { + " \"default\": \"additional\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) - .itemWalkListener(new JsonSchemaWalkListener() { - - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } + + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getCollectorMap() - .computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }) - .build(); - Schema schema = factory.getSchema(schemaData, config); + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext().getCollectorContext() + .getData().computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); - ValidationResult result = schema.walk(input, true); + ValidationResult result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index 2b9e25f49..f88295527 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -37,12 +37,12 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { SchemaLocation schemaUri = SchemaLocation.of("cache:uri_mapping/schema1.json"); String schema = "{ \"$schema\": \"https://json-schema.org/draft/2020-12/schema\", \"title\": \"json-object-with-schema\", \"type\": \"string\" }"; fetcher.addResource(schemaUri.getAbsoluteIri(), schema); - assertEquals(objectMapper.readTree(schema), factory.getSchema(schemaUri, SchemaValidatorsConfig.builder().build()).schemaNode); + assertEquals(objectMapper.readTree(schema), factory.getSchema(schemaUri).schemaNode); String modifiedSchema = "{ \"$schema\": \"https://json-schema.org/draft/2020-12/schema\", \"title\": \"json-object-with-schema\", \"type\": \"object\" }"; fetcher.addResource(schemaUri.getAbsoluteIri(), modifiedSchema); - assertEquals(objectMapper.readTree(enableCache ? schema : modifiedSchema), factory.getSchema(schemaUri, SchemaValidatorsConfig.builder().build()).schemaNode); + assertEquals(objectMapper.readTree(enableCache ? schema : modifiedSchema), factory.getSchema(schemaUri).schemaNode); } private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index 03223e0fd..abddf42e3 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -26,17 +26,17 @@ class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().cacheRefs(false).build(); - factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json"), config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().cacheRefs(false).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json")); } @Test void preloadSchemaRefMaxNestingDepth() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .preloadJsonSchemaRefMaxNestingDepth(20) .build(); - factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json"), config); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json")); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 387c28567..289bc8529 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.walk.WalkConfig; + import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -21,8 +23,10 @@ class JsonWalkApplyDefaultsTest { void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); - ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema); + Schema jsonSchema = createSchema(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); + ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema, executionContext -> executionContext.setWalkConfig(walkConfig)); if (shouldValidateSchema) { assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", @@ -42,8 +46,10 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { void testApplyDefaults2() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, false)); - ValidationResult result = jsonSchema.walk(inputNode, true); + Schema jsonSchema = createSchema(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, false)).build(); + ValidationResult result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", @@ -59,8 +65,10 @@ void testApplyDefaults2() throws IOException { void testApplyDefaults1() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode inputNode = objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data-default.json")); - Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, false, false)); - ValidationResult result = jsonSchema.walk(inputNode, true); + Schema jsonSchema = createSchema(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)).build(); + ValidationResult result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_null: null found, integer expected", "/outer/mixedObject/intValue_missingButError: string found, integer expected", @@ -82,19 +90,25 @@ void testApplyDefaults0(String method) throws IOException { List errors; switch (method) { case "walkWithEmptyStrategy": { - Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(false, false, false)); - errors = jsonSchema.walk(inputNode, true).getErrors(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(false, false, false)).build(); + Schema jsonSchema = createSchema(); + errors = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)).getErrors(); break; } case "walkWithNoDefaults": { // same empty strategy, but tests for NullPointerException - Schema jsonSchema = createSchema(null); - errors = jsonSchema.walk(inputNode, true).getErrors(); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(null).build(); + Schema jsonSchema = createSchema(); + errors = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)).getErrors(); break; } case "validateWithApplyAllDefaults": { - Schema jsonSchema = createSchema(new ApplyDefaultsStrategy(true, true, true)); - errors = jsonSchema.validate(inputNode); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); + Schema jsonSchema = createSchema(); + errors = jsonSchema.validate(inputNode, executionContext -> executionContext.setWalkConfig(walkConfig)); break; } default: @@ -119,9 +133,9 @@ void testIllegalArgumentException() { } } - private Schema createSchema(ApplyDefaultsStrategy applyDefaultsStrategy) { + private Schema createSchema() { SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().applyDefaultsStrategy(applyDefaultsStrategy).build(); - return schemaFactory.getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json"), schemaValidatorsConfig); + return schemaFactory + .getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json")); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 111cf8fe4..9dc333697 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -10,7 +10,9 @@ import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.ValidatorTypeCode; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -34,30 +36,39 @@ class JsonWalkTest { private static final String CUSTOM_KEYWORD = "custom-keyword"; + private WalkConfig walkConfig; + + private WalkConfig walkConfig1; + @BeforeEach void setup() { setupSchema(); } private void setupSchema() { - final Dialect dialect = getJsonMetaSchema(); + final Dialect dialect = getDialect(); // Create Schema. - SchemaValidatorsConfig.Builder schemaValidatorsConfigBuilder = SchemaValidatorsConfig.builder(); - schemaValidatorsConfigBuilder.keywordWalkListener(new AllKeywordListener()); - schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); - schemaValidatorsConfigBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), + KeywordWalkListenerRunner.Builder keywordWalkListenerRunnerBuilder = KeywordWalkListenerRunner.builder(); + + keywordWalkListenerRunnerBuilder.keywordWalkListener(new AllKeywordListener()); + keywordWalkListenerRunnerBuilder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunnerBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); - final SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); - this.jsonSchema = schemaFactory.getSchema(getSchema(), schemaValidatorsConfigBuilder.build()); + SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); + this.jsonSchema = schemaFactory.getSchema(getSchema()); + this.walkConfig = WalkConfig.builder().keywordWalkListenerRunner(keywordWalkListenerRunnerBuilder.build()).build(); + // Create another Schema. - SchemaValidatorsConfig.Builder schemaValidatorsConfig1Builder = SchemaValidatorsConfig.builder(); - schemaValidatorsConfig1Builder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); - schemaValidatorsConfig1Builder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), + KeywordWalkListenerRunner.Builder keywordWalkListenerRunner1Builder = KeywordWalkListenerRunner.builder(); + keywordWalkListenerRunner1Builder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunner1Builder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new PropertiesKeywordListener()); - this.jsonSchema1 = schemaFactory.getSchema(getSchema(), schemaValidatorsConfig1Builder.build()); + schemaFactory = SchemaRegistry.withDialect(dialect); + this.jsonSchema1 = schemaFactory.getSchema(getSchema()); + this.walkConfig1 = WalkConfig.builder().keywordWalkListenerRunner(keywordWalkListenerRunner1Builder.build()).build(); } - private Dialect getJsonMetaSchema() { + private Dialect getDialect() { return Dialect.builder( "https://github.com/networknt/json-schema-validator/tests/schemas/example01", Dialects.getDraft201909()) .keyword(new CustomKeyword()).build(); @@ -67,7 +78,8 @@ private Dialect getJsonMetaSchema() { void testWalk() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ValidationResult result = jsonSchema.walk( - objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false); + objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false, + executionContext -> executionContext.setWalkConfig(walkConfig)); JsonNode collectedNode = (JsonNode) result.getCollectorContext().get(SAMPLE_WALK_COLLECTOR_TYPE); assertEquals(collectedNode, (objectMapper.readTree("{" + " \"PROPERTY1\": \"sample1\"," @@ -87,7 +99,8 @@ void testWalkWithDifferentListeners() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); // This instance of schema contains all listeners. ValidationResult result = jsonSchema.walk( - objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false); + objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false, + executionContext -> executionContext.setWalkConfig(walkConfig)); JsonNode collectedNode = (JsonNode) result.getCollectorContext().get(SAMPLE_WALK_COLLECTOR_TYPE); assertEquals(collectedNode, (objectMapper.readTree("{" + " \"PROPERTY1\": \"sample1\"," @@ -101,7 +114,9 @@ void testWalkWithDifferentListeners() throws IOException { + " }" + "}"))); // This instance of schema contains one listener removed. - result = jsonSchema1.walk(objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false); + result = jsonSchema1.walk( + objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false, + executionContext -> executionContext.setWalkConfig(walkConfig1)); collectedNode = (JsonNode) result.getExecutionContext().getCollectorContext().get(SAMPLE_WALK_COLLECTOR_TYPE); assertEquals(collectedNode, (objectMapper.readTree("{" + " \"property3\": {" @@ -182,7 +197,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } } - private static class AllKeywordListener implements JsonSchemaWalkListener { + private static class AllKeywordListener implements WalkListener { @Override public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { ObjectMapper mapper = new ObjectMapper(); @@ -190,7 +205,7 @@ public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { JsonNode schemaNode = keywordWalkEvent.getSchema().getSchemaNode(); CollectorContext collectorContext = keywordWalkEvent.getExecutionContext().getCollectorContext(); if (collectorContext.get(SAMPLE_WALK_COLLECTOR_TYPE) == null) { - collectorContext.add(SAMPLE_WALK_COLLECTOR_TYPE, mapper.createObjectNode()); + collectorContext.put(SAMPLE_WALK_COLLECTOR_TYPE, mapper.createObjectNode()); } if (keyWordName.equals(CUSTOM_KEYWORD) && schemaNode.get(CUSTOM_KEYWORD).isArray()) { ObjectNode objectNode = (ObjectNode) collectorContext.get(SAMPLE_WALK_COLLECTOR_TYPE); @@ -206,14 +221,14 @@ public void onWalkEnd(WalkEvent keywordWalkEvent, List errors) { } } - private static class RefKeywordListener implements JsonSchemaWalkListener { + private static class RefKeywordListener implements WalkListener { @Override public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { ObjectMapper mapper = new ObjectMapper(); CollectorContext collectorContext = keywordWalkEvent.getExecutionContext().getCollectorContext(); if (collectorContext.get(SAMPLE_WALK_COLLECTOR_TYPE) == null) { - collectorContext.add(SAMPLE_WALK_COLLECTOR_TYPE, mapper.createObjectNode()); + collectorContext.put(SAMPLE_WALK_COLLECTOR_TYPE, mapper.createObjectNode()); } ObjectNode objectNode = (ObjectNode) collectorContext.get(SAMPLE_WALK_COLLECTOR_TYPE); objectNode.set(keywordWalkEvent.getSchema().getSchemaNode().get("title").textValue().toLowerCase(), @@ -227,7 +242,7 @@ public void onWalkEnd(WalkEvent keywordWalkEvent, List errors) { } } - private static class PropertiesKeywordListener implements JsonSchemaWalkListener { + private static class PropertiesKeywordListener implements WalkListener { @Override public WalkFlow onWalkStart(WalkEvent keywordWalkEvent) { diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index 6b2bc88ae..8cbeab29e 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -33,11 +33,11 @@ import com.networknt.schema.serialization.JsonMapperFactory; class LocaleTest { - private Schema getSchema(SchemaValidatorsConfig config) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + private Schema getSchema(SchemaRegistryConfig config) { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema( - "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }", - config); + "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }" + ); } /** @@ -50,21 +50,21 @@ private Schema getSchema(SchemaValidatorsConfig config) { @Test void executionContextLocale() throws JsonMappingException, JsonProcessingException { JsonNode rootNode = new ObjectMapper().readTree(" { \"foo\": 123 } "); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); Schema jsonSchema = getSchema(config); Locale locale = Locales.findSupported("it;q=0.9,fr;q=1.0"); // fr ExecutionContext executionContext = jsonSchema.createExecutionContext(); assertEquals(config.getLocale(), executionContext.getExecutionConfig().getLocale()); - executionContext.getExecutionConfig().setLocale(locale); + executionContext.executionConfig(executionConfig -> executionConfig.locale(locale)); List messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); assertEquals(1, messages.size()); assertEquals("/foo: integer trouvé, string attendu", messages.iterator().next().toString()); - locale = Locales.findSupported("it;q=1.0,fr;q=0.9"); // it + Locale locale2 = Locales.findSupported("it;q=1.0,fr;q=0.9"); // it executionContext = jsonSchema.createExecutionContext(); assertEquals(config.getLocale(), executionContext.getExecutionConfig().getLocale()); - executionContext.getExecutionConfig().setLocale(locale); + executionContext.executionConfig(executionConfig -> executionConfig.locale(locale2)); messages = jsonSchema.validate(executionContext, rootNode, OutputFormat.DEFAULT); assertEquals(1, messages.size()); assertEquals("/foo: integer trovato, string previsto", messages.iterator().next().toString()); @@ -93,11 +93,11 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals("$: integer gefunden, object erwartet", messages.iterator().next().toString()); + assertEquals(": integer gefunden, object erwartet", messages.iterator().next().toString()); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().locale(Locale.ENGLISH).build(); - jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) - .getSchema(JsonMapperFactory.getInstance().readTree(schema), config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.ENGLISH).build(); + jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)) + .getSchema(JsonMapperFactory.getInstance().readTree(schema)); messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals(": integer found, object expected", messages.iterator().next().toString()); @@ -115,40 +115,40 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { @Test void encoding() { Map expected = new HashMap<>(); - expected.put("ar","$: يجب أن يكون طوله 5 حرÙًا على الأكثر"); - expected.put("cs","$: musí mít maximálnÄ› 5 znaků"); - expected.put("da","$: mÃ¥ højst være pÃ¥ 5 tegn"); - expected.put("de","$: darf höchstens 5 Zeichen lang sein"); - expected.put("es","$: debe tener como máximo 5 caracteres"); - expected.put("fa","$: باید حداکثر 5 کاراکتر باشد"); - expected.put("fi","$: saa olla enintään 5 merkkiä pitkä"); - expected.put("fr","$: doit contenir au plus 5 caractères"); - expected.put("iw","$: חייב להיות ב×ורך של 5 ×ª×•×•×™× ×œ×›×œ היותר"); - expected.put("he","$: חייב להיות ב×ורך של 5 ×ª×•×•×™× ×œ×›×œ היותר"); - expected.put("hr","$: mora imati najviÅ¡e 5 znakova"); - expected.put("hu","$: legfeljebb 5 karakter hosszúságú lehet"); - expected.put("it","$: deve contenere al massimo 5 caratteri"); - expected.put("ja","$: é•·ã•ã¯æœ€å¤§ 5 文字ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“"); - expected.put("ko","$: 길ì´ëŠ” 최대 5ìžì—¬ì•¼ 합니다."); - expected.put("nb","$: mÃ¥ bestÃ¥ av maksimalt 5 tegn"); - expected.put("nl","$: mag maximaal 5 tekens lang zijn"); - expected.put("pl","$: musi mieć maksymalnie 5 znaków"); - expected.put("pt","$: deve ter no máximo 5 caracteres"); - expected.put("ro","$: trebuie să aibă cel mult 5 caractere"); - expected.put("ru","$: длина должна быть не более 5 Ñимволов."); - expected.put("sk","$: musí maÅ¥ maximálne 5 znakov"); - expected.put("sv","$: fÃ¥r vara högst 5 tecken lÃ¥ng"); - expected.put("th","$: ต้องมีความยาวสูงสุด 5 อัà¸à¸‚ระ"); - expected.put("tr","$: en fazla 5 karakter uzunluÄŸunda olmalıdır"); - expected.put("uk","$: не більше ніж 5 Ñимволів"); - expected.put("vi","$: phải dài tối Ä‘a 5 ký tá»±"); - expected.put("zh_CN","$: 长度ä¸å¾—超过 5 个字符"); - expected.put("zh_TW","$: 長度ä¸å¾—è¶…éŽ 5 個字元"); + expected.put("ar",": يجب أن يكون طوله 5 حرÙًا على الأكثر"); + expected.put("cs",": musí mít maximálnÄ› 5 znaků"); + expected.put("da",": mÃ¥ højst være pÃ¥ 5 tegn"); + expected.put("de",": darf höchstens 5 Zeichen lang sein"); + expected.put("es",": debe tener como máximo 5 caracteres"); + expected.put("fa",": باید حداکثر 5 کاراکتر باشد"); + expected.put("fi",": saa olla enintään 5 merkkiä pitkä"); + expected.put("fr",": doit contenir au plus 5 caractères"); + expected.put("iw",": חייב להיות ב×ורך של 5 ×ª×•×•×™× ×œ×›×œ היותר"); + expected.put("he",": חייב להיות ב×ורך של 5 ×ª×•×•×™× ×œ×›×œ היותר"); + expected.put("hr",": mora imati najviÅ¡e 5 znakova"); + expected.put("hu",": legfeljebb 5 karakter hosszúságú lehet"); + expected.put("it",": deve contenere al massimo 5 caratteri"); + expected.put("ja",": é•·ã•ã¯æœ€å¤§ 5 文字ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“"); + expected.put("ko",": 길ì´ëŠ” 최대 5ìžì—¬ì•¼ 합니다."); + expected.put("nb",": mÃ¥ bestÃ¥ av maksimalt 5 tegn"); + expected.put("nl",": mag maximaal 5 tekens lang zijn"); + expected.put("pl",": musi mieć maksymalnie 5 znaków"); + expected.put("pt",": deve ter no máximo 5 caracteres"); + expected.put("ro",": trebuie să aibă cel mult 5 caractere"); + expected.put("ru",": длина должна быть не более 5 Ñимволов."); + expected.put("sk",": musí maÅ¥ maximálne 5 znakov"); + expected.put("sv",": fÃ¥r vara högst 5 tecken lÃ¥ng"); + expected.put("th",": ต้องมีความยาวสูงสุด 5 อัà¸à¸‚ระ"); + expected.put("tr",": en fazla 5 karakter uzunluÄŸunda olmalıdır"); + expected.put("uk",": не більше ніж 5 Ñимволів"); + expected.put("vi",": phải dài tối Ä‘a 5 ký tá»±"); + expected.put("zh_CN",": 长度ä¸å¾—超过 5 个字符"); + expected.put("zh_TW",": 長度ä¸å¾—è¶…éŽ 5 個字元"); // In later JDK versions the numbers will be formatted Map expectedAlternate = new HashMap<>(); - expectedAlternate.put("ar","$: يجب أن يكون طوله Ù¥ حرÙًا على الأكثر"); - expectedAlternate.put("fa","$: باید حداکثر Ûµ کاراکتر باشد"); + expectedAlternate.put("ar",": يجب أن يكون طوله Ù¥ حرÙًا على الأكثر"); + expectedAlternate.put("fa",": باید حداکثر Ûµ کاراکتر باشد"); String schemaData = "{\r\n" + " \"type\": \"string\",\r\n" @@ -158,7 +158,7 @@ void encoding() { List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { - executionContext.getExecutionConfig().setLocale(locale); + executionContext.executionConfig(executionConfig -> executionConfig.locale(locale)); }); String msg = messages.iterator().next().toString(); String expectedMsg = expected.get(locale.toString()); diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 6378023c6..4a58399a7 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -181,13 +181,16 @@ void negativeDoubleOverflowTest() throws IOException { {"1.000000000000000000000001E+400", "\"1.0000000000000000000000011E+400\""}, }; + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + for (String[] aTestCycle : values) { String maximum = aTestCycle[0]; String value = aTestCycle[1]; String schema = format(NUMBER, maximum); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); + // Schema and document parsed with just double - Schema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Maximum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", maximum, value)); @@ -204,7 +207,7 @@ void negativeDoubleOverflowTest() throws IOException { // schema and document parsed with BigDecimal - v = factory.getSchema(bigDecimalMapper.readTree(schema), config); + v = factory.getSchema(bigDecimalMapper.readTree(schema)); List messages3 = v.validate(doc); //when the schema and value are both using BigDecimal, the value should be parsed in same mechanism. String theValue = value.toLowerCase().replace("\"", ""); @@ -294,9 +297,9 @@ private static void expectNoMessages(String[][] values, String schemaTemplate, O String maximum = aTestCycle[0]; String value = aTestCycle[1]; String schema = format(schemaTemplate, maximum); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - - Schema v = factory.getSchema(mapper.readTree(schema), config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 4cd22aa82..2377f97c3 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -80,7 +80,7 @@ void message() { Schema schema = factory.getSchema(schemaData); List messages = schema.validate("\"helloworlda\"", InputFormat.JSON); assertEquals(1, messages.size()); - assertEquals("$: must be equal to 'helloworld'", messages.iterator().next().toString()); + assertEquals(": must be equal to 'helloworld'", messages.iterator().next().toString()); messages = schema.validate("\"helloworld\"", InputFormat.JSON); assertEquals(0, messages.size()); diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 864900bb7..369a10c2f 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -40,12 +40,12 @@ class MetaSchemaValidationTest { void oas31() throws IOException { try (InputStream input = MetaSchemaValidationTest.class.getResourceAsStream("/schema/oas/3.1/petstore.json")) { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); Schema schema = SchemaRegistry .withDefaultDialect(Version.DRAFT_2020_12, - builder -> builder.schemaMappers(schemaMappers -> schemaMappers + builder -> builder.schemaRegistryConfig(config).schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) - .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07"), config); + .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07")); List messages = schema.validate(inputData); assertEquals(0, messages.size()); } diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 02a0f1207..c256b8a40 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -172,10 +172,11 @@ void negativeDoubleOverflowTest() throws IOException { String minimum = aTestCycle[0]; String value = aTestCycle[1]; String schema = format(NUMBER, minimum); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); // Schema and document parsed with just double - Schema v = factory.getSchema(mapper.readTree(schema), config); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper.readTree(value); List messages = v.validate(doc); assertTrue(messages.isEmpty(), format("Minimum %s and value %s are interpreted as Infinity, thus no schema violation should be reported", minimum, value)); @@ -196,7 +197,8 @@ void negativeDoubleOverflowTest() throws IOException { } // schema and document parsed with BigDecimal - v = factory.getSchema(bigDecimalMapper.readTree(schema), config); + + v = factory.getSchema(bigDecimalMapper.readTree(schema)); List messages3 = v.validate(doc); //when the schema and value are both using BigDecimal, the value should be parsed in same mechanism. String theValue = value.toLowerCase().replace("\"", ""); @@ -287,9 +289,9 @@ private void expectNoMessages(String[][] values, String integer, ObjectMapper ma String minimum = aTestCycle[0]; String value = aTestCycle[1]; String schema = format(integer, minimum); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - - Schema v = factory.getSchema(mapper.readTree(schema), config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = bigIntegerMapper.readTree(value); List messages = v.validate(doc); diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 3c00c6322..0628f7c17 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -80,8 +80,9 @@ void testTypeLoose() { assertEquals(2, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); // With type loose this has 3 multipleOf errors - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - Schema typeLoose = factory.getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + Schema typeLoose = factory.getSchema(schemaData); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); assertEquals(3, messages.stream().filter(m -> "multipleOf".equals(m.getKeyword())).count()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 66693aa6a..180c36125 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.Specification.Version; +import com.networknt.schema.dialect.Dialects; /** * OneOfValidatorTest. @@ -64,7 +65,8 @@ void oneOfMultiple() { + " \"fox\" : \"test\",\r\n" + " \"world\" : \"test\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY).build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -105,7 +107,8 @@ void oneOfZero() { String inputData = "{\r\n" + " \"test\" : 1\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY).build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -301,8 +304,7 @@ void oneOfDiscriminatorEnabled() { + " }\r\n" + " ]\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); + Schema schema = SchemaRegistry.withDialect(Dialects.getOpenApi31()).getSchema(schemaData); String inputData = "{}"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); @@ -355,8 +357,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); + Schema schema = SchemaRegistry.withDialect(Dialects.getOpenApi31()).getSchema(schemaData); // Valid String inputData = "{\r\n" + " \"type\": \"number\",\r\n" @@ -374,8 +375,7 @@ void oneOfDiscriminatorEnabledWithDiscriminator() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); + Schema schema2 = SchemaRegistry.withDialect(Dialects.getDraft202012()).getSchema(schemaData); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); } @@ -443,8 +443,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { + " }\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(true).build()); + Schema schema = SchemaRegistry.withDialect(Dialects.getOpenApi31()).getSchema(schemaData); // Valid String inputData = "{\r\n" + " \"type\": \"number\",\r\n" @@ -462,8 +461,7 @@ void oneOfDiscriminatorEnabledWithDiscriminatorInSubclass() { assertEquals(2, messages2.size()); // Invalid both messages for string and object returned - Schema schema2 = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, - SchemaValidatorsConfig.builder().discriminatorKeywordEnabled(false).build()); + Schema schema2 = SchemaRegistry.withDialect(Dialects.getDraft202012()).getSchema(schemaData); List messages3 = schema2.validate(inputData2, InputFormat.JSON); assertEquals(3, messages3.size()); } diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index a0895494f..cd0563ff8 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.networknt.schema.dialect.Dialects; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -14,8 +16,6 @@ class OpenAPI30JsonSchemaTest { protected ObjectMapper mapper = new ObjectMapper(); - protected SchemaRegistry validatorFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)).build(); OpenAPI30JsonSchemaTest() { } @@ -38,10 +38,12 @@ private void runTestFile(String testCaseFile) throws Exception { JsonNode typeLooseNode = test.get("isTypeLoose"); // Configure the schemaValidator to set typeLoose's value based on the test file, // if test file do not contains typeLoose flag, use default value: true. - SchemaValidatorsConfig.Builder configBuilder = SchemaValidatorsConfig.builder(); + SchemaRegistryConfig.Builder configBuilder = SchemaRegistryConfig.builder(); configBuilder.typeLoose(typeLooseNode != null && typeLooseNode.asBoolean()); - configBuilder.discriminatorKeywordEnabled(true); - Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema"), configBuilder.build()); + SchemaRegistry validatorFactory = SchemaRegistry.withDialect(Dialects.getOpenApi30(), + builder -> builder.schemaRegistryConfig(configBuilder.build())); + + Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema")); List errors = new ArrayList(schema.validate(node)); diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 9c92ba6d6..e9f43eccf 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -35,8 +35,7 @@ private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { @DisplayName("Test Validation Messages") void testInvalidJson() throws Exception { InputStream schemaInputStream = OutputFormatTest.class.getResourceAsStream(schemaPath1); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaInputStream, config); + Schema schema = factory.getSchema(schemaInputStream); JsonNode node = getJsonNodeFromJsonData("/data/output-format-input.json"); List errors = schema.validate(node); Assertions.assertEquals(3, errors.size()); @@ -108,7 +107,7 @@ void customFormat() { + " }\n" + "}"; Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12) - .getSchema(schemaData, InputFormat.JSON, SchemaValidatorsConfig.builder().build()); + .getSchema(schemaData, InputFormat.JSON); String inputData = "{\n" + " \"type\": \"cat\",\n" + " \"id\": 1\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index f880b0a74..fcfd731d3 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -96,15 +96,14 @@ class OutputUnitTest { @Test void annotationCollectionList() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = inputData1; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":false,\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be the constant value '1'\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"}},{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"}}]}"; assertEquals(expected, output); @@ -113,15 +112,14 @@ void annotationCollectionList() throws JsonProcessingException { @Test void annotationCollectionHierarchical() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = inputData1; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be the constant value '1'\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}}]}]}"; assertEquals(expected, output); @@ -130,15 +128,14 @@ void annotationCollectionHierarchical() throws JsonProcessingException { @Test void annotationCollectionHierarchical2() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = inputData2; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":true,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"annotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"unspecified-prop\"]},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"annotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":true,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"annotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"annotations\":{\"title\":\"bar-prop-title\"}}]}]}"; assertEquals(expected, output); @@ -179,12 +176,11 @@ void formatAnnotation(FormatInput formatInput) { + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); assertTrue(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); assertEquals(formatInput.format, details.getAnnotations().get("format")); @@ -198,13 +194,12 @@ void formatAssertion(FormatInput formatInput) { + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - executionConfiguration.getExecutionConfig().setFormatAssertionsEnabled(true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true) + .formatAssertionsEnabled(true)); + }); assertFalse(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); assertEquals(formatInput.format, details.getDroppedAnnotations().get("format")); @@ -217,12 +212,11 @@ void typeUnion() { + " \"type\": [\"string\",\"array\"]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(typeSchema, config); + Schema schema = factory.getSchema(typeSchema); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { - executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionConfiguration.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); assertFalse(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); assertNotNull(details.getErrors().get("type")); @@ -267,8 +261,7 @@ void unevaluatedProperties() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); // The following checks if the heirarchical output format is correct with multiple unevaluated properties String inputData = "{\r\n" @@ -278,8 +271,8 @@ void unevaluatedProperties() throws JsonProcessingException { + " \"coordinates\": [1, 1]\r\n" + "}"; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, - executionContext -> executionContext.getExecutionConfig() - .setAnnotationCollectionFilter(keyword -> true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionFilter(keyword -> true))); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"#\",\"instanceLocation\":\"\",\"errors\":{\"unevaluatedProperties\":[\"property 'hello' is not evaluated and the schema does not allow unevaluated properties\",\"property 'world' is not evaluated and the schema does not allow unevaluated properties\"]},\"droppedAnnotations\":{\"unevaluatedProperties\":[\"hello\",\"world\"]},\"details\":[{\"valid\":false,\"evaluationPath\":\"/$ref\",\"schemaLocation\":\"https://www.example.org/point.json#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"type\",\"coordinates\"]}}]}"; assertEquals(expected, output); @@ -316,17 +309,16 @@ void anyOf() throws JsonProcessingException { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\": \"hello\",\r\n" + " \"bar\": 1\r\n" + "}"; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); String expected = "{\"valid\":true,\"evaluationPath\":\"\",\"schemaLocation\":\"#\",\"instanceLocation\":\"\",\"details\":[{\"valid\":true,\"evaluationPath\":\"/anyOf/0\",\"schemaLocation\":\"#/anyOf/0\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"foo\"]}},{\"valid\":true,\"evaluationPath\":\"/anyOf/1\",\"schemaLocation\":\"#/anyOf/1\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"bar\"]}}]}"; assertEquals(expected, output); @@ -338,8 +330,7 @@ void listAssertionMapper() { + " \"type\": \"string\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); assertFalse(outputUnit.isValid()); OutputUnit details = outputUnit.getDetails().get(0); @@ -353,8 +344,7 @@ void hierarchicalAssertionMapper() { + " \"type\": \"string\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(formatSchema, config); + Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); assertFalse(outputUnit.isValid()); Object assertion = outputUnit.getErrors().get("type"); diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 0098643ef..7bcbe3ab8 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -59,7 +59,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertEquals(2, messages.size(), Arrays.toString(messages.toArray())); @@ -76,7 +76,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { final Schema overrideValidatorSchema = overrideValidatorFactory.getSchema(schema); messages = overrideValidatorSchema.validate(targetNode, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertTrue(messages.stream().anyMatch(it -> it.getInstanceLocation().getName(-1).equals("timestamp"))); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 88ced482c..c9c7c6500 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.Specification.Version; +import com.networknt.schema.regex.JDKRegularExpressionFactory; + import java.io.InputStream; import java.util.HashMap; import java.util.List; @@ -12,7 +14,10 @@ class OverwritingCustomMessageBugTest { private Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY) + .errorMessageKeyword("message") + .regularExpressionFactory(JDKRegularExpressionFactory.getInstance()).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 06148477f..bc5aacd9d 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -53,11 +53,11 @@ void testInvalidPatternPropertiesValidator() throws Exception { @Test void testInvalidPatternPropertiesValidatorECMA262() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() + SchemaRegistryConfig config = SchemaRegistryConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); - Schema schema = factory.getSchema("{\"patternProperties\":6}", config); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); List errors = schema.validate(node); @@ -80,8 +80,7 @@ void message() { + " }\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\n" + " \"valid_array\": [\"array1_value\", \"array2_value\"],\n" + " \"valid_string\": \"string_value\",\n" @@ -131,15 +130,14 @@ void annotation() { + " }\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\n" + " \"test\": 5\n" + "}"; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); Set patternProperties = (Set) outputUnit.getAnnotations().get("patternProperties"); assertTrue(patternProperties.isEmpty()); @@ -148,9 +146,9 @@ void annotation() { + " \"valid_string\": \"string_value\"" + "}"; outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); patternProperties = (Set) outputUnit.getAnnotations().get("patternProperties"); Set all = new HashSet<>(); all.add("valid_array"); diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index c447d1aa1..043d0bc36 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -9,7 +9,9 @@ import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.PrefixItemsValidator; import com.networknt.schema.serialization.JsonMapperFactory; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.ItemWalkListenerRunner; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -54,9 +56,9 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -80,9 +82,9 @@ void messageValid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + Schema schema = factory.getSchema(schemaData); String inputData = "[\"x\", 1, 1]"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -99,9 +101,9 @@ void messageInvalidAdditionalItems() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}],\r\n" + " \"items\": false" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + Schema schema = factory.getSchema(schemaData); String inputData = "[\"x\", 1, 1, 2]"; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -130,8 +132,7 @@ void walkNull() { + " }\n" + " ]\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -142,13 +143,17 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); - Schema schema = factory.getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); + ValidationResult result = schema.walk(null, true, + executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -183,11 +188,9 @@ void walkDefaults() throws JsonProcessingException { + " }\n" + " ]\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) - .itemWalkListener(new JsonSchemaWalkListener() { - + + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -196,17 +199,19 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { @Override public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getCollectorMap() - .computeIfAbsent("items", key -> new ArrayList()); + List items = (List) walkEvent.getExecutionContext().getCollectorContext() + .getData().computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } - }) - .build(); - Schema schema = factory.getSchema(schemaData, config); + }).build(); + WalkConfig walkConfig = WalkConfig.builder().applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) + .itemWalkListenerRunner(itemWalkListenerRunner).build(); + + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null]"); - ValidationResult result = schema.walk(input, true); + ValidationResult result = schema.walk(input, true, + executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 769c70eb7..45fa13562 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -1,6 +1,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.walk.WalkConfig; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -12,15 +14,11 @@ class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { + WalkConfig walkConfig = WalkConfig.builder().applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); - - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) - .build(); - - Schema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}", schemaValidatorsConfig); + Schema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}"); JsonNode node = getJsonNodeFromStringContent("{\"foo\": \"bar\"}"); - ValidationResult result = schema.walk(node, true); + ValidationResult result = schema.walk(node, true, executionContext -> executionContext.setWalkConfig(walkConfig)); Assertions.assertEquals(result.getErrors().size(), 1); }); } diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index b9fa26f35..057714c06 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -39,8 +39,7 @@ void messageInvalid() { + " \"propertyNames\": {\"maxLength\": 3}\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\": {},\r\n" + " \"foobar\": {}\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 7e9bf405f..0c5aac554 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -19,36 +19,32 @@ class ReadOnlyValidatorTest { @Test void givenConfigWriteFalseWhenReadOnlyTrueThenAllows() throws IOException { ObjectNode node = getJsonNode(); - List errors = loadJsonSchema(false).validate(node); + List errors = loadJsonSchema().validate(node, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.readOnly(false))); assertTrue(errors.isEmpty()); } @Test void givenConfigWriteTrueWhenReadOnlyTrueThenDenies() throws IOException { ObjectNode node = getJsonNode(); - List errors = loadJsonSchema(true).validate(node); + List errors = loadJsonSchema().validate(node, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.readOnly(true))); assertFalse(errors.isEmpty()); assertEquals("/firstName: is a readonly field, it cannot be changed", errors.stream().map(e -> e.toString()).collect(Collectors.toList()).get(0)); } - private Schema loadJsonSchema(Boolean write) { - Schema schema = this.getJsonSchema(write); + private Schema loadJsonSchema() { + Schema schema = this.getJsonSchema(); schema.initializeValidators(); return schema; } - private Schema getJsonSchema(Boolean write) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); - SchemaValidatorsConfig schemaConfig = createSchemaConfig(write); + private Schema getJsonSchema() { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); - return factory.getSchema(schema, schemaConfig); - } - - private SchemaValidatorsConfig createSchemaConfig(Boolean write) { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(write).build(); - return config; + return factory.getSchema(schema); } private ObjectNode getJsonNode() throws IOException { diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 1825c4d20..7edaf05fd 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -24,8 +24,8 @@ void testInvalidRecursiveReference() { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); - ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getMetaSchema(), - jsonSchemaFactory, null); + ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getDialect(), + jsonSchemaFactory); // Act and Assert assertThrows(JsonSchemaException.class, () -> { diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 28c12216b..15b6d7dd6 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -17,8 +17,7 @@ class RefTest { @Test void shouldLoadRelativeClasspathReference() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -26,7 +25,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getDialect().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -40,8 +39,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { @Test void shouldLoadSchemaResource() throws JsonProcessingException { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); + Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" + " \"CommonProperties\": {\r\n" @@ -49,7 +47,7 @@ void shouldLoadSchemaResource() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getDialect().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -60,8 +58,8 @@ void shouldLoadSchemaResource() throws JsonProcessingException { assertEquals("field1", error.getProperty()); Schema driver = schema.getValidationContext().getSchemaResources().get("https://www.example.org/driver#"); Schema common = schema.getValidationContext().getSchemaResources().get("https://www.example.org/common#"); - assertEquals(DialectId.DRAFT_4, driver.getValidationContext().getMetaSchema().getIri()); - assertEquals(DialectId.DRAFT_7, common.getValidationContext().getMetaSchema().getIri()); + assertEquals(DialectId.DRAFT_4, driver.getValidationContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, common.getValidationContext().getDialect().getIri()); } } diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 214988dc8..197e2de9c 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -56,13 +56,14 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " ]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>( + schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.readOnly(true)))); assertEquals(messages.size(), 2); Error message = messages.get(0); assertEquals("/required", message.getEvaluationPath().toString()); @@ -100,13 +101,14 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " ]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" + " \"bar\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>( + schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.writeOnly(true)))); assertEquals(messages.size(), 2); Error message = messages.get(0); assertEquals("/required", message.getEvaluationPath().toString()); @@ -144,13 +146,14 @@ void validateRequestRequired() { + " ]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().readOnly(true).build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"amount\":10,\r\n" + " \"description\":\"world\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>( + schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.readOnly(true)))); assertEquals(messages.size(), 0); } @@ -182,13 +185,14 @@ void validateResponseRequired() { + " ]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().writeOnly(true).build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"description\":\"world\",\r\n" + " \"name\":\"hello\"\r\n" + "}"; - List messages = new ArrayList<>(schema.validate(inputData, InputFormat.JSON)); + List messages = new ArrayList<>( + schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.writeOnly(true)))); assertEquals(messages.size(), 0); } } diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index 5bbc8339e..35bb7f296 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -32,7 +32,7 @@ void schemaFromSchemaLocationMapping() { */ schemaFromSchemaLocation.initializeValidators(); List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @@ -55,7 +55,7 @@ void schemaFromSchemaLocationContent() { */ schemaFromSchemaLocation.initializeValidators(); List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @@ -76,7 +76,7 @@ void schemaFromClasspath() { */ schemaFromClasspath.initializeValidators(); List errors = schemaFromClasspath.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @@ -92,7 +92,7 @@ void schemaFromString() { Schema schemaFromString = factory .getSchema("{\"enum\":[1, 2, 3, 4]}"); List errors = schemaFromString.validate("7", InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @@ -118,7 +118,7 @@ void schemaFromJsonNode() throws JsonProcessingException { */ schemaFromNode.initializeValidators(); List errors = schemaFromNode.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } } diff --git a/src/test/java/com/networknt/schema/SchemaRegistryTest.java b/src/test/java/com/networknt/schema/SchemaRegistryTest.java index 0e9ff2bf5..73a5781f2 100644 --- a/src/test/java/com/networknt/schema/SchemaRegistryTest.java +++ b/src/test/java/com/networknt/schema/SchemaRegistryTest.java @@ -57,13 +57,12 @@ void concurrency() { for (int i = 0; i < 50; ++i) { Runnable runner = new Runnable() { public void run() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); try { latch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } - Dialect dialect = factory.getDialect("https://www.example.com/no-validation-no-format/schema", config); + Dialect dialect = factory.getDialect("https://www.example.com/no-validation-no-format/schema"); synchronized(instance) { if (instance[0] == null) { instance[0] = dialect; diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index e84e3fac0..907728573 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -55,11 +55,12 @@ void concurrency() throws Exception { String inputData = "{\r\n" + " \"name\": 1\r\n" + "}"; + SchemaRegistryConfig config = SchemaRegistryConfig.builder().preloadJsonSchema(false).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders + builder -> builder.schemaRegistryConfig(config) + .schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().preloadJsonSchema(false).build(); - Schema schema = factory.getSchema(schemaData, config); + Schema schema = factory.getSchema(schemaData); Exception[] instance = new Exception[1]; CountDownLatch latch = new CountDownLatch(1); List threads = new ArrayList<>(); diff --git a/src/test/java/com/networknt/schema/SchemaValidatorsConfigTest.java b/src/test/java/com/networknt/schema/SchemaValidatorsConfigTest.java deleted file mode 100644 index fcfa31304..000000000 --- a/src/test/java/com/networknt/schema/SchemaValidatorsConfigTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -import com.networknt.schema.regex.ECMAScriptRegularExpressionFactory; -import com.networknt.schema.regex.JDKRegularExpressionFactory; - -/** - * Test for SchemaValidatorsConfig. - */ -@SuppressWarnings("deprecation") -class SchemaValidatorsConfigTest { - @Test - void defaultEcma262Validator() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - assertSame(JDKRegularExpressionFactory.getInstance(), config.getRegularExpressionFactory()); - assertFalse(config.isEcma262Validator()); - } - - @Test - void setEcma262Validator() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - - config.setEcma262Validator(true); - assertSame(ECMAScriptRegularExpressionFactory.getInstance(), config.getRegularExpressionFactory()); - assertTrue(config.isEcma262Validator()); - - config.setEcma262Validator(false); - assertSame(JDKRegularExpressionFactory.getInstance(), config.getRegularExpressionFactory()); - assertFalse(config.isEcma262Validator()); - } - - @Test - void constructorPathType() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - assertEquals(PathType.LEGACY, config.getPathType()); - } - - @Test - void builderPathType() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - assertEquals(PathType.JSON_POINTER, config.getPathType()); - } - - @Test - void constructorCustomMessageSupported() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - assertEquals(true, config.isCustomMessageSupported()); - } - - @Test - void builderCustomMessageSupported() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - assertEquals(false, config.isCustomMessageSupported()); - } - - @Test - void constructorHandleNullableField() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - assertEquals(true, config.isHandleNullableField()); - } - - @Test - void builderHandleNullableField() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - assertEquals(false, config.isHandleNullableField()); - } - - @Test - void constructorMutable() { - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - assertDoesNotThrow(() -> config.setFailFast(true)); - } - - @Test - void builderImmutable() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - assertThrows(UnsupportedOperationException.class, () -> config.setFailFast(true)); - } -} diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index 734fcf146..6516bc0a7 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -6,7 +6,9 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.KeywordWalkListenerRunner; +import com.networknt.schema.walk.WalkConfig; import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; @@ -14,7 +16,7 @@ * Issue 918. */ class SharedConfigTest { - private static class AllKeywordListener implements JsonSchemaWalkListener { + private static class AllKeywordListener implements WalkListener { boolean wasCalled = false; @Override @@ -30,12 +32,13 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void shouldCallAllKeywordListenerOnWalkStart() throws Exception { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); AllKeywordListener allKeywordListener = new AllKeywordListener(); - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder() - .keywordWalkListener(allKeywordListener) - .build(); + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(allKeywordListener).build(); + WalkConfig walkConfig = WalkConfig.builder().keywordWalkListenerRunner(keywordWalkListenerRunner).build(); + + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); SchemaLocation draft07Schema = SchemaLocation.of("resource:/draft-07/schema#"); @@ -46,9 +49,10 @@ void shouldCallAllKeywordListenerOnWalkStart() throws Exception { firstSchema.walk(new ObjectMapper().readTree("{ \"id\": 123 }"), true); // note that only second schema takes overridden schemaValidatorsConfig - Schema secondSchema = factory.getSchema(draft07Schema, schemaValidatorsConfig); + Schema secondSchema = factory.getSchema(draft07Schema); - secondSchema.walk(new ObjectMapper().readTree("{ \"id\": 123 }"), true); + secondSchema.walk(new ObjectMapper().readTree("{ \"id\": 123 }"), true, + executionContext -> executionContext.setWalkConfig(walkConfig)); Assertions.assertTrue(allKeywordListener.wasCalled); } } \ No newline at end of file diff --git a/src/test/java/com/networknt/schema/TypeFactoryTest.java b/src/test/java/com/networknt/schema/TypeFactoryTest.java index 90d410412..763ff5c2a 100755 --- a/src/test/java/com/networknt/schema/TypeFactoryTest.java +++ b/src/test/java/com/networknt/schema/TypeFactoryTest.java @@ -43,7 +43,7 @@ class TypeFactoryTest { @Test void testIntegralValuesWithJavaSemantics() { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().javaSemantics(true).build(); + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().javaSemantics(true).build(); for (String validValue : validIntegralValues) { assertSame(JsonType.INTEGER, getValueNodeType(DecimalNode.valueOf(new BigDecimal(validValue)), schemaValidatorsConfig), @@ -58,7 +58,7 @@ void testIntegralValuesWithJavaSemantics() { @Test void testIntegralValuesWithoutJavaSemantics() { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().javaSemantics(false).build(); + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().javaSemantics(false).build(); for (String validValue : validIntegralValues) { assertSame(JsonType.NUMBER, getValueNodeType(DecimalNode.valueOf(new BigDecimal(validValue)), schemaValidatorsConfig), @@ -73,7 +73,7 @@ void testIntegralValuesWithoutJavaSemantics() { @Test void testWithLosslessNarrowing() { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().losslessNarrowing(true).build(); + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().losslessNarrowing(true).build(); for (String validValue : validIntegralValues) { assertSame(JsonType.INTEGER, getValueNodeType(DecimalNode.valueOf(new BigDecimal("1.0")), schemaValidatorsConfig), validValue); @@ -85,7 +85,7 @@ void testWithLosslessNarrowing() { @Test void testWithoutLosslessNarrowing() { - SchemaValidatorsConfig schemaValidatorsConfig = SchemaValidatorsConfig.builder().losslessNarrowing(false).build(); + SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().losslessNarrowing(false).build(); for (String validValue : validIntegralValues) { assertSame(JsonType.NUMBER, getValueNodeType(DecimalNode.valueOf(new BigDecimal("1.0")), schemaValidatorsConfig), validValue); @@ -99,44 +99,44 @@ void testWithoutLosslessNarrowing() { @Test void testObjectValue() { assertSame(JsonType.OBJECT, getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().objectNode(), - SchemaValidatorsConfig.builder().build())); + SchemaRegistryConfig.builder().build())); } @Test void testArrayValue() { assertSame(JsonType.ARRAY, - getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().arrayNode(), SchemaValidatorsConfig.builder().build())); + getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().arrayNode(), SchemaRegistryConfig.builder().build())); } @Test void testBooleanValue() { assertSame(JsonType.BOOLEAN, getValueNodeType( - JsonMapperFactory.getInstance().getNodeFactory().booleanNode(true), SchemaValidatorsConfig.builder().build())); + JsonMapperFactory.getInstance().getNodeFactory().booleanNode(true), SchemaRegistryConfig.builder().build())); } @Test void testNullValue() { assertSame(JsonType.NULL, - getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().nullNode(), SchemaValidatorsConfig.builder().build())); + getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().nullNode(), SchemaRegistryConfig.builder().build())); } @Test void testMissingValue() { assertSame(JsonType.UNKNOWN, getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().missingNode(), - SchemaValidatorsConfig.builder().build())); + SchemaRegistryConfig.builder().build())); } @Test void testIntegerValue() { assertSame(JsonType.INTEGER, getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().numberNode(10), - SchemaValidatorsConfig.builder().build())); + SchemaRegistryConfig.builder().build())); } @Test void testBinaryValue() { assertSame(JsonType.STRING, getValueNodeType( JsonMapperFactory.getInstance().getNodeFactory().binaryNode("test".getBytes(StandardCharsets.UTF_8)), - SchemaValidatorsConfig.builder().build())); + SchemaRegistryConfig.builder().build())); } @Test diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 3e2fa3f2c..bb60775ae 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -78,8 +78,9 @@ void testTypeLoose() { assertEquals(1, messages.stream().filter(m -> "type".equals(m.getKeyword())).count()); // With type loose this has 0 type errors as any item can also be interpreted as an array of 1 item - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().typeLoose(true).build(); - Schema typeLoose = factory.getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); + factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + Schema typeLoose = factory.getSchema(schemaData); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); @@ -173,10 +174,9 @@ void nullable() { + " \"nested\":null\r\n" + " }\r\n" + "}"; - final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); - final Schema validator = factory.getSchema(schemaData, SchemaValidatorsConfig.builder() - .nullableKeywordEnabled(false) - .build()); + // nullable keyword enabled false + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); + final Schema validator = factory.getSchema(schemaData); final List errors = validator.validate(inputData, InputFormat.JSON); assertEquals(1, errors.size()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index c7072cd31..0fb4ea033 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -48,11 +48,11 @@ void unevaluatedItemsFalse() { assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); assertEquals("unevaluatedItems", assertions.get(0).getKeyword()); - assertEquals("$", assertions.get(0).getInstanceLocation().toString()); - assertEquals("$.unevaluatedItems", assertions.get(0).getEvaluationPath().toString()); + assertEquals("", assertions.get(0).getInstanceLocation().toString()); + assertEquals("/unevaluatedItems", assertions.get(0).getEvaluationPath().toString()); assertEquals("unevaluatedItems", assertions.get(1).getKeyword()); - assertEquals("$", assertions.get(1).getInstanceLocation().toString()); - assertEquals("$.unevaluatedItems", assertions.get(1).getEvaluationPath().toString()); + assertEquals("", assertions.get(1).getInstanceLocation().toString()); + assertEquals("/unevaluatedItems", assertions.get(1).getEvaluationPath().toString()); } @Test @@ -74,10 +74,10 @@ void unevaluatedItemsSchema() { assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); assertEquals("type", assertions.get(0).getKeyword()); - assertEquals("$[1]", assertions.get(0).getInstanceLocation().toString()); - assertEquals("$.unevaluatedItems.type", assertions.get(0).getEvaluationPath().toString()); + assertEquals("/1", assertions.get(0).getInstanceLocation().toString()); + assertEquals("/unevaluatedItems/type", assertions.get(0).getEvaluationPath().toString()); assertEquals("type", assertions.get(1).getKeyword()); - assertEquals("$[2]", assertions.get(1).getInstanceLocation().toString()); - assertEquals("$.unevaluatedItems.type", assertions.get(1).getEvaluationPath().toString()); + assertEquals("/2", assertions.get(1).getInstanceLocation().toString()); + assertEquals("/unevaluatedItems/type", assertions.get(1).getEvaluationPath().toString()); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 82710b4a7..3992eb60b 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -149,7 +149,7 @@ void unevaluatedPropertiesSchema() { assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); assertEquals("type", assertions.get(0).getKeyword()); - assertEquals("$.unevaluatedProperties.type", assertions.get(0).getEvaluationPath().toString()); + assertEquals("/unevaluatedProperties/type", assertions.get(0).getEvaluationPath().toString()); } @Test @@ -234,9 +234,9 @@ void nestedRef() { String inputData = "{ \"isPrimaryDevice\": true, \"roleName\": \"hello\" }"; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(false); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(false).annotationCollectionFilter(keyword -> true)); + }); assertTrue(outputUnit.isValid()); } } diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index ff15c965a..6071297d6 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -152,11 +152,10 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error try { - Schema schema = instance.getSchema(example, config); + Schema schema = instance.getSchema(example); schema.validate(mapper.createObjectNode()); fail("Expected exception not thrown"); } catch (JsonSchemaException ex) { @@ -170,7 +169,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); - Schema schema = instance.getSchema(example, config); + Schema schema = instance.getSchema(example); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); } @@ -179,9 +178,8 @@ void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json"), - config); + Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json") + ); assertEquals(0, schema.validate(mapper.readTree("[]")).size()); } diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index f36da0916..635b04b45 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -88,11 +88,9 @@ private List validateFailingFastSchemaFor(final String schemaFileName, fi final ObjectMapper objectMapper = new ObjectMapper(); final JsonNode schema = getJsonNodeFromResource(objectMapper, schemaFileName); final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); - final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().failFast(true).build(); - return SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) - .build() - .getSchema(schema, config) + final SchemaRegistryConfig config = SchemaRegistryConfig.builder().failFast(true).build(); + return SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schema) .validate(dataFile); } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 8bdb65e44..571987a8a 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -125,7 +125,7 @@ void noFormatValidation() { + "}"; List messages = schema.validate(inputDataNoValidation, InputFormat.JSON, - executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true)); + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(0, messages.size()); // Set format assertion vocab @@ -215,9 +215,9 @@ void customVocabulary() { metaSchemaData)))); Schema schema = factory.getSchema(schemaData); OutputUnit outputUnit = schema.validate("{}", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { - executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); - executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); - }); + executionContext.executionConfig(executionConfig -> executionConfig + .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); + }); assertNotNull(outputUnit.getAnnotations().get("hello")); } } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRunner.java index c4fd63e17..1f3baa11b 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRunner.java @@ -21,13 +21,15 @@ public NetworkntTestSuiteRunner(List testCases) { public Object call() { List results = new ArrayList<>(); for (NetworkntTestSuiteTestCase testCase : testCases) { - for (TestSpec testSpec : testCase.getTestCase().getTests()) { - results.add( - testCase.getSchema().validate(testSpec.getData(), OutputFormat.DEFAULT, executionContext -> { - executionContext.getExecutionConfig() - .setFormatAssertionsEnabled(testCase.getFormatAssertionsEnabled()); - })); - } + for (TestSpec testSpec : testCase.getTestCase().getTests()) { + results.add( + testCase.getSchema().validate(testSpec.getData(), OutputFormat.DEFAULT, executionContext -> { + if (testCase.getFormatAssertionsEnabled() != null) { + executionContext.executionConfig(executionConfig -> executionConfig + .formatAssertionsEnabled(testCase.getFormatAssertionsEnabled())); + } + })); + } } return results; } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index 609b08778..139c566ca 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -17,7 +17,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; @@ -66,11 +66,13 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { for (TestCase testCase : testSource.getTestCases()) { SchemaLocation testCaseFileUri = SchemaLocation .of("classpath:" + toForwardSlashPath(testCase.getSpecification())); + SchemaRegistryConfig config = SchemaRegistryConfig.builder() + .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()).build(); Schema schema = SchemaRegistry .withDefaultDialect(defaultVersion, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) - .getSchema(testCaseFileUri, testCase.getSchema(), SchemaValidatorsConfig.builder() - .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()).build()); + builder -> builder.schemaRegistryConfig(config) + .schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) + .getSchema(testCaseFileUri, testCase.getSchema()); results.add(new NetworkntTestSuiteTestCase(schema, testCase, testCase.getSource().getPath().getParent().toString().endsWith("format") ? true : null)); } diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index a6acbbae9..af50ea916 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -25,7 +25,6 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -36,10 +35,9 @@ void uriShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -49,10 +47,9 @@ void queryWithBracketsShouldFail() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } @@ -62,10 +59,9 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -75,10 +71,9 @@ void iriShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -88,9 +83,8 @@ void noAuthorityShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -100,9 +94,8 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -112,9 +105,8 @@ void noPathShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index b28c03a12..6685037de 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -36,8 +36,10 @@ void uriShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -49,8 +51,10 @@ void queryWithBracketsShouldFail() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); assertFalse(messages.isEmpty()); @@ -62,8 +66,10 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -75,8 +81,10 @@ void iriShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -88,8 +96,10 @@ void noAuthorityShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -100,8 +110,10 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); + Schema schema = SchemaRegistry + .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .getSchema(schemaData); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); } @@ -112,9 +124,8 @@ void noPathShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index 2804c9d8d..f2a09fb02 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -25,7 +25,6 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -59,9 +58,9 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate(inputData, InputFormat.JSON, + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -88,9 +87,9 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate(inputData, InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate(inputData, InputFormat.JSON, + executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index d0c00774e..b12831def 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -25,7 +25,6 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -36,10 +35,9 @@ void uriShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -48,11 +46,9 @@ void queryWithBracketsShouldFail() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } @@ -62,10 +58,9 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -75,10 +70,9 @@ void iriShouldFail() { + " \"format\": \"uri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } @@ -87,10 +81,8 @@ void noAuthorityShouldPass() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -100,9 +92,8 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -111,10 +102,8 @@ void noPathShouldPass() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index bd03f1791..4a83504d9 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -25,7 +25,6 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; @@ -36,10 +35,9 @@ void uriShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -49,10 +47,9 @@ void queryWithBracketsShouldFail() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } @@ -62,10 +59,9 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -75,10 +71,9 @@ void iriShouldFail() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", - InputFormat.JSON); + InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); } @@ -88,9 +83,8 @@ void noAuthorityShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"http://\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -100,9 +94,8 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"//\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -112,9 +105,8 @@ void noPathShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - List messages = schema.validate("\"about:\"", InputFormat.JSON); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 0cec999b2..820ec040e 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -30,7 +30,7 @@ import com.networknt.schema.OutputFormat; import com.networknt.schema.PathType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.Error; @@ -70,10 +70,11 @@ void validateMetaSchema() { */ @Test void jsonPointerWithNumberInFragment() { - SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30()); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.JSON_PATH).build(); + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi30(), builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema(SchemaLocation.of( - "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"), - SchemaValidatorsConfig.builder().pathType(PathType.JSON_PATH).build()); + "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema") + ); assertNotNull(schema); assertEquals("$.paths['/pet'].post.responses['200'].content['application/json'].schema", schema.getEvaluationPath().toString()); diff --git a/src/test/java/com/networknt/schema/suite/TestSpec.java b/src/test/java/com/networknt/schema/suite/TestSpec.java index 6d8f73bb4..e06e27f9f 100644 --- a/src/test/java/com/networknt/schema/suite/TestSpec.java +++ b/src/test/java/com/networknt/schema/suite/TestSpec.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SchemaRegistryConfig; import java.util.Collections; import java.util.HashMap; @@ -100,7 +100,7 @@ public class TestSpec { private final RegexKind regex; /** - * Config information to be provided for {@link SchemaValidatorsConfig} with which schema can be validated + * Config information to be provided for {@link SchemaRegistryConfig} with which schema can be validated *

* This is an extension of the schema used to describe tests in the * compliance suite @@ -186,7 +186,7 @@ public String getComment() { /** - * Config information to be provided for {@link SchemaValidatorsConfig} with which schema can be validated + * Config information to be provided for {@link SchemaRegistryConfig} with which schema can be validated */ public Map getConfig() { return config; diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 4400e35aa..debd40844 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -34,7 +34,6 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.Error; import com.networknt.schema.serialization.JsonMapperFactory; @@ -89,10 +88,9 @@ void jsonLocation() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, InputFormat.JSON, config); + Schema schema = factory.getSchema(schemaData, InputFormat.JSON); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); List list = messages.stream().collect(Collectors.toList()); Error format = list.get(0); @@ -135,10 +133,9 @@ void yamlLocation() { + "startDate: '1'\r\n"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); - Schema schema = factory.getSchema(schemaData, InputFormat.YAML, config); + Schema schema = factory.getSchema(schemaData, InputFormat.YAML); List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { - executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); + executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); List list = messages.stream().collect(Collectors.toList()); Error format = list.get(0); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java similarity index 87% rename from src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java rename to src/test/java/com/networknt/schema/walk/WalkListenerTest.java index d18525bb9..fdaae1d84 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -40,7 +40,6 @@ import com.networknt.schema.SchemaRegistry; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SchemaValidatorsConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.keyword.ItemsValidator; @@ -56,7 +55,7 @@ /** * JsonSchemaWalkListenerTest. */ -class JsonSchemaWalkListenerTest { +class WalkListenerTest { @Test void keywordListener() { @@ -86,14 +85,14 @@ void keywordListener() { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") List propertyKeywords = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("propertyKeywords", key -> new ArrayList<>()); propertyKeywords.add(walkEvent); return WalkFlow.CONTINUE; @@ -104,7 +103,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -117,7 +116,10 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { + " }\r\n" + " ]\r\n" + "}"; - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List propertyKeywords = (List) result.getExecutionContext().getCollectorContext().get("propertyKeywords"); @@ -166,14 +168,14 @@ void propertyListener() { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .propertyWalkListener(new JsonSchemaWalkListener() { + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() + .propertyWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") List properties = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("properties", key -> new ArrayList<>()); properties.add(walkEvent); return WalkFlow.CONTINUE; @@ -184,7 +186,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -197,7 +199,10 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { + " }\r\n" + " ]\r\n" + "}"; - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .propertyWalkListenerRunner(propertyWalkListenerRunner) + .build(); + ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -253,13 +258,13 @@ void itemsListener() { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList<>()); items.add(walkEvent); return WalkFlow.CONTINUE; @@ -269,7 +274,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -282,7 +287,11 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { + " }\r\n" + " ]\r\n" + "}"; - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + + ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -326,13 +335,13 @@ void items202012Listener() { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().itemWalkListener(new JsonSchemaWalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList<>()); items.add(walkEvent); return WalkFlow.CONTINUE; @@ -342,7 +351,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -355,7 +364,10 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { + " }\r\n" + " ]\r\n" + "}"; - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -373,14 +385,14 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void draft201909() { - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") List propertyKeywords = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("propertyKeywords", key -> new ArrayList<>()); propertyKeywords.add(walkEvent); return WalkFlow.CONTINUE; @@ -392,7 +404,8 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09) - .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09), config); + .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09)); + String inputData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\r\n" + " \"type\": \"object\",\r\n" @@ -408,11 +421,13 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { + " }\r\n" + " }\r\n" + "}"; - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); - @SuppressWarnings("unchecked") - List propertyKeywords = (List) result.getExecutionContext().getCollectorContext().getCollectorMap().get("propertyKeywords"); + List propertyKeywords = result.getExecutionContext().getCollectorContext().get("propertyKeywords"); assertEquals(28, propertyKeywords.size()); @@ -552,12 +567,11 @@ void applyDefaults() throws JsonProcessingException { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) - .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + WalkConfig walkConfig = WalkConfig.builder() + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true); + ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -585,8 +599,8 @@ void applyDefaultsWithWalker() throws JsonProcessingException { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .propertyWalkListener(new JsonSchemaWalkListener() { + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() + .propertyWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() @@ -612,9 +626,12 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + WalkConfig walkConfig = WalkConfig.builder() + .propertyWalkListenerRunner(propertyWalkListenerRunner) + .build(); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true); + ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -642,8 +659,8 @@ void applyInvalidDefaultsWithWalker() throws JsonProcessingException { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .propertyWalkListener(new JsonSchemaWalkListener() { + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() + .propertyWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() @@ -669,14 +686,17 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true); + WalkConfig walkConfig = WalkConfig.builder() + .propertyWalkListenerRunner(propertyWalkListenerRunner) + .build(); + ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); assertFalse(result.getErrors().isEmpty()); inputNode = JsonMapperFactory.getInstance().readTree("{}"); - result = schema.walk(inputNode, false); + result = schema.walk(inputNode, false, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -702,8 +722,8 @@ void missingRequired() throws JsonProcessingException { + " }\r\n" + "}"; Map missingSchemaNode = new LinkedHashMap<>(); - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new JsonSchemaWalkListener() { + KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() + .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { JsonNode requiredNode = walkEvent.getSchema().getSchemaNode().get("required"); @@ -736,10 +756,13 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); + WalkConfig walkConfig = WalkConfig.builder() + .keywordWalkListenerRunner(keywordWalkListenerRunner) + .build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true); + ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); assertEquals("{\"type\":\"integer\"}", missingSchemaNode.get("s").toString()); assertEquals("{\"type\":\"string\"}", missingSchemaNode.get("ref").toString()); @@ -774,8 +797,8 @@ void generateDataWithWalker() throws JsonProcessingException { + " }\r\n" + "}"; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .propertyWalkListener(new JsonSchemaWalkListener() { + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() + .propertyWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() @@ -806,10 +829,13 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); + WalkConfig walkConfig = WalkConfig.builder() + .propertyWalkListenerRunner(propertyWalkListenerRunner) + .build(); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true); + ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -838,7 +864,7 @@ void itemListenerDraft201909() { + " }\r\n" + " }\r\n" + " }"; - JsonSchemaWalkListener listener = new JsonSchemaWalkListener() { + WalkListener listener = new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -849,17 +875,20 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .itemWalkListener(listener) - .propertyWalkListener(listener) + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(listener).build(); + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder().propertyWalkListener(listener).build(); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); + + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(4, items.size()); @@ -901,7 +930,7 @@ void itemListenerDraft202012() { + " }\r\n" + " }\r\n" + " }"; - JsonSchemaWalkListener listener = new JsonSchemaWalkListener() { + WalkListener listener = new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -912,19 +941,21 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext() .getCollectorContext() - .getCollectorMap() + .getData() .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }; - SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() - .itemWalkListener(listener) - .propertyWalkListener(listener) + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(listener).build(); + PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder().propertyWalkListener(listener).build(); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData, config); - ValidationResult result = schema.walk(null, true); - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + + ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + List items = result.getExecutionContext().getCollectorContext().get("items"); assertEquals(4, items.size()); assertEquals("/name", items.get(0).getInstanceLocation().toString()); assertEquals("properties", items.get(0).getKeyword()); From adf41acbb3fa9aef7e216dab7916a7506a37105d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:59:40 +0800 Subject: [PATCH 18/74] Rename ValidationContext to SchemaContext --- .../schema/ExecutionContextCustomizer.java | 4 +- .../java/com/networknt/schema/Format.java | 24 +-- .../schema/JsonSchemaIdValidator.java | 6 +- .../com/networknt/schema/OutputFormat.java | 30 ++-- .../java/com/networknt/schema/Schema.java | 140 +++++++++--------- ...idationContext.java => SchemaContext.java} | 9 +- .../com/networknt/schema/SchemaRegistry.java | 50 +++---- .../dialect/DefaultDialectRegistry.java | 4 +- .../com/networknt/schema/dialect/Dialect.java | 20 +-- .../format/BaseFormatJsonValidator.java | 14 +- .../schema/format/DurationFormat.java | 10 +- .../networknt/schema/format/RegexFormat.java | 6 +- .../AdditionalPropertiesValidator.java | 10 +- .../schema/keyword/AllOfValidator.java | 12 +- .../schema/keyword/AnnotationKeyword.java | 8 +- .../schema/keyword/AnyOfValidator.java | 20 +-- .../schema/keyword/BaseKeywordValidator.java | 20 +-- .../schema/keyword/ConstValidator.java | 6 +- .../schema/keyword/ContainsValidator.java | 10 +- .../keyword/ContentEncodingValidator.java | 10 +- .../keyword/ContentMediaTypeValidator.java | 10 +- .../schema/keyword/DependenciesValidator.java | 10 +- .../schema/keyword/DependentRequired.java | 6 +- .../schema/keyword/DependentSchemas.java | 8 +- .../DisallowUnknownKeywordFactory.java | 4 +- .../keyword/DiscriminatorValidator.java | 6 +- .../schema/keyword/DynamicRefValidator.java | 22 +-- .../schema/keyword/EnumValidator.java | 12 +- .../keyword/ExclusiveMaximumValidator.java | 8 +- .../keyword/ExclusiveMinimumValidator.java | 8 +- .../schema/keyword/FalseValidator.java | 6 +- .../schema/keyword/FormatKeyword.java | 6 +- .../schema/keyword/FormatValidator.java | 10 +- .../networknt/schema/keyword/IfValidator.java | 12 +- .../schema/keyword/ItemsValidator.java | 14 +- .../schema/keyword/ItemsValidator202012.java | 8 +- .../com/networknt/schema/keyword/Keyword.java | 6 +- .../schema/keyword/KeywordFactory.java | 6 +- .../schema/keyword/MaxItemsValidator.java | 8 +- .../schema/keyword/MaxLengthValidator.java | 8 +- .../keyword/MaxPropertiesValidator.java | 6 +- .../schema/keyword/MaximumValidator.java | 8 +- .../schema/keyword/MinItemsValidator.java | 8 +- .../schema/keyword/MinLengthValidator.java | 8 +- .../keyword/MinMaxContainsValidator.java | 6 +- .../keyword/MinPropertiesValidator.java | 6 +- .../schema/keyword/MinimumValidator.java | 8 +- .../schema/keyword/MultipleOfValidator.java | 10 +- .../schema/keyword/NonValidationKeyword.java | 20 +-- .../schema/keyword/NotAllowedValidator.java | 6 +- .../schema/keyword/NotValidator.java | 8 +- .../schema/keyword/OneOfValidator.java | 18 +-- .../keyword/PatternPropertiesValidator.java | 10 +- .../schema/keyword/PatternValidator.java | 10 +- .../schema/keyword/PrefixItemsValidator.java | 8 +- .../schema/keyword/PropertiesValidator.java | 8 +- .../keyword/PropertyNamesValidator.java | 8 +- .../schema/keyword/ReadOnlyValidator.java | 6 +- .../schema/keyword/RecursiveRefValidator.java | 18 +-- .../schema/keyword/RefValidator.java | 72 ++++----- .../schema/keyword/RequiredValidator.java | 6 +- .../schema/keyword/TrueValidator.java | 6 +- .../schema/keyword/TypeValidator.java | 12 +- .../keyword/UnevaluatedItemsValidator.java | 10 +- .../UnevaluatedPropertiesValidator.java | 8 +- .../schema/keyword/UnionTypeValidator.java | 12 +- .../schema/keyword/UniqueItemsValidator.java | 6 +- .../schema/keyword/UnknownKeywordFactory.java | 4 +- .../schema/keyword/ValidatorTypeCode.java | 10 +- .../schema/keyword/WriteOnlyValidator.java | 6 +- .../HierarchicalOutputUnitFormatter.java | 10 +- .../output/ListOutputUnitFormatter.java | 4 +- .../schema/regex/RegularExpression.java | 6 +- .../networknt/schema/utils/JsonNodeUtil.java | 18 +-- .../schema/AbstractJsonSchemaTestSuite.java | 2 +- .../schema/CollectorContextTest.java | 6 +- .../schema/CustomMetaSchemaTest.java | 2 +- .../schema/DurationFormatValidatorTest.java | 2 +- .../com/networknt/schema/ExampleTest.java | 12 +- .../schema/FormatKeywordFactoryTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 4 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 2 +- .../com/networknt/schema/MessageTest.java | 8 +- .../networknt/schema/OutputFormatTest.java | 2 +- .../schema/OverrideValidatorTest.java | 2 +- ...ursiveReferenceValidatorExceptionTest.java | 4 +- .../java/com/networknt/schema/RefTest.java | 12 +- .../com/networknt/schema/VocabularyTest.java | 2 +- 89 files changed, 514 insertions(+), 511 deletions(-) rename src/main/java/com/networknt/schema/{ValidationContext.java => SchemaContext.java} (97%) diff --git a/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java b/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java index 0f67d3f9e..e79e64e79 100644 --- a/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java +++ b/src/main/java/com/networknt/schema/ExecutionContextCustomizer.java @@ -24,10 +24,10 @@ public interface ExecutionContextCustomizer { /** * Customize the execution context before validation. *

- * The validation context should only be used for reference as it is shared. + * The schema context should only be used for reference as it is shared. * * @param executionContext the execution context * @param schemaContext the schema context for reference */ - void customize(ExecutionContext executionContext, ValidationContext schemaContext); + void customize(ExecutionContext executionContext, SchemaContext schemaContext); } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/Format.java index a05e1b2e6..ea25860e8 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/Format.java @@ -82,11 +82,11 @@ default boolean matches(ExecutionContext executionContext, String value) { * Determines if the value matches the format. * * @param executionContext the execution context - * @param validationContext the validation context + * @param schemaContext the schema context * @param value to match * @return true if matches */ - default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, String value) { + default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, String value) { return matches(executionContext, value); } @@ -94,16 +94,16 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * Determines if the value matches the format. * * @param executionContext the execution context - * @param validationContext the validation context + * @param schemaContext the schema context * @param value to match * @return true if matches */ - default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, JsonNode value) { - JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getSchemaRegistryConfig()); + default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, JsonNode value) { + JsonType nodeType = TypeFactory.getValueNodeType(value, schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return true; } - return matches(executionContext, validationContext, value.textValue()); + return matches(executionContext, schemaContext, value.textValue()); } /** @@ -112,7 +112,7 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * This can be implemented for non-string node types. * * @param executionContext the execution context - * @param validationContext the validation context + * @param schemaContext the schema context * @param node the node * @param rootNode the root node * @param instanceLocation the instance location @@ -120,9 +120,9 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * @param formatValidator the format validator * @return true if matches */ - default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, JsonNode node, + default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) { - return matches(executionContext, validationContext, node); + return matches(executionContext, schemaContext, node); } /** @@ -131,7 +131,7 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * This is the most flexible method to implement. * * @param executionContext the execution context - * @param validationContext the validation context + * @param schemaContext the schema context * @param node the node * @param rootNode the root node * @param instanceLocation the instance locaiton @@ -139,12 +139,12 @@ default boolean matches(ExecutionContext executionContext, ValidationContext val * @param message the message builder * @param formatValidator the format validator */ - default void validate(ExecutionContext executionContext, ValidationContext validationContext, + default void validate(ExecutionContext executionContext, SchemaContext schemaContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, Supplier message, FormatValidator formatValidator) { if (assertionsEnabled) { - if (!matches(executionContext, validationContext, node, rootNode, instanceLocation, assertionsEnabled, + if (!matches(executionContext, schemaContext, node, rootNode, instanceLocation, assertionsEnabled, formatValidator)) { executionContext.addError(message.get() .arguments(this.getName(), this.getErrorMessageDescription(), node.asText()).build()); diff --git a/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java b/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java index 3a2ee98f7..75d446dd0 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java +++ b/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java @@ -29,12 +29,12 @@ public interface JsonSchemaIdValidator { * @param rootSchema true if this is a root schema * @param schemaLocation the schema location * @param resolvedSchemaLocation the schema location after resolving with the id - * @param validationContext the validation context for instance to get the + * @param schemaContext the schema context for instance to get the * meta schema * @return true if valid */ boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, - SchemaLocation resolvedSchemaLocation, ValidationContext validationContext); + SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext); JsonSchemaIdValidator DEFAULT = new DefaultJsonSchemaIdValidator(); @@ -51,7 +51,7 @@ boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, class DefaultJsonSchemaIdValidator implements JsonSchemaIdValidator { @Override public boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, - SchemaLocation resolvedSchemaLocation, ValidationContext validationContext) { + SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext) { if (hasNoContext(schemaLocation)) { // The following are non-standard if (isFragment(id) || startsWithSlash(id)) { diff --git a/src/main/java/com/networknt/schema/OutputFormat.java b/src/main/java/com/networknt/schema/OutputFormat.java index 750789961..bbed2ff4b 100644 --- a/src/main/java/com/networknt/schema/OutputFormat.java +++ b/src/main/java/com/networknt/schema/OutputFormat.java @@ -32,12 +32,12 @@ public interface OutputFormat { /** * Customize the execution context before validation. *

- * The validation context should only be used for reference as it is shared. + * The schema context should only be used for reference as it is shared. * * @param executionContext the execution context * @param schemaContext the schema context for reference */ - default void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + default void customize(ExecutionContext executionContext, SchemaContext schemaContext) { } /** @@ -50,7 +50,7 @@ default void customize(ExecutionContext executionContext, ValidationContext sche * @return the result */ T format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext schemaContext); + ExecutionContext executionContext, SchemaContext schemaContext); /** * The Default output format. @@ -90,13 +90,13 @@ T format(Schema jsonSchema, */ class Default implements OutputFormat> { @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { executionContext.executionConfig(executionConfig -> executionConfig.annotationCollectionEnabled(false)); } @Override public java.util.List format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return executionContext.getErrors(); } } @@ -106,14 +106,14 @@ public java.util.List format(Schema jsonSchema, */ class Flag implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { executionContext.executionConfig( executionConfig -> executionConfig.annotationCollectionEnabled(false).failFast(true)); } @Override public OutputFlag format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return new OutputFlag(executionContext.getErrors().isEmpty()); } } @@ -123,14 +123,14 @@ public OutputFlag format(Schema jsonSchema, */ class Boolean implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { executionContext.executionConfig( executionConfig -> executionConfig.annotationCollectionEnabled(false).failFast(true)); } @Override public java.lang.Boolean format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext schemaContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return executionContext.getErrors().isEmpty(); } } @@ -155,12 +155,12 @@ public List(Function errorMapper) { } @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { } @Override public OutputUnit format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext schemaContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return ListOutputUnitFormatter.format(executionContext.getErrors(), executionContext, schemaContext, this.errorMapper); } @@ -186,12 +186,12 @@ public Hierarchical(Function errorMapper) { } @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { } @Override public OutputUnit format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext schemaContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return HierarchicalOutputUnitFormatter.format(jsonSchema, executionContext.getErrors(), executionContext, schemaContext, this.errorMapper); } @@ -204,11 +204,11 @@ public OutputUnit format(Schema jsonSchema, */ class Result implements OutputFormat { @Override - public void customize(ExecutionContext executionContext, ValidationContext schemaContext) { + public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { } @Override - public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, ValidationContext schemaContext) { + public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, SchemaContext schemaContext) { return new ValidationResult(executionContext); } } diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index f72c594ff..767bb5ecc 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -65,7 +65,7 @@ public class Schema implements Validator { protected final JsonNode schemaNode; protected final Schema parentSchema; protected final SchemaLocation schemaLocation; - protected final ValidationContext validationContext; + protected final SchemaContext schemaContext; protected final boolean suppressSubSchemaRetrieval; protected final JsonNodePath evaluationPath; @@ -98,11 +98,11 @@ public Schema getEvaluationParentSchema() { return getParentSchema(); } - protected Schema fetchSubSchemaNode(ValidationContext validationContext) { - return this.suppressSubSchemaRetrieval ? null : obtainSubSchemaNode(this.schemaNode, validationContext); + protected Schema fetchSubSchemaNode(SchemaContext schemaContext) { + return this.suppressSubSchemaRetrieval ? null : obtainSubSchemaNode(this.schemaNode, schemaContext); } - private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final ValidationContext validationContext) { + private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final SchemaContext schemaContext) { final JsonNode node = schemaNode.get("id"); if (node == null) { @@ -118,7 +118,7 @@ private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final Valid return null; } final SchemaLocation schemaLocation = SchemaLocation.of(node.textValue()); - return validationContext.getSchemaRegistry().getSchema(schemaLocation); + return schemaContext.getSchemaRegistry().getSchema(schemaLocation); } public static class JsonNodePathLegacy { private static final JsonNodePath INSTANCE = new JsonNodePath(PathType.LEGACY); @@ -151,18 +151,18 @@ public void validate(ExecutionContext executionContext, JsonNode node) { * @return The path. */ protected JsonNodePath atRoot() { - if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_POINTER)) { + if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_POINTER)) { return JsonNodePathJsonPointer.getInstance(); - } else if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.LEGACY)) { + } else if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.LEGACY)) { return JsonNodePathLegacy.getInstance(); - } else if (this.validationContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_PATH)) { + } else if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_PATH)) { return JsonNodePathJsonPath.getInstance(); } - return new JsonNodePath(this.validationContext.getSchemaRegistryConfig().getPathType()); + return new JsonNodePath(this.schemaContext.getSchemaRegistryConfig().getPathType()); } - static Schema from(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { - return new Schema(validationContext, schemaLocation, evaluationPath, schemaNode, parent, suppressSubSchemaRetrieval); + static Schema from(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { + return new Schema(schemaContext, schemaLocation, evaluationPath, schemaNode, parent, suppressSubSchemaRetrieval); } private boolean hasNoFragment(SchemaLocation schemaLocation) { @@ -171,8 +171,8 @@ private boolean hasNoFragment(SchemaLocation schemaLocation) { } private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode schemaNode, boolean rootSchema, - ValidationContext validationContext) { - String id = validationContext.resolveSchemaId(schemaNode); + SchemaContext schemaContext) { + String id = schemaContext.resolveSchemaId(schemaNode); if (id != null) { String resolve = id; int fragment = id.indexOf('#'); @@ -182,18 +182,18 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc resolve = id.substring(0, fragment); } SchemaLocation result = !"".equals(resolve) ? schemaLocation.resolve(resolve) : schemaLocation; - JsonSchemaIdValidator validator = validationContext.getSchemaRegistryConfig().getSchemaIdValidator(); + JsonSchemaIdValidator validator = schemaContext.getSchemaRegistryConfig().getSchemaIdValidator(); if (validator != null) { - if (!validator.validate(id, rootSchema, schemaLocation, result, validationContext)) { - SchemaLocation idSchemaLocation = schemaLocation.append(validationContext.getDialect().getIdKeyword()); + if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) { + SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword()); Error error = Error.builder() .messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) - .arguments(id, validationContext.getDialect().getIdKeyword(), idSchemaLocation) + .arguments(id, schemaContext.getDialect().getIdKeyword(), idSchemaLocation) .schemaLocation(idSchemaLocation) .schemaNode(schemaNode) - .messageFormatter(args -> validationContext.getSchemaRegistryConfig().getMessageSource().getMessage( - ValidatorTypeCode.ID.getValue(), validationContext.getSchemaRegistryConfig().getLocale(), args)) + .messageFormatter(args -> schemaContext.getSchemaRegistryConfig().getMessageSource().getMessage( + ValidatorTypeCode.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args)) .build(); throw new InvalidSchemaException(error); } @@ -204,21 +204,21 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc } } - private Schema(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, + private Schema(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { /* - super(resolve(schemaLocation, schemaNode, parent == null, validationContext), evaluationPath, schemaNode, parent, - null, null, validationContext, suppressSubSchemaRetrieval); + super(resolve(schemaLocation, schemaNode, parent == null, schemaContext), evaluationPath, schemaNode, parent, + null, null, schemaContext, suppressSubSchemaRetrieval); */ - this.validationContext = validationContext; - this.schemaLocation = resolve(schemaLocation, schemaNode, parent == null, validationContext); + this.schemaContext = schemaContext; + this.schemaLocation = resolve(schemaLocation, schemaNode, parent == null, schemaContext); this.schemaNode = schemaNode; this.parentSchema = parent; this.suppressSubSchemaRetrieval = suppressSubSchemaRetrieval; this.evaluationPath = evaluationPath; this.evaluationParentSchema = null; - String id = this.validationContext.resolveSchemaId(this.schemaNode); + String id = this.schemaContext.resolveSchemaId(this.schemaNode); if (id != null) { // In earlier drafts $id may contain an anchor fragment see draft4/idRef.json // Note that json pointer fragments in $id are not allowed @@ -230,31 +230,31 @@ private Schema(ValidationContext validationContext, SchemaLocation schemaLocatio // This will be added to schema resources later this.id = null; } - this.validationContext.getSchemaResources().putIfAbsent(result != null ? result.toString() : id, this); + this.schemaContext.getSchemaResources().putIfAbsent(result != null ? result.toString() : id, this); } else { if (hasNoFragment(schemaLocation)) { // No $id but there is no fragment and is thus a schema resource this.id = schemaLocation.getAbsoluteIri() != null ? schemaLocation.getAbsoluteIri().toString() : ""; - this.validationContext.getSchemaResources() + this.schemaContext.getSchemaResources() .putIfAbsent(schemaLocation != null ? schemaLocation.toString() : this.id, this); } else { this.id = null; } } - String anchor = this.validationContext.getDialect().readAnchor(this.schemaNode); + String anchor = this.schemaContext.getDialect().readAnchor(this.schemaNode); if (anchor != null) { String absoluteIri = this.schemaLocation.getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() : ""; - this.validationContext.getSchemaResources() + this.schemaContext.getSchemaResources() .putIfAbsent(absoluteIri + "#" + anchor, this); } - String dynamicAnchor = this.validationContext.getDialect().readDynamicAnchor(schemaNode); + String dynamicAnchor = this.schemaContext.getDialect().readDynamicAnchor(schemaNode); if (dynamicAnchor != null) { String absoluteIri = this.schemaLocation.getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() : ""; - this.validationContext.getDynamicAnchors() + this.schemaContext.getDynamicAnchors() .putIfAbsent(absoluteIri + "#" + dynamicAnchor, this); } getValidators(); @@ -270,7 +270,7 @@ private Schema(ValidationContext validationContext, SchemaLocation schemaLocatio * @param id the id * @param suppressSubSchemaRetrieval to suppress sub schema retrieval * @param schemaNode the schema node - * @param validationContext the validation context + * @param schemaContext the schema context * @param parentSchema the parent schema * @param schemaLocation the schema location * @param evaluationPath the evaluation path @@ -287,13 +287,13 @@ protected Schema( /* Below from BaseJsonValidator */ boolean suppressSubSchemaRetrieval, JsonNode schemaNode, - ValidationContext validationContext, + SchemaContext schemaContext, Schema parentSchema, SchemaLocation schemaLocation, JsonNodePath evaluationPath, Schema evaluationParentSchema, Map errorMessage) { -// super(suppressSubSchemaRetrieval, schemaNode, validationContext, errorMessageType, keyword, +// super(suppressSubSchemaRetrieval, schemaNode, schemaContext, errorMessageType, keyword, // parentSchema, schemaLocation, evaluationPath, evaluationParentSchema, errorMessage); this.validators = validators; this.validatorsLoaded = validatorsLoaded; @@ -301,7 +301,7 @@ protected Schema( this.typeValidator = typeValidator; this.id = id; - this.validationContext = validationContext; + this.schemaContext = schemaContext; this.schemaLocation = schemaLocation; this.schemaNode = schemaNode; this.parentSchema = parentSchema; @@ -322,11 +322,11 @@ protected Schema( * @return the schema */ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluationPath) { - ValidationContext validationContext = new ValidationContext(this.getValidationContext().getDialect(), - this.getValidationContext().getSchemaRegistry(), - refEvaluationParentSchema.getValidationContext().getSchemaReferences(), - refEvaluationParentSchema.getValidationContext().getSchemaResources(), - refEvaluationParentSchema.getValidationContext().getDynamicAnchors()); + SchemaContext schemaContext = new SchemaContext(this.getSchemaContext().getDialect(), + this.getSchemaContext().getSchemaRegistry(), + refEvaluationParentSchema.getSchemaContext().getSchemaReferences(), + refEvaluationParentSchema.getSchemaContext().getSchemaResources(), + refEvaluationParentSchema.getSchemaContext().getDynamicAnchors()); JsonNodePath evaluationPath = refEvaluationPath; Schema evaluationParentSchema = refEvaluationParentSchema; // Validator state is reset due to the changes in evaluation path @@ -344,7 +344,7 @@ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluati /* Below from BaseJsonValidator */ suppressSubSchemaRetrieval, schemaNode, - validationContext, + schemaContext, parentSchema, schemaLocation, evaluationPath, evaluationParentSchema, /* errorMessage */ null); } @@ -358,7 +358,7 @@ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluati // .build(); // } // if (!this.getValidationContext().getSchemaRegistryConfig().equals(config)) { -// ValidationContext validationContext = new ValidationContext(this.getValidationContext().getMetaSchema(), +// ValidationContext schemaContext = new ValidationContext(this.getValidationContext().getMetaSchema(), // this.getValidationContext().getSchemaRegistry(), config, // this.getValidationContext().getSchemaReferences(), // this.getValidationContext().getSchemaResources(), @@ -376,7 +376,7 @@ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluati // /* Below from BaseJsonValidator */ // suppressSubSchemaRetrieval, // schemaNode, -// validationContext, +// schemaContext, // parentSchema, // schemaLocation, // evaluationPath, @@ -387,8 +387,8 @@ public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluati // return this; // } - public ValidationContext getValidationContext() { - return this.validationContext; + public SchemaContext getSchemaContext() { + return this.schemaContext; } /** @@ -433,9 +433,9 @@ public Schema getRefSchema(JsonNodePath fragment) { // Anchor String base = this.getSchemaLocation().getAbsoluteIri() != null ? this.schemaLocation.getAbsoluteIri().toString() : ""; String anchor = base + "#" + fragment; - Schema result = this.validationContext.getSchemaResources().get(anchor); + Schema result = this.schemaContext.getSchemaResources().get(anchor); if (result == null) { - result = this.validationContext.getDynamicAnchors().get(anchor); + result = this.schemaContext.getDynamicAnchors().get(anchor); } if (result == null) { throw new JsonSchemaException("Unable to find anchor "+anchor); @@ -479,15 +479,15 @@ public Schema getSubSchema(JsonNodePath fragment) { evaluationPath = evaluationPath.append(segment.toString()); } /* - * The parent validation context is used to create as there can be changes in - * $schema is later drafts which means the validation context can change. + * The parent schema context is used to create as there can be changes in + * $schema is later drafts which means the schema context can change. */ // This may need a redesign see Issue 939 and 940 - String id = parent.getValidationContext().resolveSchemaId(subSchemaNode); + String id = parent.getSchemaContext().resolveSchemaId(subSchemaNode); // if (!("definitions".equals(segment.toString()) || "$defs".equals(segment.toString()) // )) { if (id != null || x == nameCount - 1) { - subSchema = parent.getValidationContext().newSchema(schemaLocation, evaluationPath, subSchemaNode, + subSchema = parent.getSchemaContext().newSchema(schemaLocation, evaluationPath, subSchemaNode, parent); parent = subSchema; schemaLocation = subSchema.getSchemaLocation(); @@ -501,7 +501,7 @@ public Schema getSubSchema(JsonNodePath fragment) { * * See test for draft4\extra\classpath\schema.json */ - Schema found = document.findSchemaResourceRoot().fetchSubSchemaNode(this.validationContext); + Schema found = document.findSchemaResourceRoot().fetchSubSchemaNode(this.schemaContext); if (found != null) { found = found.getSubSchema(fragment); } @@ -585,7 +585,7 @@ public Schema findAncestor() { } private JsonNode handleNullNode(String ref, Schema schema) { - Schema subSchema = schema.fetchSubSchemaNode(this.validationContext); + Schema subSchema = schema.fetchSubSchemaNode(this.schemaContext); if (subSchema != null) { return subSchema.getRefSchemaNode(ref); } @@ -601,12 +601,12 @@ private List read(JsonNode schemaNode) { validators = new ArrayList<>(1); if (schemaNode.booleanValue()) { JsonNodePath path = getEvaluationPath().append("true"); - KeywordValidator validator = this.validationContext.newValidator(getSchemaLocation().append("true"), path, + KeywordValidator validator = this.schemaContext.newValidator(getSchemaLocation().append("true"), path, "true", schemaNode, this); validators.add(validator); } else { JsonNodePath path = getEvaluationPath().append("false"); - KeywordValidator validator = this.validationContext.newValidator(getSchemaLocation().append("false"), + KeywordValidator validator = this.schemaContext.newValidator(getSchemaLocation().append("false"), path, "false", schemaNode, this); validators.add(validator); } @@ -639,7 +639,7 @@ private List read(JsonNode schemaNode) { this.recursiveAnchor = nodeToUse.booleanValue(); } - KeywordValidator validator = this.validationContext.newValidator(schemaPath, path, + KeywordValidator validator = this.schemaContext.newValidator(schemaPath, path, pname, nodeToUse, this); if (validator != null) { validators.add(validator); @@ -668,7 +668,7 @@ private List read(JsonNode schemaNode) { } private long activeDialect() { - return this.validationContext + return this.schemaContext .activeDialect() .map(Version::getOrder) .orElse(Integer.MAX_VALUE); @@ -700,7 +700,7 @@ private long activeDialect() { @Override public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, JsonNodePath instanceLocation) { - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { ObjectNode discriminator = (ObjectNode) schemaNode.get("discriminator"); if (null != discriminator && null != executionContext.getCurrentDiscriminatorContext()) { executionContext.getCurrentDiscriminatorContext().registerDiscriminator(schemaLocation, @@ -712,7 +712,7 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN v.validate(executionContext, jsonNode, rootNode, instanceLocation); } - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { ObjectNode discriminator = (ObjectNode) this.schemaNode.get("discriminator"); if (null != discriminator) { final DiscriminatorContext discriminatorContext = executionContext @@ -855,7 +855,7 @@ public T validate(JsonNode rootNode, OutputFormat format, ExecutionContex * @return the result */ public T validate(JsonNode rootNode, OutputFormat format, Consumer executionCustomizer) { - return validate(createExecutionContext(), rootNode, format, (executionContext, validationContext) -> executionCustomizer.accept(executionContext)); + return validate(createExecutionContext(), rootNode, format, (executionContext, schemaContext) -> executionCustomizer.accept(executionContext)); } /** @@ -974,7 +974,7 @@ public T validate(String input, InputFormat inputFormat, OutputFormat for * @return the result */ public T validate(String input, InputFormat inputFormat, OutputFormat format, Consumer executionCustomizer) { - return validate(createExecutionContext(), deserialize(input, inputFormat), format, (executionContext, validationContext) -> executionCustomizer.accept(executionContext)); + return validate(createExecutionContext(), deserialize(input, inputFormat), format, (executionContext, schemaContext) -> executionCustomizer.accept(executionContext)); } /** @@ -1002,16 +1002,16 @@ public T validate(ExecutionContext executionContext, JsonNode node, OutputFo */ public T validate(ExecutionContext executionContext, JsonNode node, OutputFormat format, ExecutionContextCustomizer executionCustomizer) { - format.customize(executionContext, this.validationContext); + format.customize(executionContext, this.schemaContext); if (executionCustomizer != null) { - executionCustomizer.customize(executionContext, this.validationContext); + executionCustomizer.customize(executionContext, this.schemaContext); } try { validate(executionContext, node); } catch (FailFastAssertionException e) { executionContext.setErrors(e.getErrors()); } - return format.format(this, executionContext, this.validationContext); + return format.format(this, executionContext, this.schemaContext); } /** @@ -1023,7 +1023,7 @@ public T validate(ExecutionContext executionContext, JsonNode node, OutputFo */ private JsonNode deserialize(String input, InputFormat inputFormat) { try { - return this.getValidationContext().getSchemaRegistry().readTree(input, inputFormat); + return this.getSchemaContext().getSchemaRegistry().readTree(input, inputFormat); } catch (IOException e) { throw new IllegalArgumentException("Invalid input", e); } @@ -1288,18 +1288,18 @@ public ValidationResult walkAtNode(ExecutionContext executionContext, JsonNode n private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean validate, OutputFormat format, Consumer executionCustomizer) { return walkAtNodeInternal(executionContext, node, rootNode, instanceLocation, validate, format, - (executeContext, validationContext) -> executionCustomizer.accept(executeContext)); + (executeContext, schemaContext) -> executionCustomizer.accept(executeContext)); } private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean validate, OutputFormat format, ExecutionContextCustomizer executionCustomizer) { if (executionCustomizer != null) { - executionCustomizer.customize(executionContext, this.validationContext); + executionCustomizer.customize(executionContext, this.schemaContext); } // Walk through the schema. walk(executionContext, node, rootNode, instanceLocation, validate); - return format.format(this, executionContext, this.validationContext); + return format.format(this, executionContext, this.schemaContext); } @Override @@ -1386,7 +1386,7 @@ public boolean isRecursiveAnchor() { * @return the execution context */ public ExecutionContext createExecutionContext() { - SchemaRegistryConfig config = validationContext.getSchemaRegistryConfig(); + SchemaRegistryConfig config = schemaContext.getSchemaRegistryConfig(); // Copy execution config defaults from validation config ExecutionConfig executionConfig = ExecutionConfig.builder() .locale(config.getLocale()) @@ -1394,7 +1394,7 @@ public ExecutionContext createExecutionContext() { .failFast(config.isFailFast()).build(); ExecutionContext executionContext = new ExecutionContext(executionConfig); if(config.getExecutionContextCustomizer() != null) { - config.getExecutionContextCustomizer().customize(executionContext, validationContext); + config.getExecutionContextCustomizer().customize(executionContext, schemaContext); } return executionContext; } diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/SchemaContext.java similarity index 97% rename from src/main/java/com/networknt/schema/ValidationContext.java rename to src/main/java/com/networknt/schema/SchemaContext.java index 484b695af..553e3a667 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/SchemaContext.java @@ -25,7 +25,10 @@ import com.networknt.schema.dialect.Dialect; import com.networknt.schema.keyword.KeywordValidator; -public class ValidationContext { +/** + * The schema context associated with a schema and all its validators. + */ +public class SchemaContext { private final Dialect dialect; private final SchemaRegistry schemaRegistry; private final ConcurrentMap schemaReferences; @@ -83,12 +86,12 @@ public class ValidationContext { */ private final boolean nullableKeywordEnabled; - public ValidationContext(Dialect dialect, + public SchemaContext(Dialect dialect, SchemaRegistry schemaRegistry) { this(dialect, schemaRegistry, new ConcurrentHashMap<>(), new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } - public ValidationContext(Dialect dialect, SchemaRegistry schemaRegistry, + public SchemaContext(Dialect dialect, SchemaRegistry schemaRegistry, ConcurrentMap schemaReferences, ConcurrentMap schemaResources, ConcurrentMap dynamicAnchors) { if (dialect == null) { diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index a1e2c6d2b..3c55cd22d 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -290,9 +290,9 @@ public static Builder builder(final SchemaRegistry blueprint) { * @return the schema */ protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schemaNode) { - final ValidationContext validationContext = createValidationContext(schemaNode); - Schema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), - new JsonNodePath(validationContext.getSchemaRegistryConfig().getPathType()), schemaNode, null, false); + final SchemaContext schemaContext = createSchemaContext(schemaNode); + Schema jsonSchema = doCreate(schemaContext, getSchemaLocation(schemaUri), + new JsonNodePath(schemaContext.getSchemaRegistryConfig().getPathType()), schemaNode, null, false); preload(jsonSchema); return jsonSchema; } @@ -321,36 +321,36 @@ private void preload(Schema schema) { } } - public Schema create(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { - return doCreate(validationContext, schemaLocation, evaluationPath, schemaNode, parentSchema, false); + public Schema create(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { + return doCreate(schemaContext, schemaLocation, evaluationPath, schemaNode, parentSchema, false); } - private Schema doCreate(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { - return Schema.from(withDialect(validationContext, schemaNode), schemaLocation, evaluationPath, + private Schema doCreate(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { + return Schema.from(withDialect(schemaContext, schemaNode), schemaLocation, evaluationPath, schemaNode, parentSchema, suppressSubSchemaRetrieval); } /** - * Determines the validation context to use for the schema given the parent - * validation context. + * Determines the schema context to use for the schema given the parent + * schema context. *

- * This is typically the same validation context unless the schema has a + * This is typically the same schema context unless the schema has a * different $schema from the parent. *

* If the schema does not define a $schema, the parent should be used. * - * @param validationContext the parent validation context + * @param schemaContext the parent schema context * @param schemaNode the schema node - * @return the validation context to use + * @return the schema context to use */ - private ValidationContext withDialect(ValidationContext validationContext, JsonNode schemaNode) { - Dialect dialect = getDialect(schemaNode, validationContext.getSchemaRegistryConfig()); - if (dialect != null && !dialect.getIri().equals(validationContext.getDialect().getIri())) { - return new ValidationContext(dialect, validationContext.getSchemaRegistry(), - validationContext.getSchemaReferences(), validationContext.getSchemaResources(), - validationContext.getDynamicAnchors()); + private SchemaContext withDialect(SchemaContext schemaContext, JsonNode schemaNode) { + Dialect dialect = getDialect(schemaNode, schemaContext.getSchemaRegistryConfig()); + if (dialect != null && !dialect.getIri().equals(schemaContext.getDialect().getIri())) { + return new SchemaContext(dialect, schemaContext.getSchemaRegistry(), + schemaContext.getSchemaReferences(), schemaContext.getSchemaResources(), + schemaContext.getDynamicAnchors()); } - return validationContext; + return schemaContext; } /** @@ -367,9 +367,9 @@ protected SchemaLocation getSchemaLocation(SchemaLocation schemaLocation) { return schemaLocation != null ? schemaLocation : SchemaLocation.DOCUMENT; } - protected ValidationContext createValidationContext(final JsonNode schemaNode) { + protected SchemaContext createSchemaContext(final JsonNode schemaNode) { final Dialect dialect = getDialectOrDefault(schemaNode); - return new ValidationContext(dialect, this); + return new SchemaContext(dialect, this); } private Dialect getDialect(final JsonNode schemaNode, SchemaRegistryConfig config) { @@ -531,13 +531,13 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { // Schema without fragment - ValidationContext validationContext = new ValidationContext(dialect, this); - return doCreate(validationContext, schemaUri, evaluationPath, schemaNode, null, true /* retrieved via id, resolving will not change anything */); + SchemaContext schemaContext = new SchemaContext(dialect, this); + return doCreate(schemaContext, schemaUri, evaluationPath, schemaNode, null, true /* retrieved via id, resolving will not change anything */); } else { // Schema with fragment pointing to sub schema - final ValidationContext validationContext = createValidationContext(schemaNode); + final SchemaContext schemaContext = createSchemaContext(schemaNode); SchemaLocation documentLocation = new SchemaLocation(schemaUri.getAbsoluteIri()); - Schema document = doCreate(validationContext, documentLocation, evaluationPath, schemaNode, null, false); + Schema document = doCreate(schemaContext, documentLocation, evaluationPath, schemaNode, null, false); return document.getRefSchema(schemaUri.getFragment()); } } catch (IOException e) { diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index 4194120ad..4ce716e75 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -59,8 +59,8 @@ protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory) { protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory) { Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri)); - Dialect.Builder builder = Dialect.builder(iri, schema.getValidationContext().getDialect()); - Version specification = schema.getValidationContext().getDialect().getSpecification(); + Dialect.Builder builder = Dialect.builder(iri, schema.getSchemaContext().getDialect()); + Version specification = schema.getSchemaContext().getDialect().getSpecification(); if (specification != null) { if (specification.getOrder() >= Version.DRAFT_2019_09.getOrder()) { // Process vocabularies diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 19002fd1c..bcb41e960 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -25,7 +25,7 @@ import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Vocabularies; import com.networknt.schema.Vocabulary; import com.networknt.schema.VocabularyFactory; @@ -437,7 +437,7 @@ public Version getSpecification() { /** * Creates a new validator of the keyword. * - * @param validationContext the validation context + * @param schemaContext the schema context * @param schemaLocation the schema location * @param evaluationPath the evaluation path * @param keyword the keyword @@ -445,30 +445,30 @@ public Version getSpecification() { * @param parentSchema the parent schema * @return the validator */ - public KeywordValidator newValidator(ValidationContext validationContext, SchemaLocation schemaLocation, + public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword, JsonNode schemaNode, Schema parentSchema) { try { Keyword kw = this.keywords.get(keyword); if (kw == null) { - if (keyword.equals(validationContext.getSchemaRegistryConfig().getErrorMessageKeyword())) { + if (keyword.equals(schemaContext.getSchemaRegistryConfig().getErrorMessageKeyword())) { return null; } - if (validationContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) { + if (schemaContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) { return null; } if (ValidatorTypeCode.DISCRIMINATOR.getValue().equals(keyword) - && validationContext.isDiscriminatorKeywordEnabled()) { + && schemaContext.isDiscriminatorKeywordEnabled()) { return ValidatorTypeCode.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, - parentSchema, validationContext); + parentSchema, schemaContext); } kw = this.builder.unknownKeywordFactory != null - ? this.builder.unknownKeywordFactory.getKeyword(keyword, validationContext) - : UnknownKeywordFactory.getInstance().getKeyword(keyword, validationContext); + ? this.builder.unknownKeywordFactory.getKeyword(keyword, schemaContext) + : UnknownKeywordFactory.getInstance().getKeyword(keyword, schemaContext); if (kw == null) { return null; } } - return kw.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext); + return kw.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof JsonSchemaException) { logger.error("Error:", e); diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index be2d33512..1516e5f9e 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -7,7 +7,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; @@ -17,21 +17,21 @@ public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, Keyword keyword, - ValidationContext validationContext) { - super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - Version dialect = this.validationContext.getDialect().getSpecification(); + SchemaContext schemaContext) { + super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + Version dialect = this.schemaContext.getDialect().getSpecification(); if (dialect == null || dialect.getOrder() < Version.DRAFT_2019_09.getOrder()) { assertionsEnabled = true; } else { // Check vocabulary assertionsEnabled = isFormatAssertionVocabularyEnabled(dialect, - this.validationContext.getDialect().getVocabularies()); + this.schemaContext.getDialect().getVocabularies()); } } protected boolean isFormatAssertionVocabularyEnabled() { - return isFormatAssertionVocabularyEnabled(this.validationContext.getDialect().getSpecification(), - this.validationContext.getDialect().getVocabularies()); + return isFormatAssertionVocabularyEnabled(this.schemaContext.getDialect().getSpecification(), + this.schemaContext.getDialect().getVocabularies()); } protected boolean isFormatAssertionVocabularyEnabled(Version specification, Map vocabularies) { diff --git a/src/main/java/com/networknt/schema/format/DurationFormat.java b/src/main/java/com/networknt/schema/format/DurationFormat.java index 9fc33df6d..9b62b10ed 100644 --- a/src/main/java/com/networknt/schema/format/DurationFormat.java +++ b/src/main/java/com/networknt/schema/format/DurationFormat.java @@ -5,7 +5,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Format; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Format for duration. @@ -17,7 +17,7 @@ public class DurationFormat implements Format { private static final Pattern LAX = Pattern.compile("^(?:[-+]?)P(?:[-+]?[0-9]+Y)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+W)?(?:[-+]?[0-9]+D)?(?:T(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$", Pattern.CASE_INSENSITIVE); @Override - public boolean matches(ExecutionContext executionContext, ValidationContext validationContext, String duration) { + public boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, String duration) { if (null == duration) { return true; } @@ -26,13 +26,13 @@ public boolean matches(ExecutionContext executionContext, ValidationContext vali return false; } - Pattern pattern = isStrictValidation(validationContext) ? STRICT : LAX; + Pattern pattern = isStrictValidation(schemaContext) ? STRICT : LAX; Matcher matcher = pattern.matcher(duration); return matcher.matches(); } - protected boolean isStrictValidation(ValidationContext validationContext) { - return validationContext.getSchemaRegistryConfig().isStrict(DURATION); + protected boolean isStrictValidation(SchemaContext schemaContext) { + return schemaContext.getSchemaRegistryConfig().isStrict(DURATION); } @Override diff --git a/src/main/java/com/networknt/schema/format/RegexFormat.java b/src/main/java/com/networknt/schema/format/RegexFormat.java index 191e6364f..c8bffe841 100644 --- a/src/main/java/com/networknt/schema/format/RegexFormat.java +++ b/src/main/java/com/networknt/schema/format/RegexFormat.java @@ -15,7 +15,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Format; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.regex.RegularExpression; /** @@ -23,10 +23,10 @@ */ public class RegexFormat implements Format { @Override - public boolean matches(ExecutionContext executionContext, ValidationContext validationContext, String value) { + public boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, String value) { if (null == value) return true; try { - RegularExpression.compile(value, validationContext); + RegularExpression.compile(value, schemaContext); return true; } catch (RuntimeException e) { return false; diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index 52ec1a352..f659f8d98 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; @@ -46,14 +46,14 @@ public class AdditionalPropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, - ValidationContext validationContext) { - super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { allowAdditionalProperties = schemaNode.booleanValue(); additionalPropertiesSchema = null; } else if (schemaNode.isObject()) { allowAdditionalProperties = true; - additionalPropertiesSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + additionalPropertiesSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { allowAdditionalProperties = false; additionalPropertiesSchema = null; @@ -73,7 +73,7 @@ public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath if (patternPropertiesNode != null) { this.patternProperties = new ArrayList<>(patternPropertiesNode.size()); for (Iterator it = patternPropertiesNode.fieldNames(); it.hasNext(); ) { - patternProperties.add(RegularExpression.compile(it.next(), validationContext)); + patternProperties.add(RegularExpression.compile(it.next(), schemaContext)); } } else { this.patternProperties = Collections.emptyList(); diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index ccc7b2382..d4a95f351 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -28,7 +28,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for allOf. @@ -36,10 +36,10 @@ public class AllOfValidator extends BaseKeywordValidator { private final List schemas; - public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -49,7 +49,7 @@ public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath int size = schemaNode.size(); this.schemas = new ArrayList<>(size); for (int i = 0; i < size; i++) { - this.schemas.add(validationContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), + this.schemas.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), schemaNode.get(i), parentSchema)); } } @@ -66,7 +66,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } else { schema.walk(executionContext, node, rootNode, instanceLocation, true); } - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { final Iterator arrayElements = this.schemaNode.elements(); while (arrayElements.hasNext()) { final ObjectNode allOfEntry = (ObjectNode) arrayElements.next(); diff --git a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java index b4ff720c4..6cfa243e5 100644 --- a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Used for Keywords that have no validation aspect, but are part of the metaschema, where annotations may need to be collected. @@ -30,7 +30,7 @@ public class AnnotationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext, Keyword keyword) { + Schema parentSchema, SchemaContext schemaContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); } @@ -63,7 +63,7 @@ public AnnotationKeyword(String keyword) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); + Schema parentSchema, SchemaContext schemaContext) { + return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext, this); } } diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 767fa0e93..4ff176ed3 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -40,10 +40,10 @@ public class AnyOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -53,7 +53,7 @@ public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath int size = schemaNode.size(); this.schemas = new ArrayList<>(size); for (int i = 0; i < size; i++) { - this.schemas.add(validationContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), + this.schemas.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), schemaNode.get(i), parentSchema)); } } @@ -66,7 +66,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { executionContext.enterDiscriminatorContext(new DiscriminatorContext(), instanceLocation); } int numberOfValidSubSchemas = 0; @@ -107,13 +107,13 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo numberOfValidSubSchemas++; } - if (errors.isEmpty() && (!this.validationContext.isDiscriminatorKeywordEnabled()) + if (errors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) && canShortCircuit() && canShortCircuit(executionContext)) { // Clear all errors. Note that this is checked in finally. allErrors = null; executionContext.setErrors(existingErrors); return; - } else if (this.validationContext.isDiscriminatorKeywordEnabled()) { + } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { DiscriminatorContext currentDiscriminatorContext = executionContext.getCurrentDiscriminatorContext(); if (currentDiscriminatorContext.isDiscriminatorMatchFound() || currentDiscriminatorContext.isDiscriminatorIgnore()) { @@ -147,7 +147,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { executionContext.setFailFast(failFast); } - if (this.validationContext.isDiscriminatorKeywordEnabled() + if (this.schemaContext.isDiscriminatorKeywordEnabled() && executionContext.getCurrentDiscriminatorContext().isActive() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) @@ -159,7 +159,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { return; } } finally { - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { executionContext.leaveDiscriminatorContextImmediately(instanceLocation); } } diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 7ef55b917..78e5c4dca 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.Collection; import java.util.Map; @@ -31,7 +31,7 @@ * Base {@link KeywordValidator}. */ public abstract class BaseKeywordValidator extends AbstractKeywordValidator { - protected final ValidationContext validationContext; + protected final SchemaContext schemaContext; protected final Schema parentSchema; protected final Map errorMessage; @@ -39,15 +39,15 @@ public abstract class BaseKeywordValidator extends AbstractKeywordValidator { protected final Schema evaluationParentSchema; public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, - Schema parentSchema, ValidationContext validationContext, + Schema parentSchema, SchemaContext schemaContext, JsonNodePath evaluationPath) { super(keyword, schemaNode, schemaLocation, evaluationPath); - this.validationContext = validationContext; + this.schemaContext = schemaContext; this.parentSchema = parentSchema; - if (keyword != null && parentSchema != null && validationContext.getSchemaRegistryConfig().getErrorMessageKeyword() != null) { + if (keyword != null && parentSchema != null && schemaContext.getSchemaRegistryConfig().getErrorMessageKeyword() != null) { this.errorMessage = ErrorMessages.getErrorMessage(parentSchema, - validationContext.getSchemaRegistryConfig().getErrorMessageKeyword(), keyword.getValue()); + schemaContext.getSchemaRegistryConfig().getErrorMessageKeyword(), keyword.getValue()); } else { this.errorMessage = null; } @@ -59,7 +59,7 @@ public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation * @param keyword the keyword * @param schemaNode the schema node * @param schemaLocation the schema location - * @param validationContext the validation context + * @param schemaContext the schema context * @param parentSchema the parent schema * @param evaluationPath the evaluation path * @param evaluationParentSchema the evaluation parent schema @@ -69,13 +69,13 @@ protected BaseKeywordValidator( Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, - ValidationContext validationContext, + SchemaContext schemaContext, Schema parentSchema, JsonNodePath evaluationPath, Schema evaluationParentSchema, Map errorMessage) { super(keyword, schemaNode, schemaLocation, evaluationPath); - this.validationContext = validationContext; + this.schemaContext = schemaContext; this.parentSchema = parentSchema; this.errorMessage = errorMessage; @@ -156,7 +156,7 @@ protected boolean hasAdjacentKeywordInEvaluationPath(String keyword) { protected MessageSourceError.Builder error() { return MessageSourceError - .builder(this.validationContext.getSchemaRegistryConfig().getMessageSource(), this.errorMessage) + .builder(this.schemaContext.getSchemaRegistryConfig().getMessageSource(), this.errorMessage) .schemaNode(this.schemaNode).schemaLocation(this.schemaLocation).evaluationPath(this.evaluationPath) .keyword(this.getKeyword()).messageKey(this.getKeyword()); } diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index 449c7087f..a2d537ca4 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -20,15 +20,15 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for const. */ public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { public ConstValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 1574f66ec..0506eb2f8 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import static com.networknt.schema.keyword.VersionCode.MinV201909; @@ -47,18 +47,18 @@ public class ContainsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes // slightly. - this.isMinV201909 = MinV201909.getVersions().contains(this.validationContext.getDialect().getSpecification()); + this.isMinV201909 = MinV201909.getVersions().contains(this.schemaContext.getDialect().getSpecification()); Integer currentMax = null; Integer currentMin = null; if (schemaNode.isObject() || schemaNode.isBoolean()) { - this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); JsonNode parentSchemaNode = parentSchema.getSchemaNode(); Optional maxNode = Optional .ofNullable(parentSchemaNode.get(ValidatorTypeCode.MAX_CONTAINS.getValue())) diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 050c3c9e9..a656ce5d6 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.Base64; @@ -43,11 +43,11 @@ public class ContentEncodingValidator extends BaseKeywordValidator { * @param evaluationPath the evaluation path * @param schemaNode the schema node * @param parentSchema the parent schema - * @param validationContext the validation context + * @param schemaContext the schema context */ public ContentEncodingValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, validationContext, + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentEncoding = schemaNode.textValue(); } @@ -69,7 +69,7 @@ private boolean matches(String value) { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { // Ignore non-strings - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 477f652cd..a85b845a4 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -28,7 +28,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -48,11 +48,11 @@ public class ContentMediaTypeValidator extends BaseKeywordValidator { * @param evaluationPath the evaluation path * @param schemaNode the schema node * @param parentSchema the parent schema - * @param validationContext the validation context + * @param schemaContext the schema context */ public ContentMediaTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); } @@ -92,7 +92,7 @@ else if (!PATTERN.matcher(this.contentMediaType).matches()) { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { // Ignore non-strings - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 5a1a24fed..a65d0b61e 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -39,11 +39,11 @@ public class DependenciesValidator extends BaseKeywordValidator implements Keywo * @param evaluationPath the evaluation path * @param schemaNode the schema node * @param parentSchema the parent schema - * @param validationContext the validation context + * @param schemaContext the schema context */ - public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); @@ -58,7 +58,7 @@ public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluat depsProps.add(pvalue.get(i).asText()); } } else if (pvalue.isObject() || pvalue.isBoolean()) { - schemaDeps.put(pname, validationContext.newSchema(schemaLocation.append(pname), + schemaDeps.put(pname, schemaContext.newSchema(schemaLocation.append(pname), evaluationPath.append(pname), pvalue, parentSchema)); } } diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 4e149d1d9..98a907d0f 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -31,9 +31,9 @@ public class DependentRequired extends BaseKeywordValidator implements KeywordValidator { private final Map> propertyDependencies = new HashMap<>(); - public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 73cd8c0ac..2e8cec445 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -31,15 +31,15 @@ public class DependentSchemas extends BaseKeywordValidator { private final Map schemaDependencies = new HashMap<>(); - public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); JsonNode pvalue = schemaNode.get(pname); if (pvalue.isObject() || pvalue.isBoolean()) { - this.schemaDependencies.put(pname, validationContext.newSchema(schemaLocation.append(pname), + this.schemaDependencies.put(pname, schemaContext.newSchema(schemaLocation.append(pname), evaluationPath.append(pname), pvalue, parentSchema)); } } diff --git a/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java b/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java index 64c3dd5f2..30afa000b 100644 --- a/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/DisallowUnknownKeywordFactory.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Unknown keyword factory that rejects unknown keywords. @@ -29,7 +29,7 @@ public class DisallowUnknownKeywordFactory implements KeywordFactory { private static final Logger logger = LoggerFactory.getLogger(DisallowUnknownKeywordFactory.class); @Override - public Keyword getKeyword(String value, ValidationContext validationContext) { + public Keyword getKeyword(String value, SchemaContext schemaContext) { logger.error("Keyword '{}' is unknown and must be configured on the meta-schema or vocabulary", value); throw new InvalidSchemaException(Error.builder() .message("Keyword ''{0}'' is unknown and must be configured on the meta-schema or vocabulary") diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index cd112a005..10eab0c56 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -30,7 +30,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} that resolves discriminator. @@ -40,8 +40,8 @@ public class DiscriminatorValidator extends BaseKeywordValidator { private final Map mapping; public DiscriminatorValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, validationContext, + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; if (discriminator != null) { diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index daa6de84b..a236d1dfb 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.function.Supplier; @@ -36,22 +36,22 @@ public class DynamicRefValidator extends BaseKeywordValidator { protected final JsonSchemaRef schema; - public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); - this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); + this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { String ref = resolve(parentSchema, refValue); return new JsonSchemaRef(getSupplier(() -> { - Schema refSchema = validationContext.getDynamicAnchors().get(ref); + Schema refSchema = schemaContext.getDynamicAnchors().get(ref); if (refSchema == null) { // This is a $dynamicRef without a matching $dynamicAnchor // A $dynamicRef without a matching $dynamicAnchor in the same schema resource // behaves like a normal $ref to $anchor // A $dynamicRef without anchor in fragment behaves identical to $ref - JsonSchemaRef r = RefValidator.getRefSchema(parentSchema, validationContext, refValue, evaluationPath); + JsonSchemaRef r = RefValidator.getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); if (r != null) { refSchema = r.getSchema(); } @@ -67,7 +67,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat if (!baseAbsoluteIri.equals(absoluteIri)) { absoluteIri = baseAbsoluteIri; String parentRef = SchemaLocation.resolve(base.getSchemaLocation(), anchor); - Schema parentRefSchema = validationContext.getDynamicAnchors().get(parentRef); + Schema parentRefSchema = schemaContext.getDynamicAnchors().get(parentRef); if (parentRefSchema != null) { refSchema = parentRefSchema; } @@ -79,7 +79,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat refSchema = refSchema.fromRef(parentSchema, evaluationPath); } return refSchema; - }, validationContext.getSchemaRegistryConfig().isCacheRefs())); + }, schemaContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { @@ -170,8 +170,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 54d2566d6..6c2b4785c 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.math.BigDecimal; import java.util.Collections; @@ -48,8 +48,8 @@ static String asText(JsonNode node) { return node.asText(); } - public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); StringBuilder sb = new StringBuilder(); @@ -74,7 +74,7 @@ public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, } // check if the parent schema declares the fields as nullable - if (validationContext.isNullableKeywordEnabled()) { + if (schemaContext.isNullableKeywordEnabled()) { JsonNode nullable = parentSchema.getSchemaNode().get("nullable"); if (nullable != null && nullable.asBoolean()) { nodes.add(NullNode.getInstance()); @@ -98,7 +98,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } else if (node.isArray()) { node = processArrayNode((ArrayNode) node); } - if (!nodes.contains(node) && !( this.validationContext.getSchemaRegistryConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { + if (!nodes.contains(node) && !( this.schemaContext.getSchemaRegistryConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(error).build()); @@ -111,7 +111,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode * @param node JsonNode to check */ private boolean isTypeLooseContainsInEnum(JsonNode node) { - if (TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()) == JsonType.STRING) { + if (TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()) == JsonType.STRING) { String nodeText = node.textValue(); for (JsonNode n : nodes) { String value = n.asText(); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index cdf6e8f24..9dc39cd41 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; import java.math.BigDecimal; @@ -36,8 +36,8 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMaximum value is not a number"); } @@ -99,7 +99,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, validationContext.getSchemaRegistryConfig())) { + if (!JsonNodeUtil.isNumber(node, schemaContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 7d1cbccea..9b1228b51 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; import java.math.BigDecimal; @@ -40,8 +40,8 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("exclusiveMinimum value is not a number"); } @@ -106,7 +106,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { + if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index e2bfda60d..0c7d0a623 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for false. @@ -28,8 +28,8 @@ public class FalseValidator extends BaseKeywordValidator implements KeywordValidator { private final String reason; - public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 47f954fbb..e8bd016d3 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.Collection; import java.util.Collections; @@ -52,13 +52,13 @@ Collection getFormats() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { Format format = null; if (schemaNode != null && schemaNode.isTextual()) { String formatName = schemaNode.textValue(); format = this.formats.get(formatName); } - return new FormatValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, format, + return new FormatValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext, format, this); } diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index a77b087ef..a48aad19f 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.format.BaseFormatJsonValidator; import org.slf4j.Logger; @@ -39,9 +39,9 @@ public class FormatValidator extends BaseFormatJsonValidator implements KeywordV private final Format format; public FormatValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext, Format format, + Schema parentSchema, SchemaContext schemaContext, Format format, Keyword keyword) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, validationContext); + super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, schemaContext); this.format = format; } @@ -73,7 +73,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode boolean assertionsEnabled = isAssertionsEnabled(executionContext); if (this.format != null) { try { - format.validate(executionContext, validationContext, node, rootNode, instanceLocation, + format.validate(executionContext, schemaContext, node, rootNode, instanceLocation, assertionsEnabled, () -> this.error().instanceNode(node).instanceLocation(instanceLocation) .messageKey(format.getMessageKey()) @@ -137,6 +137,6 @@ protected boolean createUnknownFormatAssertions(ExecutionContext executionContex * @return whether to perform strict handling */ protected boolean isStrict(ExecutionContext executionContext) { - return this.validationContext.getSchemaRegistryConfig().isStrict(getKeyword(), Boolean.FALSE); + return this.schemaContext.getSchemaRegistryConfig().isStrict(getKeyword(), Boolean.FALSE); } } diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 5d007ed69..7cba12962 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -36,8 +36,8 @@ public class IfValidator extends BaseKeywordValidator { private final Schema thenSchema; private final Schema elseSchema; - public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Schema foundIfSchema = null; Schema foundThenSchema = null; @@ -48,13 +48,13 @@ public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, J final SchemaLocation schemaLocationOfSchema = parentSchema.getSchemaLocation().append(keyword); final JsonNodePath evaluationPathOfSchema = parentSchema.getEvaluationPath().append(keyword); if (keyword.equals("if")) { - foundIfSchema = validationContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, + foundIfSchema = schemaContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, parentSchema); } else if (keyword.equals("then") && node != null) { - foundThenSchema = validationContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, + foundThenSchema = schemaContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, parentSchema); } else if (keyword.equals("else") && node != null) { - foundElseSchema = validationContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, + foundElseSchema = schemaContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, parentSchema); } } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 3291ec66d..ce042f957 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; @@ -46,8 +46,8 @@ public class ItemsValidator extends BaseKeywordValidator { private final SchemaLocation additionalItemsSchemaLocation; private final JsonNode additionalItemsSchemaNode; - public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Boolean additionalItems = null; @@ -56,13 +56,13 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath JsonNode additionalItemsSchemaNode = null; if (schemaNode.isObject() || schemaNode.isBoolean()) { - foundSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + foundSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); this.tupleSchema = Collections.emptyList(); } else { int i = 0; this.tupleSchema = new ArrayList<>(schemaNode.size()); for (JsonNode s : schemaNode) { - this.tupleSchema.add(validationContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), + this.tupleSchema.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), s, parentSchema)); i++; } @@ -73,7 +73,7 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath if (addItemNode.isBoolean()) { additionalItems = addItemNode.asBoolean(); } else if (addItemNode.isObject()) { - foundAdditionalSchema = validationContext.newSchema( + foundAdditionalSchema = schemaContext.newSchema( parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS), parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS), addItemNode, parentSchema); } @@ -91,7 +91,7 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - if (!node.isArray() && !this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { + if (!node.isArray() && !this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { // ignores non-arrays return; } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 09930b5bb..c16ed304f 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -23,7 +23,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; @@ -38,8 +38,8 @@ public class ItemsValidator202012 extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, validationContext, + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); @@ -52,7 +52,7 @@ public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluati } if (schemaNode.isObject() || schemaNode.isBoolean()) { - this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { throw new IllegalArgumentException("The value of 'items' MUST be a valid JSON Schema."); } diff --git a/src/main/java/com/networknt/schema/keyword/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java index 598359279..76ea5fef1 100644 --- a/src/main/java/com/networknt/schema/keyword/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -21,7 +21,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Represents a keyword. @@ -41,11 +41,11 @@ public interface Keyword { * @param evaluationPath the evaluation path * @param schemaNode the schema node * @param parentSchema the parent schema - * @param validationContext the validation context + * @param schemaContext the schema context * @return the validation * @throws JsonSchemaException the exception * @throws Exception the exception */ KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception; + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception; } diff --git a/src/main/java/com/networknt/schema/keyword/KeywordFactory.java b/src/main/java/com/networknt/schema/keyword/KeywordFactory.java index 8711b5d96..f1f6967d2 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordFactory.java @@ -15,7 +15,7 @@ */ package com.networknt.schema.keyword; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Factory for {@link Keyword}. @@ -26,8 +26,8 @@ public interface KeywordFactory { * Gets the keyword given the keyword value. * * @param value the keyword value - * @param validationContext the validationContext + * @param schemaContext the schemaContext * @return the keyword */ - Keyword getKeyword(String value, ValidationContext validationContext); + Keyword getKeyword(String value, SchemaContext schemaContext); } diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index 4f26cae53..cb44fad76 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for maxItems. @@ -29,8 +29,8 @@ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordValidator { private final int max; - public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); } else { @@ -47,7 +47,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .locale(executionContext.getExecutionConfig().getLocale()) .arguments(this.max, node.size()).build()); } - } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { + } else if (this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { if (1 > this.max) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 865561ba4..e9d7256f7 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for maxLength. @@ -31,8 +31,8 @@ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordValidator { private final int maxLength; - public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); } else { @@ -43,7 +43,7 @@ public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { // ignore no-string typs return; diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index c2a03d776..81278c493 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator}for maxProperties. @@ -30,8 +30,8 @@ public class MaxPropertiesValidator extends BaseKeywordValidator implements Keyw private final int max; public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, - ValidationContext validationContext) { - super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index d455497df..1a0d79653 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; import java.math.BigDecimal; @@ -41,8 +41,8 @@ public class MaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("maximum value is not a number"); } @@ -114,7 +114,7 @@ public String thresholdValue() { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { + if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index 877621c32..2e6dda007 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for minItems. @@ -29,8 +29,8 @@ public class MinItemsValidator extends BaseKeywordValidator implements KeywordValidator { private int min = 0; - public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } @@ -46,7 +46,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .arguments(min, node.size()) .build()); } - } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose()) { + } else if (this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { if (1 < min) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index f4c3df7f9..2d1aa61d6 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for minLength. @@ -31,8 +31,8 @@ public class MinLengthValidator extends BaseKeywordValidator implements KeywordValidator { private int minLength; - public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { minLength = schemaNode.intValue(); @@ -42,7 +42,7 @@ public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { // ignore non-string types return; diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index bef4f7f2d..208f71365 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -5,7 +5,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.LinkedHashSet; import java.util.Set; @@ -21,8 +21,8 @@ public class MinMaxContainsValidator extends BaseKeywordValidator { private final Set analysis; public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, - ValidationContext validationContext) { - super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Set analysis = null; int min = 1; diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index 4a968ad57..c3cdffd50 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for minProperties. @@ -30,8 +30,8 @@ public class MinPropertiesValidator extends BaseKeywordValidator implements Keyw protected final int min; public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, - ValidationContext validationContext) { - super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index f893e03be..252f645d1 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; import java.math.BigDecimal; @@ -44,8 +44,8 @@ public class MinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new JsonSchemaException("minimum value is not a number"); @@ -121,7 +121,7 @@ public String thresholdValue() { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { + if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index 7da805246..b341323c8 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; import java.math.BigDecimal; @@ -33,8 +33,8 @@ public class MultipleOfValidator extends BaseKeywordValidator implements Keyword private final BigDecimal divisor; public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.divisor = getDivisor(schemaNode); } @@ -83,8 +83,8 @@ protected BigDecimal getDividend(JsonNode node) { // convert to BigDecimal since double type is not accurate enough to do the // division and multiple return node.isBigDecimal() ? node.decimalValue() : BigDecimal.valueOf(node.doubleValue()); - } else if (this.validationContext.getSchemaRegistryConfig().isTypeLoose() - && JsonNodeUtil.isNumber(node, this.validationContext.getSchemaRegistryConfig())) { + } else if (this.schemaContext.getSchemaRegistryConfig().isTypeLoose() + && JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // handling for type loose return new BigDecimal(node.textValue()); } diff --git a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index 204ce60b1..8a969b5bf 100644 --- a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.Iterator; import java.util.Map.Entry; @@ -33,22 +33,22 @@ public class NonValidationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext, Keyword keyword) { + Schema parentSchema, SchemaContext schemaContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); - String id = validationContext.resolveSchemaId(schemaNode); - String anchor = validationContext.getDialect().readAnchor(schemaNode); - String dynamicAnchor = validationContext.getDialect().readDynamicAnchor(schemaNode); + String id = schemaContext.resolveSchemaId(schemaNode); + String anchor = schemaContext.getDialect().readAnchor(schemaNode); + String dynamicAnchor = schemaContext.getDialect().readDynamicAnchor(schemaNode); if (id != null || anchor != null || dynamicAnchor != null) { // Used to register schema resources with $id - validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } if ("$defs".equals(keyword.getValue()) || "definitions".equals(keyword.getValue())) { for (Iterator> field = schemaNode.fields(); field.hasNext(); ) { Entry property = field.next(); SchemaLocation location = schemaLocation.append(property.getKey()); - Schema schema = validationContext.newSchema(location, evaluationPath.append(property.getKey()), + Schema schema = schemaContext.newSchema(location, evaluationPath.append(property.getKey()), property.getValue(), parentSchema); - validationContext.getSchemaReferences().put(location.toString(), schema); + schemaContext.getSchemaReferences().put(location.toString(), schema); } } } @@ -65,7 +65,7 @@ public NonValidationKeyword(String keyword) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext, this); + Schema parentSchema, SchemaContext schemaContext) { + return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext, this); } } diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index 331235b49..ec158b09c 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -31,8 +31,8 @@ public class NotAllowedValidator extends BaseKeywordValidator implements KeywordValidator { private final List fieldNames; - public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); this.fieldNames = new ArrayList<>(size); diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index 3b26f658d..a4bc3d580 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -32,9 +32,9 @@ public class NotValidator extends BaseKeywordValidator { private final Schema schema; - public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } @Override diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 21d6589d0..a765e3a75 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -30,7 +30,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for oneOf. @@ -40,10 +40,10 @@ public class OneOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { - JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new JsonSchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") @@ -54,7 +54,7 @@ public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath this.schemas = new ArrayList<>(size); for (int i = 0; i < size; i++) { JsonNode childNode = schemaNode.get(i); - this.schemas.add(validationContext.newSchema( schemaLocation.append(i), evaluationPath.append(i), childNode, parentSchema)); + this.schemas.add(schemaContext.newSchema( schemaLocation.append(i), evaluationPath.append(i), childNode, parentSchema)); } } @@ -79,7 +79,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo boolean addMessages = true; try { DiscriminatorValidator discriminator = null; - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { DiscriminatorContext discriminatorContext = new DiscriminatorContext(); executionContext.enterDiscriminatorContext(discriminatorContext, instanceLocation); @@ -116,7 +116,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo break; } - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { // The discriminator will cause all messages other than the one with the // matching discriminator to be discarded. Note that the discriminator cannot // affect the actual validation result. @@ -164,7 +164,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo index++; } - if (this.validationContext.isDiscriminatorKeywordEnabled() + if (this.schemaContext.isDiscriminatorKeywordEnabled() && (discriminator != null || executionContext.getCurrentDiscriminatorContext().isActive()) && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorMatchFound() && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { @@ -179,7 +179,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo // Restore flag executionContext.setFailFast(failFast); - if (this.validationContext.isDiscriminatorKeywordEnabled()) { + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { executionContext.leaveDiscriminatorContextImmediately(instanceLocation); } } diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 3e0040b48..d1ca7442f 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.regex.RegularExpression; import java.util.*; @@ -37,16 +37,16 @@ public class PatternPropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator = null; public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, - ValidationContext validationContext) { - super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isObject()) { throw new JsonSchemaException("patternProperties must be an object node"); } Iterator names = schemaNode.fieldNames(); while (names.hasNext()) { String name = names.next(); - RegularExpression pattern = RegularExpression.compile(name, validationContext); - schemas.put(pattern, validationContext.newSchema(schemaLocation.append(name), evaluationPath.append(name), + RegularExpression pattern = RegularExpression.compile(name, schemaContext); + schemas.put(pattern, schemaContext.newSchema(schemaLocation.append(name), evaluationPath.append(name), schemaNode.get(name), parentSchema)); } } diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index c0290e79b..5cb1a4ecd 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -25,7 +25,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.regex.RegularExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,12 +37,12 @@ public class PatternValidator extends BaseKeywordValidator { private final String pattern; private final RegularExpression compiledPattern; - public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); try { - this.compiledPattern = RegularExpression.compile(this.pattern, validationContext); + this.compiledPattern = RegularExpression.compile(this.pattern, schemaContext); } catch (RuntimeException e) { e.setStackTrace(new StackTraceElement[0]); logger.error("Failed to compile pattern '{}': {}", this.pattern, e.getMessage()); @@ -58,7 +58,7 @@ private boolean matches(String value) { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 3fada33c9..db8b0d717 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; @@ -38,14 +38,14 @@ public class PrefixItemsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { int i = 0; this.tupleSchema = new ArrayList<>(schemaNode.size()); for (JsonNode s : schemaNode) { - this.tupleSchema.add(validationContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), s, + this.tupleSchema.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), s, parentSchema)); i++; } diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 3e75ec153..17804c701 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -25,7 +25,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; import com.networknt.schema.utils.JsonSchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; @@ -46,12 +46,12 @@ public class PropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; - public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); String pname = entry.getKey(); - this.schemas.put(pname, validationContext.newSchema(schemaLocation.append(pname), + this.schemas.put(pname, schemaContext.newSchema(schemaLocation.append(pname), evaluationPath.append(pname), entry.getValue(), parentSchema)); } } diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 817a5051c..ecd28f341 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -26,13 +26,13 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private final Schema innerSchema; - public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); - innerSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + innerSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index da2fdf222..b6305c30d 100644 --- a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for readOnly. @@ -32,8 +32,8 @@ public class ReadOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ReadOnlyValidator.class); - public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded ReadOnlyValidator for property {} as {}", parentSchema, "read mode"); } diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index b80bf4ff7..6aadbda71 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.function.Supplier; @@ -36,8 +36,8 @@ public class RecursiveRefValidator extends BaseKeywordValidator { protected final JsonSchemaRef schema; - public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); if (!"#".equals(refValue)) { @@ -48,19 +48,19 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat .evaluationPath(evaluationPath).arguments(refValue).build(); throw new JsonSchemaException(error); } - this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); + this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { - return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, validationContext, refValue, evaluationPath), validationContext.getSchemaRegistryConfig().isCacheRefs())); + return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { return cache ? new CachedSupplier<>(supplier) : supplier; } - static Schema getSchema(Schema parentSchema, ValidationContext validationContext, String refValue, + static Schema getSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { Schema refSchema = parentSchema.findSchemaResourceRoot(); // Get the document Schema current = refSchema; @@ -167,8 +167,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 5b0179014..8a339fd38 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.JsonSchemaException; import com.networknt.schema.JsonSchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.function.Supplier; @@ -38,13 +38,13 @@ public class RefValidator extends BaseKeywordValidator { private static final String REF_CURRENT = "#"; - public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.REF, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); - this.schema = getRefSchema(parentSchema, validationContext, refValue, evaluationPath); + this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validationContext, String refValue, + static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { // The evaluationPath is used to derive the keywordLocation final String refValueOriginal = refValue; @@ -65,11 +65,11 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat SchemaLocation schemaLocation = SchemaLocation.of(schemaUriFinal); // This should retrieve schemas regardless of the protocol that is in the uri. return new JsonSchemaRef(getSupplier(() -> { - Schema schemaResource = validationContext.getSchemaResources().get(schemaUriFinal); + Schema schemaResource = schemaContext.getSchemaResources().get(schemaUriFinal); if (schemaResource == null) { - schemaResource = validationContext.getSchemaRegistry().loadSchema(schemaLocation); + schemaResource = schemaContext.getSchemaRegistry().loadSchema(schemaLocation); if (schemaResource != null) { - copySchemaResources(validationContext, schemaResource); + copySchemaResources(schemaContext, schemaResource); } } if (index < 0) { @@ -80,14 +80,14 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat } else { String newRefValue = refValue.substring(index); String find = schemaLocation.getAbsoluteIri() + newRefValue; - Schema findSchemaResource = validationContext.getSchemaResources().get(find); + Schema findSchemaResource = schemaContext.getSchemaResources().get(find); if (findSchemaResource == null) { - findSchemaResource = validationContext.getDynamicAnchors().get(find); + findSchemaResource = schemaContext.getDynamicAnchors().get(find); } if (findSchemaResource != null) { schemaResource = findSchemaResource; } else { - schemaResource = getJsonSchema(schemaResource, validationContext, newRefValue, refValueOriginal, + schemaResource = getJsonSchema(schemaResource, schemaContext, newRefValue, refValueOriginal, evaluationPath); } if (schemaResource == null) { @@ -95,52 +95,52 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, ValidationContext validat } return schemaResource.fromRef(parentSchema, evaluationPath); } - }, validationContext.getSchemaRegistryConfig().isCacheRefs())); + }, schemaContext.getSchemaRegistryConfig().isCacheRefs())); } else if (SchemaLocation.Fragment.isAnchorFragment(refValue)) { String absoluteIri = resolve(parentSchema, refValue); // Schema resource needs to update the parent and evaluation path return new JsonSchemaRef(getSupplier(() -> { - Schema schemaResource = validationContext.getSchemaResources().get(absoluteIri); + Schema schemaResource = schemaContext.getSchemaResources().get(absoluteIri); if (schemaResource == null) { - schemaResource = validationContext.getDynamicAnchors().get(absoluteIri); + schemaResource = schemaContext.getDynamicAnchors().get(absoluteIri); } if (schemaResource == null) { - schemaResource = getJsonSchema(parentSchema, validationContext, refValue, refValueOriginal, evaluationPath); + schemaResource = getJsonSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath); } if (schemaResource == null) { return null; } return schemaResource.fromRef(parentSchema, evaluationPath); - }, validationContext.getSchemaRegistryConfig().isCacheRefs())); + }, schemaContext.getSchemaRegistryConfig().isCacheRefs())); } if (refValue.equals(REF_CURRENT)) { return new JsonSchemaRef( getSupplier(() -> parentSchema.findSchemaResourceRoot().fromRef(parentSchema, evaluationPath), - validationContext.getSchemaRegistryConfig().isCacheRefs())); + schemaContext.getSchemaRegistryConfig().isCacheRefs())); } return new JsonSchemaRef(getSupplier( - () -> getJsonSchema(parentSchema, validationContext, refValue, refValueOriginal, evaluationPath) + () -> getJsonSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath) .fromRef(parentSchema, evaluationPath), - validationContext.getSchemaRegistryConfig().isCacheRefs())); + schemaContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { return cache ? new CachedSupplier<>(supplier) : supplier; } - private static void copySchemaResources(ValidationContext validationContext, Schema schemaResource) { - if (!schemaResource.getValidationContext().getSchemaResources().isEmpty()) { - validationContext.getSchemaResources() - .putAll(schemaResource.getValidationContext().getSchemaResources()); + private static void copySchemaResources(SchemaContext schemaContext, Schema schemaResource) { + if (!schemaResource.getSchemaContext().getSchemaResources().isEmpty()) { + schemaContext.getSchemaResources() + .putAll(schemaResource.getSchemaContext().getSchemaResources()); } - if (!schemaResource.getValidationContext().getSchemaReferences().isEmpty()) { - validationContext.getSchemaReferences() - .putAll(schemaResource.getValidationContext().getSchemaReferences()); + if (!schemaResource.getSchemaContext().getSchemaReferences().isEmpty()) { + schemaContext.getSchemaReferences() + .putAll(schemaResource.getSchemaContext().getSchemaReferences()); } - if (!schemaResource.getValidationContext().getDynamicAnchors().isEmpty()) { - validationContext.getDynamicAnchors() - .putAll(schemaResource.getValidationContext().getDynamicAnchors()); + if (!schemaResource.getSchemaContext().getDynamicAnchors().isEmpty()) { + schemaContext.getDynamicAnchors() + .putAll(schemaResource.getSchemaContext().getDynamicAnchors()); } } @@ -154,7 +154,7 @@ private static String resolve(Schema parentSchema, String refValue) { } private static Schema getJsonSchema(Schema parent, - ValidationContext validationContext, + SchemaContext schemaContext, String refValue, String refValueOriginal, JsonNodePath evaluationPath) { @@ -164,14 +164,14 @@ private static Schema getJsonSchema(Schema parent, // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. // The getSubSchema potentially recurses to call back to getJsonSchema again - Schema result = validationContext.getSchemaReferences().get(schemaReference); + Schema result = schemaContext.getSchemaReferences().get(schemaReference); if (result == null) { - synchronized (validationContext.getSchemaRegistry()) { // acquire lock on shared factory object to prevent deadlock - result = validationContext.getSchemaReferences().get(schemaReference); + synchronized (schemaContext.getSchemaRegistry()) { // acquire lock on shared factory object to prevent deadlock + result = schemaContext.getSchemaReferences().get(schemaReference); if (result == null) { result = parent.getSubSchema(fragment); if (result != null) { - validationContext.getSchemaReferences().put(schemaReference, result); + schemaContext.getSchemaReferences().put(schemaReference, result); } } } @@ -256,8 +256,8 @@ public void preloadJsonSchema() { break; } } - if (this.validationContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.validationContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java index 55e467fe6..b2062c7c1 100644 --- a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.*; @@ -31,8 +31,8 @@ public class RequiredValidator extends BaseKeywordValidator implements KeywordValidator { private final List fieldNames; - public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); for (JsonNode fieldNme : schemaNode) { diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index b74b7937d..136166e9e 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -20,14 +20,14 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for true. */ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { - public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index f4671b2b4..a35040529 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; /** @@ -33,11 +33,11 @@ public class TypeValidator extends BaseKeywordValidator { private final JsonType schemaType; private final UnionTypeValidator unionTypeValidator; - public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { - this.unionTypeValidator = new UnionTypeValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, validationContext); + this.unionTypeValidator = new UnionTypeValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); } else { this.unionTypeValidator = null; } @@ -48,7 +48,7 @@ public JsonType getSchemaType() { } public boolean equalsToSchemaType(JsonNode node) { - return JsonNodeUtil.equalsToSchemaType(node, this.schemaType, this.parentSchema, this.validationContext); + return JsonNodeUtil.equalsToSchemaType(node, this.schemaType, this.parentSchema, this.schemaContext); } @Override @@ -61,7 +61,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (!equalsToSchemaType(node)) { - JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(nodeType.toString(), this.schemaType.toString()).build()); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index b178ac4f7..d7d5726e6 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Specification.Version; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -41,12 +41,12 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { private static final Version DEFAULT_VERSION = Version.DRAFT_2019_09; public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, + Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); - isMinV202012 = MinV202012.getVersions().contains(validationContext.activeDialect().orElse(DEFAULT_VERSION)); + isMinV202012 = MinV202012.getVersions().contains(schemaContext.activeDialect().orElse(DEFAULT_VERSION)); if (schemaNode.isObject() || schemaNode.isBoolean()) { - this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { throw new IllegalArgumentException("The value of 'unevaluatedItems' MUST be a valid JSON Schema."); } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 688f599f0..309b202c7 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -29,7 +29,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; /** @@ -38,11 +38,11 @@ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private final Schema schema; - public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { - this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { throw new IllegalArgumentException("The value of 'unevaluatedProperties' MUST be a valid JSON Schema."); } diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 5c85a9b6a..38a7fcd7f 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -25,7 +25,7 @@ import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Validator; import java.util.ArrayList; @@ -38,8 +38,8 @@ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordV private final List schemas; private final String error; - public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); String sep = ""; @@ -57,11 +57,11 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluation sep = ", "; if (n.isObject()) { - schemas.add(validationContext.newSchema(schemaLocation.append(ValidatorTypeCode.TYPE.getValue()), + schemas.add(schemaContext.newSchema(schemaLocation.append(ValidatorTypeCode.TYPE.getValue()), evaluationPath.append(ValidatorTypeCode.TRUE.getValue()), n, parentSchema)); } else { schemas.add(new TypeValidator(schemaLocation.append(i), evaluationPath.append(i), n, parentSchema, - validationContext)); + schemaContext)); } i++; } @@ -74,7 +74,7 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluation public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - JsonType nodeType = TypeFactory.getValueNodeType(node, validationContext.getSchemaRegistryConfig()); + JsonType nodeType = TypeFactory.getValueNodeType(node, schemaContext.getSchemaRegistryConfig()); boolean valid = false; diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index 36937c83f..b327eedaf 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import java.util.HashSet; import java.util.Set; @@ -32,8 +32,8 @@ public class UniqueItemsValidator extends BaseKeywordValidator implements KeywordValidator { private final boolean unique; - public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java b/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java index f17d9c8d5..5df3d89b3 100644 --- a/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java +++ b/src/main/java/com/networknt/schema/keyword/UnknownKeywordFactory.java @@ -21,7 +21,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Unknown keyword factory. @@ -34,7 +34,7 @@ public class UnknownKeywordFactory implements KeywordFactory { private final Map keywords = new ConcurrentHashMap<>(); @Override - public Keyword getKeyword(String value, ValidationContext validationContext) { + public Keyword getKeyword(String value, SchemaContext schemaContext) { return this.keywords.computeIfAbsent(value, keyword -> { logger.warn( "Unknown keyword {} - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword or if it should generate annotations AnnotationKeyword", diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index 7ce83b99b..5f631ee14 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -21,7 +21,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Specification.Version; import java.util.ArrayList; @@ -34,7 +34,7 @@ @FunctionalInterface interface ValidatorFactory { KeywordValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext); + Schema parentSchema, SchemaContext schemaContext); } enum VersionCode { @@ -80,7 +80,7 @@ public enum ValidatorTypeCode implements Keyword { EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), FALSE("false", FalseValidator::new, VersionCode.MinV6), FORMAT("format", null, VersionCode.MaxV7) { - @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, @@ -158,12 +158,12 @@ public static ValidatorTypeCode fromValue(String value) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) { + Schema parentSchema, SchemaContext schemaContext) { if (this.validatorFactory == null) { throw new UnsupportedOperationException("No suitable validator for " + getValue()); } return validatorFactory.newInstance(schemaLocation, evaluationPath, schemaNode, parentSchema, - validationContext); + schemaContext); } @Override diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index 28cf5c300..44d5433c7 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -8,7 +8,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for writeOnly. @@ -16,8 +16,8 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); - public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { - super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); } diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index 8b3d4b9ce..d7e64666f 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -29,7 +29,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Error; /** @@ -109,18 +109,18 @@ public static OutputUnit format(OutputUnit root, OutputUnitData data, JsonNodePa } public static OutputUnit format(Schema jsonSchema, List errors, - ExecutionContext executionContext, ValidationContext validationContext, + ExecutionContext executionContext, SchemaContext schemaContext, Function errorMapper) { OutputUnit root = new OutputUnit(); root.setValid(errors.isEmpty()); - root.setInstanceLocation(validationContext.getSchemaRegistryConfig().getPathType().getRoot()); - root.setEvaluationPath(validationContext.getSchemaRegistryConfig().getPathType().getRoot()); + root.setInstanceLocation(schemaContext.getSchemaRegistryConfig().getPathType().getRoot()); + root.setEvaluationPath(schemaContext.getSchemaRegistryConfig().getPathType().getRoot()); root.setSchemaLocation(jsonSchema.getSchemaLocation().toString()); OutputUnitData data = OutputUnitData.from(errors, executionContext, errorMapper); - return format(root, data, new JsonNodePath(validationContext.getSchemaRegistryConfig().getPathType())); + return format(root, data, new JsonNodePath(schemaContext.getSchemaRegistryConfig().getPathType())); } /** diff --git a/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java index eb5574cd3..e8fef126a 100644 --- a/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/ListOutputUnitFormatter.java @@ -23,7 +23,7 @@ import java.util.function.Function; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; import com.networknt.schema.Error; /** @@ -91,7 +91,7 @@ public static OutputUnit format(OutputUnit root, OutputUnitData data) { } public static OutputUnit format(List errors, ExecutionContext executionContext, - ValidationContext validationContext, Function errorMapper) { + SchemaContext schemaContext, Function errorMapper) { OutputUnit root = new OutputUnit(); root.setValid(errors.isEmpty()); return format(root, OutputUnitData.from(errors, executionContext, errorMapper)); diff --git a/src/main/java/com/networknt/schema/regex/RegularExpression.java b/src/main/java/com/networknt/schema/regex/RegularExpression.java index 90669897f..e3cb6950e 100644 --- a/src/main/java/com/networknt/schema/regex/RegularExpression.java +++ b/src/main/java/com/networknt/schema/regex/RegularExpression.java @@ -1,6 +1,6 @@ package com.networknt.schema.regex; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; /** * Regular expression. @@ -9,9 +9,9 @@ public interface RegularExpression { boolean matches(String value); - static RegularExpression compile(String regex, ValidationContext validationContext) { + static RegularExpression compile(String regex, SchemaContext schemaContext) { if (null == regex) return s -> true; - return validationContext.getSchemaRegistryConfig().getRegularExpressionFactory().getRegularExpression(regex); + return schemaContext.getSchemaRegistryConfig().getRegularExpressionFactory().getRegularExpression(regex); } } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index f13ac2184..5aed89d90 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -10,7 +10,7 @@ import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.Specification.Version; import com.networknt.schema.TypeFactory; -import com.networknt.schema.ValidationContext; +import com.networknt.schema.SchemaContext; public class JsonNodeUtil { private static final long V6_VALUE = Version.DRAFT_6.getOrder(); @@ -57,16 +57,16 @@ public static boolean isNodeNullable(JsonNode schema){ } //Check to see if a JsonNode is nullable with checking the isHandleNullableField - public static boolean isNodeNullable(JsonNode schema, ValidationContext validationContext) { + public static boolean isNodeNullable(JsonNode schema, SchemaContext schemaContext) { // check if the parent schema declares the fields as nullable - if (validationContext.isNullableKeywordEnabled()) { + if (schemaContext.isNullableKeywordEnabled()) { return isNodeNullable(schema); } return false; } - public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, ValidationContext validationContext) { - SchemaRegistryConfig config = validationContext.getSchemaRegistryConfig(); + public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, SchemaContext schemaContext) { + SchemaRegistryConfig config = schemaContext.getSchemaRegistryConfig(); JsonType nodeType = TypeFactory.getValueNodeType(node, config); // in the case that node type is not the same as schema type, try to convert node to the // same type of schema. In REST API, query parameters, path parameters and headers are all @@ -79,12 +79,12 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch if (schemaType == JsonType.NUMBER && nodeType == JsonType.INTEGER) { return true; } - if (schemaType == JsonType.INTEGER && nodeType == JsonType.NUMBER && node.canConvertToExactIntegral() && V6_VALUE <= detectVersion(validationContext)) { + if (schemaType == JsonType.INTEGER && nodeType == JsonType.NUMBER && node.canConvertToExactIntegral() && V6_VALUE <= detectVersion(schemaContext)) { return true; } if (nodeType == JsonType.NULL) { - if (parentSchema != null && validationContext.isNullableKeywordEnabled()) { + if (parentSchema != null && schemaContext.isNullableKeywordEnabled()) { Schema grandParentSchema = parentSchema.getParentSchema(); if (grandParentSchema != null && JsonNodeUtil.isNodeNullable(grandParentSchema.getSchemaNode()) || JsonNodeUtil.isNodeNullable(parentSchema.getSchemaNode())) { @@ -119,8 +119,8 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch return true; } - private static long detectVersion(ValidationContext validationContext) { - return validationContext.activeDialect().orElse(Version.DRAFT_4).getOrder(); + private static long detectVersion(SchemaContext schemaContext) { + return schemaContext.activeDialect().orElse(Version.DRAFT_4).getOrder(); } /** diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 27ae16609..2c2ab47bd 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -55,7 +55,7 @@ private static String toForwardSlashPath(Path file) { } private static void executeTest(Schema schema, TestSpec testSpec) { - List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List errors = schema.validate(testSpec.getData(), OutputFormat.DEFAULT, (executionContext, schemaContext) -> { executionContext.executionConfig(executionConfig -> { if (testSpec.getConfig() != null) { if (testSpec.getConfig().containsKey("readOnly")) { diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 51395f8a9..cdf67c6bd 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -265,7 +265,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } @@ -355,7 +355,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator1(schemaLocation, evaluationPath, schemaNode); } @@ -431,7 +431,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { if (schemaNode != null && schemaNode.isBoolean()) { return new CollectValidator(schemaLocation, evaluationPath, schemaNode); } diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index c067e438c..b860c9939 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -86,7 +86,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { /* * You can access the schema node here to read data from your keyword */ diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index 44c423dac..eeffe2233 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -40,7 +40,7 @@ void durationFormatValidatorTest() throws IOException { List messages = validatorSchema.validate(validTargetNode); assertEquals(0, messages.size()); - messages = validatorSchema.validate(invalidTargetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { + messages = validatorSchema.validate(invalidTargetNode, OutputFormat.DEFAULT, (executionContext, schemaContext) -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index ce914bfd5..1a92da300 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -40,13 +40,13 @@ void exampleSchemaLocation() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 - Schema refSchema = schema.getValidationContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getDialect().getIri()); + Schema refSchema = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getIri()); } @Test @@ -62,12 +62,12 @@ void exampleClasspath() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getValidationContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getIri()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 - Schema refSchema = schema.getValidationContext().getSchemaResources().get("classpath:schema/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getValidationContext().getDialect().getIri()); + Schema refSchema = schema.getSchemaContext().getSchemaResources().get("classpath:schema/example-ref.json#"); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getIri()); } } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index 55725008d..b8f5ffef0 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -35,7 +35,7 @@ public CustomFormatKeyword(Map formats) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new IllegalArgumentException(); } } diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 3f4f56dbb..2d2fa30d3 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -187,8 +187,8 @@ static class CustomNumberFormat implements Format { } @Override - public boolean matches(ExecutionContext executionContext, ValidationContext validationContext, JsonNode value) { - JsonType nodeType = TypeFactory.getValueNodeType(value, validationContext.getSchemaRegistryConfig()); + public boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, JsonNode value) { + JsonType nodeType = TypeFactory.getValueNodeType(value, schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.NUMBER && nodeType != JsonType.INTEGER) { return true; } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index 22e09467c..d5a6b1f2c 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -121,7 +121,7 @@ static Stream invalidTimeRepresentations() { @ParameterizedTest @MethodSource("invalidTimeRepresentations") void testInvalidTimeRepresentations(String jsonObject) throws JsonProcessingException { - List errors = schema.validate(new ObjectMapper().readTree(jsonObject), OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List errors = schema.validate(new ObjectMapper().readTree(jsonObject), OutputFormat.DEFAULT, (executionContext, schemaContext) -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); Assertions.assertFalse(errors.isEmpty()); diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 9dc333697..ef38b3fe7 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -165,7 +165,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, ValidationContext validationContext) throws JsonSchemaException { + Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 2377f97c3..c2e8ce52a 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -37,8 +37,8 @@ static class EqualsValidator extends BaseKeywordValidator { EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, Keyword keyword, - ValidationContext validationContext) { - super(keyword, schemaNode, schemaLocation, parentSchema, validationContext, evaluationPath); + SchemaContext schemaContext) { + super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.value = schemaNode.textValue(); } @@ -62,9 +62,9 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, - JsonNode schemaNode, Schema parentSchema, ValidationContext validationContext) + JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { - return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, validationContext); + return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, schemaContext); } } diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index e9f43eccf..3715d6e0b 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -84,7 +84,7 @@ private Error format(Error message) { @Override public java.util.List format(Schema jsonSchema, - ExecutionContext executionContext, ValidationContext validationContext) { + ExecutionContext executionContext, SchemaContext schemaContext) { return executionContext.getErrors().stream().map(this::format).collect(Collectors.toCollection(ArrayList::new)); } } diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index 7bcbe3ab8..786beab44 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -58,7 +58,7 @@ void overrideDefaultValidator() throws JsonProcessingException, IOException { final SchemaRegistry validatorFactory = SchemaRegistry.withDialect(validatorMetaSchema); final Schema validatorSchema = validatorFactory.getSchema(schema); - List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, validationContext) -> { + List messages = validatorSchema.validate(targetNode, OutputFormat.DEFAULT, (executionContext, schemaContext) -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 7edaf05fd..f83d0fd81 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -24,12 +24,12 @@ void testInvalidRecursiveReference() { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); - ValidationContext validationContext = new ValidationContext(jsonSchema.getValidationContext().getDialect(), + SchemaContext schemaContext = new SchemaContext(jsonSchema.getSchemaContext().getDialect(), jsonSchemaFactory); // Act and Assert assertThrows(JsonSchemaException.class, () -> { - new RecursiveRefValidator(SchemaLocation.of(""), new JsonNodePath(PathType.JSON_POINTER), schemaNode, null, validationContext); + new RecursiveRefValidator(SchemaLocation.of(""), new JsonNodePath(PathType.JSON_POINTER), schemaNode, null, schemaContext); }); } diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 15b6d7dd6..2b206767a 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -25,7 +25,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -47,7 +47,7 @@ void shouldLoadSchemaResource() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getValidationContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getIri()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -56,10 +56,10 @@ void shouldLoadSchemaResource() throws JsonProcessingException { assertEquals("/properties/DriverProperties/properties/CommonProperties/$ref/required", error.getEvaluationPath().toString()); assertEquals("field1", error.getProperty()); - Schema driver = schema.getValidationContext().getSchemaResources().get("https://www.example.org/driver#"); - Schema common = schema.getValidationContext().getSchemaResources().get("https://www.example.org/common#"); - assertEquals(DialectId.DRAFT_4, driver.getValidationContext().getDialect().getIri()); - assertEquals(DialectId.DRAFT_7, common.getValidationContext().getDialect().getIri()); + Schema driver = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/driver#"); + Schema common = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/common#"); + assertEquals(DialectId.DRAFT_4, driver.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, common.getSchemaContext().getDialect().getIri()); } } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 571987a8a..8d79b710f 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -86,7 +86,7 @@ void noValidation() { messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("minimum", messages.iterator().next().getKeyword()); - assertEquals(Version.DRAFT_2020_12, schema.getValidationContext().activeDialect().get()); + assertEquals(Version.DRAFT_2020_12, schema.getSchemaContext().activeDialect().get()); } @Test From de24f14fc41cf22c69e1a53745d11b0838e171ed Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:01:24 +0800 Subject: [PATCH 19/74] Remove JsonSchemaVersion --- .../networknt/schema/JsonSchemaVersion.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/JsonSchemaVersion.java diff --git a/src/main/java/com/networknt/schema/JsonSchemaVersion.java b/src/main/java/com/networknt/schema/JsonSchemaVersion.java deleted file mode 100644 index df3809820..000000000 --- a/src/main/java/com/networknt/schema/JsonSchemaVersion.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import com.networknt.schema.dialect.Dialect; - -/** - * Json schema version. - */ -public interface JsonSchemaVersion { - /** - * Gets the meta-schema. - * - * @return the instance - */ - Dialect getInstance(); -} From 2a9e0f4c617d573bb2c9a30a0ee7cd5d09262b13 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:03:42 +0800 Subject: [PATCH 20/74] Rename JsonSchemaIdValidator to SchemaIdValidator --- src/main/java/com/networknt/schema/Schema.java | 2 +- ...SchemaIdValidator.java => SchemaIdValidator.java} | 8 ++++---- .../com/networknt/schema/SchemaRegistryConfig.java | 12 ++++++------ .../schema/DefaultJsonSchemaIdValidatorTest.java | 8 ++++---- src/test/java/com/networknt/schema/Issue936Test.java | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchemaIdValidator.java => SchemaIdValidator.java} (90%) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 767bb5ecc..0248d6855 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -182,7 +182,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc resolve = id.substring(0, fragment); } SchemaLocation result = !"".equals(resolve) ? schemaLocation.resolve(resolve) : schemaLocation; - JsonSchemaIdValidator validator = schemaContext.getSchemaRegistryConfig().getSchemaIdValidator(); + SchemaIdValidator validator = schemaContext.getSchemaRegistryConfig().getSchemaIdValidator(); if (validator != null) { if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) { SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword()); diff --git a/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java b/src/main/java/com/networknt/schema/SchemaIdValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/JsonSchemaIdValidator.java rename to src/main/java/com/networknt/schema/SchemaIdValidator.java index 75d446dd0..723136ccb 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaIdValidator.java +++ b/src/main/java/com/networknt/schema/SchemaIdValidator.java @@ -21,7 +21,7 @@ /** * Validator for validating the correctness of $id. */ -public interface JsonSchemaIdValidator { +public interface SchemaIdValidator { /** * Validates if the $id value is valid. * @@ -36,10 +36,10 @@ public interface JsonSchemaIdValidator { boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext); - JsonSchemaIdValidator DEFAULT = new DefaultJsonSchemaIdValidator(); + SchemaIdValidator DEFAULT = new DefaultSchemaIdValidator(); /** - * Implementation of {@link JsonSchemaIdValidator}. + * Implementation of {@link SchemaIdValidator}. *

* Note that this does not strictly follow the specification. *

@@ -48,7 +48,7 @@ boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, *

* This also allows non-empty fragments. */ - class DefaultJsonSchemaIdValidator implements JsonSchemaIdValidator { + class DefaultSchemaIdValidator implements SchemaIdValidator { @Override public boolean validate(String id, boolean rootSchema, SchemaLocation schemaLocation, SchemaLocation resolvedSchemaLocation, SchemaContext schemaContext) { diff --git a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java index 4e463f6b1..05a857dd2 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java +++ b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java @@ -118,7 +118,7 @@ public static SchemaRegistryConfig getInstance() { /** * Used to validate the acceptable $id values. */ - private final JsonSchemaIdValidator schemaIdValidator; + private final SchemaIdValidator schemaIdValidator; /** * Contains a mapping of how strict a keyword's validators should be. @@ -142,7 +142,7 @@ protected SchemaRegistryConfig(boolean cacheRefs, Locale locale, boolean losslessNarrowing, MessageSource messageSource, PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, - RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, + RegularExpressionFactory regularExpressionFactory, SchemaIdValidator schemaIdValidator, Map strictness, boolean typeLoose) { super(); this.cacheRefs = cacheRefs; @@ -246,7 +246,7 @@ public RegularExpressionFactory getRegularExpressionFactory() { * * @return the validator */ - public JsonSchemaIdValidator getSchemaIdValidator() { + public SchemaIdValidator getSchemaIdValidator() { return schemaIdValidator; } @@ -386,7 +386,7 @@ public static abstract class BuilderSupport { protected boolean preloadJsonSchema = true; protected int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH; protected RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance(); - protected JsonSchemaIdValidator schemaIdValidator = JsonSchemaIdValidator.DEFAULT; + protected SchemaIdValidator schemaIdValidator = SchemaIdValidator.DEFAULT; protected Map strictness = new HashMap<>(0); protected boolean typeLoose = false; @@ -550,12 +550,12 @@ public T regularExpressionFactory(RegularExpressionFactory regularExpressionFact /** * Sets the schema id validator to use. *

- * Defaults to {@link JsonSchemaIdValidator#DEFAULT}. + * Defaults to {@link SchemaIdValidator#DEFAULT}. * * @param schemaIdValidator the builder * @return the builder */ - public T schemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { + public T schemaIdValidator(SchemaIdValidator schemaIdValidator) { this.schemaIdValidator = schemaIdValidator; return self(); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index af82e38e2..6c4354d8d 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -32,7 +32,7 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) + .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); @@ -48,7 +48,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"#0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) + .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @@ -58,7 +58,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"/base\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) + .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @@ -66,7 +66,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { @Test void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) + .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"))); diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index c22dfd0ea..511611f85 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -28,7 +28,7 @@ void shouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .schemaIdValidator(JsonSchemaIdValidator.DEFAULT) + .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); From 44599265b88c5e210e89a9d887c85ac55e2ab406 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:30:56 +0800 Subject: [PATCH 21/74] Rename JsonSchemaRef to SchemaRef --- .../{JsonSchemaRef.java => SchemaRef.java} | 6 ++-- .../schema/SchemaRegistryConfig.java | 36 +++++++++---------- .../schema/keyword/DynamicRefValidator.java | 14 ++++---- .../schema/keyword/ItemsValidator.java | 6 ++-- .../schema/keyword/ItemsValidator202012.java | 6 ++-- .../schema/keyword/PrefixItemsValidator.java | 6 ++-- .../schema/keyword/PropertiesValidator.java | 6 ++-- .../schema/keyword/RecursiveRefValidator.java | 12 +++---- .../schema/keyword/RefValidator.java | 18 +++++----- .../{JsonSchemaRefs.java => SchemaRefs.java} | 8 ++--- .../schema/JsonSchemaPreloadTest.java | 2 +- .../schema/walk/WalkListenerTest.java | 14 ++++---- 12 files changed, 67 insertions(+), 67 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchemaRef.java => SchemaRef.java} (86%) rename src/main/java/com/networknt/schema/utils/{JsonSchemaRefs.java => SchemaRefs.java} (87%) diff --git a/src/main/java/com/networknt/schema/JsonSchemaRef.java b/src/main/java/com/networknt/schema/SchemaRef.java similarity index 86% rename from src/main/java/com/networknt/schema/JsonSchemaRef.java rename to src/main/java/com/networknt/schema/SchemaRef.java index fc26a462e..e3193d9ce 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaRef.java +++ b/src/main/java/com/networknt/schema/SchemaRef.java @@ -18,13 +18,13 @@ import java.util.function.Supplier; /** - * Use this object instead a JsonSchema for references. + * Use this object instead a Schema for references. */ -public class JsonSchemaRef { +public class SchemaRef { private final Supplier schemaSupplier; - public JsonSchemaRef(Supplier schema) { + public SchemaRef(Supplier schema) { this.schemaSupplier = schema; } diff --git a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java index 05a857dd2..a899d98f5 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java +++ b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java @@ -45,7 +45,7 @@ public static SchemaRegistryConfig getInstance() { return Holder.INSTANCE; } - public static final int DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH = 40; + public static final int DEFAULT_PRELOAD_SCHEMA_REF_MAX_NESTING_DEPTH = 40; /** * The execution context customizer that runs by default for all schemas. @@ -103,12 +103,12 @@ public static SchemaRegistryConfig getInstance() { /** * Controls if the schema will automatically be preloaded. */ - private final boolean preloadJsonSchema; + private final boolean preloadSchema; /** * Controls the max depth of the evaluation path to preload when preloading refs. */ - private final int preloadJsonSchemaRefMaxNestingDepth; + private final int preloadSchemaRefMaxNestingDepth; /** * Used to create {@link com.networknt.schema.regex.RegularExpression}. @@ -141,7 +141,7 @@ protected SchemaRegistryConfig(boolean cacheRefs, boolean javaSemantics, Locale locale, boolean losslessNarrowing, MessageSource messageSource, PathType pathType, - boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, + boolean preloadSchema, int preloadSchemaRefMaxNestingDepth, RegularExpressionFactory regularExpressionFactory, SchemaIdValidator schemaIdValidator, Map strictness, boolean typeLoose) { super(); @@ -155,8 +155,8 @@ protected SchemaRegistryConfig(boolean cacheRefs, this.losslessNarrowing = losslessNarrowing; this.messageSource = messageSource; this.pathType = pathType; - this.preloadJsonSchema = preloadJsonSchema; - this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; + this.preloadSchema = preloadSchema; + this.preloadSchemaRefMaxNestingDepth = preloadSchemaRefMaxNestingDepth; this.regularExpressionFactory = regularExpressionFactory; this.schemaIdValidator = schemaIdValidator; this.strictness = strictness; @@ -225,8 +225,8 @@ public PathType getPathType() { * * @return the max depth to preload */ - public int getPreloadJsonSchemaRefMaxNestingDepth() { - return preloadJsonSchemaRefMaxNestingDepth; + public int getPreloadSchemaRefMaxNestingDepth() { + return preloadSchemaRefMaxNestingDepth; } /** @@ -282,7 +282,7 @@ public boolean isLosslessNarrowing() { * @return true if it should be preloaded */ public boolean isPreloadJsonSchema() { - return preloadJsonSchema; + return preloadSchema; } /** @@ -350,8 +350,8 @@ public static Builder builder(SchemaRegistryConfig config) { builder.losslessNarrowing = config.losslessNarrowing; builder.messageSource = config.messageSource; builder.pathType = config.pathType; - builder.preloadJsonSchema = config.preloadJsonSchema; - builder.preloadJsonSchemaRefMaxNestingDepth = config.preloadJsonSchemaRefMaxNestingDepth; + builder.preloadSchema = config.preloadSchema; + builder.preloadSchemaRefMaxNestingDepth = config.preloadSchemaRefMaxNestingDepth; builder.regularExpressionFactory = config.regularExpressionFactory; builder.schemaIdValidator = config.schemaIdValidator; builder.strictness = config.strictness; @@ -383,8 +383,8 @@ public static abstract class BuilderSupport { protected boolean losslessNarrowing = false; protected MessageSource messageSource = null; protected PathType pathType = PathType.JSON_POINTER; - protected boolean preloadJsonSchema = true; - protected int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH; + protected boolean preloadSchema = true; + protected int preloadSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_SCHEMA_REF_MAX_NESTING_DEPTH; protected RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance(); protected SchemaIdValidator schemaIdValidator = SchemaIdValidator.DEFAULT; protected Map strictness = new HashMap<>(0); @@ -515,7 +515,7 @@ public T pathType(PathType pathType) { * @return the builder */ public T preloadJsonSchema(boolean preloadJsonSchema) { - this.preloadJsonSchema = preloadJsonSchema; + this.preloadSchema = preloadJsonSchema; return self(); } /** @@ -523,11 +523,11 @@ public T preloadJsonSchema(boolean preloadJsonSchema) { *

* Defaults to 40. * - * @param preloadJsonSchemaRefMaxNestingDepth to preload + * @param preloadSchemaRefMaxNestingDepth to preload * @return the builder */ - public T preloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) { - this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth; + public T preloadSchemaRefMaxNestingDepth(int preloadSchemaRefMaxNestingDepth) { + this.preloadSchemaRefMaxNestingDepth = preloadSchemaRefMaxNestingDepth; return self(); } /** @@ -575,7 +575,7 @@ public SchemaRegistryConfig build() { return new SchemaRegistryConfig(cacheRefs, errorMessageKeyword, executionContextCustomizer, failFast, formatAssertionsEnabled, javaSemantics, locale, losslessNarrowing, messageSource, - pathType, preloadJsonSchema, preloadJsonSchemaRefMaxNestingDepth, + pathType, preloadSchema, preloadSchemaRefMaxNestingDepth, regularExpressionFactory, schemaIdValidator, strictness, typeLoose ); } diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index a236d1dfb..32f197875 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -34,7 +34,7 @@ * {@link KeywordValidator} that resolves $dynamicRef. */ public class DynamicRefValidator extends BaseKeywordValidator { - protected final JsonSchemaRef schema; + protected final SchemaRef schema; public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -42,16 +42,16 @@ public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, + static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { String ref = resolve(parentSchema, refValue); - return new JsonSchemaRef(getSupplier(() -> { + return new SchemaRef(getSupplier(() -> { Schema refSchema = schemaContext.getDynamicAnchors().get(ref); if (refSchema == null) { // This is a $dynamicRef without a matching $dynamicAnchor // A $dynamicRef without a matching $dynamicAnchor in the same schema resource // behaves like a normal $ref to $anchor // A $dynamicRef without anchor in fragment behaves identical to $ref - JsonSchemaRef r = RefValidator.getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); + SchemaRef r = RefValidator.getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); if (r != null) { refSchema = r.getSchema(); } @@ -140,7 +140,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root refSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - public JsonSchemaRef getSchemaRef() { + public SchemaRef getSchemaRef() { return this.schema; } @@ -171,7 +171,7 @@ public void preloadJsonSchema() { } } if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index ce042f957..d3798102d 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -21,11 +21,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.utils.JsonSchemaRefs; +import com.networknt.schema.utils.SchemaRefs; import java.util.*; @@ -319,7 +319,7 @@ else if (this.tupleSchema != null) { private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { result = getDefaultNode(schemaRef.getSchema()); } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index c16ed304f..23fcc3f4f 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -21,11 +21,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.utils.JsonSchemaRefs; +import com.networknt.schema.utils.SchemaRefs; /** * {@link KeywordValidator} for items from V2012-12. @@ -138,7 +138,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { result = getDefaultNode(schemaRef.getSchema()); } diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index db8b0d717..3aa73036b 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -21,11 +21,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.utils.JsonSchemaRefs; +import com.networknt.schema.utils.SchemaRefs; import java.util.ArrayList; import java.util.List; @@ -137,7 +137,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { result = getDefaultNode(schemaRef.getSchema()); } diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 17804c701..24f5f81c0 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -23,11 +23,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.utils.JsonSchemaRefs; +import com.networknt.schema.utils.SchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; import java.util.Collections; import java.util.Iterator; @@ -153,7 +153,7 @@ private void applyPropertyDefaults(ObjectNode node, ExecutionContext executionCo private static JsonNode getDefaultNode(Schema schema) { JsonNode result = schema.getSchemaNode().get("default"); if (result == null) { - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { result = getDefaultNode(schemaRef.getSchema()); } diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 6aadbda71..6e8e01bba 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -34,7 +34,7 @@ * {@link KeywordValidator} that resolves $recursiveRef. */ public class RecursiveRefValidator extends BaseKeywordValidator { - protected final JsonSchemaRef schema; + protected final SchemaRef schema; public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -51,9 +51,9 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, + static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { - return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); + return new SchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); } static Supplier getSupplier(Supplier supplier, boolean cache) { @@ -137,7 +137,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root refSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - public JsonSchemaRef getSchemaRef() { + public SchemaRef getSchemaRef() { return this.schema; } @@ -168,7 +168,7 @@ public void preloadJsonSchema() { } } if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 8a339fd38..9e3989d32 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonSchemaException; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -34,7 +34,7 @@ * {@link KeywordValidator} that resolves $ref. */ public class RefValidator extends BaseKeywordValidator { - protected final JsonSchemaRef schema; + protected final SchemaRef schema; private static final String REF_CURRENT = "#"; @@ -44,7 +44,7 @@ public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } - static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, + static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, JsonNodePath evaluationPath) { // The evaluationPath is used to derive the keywordLocation final String refValueOriginal = refValue; @@ -64,7 +64,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaConte String schemaUriFinal = resolve(parentSchema, refUri); SchemaLocation schemaLocation = SchemaLocation.of(schemaUriFinal); // This should retrieve schemas regardless of the protocol that is in the uri. - return new JsonSchemaRef(getSupplier(() -> { + return new SchemaRef(getSupplier(() -> { Schema schemaResource = schemaContext.getSchemaResources().get(schemaUriFinal); if (schemaResource == null) { schemaResource = schemaContext.getSchemaRegistry().loadSchema(schemaLocation); @@ -100,7 +100,7 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaConte } else if (SchemaLocation.Fragment.isAnchorFragment(refValue)) { String absoluteIri = resolve(parentSchema, refValue); // Schema resource needs to update the parent and evaluation path - return new JsonSchemaRef(getSupplier(() -> { + return new SchemaRef(getSupplier(() -> { Schema schemaResource = schemaContext.getSchemaResources().get(absoluteIri); if (schemaResource == null) { schemaResource = schemaContext.getDynamicAnchors().get(absoluteIri); @@ -115,11 +115,11 @@ static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaConte }, schemaContext.getSchemaRegistryConfig().isCacheRefs())); } if (refValue.equals(REF_CURRENT)) { - return new JsonSchemaRef( + return new SchemaRef( getSupplier(() -> parentSchema.findSchemaResourceRoot().fromRef(parentSchema, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); } - return new JsonSchemaRef(getSupplier( + return new SchemaRef(getSupplier( () -> getJsonSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath) .fromRef(parentSchema, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); @@ -226,7 +226,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root refSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - public JsonSchemaRef getSchemaRef() { + public SchemaRef getSchemaRef() { return this.schema; } @@ -257,7 +257,7 @@ public void preloadJsonSchema() { } } if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency - && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) { + && depth < this.schemaContext.getSchemaRegistryConfig().getPreloadSchemaRefMaxNestingDepth()) { jsonSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java b/src/main/java/com/networknt/schema/utils/SchemaRefs.java similarity index 87% rename from src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java rename to src/main/java/com/networknt/schema/utils/SchemaRefs.java index 279dcfc5f..fa8d8ff14 100644 --- a/src/main/java/com/networknt/schema/utils/JsonSchemaRefs.java +++ b/src/main/java/com/networknt/schema/utils/SchemaRefs.java @@ -16,16 +16,16 @@ package com.networknt.schema.utils; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.keyword.DynamicRefValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.RecursiveRefValidator; import com.networknt.schema.keyword.RefValidator; /** - * Utility methods for JsonSchemaRef. + * Utility methods for SchemaRef. */ -public class JsonSchemaRefs { +public class SchemaRefs { /** * Gets the ref. @@ -33,7 +33,7 @@ public class JsonSchemaRefs { * @param schema the schema * @return the ref */ - public static JsonSchemaRef from(Schema schema) { + public static SchemaRef from(Schema schema) { for (KeywordValidator validator : schema.getValidators()) { if (validator instanceof RefValidator) { return ((RefValidator) validator).getSchemaRef(); diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index abddf42e3..f449697d1 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -34,7 +34,7 @@ void cacheRefsFalse() { @Test void preloadSchemaRefMaxNestingDepth() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() - .preloadJsonSchemaRefMaxNestingDepth(20) + .preloadSchemaRefMaxNestingDepth(20) .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json")); diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index fdaae1d84..6b82bdd44 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -38,7 +38,7 @@ import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.JsonSchemaRef; +import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.DialectId; @@ -48,7 +48,7 @@ import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; -import com.networknt.schema.utils.JsonSchemaRefs; +import com.networknt.schema.utils.SchemaRefs; import com.networknt.schema.Error; import com.networknt.schema.ValidationResult; @@ -606,7 +606,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { Schema schema = walkEvent.getSchema(); - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { schema = schemaRef.getSchema(); } @@ -666,7 +666,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { Schema schema = walkEvent.getSchema(); - JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema); + SchemaRef schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { schema = schemaRef.getSchema(); } @@ -741,7 +741,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { // Get the schema PropertiesValidator propertiesValidator = walkEvent.getValidator(); Schema propertySchema = propertiesValidator.getSchemas().get(requiredProperty); - JsonSchemaRef schemaRef = JsonSchemaRefs.from(propertySchema); + SchemaRef schemaRef = SchemaRefs.from(propertySchema); if (schemaRef != null) { propertySchema = schemaRef.getSchema(); } @@ -804,9 +804,9 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { if (walkEvent.getInstanceNode() == null || walkEvent.getInstanceNode().isMissingNode() || walkEvent.getInstanceNode().isNull()) { Schema schema = walkEvent.getSchema(); - JsonSchemaRef schemaRef = null; + SchemaRef schemaRef = null; do { - schemaRef = JsonSchemaRefs.from(schema); + schemaRef = SchemaRefs.from(schema); if (schemaRef != null) { schema = schemaRef.getSchema(); } From b19b613eb59bd56b6a79f07fcdfc0bf0f14c8391 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:33:35 +0800 Subject: [PATCH 22/74] Rename JsonSchemaException to SchemaException --- .../networknt/schema/FailFastAssertionException.java | 2 +- .../com/networknt/schema/InvalidSchemaException.java | 2 +- src/main/java/com/networknt/schema/Schema.java | 4 ++-- ...JsonSchemaException.java => SchemaException.java} | 10 +++++----- .../java/com/networknt/schema/SchemaRegistry.java | 8 ++++---- .../schema/SpecificationVersionDetector.java | 6 +++--- .../java/com/networknt/schema/dialect/Dialect.java | 12 ++++++------ .../com/networknt/schema/keyword/AllOfValidator.java | 4 ++-- .../com/networknt/schema/keyword/AnyOfValidator.java | 4 ++-- .../schema/keyword/DiscriminatorValidator.java | 6 +++--- .../schema/keyword/DynamicRefValidator.java | 6 +++--- .../schema/keyword/ExclusiveMaximumValidator.java | 4 ++-- .../schema/keyword/ExclusiveMinimumValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/Keyword.java | 6 +++--- .../networknt/schema/keyword/KeywordValidator.java | 6 +++--- .../networknt/schema/keyword/MaximumValidator.java | 4 ++-- .../networknt/schema/keyword/MinimumValidator.java | 4 ++-- .../com/networknt/schema/keyword/OneOfValidator.java | 4 ++-- .../schema/keyword/PatternPropertiesValidator.java | 4 ++-- .../networknt/schema/keyword/PatternValidator.java | 4 ++-- .../schema/keyword/RecursiveRefValidator.java | 8 ++++---- .../com/networknt/schema/keyword/RefValidator.java | 6 +++--- .../networknt/schema/keyword/UnionTypeValidator.java | 4 ++-- .../schema/AbstractJsonSchemaTestSuite.java | 2 +- .../com/networknt/schema/AllOfValidatorTest.java | 4 ++-- .../com/networknt/schema/AnyOfValidatorTest.java | 2 +- .../com/networknt/schema/CollectorContextTest.java | 6 +++--- .../com/networknt/schema/CustomMetaSchemaTest.java | 8 ++++---- .../schema/ExclusiveMinimumValidatorTest.java | 4 ++-- .../networknt/schema/FormatKeywordFactoryTest.java | 2 +- src/test/java/com/networknt/schema/Issue347Test.java | 6 +++--- src/test/java/com/networknt/schema/Issue406Test.java | 2 +- src/test/java/com/networknt/schema/Issue428Test.java | 2 +- src/test/java/com/networknt/schema/Issue532Test.java | 2 +- src/test/java/com/networknt/schema/Issue619Test.java | 8 ++++---- src/test/java/com/networknt/schema/JsonWalkTest.java | 2 +- src/test/java/com/networknt/schema/MessageTest.java | 2 +- .../com/networknt/schema/OneOfValidatorTest.java | 2 +- .../networknt/schema/OpenAPI30JsonSchemaTest.java | 2 +- .../schema/PatternPropertiesValidatorTest.java | 4 ++-- .../networknt/schema/PrefixItemsValidatorTest.java | 2 +- .../RecursiveReferenceValidatorExceptionTest.java | 2 +- .../schema/SpecificationVersionDetectorTest.java | 2 +- .../com/networknt/schema/UnknownMetaSchemaTest.java | 2 +- .../java/com/networknt/schema/UriMappingTest.java | 4 ++-- 45 files changed, 97 insertions(+), 97 deletions(-) rename src/main/java/com/networknt/schema/{JsonSchemaException.java => SchemaException.java} (83%) diff --git a/src/main/java/com/networknt/schema/FailFastAssertionException.java b/src/main/java/com/networknt/schema/FailFastAssertionException.java index 8185365d6..8020d0615 100644 --- a/src/main/java/com/networknt/schema/FailFastAssertionException.java +++ b/src/main/java/com/networknt/schema/FailFastAssertionException.java @@ -23,7 +23,7 @@ /** * Thrown when an assertion happens and the evaluation can fail fast. *

- * This doesn't extend off JsonSchemaException as it is used for flow control + * This doesn't extend off SchemaException as it is used for flow control * and is intended to be caught in a specific place. *

* This will be caught in the JsonSchema validate method to be passed to the diff --git a/src/main/java/com/networknt/schema/InvalidSchemaException.java b/src/main/java/com/networknt/schema/InvalidSchemaException.java index 788b0fe9a..d575429e5 100644 --- a/src/main/java/com/networknt/schema/InvalidSchemaException.java +++ b/src/main/java/com/networknt/schema/InvalidSchemaException.java @@ -21,7 +21,7 @@ /** * Thrown when an invalid schema is used. */ -public class InvalidSchemaException extends JsonSchemaException { +public class InvalidSchemaException extends SchemaException { private static final long serialVersionUID = 1L; public InvalidSchemaException(Error message, Exception cause) { diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 0248d6855..70a51f6f1 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -438,7 +438,7 @@ public Schema getRefSchema(JsonNodePath fragment) { result = this.schemaContext.getDynamicAnchors().get(anchor); } if (result == null) { - throw new JsonSchemaException("Unable to find anchor "+anchor); + throw new SchemaException("Unable to find anchor "+anchor); } return result; } @@ -634,7 +634,7 @@ private List read(JsonNode schemaNode) { .schemaLocation(schemaPath) .arguments(nodeToUse.getNodeType().toString()) .build(); - throw new JsonSchemaException(error); + throw new SchemaException(error); } this.recursiveAnchor = nodeToUse.booleanValue(); } diff --git a/src/main/java/com/networknt/schema/JsonSchemaException.java b/src/main/java/com/networknt/schema/SchemaException.java similarity index 83% rename from src/main/java/com/networknt/schema/JsonSchemaException.java rename to src/main/java/com/networknt/schema/SchemaException.java index 47a76c86b..fe94a0ef3 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaException.java +++ b/src/main/java/com/networknt/schema/SchemaException.java @@ -20,22 +20,22 @@ import java.util.List; /** - * Represents an error when processing the JsonSchema. + * Represents an error when processing the Schema. */ -public class JsonSchemaException extends RuntimeException { +public class SchemaException extends RuntimeException { private static final long serialVersionUID = -7805792737596582110L; private final Error error; - public JsonSchemaException(Error error) { + public SchemaException(Error error) { this.error = error; } - public JsonSchemaException(String message) { + public SchemaException(String message) { super(message); this.error = null; } - public JsonSchemaException(Throwable throwable) { + public SchemaException(Throwable throwable) { super(throwable); this.error = null; } diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 3c55cd22d..e726fbb9e 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -383,7 +383,7 @@ private Dialect getDialect(final JsonNode schemaNode, SchemaRegistryConfig confi private Dialect getDialectOrDefault(final JsonNode schemaNode) { final JsonNode iriNode = schemaNode.get("$schema"); if (iriNode != null && !iriNode.isNull() && !iriNode.isTextual()) { - throw new JsonSchemaException("Unknown dialect: " + iriNode); + throw new SchemaException("Unknown dialect: " + iriNode); } final String iri = iriNode == null || iriNode.isNull() ? defaultDialectId : iriNode.textValue(); return getDialect(iri); @@ -437,7 +437,7 @@ public Schema getSchema(final String schema, InputFormat inputFormat) { return newSchema(null, schemaNode); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); - throw new JsonSchemaException(ioe); + throw new SchemaException(ioe); } } @@ -470,7 +470,7 @@ public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat) return newSchema(null, schemaNode); } catch (IOException ioe) { logger.error("Failed to load json schema!", ioe); - throw new JsonSchemaException(ioe); + throw new SchemaException(ioe); } } @@ -542,7 +542,7 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { } } catch (IOException e) { logger.error("Failed to load json schema from {}", schemaUri.getAbsoluteIri(), e); - JsonSchemaException exception = new JsonSchemaException("Failed to load json schema from "+schemaUri.getAbsoluteIri()); + SchemaException exception = new SchemaException("Failed to load json schema from "+schemaUri.getAbsoluteIri()); exception.initCause(e); throw exception; } diff --git a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java index 9a91af1e4..92731c396 100644 --- a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java @@ -52,14 +52,14 @@ private SpecificationVersionDetector() { /** * Detects schema version based on the schema tag: if the schema tag is not present, throws - * {@link JsonSchemaException} with the corresponding message, otherwise - returns the detected spec version. + * {@link SchemaException} with the corresponding message, otherwise - returns the detected spec version. * * @param jsonNode JSON Node to read from * @return Spec version if present, otherwise throws an exception */ public static Version detect(JsonNode jsonNode) { return detectOptionalVersion(jsonNode, true).orElseThrow( - () -> new JsonSchemaException("'" + SCHEMA_TAG + "' tag is not present") + () -> new SchemaException("'" + SCHEMA_TAG + "' tag is not present") ); } @@ -79,7 +79,7 @@ public static Optional detectOptionalVersion(JsonNode jsonNode, boolean if (throwIfUnsupported) { return Version.fromDialectId(schemaUri) - .orElseThrow(() -> new JsonSchemaException("'" + schemaTagValue + "' is unrecognizable schema")); + .orElseThrow(() -> new SchemaException("'" + schemaTagValue + "' is unrecognizable schema")); } else { return Version.fromDialectId(schemaUri).orElse(null); } diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index bcb41e960..71537de2f 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -22,7 +22,7 @@ import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; import com.networknt.schema.SchemaContext; @@ -470,17 +470,17 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation } return kw.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); } catch (InvocationTargetException e) { - if (e.getTargetException() instanceof JsonSchemaException) { + if (e.getTargetException() instanceof SchemaException) { logger.error("Error:", e); - throw (JsonSchemaException) e.getTargetException(); + throw (SchemaException) e.getTargetException(); } logger.warn("Could not load validator {}", keyword); - throw new JsonSchemaException(e.getTargetException()); - } catch (JsonSchemaException e) { + throw new SchemaException(e.getTargetException()); + } catch (SchemaException e) { throw e; } catch (Exception e) { logger.warn("Could not load validator {}", keyword); - throw new JsonSchemaException(e); + throw new SchemaException(e); } } diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index d4a95f351..f9d5af8e6 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -40,7 +40,7 @@ public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new JsonSchemaException(error().instanceNode(schemaNode) + throw new SchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 4ff176ed3..1de7a731e 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -44,7 +44,7 @@ public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new JsonSchemaException(error().instanceNode(schemaNode) + throw new SchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 10eab0c56..571cadb8d 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -28,7 +28,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -144,7 +144,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr // this is where A -> B -> C inheritance exists, A has the root discriminator and B adds to the mapping final JsonNode propertyName = discriminatorOnSchema.get("propertyName"); if (null != propertyName) { - throw new JsonSchemaException(instanceLocation + " schema " + schema + " attempts redefining the discriminator property"); + throw new SchemaException(instanceLocation + " schema " + schema + " attempts redefining the discriminator property"); } final ObjectNode mappingOnContextDiscriminator = (ObjectNode) discriminator.get("mapping"); final ObjectNode mappingOnCurrentSchemaDiscriminator = (ObjectNode) discriminatorOnSchema.get("mapping"); @@ -163,7 +163,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr final JsonNode currentMappingValue = mappingOnContextDiscriminator.get(mappingKeyToAdd); if (null != currentMappingValue && currentMappingValue != mappingValueToAdd) { - throw new JsonSchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd + throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd + "/" + currentMappingValue + " to " + mappingValueToAdd); } else if (null == currentMappingValue) { mappingOnContextDiscriminator.set(mappingKeyToAdd, mappingValueToAdd); diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 32f197875..746b5cc86 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -149,10 +149,10 @@ public void preloadJsonSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); - } catch (JsonSchemaException e) { + } catch (SchemaException e) { throw e; } catch (RuntimeException e) { - throw new JsonSchemaException(e); + throw new SchemaException(e); } // Check for circular dependency // Only one cycle is pre-loaded diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 9dc39cd41..a17557182 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; @@ -39,7 +39,7 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { - throw new JsonSchemaException("exclusiveMaximum value is not a number"); + throw new SchemaException("exclusiveMaximum value is not a number"); } final String maximumText = schemaNode.asText(); if ((schemaNode.isLong() || schemaNode.isInt()) && (JsonType.INTEGER.toString().equals(getNodeFieldType()))) { diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 9b1228b51..64f5436c4 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; @@ -43,7 +43,7 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { - throw new JsonSchemaException("exclusiveMinimum value is not a number"); + throw new SchemaException("exclusiveMinimum value is not a number"); } final String minimumText = schemaNode.asText(); if ((schemaNode.isLong() || schemaNode.isInt()) && JsonType.INTEGER.toString().equals(getNodeFieldType())) { diff --git a/src/main/java/com/networknt/schema/keyword/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java index 76ea5fef1..d42d72450 100644 --- a/src/main/java/com/networknt/schema/keyword/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -43,9 +43,9 @@ public interface Keyword { * @param parentSchema the parent schema * @param schemaContext the schema context * @return the validation - * @throws JsonSchemaException the exception + * @throws SchemaException the exception * @throws Exception the exception */ KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception; + Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception; } diff --git a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java index 632f4860a..abadc61b4 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java @@ -16,7 +16,7 @@ package com.networknt.schema.keyword; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.Validator; /** @@ -27,11 +27,11 @@ public interface KeywordValidator extends Validator { * In case the {@link com.networknt.schema.keyword.KeywordValidator} has a related {@link com.networknt.schema.Schema} or several * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. * - * @throws JsonSchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.Schema} or nested schemas + * @throws SchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.Schema} or nested schemas * are invalid (like $ref not resolving) * @since 1.0.54 */ - default void preloadJsonSchema() throws JsonSchemaException { + default void preloadJsonSchema() throws SchemaException { // do nothing by default - to be overridden in subclasses } diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 1a0d79653..681b3bf99 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; @@ -44,7 +44,7 @@ public class MaximumValidator extends BaseKeywordValidator { public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { - throw new JsonSchemaException("maximum value is not a number"); + throw new SchemaException("maximum value is not a number"); } JsonNode exclusiveMaximumNode = getParentSchema().getSchemaNode().get(PROPERTY_EXCLUSIVE_MAXIMUM); diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index 252f645d1..cb1002c11 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.ThresholdMixin; @@ -48,7 +48,7 @@ public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPa super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { - throw new JsonSchemaException("minimum value is not a number"); + throw new SchemaException("minimum value is not a number"); } JsonNode exclusiveMinimumNode = getParentSchema().getSchemaNode().get(PROPERTY_EXCLUSIVE_MINIMUM); diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index a765e3a75..6f703703f 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -44,7 +44,7 @@ public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new JsonSchemaException(error().instanceNode(schemaNode) + throw new SchemaException(error().instanceNode(schemaNode) .instanceLocation(schemaLocation.getFragment()) .messageKey("type") .arguments(nodeType.toString(), "array") diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index d1ca7442f..a578e1d2e 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -40,7 +40,7 @@ public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath ev SchemaContext schemaContext) { super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isObject()) { - throw new JsonSchemaException("patternProperties must be an object node"); + throw new SchemaException("patternProperties must be an object node"); } Iterator names = schemaNode.fieldNames(); while (names.hasNext()) { diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index 5cb1a4ecd..fecf06f82 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.FailFastAssertionException; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -70,7 +70,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode .arguments(this.pattern).build()); return; } - } catch (JsonSchemaException | FailFastAssertionException e) { + } catch (SchemaException | FailFastAssertionException e) { throw e; } catch (RuntimeException e) { logger.error("Failed to apply pattern '{}' at {}: {}", this.pattern, instanceLocation, e.getMessage()); diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 6e8e01bba..7ad0d8192 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -46,7 +46,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat .message("The value of a $recursiveRef must be '#' but is '{0}'").instanceLocation(schemaLocation.getFragment()) .instanceNode(this.schemaNode) .evaluationPath(evaluationPath).arguments(refValue).build(); - throw new JsonSchemaException(error); + throw new SchemaException(error); } this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } @@ -146,10 +146,10 @@ public void preloadJsonSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); - } catch (JsonSchemaException e) { + } catch (SchemaException e) { throw e; } catch (RuntimeException e) { - throw new JsonSchemaException(e); + throw new SchemaException(e); } // Check for circular dependency // Only one cycle is pre-loaded diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 9e3989d32..ceb9787a1 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaRefException; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -235,10 +235,10 @@ public void preloadJsonSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); - } catch (JsonSchemaException e) { + } catch (SchemaException e) { throw e; } catch (RuntimeException e) { - throw new JsonSchemaException(e); + throw new SchemaException(e); } // Check for circular dependency // Only one cycle is pre-loaded diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 38a7fcd7f..11f225c42 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonNodePath; import com.networknt.schema.Schema; -import com.networknt.schema.JsonSchemaException; +import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; @@ -46,7 +46,7 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluation errorBuilder.append('['); if (!schemaNode.isArray()) { - throw new JsonSchemaException("Expected array for type property on Union Type Definition."); + throw new SchemaException("Expected array for type property on Union Type Definition."); } int i = 0; diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 2c2ab47bd..4f42bb8b2 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -199,7 +199,7 @@ private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { SchemaRegistry schemaRegistry = buildSchemaRegistry(defaultVersion, testCase, configBuilder.build()); return buildTest(schemaRegistry, testSpec); })); - } catch (JsonSchemaException e) { + } catch (SchemaException e) { String msg = e.getMessage(); if (msg.endsWith("' is unrecognizable schema")) { return dynamicContainer(testCase.getDisplayName(), unsupportedMetaSchema(testCase)); diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index f4a878f9a..d58fb9a0c 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -24,7 +24,7 @@ class AllOfValidatorTest { @Test - void invalidTypeShouldThrowJsonSchemaException() { + void invalidTypeShouldThrowSchemaException() { String schemaData = "{\r\n" + " \"$defs\": {\r\n" + " \"User\": true\r\n" @@ -34,7 +34,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 5d25de103..57f7be084 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -34,7 +34,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index cdf67c6bd..f07576433 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -265,7 +265,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } @@ -355,7 +355,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator1(schemaLocation, evaluationPath, schemaNode); } @@ -431,7 +431,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isBoolean()) { return new CollectValidator(schemaLocation, evaluationPath, schemaNode); } diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index b860c9939..1b489b6f9 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -86,16 +86,16 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException, Exception { + Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { /* * You can access the schema node here to read data from your keyword */ if (!schemaNode.isArray()) { - throw new JsonSchemaException("Keyword enumNames needs to receive an array"); + throw new SchemaException("Keyword enumNames needs to receive an array"); } JsonNode parentSchemaNode = parentSchema.getSchemaNode(); if (!parentSchemaNode.has("enum")) { - throw new JsonSchemaException("Keyword enumNames needs to have a sibling enum keyword"); + throw new SchemaException("Keyword enumNames needs to have a sibling enum keyword"); } JsonNode enumSchemaNode = parentSchemaNode.get("enum"); @@ -105,7 +105,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath private List readStringList(JsonNode node) { if (!node.isArray()) { - throw new JsonSchemaException("Keyword enum needs to receive an array"); + throw new SchemaException("Keyword enum needs to receive an array"); } ArrayList result = new ArrayList(node.size()); for (JsonNode child : node) { diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 6cb2a180b..48e17dfff 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -72,7 +72,7 @@ void draftV6ShouldNotAllowExclusiveMinimumBoolean() { Dialect dialect = Dialect.builder(Dialects.getDraft6()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); - assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); } @Test @@ -90,6 +90,6 @@ void draftV7ShouldNotAllowExclusiveMinimumBoolean() { Dialect dialect = Dialect.builder(Dialects.getDraft7()) .unknownKeywordFactory(DisallowUnknownKeywordFactory.getInstance()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); - assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); } } diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index b8f5ffef0..a6c927cc4 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -48,6 +48,6 @@ void shouldUseFormatKeyword() { String schemaData = "{\r\n" + " \"format\": \"hello\"\r\n" + "}"; - assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); } } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index 2a598187e..92f479056 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -12,12 +12,12 @@ class Issue347Test { @Test void failure() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); - assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); + assertThrows(SchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); } catch (Throwable e) { - assertThat(e, instanceOf(JsonSchemaException.class)); - assertEquals("/$id: 'test' is not a valid $id", ((JsonSchemaException) e).getError().toString()); + assertThat(e, instanceOf(SchemaException.class)); + assertEquals("/$id: 'test' is not a valid $id", ((SchemaException) e).getError().toString()); } } } diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index d356bcc32..16bd64977 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -24,7 +24,7 @@ void testPreloadingNotHappening() { void testPreloadingHappening() { final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); - Assertions.assertThrows(JsonSchemaException.class, + Assertions.assertThrows(SchemaException.class, new Executable() { @Override public void execute() { diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index e61ff943c..7de9d3b5c 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -77,7 +77,7 @@ private void runTestFile(String testCaseFile) throws Exception { } - } catch (JsonSchemaException e) { + } catch (SchemaException e) { throw new IllegalStateException(String.format("Current schema should not be invalid: %s", testCaseFile), e); } } diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index d82283c4c..6247f894e 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -8,7 +8,7 @@ class Issue532Test { @Test void failure() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); - JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { + SchemaException ex = assertThrows(SchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); assertEquals("Unknown dialect: true", ex.getMessage()); diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index 4f12ce8ae..39049ab24 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -156,19 +156,19 @@ void uriThatPointsToSchemaWithIdThatHasDifferentUri_Uri() throws Exception { void uriThatPointsToSchemaThatDoesNotExistShouldFail_Ref() { Schema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:data/schema-that-does-not-exist.json#/definitions/something\" }"); - assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); + assertThrows(SchemaException.class, () -> referencingNonexistentSchema.validate(one)); } @Test void uriThatPointsToSchemaThatDoesNotExistShouldFail_Uri() { - assertThrows(JsonSchemaException.class, () -> factory.getSchema(SchemaLocation.of("resource:data/schema-that-does-not-exist.json#/definitions/something"))); + assertThrows(SchemaException.class, () -> factory.getSchema(SchemaLocation.of("resource:data/schema-that-does-not-exist.json#/definitions/something"))); } @Test void uriThatPointsToNodeThatDoesNotExistShouldFail_Ref() { Schema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/node-that-does-not-exist\" }"); - assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); + assertThrows(SchemaException.class, () -> referencingNonexistentSchema.validate(one)); } @Test @@ -180,6 +180,6 @@ void uriThatPointsToNodeThatDoesNotExistShouldFail_Uri() { } catch (InterruptedException e) { e.printStackTrace(); } - assertThrows(JsonSchemaException.class, () -> factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/node-that-does-not-exist"))); + assertThrows(SchemaException.class, () -> factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/node-that-does-not-exist"))); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index ef38b3fe7..42d3d7ec1 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -165,7 +165,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) throws JsonSchemaException { + Schema parentSchema, SchemaContext schemaContext) throws SchemaException { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index c2e8ce52a..9cefae19d 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -63,7 +63,7 @@ public String getValue() { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) - throws JsonSchemaException, Exception { + throws SchemaException, Exception { return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, schemaContext); } } diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 180c36125..917d314ac 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -141,7 +141,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " }\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); - JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> factory.getSchema(schemaData)); + SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index cd0563ff8..947574c1d 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -79,7 +79,7 @@ private void runTestFile(String testCaseFile) throws Exception { assertFalse(errors.isEmpty()); } } - } catch (JsonSchemaException e) { + } catch (SchemaException e) { throw new IllegalStateException(String.format("Current schema should not be invalid: %s", testCaseFile), e); } } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index bc5aacd9d..14c934d2f 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -40,7 +40,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testInvalidPatternPropertiesValidator() throws Exception { - Assertions.assertThrows(JsonSchemaException.class, () -> { + Assertions.assertThrows(SchemaException.class, () -> { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}"); @@ -52,7 +52,7 @@ void testInvalidPatternPropertiesValidator() throws Exception { @Test void testInvalidPatternPropertiesValidatorECMA262() throws Exception { - Assertions.assertThrows(JsonSchemaException.class, () -> { + Assertions.assertThrows(SchemaException.class, () -> { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 043d0bc36..03428945a 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -38,7 +38,7 @@ void testEmptyPrefixItemsException() { Stream dynamicNodeStream = createTests(Specification.Version.DRAFT_7, "src/test/resources/prefixItemsException"); dynamicNodeStream.forEach( dynamicNode -> { - assertThrows(JsonSchemaException.class, () -> { + assertThrows(SchemaException.class, () -> { ((DynamicContainer) dynamicNode).getChildren().forEach(dynamicNode1 -> { }); }); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index f83d0fd81..d8db9b125 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -28,7 +28,7 @@ void testInvalidRecursiveReference() { jsonSchemaFactory); // Act and Assert - assertThrows(JsonSchemaException.class, () -> { + assertThrows(SchemaException.class, () -> { new RecursiveRefValidator(SchemaLocation.of(""), new JsonNodePath(PathType.JSON_POINTER), schemaNode, null, schemaContext); }); } diff --git a/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java index 4afbbd7bb..f4ae94789 100644 --- a/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java +++ b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java @@ -41,7 +41,7 @@ void detectVersion(String resourceDirectory, Specification.Version expectedFlag) void detectInvalidSchemaVersion(String schemaPath, String expectedError) throws IOException { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(schemaPath); JsonNode node = mapper.readTree(in); - JsonSchemaException exception = assertThrows(JsonSchemaException.class, () -> SpecificationVersionDetector.detect(node)); + SchemaException exception = assertThrows(SchemaException.class, () -> SpecificationVersionDetector.detect(node)); assertEquals(expectedError, exception.getMessage()); } diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index 4d007bff3..fc2ae30d9 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -60,7 +60,7 @@ void testSchema3() throws IOException { } @Test - void testNormalize() throws JsonSchemaException { + void testNormalize() throws SchemaException { String uri01 = "http://json-schema.org/draft-07/schema"; String uri02 = "http://json-schema.org/draft-07/schema#"; diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 6071297d6..0104387a7 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -91,7 +91,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { Schema schema = instance.getSchema(example); schema.validate(mapper.createObjectNode()); fail("Expected exception not thrown"); - } catch (JsonSchemaException ex) { + } catch (SchemaException ex) { Throwable cause = ex.getCause(); if (!(cause instanceof IOException )) { fail("Unexpected cause for JsonSchemaException", ex); @@ -158,7 +158,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { Schema schema = instance.getSchema(example); schema.validate(mapper.createObjectNode()); fail("Expected exception not thrown"); - } catch (JsonSchemaException ex) { + } catch (SchemaException ex) { Throwable cause = ex.getCause(); if (!(cause instanceof IOException)) { fail("Unexpected cause for JsonSchemaException"); From deacb503fcb908278678810bdf3afdb98cd6ceda Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:35:23 +0800 Subject: [PATCH 23/74] Rename JsonNodePath to NodePath --- src/main/java/com/networknt/schema/Error.java | 24 ++++---- .../networknt/schema/ExecutionContext.java | 4 +- .../java/com/networknt/schema/Format.java | 4 +- .../{JsonNodePath.java => NodePath.java} | 32 +++++------ .../java/com/networknt/schema/Schema.java | 56 +++++++++---------- .../com/networknt/schema/SchemaContext.java | 4 +- .../com/networknt/schema/SchemaLocation.java | 22 ++++---- .../com/networknt/schema/SchemaRegistry.java | 8 +-- .../java/com/networknt/schema/Validator.java | 6 +- .../schema/annotation/JsonNodeAnnotation.java | 22 ++++---- .../JsonNodeAnnotationPredicate.java | 22 ++++---- .../annotation/JsonNodeAnnotations.java | 8 +-- .../com/networknt/schema/dialect/Dialect.java | 4 +- .../format/BaseFormatJsonValidator.java | 4 +- .../keyword/AbstractKeywordValidator.java | 10 ++-- .../AdditionalPropertiesValidator.java | 10 ++-- .../schema/keyword/AllOfValidator.java | 10 ++-- .../schema/keyword/AnnotationKeyword.java | 8 +-- .../schema/keyword/AnyOfValidator.java | 10 ++-- .../schema/keyword/BaseKeywordValidator.java | 7 ++- .../schema/keyword/ConstValidator.java | 6 +- .../schema/keyword/ContainsValidator.java | 10 ++-- .../keyword/ContentEncodingValidator.java | 6 +- .../keyword/ContentMediaTypeValidator.java | 6 +- .../schema/keyword/DependenciesValidator.java | 6 +- .../schema/keyword/DependentRequired.java | 6 +- .../schema/keyword/DependentSchemas.java | 10 ++-- .../keyword/DiscriminatorValidator.java | 8 +-- .../schema/keyword/DynamicRefValidator.java | 10 ++-- .../schema/keyword/EnumValidator.java | 6 +- .../keyword/ExclusiveMaximumValidator.java | 6 +- .../keyword/ExclusiveMinimumValidator.java | 6 +- .../schema/keyword/FalseValidator.java | 6 +- .../schema/keyword/FormatKeyword.java | 4 +- .../schema/keyword/FormatValidator.java | 8 +-- .../networknt/schema/keyword/IfValidator.java | 10 ++-- .../schema/keyword/ItemsValidator.java | 16 +++--- .../schema/keyword/ItemsValidator202012.java | 12 ++-- .../com/networknt/schema/keyword/Keyword.java | 4 +- .../schema/keyword/MaxItemsValidator.java | 6 +- .../schema/keyword/MaxLengthValidator.java | 6 +- .../keyword/MaxPropertiesValidator.java | 6 +- .../schema/keyword/MaximumValidator.java | 6 +- .../schema/keyword/MinItemsValidator.java | 6 +- .../schema/keyword/MinLengthValidator.java | 6 +- .../keyword/MinMaxContainsValidator.java | 6 +- .../keyword/MinPropertiesValidator.java | 6 +- .../schema/keyword/MinimumValidator.java | 6 +- .../schema/keyword/MultipleOfValidator.java | 6 +- .../schema/keyword/NonValidationKeyword.java | 8 +-- .../schema/keyword/NotAllowedValidator.java | 6 +- .../schema/keyword/NotValidator.java | 10 ++-- .../schema/keyword/OneOfValidator.java | 10 ++-- .../keyword/PatternPropertiesValidator.java | 8 +-- .../schema/keyword/PatternValidator.java | 6 +- .../schema/keyword/PrefixItemsValidator.java | 14 ++--- .../schema/keyword/PropertiesValidator.java | 16 +++--- .../keyword/PropertyNamesValidator.java | 6 +- .../schema/keyword/ReadOnlyValidator.java | 6 +- .../schema/keyword/RecursiveRefValidator.java | 12 ++-- .../schema/keyword/RefValidator.java | 14 ++--- .../schema/keyword/RequiredValidator.java | 6 +- .../schema/keyword/TrueValidator.java | 6 +- .../schema/keyword/TypeValidator.java | 6 +- .../keyword/UnevaluatedItemsValidator.java | 6 +- .../UnevaluatedPropertiesValidator.java | 6 +- .../schema/keyword/UnionTypeValidator.java | 6 +- .../schema/keyword/UniqueItemsValidator.java | 6 +- .../schema/keyword/ValidatorTypeCode.java | 8 +-- .../schema/keyword/WriteOnlyValidator.java | 6 +- .../HierarchicalOutputUnitFormatter.java | 28 +++++----- .../schema/output/OutputUnitKey.java | 12 ++-- .../schema/result/JsonNodeResult.java | 12 ++-- .../schema/result/JsonNodeResults.java | 8 +-- .../com/networknt/schema/utils/JsonNodes.java | 4 +- .../walk/AbstractWalkListenerRunner.java | 4 +- .../schema/walk/ItemWalkListenerRunner.java | 6 +- .../walk/KeywordWalkListenerRunner.java | 6 +- .../walk/PropertyWalkListenerRunner.java | 6 +- .../com/networknt/schema/walk/WalkConfig.java | 6 +- .../com/networknt/schema/walk/WalkEvent.java | 8 +-- .../schema/walk/WalkListenerRunner.java | 6 +- .../com/networknt/schema/walk/Walker.java | 6 +- .../schema/CollectorContextTest.java | 24 ++++---- .../schema/CustomMetaSchemaTest.java | 6 +- .../schema/FormatKeywordFactoryTest.java | 2 +- .../com/networknt/schema/IfValidatorTest.java | 8 +-- .../com/networknt/schema/Issue467Test.java | 4 +- .../schema/ItemsValidator202012Test.java | 4 +- .../networknt/schema/ItemsValidatorTest.java | 10 ++-- .../schema/JsonNodeAnnotationsTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 8 +-- .../com/networknt/schema/MessageTest.java | 6 +- ...sonNodePathTest.java => NodePathTest.java} | 54 +++++++++--------- .../schema/PrefixItemsValidatorTest.java | 4 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../networknt/schema/SchemaLocationTest.java | 2 +- .../schema/walk/WalkListenerTest.java | 6 +- 98 files changed, 454 insertions(+), 453 deletions(-) rename src/main/java/com/networknt/schema/{JsonNodePath.java => NodePath.java} (87%) rename src/test/java/com/networknt/schema/{JsonNodePathTest.java => NodePathTest.java} (66%) diff --git a/src/main/java/com/networknt/schema/Error.java b/src/main/java/com/networknt/schema/Error.java index 8b04a66b4..843abf393 100644 --- a/src/main/java/com/networknt/schema/Error.java +++ b/src/main/java/com/networknt/schema/Error.java @@ -48,11 +48,11 @@ public class Error { private final String keyword; @JsonSerialize(using = ToStringSerializer.class) - private final JsonNodePath evaluationPath; + private final NodePath evaluationPath; @JsonSerialize(using = ToStringSerializer.class) private final SchemaLocation schemaLocation; @JsonSerialize(using = ToStringSerializer.class) - private final JsonNodePath instanceLocation; + private final NodePath instanceLocation; private final Object[] arguments; private final String messageKey; private final Supplier messageSupplier; @@ -60,8 +60,8 @@ public class Error { private final JsonNode instanceNode; private final JsonNode schemaNode; - Error(String keyword, JsonNodePath evaluationPath, SchemaLocation schemaLocation, - JsonNodePath instanceLocation, Object[] arguments, Map details, + Error(String keyword, NodePath evaluationPath, SchemaLocation schemaLocation, + NodePath instanceLocation, Object[] arguments, Map details, String messageKey, Supplier messageSupplier, JsonNode instanceNode, JsonNode schemaNode) { super(); this.keyword = keyword; @@ -82,7 +82,7 @@ public class Error { * * @return The path to the input json */ - public JsonNodePath getInstanceLocation() { + public NodePath getInstanceLocation() { return instanceLocation; } @@ -93,7 +93,7 @@ public JsonNodePath getInstanceLocation() { * * @return the evaluation path */ - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } @@ -239,9 +239,9 @@ public static abstract class BuilderSupport { public abstract S self(); protected String keyword; - protected JsonNodePath evaluationPath; + protected NodePath evaluationPath; protected SchemaLocation schemaLocation; - protected JsonNodePath instanceLocation; + protected NodePath instanceLocation; protected Object[] arguments; protected Map details; protected MessageFormat format; @@ -281,7 +281,7 @@ public S index(Integer index) { * @param instanceLocation the instance location * @return the builder */ - public S instanceLocation(JsonNodePath instanceLocation) { + public S instanceLocation(NodePath instanceLocation) { this.instanceLocation = instanceLocation; return self(); } @@ -308,7 +308,7 @@ public S schemaLocation(SchemaLocation schemaLocation) { * @param evaluationPath the evaluation path * @return the builder */ - public S evaluationPath(JsonNodePath evaluationPath) { + public S evaluationPath(NodePath evaluationPath) { this.evaluationPath = evaluationPath; return self(); } @@ -398,7 +398,7 @@ protected String getKeyword() { return keyword; } - protected JsonNodePath getEvaluationPath() { + protected NodePath getEvaluationPath() { return evaluationPath; } @@ -406,7 +406,7 @@ protected SchemaLocation getSchemaLocation() { return schemaLocation; } - protected JsonNodePath getInstanceLocation() { + protected NodePath getInstanceLocation() { return instanceLocation; } diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 95c38baf6..b472e98ce 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -191,14 +191,14 @@ public DiscriminatorContext getCurrentDiscriminatorContext() { return null; // this is the case when we get on a schema that has a discriminator, but it's not used in anyOf } - public void enterDiscriminatorContext(final DiscriminatorContext ctx, @SuppressWarnings("unused") JsonNodePath instanceLocation) { + public void enterDiscriminatorContext(final DiscriminatorContext ctx, @SuppressWarnings("unused") NodePath instanceLocation) { if (this.discriminatorContexts == null) { this.discriminatorContexts = new Stack<>(); } this.discriminatorContexts.push(ctx); } - public void leaveDiscriminatorContextImmediately(@SuppressWarnings("unused") JsonNodePath instanceLocation) { + public void leaveDiscriminatorContextImmediately(@SuppressWarnings("unused") NodePath instanceLocation) { this.discriminatorContexts.pop(); } diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/Format.java index ea25860e8..aae09c425 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/Format.java @@ -121,7 +121,7 @@ default boolean matches(ExecutionContext executionContext, SchemaContext schemaC * @return true if matches */ default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, JsonNode node, - JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) { + JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) { return matches(executionContext, schemaContext, node); } @@ -140,7 +140,7 @@ default boolean matches(ExecutionContext executionContext, SchemaContext schemaC * @param formatValidator the format validator */ default void validate(ExecutionContext executionContext, SchemaContext schemaContext, - JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, + JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, Supplier message, FormatValidator formatValidator) { if (assertionsEnabled) { diff --git a/src/main/java/com/networknt/schema/JsonNodePath.java b/src/main/java/com/networknt/schema/NodePath.java similarity index 87% rename from src/main/java/com/networknt/schema/JsonNodePath.java rename to src/main/java/com/networknt/schema/NodePath.java index a0ca579da..bea845709 100644 --- a/src/main/java/com/networknt/schema/JsonNodePath.java +++ b/src/main/java/com/networknt/schema/NodePath.java @@ -20,9 +20,9 @@ /** * Represents a path to a JSON node. */ -public class JsonNodePath implements Comparable { +public class NodePath implements Comparable { private final PathType type; - private final JsonNodePath parent; + private final NodePath parent; private final String pathSegment; private final int pathSegmentIndex; @@ -30,21 +30,21 @@ public class JsonNodePath implements Comparable { private volatile String value = null; // computed lazily private int hash = 0; // computed lazily - public JsonNodePath(PathType type) { + public NodePath(PathType type) { this.type = type; this.parent = null; this.pathSegment = null; this.pathSegmentIndex = -1; } - private JsonNodePath(JsonNodePath parent, String pathSegment) { + private NodePath(NodePath parent, String pathSegment) { this.parent = parent; this.type = parent.type; this.pathSegment = pathSegment; this.pathSegmentIndex = -1; } - private JsonNodePath(JsonNodePath parent, int pathSegmentIndex) { + private NodePath(NodePath parent, int pathSegmentIndex) { this.parent = parent; this.type = parent.type; this.pathSegment = null; @@ -56,7 +56,7 @@ private JsonNodePath(JsonNodePath parent, int pathSegmentIndex) { * * @return the parent */ - public JsonNodePath getParent() { + public NodePath getParent() { return this.parent; } @@ -66,8 +66,8 @@ public JsonNodePath getParent() { * @param token the child token * @return the path */ - public JsonNodePath append(String token) { - return new JsonNodePath(this, token); + public NodePath append(String token) { + return new NodePath(this, token); } /** @@ -76,8 +76,8 @@ public JsonNodePath append(String token) { * @param index the index * @return the path */ - public JsonNodePath append(int index) { - return new JsonNodePath(this, index); + public NodePath append(int index) { + return new NodePath(this, index); } /** @@ -133,7 +133,7 @@ public Object getElement(int index) { if (count < 0) { throw new IllegalArgumentException(""); } - JsonNodePath current = this; + NodePath current = this; for (int x = 0; x < count; x++) { current = current.parent; } @@ -157,7 +157,7 @@ public int getNameCount() { * @param other the other path * @return true if the path starts with the other path */ - public boolean startsWith(JsonNodePath other) { + public boolean startsWith(NodePath other) { int count = getNameCount(); int otherCount = other.getNameCount(); @@ -166,7 +166,7 @@ public boolean startsWith(JsonNodePath other) { } else if (otherCount == count) { return this.equals(other); } else { - JsonNodePath compare = this; + NodePath compare = this; int x = count - otherCount; while (x > 0) { compare = compare.getParent(); @@ -189,7 +189,7 @@ public boolean contains(String segment) { if (result) { return true; } - JsonNodePath path = this.getParent(); + NodePath path = this.getParent(); while (path != null) { if (segment.equals(path.pathSegment)) { return true; @@ -232,13 +232,13 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - JsonNodePath other = (JsonNodePath) obj; + NodePath other = (NodePath) obj; return Objects.equals(pathSegment, other.pathSegment) && pathSegmentIndex == other.pathSegmentIndex && type == other.type && Objects.equals(parent, other.parent); } @Override - public int compareTo(JsonNodePath other) { + public int compareTo(NodePath other) { if (this.parent != null && other.parent == null) { return 1; } else if (this.parent == null && other.parent != null) { diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 70a51f6f1..3895bf5cc 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -68,7 +68,7 @@ public class Schema implements Validator { protected final SchemaContext schemaContext; protected final boolean suppressSubSchemaRetrieval; - protected final JsonNodePath evaluationPath; + protected final NodePath evaluationPath; protected final Schema evaluationParentSchema; public JsonNode getSchemaNode() { @@ -87,7 +87,7 @@ public boolean isSuppressSubSchemaRetrieval() { return suppressSubSchemaRetrieval; } - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } @@ -121,22 +121,22 @@ private static Schema obtainSubSchemaNode(final JsonNode schemaNode, final Schem return schemaContext.getSchemaRegistry().getSchema(schemaLocation); } public static class JsonNodePathLegacy { - private static final JsonNodePath INSTANCE = new JsonNodePath(PathType.LEGACY); - public static JsonNodePath getInstance() { + private static final NodePath INSTANCE = new NodePath(PathType.LEGACY); + public static NodePath getInstance() { return INSTANCE; } } public static class JsonNodePathJsonPointer { - private static final JsonNodePath INSTANCE = new JsonNodePath(PathType.JSON_POINTER); - public static JsonNodePath getInstance() { + private static final NodePath INSTANCE = new NodePath(PathType.JSON_POINTER); + public static NodePath getInstance() { return INSTANCE; } } public static class JsonNodePathJsonPath { - private static final JsonNodePath INSTANCE = new JsonNodePath(PathType.JSON_PATH); - public static JsonNodePath getInstance() { + private static final NodePath INSTANCE = new NodePath(PathType.JSON_PATH); + public static NodePath getInstance() { return INSTANCE; } } @@ -150,7 +150,7 @@ public void validate(ExecutionContext executionContext, JsonNode node) { * * @return The path. */ - protected JsonNodePath atRoot() { + protected NodePath atRoot() { if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_POINTER)) { return JsonNodePathJsonPointer.getInstance(); } else if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.LEGACY)) { @@ -158,15 +158,15 @@ protected JsonNodePath atRoot() { } else if (this.schemaContext.getSchemaRegistryConfig().getPathType().equals(PathType.JSON_PATH)) { return JsonNodePathJsonPath.getInstance(); } - return new JsonNodePath(this.schemaContext.getSchemaRegistryConfig().getPathType()); + return new NodePath(this.schemaContext.getSchemaRegistryConfig().getPathType()); } - static Schema from(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { + static Schema from(SchemaContext schemaContext, SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { return new Schema(schemaContext, schemaLocation, evaluationPath, schemaNode, parent, suppressSubSchemaRetrieval); } private boolean hasNoFragment(SchemaLocation schemaLocation) { - JsonNodePath fragment = this.schemaLocation.getFragment(); + NodePath fragment = this.schemaLocation.getFragment(); return fragment == null || (fragment.getParent() == null && fragment.getNameCount() == 0); } @@ -204,7 +204,7 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc } } - private Schema(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, + private Schema(SchemaContext schemaContext, SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parent, boolean suppressSubSchemaRetrieval) { /* super(resolve(schemaLocation, schemaNode, parent == null, schemaContext), evaluationPath, schemaNode, parent, @@ -290,7 +290,7 @@ protected Schema( SchemaContext schemaContext, Schema parentSchema, SchemaLocation schemaLocation, - JsonNodePath evaluationPath, + NodePath evaluationPath, Schema evaluationParentSchema, Map errorMessage) { // super(suppressSubSchemaRetrieval, schemaNode, schemaContext, errorMessageType, keyword, @@ -321,13 +321,13 @@ protected Schema( * @param refEvaluationPath the ref evaluation path * @return the schema */ - public Schema fromRef(Schema refEvaluationParentSchema, JsonNodePath refEvaluationPath) { + public Schema fromRef(Schema refEvaluationParentSchema, NodePath refEvaluationPath) { SchemaContext schemaContext = new SchemaContext(this.getSchemaContext().getDialect(), this.getSchemaContext().getSchemaRegistry(), refEvaluationParentSchema.getSchemaContext().getSchemaReferences(), refEvaluationParentSchema.getSchemaContext().getSchemaResources(), refEvaluationParentSchema.getSchemaContext().getDynamicAnchors()); - JsonNodePath evaluationPath = refEvaluationPath; + NodePath evaluationPath = refEvaluationPath; Schema evaluationParentSchema = refEvaluationParentSchema; // Validator state is reset due to the changes in evaluation path boolean validatorsLoaded = false; @@ -425,7 +425,7 @@ public JsonNode getRefSchemaNode(String ref) { return node; } - public Schema getRefSchema(JsonNodePath fragment) { + public Schema getRefSchema(NodePath fragment) { if (PathType.JSON_POINTER.equals(fragment.getPathType())) { // Json Pointer return getSubSchema(fragment); @@ -450,13 +450,13 @@ public Schema getRefSchema(JsonNodePath fragment) { * @param fragment the json pointer fragment * @return the schema */ - public Schema getSubSchema(JsonNodePath fragment) { + public Schema getSubSchema(NodePath fragment) { Schema document = findSchemaResourceRoot(); Schema parent = document; Schema subSchema = null; JsonNode parentNode = parent.getSchemaNode(); SchemaLocation schemaLocation = document.getSchemaLocation(); - JsonNodePath evaluationPath = document.getEvaluationPath(); + NodePath evaluationPath = document.getEvaluationPath(); int nameCount = fragment.getNameCount(); for (int x = 0; x < nameCount; x++) { /* @@ -600,12 +600,12 @@ private List read(JsonNode schemaNode) { if (schemaNode.isBoolean()) { validators = new ArrayList<>(1); if (schemaNode.booleanValue()) { - JsonNodePath path = getEvaluationPath().append("true"); + NodePath path = getEvaluationPath().append("true"); KeywordValidator validator = this.schemaContext.newValidator(getSchemaLocation().append("true"), path, "true", schemaNode, this); validators.add(validator); } else { - JsonNodePath path = getEvaluationPath().append("false"); + NodePath path = getEvaluationPath().append("false"); KeywordValidator validator = this.schemaContext.newValidator(getSchemaLocation().append("false"), path, "false", schemaNode, this); validators.add(validator); @@ -620,7 +620,7 @@ private List read(JsonNode schemaNode) { String pname = entry.getKey(); JsonNode nodeToUse = entry.getValue(); - JsonNodePath path = getEvaluationPath().append(pname); + NodePath path = getEvaluationPath().append(pname); SchemaLocation schemaPath = getSchemaLocation().append(pname); if ("$recursiveAnchor".equals(pname)) { @@ -699,7 +699,7 @@ private long activeDialect() { /************************ START OF VALIDATE METHODS **********************************/ @Override - public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, NodePath instanceLocation) { if (this.schemaContext.isDiscriminatorKeywordEnabled()) { ObjectNode discriminator = (ObjectNode) schemaNode.get("discriminator"); if (null != discriminator && null != executionContext.getCurrentDiscriminatorContext()) { @@ -1280,19 +1280,19 @@ public ValidationResult walk(String input, InputFormat inputFormat, boolean vali * @return the validation result */ public ValidationResult walkAtNode(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean validate) { + NodePath instanceLocation, boolean validate) { return walkAtNodeInternal(executionContext, node, rootNode, instanceLocation, validate, OutputFormat.RESULT, (ExecutionContextCustomizer) null); } private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean validate, OutputFormat format, Consumer executionCustomizer) { + NodePath instanceLocation, boolean validate, OutputFormat format, Consumer executionCustomizer) { return walkAtNodeInternal(executionContext, node, rootNode, instanceLocation, validate, format, (executeContext, schemaContext) -> executionCustomizer.accept(executeContext)); } private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean validate, OutputFormat format, + NodePath instanceLocation, boolean validate, OutputFormat format, ExecutionContextCustomizer executionCustomizer) { if (executionCustomizer != null) { executionCustomizer.customize(executionContext, this.schemaContext); @@ -1304,11 +1304,11 @@ private T walkAtNodeInternal(ExecutionContext executionContext, JsonNode nod @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { // Walk through all the JSONWalker's. int currentErrors = executionContext.getErrors().size(); for (KeywordValidator validator : getValidators()) { - JsonNodePath evaluationPathWithKeyword = validator.getEvaluationPath(); + NodePath evaluationPathWithKeyword = validator.getEvaluationPath(); try { // Call all the pre-walk listeners. If at least one of the pre walk listeners // returns SKIP, then skip the walk. diff --git a/src/main/java/com/networknt/schema/SchemaContext.java b/src/main/java/com/networknt/schema/SchemaContext.java index 553e3a667..10bbfe511 100644 --- a/src/main/java/com/networknt/schema/SchemaContext.java +++ b/src/main/java/com/networknt/schema/SchemaContext.java @@ -119,11 +119,11 @@ public SchemaContext(Dialect dialect, SchemaRegistry schemaRegistry, } } - public Schema newSchema(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { + public Schema newSchema(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { return getSchemaRegistry().create(this, schemaLocation, evaluationPath, schemaNode, parentSchema); } - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, String keyword /* keyword */, JsonNode schemaNode, Schema parentSchema) { return this.dialect.newValidator(this, schemaLocation, evaluationPath, keyword, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/SchemaLocation.java b/src/main/java/com/networknt/schema/SchemaLocation.java index 18d44448d..dfedd3d6b 100644 --- a/src/main/java/com/networknt/schema/SchemaLocation.java +++ b/src/main/java/com/networknt/schema/SchemaLocation.java @@ -27,8 +27,8 @@ * applicators such as $ref or $dynamicRef. */ public class SchemaLocation { - private static final JsonNodePath JSON_POINTER = new JsonNodePath(PathType.JSON_POINTER); - private static final JsonNodePath ANCHOR = new JsonNodePath(PathType.URI_REFERENCE); + private static final NodePath JSON_POINTER = new NodePath(PathType.JSON_POINTER); + private static final NodePath ANCHOR = new NodePath(PathType.URI_REFERENCE); /** * Represents a relative schema location to the current document. @@ -36,7 +36,7 @@ public class SchemaLocation { public static final SchemaLocation DOCUMENT = new SchemaLocation(null, JSON_POINTER); private final AbsoluteIri absoluteIri; - private final JsonNodePath fragment; + private final NodePath fragment; private volatile String value = null; // computed lazily @@ -46,7 +46,7 @@ public class SchemaLocation { * @param absoluteIri canonical absolute IRI of the schema object * @param fragment the fragment */ - public SchemaLocation(AbsoluteIri absoluteIri, JsonNodePath fragment) { + public SchemaLocation(AbsoluteIri absoluteIri, NodePath fragment) { this.absoluteIri = absoluteIri; this.fragment = fragment; } @@ -77,7 +77,7 @@ public AbsoluteIri getAbsoluteIri() { * * @return the fragment */ - public JsonNodePath getFragment() { + public NodePath getFragment() { return this.fragment; } @@ -115,7 +115,7 @@ public static SchemaLocation of(String iri) { return DOCUMENT; } AbsoluteIri absoluteIri = null; - JsonNodePath fragment = JSON_POINTER; + NodePath fragment = JSON_POINTER; int index = iri.indexOf('#'); if (index == -1) { absoluteIri = AbsoluteIri.of(iri); @@ -141,7 +141,7 @@ public SchemaLocation resolve(String absoluteIriReferenceOrFragment) { if ("#".equals(absoluteIriReferenceOrFragment)) { return new SchemaLocation(this.getAbsoluteIri(), JSON_POINTER); } - JsonNodePath fragment = JSON_POINTER; + NodePath fragment = JSON_POINTER; int index = absoluteIriReferenceOrFragment.indexOf('#'); AbsoluteIri absoluteIri = this.getAbsoluteIri(); String part0 = index == -1 ? absoluteIriReferenceOrFragment @@ -211,11 +211,11 @@ public static class Fragment { * @param fragmentString the fragment * @return the path */ - public static JsonNodePath of(String fragmentString) { + public static NodePath of(String fragmentString) { if (fragmentString.startsWith("#")) { fragmentString = fragmentString.substring(1); } - JsonNodePath fragment = JSON_POINTER; + NodePath fragment = JSON_POINTER; String[] fragmentParts = fragmentString.split("/"); boolean jsonPointer = false; @@ -330,7 +330,7 @@ public static Builder builder() { */ public static class Builder { private AbsoluteIri absoluteIri; - private JsonNodePath fragment = JSON_POINTER; + private NodePath fragment = JSON_POINTER; /** * Sets the canonical absolute IRI of the schema object. @@ -365,7 +365,7 @@ protected Builder absoluteIri(String absoluteIri) { * @param fragment the fragment * @return the builder */ - protected Builder fragment(JsonNodePath fragment) { + protected Builder fragment(NodePath fragment) { this.fragment = fragment; return this; } diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index e726fbb9e..7d5caacaf 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -292,7 +292,7 @@ public static Builder builder(final SchemaRegistry blueprint) { protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schemaNode) { final SchemaContext schemaContext = createSchemaContext(schemaNode); Schema jsonSchema = doCreate(schemaContext, getSchemaLocation(schemaUri), - new JsonNodePath(schemaContext.getSchemaRegistryConfig().getPathType()), schemaNode, null, false); + new NodePath(schemaContext.getSchemaRegistryConfig().getPathType()), schemaNode, null, false); preload(jsonSchema); return jsonSchema; } @@ -321,11 +321,11 @@ private void preload(Schema schema) { } } - public Schema create(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { + public Schema create(SchemaContext schemaContext, SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema) { return doCreate(schemaContext, schemaLocation, evaluationPath, schemaNode, parentSchema, false); } - private Schema doCreate(SchemaContext schemaContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { + private Schema doCreate(SchemaContext schemaContext, SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, boolean suppressSubSchemaRetrieval) { return Schema.from(withDialect(schemaContext, schemaNode), schemaLocation, evaluationPath, schemaNode, parentSchema, suppressSubSchemaRetrieval); } @@ -527,7 +527,7 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { } final Dialect dialect = getDialectOrDefault(schemaNode); - JsonNodePath evaluationPath = new JsonNodePath(getSchemaRegistryConfig().getPathType()); + NodePath evaluationPath = new NodePath(getSchemaRegistryConfig().getPathType()); if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { // Schema without fragment diff --git a/src/main/java/com/networknt/schema/Validator.java b/src/main/java/com/networknt/schema/Validator.java index 4d78e278a..837a668d1 100644 --- a/src/main/java/com/networknt/schema/Validator.java +++ b/src/main/java/com/networknt/schema/Validator.java @@ -35,7 +35,7 @@ public interface Validator extends Walker { * @param instanceLocation the location of the instance node being processed */ void validate(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, - JsonNodePath instanceLocation); + NodePath instanceLocation); /** * This is default implementation of walk method. Its job is to call the @@ -43,7 +43,7 @@ void validate(ExecutionContext executionContext, JsonNode instanceNode, JsonNode */ @Override default void walk(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { if (instanceNode == null) { // Note that null is not the same as NullNode return; @@ -70,5 +70,5 @@ default void walk(ExecutionContext executionContext, JsonNode instanceNode, Json * * @return the evaluation path */ - JsonNodePath getEvaluationPath(); + NodePath getEvaluationPath(); } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java index 5843b11f2..60b60b09c 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java +++ b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java @@ -17,7 +17,7 @@ import java.util.Objects; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; import com.networknt.schema.keyword.Keyword; @@ -26,13 +26,13 @@ */ public class JsonNodeAnnotation { private final String keyword; - private final JsonNodePath instanceLocation; + private final NodePath instanceLocation; private final SchemaLocation schemaLocation; - private final JsonNodePath evaluationPath; + private final NodePath evaluationPath; private final Object value; - public JsonNodeAnnotation(String keyword, JsonNodePath instanceLocation, SchemaLocation schemaLocation, - JsonNodePath evaluationPath, Object value) { + public JsonNodeAnnotation(String keyword, NodePath instanceLocation, SchemaLocation schemaLocation, + NodePath evaluationPath, Object value) { super(); this.keyword = keyword; this.instanceLocation = instanceLocation; @@ -55,7 +55,7 @@ public String getKeyword() { * * @return the instance location */ - public JsonNodePath getInstanceLocation() { + public NodePath getInstanceLocation() { return instanceLocation; } @@ -75,7 +75,7 @@ public SchemaLocation getSchemaLocation() { * * @return the evaluation path */ - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } @@ -121,9 +121,9 @@ public static Builder builder() { public static class Builder { private String keyword; - private JsonNodePath instanceLocation; + private NodePath instanceLocation; private SchemaLocation schemaLocation; - private JsonNodePath evaluationPath; + private NodePath evaluationPath; private Object value; public Builder keyword(Keyword keyword) { @@ -136,7 +136,7 @@ public Builder keyword(String keyword) { return this; } - public Builder instanceLocation(JsonNodePath instanceLocation) { + public Builder instanceLocation(NodePath instanceLocation) { this.instanceLocation = instanceLocation; return this; } @@ -146,7 +146,7 @@ public Builder schemaLocation(SchemaLocation schemaLocation) { return this; } - public Builder evaluationPath(JsonNodePath evaluationPath) { + public Builder evaluationPath(NodePath evaluationPath) { this.evaluationPath = evaluationPath; return this; } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java index 5f356af12..4747d3c8e 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java +++ b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java @@ -17,15 +17,15 @@ import java.util.function.Predicate; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; /** * A predicate for filtering annotations. */ public class JsonNodeAnnotationPredicate implements Predicate { - final Predicate instanceLocationPredicate; - final Predicate evaluationPathPredicate; + final Predicate instanceLocationPredicate; + final Predicate evaluationPathPredicate; final Predicate schemaLocationPredicate; final Predicate keywordPredicate; final Predicate valuePredicate; @@ -39,8 +39,8 @@ public class JsonNodeAnnotationPredicate implements Predicate instanceLocationPredicate, - Predicate evaluationPathPredicate, Predicate schemaLocationPredicate, + protected JsonNodeAnnotationPredicate(Predicate instanceLocationPredicate, + Predicate evaluationPathPredicate, Predicate schemaLocationPredicate, Predicate keywordPredicate, Predicate valuePredicate) { super(); this.instanceLocationPredicate = instanceLocationPredicate; @@ -64,7 +64,7 @@ public boolean test(JsonNodeAnnotation t) { * * @return the predicate */ - public Predicate getInstanceLocationPredicate() { + public Predicate getInstanceLocationPredicate() { return instanceLocationPredicate; } @@ -73,7 +73,7 @@ public Predicate getInstanceLocationPredicate() { * * @return the predicate */ - public Predicate getEvaluationPathPredicate() { + public Predicate getEvaluationPathPredicate() { return evaluationPathPredicate; } @@ -117,18 +117,18 @@ public static Builder builder() { * Builder for building a {@link JsonNodeAnnotationPredicate}. */ public static class Builder { - Predicate instanceLocationPredicate; - Predicate evaluationPathPredicate; + Predicate instanceLocationPredicate; + Predicate evaluationPathPredicate; Predicate schemaLocationPredicate; Predicate keywordPredicate; Predicate valuePredicate; - public Builder instanceLocation(Predicate instanceLocationPredicate) { + public Builder instanceLocation(Predicate instanceLocationPredicate) { this.instanceLocationPredicate = instanceLocationPredicate; return this; } - public Builder evaluationPath(Predicate evaluationPathPredicate) { + public Builder evaluationPath(Predicate evaluationPathPredicate) { this.evaluationPathPredicate = evaluationPathPredicate; return this; } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java index 4e4f58278..dec3281e8 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java +++ b/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java @@ -21,7 +21,7 @@ import java.util.Map; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -38,7 +38,7 @@ public class JsonNodeAnnotations { *

* instancePath to annotation */ - private final Map> values = new LinkedHashMap<>(); + private final Map> values = new LinkedHashMap<>(); /** * Gets the annotations. @@ -47,7 +47,7 @@ public class JsonNodeAnnotations { * * @return the annotations */ - public Map> asMap() { + public Map> asMap() { return this.values; } @@ -76,7 +76,7 @@ public static class Formatter { * @param annotations the annotations * @return the formatted JSON */ - public static String format(Map> annotations) { + public static String format(Map> annotations) { Map>> results = new LinkedHashMap<>(); for (List list : annotations.values()) { for (JsonNodeAnnotation annotation : list) { diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 71537de2f..c8388503e 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -20,7 +20,7 @@ import com.networknt.schema.Error; import com.networknt.schema.Format; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; @@ -446,7 +446,7 @@ public Version getSpecification() { * @return the validator */ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation schemaLocation, - JsonNodePath evaluationPath, String keyword, JsonNode schemaNode, Schema parentSchema) { + NodePath evaluationPath, String keyword, JsonNode schemaNode, Schema parentSchema) { try { Keyword kw = this.keywords.get(keyword); if (kw == null) { diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java index 1516e5f9e..01fbcf93c 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -15,7 +15,7 @@ public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; - public BaseFormatJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public BaseFormatJsonValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, Keyword keyword, SchemaContext schemaContext) { super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); diff --git a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java index 1e76b4e1d..ce794af23 100644 --- a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; import com.networknt.schema.annotation.JsonNodeAnnotation; @@ -32,7 +32,7 @@ public abstract class AbstractKeywordValidator implements KeywordValidator { protected final JsonNode schemaNode; protected final SchemaLocation schemaLocation; - protected final JsonNodePath evaluationPath; + protected final NodePath evaluationPath; /** * Constructor. @@ -41,7 +41,7 @@ public abstract class AbstractKeywordValidator implements KeywordValidator { * @param schemaLocation the schema location * @param evaluationPath the evaluation path */ - public AbstractKeywordValidator(String keyword, JsonNode schemaNode, SchemaLocation schemaLocation, JsonNodePath evaluationPath) { + public AbstractKeywordValidator(String keyword, JsonNode schemaNode, SchemaLocation schemaLocation, NodePath evaluationPath) { this.keyword = keyword; this.schemaNode = schemaNode; this.schemaLocation = schemaLocation; @@ -55,7 +55,7 @@ public AbstractKeywordValidator(String keyword, JsonNode schemaNode, SchemaLocat * @param schemaLocation the schema location * @param evaluationPath the evaluation path */ - public AbstractKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, JsonNodePath evaluationPath) { + public AbstractKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, NodePath evaluationPath) { this(keyword.getValue(), schemaNode, schemaLocation, evaluationPath); } @@ -65,7 +65,7 @@ public SchemaLocation getSchemaLocation() { } @Override - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index f659f8d98..ced457462 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -45,7 +45,7 @@ public class AdditionalPropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; - public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, + public AdditionalPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { @@ -82,12 +82,12 @@ public AdditionalPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { if (!node.isObject()) { // ignore no object return; @@ -142,7 +142,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index f9d5af8e6..400393c81 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -36,7 +36,7 @@ public class AllOfValidator extends BaseKeywordValidator { private final List schemas; - public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); @@ -55,11 +55,11 @@ public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } - protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean walk) { + protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean walk) { for (Schema schema : this.schemas) { if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); @@ -98,7 +98,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java index 6cfa243e5..946756ff0 100644 --- a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -29,13 +29,13 @@ public class AnnotationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { - public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public Validator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (collectAnnotations(executionContext)) { Object value = getAnnotationValue(getSchemaNode()); if (value != null) { @@ -62,7 +62,7 @@ public AnnotationKeyword(String keyword) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext, this); } diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 1de7a731e..0ab7f1669 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -20,7 +20,7 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -40,7 +40,7 @@ public class AnyOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public AnyOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); @@ -60,12 +60,12 @@ public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { if (this.schemaContext.isDiscriminatorKeywordEnabled()) { executionContext.enterDiscriminatorContext(new DiscriminatorContext(), instanceLocation); } @@ -174,7 +174,7 @@ && canShortCircuit() && canShortCircuit(executionContext)) { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 78e5c4dca..92448eb1a 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ErrorMessages; import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaLocation; @@ -40,7 +41,7 @@ public abstract class BaseKeywordValidator extends AbstractKeywordValidator { public BaseKeywordValidator(Keyword keyword, JsonNode schemaNode, SchemaLocation schemaLocation, Schema parentSchema, SchemaContext schemaContext, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { super(keyword, schemaNode, schemaLocation, evaluationPath); this.schemaContext = schemaContext; @@ -71,7 +72,7 @@ protected BaseKeywordValidator( SchemaLocation schemaLocation, SchemaContext schemaContext, Schema parentSchema, - JsonNodePath evaluationPath, + NodePath evaluationPath, Schema evaluationParentSchema, Map errorMessage) { super(keyword, schemaNode, schemaLocation, evaluationPath); @@ -99,7 +100,7 @@ public Schema getParentSchema() { *

* This is the dynamic parent schema when following references. * - * @see Schema#fromRef(Schema, JsonNodePath) + * @see Schema#fromRef(Schema, NodePath) * @return the evaluation parent schema */ public Schema getEvaluationParentSchema() { diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index a2d537ca4..03b65029b 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -26,12 +26,12 @@ * {@link KeywordValidator} for const. */ public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { - public ConstValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public ConstValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (schemaNode.isNumber() && node.isNumber()) { if (schemaNode.decimalValue().compareTo(node.decimalValue()) != 0) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 0506eb2f8..6ecd7e085 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -47,7 +47,7 @@ public class ContainsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first @@ -81,7 +81,7 @@ public ContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // ignores non-arrays int actual = 0, i = 0; List indexes = new ArrayList<>(); // for the annotation @@ -94,7 +94,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode List test = new ArrayList<>(); executionContext.setErrors(test); for (JsonNode n : node) { - JsonNodePath path = instanceLocation.append(i); + NodePath path = instanceLocation.append(i); this.schema.validate(executionContext, n, rootNode, path); if (test.isEmpty()) { ++actual; @@ -185,7 +185,7 @@ public void preloadJsonSchema() { } private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode validatorTypeCode, Locale locale, - JsonNode instanceNode, JsonNodePath instanceLocation, int bounds) { + JsonNode instanceNode, NodePath instanceLocation, int bounds) { String messageKey = "contains"; if (ValidatorTypeCode.MIN_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MIN; diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index a656ce5d6..7e7107efb 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -45,7 +45,7 @@ public class ContentEncodingValidator extends BaseKeywordValidator { * @param parentSchema the parent schema * @param schemaContext the schema context */ - public ContentEncodingValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public ContentEncodingValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -67,7 +67,7 @@ private boolean matches(String value) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { // Ignore non-strings JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index a85b845a4..41e22a188 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -50,7 +50,7 @@ public class ContentMediaTypeValidator extends BaseKeywordValidator { * @param parentSchema the parent schema * @param schemaContext the schema context */ - public ContentMediaTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public ContentMediaTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); @@ -90,7 +90,7 @@ else if (!PATTERN.matcher(this.contentMediaType).matches()) { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { // Ignore non-strings JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); if (nodeType != JsonType.STRING) { diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index a65d0b61e..fc4df37d4 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -41,7 +41,7 @@ public class DependenciesValidator extends BaseKeywordValidator implements Keywo * @param parentSchema the parent schema * @param schemaContext the schema context */ - public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public DependenciesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -64,7 +64,7 @@ public DependenciesValidator(SchemaLocation schemaLocation, JsonNodePath evaluat } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); List deps = propertyDeps.get(pname); diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 98a907d0f..77a7bf2bc 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -31,7 +31,7 @@ public class DependentRequired extends BaseKeywordValidator implements KeywordValidator { private final Map> propertyDependencies = new HashMap<>(); - public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public DependentRequired(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -48,7 +48,7 @@ public DependentRequired(SchemaLocation schemaLocation, JsonNodePath evaluationP } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); List dependencies = propertyDependencies.get(pname); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 2e8cec445..56547930e 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -31,7 +31,7 @@ public class DependentSchemas extends BaseKeywordValidator { private final Map schemaDependencies = new HashMap<>(); - public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public DependentSchemas(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -47,12 +47,12 @@ public DependentSchemas(SchemaLocation schemaLocation, JsonNodePath evaluationPa @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { for (Iterator it = node.fieldNames(); it.hasNext(); ) { String pname = it.next(); Schema schema = this.schemaDependencies.get(pname); @@ -72,7 +72,7 @@ public void preloadJsonSchema() { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 571cadb8d..5d0df3246 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; @@ -39,7 +39,7 @@ public class DiscriminatorValidator extends BaseKeywordValidator { private final String propertyName; private final Map mapping; - public DiscriminatorValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -66,7 +66,7 @@ public DiscriminatorValidator(SchemaLocation schemaLocation, JsonNodePath evalua @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { // Do nothing } @@ -137,7 +137,7 @@ && noExplicitDiscriminatorKeyOverride(discriminatorMapping, jsonSchema)) { public static void registerAndMergeDiscriminator(final DiscriminatorContext currentDiscriminatorContext, final ObjectNode discriminator, final Schema schema, - final JsonNodePath instanceLocation) { + final NodePath instanceLocation) { final JsonNode discriminatorOnSchema = schema.getSchemaNode().get("discriminator"); if (null != discriminatorOnSchema && null != currentDiscriminatorContext .getDiscriminatorForPath(schema.getSchemaLocation())) { diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 746b5cc86..718298e38 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; @@ -36,14 +36,14 @@ public class DynamicRefValidator extends BaseKeywordValidator { protected final SchemaRef schema; - public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public DynamicRefValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { String ref = resolve(parentSchema, refValue); return new SchemaRef(getSupplier(() -> { Schema refSchema = schemaContext.getDynamicAnchors().get(ref); @@ -96,7 +96,7 @@ private static String resolve(Schema parentSchema, String refValue) { } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { Schema refSchema = this.schema.getSchema(); if (refSchema == null) { Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) @@ -109,7 +109,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references // with the latest config. Reset the config. diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 6c2b4785c..6ccab6e9f 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.node.DecimalNode; import com.fasterxml.jackson.databind.node.NullNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -48,7 +48,7 @@ static String asText(JsonNode node) { return node.asText(); } - public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public EnumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); @@ -92,7 +92,7 @@ public EnumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (node.isNumber()) { node = processNumberNode(node); } else if (node.isArray()) { diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index a17557182..831da1f76 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -36,7 +36,7 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public ExclusiveMaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public ExclusiveMaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMaximum value is not a number"); @@ -98,7 +98,7 @@ public String thresholdValue() { } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!JsonNodeUtil.isNumber(node, schemaContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 64f5436c4..ac9a00f30 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -40,7 +40,7 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public ExclusiveMinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public ExclusiveMinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMinimum value is not a number"); @@ -105,7 +105,7 @@ public String thresholdValue() { } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index 0c7d0a623..6e44f3ff4 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -28,12 +28,12 @@ public class FalseValidator extends BaseKeywordValidator implements KeywordValidator { private final String reason; - public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public FalseValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // For the false validator, it is always not valid executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index e8bd016d3..5a5922e58 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Format; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -52,7 +52,7 @@ Collection getFormats() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { Format format = null; if (schemaNode != null && schemaNode.isTextual()) { String formatName = schemaNode.textValue(); diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index a48aad19f..210ea0eeb 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Format; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -38,7 +38,7 @@ public class FormatValidator extends BaseFormatJsonValidator implements KeywordV private final Format format; - public FormatValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public FormatValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext, Format format, Keyword keyword) { super(schemaLocation, evaluationPath, schemaNode, parentSchema, keyword, schemaContext); @@ -57,7 +57,7 @@ protected Object getAnnotationValue() { return this.schemaNode.isTextual() ? schemaNode.textValue() : null; } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { /* * Annotations must be collected even if the format is unknown according to the specification. @@ -99,7 +99,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode * @param instanceLocation the instance location */ protected void validateUnknownFormat(ExecutionContext executionContext, - JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + JsonNode node, JsonNode rootNode, NodePath instanceLocation) { /* * Unknown formats should create an assertion if the vocab is specified * according to the specification. diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 7cba12962..088517b8d 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -36,7 +36,7 @@ public class IfValidator extends BaseKeywordValidator { private final Schema thenSchema; private final Schema elseSchema; - public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public IfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Schema foundIfSchema = null; @@ -46,7 +46,7 @@ public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, J for (final String keyword : KEYWORDS) { final JsonNode node = parentSchema.getSchemaNode().get(keyword); final SchemaLocation schemaLocationOfSchema = parentSchema.getSchemaLocation().append(keyword); - final JsonNodePath evaluationPathOfSchema = parentSchema.getEvaluationPath().append(keyword); + final NodePath evaluationPathOfSchema = parentSchema.getEvaluationPath().append(keyword); if (keyword.equals("if")) { foundIfSchema = schemaContext.newSchema(schemaLocationOfSchema, evaluationPathOfSchema, node, parentSchema); @@ -65,7 +65,7 @@ public IfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, J } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { boolean ifConditionPassed = false; @@ -106,7 +106,7 @@ public void preloadJsonSchema() { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { boolean checkCondition = node != null && shouldValidateSchema; boolean ifConditionPassed = false; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index d3798102d..b2070da96 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; @@ -42,11 +42,11 @@ public class ItemsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - private final JsonNodePath additionalItemsEvaluationPath; + private final NodePath additionalItemsEvaluationPath; private final SchemaLocation additionalItemsSchemaLocation; private final JsonNode additionalItemsSchemaNode; - public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public ItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Boolean additionalItems = null; @@ -88,7 +88,7 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!node.isArray() && !this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { @@ -152,9 +152,9 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } private boolean doValidate(ExecutionContext executionContext, int i, JsonNode node, - JsonNode rootNode, JsonNodePath instanceLocation) { + JsonNode rootNode, NodePath instanceLocation) { boolean isAdditionalItem = false; - JsonNodePath path = instanceLocation.append(i); + NodePath path = instanceLocation.append(i); if (this.schema != null) { // validate with item schema (the whole array has the same item @@ -194,7 +194,7 @@ private boolean doValidate(ExecutionContext executionContext, int i, JsonNode no } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { boolean collectAnnotations = collectAnnotations(); // Add items annotation @@ -328,7 +328,7 @@ private static JsonNode getDefaultNode(Schema schema) { } private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema, String keyword) { + NodePath instanceLocation, boolean shouldValidateSchema, String keyword) { boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, node, rootNode, instanceLocation, walkSchema, this); int currentErrors = executionContext.getErrors().size(); diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 23fcc3f4f..fc50fa6b7 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; @@ -37,7 +37,7 @@ public class ItemsValidator202012 extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public ItemsValidator202012(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -62,14 +62,14 @@ public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluati @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { // ignores non-arrays if (node.isArray()) { boolean evaluated = false; for (int i = this.prefixCount; i < node.size(); ++i) { - JsonNodePath path = instanceLocation.append(i); + NodePath path = instanceLocation.append(i); // validate with item schema (the whole array has the same item schema) if (additionalItems) { this.schema.validate(executionContext, node.get(i), rootNode, path); @@ -97,7 +97,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { if (node instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; @@ -147,7 +147,7 @@ private static JsonNode getDefaultNode(Schema schema) { } private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, diff --git a/src/main/java/com/networknt/schema/keyword/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java index d42d72450..f5cbf91b3 100644 --- a/src/main/java/com/networknt/schema/keyword/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -17,7 +17,7 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; @@ -46,6 +46,6 @@ public interface Keyword { * @throws SchemaException the exception * @throws Exception the exception */ - KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception; } diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index cb44fad76..55bb6f96f 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -29,7 +29,7 @@ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordValidator { private final int max; - public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MaxItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); @@ -38,7 +38,7 @@ public MaxItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (node.isArray()) { diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index e9d7256f7..2ede3f3ba 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -31,7 +31,7 @@ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordValidator { private final int maxLength; - public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MaxLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); @@ -40,7 +40,7 @@ public MaxLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index 81278c493..7091a280d 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -29,7 +29,7 @@ public class MaxPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { private final int max; - public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, + public MaxPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { @@ -39,7 +39,7 @@ public MaxPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evalua } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (node.isObject()) { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 681b3bf99..25a41b68f 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -41,7 +41,7 @@ public class MaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; - public MaximumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("maximum value is not a number"); @@ -111,7 +111,7 @@ public String thresholdValue() { } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index 2e6dda007..a154a0066 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -29,14 +29,14 @@ public class MinItemsValidator extends BaseKeywordValidator implements KeywordValidator { private int min = 0; - public MinItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MinItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (node.isArray()) { diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index 2d1aa61d6..f97f545ea 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -31,7 +31,7 @@ public class MinLengthValidator extends BaseKeywordValidator implements KeywordValidator { private int minLength; - public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MinLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { @@ -39,7 +39,7 @@ public MinLengthValidator(SchemaLocation schemaLocation, JsonNodePath evaluation } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 208f71365..7f8d88e76 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -20,7 +20,7 @@ public class MinMaxContainsValidator extends BaseKeywordValidator { private final Set analysis; - public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, + public MinMaxContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -63,7 +63,7 @@ public MinMaxContainsValidator(SchemaLocation schemaLocation, JsonNodePath evalu @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { if (this.analysis != null) { this.analysis.stream() .map(analysis -> error().instanceNode(node) diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index c3cdffd50..c54858881 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -29,7 +29,7 @@ public class MinPropertiesValidator extends BaseKeywordValidator implements KeywordValidator { protected final int min; - public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, + public MinPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { @@ -39,7 +39,7 @@ public MinPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evalua } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (node.isObject()) { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index cb1002c11..9d3865d9a 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -44,7 +44,7 @@ public class MinimumValidator extends BaseKeywordValidator { */ private final ThresholdMixin typedMinimum; - public MinimumValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public MinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { @@ -118,7 +118,7 @@ public String thresholdValue() { } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index b341323c8..9cb1ca826 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -32,14 +32,14 @@ public class MultipleOfValidator extends BaseKeywordValidator implements KeywordValidator { private final BigDecimal divisor; - public MultipleOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public MultipleOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.divisor = getDivisor(schemaNode); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { if (this.divisor != null) { BigDecimal dividend = getDividend(node); diff --git a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index 8a969b5bf..8ddba73da 100644 --- a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -32,7 +32,7 @@ public class NonValidationKeyword extends AbstractKeyword { private static final class Validator extends AbstractKeywordValidator { - public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public Validator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext, Keyword keyword) { super(keyword, schemaNode, schemaLocation, evaluationPath); String id = schemaContext.resolveSchemaId(schemaNode); @@ -54,7 +54,7 @@ public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, Jso } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // Do nothing } } @@ -64,7 +64,7 @@ public NonValidationKeyword(String keyword) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { return new Validator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext, this); } diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index ec158b09c..d47eb56d5 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -31,7 +31,7 @@ public class NotAllowedValidator extends BaseKeywordValidator implements KeywordValidator { private final List fieldNames; - public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public NotAllowedValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); @@ -44,7 +44,7 @@ public NotAllowedValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { for (String fieldName : fieldNames) { diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index a4bc3d580..440ee6966 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -32,19 +32,19 @@ public class NotValidator extends BaseKeywordValidator { private final Schema schema; - public NotValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public NotValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { @@ -74,7 +74,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 6f703703f..0768a4de9 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -40,7 +40,7 @@ public class OneOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public OneOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); @@ -60,12 +60,12 @@ public OneOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { int numberOfValidSchema = 0; int index = 0; @@ -228,7 +228,7 @@ protected boolean canShortCircuit() { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); } else { diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index a578e1d2e..241b77df1 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; @@ -36,7 +36,7 @@ public class PatternPropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator = null; - public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, + public PatternPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isObject()) { @@ -51,7 +51,7 @@ public PatternPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath ev } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!node.isObject()) { @@ -65,7 +65,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode JsonNode n = node.get(name); for (Map.Entry entry : schemas.entrySet()) { if (entry.getKey().matches(name)) { - JsonNodePath path = instanceLocation.append(name); + NodePath path = instanceLocation.append(name); int currentErrors = executionContext.getErrors().size(); entry.getValue().validate(executionContext, n, rootNode, path); if (currentErrors == executionContext.getErrors().size()) { // No new errors diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index fecf06f82..367f85804 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.FailFastAssertionException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -37,7 +37,7 @@ public class PatternValidator extends BaseKeywordValidator { private final String pattern; private final RegularExpression compiledPattern; - public PatternValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public PatternValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); @@ -55,7 +55,7 @@ private boolean matches(String value) { } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { JsonType nodeType = TypeFactory.getValueNodeType(node, this.schemaContext.getSchemaRegistryConfig()); diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 3aa73036b..6b744d069 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; @@ -38,7 +38,7 @@ public class PrefixItemsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; - public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public PrefixItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { @@ -55,13 +55,13 @@ public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluati } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // ignores non-arrays if (node.isArray()) { int count = Math.min(node.size(), this.tupleSchema.size()); for (int i = 0; i < count; ++i) { - JsonNodePath path = instanceLocation.append(i); + NodePath path = instanceLocation.append(i); this.tupleSchema.get(i).validate(executionContext, node.get(i), rootNode, path); } @@ -88,7 +88,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (node instanceof ArrayNode) { ArrayNode array = (ArrayNode) node; int count = this.tupleSchema.size(); @@ -146,13 +146,13 @@ private static JsonNode getDefaultNode(Schema schema) { } private void doWalk(ExecutionContext executionContext, int i, - JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { walkSchema(executionContext, this.tupleSchema.get(i), node, rootNode, instanceLocation.append(i), shouldValidateSchema); } private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 24f5f81c0..c13e81234 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; @@ -46,7 +46,7 @@ public class PropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; - public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public PropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); @@ -58,12 +58,12 @@ public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean walk) { + NodePath instanceLocation, boolean walk) { Set matchedInstancePropertyNames = null; @@ -71,7 +71,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo for (Entry entry : this.schemas.entrySet()) { JsonNode propertyNode = node.get(entry.getKey()); if (propertyNode != null) { - JsonNodePath path = instanceLocation.append(entry.getKey()); + NodePath path = instanceLocation.append(entry.getKey()); if (collectAnnotations) { if (matchedInstancePropertyNames == null) { matchedInstancePropertyNames = new LinkedHashSet<>(); @@ -107,7 +107,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyPropertyDefaults() && null != node && node.getNodeType() == JsonNodeType.OBJECT) { applyPropertyDefaults((ObjectNode) node, executionContext); @@ -162,10 +162,10 @@ private static JsonNode getDefaultNode(Schema schema) { } private void walkSchema(ExecutionContext executionContext, Map.Entry entry, JsonNode node, - JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, WalkListenerRunner propertyWalkListenerRunner) { + JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema, WalkListenerRunner propertyWalkListenerRunner) { Schema propertySchema = entry.getValue(); JsonNode propertyNode = (node == null ? null : node.get(entry.getKey())); - JsonNodePath path = instanceLocation.append(entry.getKey()); + NodePath path = instanceLocation.append(entry.getKey()); boolean executeWalk = propertyWalkListenerRunner.runPreWalkListeners(executionContext, ValidatorTypeCode.PROPERTIES.getValue(), propertyNode, rootNode, path, propertySchema, this); diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index ecd28f341..64e49a035 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -23,19 +23,19 @@ import com.fasterxml.jackson.databind.node.TextNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private final Schema innerSchema; - public PropertyNamesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public PropertyNamesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); innerSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { List existingErrors = executionContext.getErrors(); diff --git a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index b6305c30d..cecf134ab 100644 --- a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -32,13 +32,13 @@ public class ReadOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(ReadOnlyValidator.class); - public ReadOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public ReadOnlyValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.READ_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded ReadOnlyValidator for property {} as {}", parentSchema, "read mode"); } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (Boolean.TRUE.equals(executionContext.getExecutionConfig().getReadOnly())) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 7ad0d8192..fafe9c50b 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; @@ -36,7 +36,7 @@ public class RecursiveRefValidator extends BaseKeywordValidator { protected final SchemaRef schema; - public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public RecursiveRefValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); @@ -52,7 +52,7 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat } static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { return new SchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); } @@ -61,7 +61,7 @@ static Supplier getSupplier(Supplier supplier, boolean cache) { } static Schema getSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { Schema refSchema = parentSchema.findSchemaResourceRoot(); // Get the document Schema current = refSchema; Schema check = null; @@ -91,7 +91,7 @@ static Schema getSchema(Schema parentSchema, SchemaContext schemaContext, String } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { Schema refSchema = this.schema.getSchema(); if (refSchema == null) { @@ -105,7 +105,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index ceb9787a1..bd9762bc0 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -21,7 +21,7 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; @@ -38,14 +38,14 @@ public class RefValidator extends BaseKeywordValidator { private static final String REF_CURRENT = "#"; - public RefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public RefValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { // The evaluationPath is used to derive the keywordLocation final String refValueOriginal = refValue; @@ -157,9 +157,9 @@ private static Schema getJsonSchema(Schema parent, SchemaContext schemaContext, String refValue, String refValueOriginal, - JsonNodePath evaluationPath) { + NodePath evaluationPath) { // This should be processing json pointer fragments only - JsonNodePath fragment = SchemaLocation.Fragment.of(refValue); + NodePath fragment = SchemaLocation.Fragment.of(refValue); String schemaReference = resolve(parent, refValueOriginal); // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. @@ -180,7 +180,7 @@ private static Schema getJsonSchema(Schema parent, } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { Schema refSchema = this.schema.getSchema(); if (refSchema == null) { @@ -194,7 +194,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { // This is important because if we use same JsonSchemaFactory for creating multiple JSONSchema instances, // these schemas will be cached along with config. We have to replace the config for cached $ref references diff --git a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java index b2062c7c1..72a209353 100644 --- a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -31,7 +31,7 @@ public class RequiredValidator extends BaseKeywordValidator implements KeywordValidator { private final List fieldNames; - public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public RequiredValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); @@ -43,7 +43,7 @@ public RequiredValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!node.isObject()) { diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index 136166e9e..b1672453e 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -26,11 +26,11 @@ * {@link KeywordValidator} for true. */ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { - public TrueValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public TrueValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // For the true validator, it is always valid which means there is no Error. } diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index a35040529..97c867d5f 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; @@ -33,7 +33,7 @@ public class TypeValidator extends BaseKeywordValidator { private final JsonType schemaType; private final UnionTypeValidator unionTypeValidator; - public TypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public TypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { @@ -52,7 +52,7 @@ public boolean equalsToSchemaType(JsonNode node) { } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (this.schemaType == JsonType.UNION) { diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index d7d5726e6..10bfffffc 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -40,7 +40,7 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { private final boolean isMinV202012; private static final Version DEFAULT_VERSION = Version.DRAFT_2019_09; - public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -53,7 +53,7 @@ public UnevaluatedItemsValidator(SchemaLocation schemaLocation, JsonNodePath eva } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!node.isArray()) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 309b202c7..3e1f11603 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -38,7 +38,7 @@ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private final Schema schema; - public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { @@ -49,7 +49,7 @@ public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, JsonNodePat } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (!node.isObject()) { return; } diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 11f225c42..194b96a28 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -38,7 +38,7 @@ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordV private final List schemas; private final String error; - public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public UnionTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); @@ -71,7 +71,7 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNodePath evaluation error = errorBuilder.toString(); } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { JsonType nodeType = TypeFactory.getValueNodeType(node, schemaContext.getSchemaRegistryConfig()); diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index b327eedaf..fd8c95b15 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -32,7 +32,7 @@ public class UniqueItemsValidator extends BaseKeywordValidator implements KeywordValidator { private final boolean unique; - public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public UniqueItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); @@ -41,7 +41,7 @@ public UniqueItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluati } } - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (unique) { diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index 5f631ee14..c695219ee 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -17,7 +17,7 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; @@ -33,7 +33,7 @@ @FunctionalInterface interface ValidatorFactory { - KeywordValidator newInstance(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + KeywordValidator newInstance(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext); } @@ -80,7 +80,7 @@ public enum ValidatorTypeCode implements Keyword { EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), FALSE("false", FalseValidator::new, VersionCode.MinV6), FORMAT("format", null, VersionCode.MaxV7) { - @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, @@ -157,7 +157,7 @@ public static ValidatorTypeCode fromValue(String value) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { if (this.validatorFactory == null) { throw new UnsupportedOperationException("No suitable validator for " + getValue()); diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index 44d5433c7..a173eef5c 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -16,13 +16,13 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); - public WriteOnlyValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public WriteOnlyValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { if (Boolean.TRUE.equals(executionContext.getExecutionConfig().getWriteOnly())) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index d7e64666f..ac083642c 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -27,7 +27,7 @@ import java.util.Set; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaContext; import com.networknt.schema.Error; @@ -36,21 +36,21 @@ * HierarchicalOutputUnitFormatter. */ public class HierarchicalOutputUnitFormatter { - public static OutputUnit format(OutputUnit root, OutputUnitData data, JsonNodePath rootPath) { + public static OutputUnit format(OutputUnit root, OutputUnitData data, NodePath rootPath) { Map valid = data.getValid(); Map> errors = data.getErrors(); Map> annotations = data.getAnnotations(); Map> droppedAnnotations = data.getDroppedAnnotations(); // Evaluation path to output unit - Map> index = new LinkedHashMap<>(); - Map r = new LinkedHashMap<>(); + Map> index = new LinkedHashMap<>(); + Map r = new LinkedHashMap<>(); r.put(rootPath, root); index.put(rootPath, r); // Get all the evaluation paths with data // This is a map of evaluation path to instance location - Map> keys = new LinkedHashMap<>(); + Map> keys = new LinkedHashMap<>(); errors.keySet().stream().forEach(k -> keys.computeIfAbsent(k.getEvaluationPath(), a -> new LinkedHashSet<>()) .add(k.getInstanceLocation())); annotations.keySet().stream().forEach(k -> keys @@ -120,7 +120,7 @@ public static OutputUnit format(Schema jsonSchema, List errors, OutputUnitData data = OutputUnitData.from(errors, executionContext, errorMapper); - return format(root, data, new JsonNodePath(schemaContext.getSchemaRegistryConfig().getPathType())); + return format(root, data, new NodePath(schemaContext.getSchemaRegistryConfig().getPathType())); } /** @@ -132,14 +132,14 @@ public static OutputUnit format(Schema jsonSchema, List errors, * @param keys that contain all the evaluation paths with instance data * @param root the root output unit */ - protected static void buildIndex(OutputUnitKey key, Map> index, - Map> keys, OutputUnit root) { + protected static void buildIndex(OutputUnitKey key, Map> index, + Map> keys, OutputUnit root) { if (index.containsKey(key.getEvaluationPath())) { return; } // Ensure the path is created - JsonNodePath path = key.getEvaluationPath(); - Deque stack = new ArrayDeque<>(); + NodePath path = key.getEvaluationPath(); + Deque stack = new ArrayDeque<>(); while (path != null && path.getElement(-1) != null) { stack.push(path); path = path.getParent(); @@ -147,10 +147,10 @@ protected static void buildIndex(OutputUnitKey key, Map result = index.get(current); + Map result = index.get(current); if (result != null) { - for (Entry entry : result.entrySet()) { + for (Entry entry : result.entrySet()) { if (key.getInstanceLocation().startsWith(entry.getKey())) { parent = entry.getValue(); break; diff --git a/src/main/java/com/networknt/schema/output/OutputUnitKey.java b/src/main/java/com/networknt/schema/output/OutputUnitKey.java index 760f75871..fac292647 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitKey.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitKey.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; import com.networknt.schema.serialization.JsonMapperFactory; @@ -29,20 +29,20 @@ */ public class OutputUnitKey { @JsonSerialize(using = ToStringSerializer.class) - final JsonNodePath evaluationPath; + final NodePath evaluationPath; @JsonSerialize(using = ToStringSerializer.class) final SchemaLocation schemaLocation; @JsonSerialize(using = ToStringSerializer.class) - final JsonNodePath instanceLocation; + final NodePath instanceLocation; - public OutputUnitKey(JsonNodePath evaluationPath, SchemaLocation schemaLocation, JsonNodePath instanceLocation) { + public OutputUnitKey(NodePath evaluationPath, SchemaLocation schemaLocation, NodePath instanceLocation) { super(); this.evaluationPath = evaluationPath; this.schemaLocation = schemaLocation; this.instanceLocation = instanceLocation; } - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } @@ -50,7 +50,7 @@ public SchemaLocation getSchemaLocation() { return schemaLocation; } - public JsonNodePath getInstanceLocation() { + public NodePath getInstanceLocation() { return instanceLocation; } diff --git a/src/main/java/com/networknt/schema/result/JsonNodeResult.java b/src/main/java/com/networknt/schema/result/JsonNodeResult.java index 8b464d37b..4baf9ba31 100644 --- a/src/main/java/com/networknt/schema/result/JsonNodeResult.java +++ b/src/main/java/com/networknt/schema/result/JsonNodeResult.java @@ -17,19 +17,19 @@ import java.util.Objects; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; /** * Sub schema results. */ public class JsonNodeResult { - private final JsonNodePath instanceLocation; + private final NodePath instanceLocation; private final SchemaLocation schemaLocation; - private final JsonNodePath evaluationPath; + private final NodePath evaluationPath; private final boolean valid; - public JsonNodeResult(JsonNodePath instanceLocation, SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public JsonNodeResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { super(); this.instanceLocation = instanceLocation; @@ -38,7 +38,7 @@ public JsonNodeResult(JsonNodePath instanceLocation, SchemaLocation schemaLocati this.valid = valid; } - public JsonNodePath getInstanceLocation() { + public NodePath getInstanceLocation() { return instanceLocation; } @@ -46,7 +46,7 @@ public SchemaLocation getSchemaLocation() { return schemaLocation; } - public JsonNodePath getEvaluationPath() { + public NodePath getEvaluationPath() { return evaluationPath; } diff --git a/src/main/java/com/networknt/schema/result/JsonNodeResults.java b/src/main/java/com/networknt/schema/result/JsonNodeResults.java index 0b3f5e893..0196c9a50 100644 --- a/src/main/java/com/networknt/schema/result/JsonNodeResults.java +++ b/src/main/java/com/networknt/schema/result/JsonNodeResults.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; /** @@ -31,16 +31,16 @@ public class JsonNodeResults { /** * Stores the invalid results. */ - private final Map> values = new HashMap<>(); + private final Map> values = new HashMap<>(); - public void setResult(JsonNodePath instanceLocation, SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public void setResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { JsonNodeResult result = new JsonNodeResult(instanceLocation, schemaLocation, evaluationPath, valid); List v = values.computeIfAbsent(instanceLocation, k -> new ArrayList<>()); v.add(result); } - public boolean isValid(JsonNodePath instanceLocation, JsonNodePath evaluationPath) { + public boolean isValid(NodePath instanceLocation, NodePath evaluationPath) { List instance = values.get(instanceLocation); if (instance != null) { for (JsonNodeResult result : instance) { diff --git a/src/main/java/com/networknt/schema/utils/JsonNodes.java b/src/main/java/com/networknt/schema/utils/JsonNodes.java index 3bfd9aa6d..9891f5a56 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodes.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodes.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.serialization.node.JsonLocationAware; import com.networknt.schema.serialization.node.JsonNodeFactoryFactory; @@ -42,7 +42,7 @@ public class JsonNodes { * @return the node found at the path or null */ @SuppressWarnings("unchecked") - public static T get(JsonNode node, JsonNodePath path) { + public static T get(JsonNode node, NodePath path) { int nameCount = path.getNameCount(); JsonNode current = node; for (int x = 0; x < nameCount; x++) { diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index 4de62f764..9dd30f45b 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -12,7 +12,7 @@ public abstract class AbstractWalkListenerRunner implements WalkListenerRunner { protected WalkEvent constructWalkEvent(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator) { return WalkEvent.builder().executionContext(executionContext).instanceLocation(instanceLocation) .keyword(keyword).instanceNode(instanceNode) .rootNode(rootNode).schema(schema).validator(validator).build(); diff --git a/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java index ceb1a145a..dec947645 100644 --- a/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -40,7 +40,7 @@ public ItemWalkListenerRunner(List itemWalkListeners) { @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(itemWalkListeners, walkEvent); @@ -48,7 +48,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); runPostWalkListeners(itemWalkListeners, walkEvent, errors); diff --git a/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java index aba9ef4fe..9835d52e9 100644 --- a/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; @@ -45,7 +45,7 @@ public KeywordWalkListenerRunner(List allKeywordWalkListeners, @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator) { boolean continueRunningListenersAndWalk = true; WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); @@ -61,7 +61,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { WalkEvent keywordWalkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); diff --git a/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java index cea2388d9..dc7a45c28 100644 --- a/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -40,7 +40,7 @@ public PropertyWalkListenerRunner(List propertyWalkListeners) { @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); return runPreWalkListeners(propertyWalkListeners, walkEvent); @@ -48,7 +48,7 @@ public boolean runPreWalkListeners(ExecutionContext executionContext, String key @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { WalkEvent walkEvent = constructWalkEvent(executionContext, keyword, instanceNode, rootNode, instanceLocation, schema, validator); diff --git a/src/main/java/com/networknt/schema/walk/WalkConfig.java b/src/main/java/com/networknt/schema/walk/WalkConfig.java index 9b8349259..c8d0d1b3e 100644 --- a/src/main/java/com/networknt/schema/walk/WalkConfig.java +++ b/src/main/java/com/networknt/schema/walk/WalkConfig.java @@ -22,7 +22,7 @@ import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; @@ -53,14 +53,14 @@ public static NoOpWalkListenerRunner getInstance() { @Override public boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator) { + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator) { // Always walk return true; } @Override public void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator, List errors) { } } diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index 059dee63c..14900e7f6 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; @@ -16,7 +16,7 @@ public class WalkEvent { private String keyword; private JsonNode rootNode; private JsonNode instanceNode; - private JsonNodePath instanceLocation; + private NodePath instanceLocation; private KeywordValidator validator; /** @@ -77,7 +77,7 @@ public JsonNode getInstanceNode() { * * @return the instance location of the instance node */ - public JsonNodePath getInstanceLocation() { + public NodePath getInstanceLocation() { return instanceLocation; } @@ -130,7 +130,7 @@ public WalkEventBuilder rootNode(JsonNode rootNode) { return this; } - public WalkEventBuilder instanceLocation(JsonNodePath instanceLocation) { + public WalkEventBuilder instanceLocation(NodePath instanceLocation) { walkEvent.instanceLocation = instanceLocation; return this; } diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index a534b0ef5..171d516ae 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.Error; @@ -12,9 +12,9 @@ public interface WalkListenerRunner { boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator); + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator); void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, - JsonNode rootNode, JsonNodePath instanceLocation, Schema schema, KeywordValidator validator, List errors); + JsonNode rootNode, NodePath instanceLocation, Schema schema, KeywordValidator validator, List errors); } diff --git a/src/main/java/com/networknt/schema/walk/Walker.java b/src/main/java/com/networknt/schema/walk/Walker.java index 190d7ac1f..b5cddea8d 100644 --- a/src/main/java/com/networknt/schema/walk/Walker.java +++ b/src/main/java/com/networknt/schema/walk/Walker.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Validator; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; public interface Walker { /** @@ -12,7 +12,7 @@ public interface Walker { * cross-cutting concerns like logging or instrumentation. This method also * performs the validation if {@code shouldValidateSchema} is set to true.
*
- * {@link Validator#walk(ExecutionContext, JsonNode, JsonNode, JsonNodePath, boolean)} + * {@link Validator#walk(ExecutionContext, JsonNode, JsonNode, NodePath, boolean)} * provides a default implementation of this method. However, validators that * parse sub-schemas should override this method to call walk method on those * sub-schemas. @@ -25,5 +25,5 @@ public interface Walker { * @param shouldValidateSchema true to validate the schema while walking */ void walk(ExecutionContext executionContext, JsonNode instanceNode, JsonNode instance, - JsonNodePath instanceLocation, boolean shouldValidateSchema); + NodePath instanceLocation, boolean shouldValidateSchema); } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index f07576433..3a1040242 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -264,7 +264,7 @@ public String getValue() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); @@ -281,13 +281,13 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath */ private class CustomValidator extends AbstractKeywordValidator { private final CustomCollector customCollector = new CustomCollector(); - public CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + public CustomValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode) { super(new CustomKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { CollectorContext collectorContext = executionContext.getCollectorContext(); List result = collectorContext.computeIfAbsent(Data.SAMPLE_COLLECTOR, key -> customCollector.supplier().get()); @@ -295,7 +295,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { // Ignore this method for testing. } } @@ -354,7 +354,7 @@ public String getValue() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator1(schemaLocation, evaluationPath, schemaNode); @@ -372,13 +372,13 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath * keyword has been used multiple times in JSON Schema. */ private class CustomValidator1 extends AbstractKeywordValidator { - public CustomValidator1(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + public CustomValidator1(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode) { super(new CustomKeyword(), schemaNode,schemaLocation, evaluationPath); } @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { // Get an instance of collector context. CollectorContext collectorContext = executionContext.getCollectorContext(); // If collector type is not added to context add one. @@ -390,7 +390,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { // Ignore this method for testing. } } @@ -430,7 +430,7 @@ public String getValue() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { if (schemaNode != null && schemaNode.isBoolean()) { return new CollectValidator(schemaLocation, evaluationPath, schemaNode); @@ -440,12 +440,12 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath } private class CollectValidator extends AbstractKeywordValidator { - CollectValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + CollectValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode) { super(new CollectKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { // Get an instance of collector context. CollectorContext collectorContext = executionContext.getCollectorContext(); AtomicInteger count = collectorContext.computeIfAbsent("collect", @@ -455,7 +455,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { if (!shouldValidateSchema) { CollectorContext collectorContext = executionContext.getCollectorContext(); AtomicInteger count = (AtomicInteger) collectorContext.getData().computeIfAbsent("collect", diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index 1b489b6f9..c2529c144 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -51,7 +51,7 @@ private static final class Validator extends AbstractKeywordValidator { private final List enumNames; private final String keyword; - private Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, String keyword, + private Validator(SchemaLocation schemaLocation, NodePath evaluationPath, String keyword, List enumValues, List enumNames, JsonNode schemaNode) { super(new EnumNamesKeyword(), schemaNode, schemaLocation, evaluationPath); if (enumNames.size() != enumValues.size()) { @@ -63,7 +63,7 @@ private Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, St } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { String value = node.asText(); int idx = enumValues.indexOf(value); if (idx < 0) { @@ -85,7 +85,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { /* * You can access the schema node here to read data from your keyword diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index a6c927cc4..ca85350b9 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -35,7 +35,7 @@ public CustomFormatKeyword(Map formats) { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new IllegalArgumentException(); } } diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 5e5ff72c6..83bc0ba29 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -63,7 +63,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List types = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("types", key -> new ArrayList()); + .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) @@ -108,7 +108,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List types = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("types", key -> new ArrayList()); + .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) @@ -154,7 +154,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List types = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("types", key -> new ArrayList()); + .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) @@ -198,7 +198,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List types = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("types", key -> new ArrayList()); + .computeIfAbsent("types", key -> new ArrayList()); types.add(walkEvent); } }) diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 427e5644b..bd298ac85 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -47,7 +47,7 @@ class Issue467Test { @Test void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); - final Set properties = new LinkedHashSet<>(); + final Set properties = new LinkedHashSet<>(); KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { @Override @@ -76,7 +76,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { @Test void shouldWalkPropertiesWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); - final Set properties = new LinkedHashSet<>(); + final Set properties = new LinkedHashSet<>(); PropertyWalkListenerRunner propertyWalkListenerRunner = PropertyWalkListenerRunner.builder() .propertyWalkListener(new WalkListener() { @Override diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 459fdbf0a..b0478d92e 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -80,7 +80,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -122,7 +122,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 746654b49..055830be8 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -136,7 +136,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -174,7 +174,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -218,7 +218,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -270,7 +270,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -326,7 +326,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext().getCollectorContext() - .getData().computeIfAbsent("items", key -> new ArrayList()); + .getData().computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); diff --git a/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java b/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java index 596393985..38bb8a2c9 100644 --- a/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java +++ b/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java @@ -30,7 +30,7 @@ class JsonNodeAnnotationsTest { void put() { JsonNodeAnnotations annotations = new JsonNodeAnnotations(); JsonNodeAnnotation annotation = new JsonNodeAnnotation("unevaluatedProperties", - new JsonNodePath(PathType.JSON_POINTER), SchemaLocation.of(""), new JsonNodePath(PathType.JSON_POINTER), + new NodePath(PathType.JSON_POINTER), SchemaLocation.of(""), new NodePath(PathType.JSON_POINTER), "test"); annotations.put(annotation); assertTrue(annotations.asMap().get(annotation.getInstanceLocation()).contains(annotation)); diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 42d3d7ec1..10d5c8b25 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -164,7 +164,7 @@ public String getValue() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException { if (schemaNode != null && schemaNode.isArray()) { return new CustomValidator(schemaLocation, evaluationPath, schemaNode); @@ -180,18 +180,18 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath */ private static class CustomValidator extends AbstractKeywordValidator { - CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + CustomValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode) { super(new CustomKeyword(), schemaNode, schemaLocation, evaluationPath); } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { return; } @Override public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation, boolean shouldValidateSchema) { + NodePath instanceLocation, boolean shouldValidateSchema) { return; } } diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 9cefae19d..ee1ecd41f 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -35,7 +35,7 @@ class MessageTest { static class EqualsValidator extends BaseKeywordValidator { private final String value; - EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + EqualsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, Keyword keyword, SchemaContext schemaContext) { super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -44,7 +44,7 @@ static class EqualsValidator extends BaseKeywordValidator { @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - JsonNodePath instanceLocation) { + NodePath instanceLocation) { if (!node.asText().equals(value)) { executionContext.addError(error().message("must be equal to ''{0}''") .arguments(value) @@ -61,7 +61,7 @@ public String getValue() { } @Override - public KeywordValidator newValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, + public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) throws SchemaException, Exception { return new EqualsValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, this, schemaContext); diff --git a/src/test/java/com/networknt/schema/JsonNodePathTest.java b/src/test/java/com/networknt/schema/NodePathTest.java similarity index 66% rename from src/test/java/com/networknt/schema/JsonNodePathTest.java rename to src/test/java/com/networknt/schema/NodePathTest.java index 9f91ca91f..5483127ae 100644 --- a/src/test/java/com/networknt/schema/JsonNodePathTest.java +++ b/src/test/java/com/networknt/schema/NodePathTest.java @@ -24,19 +24,19 @@ import org.junit.jupiter.api.Test; -class JsonNodePathTest { +class NodePathTest { @Test void getNameCount() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); - JsonNodePath path = root.append("hello").append("world"); + NodePath root = new NodePath(PathType.JSON_POINTER); + NodePath path = root.append("hello").append("world"); assertEquals(2, path.getNameCount()); } @Test void getName() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); - JsonNodePath path = root.append("hello").append("world"); + NodePath root = new NodePath(PathType.JSON_POINTER); + NodePath path = root.append("hello").append("world"); assertEquals("hello", path.getName(0)); assertEquals("world", path.getName(1)); assertEquals("world", path.getName(-1)); @@ -45,19 +45,19 @@ void getName() { @Test void compareTo() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); - JsonNodePath a = root.append("a"); - JsonNodePath aa = a.append("a"); + NodePath root = new NodePath(PathType.JSON_POINTER); + NodePath a = root.append("a"); + NodePath aa = a.append("a"); - JsonNodePath b = root.append("b"); - JsonNodePath bb = b.append("b"); - JsonNodePath b1 = b.append(1); - JsonNodePath bbb = bb.append("b"); + NodePath b = root.append("b"); + NodePath bb = b.append("b"); + NodePath b1 = b.append(1); + NodePath bbb = bb.append("b"); - JsonNodePath c = root.append("c"); - JsonNodePath cc = c.append("c"); + NodePath c = root.append("c"); + NodePath cc = c.append("c"); - List paths = new ArrayList<>(); + List paths = new ArrayList<>(); paths.add(cc); paths.add(aa); paths.add(bb); @@ -79,30 +79,30 @@ void compareTo() { @Test void equalsEquals() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); - JsonNodePath a1 = root.append("a"); - JsonNodePath a2 = root.append("a"); + NodePath root = new NodePath(PathType.JSON_POINTER); + NodePath a1 = root.append("a"); + NodePath a2 = root.append("a"); assertEquals(a1, a2); } @Test void hashCodeEquals() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); - JsonNodePath a1 = root.append("a"); - JsonNodePath a2 = root.append("a"); + NodePath root = new NodePath(PathType.JSON_POINTER); + NodePath a1 = root.append("a"); + NodePath a2 = root.append("a"); assertEquals(a1.hashCode(), a2.hashCode()); } @Test void getPathType() { - JsonNodePath root = new JsonNodePath(PathType.JSON_POINTER); + NodePath root = new NodePath(PathType.JSON_POINTER); assertEquals(PathType.JSON_POINTER, root.getPathType()); } @Test void getElement() { - JsonNodePath root = new JsonNodePath(PathType.JSON_PATH); - JsonNodePath path = root.append("hello").append(1).append("world"); + NodePath root = new NodePath(PathType.JSON_PATH); + NodePath path = root.append("hello").append(1).append("world"); assertEquals("hello", path.getElement(0)); assertEquals(Integer.valueOf(1), path.getElement(1)); assertEquals("world", path.getElement(2)); @@ -113,9 +113,9 @@ void getElement() { @Test void startsWith() { - JsonNodePath root = new JsonNodePath(PathType.JSON_PATH); - JsonNodePath path = root.append("items"); - JsonNodePath other = root.append("unevaluatedItems"); + NodePath root = new NodePath(PathType.JSON_PATH); + NodePath path = root.append("items"); + NodePath other = root.append("unevaluatedItems"); assertTrue(path.startsWith(other.getParent())); path = root.append("allOf").append(0).append("items"); diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 03428945a..02b663f02 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -144,7 +144,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); @@ -200,7 +200,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { @SuppressWarnings("unchecked") List items = (List) walkEvent.getExecutionContext().getCollectorContext() - .getData().computeIfAbsent("items", key -> new ArrayList()); + .getData().computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }).build(); diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index d8db9b125..43147bf08 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -29,7 +29,7 @@ void testInvalidRecursiveReference() { // Act and Assert assertThrows(SchemaException.class, () -> { - new RecursiveRefValidator(SchemaLocation.of(""), new JsonNodePath(PathType.JSON_POINTER), schemaNode, null, schemaContext); + new RecursiveRefValidator(SchemaLocation.of(""), new NodePath(PathType.JSON_POINTER), schemaNode, null, schemaContext); }); } diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index 8823bb5c9..fc30674e8 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -228,7 +228,7 @@ void shouldLoadEscapedFragment() { @Test void escapedJsonPointerFragment() { - JsonNodePath fragment = SchemaLocation.Fragment.of("/paths/~1users/post/requestBody/application~1json/schema"); + NodePath fragment = SchemaLocation.Fragment.of("/paths/~1users/post/requestBody/application~1json/schema"); assertEquals("/paths/~1users/post/requestBody/application~1json/schema", fragment.toString()); assertEquals(6, fragment.getNameCount()); assertEquals("paths", fragment.getName(0)); diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 6b82bdd44..aec812d7f 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -35,7 +35,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.InputFormat; -import com.networknt.schema.JsonNodePath; +import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaRef; @@ -876,7 +876,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }; @@ -942,7 +942,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) walkEvent.getExecutionContext() .getCollectorContext() .getData() - .computeIfAbsent("items", key -> new ArrayList()); + .computeIfAbsent("items", key -> new ArrayList()); items.add(walkEvent); } }; From 83a81f0c44517bd11c92b116a21766417dbaf78a Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:48:49 +0800 Subject: [PATCH 24/74] Rename preloadJsonSchema in KeywordValidator to preloadSchema --- .../networknt/schema/FailFastAssertionException.java | 2 +- src/main/java/com/networknt/schema/Schema.java | 6 +++--- src/main/java/com/networknt/schema/SchemaRegistry.java | 4 ++-- .../com/networknt/schema/SchemaRegistryConfig.java | 8 ++++---- .../schema/keyword/AdditionalPropertiesValidator.java | 2 +- .../com/networknt/schema/keyword/AllOfValidator.java | 4 ++-- .../com/networknt/schema/keyword/AnyOfValidator.java | 4 ++-- .../networknt/schema/keyword/BaseKeywordValidator.java | 2 +- .../networknt/schema/keyword/ContainsValidator.java | 2 +- .../schema/keyword/DependenciesValidator.java | 4 ++-- .../com/networknt/schema/keyword/DependentSchemas.java | 4 ++-- .../networknt/schema/keyword/DynamicRefValidator.java | 2 +- .../java/com/networknt/schema/keyword/IfValidator.java | 2 +- .../com/networknt/schema/keyword/ItemsValidator.java | 4 ++-- .../networknt/schema/keyword/ItemsValidator202012.java | 2 +- .../com/networknt/schema/keyword/KeywordValidator.java | 4 ++-- .../com/networknt/schema/keyword/NotValidator.java | 2 +- .../com/networknt/schema/keyword/OneOfValidator.java | 2 +- .../schema/keyword/PatternPropertiesValidator.java | 4 ++-- .../networknt/schema/keyword/PrefixItemsValidator.java | 4 ++-- .../networknt/schema/keyword/PropertiesValidator.java | 4 ++-- .../schema/keyword/PropertyNamesValidator.java | 2 +- .../schema/keyword/RecursiveRefValidator.java | 2 +- .../com/networknt/schema/keyword/RefValidator.java | 10 +++++----- .../networknt/schema/keyword/UnionTypeValidator.java | 4 ++-- src/test/java/com/networknt/schema/SchemaTest.java | 2 +- 26 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/networknt/schema/FailFastAssertionException.java b/src/main/java/com/networknt/schema/FailFastAssertionException.java index 8020d0615..0e033d28e 100644 --- a/src/main/java/com/networknt/schema/FailFastAssertionException.java +++ b/src/main/java/com/networknt/schema/FailFastAssertionException.java @@ -26,7 +26,7 @@ * This doesn't extend off SchemaException as it is used for flow control * and is intended to be caught in a specific place. *

- * This will be caught in the JsonSchema validate method to be passed to the + * This will be caught in the Schema validate method to be passed to the * output formatter. */ public class FailFastAssertionException extends RuntimeException { diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 3895bf5cc..a933c9a22 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -44,10 +44,10 @@ * be cached for performance. *

* This is the core of json constraint implementation. It parses json constraint - * file and generates JsonValidators. The class is thread safe, once it is + * file and generates KeywordValidators. The class is thread safe, once it is * constructed, it can be used to validate multiple json data concurrently. *

- * JsonSchema instances are thread-safe provided its configuration is not + * Schema instances are thread-safe provided its configuration is not * modified. */ public class Schema implements Validator { @@ -1365,7 +1365,7 @@ public List getValidators() { public void initializeValidators() { if (!this.validatorsLoaded) { for (final KeywordValidator validator : getValidators()) { - validator.preloadJsonSchema(); + validator.preloadSchema(); } /* * This is only set to true after the preload as it may throw an exception for diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 7d5caacaf..483c5e739 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -304,7 +304,7 @@ protected Schema newSchema(final SchemaLocation schemaUri, final JsonNode schema * @param config containing the configuration option */ private void preload(Schema schema) { - if (this.getSchemaRegistryConfig().isPreloadJsonSchema()) { + if (this.getSchemaRegistryConfig().isPreloadSchema()) { try { /* * Attempt to preload and resolve $refs for performance. @@ -358,7 +358,7 @@ private SchemaContext withDialect(SchemaContext schemaContext, JsonNode schemaNo * one with a null base IRI. *

* Note that the resolving of the $id or id in the schema node will take place - * in the JsonSchema constructor. + * in the Schema constructor. * * @param schemaLocation the schema retrieval uri * @return the schema location diff --git a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java index a899d98f5..b51cc9ac1 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java +++ b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java @@ -281,7 +281,7 @@ public boolean isLosslessNarrowing() { * * @return true if it should be preloaded */ - public boolean isPreloadJsonSchema() { + public boolean isPreloadSchema() { return preloadSchema; } @@ -511,11 +511,11 @@ public T pathType(PathType pathType) { *

* Defaults to true. * - * @param preloadJsonSchema true to preload + * @param preloadSchema true to preload * @return the builder */ - public T preloadJsonSchema(boolean preloadJsonSchema) { - this.preloadSchema = preloadJsonSchema; + public T preloadSchema(boolean preloadSchema) { + this.preloadSchema = preloadSchema; return self(); } /** diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index ced457462..a669a1676 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -192,7 +192,7 @@ private boolean hasUnevaluatedPropertiesValidator() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { if(additionalPropertiesSchema != null) { additionalPropertiesSchema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index 400393c81..f6cd4e1f8 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -110,7 +110,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(this.schemas); + public void preloadSchema() { + preloadSchemas(this.schemas); } } diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 0ab7f1669..c8432c410 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -216,8 +216,8 @@ protected boolean canShortCircuit() { } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(this.schemas); + public void preloadSchema() { + preloadSchemas(this.schemas); canShortCircuit(); // cache flag } } \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 92448eb1a..91ec128bc 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -118,7 +118,7 @@ protected String getNodeFieldType() { return null; } - protected void preloadJsonSchemas(final Collection schemas) { + protected void preloadSchemas(final Collection schemas) { for (final Schema schema : schemas) { schema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 6ecd7e085..6b707256e 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -179,7 +179,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void preloadJsonSchema() { + public void preloadSchema() { Optional.ofNullable(this.schema).ifPresent(Schema::initializeValidators); collectAnnotations(); // cache the flag } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index fc4df37d4..a0c72b899 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -85,7 +85,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(schemaDeps.values()); + public void preloadSchema() { + preloadSchemas(schemaDeps.values()); } } diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 56547930e..76c919388 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -67,8 +67,8 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(this.schemaDependencies.values()); + public void preloadSchema() { + preloadSchemas(this.schemaDependencies.values()); } @Override diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 718298e38..d8f74c1c5 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -145,7 +145,7 @@ public SchemaRef getSchemaRef() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 088517b8d..4084ac733 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -93,7 +93,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void preloadJsonSchema() { + public void preloadSchema() { if (null != this.ifSchema) { this.ifSchema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index b2070da96..9c5eca24a 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -360,11 +360,11 @@ private boolean hasUnevaluatedItemsValidator() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { if (null != this.schema) { this.schema.initializeValidators(); } - preloadJsonSchemas(this.tupleSchema); + preloadSchemas(this.tupleSchema); if (null != this.additionalSchema) { this.additionalSchema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index fc50fa6b7..160b4edaf 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -178,7 +178,7 @@ public Schema getSchema() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { this.schema.initializeValidators(); collectAnnotations(); // cache the flag } diff --git a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java index abadc61b4..dbf561da8 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordValidator.java @@ -25,13 +25,13 @@ public interface KeywordValidator extends Validator { /** * In case the {@link com.networknt.schema.keyword.KeywordValidator} has a related {@link com.networknt.schema.Schema} or several - * ones, calling preloadJsonSchema will actually load the schema document(s) eagerly. + * ones, calling preloadSchema will actually load the schema document(s) eagerly. * * @throws SchemaException (a {@link java.lang.RuntimeException}) in case the {@link com.networknt.schema.Schema} or nested schemas * are invalid (like $ref not resolving) * @since 1.0.54 */ - default void preloadJsonSchema() throws SchemaException { + default void preloadSchema() throws SchemaException { // do nothing by default - to be overridden in subclasses } diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index 440ee6966..e6d9380d6 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -84,7 +84,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } @Override - public void preloadJsonSchema() { + public void preloadSchema() { if (null != this.schema) { this.schema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 0768a4de9..a01d31a48 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -239,7 +239,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } @Override - public void preloadJsonSchema() { + public void preloadSchema() { for (Schema schema: this.schemas) { schema.initializeValidators(); } diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 241b77df1..879f7dff1 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -102,8 +102,8 @@ private boolean hasUnevaluatedPropertiesValidator() { } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(schemas.values()); + public void preloadSchema() { + preloadSchemas(schemas.values()); collectAnnotations(); // cache the flag } } diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 6b744d069..2e4d0c61e 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -194,8 +194,8 @@ private boolean hasUnevaluatedItemsValidator() { } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(this.tupleSchema); + public void preloadSchema() { + preloadSchemas(this.tupleSchema); collectAnnotations(); // cache the flag } diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index c13e81234..56fc06354 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -187,8 +187,8 @@ public Map getSchemas() { } @Override - public void preloadJsonSchema() { - preloadJsonSchemas(this.schemas.values()); + public void preloadSchema() { + preloadSchemas(this.schemas.values()); collectAnnotations(); // cache the flag } } diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 64e49a035..67321427c 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -63,7 +63,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode @Override - public void preloadJsonSchema() { + public void preloadSchema() { innerSchema.initializeValidators(); } } diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index fafe9c50b..a4028f52f 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -142,7 +142,7 @@ public SchemaRef getSchemaRef() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index bd9762bc0..10800af6c 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -87,7 +87,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, if (findSchemaResource != null) { schemaResource = findSchemaResource; } else { - schemaResource = getJsonSchema(schemaResource, schemaContext, newRefValue, refValueOriginal, + schemaResource = getSchema(schemaResource, schemaContext, newRefValue, refValueOriginal, evaluationPath); } if (schemaResource == null) { @@ -106,7 +106,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, schemaResource = schemaContext.getDynamicAnchors().get(absoluteIri); } if (schemaResource == null) { - schemaResource = getJsonSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath); + schemaResource = getSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath); } if (schemaResource == null) { return null; @@ -120,7 +120,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, schemaContext.getSchemaRegistryConfig().isCacheRefs())); } return new SchemaRef(getSupplier( - () -> getJsonSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath) + () -> getSchema(parentSchema, schemaContext, refValue, refValueOriginal, evaluationPath) .fromRef(parentSchema, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs())); } @@ -153,7 +153,7 @@ private static String resolve(Schema parentSchema, String refValue) { return SchemaLocation.resolve(base.getSchemaLocation(), refValue); } - private static Schema getJsonSchema(Schema parent, + private static Schema getSchema(Schema parent, SchemaContext schemaContext, String refValue, String refValueOriginal, @@ -231,7 +231,7 @@ public SchemaRef getSchemaRef() { } @Override - public void preloadJsonSchema() { + public void preloadSchema() { Schema jsonSchema = null; try { jsonSchema = this.schema.getSchema(); diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 194b96a28..100ac2c09 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -110,10 +110,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } @Override - public void preloadJsonSchema() { + public void preloadSchema() { for (final Validator validator : schemas) { if (validator instanceof KeywordValidator) { - ((KeywordValidator) validator).preloadJsonSchema(); + ((KeywordValidator) validator).preloadSchema(); } else if (validator instanceof Schema) { ((Schema) validator).initializeValidators(); } diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index 907728573..bc032b833 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -55,7 +55,7 @@ void concurrency() throws Exception { String inputData = "{\r\n" + " \"name\": 1\r\n" + "}"; - SchemaRegistryConfig config = SchemaRegistryConfig.builder().preloadJsonSchema(false).build(); + SchemaRegistryConfig config = SchemaRegistryConfig.builder().preloadSchema(false).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config) .schemaLoaders(schemaLoaders -> schemaLoaders From 112bcb9c85246ee505e6dc388b4429d7b01cfbd1 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:51:46 +0800 Subject: [PATCH 25/74] Rename JsonNodeAnnotation to Annotation --- .../networknt/schema/ExecutionContext.java | 8 +++--- ...sonNodeAnnotation.java => Annotation.java} | 12 ++++----- ...redicate.java => AnnotationPredicate.java} | 12 ++++----- ...nNodeAnnotations.java => Annotations.java} | 14 +++++----- .../keyword/AbstractKeywordValidator.java | 6 ++--- .../AdditionalPropertiesValidator.java | 4 +-- .../schema/keyword/ContainsValidator.java | 10 +++---- .../schema/keyword/ItemsValidator.java | 18 ++++++------- .../schema/keyword/ItemsValidator202012.java | 6 ++--- .../keyword/PatternPropertiesValidator.java | 4 +-- .../schema/keyword/PrefixItemsValidator.java | 10 +++---- .../schema/keyword/PropertiesValidator.java | 4 +-- .../keyword/UnevaluatedItemsValidator.java | 26 +++++++++---------- .../UnevaluatedPropertiesValidator.java | 26 +++++++++---------- .../schema/output/OutputUnitData.java | 6 ++--- ...otationsTest.java => AnnotationsTest.java} | 12 ++++----- 16 files changed, 89 insertions(+), 89 deletions(-) rename src/main/java/com/networknt/schema/annotation/{JsonNodeAnnotation.java => Annotation.java} (87%) rename src/main/java/com/networknt/schema/annotation/{JsonNodeAnnotationPredicate.java => AnnotationPredicate.java} (89%) rename src/main/java/com/networknt/schema/annotation/{JsonNodeAnnotations.java => Annotations.java} (83%) rename src/test/java/com/networknt/schema/{JsonNodeAnnotationsTest.java => AnnotationsTest.java} (74%) diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index b472e98ce..65b393f31 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -16,7 +16,7 @@ package com.networknt.schema; -import com.networknt.schema.annotation.JsonNodeAnnotations; +import com.networknt.schema.annotation.Annotations; import com.networknt.schema.result.JsonNodeResults; import com.networknt.schema.walk.WalkConfig; @@ -34,7 +34,7 @@ public class ExecutionContext { private CollectorContext collectorContext = null; private Stack discriminatorContexts = null; - private JsonNodeAnnotations annotations = null; + private Annotations annotations = null; private JsonNodeResults results = null; private List errors = new ArrayList<>(); @@ -141,9 +141,9 @@ public void setExecutionConfig(ExecutionConfig executionConfig) { this.executionConfig = executionConfig; } - public JsonNodeAnnotations getAnnotations() { + public Annotations getAnnotations() { if (this.annotations == null) { - this.annotations = new JsonNodeAnnotations(); + this.annotations = new Annotations(); } return annotations; } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java b/src/main/java/com/networknt/schema/annotation/Annotation.java similarity index 87% rename from src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java rename to src/main/java/com/networknt/schema/annotation/Annotation.java index 60b60b09c..6649b05f0 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotation.java +++ b/src/main/java/com/networknt/schema/annotation/Annotation.java @@ -24,14 +24,14 @@ /** * The annotation. */ -public class JsonNodeAnnotation { +public class Annotation { private final String keyword; private final NodePath instanceLocation; private final SchemaLocation schemaLocation; private final NodePath evaluationPath; private final Object value; - public JsonNodeAnnotation(String keyword, NodePath instanceLocation, SchemaLocation schemaLocation, + public Annotation(String keyword, NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, Object value) { super(); this.keyword = keyword; @@ -92,7 +92,7 @@ public T getValue() { @Override public String toString() { - return "JsonNodeAnnotation [evaluationPath=" + evaluationPath + ", schemaLocation=" + schemaLocation + return "Annotation [evaluationPath=" + evaluationPath + ", schemaLocation=" + schemaLocation + ", instanceLocation=" + instanceLocation + ", keyword=" + keyword + ", value=" + value + "]"; } @@ -109,7 +109,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - JsonNodeAnnotation other = (JsonNodeAnnotation) obj; + Annotation other = (Annotation) obj; return Objects.equals(evaluationPath, other.evaluationPath) && Objects.equals(instanceLocation, other.instanceLocation) && Objects.equals(keyword, other.keyword) && Objects.equals(schemaLocation, other.schemaLocation) && Objects.equals(value, other.value); @@ -156,8 +156,8 @@ public Builder value(Object value) { return this; } - public JsonNodeAnnotation build() { - return new JsonNodeAnnotation(keyword, instanceLocation, schemaLocation, evaluationPath, value); + public Annotation build() { + return new Annotation(keyword, instanceLocation, schemaLocation, evaluationPath, value); } } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java b/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java similarity index 89% rename from src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java rename to src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java index 4747d3c8e..2fe8f44ad 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotationPredicate.java +++ b/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java @@ -23,7 +23,7 @@ /** * A predicate for filtering annotations. */ -public class JsonNodeAnnotationPredicate implements Predicate { +public class AnnotationPredicate implements Predicate { final Predicate instanceLocationPredicate; final Predicate evaluationPathPredicate; final Predicate schemaLocationPredicate; @@ -39,7 +39,7 @@ public class JsonNodeAnnotationPredicate implements Predicate instanceLocationPredicate, + protected AnnotationPredicate(Predicate instanceLocationPredicate, Predicate evaluationPathPredicate, Predicate schemaLocationPredicate, Predicate keywordPredicate, Predicate valuePredicate) { super(); @@ -51,7 +51,7 @@ protected JsonNodeAnnotationPredicate(Predicate instanceLocationPredic } @Override - public boolean test(JsonNodeAnnotation t) { + public boolean test(Annotation t) { return ((valuePredicate == null || valuePredicate.test(t.getValue())) && (keywordPredicate == null || keywordPredicate.test(t.getKeyword())) && (instanceLocationPredicate == null || instanceLocationPredicate.test(t.getInstanceLocation())) @@ -114,7 +114,7 @@ public static Builder builder() { } /** - * Builder for building a {@link JsonNodeAnnotationPredicate}. + * Builder for building a {@link AnnotationPredicate}. */ public static class Builder { Predicate instanceLocationPredicate; @@ -148,8 +148,8 @@ public Builder value(Predicate valuePredicate) { return this; } - public JsonNodeAnnotationPredicate build() { - return new JsonNodeAnnotationPredicate(instanceLocationPredicate, evaluationPathPredicate, + public AnnotationPredicate build() { + return new AnnotationPredicate(instanceLocationPredicate, evaluationPathPredicate, schemaLocationPredicate, keywordPredicate, valuePredicate); } } diff --git a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java b/src/main/java/com/networknt/schema/annotation/Annotations.java similarity index 83% rename from src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java rename to src/main/java/com/networknt/schema/annotation/Annotations.java index dec3281e8..f1fdbeb82 100644 --- a/src/main/java/com/networknt/schema/annotation/JsonNodeAnnotations.java +++ b/src/main/java/com/networknt/schema/annotation/Annotations.java @@ -31,14 +31,14 @@ * "https://github.com/json-schema-org/json-schema-spec/issues/530">Details * of annotation collection */ -public class JsonNodeAnnotations { +public class Annotations { /** * Stores the annotations. *

* instancePath to annotation */ - private final Map> values = new LinkedHashMap<>(); + private final Map> values = new LinkedHashMap<>(); /** * Gets the annotations. @@ -47,7 +47,7 @@ public class JsonNodeAnnotations { * * @return the annotations */ - public Map> asMap() { + public Map> asMap() { return this.values; } @@ -56,7 +56,7 @@ public Map> asMap() { * * @param annotation the annotation */ - public void put(JsonNodeAnnotation annotation) { + public void put(Annotation annotation) { this.values.computeIfAbsent(annotation.getInstanceLocation(), (k) -> new ArrayList<>()).add(annotation); } @@ -76,10 +76,10 @@ public static class Formatter { * @param annotations the annotations * @return the formatted JSON */ - public static String format(Map> annotations) { + public static String format(Map> annotations) { Map>> results = new LinkedHashMap<>(); - for (List list : annotations.values()) { - for (JsonNodeAnnotation annotation : list) { + for (List list : annotations.values()) { + for (Annotation annotation : list) { String keyword = annotation.getKeyword(); String instancePath = annotation.getInstanceLocation().toString(); String evaluationPath = annotation.getEvaluationPath().toString(); diff --git a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java index ce794af23..894319663 100644 --- a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; /** * Abstract {@link KeywordValidator}. @@ -116,8 +116,8 @@ protected boolean collectAnnotations(ExecutionContext executionContext, String k * @param executionContext the execution context * @param customizer to customize the annotation */ - protected void putAnnotation(ExecutionContext executionContext, Consumer customizer) { - JsonNodeAnnotation.Builder builder = JsonNodeAnnotation.builder().evaluationPath(this.evaluationPath) + protected void putAnnotation(ExecutionContext executionContext, Consumer customizer) { + Annotation.Builder builder = Annotation.builder().evaluationPath(this.evaluationPath) .schemaLocation(this.schemaLocation).keyword(getKeyword()); customizer.accept(builder); executionContext.getAnnotations().put(builder.build()); diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index a669a1676..6318f3637 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.regex.RegularExpression; import java.util.ArrayList; @@ -134,7 +134,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } } if (collectAnnotations) { - executionContext.getAnnotations().put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + executionContext.getAnnotations().put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation).keyword(getKeyword()) .value(matchedInstancePropertyNames != null ? matchedInstancePropertyNames : Collections.emptySet()) .build()); diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 6b707256e..64d1f7e0d 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import static com.networknt.schema.keyword.VersionCode.MinV201909; @@ -139,12 +139,12 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (actual == i) { // evaluated all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword("contains").value(true).build()); } else { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword("contains").value(indexes).build()); } @@ -158,7 +158,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // in the section for contains, the absence of this keyword's annotation causes // contains to assume a minimum value of 1. executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath.append(minContainsKeyword)) .schemaLocation(this.schemaLocation.append(minContainsKeyword)) .keyword(minContainsKeyword).value(this.min).build()); @@ -169,7 +169,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode String maxContainsKeyword = "maxContains"; if (collectAnnotations || collectAnnotations(executionContext, maxContainsKeyword)) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath.append(maxContainsKeyword)) .schemaLocation(this.schemaLocation.append(maxContainsKeyword)) .keyword(maxContainsKeyword).value(this.max).build()); diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 9c5eca24a..3dff9a46e 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.utils.SchemaRefs; import java.util.*; @@ -102,7 +102,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (this.schema != null) { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } else if (this.tupleSchema != null) { @@ -112,13 +112,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (items > schemas) { // More items than schemas so the keyword only applied to the number of schemas executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(schemas).build()); } else { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } @@ -143,7 +143,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (hasAdditionalItem) { if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.additionalItemsEvaluationPath) .schemaLocation(this.additionalItemsSchemaLocation) .keyword("additionalItems").value(true).build()); @@ -202,7 +202,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (this.schema != null) { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } else if (this.tupleSchema != null) { @@ -212,13 +212,13 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (items > schemas) { // More items than schemas so the keyword only applied to the number of schemas executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(schemas).build()); } else { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } @@ -306,7 +306,7 @@ else if (this.tupleSchema != null) { if (hasAdditionalItem) { if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.additionalItemsEvaluationPath) .schemaLocation(this.additionalItemsSchemaLocation) .keyword("additionalItems").value(true).build()); diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 160b4edaf..98633b7f0 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -24,7 +24,7 @@ import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.utils.SchemaRefs; /** @@ -87,7 +87,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (collectAnnotations() || collectAnnotations(executionContext)) { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } @@ -122,7 +122,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (collectAnnotations() || collectAnnotations(executionContext)) { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 879f7dff1..0cddab953 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.regex.RegularExpression; import java.util.*; @@ -81,7 +81,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } if (collectAnnotations) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()) .value(matchedInstancePropertyNames != null ? matchedInstancePropertyNames diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 2e4d0c61e..71c56ebeb 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.utils.SchemaRefs; import java.util.ArrayList; @@ -73,13 +73,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (items > schemas) { // More items than schemas so the keyword only applied to the number of schemas executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(schemas).build()); } else { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } @@ -115,13 +115,13 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root if (items > schemas) { // More items than schemas so the keyword only applied to the number of schemas executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(schemas).build()); } else { // Applies to all executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(true).build()); } diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 56fc06354..43fb33628 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -26,7 +26,7 @@ import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import com.networknt.schema.utils.SchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; import java.util.Collections; @@ -98,7 +98,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } if (collectAnnotations) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword(getKeyword()).value(matchedInstancePropertyNames == null ? Collections.emptySet() : matchedInstancePropertyNames) diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 10bfffffc..cc9d32ff7 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.Specification.Version; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; import static com.networknt.schema.keyword.VersionCode.MinV202012; @@ -75,12 +75,12 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode boolean evaluated = false; // Get all the valid adjacent annotations - Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); + Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); - Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() + Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() .startsWith(this.evaluationPath.getParent()); - List instanceLocationAnnotations = executionContext.getAnnotations().asMap() + List instanceLocationAnnotations = executionContext.getAnnotations().asMap() .getOrDefault(instanceLocation, Collections.emptyList()); // If schema is "unevaluatedItems: true" this is valid @@ -93,7 +93,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } } else { // Get all the "items" for the instanceLocation - List items = instanceLocationAnnotations.stream() + List items = instanceLocationAnnotations.stream() .filter(a -> itemsKeyword.equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); if (items.isEmpty()) { @@ -104,7 +104,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // same instance location are combined by setting the combined result to true if // any of the values are true, and otherwise retaining the largest numerical // value. - for (JsonNodeAnnotation annotation : items) { + for (Annotation annotation : items) { if (annotation.getValue() instanceof Number) { Number value = annotation.getValue(); int existing = value.intValue(); @@ -125,10 +125,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // from any subschema applied to the same instance location produces an // annotation value of true, then the combined result from these keywords is // also true. - List additionalItems = instanceLocationAnnotations.stream() + List additionalItems = instanceLocationAnnotations.stream() .filter(a -> additionalItemsKeyword.equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : additionalItems) { + for (Annotation annotation : additionalItems) { if (annotation.getValue() instanceof Boolean && Boolean.TRUE.equals(annotation.getValue())) { // The annotation "additionalItems: true" valid = true; @@ -138,10 +138,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!valid) { // Unevaluated // Check if there are any "unevaluatedItems" annotations - List unevaluatedItems = instanceLocationAnnotations.stream() + List unevaluatedItems = instanceLocationAnnotations.stream() .filter(a -> "unevaluatedItems".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : unevaluatedItems) { + for (Annotation annotation : unevaluatedItems) { if (annotation.getValue() instanceof Boolean && Boolean.TRUE.equals(annotation.getValue())) { // The annotation "unevaluatedItems: true" valid = true; @@ -152,13 +152,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode if (!valid) { int currentErrors = executionContext.getErrors().size(); // Get all the "contains" for the instanceLocation - List contains = instanceLocationAnnotations.stream() + List contains = instanceLocationAnnotations.stream() .filter(a -> "contains".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); Set containsEvaluated = new HashSet<>(); boolean containsEvaluatedAll = false; - for (JsonNodeAnnotation a : contains) { + for (Annotation a : contains) { if (a.getValue() instanceof List) { List values = a.getValue(); containsEvaluated.addAll(values); @@ -197,7 +197,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // also true. if (evaluated) { executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) + .put(Annotation.builder().instanceLocation(instanceLocation) .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) .keyword("unevaluatedItems").value(true).build()); } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 3e1f11603..7d9e0d0c6 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -30,7 +30,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; /** * {@link KeywordValidator} for unevaluatedProperties. @@ -56,21 +56,21 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // Get all the valid adjacent annotations - Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); + Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); - Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() + Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() .startsWith(this.evaluationPath.getParent()); - List instanceLocationAnnotations = executionContext.getAnnotations().asMap() + List instanceLocationAnnotations = executionContext.getAnnotations().asMap() .getOrDefault(instanceLocation, Collections.emptyList()); Set evaluatedProperties = new LinkedHashSet<>(); // The properties that unevaluatedProperties schema Set existingEvaluatedProperties = new LinkedHashSet<>(); // Get all the "properties" for the instanceLocation - List properties = instanceLocationAnnotations.stream() + List properties = instanceLocationAnnotations.stream() .filter(a -> "properties".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : properties) { + for (Annotation annotation : properties) { if (annotation.getValue() instanceof Set) { Set p = annotation.getValue(); existingEvaluatedProperties.addAll(p); @@ -78,10 +78,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } // Get all the "patternProperties" for the instanceLocation - List patternProperties = instanceLocationAnnotations.stream() + List patternProperties = instanceLocationAnnotations.stream() .filter(a -> "patternProperties".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : patternProperties) { + for (Annotation annotation : patternProperties) { if (annotation.getValue() instanceof Set) { Set p = annotation.getValue(); existingEvaluatedProperties.addAll(p); @@ -89,10 +89,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } // Get all the "patternProperties" for the instanceLocation - List additionalProperties = instanceLocationAnnotations.stream() + List additionalProperties = instanceLocationAnnotations.stream() .filter(a -> "additionalProperties".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : additionalProperties) { + for (Annotation annotation : additionalProperties) { if (annotation.getValue() instanceof Set) { Set p = annotation.getValue(); existingEvaluatedProperties.addAll(p); @@ -100,10 +100,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } // Get all the "unevaluatedProperties" for the instanceLocation - List unevaluatedProperties = instanceLocationAnnotations.stream() + List unevaluatedProperties = instanceLocationAnnotations.stream() .filter(a -> "unevaluatedProperties".equals(a.getKeyword())).filter(adjacentEvaluationPathFilter) .filter(validEvaluationPathFilter).collect(Collectors.toList()); - for (JsonNodeAnnotation annotation : unevaluatedProperties) { + for (Annotation annotation : unevaluatedProperties) { if (annotation.getValue() instanceof Set) { Set p = annotation.getValue(); existingEvaluatedProperties.addAll(p); @@ -134,7 +134,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode executionContext.setFailFast(failFast); // restore flag } executionContext.getAnnotations() - .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation).evaluationPath(this.evaluationPath) + .put(Annotation.builder().instanceLocation(instanceLocation).evaluationPath(this.evaluationPath) .schemaLocation(this.schemaLocation).keyword(getKeyword()).value(evaluatedProperties).build()); return; diff --git a/src/main/java/com/networknt/schema/output/OutputUnitData.java b/src/main/java/com/networknt/schema/output/OutputUnitData.java index 76b7c0881..42ceddebe 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitData.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitData.java @@ -24,7 +24,7 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Error; -import com.networknt.schema.annotation.JsonNodeAnnotation; +import com.networknt.schema.annotation.Annotation; /** * Output Unit Data. @@ -88,8 +88,8 @@ public static OutputUnitData from(List validationErrors, ExecutionContext } } - for (List annotationsResult : executionContext.getAnnotations().asMap().values()) { - for (JsonNodeAnnotation annotation : annotationsResult) { + for (List annotationsResult : executionContext.getAnnotations().asMap().values()) { + for (Annotation annotation : annotationsResult) { // As some annotations are required for computation, filter those that are not // required for reporting if (executionContext.getExecutionConfig().getAnnotationCollectionFilter() diff --git a/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java b/src/test/java/com/networknt/schema/AnnotationsTest.java similarity index 74% rename from src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java rename to src/test/java/com/networknt/schema/AnnotationsTest.java index 38bb8a2c9..734b37ba9 100644 --- a/src/test/java/com/networknt/schema/JsonNodeAnnotationsTest.java +++ b/src/test/java/com/networknt/schema/AnnotationsTest.java @@ -19,17 +19,17 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.annotation.JsonNodeAnnotations; +import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.annotation.Annotations; /** - * JsonNodeAnnotationsTest. + * AnnotationsTest. */ -class JsonNodeAnnotationsTest { +class AnnotationsTest { @Test void put() { - JsonNodeAnnotations annotations = new JsonNodeAnnotations(); - JsonNodeAnnotation annotation = new JsonNodeAnnotation("unevaluatedProperties", + Annotations annotations = new Annotations(); + Annotation annotation = new Annotation("unevaluatedProperties", new NodePath(PathType.JSON_POINTER), SchemaLocation.of(""), new NodePath(PathType.JSON_POINTER), "test"); annotations.put(annotation); From a52730c507ba4ab4233fd50961068dc60ab24729 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:53:07 +0800 Subject: [PATCH 26/74] Rename BaseFormatJsonValidator to BaseFormatValidator --- ...{BaseFormatJsonValidator.java => BaseFormatValidator.java} | 4 ++-- .../java/com/networknt/schema/keyword/FormatValidator.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/networknt/schema/format/{BaseFormatJsonValidator.java => BaseFormatValidator.java} (90%) diff --git a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java similarity index 90% rename from src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java rename to src/main/java/com/networknt/schema/format/BaseFormatValidator.java index 01fbcf93c..cc7c3596c 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatJsonValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java @@ -12,10 +12,10 @@ import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; -public abstract class BaseFormatJsonValidator extends BaseKeywordValidator { +public abstract class BaseFormatValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; - public BaseFormatJsonValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + public BaseFormatValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, Keyword keyword, SchemaContext schemaContext) { super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index 210ea0eeb..af4211877 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.format.BaseFormatJsonValidator; +import com.networknt.schema.format.BaseFormatValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +33,7 @@ /** * Validator for Format. */ -public class FormatValidator extends BaseFormatJsonValidator implements KeywordValidator { +public class FormatValidator extends BaseFormatValidator implements KeywordValidator { private static final Logger logger = LoggerFactory.getLogger(FormatValidator.class); private final Format format; From 200403b9439c6fabd142d0c5f020e31fbc2dd069 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:54:05 +0800 Subject: [PATCH 27/74] Rename JsonNodeResult to SchemaResult --- .../java/com/networknt/schema/ExecutionContext.java | 8 ++++---- .../{JsonNodeResult.java => SchemaResult.java} | 6 +++--- .../{JsonNodeResults.java => SchemaResults.java} | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) rename src/main/java/com/networknt/schema/result/{JsonNodeResult.java => SchemaResult.java} (89%) rename src/main/java/com/networknt/schema/result/{JsonNodeResults.java => SchemaResults.java} (74%) diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 65b393f31..931348c96 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -17,7 +17,7 @@ package com.networknt.schema; import com.networknt.schema.annotation.Annotations; -import com.networknt.schema.result.JsonNodeResults; +import com.networknt.schema.result.SchemaResults; import com.networknt.schema.walk.WalkConfig; import java.util.ArrayList; @@ -35,7 +35,7 @@ public class ExecutionContext { private Stack discriminatorContexts = null; private Annotations annotations = null; - private JsonNodeResults results = null; + private SchemaResults results = null; private List errors = new ArrayList<>(); /** @@ -148,9 +148,9 @@ public Annotations getAnnotations() { return annotations; } - public JsonNodeResults getResults() { + public SchemaResults getResults() { if (this.results == null) { - this.results = new JsonNodeResults(); + this.results = new SchemaResults(); } return results; } diff --git a/src/main/java/com/networknt/schema/result/JsonNodeResult.java b/src/main/java/com/networknt/schema/result/SchemaResult.java similarity index 89% rename from src/main/java/com/networknt/schema/result/JsonNodeResult.java rename to src/main/java/com/networknt/schema/result/SchemaResult.java index 4baf9ba31..a1eae6ba3 100644 --- a/src/main/java/com/networknt/schema/result/JsonNodeResult.java +++ b/src/main/java/com/networknt/schema/result/SchemaResult.java @@ -23,13 +23,13 @@ /** * Sub schema results. */ -public class JsonNodeResult { +public class SchemaResult { private final NodePath instanceLocation; private final SchemaLocation schemaLocation; private final NodePath evaluationPath; private final boolean valid; - public JsonNodeResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, + public SchemaResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { super(); this.instanceLocation = instanceLocation; @@ -73,7 +73,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - JsonNodeResult other = (JsonNodeResult) obj; + SchemaResult other = (SchemaResult) obj; return Objects.equals(evaluationPath, other.evaluationPath) && Objects.equals(instanceLocation, other.instanceLocation) && Objects.equals(schemaLocation, other.schemaLocation) && valid == other.valid; diff --git a/src/main/java/com/networknt/schema/result/JsonNodeResults.java b/src/main/java/com/networknt/schema/result/SchemaResults.java similarity index 74% rename from src/main/java/com/networknt/schema/result/JsonNodeResults.java rename to src/main/java/com/networknt/schema/result/SchemaResults.java index 0196c9a50..9c2514a44 100644 --- a/src/main/java/com/networknt/schema/result/JsonNodeResults.java +++ b/src/main/java/com/networknt/schema/result/SchemaResults.java @@ -26,24 +26,24 @@ /** * Sub schema results. */ -public class JsonNodeResults { +public class SchemaResults { /** * Stores the invalid results. */ - private final Map> values = new HashMap<>(); + private final Map> values = new HashMap<>(); public void setResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { - JsonNodeResult result = new JsonNodeResult(instanceLocation, schemaLocation, evaluationPath, valid); - List v = values.computeIfAbsent(instanceLocation, k -> new ArrayList<>()); + SchemaResult result = new SchemaResult(instanceLocation, schemaLocation, evaluationPath, valid); + List v = values.computeIfAbsent(instanceLocation, k -> new ArrayList<>()); v.add(result); } public boolean isValid(NodePath instanceLocation, NodePath evaluationPath) { - List instance = values.get(instanceLocation); + List instance = values.get(instanceLocation); if (instance != null) { - for (JsonNodeResult result : instance) { + for (SchemaResult result : instance) { if (evaluationPath.startsWith(result.getEvaluationPath())) { if(!result.isValid()) { return false; From cf6ebb590646c13744d3d1a38064f75386f66bff Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:56:20 +0800 Subject: [PATCH 28/74] Rename ValidationResult to Result --- .../com/networknt/schema/OutputFormat.java | 7 ++--- .../{ValidationResult.java => Result.java} | 4 +-- .../java/com/networknt/schema/Schema.java | 24 ++++++++--------- .../networknt/schema/AllOfValidatorTest.java | 2 +- .../networknt/schema/AnyOfValidatorTest.java | 2 +- .../schema/CollectorContextTest.java | 18 ++++++------- .../com/networknt/schema/IfValidatorTest.java | 8 +++--- .../com/networknt/schema/Issue461Test.java | 2 +- .../com/networknt/schema/Issue467Test.java | 4 +-- .../com/networknt/schema/Issue877Test.java | 2 +- .../schema/ItemsValidator202012Test.java | 4 +-- .../networknt/schema/ItemsValidatorTest.java | 10 +++---- .../schema/JsonWalkApplyDefaultsTest.java | 6 ++--- .../com/networknt/schema/JsonWalkTest.java | 4 +-- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 2 +- .../schema/PrefixItemsValidatorTest.java | 4 +-- .../schema/PropertiesValidatorTest.java | 2 +- .../networknt/schema/TypeValidatorTest.java | 2 +- .../schema/walk/WalkListenerTest.java | 26 +++++++++---------- 20 files changed, 68 insertions(+), 67 deletions(-) rename src/main/java/com/networknt/schema/{ValidationResult.java => Result.java} (92%) diff --git a/src/main/java/com/networknt/schema/OutputFormat.java b/src/main/java/com/networknt/schema/OutputFormat.java index bbed2ff4b..9a64c71c2 100644 --- a/src/main/java/com/networknt/schema/OutputFormat.java +++ b/src/main/java/com/networknt/schema/OutputFormat.java @@ -202,14 +202,15 @@ public OutputUnit format(Schema jsonSchema, *

* This is currently not exposed to consumers. */ - class Result implements OutputFormat { + class Result implements OutputFormat { @Override public void customize(ExecutionContext executionContext, SchemaContext schemaContext) { } @Override - public ValidationResult format(Schema jsonSchema,ExecutionContext executionContext, SchemaContext schemaContext) { - return new ValidationResult(executionContext); + public com.networknt.schema.Result format(Schema jsonSchema, ExecutionContext executionContext, + SchemaContext schemaContext) { + return new com.networknt.schema.Result(executionContext); } } } diff --git a/src/main/java/com/networknt/schema/ValidationResult.java b/src/main/java/com/networknt/schema/Result.java similarity index 92% rename from src/main/java/com/networknt/schema/ValidationResult.java rename to src/main/java/com/networknt/schema/Result.java index fe6ded59f..028d6bd2b 100644 --- a/src/main/java/com/networknt/schema/ValidationResult.java +++ b/src/main/java/com/networknt/schema/Result.java @@ -20,10 +20,10 @@ /** * Represents a validation result. */ -public class ValidationResult { +public class Result { private final ExecutionContext executionContext; - public ValidationResult(ExecutionContext executionContext) { + public Result(ExecutionContext executionContext) { super(); this.executionContext = executionContext; } diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index a933c9a22..06e6b81b6 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -1043,7 +1043,7 @@ private JsonNode deserialize(String input, InputFormat inputFormat) { * * @return the validation result */ - public ValidationResult walk(ExecutionContext executionContext, JsonNode node, boolean validate, + public Result walk(ExecutionContext executionContext, JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer) { return walkAtNodeInternal(executionContext, node, node, atRoot(), validate, OutputFormat.RESULT, executionCustomizer); @@ -1076,7 +1076,7 @@ public T walk(ExecutionContext executionContext, JsonNode node, OutputFormat * * @return the validation result */ - public ValidationResult walk(ExecutionContext executionContext, JsonNode node, boolean validate, + public Result walk(ExecutionContext executionContext, JsonNode node, boolean validate, Consumer executionCustomizer) { return walkAtNodeInternal(executionContext, node, node, atRoot(), validate, OutputFormat.RESULT, executionCustomizer); @@ -1108,7 +1108,7 @@ public T walk(ExecutionContext executionContext, JsonNode node, OutputFormat * * @return the validation result */ - public ValidationResult walk(ExecutionContext executionContext, JsonNode node, boolean validate) { + public Result walk(ExecutionContext executionContext, JsonNode node, boolean validate) { return walkAtNodeInternal(executionContext, node, node, atRoot(), validate, OutputFormat.RESULT, (ExecutionContextCustomizer) null); } @@ -1122,7 +1122,7 @@ public ValidationResult walk(ExecutionContext executionContext, JsonNode node, b * @param validate true to validate the input against the schema * @return the validation result */ - public ValidationResult walk(ExecutionContext executionContext, String input, InputFormat inputFormat, + public Result walk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate) { JsonNode node = deserialize(input, inputFormat); return walkAtNodeInternal(executionContext, node, node, atRoot(), validate, OutputFormat.RESULT, @@ -1157,7 +1157,7 @@ public T walk(ExecutionContext executionContext, String input, InputFormat i * @param executionCustomizer the customizer * @return the validation result */ - public ValidationResult walk(ExecutionContext executionContext, String input, InputFormat inputFormat, + public Result walk(ExecutionContext executionContext, String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer) { JsonNode node = deserialize(input, inputFormat); return walkAtNodeInternal(executionContext, node, node, atRoot(), validate, OutputFormat.RESULT, executionCustomizer); @@ -1188,7 +1188,7 @@ public T walk(ExecutionContext executionContext, String input, InputFormat i * @param validate true to validate the input against the schema * @return the validation result */ - public ValidationResult walk(JsonNode node, boolean validate) { + public Result walk(JsonNode node, boolean validate) { return walk(createExecutionContext(), node, validate); } @@ -1200,7 +1200,7 @@ public ValidationResult walk(JsonNode node, boolean validate) { * @param executionCustomizer the customizer * @return the validation result */ - public ValidationResult walk(JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer) { + public Result walk(JsonNode node, boolean validate, ExecutionContextCustomizer executionCustomizer) { return walk(createExecutionContext(), node, validate, executionCustomizer); } @@ -1212,7 +1212,7 @@ public ValidationResult walk(JsonNode node, boolean validate, ExecutionContextCu * @param executionCustomizer the customizer * @return the validation result */ - public ValidationResult walk(JsonNode node, boolean validate, Consumer executionCustomizer) { + public Result walk(JsonNode node, boolean validate, Consumer executionCustomizer) { return walk(createExecutionContext(), node, validate, executionCustomizer); } @@ -1237,7 +1237,7 @@ public T walk(JsonNode node, OutputFormat outputFormat, boolean validate) * @param validate true to validate the input against the schema * @return the validation result */ - public ValidationResult walk(String input, InputFormat inputFormat, boolean validate) { + public Result walk(String input, InputFormat inputFormat, boolean validate) { return walk(createExecutionContext(), deserialize(input, inputFormat), validate); } @@ -1250,7 +1250,7 @@ public ValidationResult walk(String input, InputFormat inputFormat, boolean vali * @param executionCustomizer the customizer * @return the validation result */ - public ValidationResult walk(String input, InputFormat inputFormat, boolean validate, + public Result walk(String input, InputFormat inputFormat, boolean validate, ExecutionContextCustomizer executionCustomizer) { return walk(createExecutionContext(), deserialize(input, inputFormat), validate, executionCustomizer); } @@ -1264,7 +1264,7 @@ public ValidationResult walk(String input, InputFormat inputFormat, boolean vali * @param executionCustomizer the customizer * @return the validation result */ - public ValidationResult walk(String input, InputFormat inputFormat, boolean validate, + public Result walk(String input, InputFormat inputFormat, boolean validate, Consumer executionCustomizer) { return walk(createExecutionContext(), deserialize(input, inputFormat), validate, executionCustomizer); } @@ -1279,7 +1279,7 @@ public ValidationResult walk(String input, InputFormat inputFormat, boolean vali * @param validate true to validate the input against the schema * @return the validation result */ - public ValidationResult walkAtNode(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + public Result walkAtNode(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean validate) { return walkAtNodeInternal(executionContext, node, rootNode, instanceLocation, validate, OutputFormat.RESULT, (ExecutionContextCustomizer) null); diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index d58fb9a0c..bda2bef66 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -61,7 +61,7 @@ void walkValidationWithNullNodeShouldNotValidate() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); - ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); + Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 57f7be084..24bff0985 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -61,7 +61,7 @@ void walkValidationWithNullNodeShouldNotValidate() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); - ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); + Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 3a1040242..d79b463bc 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -61,7 +61,7 @@ void setup() throws Exception { @Test void testCollectorContextWithKeyword() throws Exception { - ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); + Result validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); Assertions.assertEquals(0, validationResult.getErrors().size()); List contextValues = validationResult.getCollectorContext().get(Data.SAMPLE_COLLECTOR); contextValues.sort(null); @@ -93,9 +93,9 @@ void testCollectorContextWithMultipleThreads() throws Exception { thread2.join(); thread3.join(); - ValidationResult validationResult1 = validationRunnable1.getValidationResult(); - ValidationResult validationResult2 = validationRunnable2.getValidationResult(); - ValidationResult validationResult3 = validationRunnable3.getValidationResult(); + Result validationResult1 = validationRunnable1.getValidationResult(); + Result validationResult2 = validationRunnable2.getValidationResult(); + Result validationResult3 = validationRunnable3.getValidationResult(); Assertions.assertEquals(0, validationResult1.getErrors().size()); Assertions.assertEquals(0, validationResult2.getErrors().size()); @@ -117,7 +117,7 @@ void testCollectorGetAll() throws IOException { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); jsonSchemaForCombine.validate(executionContext, objectMapper .readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }")); - ValidationResult validationResult = new ValidationResult(executionContext); + Result validationResult = new Result(executionContext); CollectorContext collectorContext = validationResult.getCollectorContext(); List sampleCollector = collectorContext.get(Data.SAMPLE_COLLECTOR); List sampleCollectorOther = collectorContext.get(Data.SAMPLE_COLLECTOR_OTHER); @@ -222,7 +222,7 @@ private class ValidationThread implements Runnable { private final String name; - private ValidationResult validationResult; + private Result validationResult; ValidationThread(String data, String name) { this.name = name; @@ -242,7 +242,7 @@ public void run() { } } - ValidationResult getValidationResult() { + Result getValidationResult() { return this.validationResult; } @@ -395,11 +395,11 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root } } - private ValidationResult validate(String jsonData) throws Exception { + private Result validate(String jsonData) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ExecutionContext executionContext = this.jsonSchema.createExecutionContext(); this.jsonSchema.validate(executionContext, objectMapper.readTree(jsonData)); - return new ValidationResult(executionContext); + return new Result(executionContext); } protected static Map getDatasourceMap() { diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 83bc0ba29..472458497 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -73,7 +73,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk("\"false\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); List types = result.getExecutionContext().getCollectorContext().get("types"); @@ -118,7 +118,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk("\"hello\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk("\"hello\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -164,7 +164,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -208,7 +208,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk("\"false\"", InputFormat.JSON, false, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk("\"false\"", InputFormat.JSON, false, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 458866637..8dd16639c 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -34,7 +34,7 @@ void shouldWalkWithValidation() throws IOException { Schema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); JsonNode data = mapper.readTree(Issue461Test.class.getResource("/data/issue461-v7.json")); - ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); Assertions.assertTrue(result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index bd298ac85..e79a47fb3 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -67,7 +67,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); - ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals(new HashSet<>(Arrays.asList("/properties", "/properties/tags/items/0/properties")), properties.stream().map(Object::toString).collect(Collectors.toSet())); assertEquals(1, result.getErrors().size()); @@ -96,7 +96,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); - ValidationResult result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals( new HashSet<>(Arrays.asList("/properties/tags", "/properties/tags/items/0/properties/category", "/properties/tags/items/0/properties/value")), properties.stream().map(Object::toString).collect(Collectors.toSet())); diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 70d1bbd5b..0eedab865 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -33,7 +33,7 @@ void test() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; - ValidationResult result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); + Result result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); assertEquals(0, result.getErrors().size()); input = ""; diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index b0478d92e..e3e3ebf9e 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -89,7 +89,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -131,7 +131,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 055830be8..a8b5f7536 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -143,7 +143,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -181,7 +181,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -225,7 +225,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -279,7 +279,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); - ValidationResult result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -335,7 +335,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); - ValidationResult result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 289bc8529..0795af45d 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -26,7 +26,7 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException { Schema jsonSchema = createSchema(); WalkConfig walkConfig = WalkConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); - ValidationResult result = jsonSchema.walk(inputNode, shouldValidateSchema, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = jsonSchema.walk(inputNode, shouldValidateSchema, executionContext -> executionContext.setWalkConfig(walkConfig)); if (shouldValidateSchema) { assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", @@ -49,7 +49,7 @@ void testApplyDefaults2() throws IOException { Schema jsonSchema = createSchema(); WalkConfig walkConfig = WalkConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, false)).build(); - ValidationResult result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_missingButError: string found, integer expected", "/outer/goodArray/1: null found, string expected", @@ -68,7 +68,7 @@ void testApplyDefaults1() throws IOException { Schema jsonSchema = createSchema(); WalkConfig walkConfig = WalkConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)).build(); - ValidationResult result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = jsonSchema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertThat(result.getErrors().stream().map(Error::toString).collect(Collectors.toList()), Matchers.containsInAnyOrder("/outer/mixedObject/intValue_null: null found, integer expected", "/outer/mixedObject/intValue_missingButError: string found, integer expected", diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 10d5c8b25..cb83e735e 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -77,7 +77,7 @@ private Dialect getDialect() { @Test void testWalk() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - ValidationResult result = jsonSchema.walk( + Result result = jsonSchema.walk( objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false, executionContext -> executionContext.setWalkConfig(walkConfig)); JsonNode collectedNode = (JsonNode) result.getCollectorContext().get(SAMPLE_WALK_COLLECTOR_TYPE); @@ -98,7 +98,7 @@ void testWalk() throws IOException { void testWalkWithDifferentListeners() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); // This instance of schema contains all listeners. - ValidationResult result = jsonSchema.walk( + Result result = jsonSchema.walk( objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false, executionContext -> executionContext.setWalkConfig(walkConfig)); JsonNode collectedNode = (JsonNode) result.getCollectorContext().get(SAMPLE_WALK_COLLECTOR_TYPE); diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index 3d5461841..53b8aa250 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -38,7 +38,7 @@ void walkValidationWithNullNodeShouldNotValidate() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); - ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); + Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); } } diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 917d314ac..a47378de0 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -489,7 +489,7 @@ void walkValidationWithNullNodeShouldNotValidate() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); Schema schema = factory.getSchema(schemaContents); - ValidationResult result = schema.walk(jsonContents, InputFormat.JSON, true); + Result result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); assertEquals(true, result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 02b663f02..a5580fef1 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -152,7 +152,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); - ValidationResult result = schema.walk(null, true, + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -210,7 +210,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null]"); - ValidationResult result = schema.walk(input, true, + Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 45fa13562..76d3593c4 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -18,7 +18,7 @@ void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exceptio SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); Schema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}"); JsonNode node = getJsonNodeFromStringContent("{\"foo\": \"bar\"}"); - ValidationResult result = schema.walk(node, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(node, true, executionContext -> executionContext.setWalkConfig(walkConfig)); Assertions.assertEquals(result.getErrors().size(), 1); }); } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index bb60775ae..934cb71c6 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -147,7 +147,7 @@ void walkNull() { + " \"type\": \"integer\"\r\n" + "}"; Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4).getSchema(schemaData); - ValidationResult result = schema.walk(null, true); + Result result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index aec812d7f..22c78e80f 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -50,7 +50,7 @@ import com.networknt.schema.utils.JsonNodes; import com.networknt.schema.utils.SchemaRefs; import com.networknt.schema.Error; -import com.networknt.schema.ValidationResult; +import com.networknt.schema.Result; /** * JsonSchemaWalkListenerTest. @@ -119,7 +119,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") List propertyKeywords = (List) result.getExecutionContext().getCollectorContext().get("propertyKeywords"); @@ -202,7 +202,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -291,7 +291,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListenerRunner(itemWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -367,7 +367,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .itemWalkListenerRunner(itemWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @SuppressWarnings("unchecked") @@ -424,7 +424,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputData, InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); List propertyKeywords = result.getExecutionContext().getCollectorContext().get("propertyKeywords"); @@ -571,7 +571,7 @@ void applyDefaults() throws JsonProcessingException { .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -631,7 +631,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -691,7 +691,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":1,\"ref\":\"REF\"}", inputNode.toString()); assertFalse(result.getErrors().isEmpty()); @@ -762,7 +762,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); assertEquals("{\"type\":\"integer\"}", missingSchemaNode.get("s").toString()); assertEquals("{\"type\":\"string\"}", missingSchemaNode.get("ref").toString()); @@ -835,7 +835,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); - ValidationResult result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"name\":\"John Doe\",\"email\":\"john.doe@gmail.com\"}", inputNode.toString()); assertTrue(result.getErrors().isEmpty()); } @@ -888,7 +888,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(4, items.size()); @@ -954,7 +954,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .build(); Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); - ValidationResult result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); List items = result.getExecutionContext().getCollectorContext().get("items"); assertEquals(4, items.size()); assertEquals("/name", items.get(0).getInstanceLocation().toString()); From d7b00b341cdf1286795ce942132813b1f1164d0c Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 23 Sep 2025 23:08:36 +0800 Subject: [PATCH 29/74] Refactor naming --- .../java/com/networknt/schema/Schema.java | 11 +---- .../com/networknt/schema/SchemaContext.java | 4 -- .../com/networknt/schema/SchemaRegistry.java | 6 +-- .../com/networknt/schema/Vocabularies.java | 28 +++++------ .../java/com/networknt/schema/Vocabulary.java | 28 +++++------ .../schema/dialect/BasicDialectRegistry.java | 2 +- .../com/networknt/schema/dialect/Dialect.java | 48 +++++++++---------- .../networknt/schema/dialect/Draft201909.java | 8 ++-- .../networknt/schema/dialect/Draft202012.java | 8 ++-- .../com/networknt/schema/dialect/Draft4.java | 8 ++-- .../com/networknt/schema/dialect/Draft6.java | 8 ++-- .../com/networknt/schema/dialect/Draft7.java | 8 ++-- .../networknt/schema/dialect/OpenApi30.java | 8 ++-- .../networknt/schema/dialect/OpenApi31.java | 8 ++-- .../schema/keyword/BaseKeywordValidator.java | 1 - .../keyword/UnevaluatedItemsValidator.java | 3 +- .../networknt/schema/utils/JsonNodeUtil.java | 2 +- .../com/networknt/schema/ExampleTest.java | 8 ++-- .../com/networknt/schema/Issue471Test.java | 10 ++-- .../com/networknt/schema/Issue784Test.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue832Test.java | 2 +- .../com/networknt/schema/Issue994Test.java | 2 +- .../com/networknt/schema/MessageTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 8 ++-- .../com/networknt/schema/UriMappingTest.java | 4 +- .../java/com/networknt/schema/UrnTest.java | 2 +- .../com/networknt/schema/VocabularyTest.java | 6 +-- 28 files changed, 112 insertions(+), 125 deletions(-) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 06e6b81b6..9e41daec3 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -51,7 +51,7 @@ * modified. */ public class Schema implements Validator { - private static final long V201909_VALUE = Version.DRAFT_2019_09.getOrder(); + private static final long DRAFT_2019_09_VALUE = Version.DRAFT_2019_09.getOrder(); private final String id; /** @@ -656,7 +656,7 @@ private List read(JsonNode schemaNode) { } // Ignore siblings for older drafts - if (null != refValidator && activeDialect() < V201909_VALUE) { + if (null != refValidator && getSchemaContext().getDialect().getSpecification().getOrder() < DRAFT_2019_09_VALUE) { validators.clear(); validators.add(refValidator); } @@ -667,13 +667,6 @@ private List read(JsonNode schemaNode) { return validators; } - private long activeDialect() { - return this.schemaContext - .activeDialect() - .map(Version::getOrder) - .orElse(Integer.MAX_VALUE); - } - /** * A comparator that sorts validators, such that 'properties' comes before 'required', * so that we can apply default values before validating required. diff --git a/src/main/java/com/networknt/schema/SchemaContext.java b/src/main/java/com/networknt/schema/SchemaContext.java index 10bbfe511..1dbd8b714 100644 --- a/src/main/java/com/networknt/schema/SchemaContext.java +++ b/src/main/java/com/networknt/schema/SchemaContext.java @@ -171,10 +171,6 @@ public Dialect getDialect() { return this.dialect; } - public Optional activeDialect() { - return Optional.of(this.dialect.getSpecification()); - } - public boolean isDiscriminatorKeywordEnabled() { return discriminatorKeywordEnabled; } diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 483c5e739..8c2402f33 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -209,7 +209,7 @@ public static SchemaRegistry withDefaultDialect(Specification.Version specificat public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion, Consumer customizer) { Dialect dialect = Specification.getDialect(specificationVersion); - return withDefaultDialectId(dialect.getIri(), customizer); + return withDefaultDialectId(dialect.getId(), customizer); } /** @@ -251,7 +251,7 @@ public static SchemaRegistry withDialect(Dialect dialect) { * @return the schema registry */ public static SchemaRegistry withDialect(Dialect dialect, Consumer customizer) { - SchemaRegistry.Builder builder = builder().defaultDialectId(dialect.getIri()) + SchemaRegistry.Builder builder = builder().defaultDialectId(dialect.getId()) .dialectRegistry(new BasicDialectRegistry(dialect)); if (customizer != null) { customizer.accept(builder); @@ -345,7 +345,7 @@ private Schema doCreate(SchemaContext schemaContext, SchemaLocation schemaLocati */ private SchemaContext withDialect(SchemaContext schemaContext, JsonNode schemaNode) { Dialect dialect = getDialect(schemaNode, schemaContext.getSchemaRegistryConfig()); - if (dialect != null && !dialect.getIri().equals(schemaContext.getDialect().getIri())) { + if (dialect != null && !dialect.getId().equals(schemaContext.getDialect().getId())) { return new SchemaContext(dialect, schemaContext.getSchemaRegistry(), schemaContext.getSchemaReferences(), schemaContext.getSchemaResources(), schemaContext.getDynamicAnchors()); diff --git a/src/main/java/com/networknt/schema/Vocabularies.java b/src/main/java/com/networknt/schema/Vocabularies.java index 821a92f36..0c9f33528 100644 --- a/src/main/java/com/networknt/schema/Vocabularies.java +++ b/src/main/java/com/networknt/schema/Vocabularies.java @@ -26,21 +26,21 @@ public class Vocabularies { static { Map mapping = new HashMap<>(); - mapping.put(Vocabulary.V201909_CORE.getIri(), Vocabulary.V201909_CORE); - mapping.put(Vocabulary.V201909_APPLICATOR.getIri(), Vocabulary.V201909_APPLICATOR); - mapping.put(Vocabulary.V201909_VALIDATION.getIri(), Vocabulary.V201909_VALIDATION); - mapping.put(Vocabulary.V201909_META_DATA.getIri(), Vocabulary.V201909_META_DATA); - mapping.put(Vocabulary.V201909_FORMAT.getIri(), Vocabulary.V201909_FORMAT); - mapping.put(Vocabulary.V201909_CONTENT.getIri(), Vocabulary.V201909_CONTENT); + mapping.put(Vocabulary.DRAFT_2019_09_CORE.getIri(), Vocabulary.DRAFT_2019_09_CORE); + mapping.put(Vocabulary.DRAFT_2019_09_APPLICATOR.getIri(), Vocabulary.DRAFT_2019_09_APPLICATOR); + mapping.put(Vocabulary.DRAFT_2019_09_VALIDATION.getIri(), Vocabulary.DRAFT_2019_09_VALIDATION); + mapping.put(Vocabulary.DRAFT_2019_09_META_DATA.getIri(), Vocabulary.DRAFT_2019_09_META_DATA); + mapping.put(Vocabulary.DRAFT_2019_09_FORMAT.getIri(), Vocabulary.DRAFT_2019_09_FORMAT); + mapping.put(Vocabulary.DRAFT_2019_09_CONTENT.getIri(), Vocabulary.DRAFT_2019_09_CONTENT); - mapping.put(Vocabulary.V202012_CORE.getIri(), Vocabulary.V202012_CORE); - mapping.put(Vocabulary.V202012_APPLICATOR.getIri(), Vocabulary.V202012_APPLICATOR); - mapping.put(Vocabulary.V202012_UNEVALUATED.getIri(), Vocabulary.V202012_UNEVALUATED); - mapping.put(Vocabulary.V202012_VALIDATION.getIri(), Vocabulary.V202012_VALIDATION); - mapping.put(Vocabulary.V202012_META_DATA.getIri(), Vocabulary.V202012_META_DATA); - mapping.put(Vocabulary.V202012_FORMAT_ANNOTATION.getIri(), Vocabulary.V202012_FORMAT_ANNOTATION); - mapping.put(Vocabulary.V202012_FORMAT_ASSERTION.getIri(), Vocabulary.V202012_FORMAT_ASSERTION); - mapping.put(Vocabulary.V202012_CONTENT.getIri(), Vocabulary.V202012_CONTENT); + mapping.put(Vocabulary.DRAFT_2020_12_CORE.getIri(), Vocabulary.DRAFT_2020_12_CORE); + mapping.put(Vocabulary.DRAFT_2020_12_APPLICATOR.getIri(), Vocabulary.DRAFT_2020_12_APPLICATOR); + mapping.put(Vocabulary.DRAFT_2020_12_UNEVALUATED.getIri(), Vocabulary.DRAFT_2020_12_UNEVALUATED); + mapping.put(Vocabulary.DRAFT_2020_12_VALIDATION.getIri(), Vocabulary.DRAFT_2020_12_VALIDATION); + mapping.put(Vocabulary.DRAFT_2020_12_META_DATA.getIri(), Vocabulary.DRAFT_2020_12_META_DATA); + mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION.getIri(), Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION); + mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getIri(), Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION); + mapping.put(Vocabulary.DRAFT_2020_12_CONTENT.getIri(), Vocabulary.DRAFT_2020_12_CONTENT); mapping.put(Vocabulary.OPENAPI_3_1_BASE.getIri(), Vocabulary.OPENAPI_3_1_BASE); diff --git a/src/main/java/com/networknt/schema/Vocabulary.java b/src/main/java/com/networknt/schema/Vocabulary.java index 7bc9295d1..c600ae407 100644 --- a/src/main/java/com/networknt/schema/Vocabulary.java +++ b/src/main/java/com/networknt/schema/Vocabulary.java @@ -33,12 +33,12 @@ public class Vocabulary { // 2019-09 - public static final Vocabulary V201909_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core", + public static final Vocabulary DRAFT_2019_09_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core", new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), new NonValidationKeyword("$anchor"), ValidatorTypeCode.REF, ValidatorTypeCode.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); - public static final Vocabulary V201909_APPLICATOR = new Vocabulary( + public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"), ValidatorTypeCode.UNEVALUATED_ITEMS, ValidatorTypeCode.ITEMS, ValidatorTypeCode.CONTAINS, ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.UNEVALUATED_PROPERTIES, @@ -46,7 +46,7 @@ ValidatorTypeCode.REF, ValidatorTypeCode.RECURSIVE_REF, new NonValidationKeyword ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"), new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF, ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT); - public static final Vocabulary V201909_VALIDATION = new Vocabulary( + public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/validation", ValidatorTypeCode.MULTIPLE_OF, ValidatorTypeCode.MAXIMUM, ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM, ValidatorTypeCode.EXCLUSIVE_MINIMUM, ValidatorTypeCode.MAX_LENGTH, ValidatorTypeCode.MIN_LENGTH, @@ -55,33 +55,33 @@ ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidati ValidatorTypeCode.MAX_PROPERTIES, ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED, ValidatorTypeCode.DEPENDENT_REQUIRED, ValidatorTypeCode.CONST, ValidatorTypeCode.ENUM, ValidatorTypeCode.TYPE); - public static final Vocabulary V201909_META_DATA = new Vocabulary( + public static final Vocabulary DRAFT_2019_09_META_DATA = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples")); - public static final Vocabulary V201909_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format", + public static final Vocabulary DRAFT_2019_09_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format", ValidatorTypeCode.FORMAT); - public static final Vocabulary V201909_CONTENT = new Vocabulary( + public static final Vocabulary DRAFT_2019_09_CONTENT = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/content", new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentSchema")); // 2020-12 - public static final Vocabulary V202012_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core", + public static final Vocabulary DRAFT_2020_12_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core", new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), ValidatorTypeCode.REF, new NonValidationKeyword("$anchor"), ValidatorTypeCode.DYNAMIC_REF, new NonValidationKeyword("$dynamicAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); - public static final Vocabulary V202012_APPLICATOR = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/applicator", ValidatorTypeCode.PREFIX_ITEMS, ValidatorTypeCode.ITEMS_202012, ValidatorTypeCode.CONTAINS, ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.PROPERTIES, ValidatorTypeCode.PATTERN_PROPERTIES, ValidatorTypeCode.DEPENDENT_SCHEMAS, ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"), new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF, ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT); - public static final Vocabulary V202012_UNEVALUATED = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/unevaluated", ValidatorTypeCode.UNEVALUATED_ITEMS, ValidatorTypeCode.UNEVALUATED_PROPERTIES); - public static final Vocabulary V202012_VALIDATION = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_VALIDATION = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/validation", ValidatorTypeCode.TYPE, ValidatorTypeCode.CONST, ValidatorTypeCode.ENUM, ValidatorTypeCode.MULTIPLE_OF, ValidatorTypeCode.MAXIMUM, ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM, ValidatorTypeCode.EXCLUSIVE_MINIMUM, @@ -89,15 +89,15 @@ ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidati ValidatorTypeCode.MAX_ITEMS, ValidatorTypeCode.MIN_ITEMS, ValidatorTypeCode.UNIQUE_ITEMS, ValidatorTypeCode.MAX_CONTAINS, ValidatorTypeCode.MIN_CONTAINS, ValidatorTypeCode.MAX_PROPERTIES, ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED, ValidatorTypeCode.DEPENDENT_REQUIRED); - public static final Vocabulary V202012_META_DATA = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_META_DATA = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples")); - public static final Vocabulary V202012_FORMAT_ANNOTATION = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_FORMAT_ANNOTATION = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/format-annotation", ValidatorTypeCode.FORMAT); - public static final Vocabulary V202012_FORMAT_ASSERTION = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_FORMAT_ASSERTION = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/format-assertion", ValidatorTypeCode.FORMAT); - public static final Vocabulary V202012_CONTENT = new Vocabulary( + public static final Vocabulary DRAFT_2020_12_CONTENT = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/content", new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentSchema")); diff --git a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java index c9bfe5964..0eac88636 100644 --- a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java @@ -29,7 +29,7 @@ public BasicDialectRegistry(Function dialects) { } public BasicDialectRegistry(Dialect dialect) { - this.dialects = dialectId -> dialect.getIri().equals(dialectId) ? dialect : null; + this.dialects = dialectId -> dialect.getId().equals(dialectId) ? dialect : null; } @Override diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index c8388503e..a1d728f4c 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -74,7 +74,7 @@ public interface FormatKeywordFactory { * Builder for {@link Dialect}. */ public static class Builder { - private String iri; + private String id; private String idKeyword = "$id"; private Version specification = null; private final Map keywords = new HashMap<>(); @@ -84,8 +84,8 @@ public static class Builder { private VocabularyFactory vocabularyFactory = null; private KeywordFactory unknownKeywordFactory = null; - public Builder(String iri) { - this.iri = iri; + public Builder(String id) { + this.id = id; } private Map createKeywordsMap(Map kwords, Map formats) { @@ -306,18 +306,18 @@ public Dialect build() { } else if (Boolean.TRUE.equals(entry.getValue())) { Error error = Error.builder() .message("Meta-schema ''{0}'' has unknown required vocabulary ''{1}''") - .arguments(this.iri, id).build(); + .arguments(this.id, id).build(); throw new InvalidSchemaException(error); } } } } Map result = createKeywordsMap(keywords, this.formats); - return new Dialect(this.iri, this.idKeyword, result, this.vocabularies, this.specification, this); + return new Dialect(this.id, this.idKeyword, result, this.vocabularies, this.specification, this); } } - private final String iri; + private final String id; private final String idKeyword; private final Map keywords; private final Map vocabularies; @@ -325,9 +325,9 @@ public Dialect build() { private final Builder builder; - Dialect(String iri, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { - if (StringUtils.isBlank(iri)) { - throw new IllegalArgumentException("iri must not be null or blank"); + Dialect(String dialectId, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { + if (StringUtils.isBlank(dialectId)) { + throw new IllegalArgumentException("dialect id must not be null or blank"); } if (StringUtils.isBlank(idKeyword)) { throw new IllegalArgumentException("idKeyword must not be null or blank"); @@ -336,7 +336,7 @@ public Dialect build() { throw new IllegalArgumentException("keywords must not be null "); } - this.iri = iri; + this.id = dialectId; this.idKeyword = idKeyword; this.keywords = keywords; this.specification = specification; @@ -347,37 +347,37 @@ public Dialect build() { /** * Create a builder without keywords or formats. * - * @param iri the IRI of the metaschema that will be defined via this builder. + * @param id the IRI of the dialect that will be defined via this builder. * @return a builder instance without any keywords or formats - usually not what one needs. */ - public static Builder builder(String iri) { - return new Builder(iri); + public static Builder builder(String id) { + return new Builder(id); } /** * Create a builder. * - * @param iri the IRI of your new JsonMetaSchema that will be defined via + * @param id the IRI of your new Dialect that will be defined via * this builder. - * @param blueprint the JsonMetaSchema to base your custom JsonMetaSchema on. + * @param blueprint the Dialect to base your custom Dialect on. * @return a builder instance preconfigured to be the same as blueprint, but * with a different uri. */ - public static Builder builder(String iri, Dialect blueprint) { + public static Builder builder(String id, Dialect blueprint) { Builder builder = builder(blueprint); - builder.iri = iri; + builder.id = id; return builder; } /** * Create a builder. * - * @param blueprint the JsonMetaSchema to base your custom JsonMetaSchema on. + * @param blueprint the Dialect to base your custom Dialect on. * @return a builder instance preconfigured to be the same as blueprint */ public static Builder builder(Dialect blueprint) { Map vocabularies = new HashMap<>(blueprint.getVocabularies()); - return builder(blueprint.getIri()) + return builder(blueprint.getId()) .idKeyword(blueprint.idKeyword) .keywords(blueprint.builder.keywords.values()) .formats(blueprint.builder.formats.values()) @@ -418,8 +418,8 @@ private static String readText(JsonNode node, String field) { return fieldNode == null ? null : fieldNode.textValue(); } - public String getIri() { - return this.iri; + public String getId() { + return this.id; } public Map getKeywords() { @@ -486,12 +486,12 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation @Override public String toString() { - return this.iri; + return this.id; } @Override public int hashCode() { - return Objects.hash(iri); + return id.hashCode(); } @Override @@ -503,6 +503,6 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; Dialect other = (Dialect) obj; - return Objects.equals(iri, other.iri); + return Objects.equals(id, other.id); } } diff --git a/src/main/java/com/networknt/schema/dialect/Draft201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java index 53370e146..e81291d41 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -13,8 +13,8 @@ * Draft 2019-09 dialect. */ public class Draft201909 { - private static final String IRI = DialectId.DRAFT_2019_09; - private static final String ID = "$id"; + private static final String ID = DialectId.DRAFT_2019_09; + private static final String ID_KEYWORD = "$id"; private static final Map VOCABULARY; static { @@ -31,9 +31,9 @@ public class Draft201909 { private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_2019_09) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2019_09)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/dialect/Draft202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java index c79e421d5..3c5e26eb8 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -13,8 +13,8 @@ * Draft 2020-12 dialect. */ public class Draft202012 { - private static final String IRI = DialectId.DRAFT_2020_12; - private static final String ID = "$id"; + private static final String ID = DialectId.DRAFT_2020_12; + private static final String ID_KEYWORD = "$id"; private static final Map VOCABULARY; static { @@ -32,9 +32,9 @@ public class Draft202012 { private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_2020_12) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/dialect/Draft4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java index 12fa1b6e9..d1aea21e0 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -12,15 +12,15 @@ * Draft 4 dialect. */ public class Draft4 { - private static final String IRI = DialectId.DRAFT_4; - private static final String ID = "id"; + private static final String ID = DialectId.DRAFT_4; + private static final String ID_KEYWORD = "id"; private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_4) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/dialect/Draft6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java index 3964cf362..7740a2b26 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -12,16 +12,16 @@ * Draft 6 dialect. */ public class Draft6 { - private static final String IRI = DialectId.DRAFT_6; + private static final String ID = DialectId.DRAFT_6; // Draft 6 uses "$id" - private static final String ID = "$id"; + private static final String ID_KEYWORD = "$id"; private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_6) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_6)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/dialect/Draft7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java index 2936be4b0..20c9fc0ad 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -12,15 +12,15 @@ * Draft 7 dialect. */ public class Draft7 { - private static final String IRI = DialectId.DRAFT_7; - private static final String ID = "$id"; + private static final String ID = DialectId.DRAFT_7; + private static final String ID_KEYWORD = "$id"; private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_7) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_7)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index 13677893d..f77936226 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -12,15 +12,15 @@ * OpenAPI 3.0. */ public class OpenApi30 { - private static final String IRI = DialectId.OPENAPI_3_0; - private static final String ID = "id"; + private static final String ID = DialectId.OPENAPI_3_0; + private static final String ID_KEYWORD = "id"; private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_4) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(Arrays.asList( new AnnotationKeyword("title"), diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java index 652513c7d..e9e28b74b 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -13,8 +13,8 @@ * OpenAPI 3.1. */ public class OpenApi31 { - private static final String IRI = DialectId.OPENAPI_3_1; - private static final String ID = "$id"; + private static final String ID = DialectId.OPENAPI_3_1; + private static final String ID_KEYWORD = "$id"; private static final Map VOCABULARY; static { @@ -33,9 +33,9 @@ public class OpenApi31 { private static class Holder { private static final Dialect INSTANCE; static { - INSTANCE = Dialect.builder(IRI) + INSTANCE = Dialect.builder(ID) .specification(Specification.Version.DRAFT_2020_12) - .idKeyword(ID) + .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 91ec128bc..23eab3c0c 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ErrorMessages; -import com.networknt.schema.JsonNodePath; import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index cc9d32ff7..68624c901 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -38,13 +38,12 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { private final Schema schema; private final boolean isMinV202012; - private static final Version DEFAULT_VERSION = Version.DRAFT_2019_09; public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); - isMinV202012 = MinV202012.getVersions().contains(schemaContext.activeDialect().orElse(DEFAULT_VERSION)); + isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecification()); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 5aed89d90..b1b14fc41 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -120,7 +120,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch } private static long detectVersion(SchemaContext schemaContext) { - return schemaContext.activeDialect().orElse(Version.DRAFT_4).getOrder(); + return schemaContext.getDialect().getSpecification().getOrder(); } /** diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 1a92da300..da1780c62 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -40,13 +40,13 @@ void exampleSchemaLocation() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getId()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 Schema refSchema = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getId()); } @Test @@ -62,12 +62,12 @@ void exampleClasspath() { + " }\r\n" + "}"; // The example-main.json schema defines $schema with Draft 07 - assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_7, schema.getSchemaContext().getDialect().getId()); List assertions = schema.validate(input, InputFormat.JSON); assertEquals(1, assertions.size()); // The example-ref.json schema defines $schema with Draft 2019-09 Schema refSchema = schema.getSchemaContext().getSchemaResources().get("classpath:schema/example-ref.json#"); - assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_2019_09, refSchema.getSchemaContext().getDialect().getId()); } } diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index d80b686b4..8fab5b129 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -20,7 +20,7 @@ class Issue471Test { @Test @Disabled - void shouldFailV201909_with_enUS() throws Exception { + void shouldFailDRAFT_2019_09_with_enUS() throws Exception { Locale.setDefault(Locale.US); Map errorsMap = validate(); Assertions.assertEquals("$.title: may only be 10 characters long", errorsMap.get("$.title")); @@ -29,7 +29,7 @@ void shouldFailV201909_with_enUS() throws Exception { @Test @Disabled - void shouldFailV201909_with_zhCN() throws Exception { + void shouldFailDRAFT_2019_09_with_zhCN() throws Exception { Locale.setDefault(Locale.CHINA); Map errorsMap = validate(); Assertions.assertEquals("$.title:å¯èƒ½åªæœ‰ 10 个字符长", errorsMap.get("$.title")); @@ -38,7 +38,7 @@ void shouldFailV201909_with_zhCN() throws Exception { @Test @Disabled - void shouldFailV201909_with_deDE() throws Exception { + void shouldFailDRAFT_2019_09_with_deDE() throws Exception { Locale.setDefault(Locale.GERMANY); Map errorsMap = validate(); Assertions.assertEquals("$.title darf höchstens 10 Zeichen lang sein", errorsMap.get("$.title")); @@ -47,7 +47,7 @@ void shouldFailV201909_with_deDE() throws Exception { @Test @Disabled - void shouldFailV201909_with_frFR() throws Exception { + void shouldFailDRAFT_2019_09_with_frFR() throws Exception { Locale.setDefault(Locale.FRANCE); Map errorsMap = validate(); Assertions.assertEquals("$.title: ne doit pas dépasser 10 caractères", errorsMap.get("$.title")); @@ -56,7 +56,7 @@ void shouldFailV201909_with_frFR() throws Exception { @Test @Disabled - void shouldFailV201909_with_frIT() throws Exception { + void shouldFailDRAFT_2019_09_with_frIT() throws Exception { Locale.setDefault(Locale.ITALIAN); Map errorsMap = validate(); Assertions.assertEquals("$.title: può avere lunghezza massima di 10", errorsMap.get("$.title")); diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 242bad787..e38e2b999 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -64,7 +64,7 @@ private List validate(Schema jsonSchema, String myDateTimeContent) throws private Schema createSchema(boolean useCustomDateFormat) { Dialect overrideDateTimeValidator = Dialect - .builder(Dialects.getDraft7().getIri(), Dialects.getDraft7()) + .builder(Dialects.getDraft7().getId(), Dialects.getDraft7()) .formats(formats -> { if (useCustomDateFormat) { CustomDateTimeFormat format = new CustomDateTimeFormat(); diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 4cff7303b..662b66d91 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -19,7 +19,7 @@ void validate() throws JsonProcessingException { .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() - .getSchema(SchemaLocation.of(Dialects.getDraft201909().getIri())); + .getSchema(SchemaLocation.of(Dialects.getDraft201909().getId())); final JsonNode invalidSchema = new ObjectMapper().readTree( "{"+ " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\","+ diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 53b18b0cd..bf152f347 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -37,7 +37,7 @@ private SchemaRegistry buildV7PlusNoFormatSchemaFactory() { formats.add(new NoMatchFormat()); Dialect dialect = Dialect.builder( - Dialects.getDraft7().getIri(), + Dialects.getDraft7().getId(), Dialects.getDraft7()) .formats(formats) .build(); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index 0a3313f70..4fc1d23dd 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -43,7 +43,7 @@ void test() throws JsonProcessingException { + " }\r\n" + "}"; Dialect dialect = Dialect.builder(Dialects.getDraft202012()).vocabularies(vocabularies -> { - vocabularies.remove(Vocabulary.V202012_VALIDATION.getIri()); + vocabularies.remove(Vocabulary.DRAFT_2020_12_VALIDATION.getIri()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); Schema schema = SchemaRegistry diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index ee1ecd41f..5ad5b5846 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -70,7 +70,7 @@ public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath eva @Test void message() { - Dialect dialect = Dialect.builder(Dialects.getDraft202012().getIri(), Dialects.getDraft202012()) + Dialect dialect = Dialect.builder(Dialects.getDraft202012().getId(), Dialects.getDraft202012()) .keyword(new EqualsKeyword()).build(); SchemaRegistry factory = SchemaRegistry.withDialect(dialect); String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 2b206767a..7bde6509e 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -25,7 +25,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getId()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -47,7 +47,7 @@ void shouldLoadSchemaResource() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_4, schema.getSchemaContext().getDialect().getId()); List errors = schema.validate(OBJECT_MAPPER.readTree(input)); assertEquals(1, errors.size()); Error error = errors.iterator().next(); @@ -58,8 +58,8 @@ void shouldLoadSchemaResource() throws JsonProcessingException { assertEquals("field1", error.getProperty()); Schema driver = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/driver#"); Schema common = schema.getSchemaContext().getSchemaResources().get("https://www.example.org/common#"); - assertEquals(DialectId.DRAFT_4, driver.getSchemaContext().getDialect().getIri()); - assertEquals(DialectId.DRAFT_7, common.getSchemaContext().getDialect().getIri()); + assertEquals(DialectId.DRAFT_4, driver.getSchemaContext().getDialect().getId()); + assertEquals(DialectId.DRAFT_7, common.getSchemaContext().getDialect().getId()); } } diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 0104387a7..aab1adce0 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -52,7 +52,7 @@ void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); Dialect draftV4 = Dialects.getDraft4(); Builder builder = SchemaRegistry.builder() - .defaultDialectId(draftV4.getIri()) + .defaultDialectId(draftV4.getId()) .dialectRegistry(new BasicDialectRegistry(draftV4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); SchemaRegistry instance = builder.build(); @@ -103,7 +103,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); Dialect draftV4 = Dialects.getDraft4(); Builder builder = SchemaRegistry.builder() - .defaultDialectId(draftV4.getIri()) + .defaultDialectId(draftV4.getId()) .dialectRegistry(new BasicDialectRegistry(draftV4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); instance = builder.build(); diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 78b533cb9..4b907548e 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -31,7 +31,7 @@ void testURNToURI() throws Exception { is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); Dialect draftV7 = Dialects.getDraft7(); SchemaRegistry.Builder builder = SchemaRegistry.builder() - .defaultDialectId(draftV7.getIri()) + .defaultDialectId(draftV7.getId()) .dialectRegistry(new BasicDialectRegistry(draftV7)) .schemaMappers(schemaMappers -> schemaMappers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) ); diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 8d79b710f..0f2a4563c 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -81,12 +81,12 @@ void noValidation() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/validation", - Vocabulary.V202012_VALIDATION.getIri()))))) + Vocabulary.DRAFT_2020_12_VALIDATION.getIri()))))) .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("minimum", messages.iterator().next().getKeyword()); - assertEquals(Version.DRAFT_2020_12, schema.getSchemaContext().activeDialect().get()); + assertEquals(Version.DRAFT_2020_12, schema.getSchemaContext().getDialect().getSpecification()); } @Test @@ -134,7 +134,7 @@ void noFormatValidation() { builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/format", - Vocabulary.V202012_FORMAT_ASSERTION.getIri()))))) + Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getIri()))))) .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); From dd09cd5a45d5f4f69a805928d4ece5c7185f4b96 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:07:26 +0800 Subject: [PATCH 30/74] Rename Specification.Version to SpecificationVersion and refactor --- .../java/com/networknt/schema/Schema.java | 5 +- .../com/networknt/schema/SchemaContext.java | 2 - .../com/networknt/schema/SchemaRegistry.java | 9 +- .../com/networknt/schema/Specification.java | 89 +++--------------- .../schema/SpecificationVersion.java | 93 +++++++++++++++++++ .../schema/SpecificationVersionDetector.java | 25 +++-- .../dialect/DefaultDialectRegistry.java | 6 +- .../com/networknt/schema/dialect/Dialect.java | 31 +++---- .../networknt/schema/dialect/Draft201909.java | 6 +- .../networknt/schema/dialect/Draft202012.java | 6 +- .../com/networknt/schema/dialect/Draft4.java | 6 +- .../com/networknt/schema/dialect/Draft6.java | 6 +- .../com/networknt/schema/dialect/Draft7.java | 6 +- .../networknt/schema/dialect/OpenApi30.java | 4 +- .../networknt/schema/dialect/OpenApi31.java | 6 +- .../schema/format/BaseFormatValidator.java | 14 +-- .../schema/keyword/ContainsValidator.java | 2 +- .../keyword/UnevaluatedItemsValidator.java | 3 +- .../schema/keyword/ValidatorTypeCode.java | 39 ++++---- .../networknt/schema/utils/JsonNodeUtil.java | 6 +- .../schema/AbstractJsonSchemaTest.java | 2 +- .../schema/AbstractJsonSchemaTestSuite.java | 13 ++- .../AdditionalPropertiesValidatorTest.java | 6 +- .../networknt/schema/AllOfValidatorTest.java | 6 +- .../networknt/schema/AnyOfValidatorTest.java | 6 +- .../schema/BaseJsonSchemaValidatorTest.java | 12 +-- .../networknt/schema/ConstValidatorTest.java | 11 +-- .../schema/ContentSchemaValidatorTest.java | 3 +- .../networknt/schema/CustomMessageTest.java | 6 +- .../com/networknt/schema/CustomUriTest.java | 2 +- .../schema/CyclicDependencyTest.java | 2 +- .../com/networknt/schema/DateTimeDSTTest.java | 2 +- .../DefaultJsonSchemaIdValidatorTest.java | 12 +-- .../schema/DependentRequiredTest.java | 2 +- .../schema/DurationFormatValidatorTest.java | 2 +- .../networknt/schema/EnumValidatorTest.java | 6 +- .../networknt/schema/ErrorHandlerTest.java | 6 +- .../com/networknt/schema/ExampleTest.java | 5 +- .../networknt/schema/FormatValidatorTest.java | 13 ++- .../com/networknt/schema/IfValidatorTest.java | 9 +- .../com/networknt/schema/Issue1091Test.java | 3 +- .../com/networknt/schema/Issue255Test.java | 2 +- .../com/networknt/schema/Issue285Test.java | 2 +- .../com/networknt/schema/Issue295Test.java | 2 +- .../com/networknt/schema/Issue313Test.java | 4 +- .../com/networknt/schema/Issue327Test.java | 2 +- .../com/networknt/schema/Issue342Test.java | 2 +- .../com/networknt/schema/Issue347Test.java | 2 +- .../schema/Issue366FailFastTest.java | 2 +- .../schema/Issue366FailSlowTest.java | 2 +- .../com/networknt/schema/Issue375Test.java | 3 +- .../com/networknt/schema/Issue383Test.java | 2 +- .../com/networknt/schema/Issue396Test.java | 2 +- .../com/networknt/schema/Issue404Test.java | 2 +- .../com/networknt/schema/Issue406Test.java | 6 +- .../com/networknt/schema/Issue426Test.java | 2 +- .../com/networknt/schema/Issue428Test.java | 2 +- .../com/networknt/schema/Issue451Test.java | 2 +- .../com/networknt/schema/Issue456Test.java | 2 +- .../com/networknt/schema/Issue461Test.java | 2 +- .../com/networknt/schema/Issue467Test.java | 4 +- .../com/networknt/schema/Issue471Test.java | 2 +- .../com/networknt/schema/Issue475Test.java | 11 +-- .../com/networknt/schema/Issue493Test.java | 2 +- .../com/networknt/schema/Issue532Test.java | 2 +- .../com/networknt/schema/Issue550Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 2 +- .../com/networknt/schema/Issue604Test.java | 2 +- .../com/networknt/schema/Issue606Test.java | 2 +- .../com/networknt/schema/Issue619Test.java | 2 +- .../com/networknt/schema/Issue650Test.java | 2 +- .../com/networknt/schema/Issue662Test.java | 2 +- .../com/networknt/schema/Issue664Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 4 +- .../com/networknt/schema/Issue668Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 4 +- .../com/networknt/schema/Issue724Test.java | 3 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue857Test.java | 4 +- .../com/networknt/schema/Issue877Test.java | 3 +- .../com/networknt/schema/Issue898Test.java | 2 +- .../com/networknt/schema/Issue927Test.java | 3 +- .../com/networknt/schema/Issue928Test.java | 10 +- .../com/networknt/schema/Issue935Test.java | 4 +- .../com/networknt/schema/Issue936Test.java | 6 +- .../com/networknt/schema/Issue939Test.java | 4 +- .../com/networknt/schema/Issue940Test.java | 4 +- .../com/networknt/schema/Issue943Test.java | 4 +- .../schema/ItemsValidator202012Test.java | 7 +- .../networknt/schema/ItemsValidatorTest.java | 17 ++-- .../schema/JsonSchemaFactoryUriCacheTest.java | 2 +- .../schema/JsonSchemaPreloadTest.java | 6 +- .../schema/JsonSchemaTestSuiteExtrasTest.java | 12 +-- .../schema/JsonSchemaTestSuiteTest.java | 12 +-- .../schema/JsonWalkApplyDefaultsTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 2 +- .../java/com/networknt/schema/LocaleTest.java | 9 +- .../schema/MaximumValidatorTest.java | 6 +- .../schema/MetaSchemaValidationTest.java | 3 +- .../schema/MinimumValidatorTest.java | 6 +- .../schema/MultipleOfValidatorTest.java | 8 +- .../networknt/schema/NotValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 13 ++- .../networknt/schema/OutputFormatTest.java | 5 +- .../com/networknt/schema/OutputUnitTest.java | 21 ++--- .../OverwritingCustomMessageBugTest.java | 3 +- .../PatternPropertiesValidatorTest.java | 9 +- .../schema/PatternValidatorTest.java | 4 +- .../schema/PrefixItemsValidatorTest.java | 13 ++- .../com/networknt/schema/PropertiesTest.java | 4 +- .../schema/PropertiesValidatorTest.java | 2 +- .../schema/PropertyNamesValidatorTest.java | 4 +- .../schema/ReadOnlyValidatorTest.java | 2 +- ...ursiveReferenceValidatorExceptionTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 4 +- .../networknt/schema/RefValidatorTest.java | 14 ++- .../schema/RequiredValidatorTest.java | 10 +- .../java/com/networknt/schema/SampleTest.java | 11 +-- .../networknt/schema/SchemaLocationTest.java | 4 +- .../networknt/schema/SchemaRegistryTest.java | 3 +- .../java/com/networknt/schema/SchemaTest.java | 4 +- .../networknt/schema/SharedConfigTest.java | 2 +- .../SpecificationVersionDetectorTest.java | 6 +- .../networknt/schema/TypeValidatorTest.java | 14 ++- .../schema/UnevaluatedItemsTest.java | 3 +- .../schema/UnevaluatedItemsValidatorTest.java | 6 +- .../schema/UnevaluatedPropertiesTest.java | 4 +- .../UnevaluatedPropertiesValidatorTest.java | 11 +-- .../schema/UnknownMetaSchemaTest.java | 6 +- .../com/networknt/schema/UriMappingTest.java | 10 +- .../networknt/schema/V4JsonSchemaTest.java | 4 +- .../schema/ValidatorTypeCodeTest.java | 4 +- .../com/networknt/schema/VocabularyTest.java | 5 +- .../benchmark/NetworkntBasicRunner.java | 4 +- .../NetworkntTestSuite202012OptionalPerf.java | 4 +- .../NetworkntTestSuite202012RequiredPerf.java | 4 +- .../NetworkntTestSuiteOptionalBenchmark.java | 12 +-- .../NetworkntTestSuiteRequiredBenchmark.java | 12 +-- .../NetworkntTestSuiteTestCases.java | 6 +- .../schema/format/IriFormatTest.java | 16 ++-- .../schema/format/IriReferenceFormatTest.java | 16 ++-- .../schema/format/TimeFormatTest.java | 6 +- .../schema/format/UriFormatTest.java | 16 ++-- .../schema/format/UriReferenceFormatTest.java | 16 ++-- .../networknt/schema/oas/OpenApi31Test.java | 4 +- .../resource/AllowSchemaLoaderTest.java | 4 +- .../resource/DisallowSchemaLoaderTest.java | 4 +- .../networknt/schema/utils/JsonNodesTest.java | 6 +- .../schema/walk/WalkListenerTest.java | 26 +++--- 151 files changed, 516 insertions(+), 579 deletions(-) create mode 100644 src/main/java/com/networknt/schema/SpecificationVersion.java diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 9e41daec3..7eed958ec 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -31,7 +31,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; @@ -51,7 +50,7 @@ * modified. */ public class Schema implements Validator { - private static final long DRAFT_2019_09_VALUE = Version.DRAFT_2019_09.getOrder(); + private static final long DRAFT_2019_09_VALUE = SpecificationVersion.DRAFT_2019_09.getOrder(); private final String id; /** @@ -656,7 +655,7 @@ private List read(JsonNode schemaNode) { } // Ignore siblings for older drafts - if (null != refValidator && getSchemaContext().getDialect().getSpecification().getOrder() < DRAFT_2019_09_VALUE) { + if (null != refValidator && getSchemaContext().getDialect().getSpecificationVersion().getOrder() < DRAFT_2019_09_VALUE) { validators.clear(); validators.add(refValidator); } diff --git a/src/main/java/com/networknt/schema/SchemaContext.java b/src/main/java/com/networknt/schema/SchemaContext.java index 1dbd8b714..53539a3a0 100644 --- a/src/main/java/com/networknt/schema/SchemaContext.java +++ b/src/main/java/com/networknt/schema/SchemaContext.java @@ -16,12 +16,10 @@ package com.networknt.schema; -import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.keyword.KeywordValidator; diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 8c2402f33..9bd7e1854 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -17,7 +17,6 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.DefaultDialectRegistry; import com.networknt.schema.dialect.Dialect; @@ -174,7 +173,7 @@ public SchemaLoader getSchemaLoader() { * Builder without keywords or formats. *

* Typically {@link #builder(SchemaRegistry)} or - * {@link #withDefaultDialect(Version)} or {@link #withDialect(Dialect)} would be used instead. + * {@link #withDefaultDialect(SpecificationVersion)} or {@link #withDialect(Dialect)} would be used instead. * * @return a builder instance without any keywords or formats - usually not what * one needs. @@ -192,7 +191,7 @@ public static Builder builder() { * not specify the $schema keyword * @return the factory */ - public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion) { + public static SchemaRegistry withDefaultDialect(SpecificationVersion specificationVersion) { return withDefaultDialect(specificationVersion, null); } @@ -206,7 +205,7 @@ public static SchemaRegistry withDefaultDialect(Specification.Version specificat * @param customizer to customize the registry * @return the factory */ - public static SchemaRegistry withDefaultDialect(Specification.Version specificationVersion, + public static SchemaRegistry withDefaultDialect(SpecificationVersion specificationVersion, Consumer customizer) { Dialect dialect = Specification.getDialect(specificationVersion); return withDefaultDialectId(dialect.getId(), customizer); @@ -628,7 +627,7 @@ private boolean isYaml(final SchemaLocation schemaUri) { */ static protected String normalizeDialectId(String id) { boolean found = false; - for (Version flag : Specification.Version.values()) { + for (SpecificationVersion flag : SpecificationVersion.values()) { if(flag.getDialectId().equals(id)) { found = true; break; diff --git a/src/main/java/com/networknt/schema/Specification.java b/src/main/java/com/networknt/schema/Specification.java index 05f68a444..67cd6a61d 100644 --- a/src/main/java/com/networknt/schema/Specification.java +++ b/src/main/java/com/networknt/schema/Specification.java @@ -15,96 +15,26 @@ */ package com.networknt.schema; -import java.util.Optional; - import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.dialect.Dialects; /** - * The JSON Schema specification which defines the standard dialects. + * The version of the JSON Schema specification that defines the standard + * dialects. */ public class Specification { /** - * The JSON Schema specification version. - */ - public enum Version { - /** - * Draft 4. - */ - DRAFT_4(4, DialectId.DRAFT_4), - /** - * Draft 6. - */ - DRAFT_6(6, DialectId.DRAFT_6), - /** - * Draft 7. - */ - DRAFT_7(7, DialectId.DRAFT_7), - /** - * Draft 2019-09. - */ - DRAFT_2019_09(8, DialectId.DRAFT_2019_09), - /** - * Draft 2020-12. - */ - DRAFT_2020_12(9, DialectId.DRAFT_2020_12); - - private final int order; - private final String dialectId; - - Version(int order, String dialectId) { - this.order = order; - this.dialectId = dialectId; - } - - /** - * Gets the dialect id used for the $schema keyword. The dialect id is an IRI - * that identifies the meta schema used to validate the dialect. - * - * @return the dialect id - */ - public String getDialectId() { - return this.dialectId; - } - - /** - * Gets the unique release order of the specification version used that - * indicates when the specification was released. Lower numbers indicate the - * specification was released earlier. - * - * @return the order when the specification was released - */ - public int getOrder() { - return this.order; - } - - /** - * Gets the specification version that matches the dialect id indicated by - * $schema keyword. The dialect id is an IRI that identifies the meta schema - * used to validate the dialect. - * - * @param dialectId the dialect id specified by $schema keyword - * @return the specification version if it matches the dialect id - */ - public static Optional fromDialectId(String dialectId) { - for (Version version : Version.values()) { - if (version.dialectId.equals(dialectId)) { - return Optional.of(version); - } - } - return Optional.empty(); - } - } - - /** - * Gets the dialect given the specification version. + * Gets the standard dialect given the specification version. + *

+ * This should only be used if the standard dialect is required, otherwise the + * dialect should be retrieved from the dialect registry. * * @param version the schema specification version * @return the dialect or null if not found */ - public static Dialect getDialect(Specification.Version version) { + public static Dialect getDialect(SpecificationVersion version) { if (null == version) { return null; } @@ -125,7 +55,10 @@ public static Dialect getDialect(Specification.Version version) { } /** - * Gets the dialect given the dialect id. + * Gets the standard dialect given the dialect id. + *

+ * This should only be used if the standard dialect is required, otherwise the + * dialect should be retrieved from the dialect registry. * * @param dialectId the schema specification version * @return the dialect or null if not found diff --git a/src/main/java/com/networknt/schema/SpecificationVersion.java b/src/main/java/com/networknt/schema/SpecificationVersion.java new file mode 100644 index 000000000..33bd3752e --- /dev/null +++ b/src/main/java/com/networknt/schema/SpecificationVersion.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import java.util.Optional; + +import com.networknt.schema.dialect.DialectId; + +/** + * The version of the JSON Schema specification that defines the standard + * dialects. + */ +public enum SpecificationVersion { + /** + * Draft 4. + */ + DRAFT_4(4, DialectId.DRAFT_4), + /** + * Draft 6. + */ + DRAFT_6(6, DialectId.DRAFT_6), + /** + * Draft 7. + */ + DRAFT_7(7, DialectId.DRAFT_7), + /** + * Draft 2019-09. + */ + DRAFT_2019_09(8, DialectId.DRAFT_2019_09), + /** + * Draft 2020-12. + */ + DRAFT_2020_12(9, DialectId.DRAFT_2020_12); + + private final int order; + private final String dialectId; + + SpecificationVersion(int order, String dialectId) { + this.order = order; + this.dialectId = dialectId; + } + + /** + * Gets the dialect id used for the $schema keyword. The dialect id is an IRI + * that identifies the meta schema used to validate the dialect. + * + * @return the dialect id + */ + public String getDialectId() { + return this.dialectId; + } + + /** + * Gets the unique release order of the specification version used that + * indicates when the specification was released. Lower numbers indicate the + * specification was released earlier. + * + * @return the order when the specification was released + */ + public int getOrder() { + return this.order; + } + + /** + * Gets the specification version that matches the dialect id indicated by + * $schema keyword. The dialect id is an IRI that identifies the meta schema + * used to validate the dialect. + * + * @param dialectId the dialect id specified by $schema keyword + * @return the specification version if it matches the dialect id + */ + public static Optional fromDialectId(String dialectId) { + for (SpecificationVersion version : SpecificationVersion.values()) { + if (version.dialectId.equals(dialectId)) { + return Optional.of(version); + } + } + return Optional.empty(); + } +} diff --git a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java index 92731c396..73c89678f 100644 --- a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionDetector.java @@ -17,7 +17,6 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import java.nio.file.Path; import java.util.HashMap; @@ -35,15 +34,15 @@ */ public final class SpecificationVersionDetector { - private static final Map supportedVersions = new HashMap<>(); + private static final Map supportedVersions = new HashMap<>(); private static final String SCHEMA_TAG = "$schema"; static { - supportedVersions.put("draft2019-09", Version.DRAFT_2019_09); - supportedVersions.put("draft2020-12", Version.DRAFT_2020_12); - supportedVersions.put("draft4", Version.DRAFT_4); - supportedVersions.put("draft6", Version.DRAFT_6); - supportedVersions.put("draft7", Version.DRAFT_7); + supportedVersions.put("draft2019-09", SpecificationVersion.DRAFT_2019_09); + supportedVersions.put("draft2020-12", SpecificationVersion.DRAFT_2020_12); + supportedVersions.put("draft4", SpecificationVersion.DRAFT_4); + supportedVersions.put("draft6", SpecificationVersion.DRAFT_6); + supportedVersions.put("draft7", SpecificationVersion.DRAFT_7); } private SpecificationVersionDetector() { @@ -57,7 +56,7 @@ private SpecificationVersionDetector() { * @param jsonNode JSON Node to read from * @return Spec version if present, otherwise throws an exception */ - public static Version detect(JsonNode jsonNode) { + public static SpecificationVersion detect(JsonNode jsonNode) { return detectOptionalVersion(jsonNode, true).orElseThrow( () -> new SchemaException("'" + SCHEMA_TAG + "' tag is not present") ); @@ -71,17 +70,17 @@ public static Version detect(JsonNode jsonNode) { * @param throwIfUnsupported whether to throw an exception if the version is not supported * @return Spec version if present, otherwise empty */ - public static Optional detectOptionalVersion(JsonNode jsonNode, boolean throwIfUnsupported) { + public static Optional detectOptionalVersion(JsonNode jsonNode, boolean throwIfUnsupported) { return Optional.ofNullable(jsonNode.get(SCHEMA_TAG)).map(schemaTag -> { String schemaTagValue = schemaTag.asText(); String schemaUri = SchemaRegistry.normalizeDialectId(schemaTagValue); if (throwIfUnsupported) { - return Version.fromDialectId(schemaUri) + return SpecificationVersion.fromDialectId(schemaUri) .orElseThrow(() -> new SchemaException("'" + schemaTagValue + "' is unrecognizable schema")); } else { - return Version.fromDialectId(schemaUri).orElse(null); + return SpecificationVersion.fromDialectId(schemaUri).orElse(null); } }); } @@ -89,7 +88,7 @@ public static Optional detectOptionalVersion(JsonNode jsonNode, boolean // For 2019-09 and later published drafts, implementations that are able to // detect the draft of each schema via $schema SHOULD be configured to do so - public static Version detectVersion(JsonNode jsonNode, Path specification, Version defaultVersion, boolean throwIfUnsupported) { + public static SpecificationVersion detectVersion(JsonNode jsonNode, Path specification, SpecificationVersion defaultVersion, boolean throwIfUnsupported) { return Stream.of( detectOptionalVersion(jsonNode, throwIfUnsupported), detectVersionFromPath(specification) @@ -103,7 +102,7 @@ public static Version detectVersion(JsonNode jsonNode, Path specification, Versi // For draft-07 and earlier, draft-next, and implementations unable to // detect via $schema, implementations MUST be configured to expect the // draft matching the test directory name - public static Optional detectVersionFromPath(Path path) { + public static Optional detectVersionFromPath(Path path) { return StreamSupport.stream(path.spliterator(), false) .map(Path::toString) .map(supportedVersions::get) diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index 4ce716e75..021cf5709 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -27,7 +27,7 @@ import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; /** * Default {@link DialectRegistry}. @@ -60,9 +60,9 @@ protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory) { protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory) { Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri)); Dialect.Builder builder = Dialect.builder(iri, schema.getSchemaContext().getDialect()); - Version specification = schema.getSchemaContext().getDialect().getSpecification(); + SpecificationVersion specification = schema.getSchemaContext().getDialect().getSpecificationVersion(); if (specification != null) { - if (specification.getOrder() >= Version.DRAFT_2019_09.getOrder()) { + if (specification.getOrder() >= SpecificationVersion.DRAFT_2019_09.getOrder()) { // Process vocabularies JsonNode vocabulary = schema.getSchemaNode().get("$vocabulary"); if (vocabulary != null) { diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index a1d728f4c..df3d230f8 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -24,12 +24,11 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification; import com.networknt.schema.SchemaContext; import com.networknt.schema.Vocabularies; import com.networknt.schema.Vocabulary; import com.networknt.schema.VocabularyFactory; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordFactory; @@ -76,7 +75,7 @@ public interface FormatKeywordFactory { public static class Builder { private String id; private String idKeyword = "$id"; - private Version specification = null; + private SpecificationVersion specificationVersion = null; private final Map keywords = new HashMap<>(); private final Map formats = new HashMap<>(); private final Map vocabularies = new HashMap<>(); @@ -263,13 +262,13 @@ public Builder vocabularies(Consumer> customizer) { } /** - * Sets the specification. + * Sets the specification version. * - * @param specification the specification + * @param specification the specification version * @return the builder */ - public Builder specification(Version specification) { - this.specification = specification; + public Builder specificationVersion(SpecificationVersion specification) { + this.specificationVersion = specification; return this; } @@ -287,8 +286,8 @@ public Builder idKeyword(String idKeyword) { public Dialect build() { // create builtin keywords with (custom) formats. Map keywords = this.keywords; - if (this.specification != null) { - if (this.specification.getOrder() >= Specification.Version.DRAFT_2019_09.getOrder()) { + if (this.specificationVersion != null) { + if (this.specificationVersion.getOrder() >= SpecificationVersion.DRAFT_2019_09.getOrder()) { keywords = new HashMap<>(this.keywords); for(Entry entry : this.vocabularies.entrySet()) { Vocabulary vocabulary = null; @@ -313,7 +312,7 @@ public Dialect build() { } } Map result = createKeywordsMap(keywords, this.formats); - return new Dialect(this.id, this.idKeyword, result, this.vocabularies, this.specification, this); + return new Dialect(this.id, this.idKeyword, result, this.vocabularies, this.specificationVersion, this); } } @@ -321,11 +320,11 @@ public Dialect build() { private final String idKeyword; private final Map keywords; private final Map vocabularies; - private final Version specification; + private final SpecificationVersion specificationVersion; private final Builder builder; - Dialect(String dialectId, String idKeyword, Map keywords, Map vocabularies, Version specification, Builder builder) { + Dialect(String dialectId, String idKeyword, Map keywords, Map vocabularies, SpecificationVersion specification, Builder builder) { if (StringUtils.isBlank(dialectId)) { throw new IllegalArgumentException("dialect id must not be null or blank"); } @@ -339,7 +338,7 @@ public Dialect build() { this.id = dialectId; this.idKeyword = idKeyword; this.keywords = keywords; - this.specification = specification; + this.specificationVersion = specification; this.vocabularies = vocabularies; this.builder = builder; } @@ -381,7 +380,7 @@ public static Builder builder(Dialect blueprint) { .idKeyword(blueprint.idKeyword) .keywords(blueprint.builder.keywords.values()) .formats(blueprint.builder.formats.values()) - .specification(blueprint.getSpecification()) + .specificationVersion(blueprint.getSpecificationVersion()) .vocabularies(vocabularies) .vocabularyFactory(blueprint.builder.vocabularyFactory) .formatKeywordFactory(blueprint.builder.formatKeywordFactory) @@ -430,8 +429,8 @@ public Map getVocabularies() { return this.vocabularies; } - public Version getSpecification() { - return this.specification; + public SpecificationVersion getSpecificationVersion() { + return this.specificationVersion; } /** diff --git a/src/main/java/com/networknt/schema/dialect/Draft201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java index e81291d41..a71800f13 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -5,7 +5,7 @@ import java.util.Map; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -32,10 +32,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_2019_09) + .specificationVersion(SpecificationVersion.DRAFT_2019_09) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2019_09)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2019_09)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java index 3c5e26eb8..7cfa0cebf 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -5,7 +5,7 @@ import java.util.Map; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -33,10 +33,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_2020_12) + .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java index d1aea21e0..0703a2903 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -3,7 +3,7 @@ import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -19,10 +19,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_4) + .specificationVersion(SpecificationVersion.DRAFT_4) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java index 7740a2b26..fbdab7225 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -3,7 +3,7 @@ import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -20,10 +20,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_6) + .specificationVersion(SpecificationVersion.DRAFT_6) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_6)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_6)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java index 20c9fc0ad..d26cbb82d 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -3,7 +3,7 @@ import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -19,10 +19,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_7) + .specificationVersion(SpecificationVersion.DRAFT_7) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_7)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_7)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index f77936226..74bea5f8b 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -3,7 +3,7 @@ import java.util.Arrays; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -19,7 +19,7 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_4) + .specificationVersion(SpecificationVersion.DRAFT_4) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) .keywords(Arrays.asList( diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java index e9e28b74b..d3442f554 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -5,7 +5,7 @@ import java.util.Map; import com.networknt.schema.Formats; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.ValidatorTypeCode; @@ -34,10 +34,10 @@ private static class Holder { private static final Dialect INSTANCE; static { INSTANCE = Dialect.builder(ID) - .specification(Specification.Version.DRAFT_2020_12) + .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_2020_12)) + .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/format/BaseFormatValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java index cc7c3596c..ae79b1f57 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java @@ -8,7 +8,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; @@ -19,8 +19,8 @@ public BaseFormatValidator(SchemaLocation schemaLocation, NodePath evaluationPat Schema parentSchema, Keyword keyword, SchemaContext schemaContext) { super(keyword, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); - Version dialect = this.schemaContext.getDialect().getSpecification(); - if (dialect == null || dialect.getOrder() < Version.DRAFT_2019_09.getOrder()) { + SpecificationVersion dialect = this.schemaContext.getDialect().getSpecificationVersion(); + if (dialect == null || dialect.getOrder() < SpecificationVersion.DRAFT_2019_09.getOrder()) { assertionsEnabled = true; } else { // Check vocabulary @@ -30,15 +30,15 @@ public BaseFormatValidator(SchemaLocation schemaLocation, NodePath evaluationPat } protected boolean isFormatAssertionVocabularyEnabled() { - return isFormatAssertionVocabularyEnabled(this.schemaContext.getDialect().getSpecification(), + return isFormatAssertionVocabularyEnabled(this.schemaContext.getDialect().getSpecificationVersion(), this.schemaContext.getDialect().getVocabularies()); } - protected boolean isFormatAssertionVocabularyEnabled(Version specification, Map vocabularies) { - if (Version.DRAFT_2020_12.equals(specification)) { + protected boolean isFormatAssertionVocabularyEnabled(SpecificationVersion specification, Map vocabularies) { + if (SpecificationVersion.DRAFT_2020_12.equals(specification)) { String vocabulary = "https://json-schema.org/draft/2020-12/vocab/format-assertion"; return vocabularies.containsKey(vocabulary); // doesn't matter if it is true or false - } else if (Version.DRAFT_2019_09.equals(specification)) { + } else if (SpecificationVersion.DRAFT_2019_09.equals(specification)) { String vocabulary = "https://json-schema.org/draft/2019-09/vocab/format"; return vocabularies.getOrDefault(vocabulary, false); } diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 64d1f7e0d..39e4b5cd9 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -53,7 +53,7 @@ public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes // slightly. - this.isMinV201909 = MinV201909.getVersions().contains(this.schemaContext.getDialect().getSpecification()); + this.isMinV201909 = MinV201909.getVersions().contains(this.schemaContext.getDialect().getSpecificationVersion()); Integer currentMax = null; Integer currentMin = null; diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 68624c901..b356be790 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -22,7 +22,6 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.Specification.Version; import com.networknt.schema.annotation.Annotation; import static com.networknt.schema.keyword.VersionCode.MinV202012; @@ -43,7 +42,7 @@ public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluat Schema parentSchema, SchemaContext schemaContext) { super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); - isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecification()); + isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecificationVersion()); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java index c695219ee..15b565744 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java @@ -20,9 +20,8 @@ import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.SchemaContext; -import com.networknt.schema.Specification.Version; import java.util.ArrayList; import java.util.Arrays; @@ -38,26 +37,26 @@ KeywordValidator newInstance(SchemaLocation schemaLocation, NodePath evaluationP } enum VersionCode { - None(new Specification.Version[] { }), - AllVersions(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), - MinV6(new Specification.Version[] { Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), - MinV6MaxV7(new Specification.Version[] { Specification.Version.DRAFT_6, Specification.Version.DRAFT_7 }), - MinV7(new Specification.Version[] { Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), - MaxV7(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7 }), - MaxV201909(new Specification.Version[] { Specification.Version.DRAFT_4, Specification.Version.DRAFT_6, Specification.Version.DRAFT_7, Specification.Version.DRAFT_2019_09 }), - MinV201909(new Specification.Version[] { Specification.Version.DRAFT_2019_09, Specification.Version.DRAFT_2020_12 }), - MinV202012(new Specification.Version[] { Specification.Version.DRAFT_2020_12 }), - V201909(new Specification.Version[] { Specification.Version.DRAFT_2019_09 }), - V7(new Specification.Version[] { Specification.Version.DRAFT_7 }); - - private final EnumSet versions; - - VersionCode(Specification.Version[] versionFlags) { - this.versions = EnumSet.noneOf(Version.class); + None(new SpecificationVersion[] { }), + AllVersions(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV6(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV6MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MinV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MaxV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09 }), + MinV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV202012(new SpecificationVersion[] { SpecificationVersion.DRAFT_2020_12 }), + V201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09 }), + V7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7 }); + + private final EnumSet versions; + + VersionCode(SpecificationVersion[] versionFlags) { + this.versions = EnumSet.noneOf(SpecificationVersion.class); this.versions.addAll(Arrays.asList(versionFlags)); } - EnumSet getVersions() { + EnumSet getVersions() { return this.versions; } } @@ -138,7 +137,7 @@ public enum ValidatorTypeCode implements Keyword { this.versionCode = versionCode; } - public static List getKeywords(Specification.Version versionFlag) { + public static List getKeywords(SpecificationVersion versionFlag) { final List result = new ArrayList<>(); for (ValidatorTypeCode keyword : values()) { if (keyword.getVersionCode().getVersions().contains(versionFlag)) { diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index b1b14fc41..7f19f615a 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -8,12 +8,12 @@ import com.networknt.schema.JsonType; import com.networknt.schema.PathType; import com.networknt.schema.SchemaRegistryConfig; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.TypeFactory; import com.networknt.schema.SchemaContext; public class JsonNodeUtil { - private static final long V6_VALUE = Version.DRAFT_6.getOrder(); + private static final long V6_VALUE = SpecificationVersion.DRAFT_6.getOrder(); private static final String TYPE = "type"; private static final String ENUM = "enum"; @@ -120,7 +120,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch } private static long detectVersion(SchemaContext schemaContext) { - return schemaContext.getDialect().getSpecification().getOrder(); + return schemaContext.getDialect().getSpecificationVersion().getOrder(); } /** diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index e9a18c76b..0f564b016 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -22,7 +22,7 @@ abstract class AbstractJsonSchemaTest { private static final String SCHEMA = "$schema"; - private static final Specification.Version DEFAULT_VERSION_FLAG = Specification.Version.DRAFT_2020_12; + private static final SpecificationVersion DEFAULT_VERSION_FLAG = SpecificationVersion.DRAFT_2020_12; private static final String ASSERT_MSG_KEYWORD = "Validation result should contain {0} keyword"; protected List validate(String dataPath) { diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 4f42bb8b2..34bdb3456 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -16,7 +16,6 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; import com.networknt.schema.regex.JDKRegularExpressionFactory; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; @@ -149,7 +148,7 @@ private static Iterable unsupportedMetaSchema(TestCase te ); } - protected Stream createTests(Version defaultVersion, String basePath) { + protected Stream createTests(SpecificationVersion defaultVersion, String basePath) { return findTestCases(basePath) .stream() .peek(System.out::println) @@ -164,7 +163,7 @@ protected Optional reason(@SuppressWarnings("unused") Path path) { return Optional.empty(); } - private Stream buildContainers(Version defaultVersion, Path path) { + private Stream buildContainers(SpecificationVersion defaultVersion, Path path) { boolean disabled = !enabled(path); String reason = reason(path).orElse("Unknown"); return TestSource.loadFrom(path, disabled, reason) @@ -172,11 +171,11 @@ private Stream buildContainers(Version defaultVersion, Path path) { .orElse(Stream.empty()); } - private Stream buildContainer(Version defaultVersion, TestSource testSource) { + private Stream buildContainer(SpecificationVersion defaultVersion, TestSource testSource) { return testSource.getTestCases().stream().map(testCase -> buildContainer(defaultVersion, testCase)); } - private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { + private DynamicNode buildContainer(SpecificationVersion defaultVersion, TestCase testCase) { try { return dynamicContainer(testCase.getDisplayName(), testCase.getTests().stream().map(testSpec -> { // Configure the schemaValidator to set typeLoose's value based on the test file, @@ -208,7 +207,7 @@ private DynamicNode buildContainer(Version defaultVersion, TestCase testCase) { } } - private SchemaRegistry buildSchemaRegistry(Version defaultVersion, TestCase testCase, SchemaRegistryConfig schemaRegistryConfig) { + private SchemaRegistry buildSchemaRegistry(SpecificationVersion defaultVersion, TestCase testCase, SchemaRegistryConfig schemaRegistryConfig) { if (testCase.isDisabled()) return null; SchemaLoader schemaLoader = new SchemaLoader() { @Override @@ -227,7 +226,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - Version specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); + SpecificationVersion specVersion = detectVersion(testCase.getSchema(), testCase.getSpecification(), defaultVersion, false); SchemaRegistry base = SchemaRegistry.withDefaultDialect(specVersion); return SchemaRegistry .builder(base) diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 375cdd0a8..64dc4330c 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * AdditionalPropertiesValidatorTest. */ @@ -45,7 +43,7 @@ void messageFalse() { + " },\r\n" + " \"additionalProperties\": false\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" @@ -79,7 +77,7 @@ void messageSchema() { + " },\r\n" + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index bda2bef66..9559e1ff7 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -20,8 +20,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class AllOfValidatorTest { @Test void invalidTypeShouldThrowSchemaException() { @@ -33,7 +31,7 @@ void invalidTypeShouldThrowSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +57,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaContents); Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 24bff0985..b7b89e78b 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -20,8 +20,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class AnyOfValidatorTest { @Test void invalidTypeShouldThrowJsonSchemaException() { @@ -33,7 +31,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -59,7 +57,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaContents); Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index b2def6495..d02924de5 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -47,14 +47,14 @@ public static JsonNode getJsonNodeFromUrl(String url) throws IOException { } public static Schema getJsonSchemaFromClasspath(String name) { - return getJsonSchemaFromClasspath(name, Specification.Version.DRAFT_4, null); + return getJsonSchemaFromClasspath(name, SpecificationVersion.DRAFT_4, null); } - public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion) { + public static Schema getJsonSchemaFromClasspath(String name, SpecificationVersion schemaVersion) { return getJsonSchemaFromClasspath(name, schemaVersion, null); } - public static Schema getJsonSchemaFromClasspath(String name, Specification.Version schemaVersion, SchemaRegistryConfig config) { + public static Schema getJsonSchemaFromClasspath(String name, SpecificationVersion schemaVersion, SchemaRegistryConfig config) { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(schemaVersion, builder -> builder.schemaRegistryConfig(config)); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); @@ -62,17 +62,17 @@ public static Schema getJsonSchemaFromClasspath(String name, Specification.Versi } public static Schema getJsonSchemaFromStringContent(String schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); return factory.getSchema(schemaContent); } public static Schema getJsonSchemaFromUrl(String uri) throws URISyntaxException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); return factory.getSchema(SchemaLocation.of(uri)); } public static Schema getJsonSchemaFromJsonNode(JsonNode jsonNode) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); return factory.getSchema(jsonNode); } diff --git a/src/test/java/com/networknt/schema/ConstValidatorTest.java b/src/test/java/com/networknt/schema/ConstValidatorTest.java index ed711a62d..585c0552a 100644 --- a/src/test/java/com/networknt/schema/ConstValidatorTest.java +++ b/src/test/java/com/networknt/schema/ConstValidatorTest.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.i18n.ResourceBundleMessageSource; /** @@ -39,7 +38,7 @@ void localeMessageOthers() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "\"bb\""; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value 'aa' but is 'bb'", messages.iterator().next().toString()); @@ -53,7 +52,7 @@ void localeMessageNumber() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .messageSource(new ResourceBundleMessageSource("const-messages-override", "jsv-messages")) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "2"; List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(": must be the constant value '1' but is '2'", messages.iterator().next().toString()); @@ -65,7 +64,7 @@ void validOthers() { + " \"const\": \"aa\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); String inputData = "\"aa\""; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -76,7 +75,7 @@ void validNumber() { String schemaData = "{\r\n" + " \"const\": 1234.56789\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); String inputData = "1234.56789"; List messages = schema.validate(inputData, InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -87,7 +86,7 @@ void invalidNumber() { String schemaData = "{\r\n" + " \"const\": 1234.56789\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); String inputData = "\"1234.56789\""; List messages = schema.validate(inputData, InputFormat.JSON); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index 0d60571c1..929c0cd1a 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.serialization.JsonMapperFactory; @@ -54,7 +53,7 @@ void annotationCollection() throws JsonProcessingException { + " ]\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "\"helloworld\""; diff --git a/src/test/java/com/networknt/schema/CustomMessageTest.java b/src/test/java/com/networknt/schema/CustomMessageTest.java index b0638baf7..cf0064bd0 100644 --- a/src/test/java/com/networknt/schema/CustomMessageTest.java +++ b/src/test/java/com/networknt/schema/CustomMessageTest.java @@ -1,7 +1,5 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -14,13 +12,13 @@ class CustomMessageTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09 - Custom Messages Enabled") Stream draft201909__customMessagesEnabled() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-tests.json"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-tests.json"); } @TestFactory @DisplayName("Draft 2019-09 - Custom Messages Disabled") Stream draft201909__customMessagesDisabled() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index 4e850e46e..0bf01c189 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -31,7 +31,7 @@ void customUri() throws Exception { } private SchemaRegistry buildJsonSchemaFactory() { - return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) + return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) .schemaLoaders(schemaLoaders -> schemaLoaders.add(new CustomUriFetcher())).build(); } diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index d403b47f5..3ac6a8910 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -11,7 +11,7 @@ class CyclicDependencyTest { void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) + .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) .build(); String jsonObject = "{\n" + " \"element\": {\n" + diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index d22d412db..f98ed0ffb 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -10,7 +10,7 @@ class DateTimeDSTTest { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index 6c4354d8d..4c52bd6e8 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -21,8 +21,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Tests for the non-standard DefaultJsonSchemaIdValidator. */ @@ -35,9 +33,9 @@ void givenRelativeIdShouldThrowInvalidSchemaException() { .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); + () -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); try { - SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); + SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } @@ -50,7 +48,7 @@ void givenFragmentWithNoContextShouldNotThrowInvalidSchemaException() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @Test @@ -60,7 +58,7 @@ void givenSlashWithNoContextShouldNotThrowInvalidSchemaException() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); } @Test @@ -68,7 +66,7 @@ void givenRelativeIdWithClasspathBaseShouldNotThrowInvalidSchemaException() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); - assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + assertDoesNotThrow(() -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(SchemaLocation.of("classpath:schema/id-relative.json"))); } } diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index 6dd69a2e8..4a5e327a6 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -28,7 +28,7 @@ class DependentRequiredTest { " }" + "}"; - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); private static final Schema schema = factory.getSchema(SCHEMA); private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index eeffe2233..e71e00539 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -34,7 +34,7 @@ void durationFormatValidatorTest() throws IOException { final JsonNode validTargetNode = objectMapper.readTree("\"P1D\""); final JsonNode invalidTargetNode = objectMapper.readTree("\"INVALID_DURATION\""); - final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)).build(); + final SchemaRegistry validatorFactory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)).build(); final Schema validatorSchema = validatorFactory.getSchema(schema); List messages = validatorSchema.validate(validTargetNode); diff --git a/src/test/java/com/networknt/schema/EnumValidatorTest.java b/src/test/java/com/networknt/schema/EnumValidatorTest.java index b31824415..2e78e3b5c 100644 --- a/src/test/java/com/networknt/schema/EnumValidatorTest.java +++ b/src/test/java/com/networknt/schema/EnumValidatorTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * EnumValidator test. */ @@ -85,7 +83,7 @@ void enumWithObjectNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); Error message = messages.get(0); @@ -104,7 +102,7 @@ void enumWithHeterogenousNodes() { + " \"name\": \"FOO\",\r\n" + " \"cardinality\": 50\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertEquals(1, messages.size()); Error message = messages.get(0); diff --git a/src/test/java/com/networknt/schema/ErrorHandlerTest.java b/src/test/java/com/networknt/schema/ErrorHandlerTest.java index 2b3e9a81e..7b1463d53 100644 --- a/src/test/java/com/networknt/schema/ErrorHandlerTest.java +++ b/src/test/java/com/networknt/schema/ErrorHandlerTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * ErrorHandlerTest. */ @@ -53,7 +51,7 @@ void errorMessage() { + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("errorMessage").build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); @@ -84,7 +82,7 @@ void errorMessageUnionType() { + " \"keyword1\": 2\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("errorMessage").build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON).stream().collect(Collectors.toList()); assertFalse(messages.isEmpty()); assertEquals("/keyword1", messages.get(0).getInstanceLocation().toString()); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index da1780c62..b7a79e80d 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -21,14 +21,13 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.DialectId; class ExampleTest { @Test void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json")); @@ -52,7 +51,7 @@ void exampleSchemaLocation() { @Test void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("classpath:schema/example-main.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 2d2fa30d3..6d862f6c0 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.params.provider.EnumSource; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.format.PatternFormat; @@ -43,7 +42,7 @@ void unknownFormatNoVocab() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); @@ -56,7 +55,7 @@ void unknownFormatNoVocabStrictTrue() { + " \"format\":\"unknown\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().strict("format", true).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); @@ -85,7 +84,7 @@ void unknownFormatAssertionsVocab() { + " \"format\":\"unknown\"\r\n" + "}"; Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) .getSchema(schemaData); @@ -99,7 +98,7 @@ void unknownFormatShouldCollectAnnotations() { String schemaData = "{\r\n" + " \"format\":\"unknown\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); OutputUnit outputUnit = schema.validate("\"hello\"", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig @@ -143,7 +142,7 @@ void formatAssertions(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(formatSchema); List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); @@ -236,7 +235,7 @@ void draft7DisableFormat() { String schemaData = "{\r\n" + " \"format\":\"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(false)); }); diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 472458497..0f4c4b3dc 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.ValidatorTypeCode; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; @@ -71,7 +70,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk("\"false\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); @@ -116,7 +115,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk("\"hello\"", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertFalse(result.getErrors().isEmpty()); @@ -162,7 +161,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -206,7 +205,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk("\"false\"", InputFormat.JSON, false, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index 099e77278..854e0e538 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; class Issue1091Test { @@ -33,7 +32,7 @@ class Issue1091Test { void testHasAdjacentKeywordInEvaluationPath() throws Exception { SchemaRegistryConfig config = SchemaRegistryConfig.builder().cacheRefs(false).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) .getSchema(SchemaLocation.of("classpath:schema/issue1091.json")); JsonNode node = JsonMapperFactory.getInstance() .readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json")); diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index 2d35c11b4..dc6dbba81 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -25,7 +25,7 @@ class Issue255Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index 3c07271c6..06d5ec873 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -13,7 +13,7 @@ class Issue285Test { private final ObjectMapper mapper = new ObjectMapper(); private final SchemaRegistry schemaFactory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) + .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("http://json-schema.org", "resource:") .mapPrefix("https://json-schema.org", "resource:")) diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index eacd60330..27e6d9a36 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -10,7 +10,7 @@ class Issue295Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 012034cc9..430f9d44b 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -11,12 +11,12 @@ class Issue313Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } protected Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index e8a71c904..2c80e418e 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -10,7 +10,7 @@ class Issue327Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 3c75d1d70..94ef7e0a5 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -11,7 +11,7 @@ class Issue342Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index 92f479056..649b82657 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -11,7 +11,7 @@ class Issue347Test { @Test void failure() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); assertThrows(SchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 121a2f8bf..7c41e4693 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -26,7 +26,7 @@ private void setupSchema() throws IOException { .failFast(true) .typeLoose(false) .build(); - SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); SchemaLocation uri = getSchema(); InputStream in = getClass().getResourceAsStream("/schema/issue366_schema.json"); diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 18163f8c2..bd00d2558 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -25,7 +25,7 @@ void setup() throws IOException { private void setupSchema() throws IOException { SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().typeLoose(false).build(); - SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)); SchemaLocation uri = getSchema(); diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 8f6ee999b..4974513f3 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; @@ -28,7 +27,7 @@ class Issue375Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index c826b8f19..3fdf85f32 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -11,7 +11,7 @@ class Issue383Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index 1ccaeb24c..e625cdde9 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -14,7 +14,7 @@ class Issue396Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index d02fce56a..5cc37ebe9 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -10,7 +10,7 @@ class Issue404Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index 16bd64977..36273254e 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -14,7 +14,7 @@ class Issue406Test { @Test void testPreloadingNotHappening() { - final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass Assertions.assertNotNull(schema); @@ -22,7 +22,7 @@ void testPreloadingNotHappening() { @Test void testPreloadingHappening() { - final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); final Schema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(SchemaException.class, new Executable() { @@ -36,7 +36,7 @@ public void execute() { @Test void testPreloadingHappeningForCircularDependency() { - final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); final Schema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); } diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 65724aa3e..a3b27e0fa 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -14,7 +14,7 @@ class Issue426Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { SchemaRegistryConfig config = SchemaRegistryConfig.builder().errorMessageKeyword("message").build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index 7de9d3b5c..166ddc96c 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -37,7 +37,7 @@ private void runTestFile(String testCaseFile) throws Exception { configBuilder.typeLoose(typeLooseNode != null && typeLooseNode.asBoolean()); SchemaRegistryConfig config = configBuilder.build(); - SchemaRegistry validatorFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry validatorFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); Schema schema = validatorFactory.getSchema(testCaseFileUri, testCase.get("schema")); List errors = new ArrayList(schema.validate(node)); diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 051130f39..229bfc478 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -24,7 +24,7 @@ class Issue451Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index 88301babb..7dc2566be 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -11,7 +11,7 @@ class Issue456Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 8dd16639c..737aaaba0 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -19,7 +19,7 @@ class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaUri); } diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index e79a47fb3..515d4b616 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -64,7 +64,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); Result result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @@ -93,7 +93,7 @@ public void onWalkEnd(WalkEvent walkEvent, List set) { WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaInputStream); JsonNode data = mapper.readTree(Issue467Test.class.getResource("/data/issue467.json")); Result result = schema.walk(data, true, executionContext -> executionContext.setWalkConfig(walkConfig)); diff --git a/src/test/java/com/networknt/schema/Issue471Test.java b/src/test/java/com/networknt/schema/Issue471Test.java index 8fab5b129..903a493a8 100644 --- a/src/test/java/com/networknt/schema/Issue471Test.java +++ b/src/test/java/com/networknt/schema/Issue471Test.java @@ -78,7 +78,7 @@ private Map convertErrorsToMap(List errors) { } private Schema getJsonSchemaFromStreamContentV201909(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 8d4d6aba1..e756c3988 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.serialization.JsonMapperFactory; @@ -51,7 +50,7 @@ class Issue475Test { @Test void draft4() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_4, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4)); @@ -64,7 +63,7 @@ void draft4() throws Exception { @Test void draft6() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_6, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6)); @@ -77,7 +76,7 @@ void draft6() throws Exception { @Test void draft7() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7)); @@ -90,7 +89,7 @@ void draft7() throws Exception { @Test void draft201909() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09)); @@ -103,7 +102,7 @@ void draft201909() throws Exception { @Test void draft202012() throws Exception { - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12)); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index b4f7ab83e..d0926d9bc 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -18,7 +18,7 @@ class Issue493Test { - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); private static final String schemaPath1 = "/schema/issue493.json"; private JsonNode getJsonNodeFromJsonData (String jsonFilePath) diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index 6247f894e..fa537fdd8 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -7,7 +7,7 @@ class Issue532Test { @Test void failure() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); SchemaException ex = assertThrows(SchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); }); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index 1b53dff91..4c65f08b8 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -12,7 +12,7 @@ class Issue550Test { protected Schema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index d5a6b1f2c..e54e05ae7 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -25,7 +25,7 @@ class Issue575Test { @BeforeAll static void init() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); String schemaPath = "/schema/issue575-2019-09.json"; InputStream schemaInputStream = Issue575Test.class.getResourceAsStream(schemaPath); schema = factory.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index 0c4b207c5..db6c7db6f 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -12,7 +12,7 @@ class Issue604Test { void failure() { WalkConfig walkConfig = WalkConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }"); ObjectMapper objectMapper = new ObjectMapper(); assertDoesNotThrow(() -> { diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index 1cd34832c..14ef4eee3 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -10,7 +10,7 @@ class Issue606Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index 39049ab24..98d4a6d3a 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -53,7 +53,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; - factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, + factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index a24c8fe46..fdd15a33d 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -37,7 +37,7 @@ void testBinaryNode() throws Exception { // schema with data property of type string: InputStream schemaInputStream = getClass().getResourceAsStream("/draft7/issue650.json"); - Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7).getSchema(schemaInputStream); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaInputStream); // create model first: Issue650Test.Model model = new Issue650Test.Model(); diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index f911de7df..5241d4378 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -17,7 +17,7 @@ class Issue662Test extends BaseJsonSchemaValidatorTest { @BeforeAll static void setup() { - schema = getJsonSchemaFromClasspath(resource("schema.json"), Specification.Version.DRAFT_7); + schema = getJsonSchemaFromClasspath(resource("schema.json"), SpecificationVersion.DRAFT_7); } @Test diff --git a/src/test/java/com/networknt/schema/Issue664Test.java b/src/test/java/com/networknt/schema/Issue664Test.java index d1da7ffb2..738e08665 100644 --- a/src/test/java/com/networknt/schema/Issue664Test.java +++ b/src/test/java/com/networknt/schema/Issue664Test.java @@ -14,7 +14,7 @@ class Issue664Test { protected Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index e5443ad93..bf07a47de 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -13,7 +13,7 @@ class Issue665Test extends BaseJsonSchemaValidatorTest { @Test void testUrnUriAsLocalRef() throws IOException { - Schema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", Specification.Version.DRAFT_7); + Schema schema = getJsonSchemaFromClasspath("draft7/urn/issue665.json", SpecificationVersion.DRAFT_7); Assertions.assertNotNull(schema); Assertions.assertDoesNotThrow(schema::initializeValidators); List messages = schema.validate(getJsonNodeFromStringContent( @@ -24,7 +24,7 @@ void testUrnUriAsLocalRef() throws IOException { @Test void testUrnUriAsLocalRef_ExternalURN() { SchemaRegistry factory = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)) + .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7)) .schemaMappers(schemaMappers -> { schemaMappers.mappings(Collections.singletonMap("urn:data", "classpath:draft7/urn/issue665_external_urn_subschema.json")); diff --git a/src/test/java/com/networknt/schema/Issue668Test.java b/src/test/java/com/networknt/schema/Issue668Test.java index 7e1474c4c..040b65286 100644 --- a/src/test/java/com/networknt/schema/Issue668Test.java +++ b/src/test/java/com/networknt/schema/Issue668Test.java @@ -11,7 +11,7 @@ class Issue668Test { protected Schema getJsonSchemaFromStreamContent(InputStream schemaContent) throws Exception { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); YAMLMapper mapper = new YAMLMapper(); JsonNode node = mapper.readTree(schemaContent); return factory.getSchema(node); diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index 32045742f..c0f49d187 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -54,7 +54,7 @@ void testLocaleSwitch() throws JsonProcessingException { } private Schema getSchema(SchemaRegistryConfig config) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema("{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }"); } diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index 9811273c4..5a26f4570 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -81,7 +81,7 @@ void testAppendIndex(PathType pathType, String currentPath, Integer index, Strin @MethodSource("errors") void testError(PathType pathType, String schemaPath, String content, String[] expectedMessagePaths) throws JsonProcessingException { SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(pathType).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema(Issue687Test.class.getResourceAsStream(schemaPath)); List messages = schema.validate(new ObjectMapper().readTree(content)); assertEquals(expectedMessagePaths.length, messages.size()); @@ -114,7 +114,7 @@ static Stream specialCharacterTests() { void testSpecialCharacters(PathType pathType, String propertyName, String expectedPath) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); SchemaRegistryConfig schemaValidatorsConfig = SchemaRegistryConfig.builder().pathType(pathType).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)) + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(schemaValidatorsConfig)) .getSchema(mapper.readTree("{\n" + " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n" + " \"type\": \"object\",\n" + diff --git a/src/test/java/com/networknt/schema/Issue724Test.java b/src/test/java/com/networknt/schema/Issue724Test.java index b663d356c..13486210a 100644 --- a/src/test/java/com/networknt/schema/Issue724Test.java +++ b/src/test/java/com/networknt/schema/Issue724Test.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; @@ -54,7 +53,7 @@ void test() throws JsonProcessingException { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schema); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schema); jsonSchema.walk(new ObjectMapper().readTree(data), /* shouldValidateSchema= */ false, executionContext -> executionContext.setWalkConfig(walkConfig)); System.out.println(stringCollector.strings); diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index fd0d6ce2b..b2302017c 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -14,7 +14,7 @@ class Issue792 { void test() throws JsonProcessingException { SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(false).failFast(true).build(); - SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); String schemaDef = "{\n" + diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index 662b66d91..ba11e864c 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -15,7 +15,7 @@ class Issue824Test { @Test void validate() throws JsonProcessingException { final Schema v201909SpecSchema = SchemaRegistry - .builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)) + .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) .schemaMappers(schemaMappers -> { schemaMappers.mapPrefix("https://json-schema.org", "resource:"); }).build() diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index ffe38783e..946629d3d 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -21,8 +21,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue857Test { @Test void test() { @@ -49,7 +47,7 @@ void test() { + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().failFast(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); List result = factory.getSchema(schema).validate(input, InputFormat.JSON); assertTrue(result.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index 0eedab865..083580106 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; class Issue877Test { @@ -30,7 +29,7 @@ void test() throws Exception { + " \"unevaluatedProperties\": false\n" + "}"; - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = jsonSchemaFactory.getSchema(schemaData); String input = "{}"; Result result = schema.walk(JsonMapperFactory.getInstance().readTree(input), true); diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index ca31033f6..45ee0ea23 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -15,7 +15,7 @@ class Issue898Test extends BaseJsonSchemaValidatorTest { void testMessagesWithSingleQuotes() throws Exception { SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.FRENCH).build(); - Schema schema = getJsonSchemaFromClasspath("schema/issue898.json", Specification.Version.DRAFT_2020_12, config); + Schema schema = getJsonSchemaFromClasspath("schema/issue898.json", SpecificationVersion.DRAFT_2020_12, config); JsonNode node = getJsonNodeFromClasspath("data/issue898.json"); List messages = schema.validate(node).stream() diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index fa29ad126..0d1270375 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -105,7 +104,7 @@ void test() throws JsonProcessingException { + " }\r\n" + " }\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7) .getSchema(SchemaLocation.of("http://www.example.org"), JsonMapperFactory.getInstance().readTree(schema)); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index fdd45e5bc..ec1fbc131 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -7,7 +7,7 @@ class Issue928Test { private final ObjectMapper mapper = new ObjectMapper(); - private SchemaRegistry factoryFor(Specification.Version version) { + private SchemaRegistry factoryFor(SpecificationVersion version) { return SchemaRegistry .builder(SchemaRegistry.withDefaultDialect(version)) .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://example.org", "classpath:")) @@ -16,20 +16,20 @@ private SchemaRegistry factoryFor(Specification.Version version) { @Test void test_07() { - test_spec(Specification.Version.DRAFT_7); + test_spec(SpecificationVersion.DRAFT_7); } @Test void test_201909() { - test_spec(Specification.Version.DRAFT_2019_09); + test_spec(SpecificationVersion.DRAFT_2019_09); } @Test void test_202012() { - test_spec(Specification.Version.DRAFT_2020_12); + test_spec(SpecificationVersion.DRAFT_2020_12); } - void test_spec(Specification.Version specVersion) { + void test_spec(SpecificationVersion specVersion) { SchemaRegistry schemaFactory = factoryFor(specVersion); String versionId = specVersion.getDialectId(); diff --git a/src/test/java/com/networknt/schema/Issue935Test.java b/src/test/java/com/networknt/schema/Issue935Test.java index 16d1cfdea..13ba128ff 100644 --- a/src/test/java/com/networknt/schema/Issue935Test.java +++ b/src/test/java/com/networknt/schema/Issue935Test.java @@ -19,13 +19,11 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue935Test { @Test void shouldThrowInvalidSchemaException() { String schema = "{ \"$schema\": \"0\" }"; assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schema)); + () -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09).getSchema(schema)); } } diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index 511611f85..925e6c0e3 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -20,8 +20,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue936Test { @Test void shouldThrowInvalidSchemaException() { @@ -31,9 +29,9 @@ void shouldThrowInvalidSchemaException() { .schemaIdValidator(SchemaIdValidator.DEFAULT) .build(); assertThrowsExactly(InvalidSchemaException.class, - () -> SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); + () -> SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema)); try { - SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); + SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schema); } catch (InvalidSchemaException e) { assertEquals("/$id: '0' is not a valid $id", e.getError().toString()); } diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index ee2e72e7a..4c75ce86f 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue939Test { @Test void shouldNotThrowException() { @@ -48,7 +46,7 @@ void shouldNotThrowException() { + " }\r\n" + " }\r\n" + " }"; - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); List assertions = jsonSchema .validate("{\"someUuid\":\"invalid\"}", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index 352127948..8dbd10233 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -19,8 +19,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue940Test { @Test void shouldNotThrowException() { @@ -31,7 +29,7 @@ void shouldNotThrowException() { + " \"greeting\": {}\r\n" + " }\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schema); + Schema jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schema); assertDoesNotThrow(() -> jsonSchema.initializeValidators()); } } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index 4402626ad..e7954d5b9 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class Issue943Test { @Test void test() { @@ -67,7 +65,7 @@ void test() { + " \"type\": \"Point\",\r\n" + " \"coordinates\": [1, 1]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); Schema schema = factory.getSchema(schemaData); assertTrue(schema.validate(inputData, InputFormat.JSON).isEmpty()); diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index e3e3ebf9e..c055dd485 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.WalkConfig; @@ -46,7 +45,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -87,7 +86,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .itemWalkListenerRunner(itemWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -129,7 +128,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .itemWalkListenerRunner(itemWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index a8b5f7536..5c90903a7 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; @@ -49,7 +48,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -75,7 +74,7 @@ void messageAdditionalItemsInvalid() { + " \"items\": [{}]," + " \"additionalItems\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -101,7 +100,7 @@ void messageAdditionalItemsFalseInvalid() { + " \"items\": [{}]," + " \"additionalItems\": false" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); String inputData = "[ null, 2, 3, \"foo\" ]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -141,7 +140,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); Result result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -179,7 +178,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -223,7 +222,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -276,7 +275,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @@ -332,7 +331,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index f88295527..49001b656 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -46,7 +46,7 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { } private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { - return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12)) + return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) .dialectRegistry(new BasicDialectRegistry(Dialects.getDraft202012())) diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index f449697d1..5bb119753 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -18,8 +18,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Test to control preloading of schemas. */ @@ -27,7 +25,7 @@ class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().cacheRefs(false).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json")); } @@ -36,7 +34,7 @@ void preloadSchemaRefMaxNestingDepth() { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .preloadSchemaRefMaxNestingDepth(20) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); factory.getSchema(SchemaLocation.of("classpath:/issues/1016/schema.json")); } } diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java index c442e4848..7242260f9 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteExtrasTest.java @@ -1,7 +1,5 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -18,31 +16,31 @@ class JsonSchemaTestSuiteExtrasTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2020-12") Stream draft2022012() { - return createTests(Version.DRAFT_2020_12, "src/test/resources/draft2020-12"); + return createTests(SpecificationVersion.DRAFT_2020_12, "src/test/resources/draft2020-12"); } @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/draft2019-09"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/draft2019-09"); } @TestFactory @DisplayName("Draft 7") Stream draft7() { - return createTests(Version.DRAFT_7, "src/test/resources/draft7"); + return createTests(SpecificationVersion.DRAFT_7, "src/test/resources/draft7"); } @TestFactory @DisplayName("Draft 6") Stream draft6() { - return createTests(Version.DRAFT_6, "src/test/resources/draft6"); + return createTests(SpecificationVersion.DRAFT_6, "src/test/resources/draft6"); } @TestFactory @DisplayName("Draft 4") Stream draft4() { - return createTests(Version.DRAFT_4, "src/test/resources/draft4"); + return createTests(SpecificationVersion.DRAFT_4, "src/test/resources/draft4"); } @Override diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java index 478b7628e..5ff37905a 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java @@ -10,8 +10,6 @@ import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; -import com.networknt.schema.Specification.Version; - @DisplayName("JSON Schema Test Suite") class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { @@ -30,31 +28,31 @@ class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2020-12") Stream draft2022012() { - return createTests(Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12"); + return createTests(SpecificationVersion.DRAFT_2020_12, "src/test/suite/tests/draft2020-12"); } @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/suite/tests/draft2019-09"); } @TestFactory @DisplayName("Draft 7") Stream draft7() { - return createTests(Version.DRAFT_7, "src/test/suite/tests/draft7"); + return createTests(SpecificationVersion.DRAFT_7, "src/test/suite/tests/draft7"); } @TestFactory @DisplayName("Draft 6") Stream draft6() { - return createTests(Version.DRAFT_6, "src/test/suite/tests/draft6"); + return createTests(SpecificationVersion.DRAFT_6, "src/test/suite/tests/draft6"); } @TestFactory @DisplayName("Draft 4") Stream draft4() { - return createTests(Version.DRAFT_4, "src/test/suite/tests/draft4"); + return createTests(SpecificationVersion.DRAFT_4, "src/test/suite/tests/draft4"); } @Override diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 0795af45d..9e3b127ee 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -134,7 +134,7 @@ void testIllegalArgumentException() { } private Schema createSchema() { - SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry schemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); return schemaFactory .getSchema(getClass().getClassLoader().getResourceAsStream("schema/walk-schema-default.json")); } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index cb83e735e..bae464db5 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -144,7 +144,7 @@ void testWalkMissingNodeWithPropertiesSchemaShouldNotThrow() { + " }\n" + " }"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaContents); JsonNode missingNode = MissingNode.getInstance(); assertDoesNotThrow(() -> schema.walk(missingNode, true)); diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index 8cbeab29e..c28cf5c1c 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -28,13 +28,12 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import com.networknt.schema.i18n.Locales; import com.networknt.schema.serialization.JsonMapperFactory; class LocaleTest { private Schema getSchema(SchemaRegistryConfig config) { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema( "{ \"$schema\": \"https://json-schema.org/draft/2019-09/schema\", \"$id\": \"https://json-schema.org/draft/2019-09/schema\", \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"string\" } } } }" ); @@ -88,7 +87,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { + " \"$id\": \"https://www.example.com\",\r\n" + " \"type\": \"object\"\r\n" + "}"; - Schema jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7) + Schema jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); String input = "1"; List messages = jsonSchema.validate(input, InputFormat.JSON); @@ -96,7 +95,7 @@ void englishLocale() throws JsonMappingException, JsonProcessingException { assertEquals(": integer gefunden, object erwartet", messages.iterator().next().toString()); SchemaRegistryConfig config = SchemaRegistryConfig.builder().locale(Locale.ENGLISH).build(); - jsonSchema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)) + jsonSchema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)) .getSchema(JsonMapperFactory.getInstance().readTree(schema)); messages = jsonSchema.validate(input, InputFormat.JSON); assertEquals(1, messages.size()); @@ -154,7 +153,7 @@ void encoding() { + " \"type\": \"string\",\r\n" + " \"maxLength\": 5\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); List locales = Locales.getSupportedLocales(); for (Locale locale : locales) { List messages = schema.validate("\"aaaaaa\"", InputFormat.JSON, executionContext -> { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index 4a58399a7..634945fca 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -34,7 +34,7 @@ class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s, \"exclusiveMaximum\": true}"; - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); private static final ObjectMapper mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly @@ -182,7 +182,7 @@ void negativeDoubleOverflowTest() throws IOException { }; SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); for (String[] aTestCycle : values) { String maximum = aTestCycle[0]; @@ -298,7 +298,7 @@ private static void expectNoMessages(String[][] values, String schemaTemplate, O String value = aTestCycle[1]; String schema = format(schemaTemplate, maximum); SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = mapper.readTree(value); diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 369a10c2f..944dd7e52 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -42,7 +41,7 @@ void oas31() throws IOException { JsonNode inputData = JsonMapperFactory.getInstance().readTree(input); SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config).schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07")); diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index c256b8a40..b4888358c 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -38,7 +38,7 @@ class MinimumValidatorTest { private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s }"; private static final String NEGATIVE_MESSAGE_TEMPLATE = "Expecting validation errors, value %s is smaller than minimum %s"; private static final String POSITIVT_MESSAGE_TEMPLATE = "Expecting no validation errors, value %s is greater than minimum %s"; - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); private static ObjectMapper mapper; private static ObjectMapper bigDecimalMapper; @@ -173,7 +173,7 @@ void negativeDoubleOverflowTest() throws IOException { String value = aTestCycle[1]; String schema = format(NUMBER, minimum); SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); // Schema and document parsed with just double Schema v = factory.getSchema(mapper.readTree(schema)); @@ -290,7 +290,7 @@ private void expectNoMessages(String[][] values, String integer, ObjectMapper ma String value = aTestCycle[1]; String schema = format(integer, minimum); SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); Schema v = factory.getSchema(mapper.readTree(schema)); JsonNode doc = bigIntegerMapper.readTree(value); diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 0628f7c17..99825a826 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -21,8 +21,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Test MultipleOfValidator validator. */ @@ -47,7 +45,7 @@ class MultipleOfValidatorTest { @Test void test() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":123.892,\"value2\":123456.2934,\"value3\":123.123}"; String validData = "{\"value1\":123.89,\"value2\":123456,\"value3\":123.010}"; @@ -62,7 +60,7 @@ void test() { @Test void testTypeLoose() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\"value1\":\"123.892\",\"value2\":\"123456.2934\",\"value3\":123.123}"; @@ -81,7 +79,7 @@ void testTypeLoose() { // With type loose this has 3 multipleOf errors SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); Schema typeLoose = factory.getSchema(schemaData); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); diff --git a/src/test/java/com/networknt/schema/NotValidatorTest.java b/src/test/java/com/networknt/schema/NotValidatorTest.java index 53b8aa250..454924745 100644 --- a/src/test/java/com/networknt/schema/NotValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotValidatorTest.java @@ -36,7 +36,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaContents); Result result = schema.walk(jsonContents, InputFormat.JSON, true); assertEquals(true, result.getErrors().isEmpty()); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index a47378de0..0fbd219eb 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialects; /** @@ -66,7 +65,7 @@ void oneOfMultiple() { + " \"world\" : \"test\"\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(3, messages.size()); // even if more than 1 matches the mismatch errors are still reported List assertions = messages.stream().collect(Collectors.toList()); @@ -108,7 +107,7 @@ void oneOfZero() { + " \"test\" : 1\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(4, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -140,7 +139,7 @@ void invalidTypeShouldThrowJsonSchemaException() { + " \"$ref\": \"#/defs/User\"\r\n" + " }\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); SchemaException ex = assertThrows(SchemaException.class, () -> factory.getSchema(schemaData)); assertEquals("type", ex.getError().getMessageKey()); } @@ -188,7 +187,7 @@ void invalidSwaggerIoExample() { + " type: integer"; Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -262,7 +261,7 @@ void fixedSwaggerIoExample() { + " - age"; Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( @@ -487,7 +486,7 @@ void walkValidationWithNullNodeShouldNotValidate() { String jsonContents = "{}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); Schema schema = factory.getSchema(schemaContents); Result result = schema.walk(jsonContents, InputFormat.JSON, true); result.getErrors().forEach(m -> System.out.println(m)); diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 3715d6e0b..4f144f0c6 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -17,12 +17,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import com.networknt.schema.utils.CachingSupplier; class OutputFormatTest { - private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); + private static final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); private static final String schemaPath1 = "/schema/output-format-schema.json"; private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { @@ -106,7 +105,7 @@ void customFormat() { + " }\n" + " }\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12) + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12) .getSchema(schemaData, InputFormat.JSON); String inputData = "{\n" + " \"type\": \"cat\",\n" diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index fcfd731d3..e55231882 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -29,7 +29,6 @@ import org.junit.jupiter.params.provider.EnumSource; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.serialization.JsonMapperFactory; @@ -95,7 +94,7 @@ class OutputUnitTest { + "}"; @Test void annotationCollectionList() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = inputData1; @@ -111,7 +110,7 @@ void annotationCollectionList() throws JsonProcessingException { @Test void annotationCollectionHierarchical() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = inputData1; @@ -127,7 +126,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { @Test void annotationCollectionHierarchical2() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = inputData2; @@ -175,7 +174,7 @@ void formatAnnotation(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.executionConfig(executionConfig -> executionConfig @@ -193,7 +192,7 @@ void formatAssertion(FormatInput formatInput) { + " \"type\": \"string\",\r\n" + " \"format\": \""+formatInput.format+"\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.executionConfig(executionConfig -> executionConfig @@ -211,7 +210,7 @@ void typeUnion() { String typeSchema = "{\r\n" + " \"type\": [\"string\",\"array\"]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(typeSchema); OutputUnit outputUnit = schema.validate("1", InputFormat.JSON, OutputFormat.LIST, executionConfiguration -> { executionConfiguration.executionConfig(executionConfig -> executionConfig @@ -259,7 +258,7 @@ void unevaluatedProperties() throws JsonProcessingException { + " \"unevaluatedProperties\": false\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); Schema schema = factory.getSchema(schemaData); @@ -308,7 +307,7 @@ void anyOf() throws JsonProcessingException { + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" @@ -329,7 +328,7 @@ void listAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.List(a -> a)); assertFalse(outputUnit.isValid()); @@ -343,7 +342,7 @@ void hierarchicalAssertionMapper() { String formatSchema = "{\r\n" + " \"type\": \"string\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(formatSchema); OutputUnit outputUnit = schema.validate("1234", InputFormat.JSON, new OutputFormat.Hierarchical(a -> a)); assertFalse(outputUnit.isValid()); diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index c9c7c6500..2466b1fbe 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.Specification.Version; import com.networknt.schema.regex.JDKRegularExpressionFactory; import java.io.InputStream; @@ -17,7 +16,7 @@ private Schema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { SchemaRegistryConfig config = SchemaRegistryConfig.builder().pathType(PathType.LEGACY) .errorMessageKeyword("message") .regularExpressionFactory(JDKRegularExpressionFactory.getInstance()).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaRegistryConfig(config)); return factory.getSchema(schemaContent); } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 14c934d2f..452e97afd 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -17,7 +17,6 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; import com.networknt.schema.regex.JoniRegularExpressionFactory; @@ -41,7 +40,7 @@ class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(SchemaException.class, () -> { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); @@ -56,7 +55,7 @@ void testInvalidPatternPropertiesValidatorECMA262() throws Exception { SchemaRegistryConfig config = SchemaRegistryConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema("{\"patternProperties\":6}"); JsonNode node = getJsonNodeFromStringContent(""); @@ -79,7 +78,7 @@ void message() { + " }\n" + " }\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\n" + " \"valid_array\": [\"array1_value\", \"array2_value\"],\n" @@ -129,7 +128,7 @@ void annotation() { + " }\n" + " }\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\n" + " \"test\": 5\n" diff --git a/src/test/java/com/networknt/schema/PatternValidatorTest.java b/src/test/java/com/networknt/schema/PatternValidatorTest.java index 499d1a8e5..3dd1e3188 100644 --- a/src/test/java/com/networknt/schema/PatternValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternValidatorTest.java @@ -19,8 +19,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * PatternValidatorTest. */ @@ -32,7 +30,7 @@ void failFast() { + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" + "}"; String inputData = "\"hello\""; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); assertFalse(result); } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index a5580fef1..5e713ab92 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.keyword.PrefixItemsValidator; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.ItemWalkListenerRunner; @@ -35,7 +34,7 @@ class PrefixItemsValidatorTest extends AbstractJsonSchemaTestSuite { */ @Test void testEmptyPrefixItemsException() { - Stream dynamicNodeStream = createTests(Specification.Version.DRAFT_7, "src/test/resources/prefixItemsException"); + Stream dynamicNodeStream = createTests(SpecificationVersion.DRAFT_7, "src/test/resources/prefixItemsException"); dynamicNodeStream.forEach( dynamicNode -> { assertThrows(SchemaException.class, () -> { @@ -57,7 +56,7 @@ void messageInvalid() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -83,7 +82,7 @@ void messageValid() { + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema(schemaData); String inputData = "[\"x\", 1, 1]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -102,7 +101,7 @@ void messageInvalidAdditionalItems() { + " \"items\": false" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); Schema schema = factory.getSchema(schemaData); String inputData = "[\"x\", 1, 1, 2]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -150,7 +149,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }).build(); WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @@ -207,7 +206,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder().applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)) .itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null]"); Result result = schema.walk(input, true, diff --git a/src/test/java/com/networknt/schema/PropertiesTest.java b/src/test/java/com/networknt/schema/PropertiesTest.java index 64ca99974..e427ceeec 100644 --- a/src/test/java/com/networknt/schema/PropertiesTest.java +++ b/src/test/java/com/networknt/schema/PropertiesTest.java @@ -1,7 +1,5 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -14,7 +12,7 @@ class PropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/draft2019-09/properties.json"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/draft2019-09/properties.json"); } } diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 76d3593c4..616012acc 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -15,7 +15,7 @@ class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { WalkConfig walkConfig = WalkConfig.builder().applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); Schema schema = factory.getSchema("{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"object\", \"properties\": {} },\"i-have-default\":{\"type\":\"string\",\"default\":\"foo\"}}}"); JsonNode node = getJsonNodeFromStringContent("{\"foo\": \"bar\"}"); Result result = schema.walk(node, true, executionContext -> executionContext.setWalkConfig(walkConfig)); diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 057714c06..e39cc6a42 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * PropertyNamesValidatorTest. */ @@ -38,7 +36,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"propertyNames\": {\"maxLength\": 3}\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\": {},\r\n" diff --git a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java index 0c5aac554..f9fab9dbb 100644 --- a/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java +++ b/src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java @@ -42,7 +42,7 @@ private Schema loadJsonSchema() { } private Schema getJsonSchema() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); InputStream schema = getClass().getClassLoader().getResourceAsStream("schema/read-only-schema.json"); return factory.getSchema(schema); } diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 43147bf08..9cacaa226 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -21,7 +21,7 @@ class RecursiveReferenceValidatorExceptionTest extends AbstractJsonSchemaTestSui void testInvalidRecursiveReference() { // Arrange String invalidSchemaJson = "{ \"$recursiveRef\": \"invalid\" }"; - SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); + SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema jsonSchema = jsonSchemaFactory.getSchema(invalidSchemaJson); JsonNode schemaNode = jsonSchema.getSchemaNode(); SchemaContext schemaContext = new SchemaContext(jsonSchema.getSchemaContext().getDialect(), diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index 7bde6509e..ddba8bf53 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -16,7 +16,7 @@ class RefTest { @Test void shouldLoadRelativeClasspathReference() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" @@ -38,7 +38,7 @@ void shouldLoadRelativeClasspathReference() throws JsonProcessingException { @Test void shouldLoadSchemaResource() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json")); String input = "{\r\n" + " \"DriverProperties\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 401b6f30e..984e81da9 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Tests for RefValidator. */ @@ -40,7 +38,7 @@ void resolveSamePathDotSlash() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -59,7 +57,7 @@ void resolveSamePath() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -78,7 +76,7 @@ void resolveParent() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -97,7 +95,7 @@ void resolveComplex() { + " \"type\": \"integer\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); @@ -107,7 +105,7 @@ void resolveComplex() { @Test void classPathSlash() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:/schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" @@ -123,7 +121,7 @@ void classPathSlash() { @Test void classPathNoSlash() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/main/main.json")); String inputData = "{\r\n" + " \"fields\": {\r\n" diff --git a/src/test/java/com/networknt/schema/RequiredValidatorTest.java b/src/test/java/com/networknt/schema/RequiredValidatorTest.java index 197e2de9c..ba542c46f 100644 --- a/src/test/java/com/networknt/schema/RequiredValidatorTest.java +++ b/src/test/java/com/networknt/schema/RequiredValidatorTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * RequiredValidatorTest. */ @@ -55,7 +53,7 @@ void validateRequestRequiredReadOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" @@ -100,7 +98,7 @@ void validateResponseRequiredWriteOnlyShouldBeIgnored() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"foo\":\"hello\",\r\n" @@ -145,7 +143,7 @@ void validateRequestRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"amount\":10,\r\n" @@ -184,7 +182,7 @@ void validateResponseRequired() { + " \"name\"\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" + " \"description\":\"world\",\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index 35bb7f296..e3e5eba7b 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -9,7 +9,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Specification.Version; import com.networknt.schema.serialization.JsonMapperFactory; /** @@ -18,7 +17,7 @@ class SampleTest { @Test void schemaFromSchemaLocationMapping() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaMappers( + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaMappers( schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. @@ -40,7 +39,7 @@ void schemaFromSchemaLocationMapping() { void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); /* @@ -61,7 +60,7 @@ void schemaFromSchemaLocationContent() { @Test void schemaFromClasspath() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); /* * This should be cached for performance. * @@ -82,7 +81,7 @@ void schemaFromClasspath() { @Test void schemaFromString() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); /* * This should be cached for performance. * @@ -98,7 +97,7 @@ void schemaFromString() { @Test void schemaFromJsonNode() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); /* diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index fc30674e8..6551fda67 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -21,8 +21,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - class SchemaLocationTest { @Test @@ -217,7 +215,7 @@ void documentFragment() { @Test void shouldLoadEscapedFragment() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(SchemaLocation .of("classpath:schema/example-escaped.yaml#/paths/~1users/post/requestBody/application~1json/schema")); List result = schema.validate("1", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/SchemaRegistryTest.java b/src/test/java/com/networknt/schema/SchemaRegistryTest.java index 73a5781f2..6102f0807 100644 --- a/src/test/java/com/networknt/schema/SchemaRegistryTest.java +++ b/src/test/java/com/networknt/schema/SchemaRegistryTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.Dialect; /** @@ -47,7 +46,7 @@ void concurrency() { + " { \"$ref\": \"https://json-schema.org/draft/2020-12/meta/core\" }\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index bc032b833..52b9fc693 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -25,8 +25,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Tests for JsonSchemaFactory. */ @@ -56,7 +54,7 @@ void concurrency() throws Exception { + " \"name\": 1\r\n" + "}"; SchemaRegistryConfig config = SchemaRegistryConfig.builder().preloadSchema(false).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config) .schemaLoaders(schemaLoaders -> schemaLoaders .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index 6516bc0a7..edd62b88d 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -38,7 +38,7 @@ void shouldCallAllKeywordListenerOnWalkStart() throws Exception { .keywordWalkListener(allKeywordListener).build(); WalkConfig walkConfig = WalkConfig.builder().keywordWalkListenerRunner(keywordWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); SchemaLocation draft07Schema = SchemaLocation.of("resource:/draft-07/schema#"); diff --git a/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java index f4ae94789..2fbdd6324 100644 --- a/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java +++ b/src/test/java/com/networknt/schema/SpecificationVersionDetectorTest.java @@ -25,11 +25,11 @@ class SpecificationVersionDetectorTest { "draft2019-09, DRAFT_2019_09", "draft2020-12, DRAFT_2020_12" }) - void detectVersion(String resourceDirectory, Specification.Version expectedFlag) throws IOException { + void detectVersion(String resourceDirectory, SpecificationVersion expectedFlag) throws IOException { InputStream in = Thread.currentThread().getContextClassLoader() .getResourceAsStream(resourceDirectory + "/schemaTag.json"); JsonNode node = mapper.readTree(in); - Specification.Version flag = SpecificationVersionDetector.detect(node); + SpecificationVersion flag = SpecificationVersionDetector.detect(node); assertEquals(expectedFlag, flag); } @@ -50,7 +50,7 @@ void detectOptionalSpecVersion() throws IOException { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream( "data/schemaTagMissing.json"); JsonNode node = mapper.readTree(in); - Optional flag = SpecificationVersionDetector.detectOptionalVersion(node, true); + Optional flag = SpecificationVersionDetector.detectOptionalVersion(node, true); assertEquals(Optional.empty(), flag); } } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 934cb71c6..7c2feb91d 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * Test TypeValidator validator. */ @@ -52,7 +50,7 @@ class TypeValidatorTest { @Test void testTypeLoose() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "{\r\n" @@ -79,7 +77,7 @@ void testTypeLoose() { // With type loose this has 0 type errors as any item can also be interpreted as an array of 1 item SchemaRegistryConfig config = SchemaRegistryConfig.builder().typeLoose(true).build(); - factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); + factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)); Schema typeLoose = factory.getSchema(schemaData); messages = typeLoose.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); @@ -102,7 +100,7 @@ void integer() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); messages = schema.validate("2.0", InputFormat.JSON); @@ -131,7 +129,7 @@ void integerDraft4() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4).getSchema(schemaData); List messages = schema.validate("1", InputFormat.JSON); assertEquals(0, messages.size()); // The logic in JsonNodeUtil specifically excludes V4 from this handling @@ -146,7 +144,7 @@ void walkNull() { String schemaData = "{\r\n" + " \"type\": \"integer\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_4).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4).getSchema(schemaData); Result result = schema.walk(null, true); assertTrue(result.getErrors().isEmpty()); } @@ -175,7 +173,7 @@ void nullable() { + " }\r\n" + "}"; // nullable keyword enabled false - final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_7); + final SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7); final Schema validator = factory.getSchema(schemaData); final List errors = validator.validate(inputData, InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java index 4ed55be2b..fb6d8b1a3 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java @@ -1,6 +1,5 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -13,7 +12,7 @@ class UnevaluatedItemsTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index 0fb4ea033..159a2925d 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; - /** * UnevaluatedItemsValidatorTest. */ @@ -43,7 +41,7 @@ void unevaluatedItemsFalse() { + " \"unevaluatedItems\" : false\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -69,7 +67,7 @@ void unevaluatedItemsSchema() { + " \"unevaluatedItems\" : { \"type\" : \"string\" }\r\n" + "}"; String inputData = "[1,2,3]"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java index 9a677746d..767f59f78 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java @@ -1,7 +1,5 @@ package com.networknt.schema; -import com.networknt.schema.Specification.Version; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.TestFactory; @@ -14,7 +12,7 @@ class UnevaluatedPropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") Stream draft201909() { - return createTests(Version.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-tests.json"); + return createTests(SpecificationVersion.DRAFT_2019_09, "src/test/resources/schema/unevaluatedTests/unevaluated-tests.json"); } } diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 3992eb60b..6533fd10b 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.output.OutputUnit; /** @@ -61,7 +60,7 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() { + " \"key3\": \"value3\",\r\n" + " \"key4\": \"value4\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(2, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -116,7 +115,7 @@ void subschemaProcessing() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -144,7 +143,7 @@ void unevaluatedPropertiesSchema() { + " \"notallowed\": false\r\n" + " }\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(1, messages.size()); List assertions = messages.stream().collect(Collectors.toList()); @@ -189,7 +188,7 @@ void ref() { + " \"unevaluatedProperties\": false\r\n" + "}"; String inputData = "{ \"pontoons\": {}, \"wheels\": {}, \"surfboard\": \"2\" }"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); assertEquals(0, messages.size()); } @@ -228,7 +227,7 @@ void nestedRef() { schemas.put("https://www.example.org/PrimaryDeviceConfiguration.json", primaryDeviceConfiguration); schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2019_09, + .withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) .getSchema(schemaData); String inputData = "{ \"isPrimaryDevice\": true, \"roleName\": \"hello\" }"; diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index fc2ae30d9..0b21409a2 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -23,7 +23,7 @@ void testSchema1() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema1); List errors = jsonSchema.validate(jsonNode); @@ -37,7 +37,7 @@ void testSchema2() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema2); List errors = jsonSchema.validate(jsonNode); @@ -50,7 +50,7 @@ void testSchema3() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); - SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_7)).build(); + SchemaRegistry factory = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7)).build(); Schema jsonSchema = factory.getSchema(schema3); List errors = jsonSchema.validate(jsonNode); diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index aab1adce0..daaa2ac8d 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -83,7 +83,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { return null; } }; - SchemaRegistry instance = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -120,7 +120,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); @@ -150,7 +150,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -167,7 +167,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } catch (Exception ex) { fail("Unexpected exception thrown"); } - instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) + instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(example); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); @@ -176,7 +176,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { @Test void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); - SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4)) + SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json") ); diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index 635b04b45..cb203ef8a 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -37,7 +37,7 @@ class V4JsonSchemaTest { void testLoadingWithId() throws Exception { try (InputStream inputStream = new FileInputStream("src/test/resources/remotes/self_ref/selfRef.json")) { JsonNode schemaJson = mapper.readTree(inputStream); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); @SuppressWarnings("unused") Schema schema = factory.getSchema(schemaJson); } @@ -89,7 +89,7 @@ private List validateFailingFastSchemaFor(final String schemaFileName, fi final JsonNode schema = getJsonNodeFromResource(objectMapper, schemaFileName); final JsonNode dataFile = getJsonNodeFromResource(objectMapper, dataFileName); final SchemaRegistryConfig config = SchemaRegistryConfig.builder().failFast(true).build(); - return SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) + return SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config)) .getSchema(schema) .validate(dataFile); } diff --git a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java index 95497310a..779b051af 100644 --- a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java +++ b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java @@ -39,13 +39,13 @@ void testFromValueMissing() { @Test void testIfThenElseNotInV4() { - List list = ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4); + List list = ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("if"))); } @Test void testExclusiveMaximumNotInV4() { - List list = ValidatorTypeCode.getKeywords(Specification.Version.DRAFT_4); + List list = ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("exclusiveMaximum"))); } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 0f2a4563c..ff87bfc88 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.Specification.Version; import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; @@ -86,7 +85,7 @@ void noValidation() { messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); assertEquals("minimum", messages.iterator().next().getKeyword()); - assertEquals(Version.DRAFT_2020_12, schema.getSchemaContext().getDialect().getSpecification()); + assertEquals(SpecificationVersion.DRAFT_2020_12, schema.getSchemaContext().getDialect().getSpecificationVersion()); } @Test @@ -209,7 +208,7 @@ void customVocabulary() { .vocabularyFactory(vocabularyFactory) .build(); SchemaRegistry factory = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.dialectRegistry(new BasicDialectRegistry(dialect)).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java index c47f0e4c4..48c6b8f21 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntBasicRunner.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; /** * Basic Benchmark. @@ -26,7 +26,7 @@ public class NetworkntBasicRunner implements Callable { public NetworkntBasicRunner() { ObjectMapper objectMapper = new ObjectMapper(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_4); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4); try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ObjectReader reader = objectMapper.reader(); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java index af95452e5..d5dee00aa 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012OptionalPerf.java @@ -2,12 +2,12 @@ import java.util.concurrent.Callable; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; public class NetworkntTestSuite202012OptionalPerf { public static void main(String[] args) throws Exception { Callable runner = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); + SpecificationVersion.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); runner.call(); } } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java index ede2e752b..d8f8c576f 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuite202012RequiredPerf.java @@ -2,12 +2,12 @@ import java.util.concurrent.Callable; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; public class NetworkntTestSuite202012RequiredPerf { public static void main(String[] args) throws Exception { Callable runner = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); + SpecificationVersion.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); runner.call(); } } diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java index 2369ee2dc..1c639e14c 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteOptionalBenchmark.java @@ -18,7 +18,7 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; public class NetworkntTestSuiteOptionalBenchmark { public static final String VERSION_202012 = "2020-12"; @@ -33,17 +33,17 @@ public static class BenchmarkState { private String specification; private Callable draft202012Optional = new NetworkntTestSuiteRunner( - NetworkntTestSuiteTestCases.findTestCases(Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", + NetworkntTestSuiteTestCases.findTestCases(SpecificationVersion.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.optionalType())); private Callable draft201909Optional = new NetworkntTestSuiteRunner( - NetworkntTestSuiteTestCases.findTestCases(Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", + NetworkntTestSuiteTestCases.findTestCases(SpecificationVersion.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", TestCaseFilter.optionalType())); private Callable draft7Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.optionalType())); + .findTestCases(SpecificationVersion.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.optionalType())); private Callable draft6Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.optionalType())); + .findTestCases(SpecificationVersion.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.optionalType())); private Callable draft4Optional = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.optionalType())); + .findTestCases(SpecificationVersion.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.optionalType())); private Callable getTestSuite() { switch (specification) { diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java index 8cf09366c..60b24d17b 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteRequiredBenchmark.java @@ -18,7 +18,7 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; public class NetworkntTestSuiteRequiredBenchmark { public static final String VERSION_202012 = "2020-12"; @@ -33,15 +33,15 @@ public static class BenchmarkState { private String specification; private Callable draft202012 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - Version.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); + SpecificationVersion.DRAFT_2020_12, "src/test/suite/tests/draft2020-12", TestCaseFilter.requiredType())); private Callable draft201909 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases.findTestCases( - Version.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", TestCaseFilter.requiredType())); + SpecificationVersion.DRAFT_2019_09, "src/test/suite/tests/draft2019-09", TestCaseFilter.requiredType())); private Callable draft7 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.requiredType())); + .findTestCases(SpecificationVersion.DRAFT_7, "src/test/suite/tests/draft7", TestCaseFilter.requiredType())); private Callable draft6 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.requiredType())); + .findTestCases(SpecificationVersion.DRAFT_6, "src/test/suite/tests/draft6", TestCaseFilter.requiredType())); private Callable draft4 = new NetworkntTestSuiteRunner(NetworkntTestSuiteTestCases - .findTestCases(Version.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.requiredType())); + .findTestCases(SpecificationVersion.DRAFT_4, "src/test/suite/tests/draft4", TestCaseFilter.requiredType())); private Callable getTestSuite() { switch (specification) { diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index 139c566ca..67cc08578 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -18,7 +18,7 @@ import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaRegistryConfig; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.SchemaLoader; @@ -38,11 +38,11 @@ private static List findTestCasePaths(String basePath, Predicate findTestCases(Version defaultVersion, String basePath) { + public static List findTestCases(SpecificationVersion defaultVersion, String basePath) { return findTestCases(defaultVersion, basePath, path -> true); } - public static List findTestCases(Version defaultVersion, String basePath, + public static List findTestCases(SpecificationVersion defaultVersion, String basePath, Predicate filter) { SchemaLoader schemaLoader = new SchemaLoader() { @Override diff --git a/src/test/java/com/networknt/schema/format/IriFormatTest.java b/src/test/java/com/networknt/schema/format/IriFormatTest.java index af50ea916..84479f45a 100644 --- a/src/test/java/com/networknt/schema/format/IriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriFormatTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; class IriFormatTest { @@ -35,7 +35,7 @@ void uriShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -47,7 +47,7 @@ void queryWithBracketsShouldFail() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); @@ -59,7 +59,7 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -71,7 +71,7 @@ void iriShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -83,7 +83,7 @@ void noAuthorityShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -94,7 +94,7 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -105,7 +105,7 @@ void noPathShouldPass() { + " \"format\": \"iri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java index 6685037de..a05a262a5 100644 --- a/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/IriReferenceFormatTest.java @@ -26,7 +26,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaRegistryConfig; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; class IriReferenceFormatTest { @@ -38,7 +38,7 @@ void uriShouldPass() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON); @@ -53,7 +53,7 @@ void queryWithBracketsShouldFail() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON); @@ -68,7 +68,7 @@ void queryWithEncodedBracketsShouldPass() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON); @@ -83,7 +83,7 @@ void iriShouldPass() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON); @@ -98,7 +98,7 @@ void noAuthorityShouldPass() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"http://\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -112,7 +112,7 @@ void noSchemeNoAuthorityShouldPass() { SchemaRegistryConfig config = SchemaRegistryConfig.builder().formatAssertionsEnabled(true).build(); Schema schema = SchemaRegistry - .withDefaultDialect(Version.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) + .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config)) .getSchema(schemaData); List messages = schema.validate("\"//\"", InputFormat.JSON); assertTrue(messages.isEmpty()); @@ -124,7 +124,7 @@ void noPathShouldPass() { + " \"format\": \"iri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/TimeFormatTest.java b/src/test/java/com/networknt/schema/format/TimeFormatTest.java index f2a09fb02..2081d2203 100644 --- a/src/test/java/com/networknt/schema/format/TimeFormatTest.java +++ b/src/test/java/com/networknt/schema/format/TimeFormatTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; class TimeFormatTest { @@ -58,7 +58,7 @@ void validTimeShouldPass(ValidTimeFormatInput input) { String inputData = "\""+input.format+"\""; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -87,7 +87,7 @@ void invalidTimeShouldFail(InvalidTimeFormatInput input) { String inputData = "\""+input.format+"\""; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/format/UriFormatTest.java b/src/test/java/com/networknt/schema/format/UriFormatTest.java index b12831def..c7a5c83ca 100644 --- a/src/test/java/com/networknt/schema/format/UriFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriFormatTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; class UriFormatTest { @@ -35,7 +35,7 @@ void uriShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -46,7 +46,7 @@ void queryWithBracketsShouldFail() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); @@ -58,7 +58,7 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -70,7 +70,7 @@ void iriShouldFail() { + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); @@ -81,7 +81,7 @@ void noAuthorityShouldPass() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -92,7 +92,7 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -102,7 +102,7 @@ void noPathShouldPass() { String schemaData = "{\r\n" + " \"format\": \"uri\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java index 4a83504d9..5092c3c01 100644 --- a/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java +++ b/src/test/java/com/networknt/schema/format/UriReferenceFormatTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; class UriReferenceFormatTest { @@ -35,7 +35,7 @@ void uriShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -47,7 +47,7 @@ void queryWithBracketsShouldFail() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter[test]=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); @@ -59,7 +59,7 @@ void queryWithEncodedBracketsShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/product.pdf?filter%5Btest%5D=1\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); @@ -71,7 +71,7 @@ void iriShouldFail() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"https://test.com/assets/produktdatenblätter.pdf\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertFalse(messages.isEmpty()); @@ -83,7 +83,7 @@ void noAuthorityShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"http://\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -94,7 +94,7 @@ void noSchemeNoAuthorityShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"//\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } @@ -105,7 +105,7 @@ void noPathShouldPass() { + " \"format\": \"uri-reference\"\r\n" + "}"; - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); List messages = schema.validate("\"about:\"", InputFormat.JSON, executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertTrue(messages.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index b488947c4..f92bd9c22 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -26,7 +26,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.Error; @@ -39,7 +39,7 @@ class OpenApi31Test { */ @Test void validateVocabulary() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaMappers(schemaMappers -> schemaMappers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); Schema schema = factory diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java index 2b50198c6..ec1e71f75 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java @@ -25,7 +25,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; /** * Test for AllowSchemaLoader. @@ -34,7 +34,7 @@ class AllowSchemaLoaderTest { @Test void integration() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders .add(new AllowSchemaLoader(iri -> iri.toString().startsWith("classpath:"))))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, diff --git a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java index cba2728fd..15f2ed6c3 100644 --- a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java @@ -23,7 +23,7 @@ import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; /** * Test for DisallowSchemaLoader. @@ -32,7 +32,7 @@ class DisallowSchemaLoaderTest { @Test void integration() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, builder -> builder + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder .schemaLoaders(schemaLoaders -> schemaLoaders.add(DisallowSchemaLoader.getInstance()))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index debd40844..207203b3f 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -34,7 +34,7 @@ import com.networknt.schema.InputFormat; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.serialization.JsonNodeReader; @@ -86,7 +86,7 @@ void jsonLocation() { String inputData = "{\r\n" + " \"startDate\": \"1\"\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); Schema schema = factory.getSchema(schemaData, InputFormat.JSON); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { @@ -131,7 +131,7 @@ void yamlLocation() { + " minLength: 6\r\n"; String inputData = "---\r\n" + "startDate: '1'\r\n"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12, + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); Schema schema = factory.getSchema(schemaData, InputFormat.YAML); List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 22c78e80f..13a3710dd 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -40,7 +40,7 @@ import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.Specification.Version; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; @@ -103,7 +103,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -186,7 +186,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -274,7 +274,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -351,7 +351,7 @@ public WalkFlow onWalkStart(WalkEvent walkEvent) { public void onWalkEnd(WalkEvent walkEvent, List errors) { } }).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_7).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7).getSchema(schemaData); String inputData = "{\r\n" + " \"tags\": [\r\n" + " {\r\n" @@ -403,7 +403,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09) + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09) .getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09)); String inputData = "{\r\n" @@ -569,7 +569,7 @@ void applyDefaults() throws JsonProcessingException { WalkConfig walkConfig = WalkConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertEquals("{\"s\":\"S\",\"ref\":\"REF\"}", inputNode.toString()); @@ -626,7 +626,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); @@ -686,7 +686,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { }) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) @@ -759,7 +759,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @@ -832,7 +832,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { WalkConfig walkConfig = WalkConfig.builder() .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); JsonNode inputNode = JsonMapperFactory.getInstance().readTree("{}"); Result result = schema.walk(inputNode, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @@ -886,7 +886,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListenerRunner(itemWalkListenerRunner) .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2019_09).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09).getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); @SuppressWarnings("unchecked") @@ -952,7 +952,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { .itemWalkListenerRunner(itemWalkListenerRunner) .propertyWalkListenerRunner(propertyWalkListenerRunner) .build(); - Schema schema = SchemaRegistry.withDefaultDialect(Version.DRAFT_2020_12).getSchema(schemaData); + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12).getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); List items = result.getExecutionContext().getCollectorContext().get("items"); From f2181f16a81d0bd97910a2d208493ab36d089a18 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:44:11 +0800 Subject: [PATCH 31/74] Rename ValidatorTypeCode to Keywords --- .../java/com/networknt/schema/Schema.java | 8 +- .../java/com/networknt/schema/Vocabulary.java | 78 +++++++++---------- .../com/networknt/schema/dialect/Dialect.java | 10 +-- .../networknt/schema/dialect/Draft201909.java | 4 +- .../networknt/schema/dialect/Draft202012.java | 4 +- .../com/networknt/schema/dialect/Draft4.java | 4 +- .../com/networknt/schema/dialect/Draft6.java | 4 +- .../com/networknt/schema/dialect/Draft7.java | 4 +- .../networknt/schema/dialect/OpenApi30.java | 54 ++++++------- .../networknt/schema/dialect/OpenApi31.java | 4 +- .../AdditionalPropertiesValidator.java | 2 +- .../schema/keyword/AllOfValidator.java | 2 +- .../schema/keyword/AnyOfValidator.java | 2 +- .../schema/keyword/ConstValidator.java | 2 +- .../schema/keyword/ContainsValidator.java | 16 ++-- .../keyword/ContentEncodingValidator.java | 2 +- .../keyword/ContentMediaTypeValidator.java | 2 +- .../schema/keyword/DependenciesValidator.java | 2 +- .../schema/keyword/DependentRequired.java | 2 +- .../schema/keyword/DependentSchemas.java | 2 +- .../keyword/DiscriminatorValidator.java | 2 +- .../schema/keyword/DynamicRefValidator.java | 6 +- .../schema/keyword/EnumValidator.java | 2 +- .../keyword/ExclusiveMaximumValidator.java | 2 +- .../keyword/ExclusiveMinimumValidator.java | 2 +- .../schema/keyword/FalseValidator.java | 2 +- .../schema/keyword/FormatKeyword.java | 2 +- .../networknt/schema/keyword/IfValidator.java | 2 +- .../schema/keyword/ItemsValidator.java | 10 +-- .../schema/keyword/ItemsValidator202012.java | 6 +- .../{ValidatorTypeCode.java => Keywords.java} | 18 ++--- .../schema/keyword/MaxItemsValidator.java | 2 +- .../schema/keyword/MaxLengthValidator.java | 2 +- .../keyword/MaxPropertiesValidator.java | 2 +- .../schema/keyword/MaximumValidator.java | 2 +- .../schema/keyword/MinItemsValidator.java | 2 +- .../schema/keyword/MinLengthValidator.java | 2 +- .../keyword/MinMaxContainsValidator.java | 2 +- .../keyword/MinPropertiesValidator.java | 2 +- .../schema/keyword/MinimumValidator.java | 2 +- .../schema/keyword/MultipleOfValidator.java | 2 +- .../schema/keyword/NotAllowedValidator.java | 2 +- .../schema/keyword/NotValidator.java | 2 +- .../schema/keyword/OneOfValidator.java | 2 +- .../keyword/PatternPropertiesValidator.java | 2 +- .../schema/keyword/PatternValidator.java | 2 +- .../schema/keyword/PrefixItemsValidator.java | 6 +- .../schema/keyword/PropertiesValidator.java | 6 +- .../keyword/PropertyNamesValidator.java | 2 +- .../schema/keyword/ReadOnlyValidator.java | 2 +- .../schema/keyword/RecursiveRefValidator.java | 8 +- .../schema/keyword/RefValidator.java | 6 +- .../schema/keyword/RequiredValidator.java | 2 +- .../schema/keyword/TrueValidator.java | 2 +- .../schema/keyword/TypeValidator.java | 2 +- .../keyword/UnevaluatedItemsValidator.java | 2 +- .../UnevaluatedPropertiesValidator.java | 2 +- .../schema/keyword/UnionTypeValidator.java | 6 +- .../schema/keyword/UniqueItemsValidator.java | 2 +- .../schema/keyword/WriteOnlyValidator.java | 2 +- .../schema/AbstractJsonSchemaTest.java | 4 +- .../com/networknt/schema/IfValidatorTest.java | 10 +-- .../com/networknt/schema/Issue461Test.java | 4 +- .../com/networknt/schema/Issue467Test.java | 4 +- .../schema/Issue769ContainsTest.java | 10 +-- .../com/networknt/schema/JsonWalkTest.java | 10 +-- ...torTypeCodeTest.java => KeywordsTest.java} | 16 ++-- .../schema/NotAllowedValidatorTest.java | 4 +- .../schema/walk/WalkListenerTest.java | 8 +- 69 files changed, 206 insertions(+), 206 deletions(-) rename src/main/java/com/networknt/schema/keyword/{ValidatorTypeCode.java => Keywords.java} (93%) rename src/test/java/com/networknt/schema/{ValidatorTypeCodeTest.java => KeywordsTest.java} (61%) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 7eed958ec..45e9a90f4 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -34,7 +34,7 @@ import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.utils.JsonNodes; /** @@ -186,13 +186,13 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) { SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword()); Error error = Error.builder() - .messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue()) + .messageKey(Keywords.ID.getValue()).keyword(Keywords.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) .arguments(id, schemaContext.getDialect().getIdKeyword(), idSchemaLocation) .schemaLocation(idSchemaLocation) .schemaNode(schemaNode) .messageFormatter(args -> schemaContext.getSchemaRegistryConfig().getMessageSource().getMessage( - ValidatorTypeCode.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args)) + Keywords.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args)) .build(); throw new InvalidSchemaException(error); } @@ -506,7 +506,7 @@ public Schema getSubSchema(NodePath fragment) { } if (found == null) { Error error = Error.builder() - .keyword(ValidatorTypeCode.REF.getValue()).messageKey("internal.unresolvedRef") + .keyword(Keywords.REF.getValue()).messageKey("internal.unresolvedRef") .message("Reference {0} cannot be resolved") .instanceLocation(schemaLocation.getFragment()) .schemaLocation(schemaLocation) diff --git a/src/main/java/com/networknt/schema/Vocabulary.java b/src/main/java/com/networknt/schema/Vocabulary.java index c600ae407..6dc019b14 100644 --- a/src/main/java/com/networknt/schema/Vocabulary.java +++ b/src/main/java/com/networknt/schema/Vocabulary.java @@ -23,7 +23,7 @@ import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Represents a vocabulary in meta-schema. @@ -35,75 +35,75 @@ public class Vocabulary { // 2019-09 public static final Vocabulary DRAFT_2019_09_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core", new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), new NonValidationKeyword("$anchor"), - ValidatorTypeCode.REF, ValidatorTypeCode.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"), + Keywords.REF, Keywords.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"), - ValidatorTypeCode.UNEVALUATED_ITEMS, ValidatorTypeCode.ITEMS, ValidatorTypeCode.CONTAINS, - ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.UNEVALUATED_PROPERTIES, - ValidatorTypeCode.PROPERTIES, ValidatorTypeCode.PATTERN_PROPERTIES, ValidatorTypeCode.DEPENDENT_SCHEMAS, - ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"), - new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF, - ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT); + Keywords.UNEVALUATED_ITEMS, Keywords.ITEMS, Keywords.CONTAINS, + Keywords.ADDITIONAL_PROPERTIES, Keywords.UNEVALUATED_PROPERTIES, + Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS, + Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"), + new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF, + Keywords.ONE_OF, Keywords.NOT); public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary( - "https://json-schema.org/draft/2019-09/vocab/validation", ValidatorTypeCode.MULTIPLE_OF, - ValidatorTypeCode.MAXIMUM, ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM, - ValidatorTypeCode.EXCLUSIVE_MINIMUM, ValidatorTypeCode.MAX_LENGTH, ValidatorTypeCode.MIN_LENGTH, - ValidatorTypeCode.PATTERN, ValidatorTypeCode.MAX_ITEMS, ValidatorTypeCode.MIN_ITEMS, - ValidatorTypeCode.UNIQUE_ITEMS, ValidatorTypeCode.MAX_CONTAINS, ValidatorTypeCode.MIN_CONTAINS, - ValidatorTypeCode.MAX_PROPERTIES, ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED, - ValidatorTypeCode.DEPENDENT_REQUIRED, ValidatorTypeCode.CONST, ValidatorTypeCode.ENUM, - ValidatorTypeCode.TYPE); + "https://json-schema.org/draft/2019-09/vocab/validation", Keywords.MULTIPLE_OF, + Keywords.MAXIMUM, Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, + Keywords.EXCLUSIVE_MINIMUM, Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, + Keywords.PATTERN, Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, + Keywords.UNIQUE_ITEMS, Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, + Keywords.MAX_PROPERTIES, Keywords.MIN_PROPERTIES, Keywords.REQUIRED, + Keywords.DEPENDENT_REQUIRED, Keywords.CONST, Keywords.ENUM, + Keywords.TYPE); public static final Vocabulary DRAFT_2019_09_META_DATA = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), - ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples")); + Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples")); public static final Vocabulary DRAFT_2019_09_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format", - ValidatorTypeCode.FORMAT); + Keywords.FORMAT); public static final Vocabulary DRAFT_2019_09_CONTENT = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/content", new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentSchema")); // 2020-12 public static final Vocabulary DRAFT_2020_12_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core", - new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), ValidatorTypeCode.REF, - new NonValidationKeyword("$anchor"), ValidatorTypeCode.DYNAMIC_REF, + new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), Keywords.REF, + new NonValidationKeyword("$anchor"), Keywords.DYNAMIC_REF, new NonValidationKeyword("$dynamicAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/applicator", ValidatorTypeCode.PREFIX_ITEMS, - ValidatorTypeCode.ITEMS_202012, ValidatorTypeCode.CONTAINS, ValidatorTypeCode.ADDITIONAL_PROPERTIES, - ValidatorTypeCode.PROPERTIES, ValidatorTypeCode.PATTERN_PROPERTIES, ValidatorTypeCode.DEPENDENT_SCHEMAS, - ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"), - new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF, - ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT); + "https://json-schema.org/draft/2020-12/vocab/applicator", Keywords.PREFIX_ITEMS, + Keywords.ITEMS_202012, Keywords.CONTAINS, Keywords.ADDITIONAL_PROPERTIES, + Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS, + Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"), + new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF, + Keywords.ONE_OF, Keywords.NOT); public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/unevaluated", ValidatorTypeCode.UNEVALUATED_ITEMS, - ValidatorTypeCode.UNEVALUATED_PROPERTIES); + "https://json-schema.org/draft/2020-12/vocab/unevaluated", Keywords.UNEVALUATED_ITEMS, + Keywords.UNEVALUATED_PROPERTIES); public static final Vocabulary DRAFT_2020_12_VALIDATION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/validation", ValidatorTypeCode.TYPE, ValidatorTypeCode.CONST, - ValidatorTypeCode.ENUM, ValidatorTypeCode.MULTIPLE_OF, ValidatorTypeCode.MAXIMUM, - ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM, ValidatorTypeCode.EXCLUSIVE_MINIMUM, - ValidatorTypeCode.MAX_LENGTH, ValidatorTypeCode.MIN_LENGTH, ValidatorTypeCode.PATTERN, - ValidatorTypeCode.MAX_ITEMS, ValidatorTypeCode.MIN_ITEMS, ValidatorTypeCode.UNIQUE_ITEMS, - ValidatorTypeCode.MAX_CONTAINS, ValidatorTypeCode.MIN_CONTAINS, ValidatorTypeCode.MAX_PROPERTIES, - ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED, ValidatorTypeCode.DEPENDENT_REQUIRED); + "https://json-schema.org/draft/2020-12/vocab/validation", Keywords.TYPE, Keywords.CONST, + Keywords.ENUM, Keywords.MULTIPLE_OF, Keywords.MAXIMUM, + Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, Keywords.EXCLUSIVE_MINIMUM, + Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, Keywords.PATTERN, + Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, Keywords.UNIQUE_ITEMS, + Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, Keywords.MAX_PROPERTIES, + Keywords.MIN_PROPERTIES, Keywords.REQUIRED, Keywords.DEPENDENT_REQUIRED); public static final Vocabulary DRAFT_2020_12_META_DATA = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), - ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples")); + Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples")); public static final Vocabulary DRAFT_2020_12_FORMAT_ANNOTATION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/format-annotation", ValidatorTypeCode.FORMAT); + "https://json-schema.org/draft/2020-12/vocab/format-annotation", Keywords.FORMAT); public static final Vocabulary DRAFT_2020_12_FORMAT_ASSERTION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/format-assertion", ValidatorTypeCode.FORMAT); + "https://json-schema.org/draft/2020-12/vocab/format-assertion", Keywords.FORMAT); public static final Vocabulary DRAFT_2020_12_CONTENT = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/content", new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentSchema")); // OpenAPI 3.1 public static final Vocabulary OPENAPI_3_1_BASE = new Vocabulary("https://spec.openapis.org/oas/3.1/vocab/base", - new AnnotationKeyword("example"), ValidatorTypeCode.DISCRIMINATOR, new AnnotationKeyword("externalDocs"), + new AnnotationKeyword("example"), Keywords.DISCRIMINATOR, new AnnotationKeyword("externalDocs"), new AnnotationKeyword("xml")); private final String iri; diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index df3d230f8..6858722c4 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -34,7 +34,7 @@ import com.networknt.schema.keyword.KeywordFactory; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.UnknownKeywordFactory; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,8 +93,8 @@ private Map createKeywordsMap(Map kwords, Map< for (Map.Entry type : kwords.entrySet()) { String keywordName = type.getKey(); Keyword keyword = type.getValue(); - if (ValidatorTypeCode.FORMAT.getValue().equals(keywordName)) { - if (!(keyword instanceof FormatKeyword) && !ValidatorTypeCode.FORMAT.equals(keyword)) { + if (Keywords.FORMAT.getValue().equals(keywordName)) { + if (!(keyword instanceof FormatKeyword) && !Keywords.FORMAT.equals(keyword)) { throw new IllegalArgumentException("Overriding the keyword 'format' is not supported. Use the formatKeywordFactory and extend the FormatKeyword."); } // Indicate that the format keyword needs to be created @@ -455,9 +455,9 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation if (schemaContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) { return null; } - if (ValidatorTypeCode.DISCRIMINATOR.getValue().equals(keyword) + if (Keywords.DISCRIMINATOR.getValue().equals(keyword) && schemaContext.isDiscriminatorKeywordEnabled()) { - return ValidatorTypeCode.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, + return Keywords.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); } kw = this.builder.unknownKeywordFactory != null diff --git a/src/main/java/com/networknt/schema/dialect/Draft201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java index a71800f13..6559153a7 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Draft 2019-09 dialect. @@ -35,7 +35,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2019_09) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2019_09)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2019_09)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java index 7cfa0cebf..9ffcc41b7 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Draft 2020-12 dialect. @@ -36,7 +36,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2020_12)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java index 0703a2903..c1a952c4e 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Draft 4 dialect. @@ -22,7 +22,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_4) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_4)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java index fbdab7225..5ef0be929 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Draft 6 dialect. @@ -23,7 +23,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_6) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_6)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_6)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java index d26cbb82d..92a97979a 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * Draft 7 dialect. @@ -22,7 +22,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_7) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_7)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_7)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index 74bea5f8b..5eda0c298 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * OpenAPI 3.0. @@ -24,42 +24,42 @@ private static class Holder { .formats(Formats.DEFAULT) .keywords(Arrays.asList( new AnnotationKeyword("title"), - ValidatorTypeCode.PATTERN, - ValidatorTypeCode.REQUIRED, - ValidatorTypeCode.ENUM, - ValidatorTypeCode.MINIMUM, - ValidatorTypeCode.MAXIMUM, - ValidatorTypeCode.MULTIPLE_OF, - ValidatorTypeCode.MIN_LENGTH, - ValidatorTypeCode.MAX_LENGTH, - ValidatorTypeCode.MIN_ITEMS, - ValidatorTypeCode.MAX_ITEMS, - ValidatorTypeCode.UNIQUE_ITEMS, - ValidatorTypeCode.MIN_PROPERTIES, - ValidatorTypeCode.MAX_PROPERTIES, + Keywords.PATTERN, + Keywords.REQUIRED, + Keywords.ENUM, + Keywords.MINIMUM, + Keywords.MAXIMUM, + Keywords.MULTIPLE_OF, + Keywords.MIN_LENGTH, + Keywords.MAX_LENGTH, + Keywords.MIN_ITEMS, + Keywords.MAX_ITEMS, + Keywords.UNIQUE_ITEMS, + Keywords.MIN_PROPERTIES, + Keywords.MAX_PROPERTIES, - ValidatorTypeCode.TYPE, - ValidatorTypeCode.FORMAT, + Keywords.TYPE, + Keywords.FORMAT, new AnnotationKeyword("description"), - ValidatorTypeCode.ITEMS, - ValidatorTypeCode.PROPERTIES, - ValidatorTypeCode.ADDITIONAL_PROPERTIES, + Keywords.ITEMS, + Keywords.PROPERTIES, + Keywords.ADDITIONAL_PROPERTIES, new AnnotationKeyword("default"), - ValidatorTypeCode.ALL_OF, - ValidatorTypeCode.ONE_OF, - ValidatorTypeCode.ANY_OF, - ValidatorTypeCode.NOT, + Keywords.ALL_OF, + Keywords.ONE_OF, + Keywords.ANY_OF, + Keywords.NOT, new AnnotationKeyword("deprecated"), - ValidatorTypeCode.DISCRIMINATOR, + Keywords.DISCRIMINATOR, new AnnotationKeyword("example"), new AnnotationKeyword("externalDocs"), new NonValidationKeyword("nullable"), - ValidatorTypeCode.READ_ONLY, - ValidatorTypeCode.WRITE_ONLY, + Keywords.READ_ONLY, + Keywords.WRITE_ONLY, new AnnotationKeyword("xml"), - ValidatorTypeCode.REF + Keywords.REF )) .build(); } diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java index d3442f554..f8b667f90 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** * OpenAPI 3.1. @@ -37,7 +37,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2020_12)) + .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index 6318f3637..ffd3e7012 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -47,7 +47,7 @@ public class AdditionalPropertiesValidator extends BaseKeywordValidator { public AdditionalPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { allowAdditionalProperties = schemaNode.booleanValue(); additionalPropertiesSchema = null; diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index f6cd4e1f8..7e2b160f3 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -37,7 +37,7 @@ public class AllOfValidator extends BaseKeywordValidator { private final List schemas; public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index c8432c410..ff9bb0a82 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -41,7 +41,7 @@ public class AnyOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; public AnyOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index 03b65029b..0a6525da9 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -28,7 +28,7 @@ public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { public ConstValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 39e4b5cd9..2e32b1f58 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -48,7 +48,7 @@ public class ContainsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes @@ -61,14 +61,14 @@ public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); JsonNode parentSchemaNode = parentSchema.getSchemaNode(); Optional maxNode = Optional - .ofNullable(parentSchemaNode.get(ValidatorTypeCode.MAX_CONTAINS.getValue())) + .ofNullable(parentSchemaNode.get(Keywords.MAX_CONTAINS.getValue())) .filter(JsonNode::canConvertToExactIntegral); if (maxNode.isPresent()) { currentMax = maxNode.get().intValue(); } Optional minNode = Optional - .ofNullable(parentSchemaNode.get(ValidatorTypeCode.MIN_CONTAINS.getValue())) + .ofNullable(parentSchemaNode.get(Keywords.MIN_CONTAINS.getValue())) .filter(JsonNode::canConvertToExactIntegral); if (minNode.isPresent()) { currentMin = minNode.get().intValue(); @@ -114,13 +114,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode m = this.min; } if (actual < m) { - boundsViolated(executionContext, isMinV201909 ? ValidatorTypeCode.MIN_CONTAINS : ValidatorTypeCode.CONTAINS, + boundsViolated(executionContext, isMinV201909 ? Keywords.MIN_CONTAINS : Keywords.CONTAINS, executionContext.getExecutionConfig().getLocale(), node, instanceLocation, m); } if (this.max != null && actual > this.max) { - boundsViolated(executionContext, isMinV201909 ? ValidatorTypeCode.MAX_CONTAINS : ValidatorTypeCode.CONTAINS, + boundsViolated(executionContext, isMinV201909 ? Keywords.MAX_CONTAINS : Keywords.CONTAINS, executionContext.getExecutionConfig().getLocale(), node, instanceLocation, this.max); } @@ -184,12 +184,12 @@ public void preloadSchema() { collectAnnotations(); // cache the flag } - private void boundsViolated(ExecutionContext executionContext, ValidatorTypeCode validatorTypeCode, Locale locale, + private void boundsViolated(ExecutionContext executionContext, Keywords validatorTypeCode, Locale locale, JsonNode instanceNode, NodePath instanceLocation, int bounds) { String messageKey = "contains"; - if (ValidatorTypeCode.MIN_CONTAINS.equals(validatorTypeCode)) { + if (Keywords.MIN_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MIN; - } else if (ValidatorTypeCode.MAX_CONTAINS.equals(validatorTypeCode)) { + } else if (Keywords.MAX_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MAX; } executionContext.addError(error().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 7e7107efb..39d7e39af 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -47,7 +47,7 @@ public class ContentEncodingValidator extends BaseKeywordValidator { */ public ContentEncodingValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, + super(Keywords.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentEncoding = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 41e22a188..e581e178e 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -52,7 +52,7 @@ public class ContentMediaTypeValidator extends BaseKeywordValidator { */ public ContentMediaTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index a0c72b899..807402ad9 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -43,7 +43,7 @@ public class DependenciesValidator extends BaseKeywordValidator implements Keywo */ public DependenciesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 77a7bf2bc..2d4e6a1c4 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -33,7 +33,7 @@ public class DependentRequired extends BaseKeywordValidator implements KeywordVa public DependentRequired(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 76c919388..252dd6d0f 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -33,7 +33,7 @@ public class DependentSchemas extends BaseKeywordValidator { public DependentSchemas(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 5d0df3246..824ef63cb 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -41,7 +41,7 @@ public class DiscriminatorValidator extends BaseKeywordValidator { public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, + super(Keywords.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; if (discriminator != null) { diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index d8f74c1c5..50a4b7489 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -37,7 +37,7 @@ public class DynamicRefValidator extends BaseKeywordValidator { protected final SchemaRef schema; public DynamicRefValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } @@ -99,7 +99,7 @@ private static String resolve(Schema parentSchema, String refValue) { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { Schema refSchema = this.schema.getSchema(); if (refSchema == null) { - Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + Error error = error().keyword(Keywords.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); @@ -115,7 +115,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. Schema refSchema = this.schema.getSchema(); if (refSchema == null) { - Error error = error().keyword(ValidatorTypeCode.DYNAMIC_REF.getValue()) + Error error = error().keyword(Keywords.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 6ccab6e9f..5654fc151 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -49,7 +49,7 @@ static String asText(JsonNode node) { } public EnumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 831da1f76..4d2e90373 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -37,7 +37,7 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; public ExclusiveMaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMaximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index ac9a00f30..e50b83ed7 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -41,7 +41,7 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMinimum; public ExclusiveMinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMinimum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index 6e44f3ff4..ac864a0d0 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -29,7 +29,7 @@ public class FalseValidator extends BaseKeywordValidator implements KeywordValid private final String reason; public FalseValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 5a5922e58..54b13b72d 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -35,7 +35,7 @@ public class FormatKeyword implements Keyword { private final Map formats; public FormatKeyword(Map formats) { - this(ValidatorTypeCode.FORMAT, formats); + this(Keywords.FORMAT, formats); } public FormatKeyword(Keyword type, Map formats) { diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 4084ac733..110c9bb5f 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -37,7 +37,7 @@ public class IfValidator extends BaseKeywordValidator { private final Schema elseSchema; public IfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Schema foundIfSchema = null; Schema foundThenSchema = null; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 3dff9a46e..5d9d14bf4 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -47,7 +47,7 @@ public class ItemsValidator extends BaseKeywordValidator { private final JsonNode additionalItemsSchemaNode; public ItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Boolean additionalItems = null; @@ -242,10 +242,10 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root n = defaultNode; } } - walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, ValidatorTypeCode.ITEMS.getValue()); + walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, Keywords.ITEMS.getValue()); } } else { - walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, ValidatorTypeCode.ITEMS.getValue()); + walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, Keywords.ITEMS.getValue()); } } else if (this.tupleSchema != null) { @@ -266,10 +266,10 @@ else if (this.tupleSchema != null) { } } walkSchema(executionContext, this.tupleSchema.get(i), n, rootNode, instanceLocation.append(i), - shouldValidateSchema, ValidatorTypeCode.ITEMS.getValue()); + shouldValidateSchema, Keywords.ITEMS.getValue()); } else { walkSchema(executionContext, this.tupleSchema.get(i), null, rootNode, instanceLocation.append(i), - shouldValidateSchema, ValidatorTypeCode.ITEMS.getValue()); + shouldValidateSchema, Keywords.ITEMS.getValue()); } } if (this.additionalSchema != null) { diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 98633b7f0..b820df321 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -39,7 +39,7 @@ public class ItemsValidator202012 extends BaseKeywordValidator { public ItemsValidator202012(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, + super(Keywords.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); @@ -151,7 +151,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, - ValidatorTypeCode.ITEMS.getValue(), + Keywords.ITEMS.getValue(), node, rootNode, instanceLocation, @@ -163,7 +163,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js } executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, - ValidatorTypeCode.ITEMS.getValue(), + Keywords.ITEMS.getValue(), node, rootNode, instanceLocation, diff --git a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java b/src/main/java/com/networknt/schema/keyword/Keywords.java similarity index 93% rename from src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java rename to src/main/java/com/networknt/schema/keyword/Keywords.java index 15b565744..44cfe19f4 100644 --- a/src/main/java/com/networknt/schema/keyword/ValidatorTypeCode.java +++ b/src/main/java/com/networknt/schema/keyword/Keywords.java @@ -61,7 +61,7 @@ EnumSet getVersions() { } } -public enum ValidatorTypeCode implements Keyword { +public enum Keywords implements Keyword { ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, VersionCode.MaxV7), ALL_OF("allOf", AllOfValidator::new, VersionCode.MaxV7), ANY_OF("anyOf", AnyOfValidator::new, VersionCode.MaxV7), @@ -119,10 +119,10 @@ public enum ValidatorTypeCode implements Keyword { WRITE_ONLY("writeOnly", WriteOnlyValidator::new, VersionCode.V7), ; - private static final Map CONSTANTS = new HashMap<>(); + private static final Map CONSTANTS = new HashMap<>(); static { - for (ValidatorTypeCode c : values()) { + for (Keywords c : values()) { CONSTANTS.put(c.value, c); } } @@ -131,15 +131,15 @@ public enum ValidatorTypeCode implements Keyword { private final ValidatorFactory validatorFactory; private final VersionCode versionCode; - ValidatorTypeCode(String value, ValidatorFactory validatorFactory, VersionCode versionCode) { + Keywords(String value, ValidatorFactory validatorFactory, VersionCode versionCode) { this.value = value; this.validatorFactory = validatorFactory; this.versionCode = versionCode; } - public static List getKeywords(SpecificationVersion versionFlag) { - final List result = new ArrayList<>(); - for (ValidatorTypeCode keyword : values()) { + public static List getKeywords(SpecificationVersion versionFlag) { + final List result = new ArrayList<>(); + for (Keywords keyword : values()) { if (keyword.getVersionCode().getVersions().contains(versionFlag)) { result.add(keyword); } @@ -147,8 +147,8 @@ public static List getKeywords(SpecificationVersion versionFl return result; } - public static ValidatorTypeCode fromValue(String value) { - ValidatorTypeCode constant = CONSTANTS.get(value); + public static Keywords fromValue(String value) { + Keywords constant = CONSTANTS.get(value); if (constant == null) { throw new IllegalArgumentException(value); } diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index 55bb6f96f..ca09888e2 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -30,7 +30,7 @@ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordVa private final int max; public MaxItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 2ede3f3ba..ccc1a9d89 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -32,7 +32,7 @@ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordV private final int maxLength; public MaxLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index 7091a280d..fc58b0dec 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -31,7 +31,7 @@ public class MaxPropertiesValidator extends BaseKeywordValidator implements Keyw public MaxPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 25a41b68f..a17dabdbc 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -42,7 +42,7 @@ public class MaximumValidator extends BaseKeywordValidator { public MaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("maximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index a154a0066..bd0a24a6d 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -30,7 +30,7 @@ public class MinItemsValidator extends BaseKeywordValidator implements KeywordVa private int min = 0; public MinItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index f97f545ea..38eef6681 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -32,7 +32,7 @@ public class MinLengthValidator extends BaseKeywordValidator implements KeywordV private int minLength; public MinLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { minLength = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 7f8d88e76..3936ba57b 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -22,7 +22,7 @@ public class MinMaxContainsValidator extends BaseKeywordValidator { public MinMaxContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Set analysis = null; int min = 1; diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index c54858881..fea999e7d 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -31,7 +31,7 @@ public class MinPropertiesValidator extends BaseKeywordValidator implements Keyw public MinPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index 9d3865d9a..4e234b9db 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -45,7 +45,7 @@ public class MinimumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMinimum; public MinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("minimum value is not a number"); diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index 9cb1ca826..c6e96d072 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -34,7 +34,7 @@ public class MultipleOfValidator extends BaseKeywordValidator implements Keyword public MultipleOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.divisor = getDivisor(schemaNode); } diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index d47eb56d5..94bd8b598 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -32,7 +32,7 @@ public class NotAllowedValidator extends BaseKeywordValidator implements Keyword private final List fieldNames; public NotAllowedValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); this.fieldNames = new ArrayList<>(size); diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index e6d9380d6..b7501c530 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -33,7 +33,7 @@ public class NotValidator extends BaseKeywordValidator { private final Schema schema; public NotValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index a01d31a48..35dbc4a1f 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -41,7 +41,7 @@ public class OneOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; public OneOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 0cddab953..85eb266fe 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -38,7 +38,7 @@ public class PatternPropertiesValidator extends BaseKeywordValidator { public PatternPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isObject()) { throw new SchemaException("patternProperties must be an object node"); } diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index 367f85804..e1b6d6632 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -38,7 +38,7 @@ public class PatternValidator extends BaseKeywordValidator { private final RegularExpression compiledPattern; public PatternValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); try { diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 71c56ebeb..244dd6262 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -39,7 +39,7 @@ public class PrefixItemsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; public PrefixItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { int i = 0; @@ -156,7 +156,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, - ValidatorTypeCode.PREFIX_ITEMS.getValue(), + Keywords.PREFIX_ITEMS.getValue(), node, rootNode, instanceLocation, @@ -168,7 +168,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js } executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, - ValidatorTypeCode.PREFIX_ITEMS.getValue(), + Keywords.PREFIX_ITEMS.getValue(), node, rootNode, instanceLocation, diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 43fb33628..bc4539668 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -47,7 +47,7 @@ public class PropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; public PropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); String pname = entry.getKey(); @@ -167,7 +167,7 @@ private void walkSchema(ExecutionContext executionContext, Map.Entry fieldNames; public RequiredValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); for (JsonNode fieldNme : schemaNode) { diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index b1672453e..40bfca9b4 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -27,7 +27,7 @@ */ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { public TrueValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index 97c867d5f..c8a3af0ed 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -34,7 +34,7 @@ public class TypeValidator extends BaseKeywordValidator { private final UnionTypeValidator unionTypeValidator; public TypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { this.unionTypeValidator = new UnionTypeValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index b356be790..18a822fce 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -40,7 +40,7 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, + super(Keywords.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecificationVersion()); if (schemaNode.isObject() || schemaNode.isBoolean()) { diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 7d9e0d0c6..69ba55799 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -39,7 +39,7 @@ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private final Schema schema; public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 100ac2c09..694180c37 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -39,7 +39,7 @@ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordV private final String error; public UnionTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); String sep = ""; @@ -57,8 +57,8 @@ public UnionTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath sep = ", "; if (n.isObject()) { - schemas.add(schemaContext.newSchema(schemaLocation.append(ValidatorTypeCode.TYPE.getValue()), - evaluationPath.append(ValidatorTypeCode.TRUE.getValue()), n, parentSchema)); + schemas.add(schemaContext.newSchema(schemaLocation.append(Keywords.TYPE.getValue()), + evaluationPath.append(Keywords.TRUE.getValue()), n, parentSchema)); } else { schemas.add(new TypeValidator(schemaLocation.append(i), evaluationPath.append(i), n, parentSchema, schemaContext)); diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index fd8c95b15..924d813e0 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -33,7 +33,7 @@ public class UniqueItemsValidator extends BaseKeywordValidator implements Keywor private final boolean unique; public UniqueItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index a173eef5c..6b9b5ccf4 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -17,7 +17,7 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); public WriteOnlyValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(ValidatorTypeCode.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(Keywords.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 0f564b016..b4299c4b3 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.serialization.JsonMapperFactory; import java.io.IOException; @@ -30,7 +30,7 @@ protected List validate(String dataPath) { return getJsonSchemaFromDataNode(dataNode).validate(dataNode); } - protected void assertValidatorType(String filename, ValidatorTypeCode validatorTypeCode) { + protected void assertValidatorType(String filename, Keywords validatorTypeCode) { List errors = validate(getDataTestFolder() + filename); assertTrue( diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 0f4c4b3dc..552c2977e 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; @@ -50,7 +50,7 @@ void walkValidateThen() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -95,7 +95,7 @@ void walkValidateElse() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -141,7 +141,7 @@ void walkValidateNull() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -185,7 +185,7 @@ void walkNoValidate() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 737aaaba0..7fcbec3ea 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; @@ -26,7 +26,7 @@ protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { @Test void shouldWalkWithValidation() throws IOException { KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new Walker()) + .keywordWalkListener(Keywords.PROPERTIES.getValue(), new Walker()) .build(); WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 515d4b616..5dce23a6b 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.PropertyWalkListenerRunner; @@ -49,7 +49,7 @@ void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { properties.add(walkEvent.getSchema().getEvaluationPath().append(walkEvent.getKeyword())); diff --git a/src/test/java/com/networknt/schema/Issue769ContainsTest.java b/src/test/java/com/networknt/schema/Issue769ContainsTest.java index b344a7aeb..e6c0c6a77 100644 --- a/src/test/java/com/networknt/schema/Issue769ContainsTest.java +++ b/src/test/java/com/networknt/schema/Issue769ContainsTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.keyword.ContainsValidator; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** *

Test class for issue #769

@@ -21,22 +21,22 @@ protected String getDataTestFolder() { @Test void shouldReturnMinContainsKeyword() { - assertValidatorType("min-contains.json", ValidatorTypeCode.MIN_CONTAINS); + assertValidatorType("min-contains.json", Keywords.MIN_CONTAINS); } @Test void shouldReturnContainsKeywordForMinContainsV7() { - assertValidatorType("min-contains-v7.json", ValidatorTypeCode.CONTAINS); + assertValidatorType("min-contains-v7.json", Keywords.CONTAINS); } @Test void shouldReturnMaxContainsKeyword() { - assertValidatorType("max-contains.json", ValidatorTypeCode.MAX_CONTAINS); + assertValidatorType("max-contains.json", Keywords.MAX_CONTAINS); } @Test void shouldReturnContainsKeywordForMaxContainsV7() { - assertValidatorType("max-contains-v7.json", ValidatorTypeCode.CONTAINS); + assertValidatorType("max-contains-v7.json", Keywords.CONTAINS); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index bae464db5..347dbe5a1 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -9,7 +9,7 @@ import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; @@ -51,8 +51,8 @@ private void setupSchema() { KeywordWalkListenerRunner.Builder keywordWalkListenerRunnerBuilder = KeywordWalkListenerRunner.builder(); keywordWalkListenerRunnerBuilder.keywordWalkListener(new AllKeywordListener()); - keywordWalkListenerRunnerBuilder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); - keywordWalkListenerRunnerBuilder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), + keywordWalkListenerRunnerBuilder.keywordWalkListener(Keywords.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunnerBuilder.keywordWalkListener(Keywords.PROPERTIES.getValue(), new PropertiesKeywordListener()); SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); this.jsonSchema = schemaFactory.getSchema(getSchema()); @@ -60,8 +60,8 @@ private void setupSchema() { // Create another Schema. KeywordWalkListenerRunner.Builder keywordWalkListenerRunner1Builder = KeywordWalkListenerRunner.builder(); - keywordWalkListenerRunner1Builder.keywordWalkListener(ValidatorTypeCode.REF.getValue(), new RefKeywordListener()); - keywordWalkListenerRunner1Builder.keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), + keywordWalkListenerRunner1Builder.keywordWalkListener(Keywords.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunner1Builder.keywordWalkListener(Keywords.PROPERTIES.getValue(), new PropertiesKeywordListener()); schemaFactory = SchemaRegistry.withDialect(dialect); this.jsonSchema1 = schemaFactory.getSchema(getSchema()); diff --git a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java b/src/test/java/com/networknt/schema/KeywordsTest.java similarity index 61% rename from src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java rename to src/test/java/com/networknt/schema/KeywordsTest.java index 779b051af..83558a694 100644 --- a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java +++ b/src/test/java/com/networknt/schema/KeywordsTest.java @@ -19,34 +19,34 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; -class ValidatorTypeCodeTest { +class KeywordsTest { @Test void testFromValueString() { - assertEquals(ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.fromValue("additionalProperties")); + assertEquals(Keywords.ADDITIONAL_PROPERTIES, Keywords.fromValue("additionalProperties")); } @Test void testFromValueMissing() { - Assertions.assertThrows(IllegalArgumentException.class, () -> assertEquals(ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.fromValue("missing"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> assertEquals(Keywords.ADDITIONAL_PROPERTIES, Keywords.fromValue("missing"))); } @Test void testIfThenElseNotInV4() { - List list = ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4); - Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("if"))); + List list = Keywords.getKeywords(SpecificationVersion.DRAFT_4); + Assertions.assertFalse(list.contains(Keywords.fromValue("if"))); } @Test void testExclusiveMaximumNotInV4() { - List list = ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4); - Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("exclusiveMaximum"))); + List list = Keywords.getKeywords(SpecificationVersion.DRAFT_4); + Assertions.assertFalse(list.contains(Keywords.fromValue("exclusiveMaximum"))); } } diff --git a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java index fa22835e5..10f713748 100644 --- a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.keyword.NotAllowedValidator; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; /** @@ -23,6 +23,6 @@ protected String getDataTestFolder() { */ @Test void testNotAllowedValidatorWorks() { - assertValidatorType("notAllowedJson.json", ValidatorTypeCode.NOT_ALLOWED); + assertValidatorType("notAllowedJson.json", Keywords.NOT_ALLOWED); } } diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 13a3710dd..4dcc7861b 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -45,7 +45,7 @@ import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; -import com.networknt.schema.keyword.ValidatorTypeCode; +import com.networknt.schema.keyword.Keywords; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; import com.networknt.schema.utils.SchemaRefs; @@ -86,7 +86,7 @@ void keywordListener() { + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") @@ -386,7 +386,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void draft201909() { KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") @@ -723,7 +723,7 @@ void missingRequired() throws JsonProcessingException { + "}"; Map missingSchemaNode = new LinkedHashMap<>(); KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(ValidatorTypeCode.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { JsonNode requiredNode = walkEvent.getSchema().getSchemaNode().get("required"); From 59f8d9e9c76732d49ba02429172376ffa22c9659 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:50:11 +0800 Subject: [PATCH 32/74] Rename VersionCode to SpecificationVersionRange --- .../schema/SpecificationVersionRange.java | 32 +++++ .../schema/keyword/ContainsValidator.java | 2 +- .../networknt/schema/keyword/Keywords.java | 136 +++++++----------- .../keyword/UnevaluatedItemsValidator.java | 2 +- 4 files changed, 89 insertions(+), 83 deletions(-) create mode 100644 src/main/java/com/networknt/schema/SpecificationVersionRange.java diff --git a/src/main/java/com/networknt/schema/SpecificationVersionRange.java b/src/main/java/com/networknt/schema/SpecificationVersionRange.java new file mode 100644 index 000000000..e7bb94e6a --- /dev/null +++ b/src/main/java/com/networknt/schema/SpecificationVersionRange.java @@ -0,0 +1,32 @@ +package com.networknt.schema; + +import java.util.Arrays; +import java.util.EnumSet; + +/** + * SpecificationVersionRange. + */ +public enum SpecificationVersionRange { + None(new SpecificationVersion[] { }), + AllVersions(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV6(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV6MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MinV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MaxV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09 }), + MinV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MinV202012(new SpecificationVersion[] { SpecificationVersion.DRAFT_2020_12 }), + V201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09 }), + V7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7 }); + + private final EnumSet versions; + + SpecificationVersionRange(SpecificationVersion[] versionFlags) { + this.versions = EnumSet.noneOf(SpecificationVersion.class); + this.versions.addAll(Arrays.asList(versionFlags)); + } + + public EnumSet getVersions() { + return this.versions; + } +} \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 2e32b1f58..082f04b5b 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -25,7 +25,7 @@ import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; -import static com.networknt.schema.keyword.VersionCode.MinV201909; +import static com.networknt.schema.SpecificationVersionRange.MinV201909; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/networknt/schema/keyword/Keywords.java b/src/main/java/com/networknt/schema/keyword/Keywords.java index 44cfe19f4..bfe4931ea 100644 --- a/src/main/java/com/networknt/schema/keyword/Keywords.java +++ b/src/main/java/com/networknt/schema/keyword/Keywords.java @@ -21,11 +21,10 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.SpecificationVersionRange; import com.networknt.schema.SchemaContext; import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,87 +35,62 @@ KeywordValidator newInstance(SchemaLocation schemaLocation, NodePath evaluationP Schema parentSchema, SchemaContext schemaContext); } -enum VersionCode { - None(new SpecificationVersion[] { }), - AllVersions(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV6(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV6MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), - MinV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), - MaxV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09 }), - MinV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV202012(new SpecificationVersion[] { SpecificationVersion.DRAFT_2020_12 }), - V201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09 }), - V7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7 }); - - private final EnumSet versions; - - VersionCode(SpecificationVersion[] versionFlags) { - this.versions = EnumSet.noneOf(SpecificationVersion.class); - this.versions.addAll(Arrays.asList(versionFlags)); - } - - EnumSet getVersions() { - return this.versions; - } -} - public enum Keywords implements Keyword { - ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, VersionCode.MaxV7), - ALL_OF("allOf", AllOfValidator::new, VersionCode.MaxV7), - ANY_OF("anyOf", AnyOfValidator::new, VersionCode.MaxV7), - CONST("const", ConstValidator::new, VersionCode.MinV6MaxV7), - CONTAINS("contains", ContainsValidator::new, VersionCode.MinV6MaxV7), - CONTENT_ENCODING("contentEncoding", ContentEncodingValidator::new, VersionCode.V7), - CONTENT_MEDIA_TYPE("contentMediaType", ContentMediaTypeValidator::new, VersionCode.V7), - DEPENDENCIES("dependencies", DependenciesValidator::new, VersionCode.AllVersions), - DEPENDENT_REQUIRED("dependentRequired", DependentRequired::new, VersionCode.None), - DEPENDENT_SCHEMAS("dependentSchemas", DependentSchemas::new, VersionCode.None), - DISCRIMINATOR("discriminator", DiscriminatorValidator::new, VersionCode.None), - DYNAMIC_REF("$dynamicRef", DynamicRefValidator::new, VersionCode.None), - ENUM("enum", EnumValidator::new, VersionCode.MaxV7), - EXCLUSIVE_MAXIMUM("exclusiveMaximum", ExclusiveMaximumValidator::new, VersionCode.MinV6MaxV7), - EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, VersionCode.MinV6MaxV7), - FALSE("false", FalseValidator::new, VersionCode.MinV6), - FORMAT("format", null, VersionCode.MaxV7) { + ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, SpecificationVersionRange.MaxV7), + ALL_OF("allOf", AllOfValidator::new, SpecificationVersionRange.MaxV7), + ANY_OF("anyOf", AnyOfValidator::new, SpecificationVersionRange.MaxV7), + CONST("const", ConstValidator::new, SpecificationVersionRange.MinV6MaxV7), + CONTAINS("contains", ContainsValidator::new, SpecificationVersionRange.MinV6MaxV7), + CONTENT_ENCODING("contentEncoding", ContentEncodingValidator::new, SpecificationVersionRange.V7), + CONTENT_MEDIA_TYPE("contentMediaType", ContentMediaTypeValidator::new, SpecificationVersionRange.V7), + DEPENDENCIES("dependencies", DependenciesValidator::new, SpecificationVersionRange.AllVersions), + DEPENDENT_REQUIRED("dependentRequired", DependentRequired::new, SpecificationVersionRange.None), + DEPENDENT_SCHEMAS("dependentSchemas", DependentSchemas::new, SpecificationVersionRange.None), + DISCRIMINATOR("discriminator", DiscriminatorValidator::new, SpecificationVersionRange.None), + DYNAMIC_REF("$dynamicRef", DynamicRefValidator::new, SpecificationVersionRange.None), + ENUM("enum", EnumValidator::new, SpecificationVersionRange.MaxV7), + EXCLUSIVE_MAXIMUM("exclusiveMaximum", ExclusiveMaximumValidator::new, SpecificationVersionRange.MinV6MaxV7), + EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, SpecificationVersionRange.MinV6MaxV7), + FALSE("false", FalseValidator::new, SpecificationVersionRange.MinV6), + FORMAT("format", null, SpecificationVersionRange.MaxV7) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, - ID("id", null, VersionCode.AllVersions), - IF_THEN_ELSE("if", IfValidator::new, VersionCode.V7), - ITEMS_202012("items", ItemsValidator202012::new, VersionCode.None), - ITEMS("items", ItemsValidator::new, VersionCode.MaxV7), - MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, VersionCode.None), - MAX_ITEMS("maxItems", MaxItemsValidator::new, VersionCode.MaxV7), - MAX_LENGTH("maxLength", MaxLengthValidator::new, VersionCode.MaxV7), - MAX_PROPERTIES("maxProperties", MaxPropertiesValidator::new, VersionCode.MaxV7), - MAXIMUM("maximum", MaximumValidator::new, VersionCode.MaxV7), - MIN_CONTAINS("minContains", MinMaxContainsValidator::new, VersionCode.None), - MIN_ITEMS("minItems", MinItemsValidator::new, VersionCode.MaxV7), - MIN_LENGTH("minLength", MinLengthValidator::new, VersionCode.MaxV7), - MIN_PROPERTIES("minProperties", MinPropertiesValidator::new, VersionCode.MaxV7), - MINIMUM("minimum", MinimumValidator::new, VersionCode.MaxV7), - MULTIPLE_OF("multipleOf", MultipleOfValidator::new, VersionCode.MaxV7), - NOT_ALLOWED("notAllowed", NotAllowedValidator::new, VersionCode.AllVersions), - NOT("not", NotValidator::new, VersionCode.MaxV7), - ONE_OF("oneOf", OneOfValidator::new, VersionCode.MaxV7), - PATTERN_PROPERTIES("patternProperties", PatternPropertiesValidator::new, VersionCode.MaxV7), - PATTERN("pattern", PatternValidator::new, VersionCode.MaxV7), - PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, VersionCode.None), - PROPERTIES("properties", PropertiesValidator::new, VersionCode.MaxV7), - PROPERTYNAMES("propertyNames", PropertyNamesValidator::new, VersionCode.MinV6MaxV7), - READ_ONLY("readOnly", ReadOnlyValidator::new, VersionCode.V7), - RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, VersionCode.None), - REF("$ref", RefValidator::new, VersionCode.MaxV7), - REQUIRED("required", RequiredValidator::new, VersionCode.MaxV7), - TRUE("true", TrueValidator::new, VersionCode.MinV6), - TYPE("type", TypeValidator::new, VersionCode.MaxV7), - UNEVALUATED_ITEMS("unevaluatedItems", UnevaluatedItemsValidator::new, VersionCode.None), - UNEVALUATED_PROPERTIES("unevaluatedProperties",UnevaluatedPropertiesValidator::new,VersionCode.None), - UNION_TYPE("unionType", UnionTypeValidator::new, VersionCode.None), - UNIQUE_ITEMS("uniqueItems", UniqueItemsValidator::new, VersionCode.MaxV7), - WRITE_ONLY("writeOnly", WriteOnlyValidator::new, VersionCode.V7), + ID("id", null, SpecificationVersionRange.AllVersions), + IF_THEN_ELSE("if", IfValidator::new, SpecificationVersionRange.V7), + ITEMS_202012("items", ItemsValidator202012::new, SpecificationVersionRange.None), + ITEMS("items", ItemsValidator::new, SpecificationVersionRange.MaxV7), + MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, SpecificationVersionRange.None), + MAX_ITEMS("maxItems", MaxItemsValidator::new, SpecificationVersionRange.MaxV7), + MAX_LENGTH("maxLength", MaxLengthValidator::new, SpecificationVersionRange.MaxV7), + MAX_PROPERTIES("maxProperties", MaxPropertiesValidator::new, SpecificationVersionRange.MaxV7), + MAXIMUM("maximum", MaximumValidator::new, SpecificationVersionRange.MaxV7), + MIN_CONTAINS("minContains", MinMaxContainsValidator::new, SpecificationVersionRange.None), + MIN_ITEMS("minItems", MinItemsValidator::new, SpecificationVersionRange.MaxV7), + MIN_LENGTH("minLength", MinLengthValidator::new, SpecificationVersionRange.MaxV7), + MIN_PROPERTIES("minProperties", MinPropertiesValidator::new, SpecificationVersionRange.MaxV7), + MINIMUM("minimum", MinimumValidator::new, SpecificationVersionRange.MaxV7), + MULTIPLE_OF("multipleOf", MultipleOfValidator::new, SpecificationVersionRange.MaxV7), + NOT_ALLOWED("notAllowed", NotAllowedValidator::new, SpecificationVersionRange.AllVersions), + NOT("not", NotValidator::new, SpecificationVersionRange.MaxV7), + ONE_OF("oneOf", OneOfValidator::new, SpecificationVersionRange.MaxV7), + PATTERN_PROPERTIES("patternProperties", PatternPropertiesValidator::new, SpecificationVersionRange.MaxV7), + PATTERN("pattern", PatternValidator::new, SpecificationVersionRange.MaxV7), + PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, SpecificationVersionRange.None), + PROPERTIES("properties", PropertiesValidator::new, SpecificationVersionRange.MaxV7), + PROPERTYNAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.MinV6MaxV7), + READ_ONLY("readOnly", ReadOnlyValidator::new, SpecificationVersionRange.V7), + RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, SpecificationVersionRange.None), + REF("$ref", RefValidator::new, SpecificationVersionRange.MaxV7), + REQUIRED("required", RequiredValidator::new, SpecificationVersionRange.MaxV7), + TRUE("true", TrueValidator::new, SpecificationVersionRange.MinV6), + TYPE("type", TypeValidator::new, SpecificationVersionRange.MaxV7), + UNEVALUATED_ITEMS("unevaluatedItems", UnevaluatedItemsValidator::new, SpecificationVersionRange.None), + UNEVALUATED_PROPERTIES("unevaluatedProperties",UnevaluatedPropertiesValidator::new,SpecificationVersionRange.None), + UNION_TYPE("unionType", UnionTypeValidator::new, SpecificationVersionRange.None), + UNIQUE_ITEMS("uniqueItems", UniqueItemsValidator::new, SpecificationVersionRange.MaxV7), + WRITE_ONLY("writeOnly", WriteOnlyValidator::new, SpecificationVersionRange.V7), ; private static final Map CONSTANTS = new HashMap<>(); @@ -129,9 +103,9 @@ public enum Keywords implements Keyword { private final String value; private final ValidatorFactory validatorFactory; - private final VersionCode versionCode; + private final SpecificationVersionRange versionCode; - Keywords(String value, ValidatorFactory validatorFactory, VersionCode versionCode) { + Keywords(String value, ValidatorFactory validatorFactory, SpecificationVersionRange versionCode) { this.value = value; this.validatorFactory = validatorFactory; this.versionCode = versionCode; @@ -175,7 +149,7 @@ public String getValue() { return this.value; } - public VersionCode getVersionCode() { + public SpecificationVersionRange getVersionCode() { return this.versionCode; } } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 18a822fce..4fd734d85 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; -import static com.networknt.schema.keyword.VersionCode.MinV202012; +import static com.networknt.schema.SpecificationVersionRange.MinV202012; import java.util.*; import java.util.function.Predicate; From 63347fcb7391d0a6d42b9033393fcc9ca3c3b240 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 09:49:09 +0800 Subject: [PATCH 33/74] Rename ValidatorTypeCode to KeywordType --- .../java/com/networknt/schema/Schema.java | 8 +- .../java/com/networknt/schema/Vocabulary.java | 78 +++++++++---------- .../com/networknt/schema/dialect/Dialect.java | 10 +-- .../networknt/schema/dialect/Draft201909.java | 4 +- .../networknt/schema/dialect/Draft202012.java | 4 +- .../com/networknt/schema/dialect/Draft4.java | 4 +- .../com/networknt/schema/dialect/Draft6.java | 4 +- .../com/networknt/schema/dialect/Draft7.java | 4 +- .../networknt/schema/dialect/OpenApi30.java | 54 ++++++------- .../networknt/schema/dialect/OpenApi31.java | 4 +- .../AdditionalPropertiesValidator.java | 2 +- .../schema/keyword/AllOfValidator.java | 2 +- .../schema/keyword/AnyOfValidator.java | 2 +- .../schema/keyword/ConstValidator.java | 2 +- .../schema/keyword/ContainsValidator.java | 16 ++-- .../keyword/ContentEncodingValidator.java | 2 +- .../keyword/ContentMediaTypeValidator.java | 2 +- .../schema/keyword/DependenciesValidator.java | 2 +- .../schema/keyword/DependentRequired.java | 2 +- .../schema/keyword/DependentSchemas.java | 2 +- .../keyword/DiscriminatorValidator.java | 2 +- .../schema/keyword/DynamicRefValidator.java | 6 +- .../schema/keyword/EnumValidator.java | 2 +- .../keyword/ExclusiveMaximumValidator.java | 2 +- .../keyword/ExclusiveMinimumValidator.java | 2 +- .../schema/keyword/FalseValidator.java | 2 +- .../schema/keyword/FormatKeyword.java | 2 +- .../networknt/schema/keyword/IfValidator.java | 2 +- .../schema/keyword/ItemsValidator.java | 10 +-- .../schema/keyword/ItemsValidator202012.java | 6 +- .../{Keywords.java => KeywordType.java} | 18 ++--- .../schema/keyword/MaxItemsValidator.java | 2 +- .../schema/keyword/MaxLengthValidator.java | 2 +- .../keyword/MaxPropertiesValidator.java | 2 +- .../schema/keyword/MaximumValidator.java | 2 +- .../schema/keyword/MinItemsValidator.java | 2 +- .../schema/keyword/MinLengthValidator.java | 2 +- .../keyword/MinMaxContainsValidator.java | 2 +- .../keyword/MinPropertiesValidator.java | 2 +- .../schema/keyword/MinimumValidator.java | 2 +- .../schema/keyword/MultipleOfValidator.java | 2 +- .../schema/keyword/NotAllowedValidator.java | 2 +- .../schema/keyword/NotValidator.java | 2 +- .../schema/keyword/OneOfValidator.java | 2 +- .../keyword/PatternPropertiesValidator.java | 2 +- .../schema/keyword/PatternValidator.java | 2 +- .../schema/keyword/PrefixItemsValidator.java | 6 +- .../schema/keyword/PropertiesValidator.java | 6 +- .../keyword/PropertyNamesValidator.java | 2 +- .../schema/keyword/ReadOnlyValidator.java | 2 +- .../schema/keyword/RecursiveRefValidator.java | 8 +- .../schema/keyword/RefValidator.java | 6 +- .../schema/keyword/RequiredValidator.java | 2 +- .../schema/keyword/TrueValidator.java | 2 +- .../schema/keyword/TypeValidator.java | 2 +- .../keyword/UnevaluatedItemsValidator.java | 2 +- .../UnevaluatedPropertiesValidator.java | 2 +- .../schema/keyword/UnionTypeValidator.java | 6 +- .../schema/keyword/UniqueItemsValidator.java | 2 +- .../schema/keyword/WriteOnlyValidator.java | 2 +- .../schema/AbstractJsonSchemaTest.java | 4 +- .../com/networknt/schema/IfValidatorTest.java | 10 +-- .../com/networknt/schema/Issue461Test.java | 4 +- .../com/networknt/schema/Issue467Test.java | 4 +- .../schema/Issue769ContainsTest.java | 10 +-- .../com/networknt/schema/JsonWalkTest.java | 10 +-- .../com/networknt/schema/KeywordsTest.java | 14 ++-- .../schema/NotAllowedValidatorTest.java | 4 +- .../schema/walk/WalkListenerTest.java | 8 +- 69 files changed, 205 insertions(+), 205 deletions(-) rename src/main/java/com/networknt/schema/keyword/{Keywords.java => KeywordType.java} (92%) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 45e9a90f4..314c44675 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -34,7 +34,7 @@ import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.JsonNodes; /** @@ -186,13 +186,13 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) { SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword()); Error error = Error.builder() - .messageKey(Keywords.ID.getValue()).keyword(Keywords.ID.getValue()) + .messageKey(KeywordType.ID.getValue()).keyword(KeywordType.ID.getValue()) .instanceLocation(idSchemaLocation.getFragment()) .arguments(id, schemaContext.getDialect().getIdKeyword(), idSchemaLocation) .schemaLocation(idSchemaLocation) .schemaNode(schemaNode) .messageFormatter(args -> schemaContext.getSchemaRegistryConfig().getMessageSource().getMessage( - Keywords.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args)) + KeywordType.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args)) .build(); throw new InvalidSchemaException(error); } @@ -506,7 +506,7 @@ public Schema getSubSchema(NodePath fragment) { } if (found == null) { Error error = Error.builder() - .keyword(Keywords.REF.getValue()).messageKey("internal.unresolvedRef") + .keyword(KeywordType.REF.getValue()).messageKey("internal.unresolvedRef") .message("Reference {0} cannot be resolved") .instanceLocation(schemaLocation.getFragment()) .schemaLocation(schemaLocation) diff --git a/src/main/java/com/networknt/schema/Vocabulary.java b/src/main/java/com/networknt/schema/Vocabulary.java index 6dc019b14..786de196c 100644 --- a/src/main/java/com/networknt/schema/Vocabulary.java +++ b/src/main/java/com/networknt/schema/Vocabulary.java @@ -23,7 +23,7 @@ import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Represents a vocabulary in meta-schema. @@ -35,75 +35,75 @@ public class Vocabulary { // 2019-09 public static final Vocabulary DRAFT_2019_09_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core", new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), new NonValidationKeyword("$anchor"), - Keywords.REF, Keywords.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"), + KeywordType.REF, KeywordType.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"), - Keywords.UNEVALUATED_ITEMS, Keywords.ITEMS, Keywords.CONTAINS, - Keywords.ADDITIONAL_PROPERTIES, Keywords.UNEVALUATED_PROPERTIES, - Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS, - Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"), - new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF, - Keywords.ONE_OF, Keywords.NOT); + KeywordType.UNEVALUATED_ITEMS, KeywordType.ITEMS, KeywordType.CONTAINS, + KeywordType.ADDITIONAL_PROPERTIES, KeywordType.UNEVALUATED_PROPERTIES, + KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, + KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), + new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF, + KeywordType.ONE_OF, KeywordType.NOT); public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary( - "https://json-schema.org/draft/2019-09/vocab/validation", Keywords.MULTIPLE_OF, - Keywords.MAXIMUM, Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, - Keywords.EXCLUSIVE_MINIMUM, Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, - Keywords.PATTERN, Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, - Keywords.UNIQUE_ITEMS, Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, - Keywords.MAX_PROPERTIES, Keywords.MIN_PROPERTIES, Keywords.REQUIRED, - Keywords.DEPENDENT_REQUIRED, Keywords.CONST, Keywords.ENUM, - Keywords.TYPE); + "https://json-schema.org/draft/2019-09/vocab/validation", KeywordType.MULTIPLE_OF, + KeywordType.MAXIMUM, KeywordType.EXCLUSIVE_MAXIMUM, KeywordType.MINIMUM, + KeywordType.EXCLUSIVE_MINIMUM, KeywordType.MAX_LENGTH, KeywordType.MIN_LENGTH, + KeywordType.PATTERN, KeywordType.MAX_ITEMS, KeywordType.MIN_ITEMS, + KeywordType.UNIQUE_ITEMS, KeywordType.MAX_CONTAINS, KeywordType.MIN_CONTAINS, + KeywordType.MAX_PROPERTIES, KeywordType.MIN_PROPERTIES, KeywordType.REQUIRED, + KeywordType.DEPENDENT_REQUIRED, KeywordType.CONST, KeywordType.ENUM, + KeywordType.TYPE); public static final Vocabulary DRAFT_2019_09_META_DATA = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), - Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples")); + KeywordType.READ_ONLY, KeywordType.WRITE_ONLY, new AnnotationKeyword("examples")); public static final Vocabulary DRAFT_2019_09_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format", - Keywords.FORMAT); + KeywordType.FORMAT); public static final Vocabulary DRAFT_2019_09_CONTENT = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/content", new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentSchema")); // 2020-12 public static final Vocabulary DRAFT_2020_12_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core", - new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), Keywords.REF, - new NonValidationKeyword("$anchor"), Keywords.DYNAMIC_REF, + new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), KeywordType.REF, + new NonValidationKeyword("$anchor"), KeywordType.DYNAMIC_REF, new NonValidationKeyword("$dynamicAnchor"), new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/applicator", Keywords.PREFIX_ITEMS, - Keywords.ITEMS_202012, Keywords.CONTAINS, Keywords.ADDITIONAL_PROPERTIES, - Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS, - Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"), - new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF, - Keywords.ONE_OF, Keywords.NOT); + "https://json-schema.org/draft/2020-12/vocab/applicator", KeywordType.PREFIX_ITEMS, + KeywordType.ITEMS_202012, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, + KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, + KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), + new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF, + KeywordType.ONE_OF, KeywordType.NOT); public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/unevaluated", Keywords.UNEVALUATED_ITEMS, - Keywords.UNEVALUATED_PROPERTIES); + "https://json-schema.org/draft/2020-12/vocab/unevaluated", KeywordType.UNEVALUATED_ITEMS, + KeywordType.UNEVALUATED_PROPERTIES); public static final Vocabulary DRAFT_2020_12_VALIDATION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/validation", Keywords.TYPE, Keywords.CONST, - Keywords.ENUM, Keywords.MULTIPLE_OF, Keywords.MAXIMUM, - Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, Keywords.EXCLUSIVE_MINIMUM, - Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, Keywords.PATTERN, - Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, Keywords.UNIQUE_ITEMS, - Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, Keywords.MAX_PROPERTIES, - Keywords.MIN_PROPERTIES, Keywords.REQUIRED, Keywords.DEPENDENT_REQUIRED); + "https://json-schema.org/draft/2020-12/vocab/validation", KeywordType.TYPE, KeywordType.CONST, + KeywordType.ENUM, KeywordType.MULTIPLE_OF, KeywordType.MAXIMUM, + KeywordType.EXCLUSIVE_MAXIMUM, KeywordType.MINIMUM, KeywordType.EXCLUSIVE_MINIMUM, + KeywordType.MAX_LENGTH, KeywordType.MIN_LENGTH, KeywordType.PATTERN, + KeywordType.MAX_ITEMS, KeywordType.MIN_ITEMS, KeywordType.UNIQUE_ITEMS, + KeywordType.MAX_CONTAINS, KeywordType.MIN_CONTAINS, KeywordType.MAX_PROPERTIES, + KeywordType.MIN_PROPERTIES, KeywordType.REQUIRED, KeywordType.DEPENDENT_REQUIRED); public static final Vocabulary DRAFT_2020_12_META_DATA = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/meta-data", new AnnotationKeyword("title"), new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"), - Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples")); + KeywordType.READ_ONLY, KeywordType.WRITE_ONLY, new AnnotationKeyword("examples")); public static final Vocabulary DRAFT_2020_12_FORMAT_ANNOTATION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/format-annotation", Keywords.FORMAT); + "https://json-schema.org/draft/2020-12/vocab/format-annotation", KeywordType.FORMAT); public static final Vocabulary DRAFT_2020_12_FORMAT_ASSERTION = new Vocabulary( - "https://json-schema.org/draft/2020-12/vocab/format-assertion", Keywords.FORMAT); + "https://json-schema.org/draft/2020-12/vocab/format-assertion", KeywordType.FORMAT); public static final Vocabulary DRAFT_2020_12_CONTENT = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/content", new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentSchema")); // OpenAPI 3.1 public static final Vocabulary OPENAPI_3_1_BASE = new Vocabulary("https://spec.openapis.org/oas/3.1/vocab/base", - new AnnotationKeyword("example"), Keywords.DISCRIMINATOR, new AnnotationKeyword("externalDocs"), + new AnnotationKeyword("example"), KeywordType.DISCRIMINATOR, new AnnotationKeyword("externalDocs"), new AnnotationKeyword("xml")); private final String iri; diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 6858722c4..26e869573 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -34,7 +34,7 @@ import com.networknt.schema.keyword.KeywordFactory; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.UnknownKeywordFactory; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,8 +93,8 @@ private Map createKeywordsMap(Map kwords, Map< for (Map.Entry type : kwords.entrySet()) { String keywordName = type.getKey(); Keyword keyword = type.getValue(); - if (Keywords.FORMAT.getValue().equals(keywordName)) { - if (!(keyword instanceof FormatKeyword) && !Keywords.FORMAT.equals(keyword)) { + if (KeywordType.FORMAT.getValue().equals(keywordName)) { + if (!(keyword instanceof FormatKeyword) && !KeywordType.FORMAT.equals(keyword)) { throw new IllegalArgumentException("Overriding the keyword 'format' is not supported. Use the formatKeywordFactory and extend the FormatKeyword."); } // Indicate that the format keyword needs to be created @@ -455,9 +455,9 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation if (schemaContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) { return null; } - if (Keywords.DISCRIMINATOR.getValue().equals(keyword) + if (KeywordType.DISCRIMINATOR.getValue().equals(keyword) && schemaContext.isDiscriminatorKeywordEnabled()) { - return Keywords.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, + return KeywordType.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); } kw = this.builder.unknownKeywordFactory != null diff --git a/src/main/java/com/networknt/schema/dialect/Draft201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java index 6559153a7..8185ea055 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Draft 2019-09 dialect. @@ -35,7 +35,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2019_09) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2019_09)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_2019_09)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java index 9ffcc41b7..19a88ce2f 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Draft 2020-12 dialect. @@ -36,7 +36,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/dialect/Draft4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java index c1a952c4e..0c24a08ab 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Draft 4 dialect. @@ -22,7 +22,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_4) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_4)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_4)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java index 5ef0be929..84dad325b 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Draft 6 dialect. @@ -23,7 +23,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_6) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_6)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_6)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/Draft7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java index 92a97979a..a9a68cb54 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * Draft 7 dialect. @@ -22,7 +22,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_7) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_7)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_7)) // keywords that may validly exist, but have no validation aspect to them .keywords(Arrays.asList( new NonValidationKeyword("$schema"), diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index 5eda0c298..7bb2e46fd 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -6,7 +6,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * OpenAPI 3.0. @@ -24,42 +24,42 @@ private static class Holder { .formats(Formats.DEFAULT) .keywords(Arrays.asList( new AnnotationKeyword("title"), - Keywords.PATTERN, - Keywords.REQUIRED, - Keywords.ENUM, - Keywords.MINIMUM, - Keywords.MAXIMUM, - Keywords.MULTIPLE_OF, - Keywords.MIN_LENGTH, - Keywords.MAX_LENGTH, - Keywords.MIN_ITEMS, - Keywords.MAX_ITEMS, - Keywords.UNIQUE_ITEMS, - Keywords.MIN_PROPERTIES, - Keywords.MAX_PROPERTIES, + KeywordType.PATTERN, + KeywordType.REQUIRED, + KeywordType.ENUM, + KeywordType.MINIMUM, + KeywordType.MAXIMUM, + KeywordType.MULTIPLE_OF, + KeywordType.MIN_LENGTH, + KeywordType.MAX_LENGTH, + KeywordType.MIN_ITEMS, + KeywordType.MAX_ITEMS, + KeywordType.UNIQUE_ITEMS, + KeywordType.MIN_PROPERTIES, + KeywordType.MAX_PROPERTIES, - Keywords.TYPE, - Keywords.FORMAT, + KeywordType.TYPE, + KeywordType.FORMAT, new AnnotationKeyword("description"), - Keywords.ITEMS, - Keywords.PROPERTIES, - Keywords.ADDITIONAL_PROPERTIES, + KeywordType.ITEMS, + KeywordType.PROPERTIES, + KeywordType.ADDITIONAL_PROPERTIES, new AnnotationKeyword("default"), - Keywords.ALL_OF, - Keywords.ONE_OF, - Keywords.ANY_OF, - Keywords.NOT, + KeywordType.ALL_OF, + KeywordType.ONE_OF, + KeywordType.ANY_OF, + KeywordType.NOT, new AnnotationKeyword("deprecated"), - Keywords.DISCRIMINATOR, + KeywordType.DISCRIMINATOR, new AnnotationKeyword("example"), new AnnotationKeyword("externalDocs"), new NonValidationKeyword("nullable"), - Keywords.READ_ONLY, - Keywords.WRITE_ONLY, + KeywordType.READ_ONLY, + KeywordType.WRITE_ONLY, new AnnotationKeyword("xml"), - Keywords.REF + KeywordType.REF )) .build(); } diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java index f8b667f90..4499f94b4 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -7,7 +7,7 @@ import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.NonValidationKeyword; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** * OpenAPI 3.1. @@ -37,7 +37,7 @@ private static class Holder { .specificationVersion(SpecificationVersion.DRAFT_2020_12) .idKeyword(ID_KEYWORD) .formats(Formats.DEFAULT) - .keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12)) + .keywords(KeywordType.getKeywords(SpecificationVersion.DRAFT_2020_12)) // keywords that may validly exist, but have no validation aspect to them .keywords(Collections.singletonList( new NonValidationKeyword("definitions") diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index ffd3e7012..66a49e21f 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -47,7 +47,7 @@ public class AdditionalPropertiesValidator extends BaseKeywordValidator { public AdditionalPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ADDITIONAL_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { allowAdditionalProperties = schemaNode.booleanValue(); additionalPropertiesSchema = null; diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index 7e2b160f3..c931ebcbc 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -37,7 +37,7 @@ public class AllOfValidator extends BaseKeywordValidator { private final List schemas; public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index ff9bb0a82..99203fa88 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -41,7 +41,7 @@ public class AnyOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; public AnyOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index 0a6525da9..782c5f631 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -28,7 +28,7 @@ public class ConstValidator extends BaseKeywordValidator implements KeywordValidator { public ConstValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.CONST, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 082f04b5b..2fb624459 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -48,7 +48,7 @@ public class ContainsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes @@ -61,14 +61,14 @@ public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); JsonNode parentSchemaNode = parentSchema.getSchemaNode(); Optional maxNode = Optional - .ofNullable(parentSchemaNode.get(Keywords.MAX_CONTAINS.getValue())) + .ofNullable(parentSchemaNode.get(KeywordType.MAX_CONTAINS.getValue())) .filter(JsonNode::canConvertToExactIntegral); if (maxNode.isPresent()) { currentMax = maxNode.get().intValue(); } Optional minNode = Optional - .ofNullable(parentSchemaNode.get(Keywords.MIN_CONTAINS.getValue())) + .ofNullable(parentSchemaNode.get(KeywordType.MIN_CONTAINS.getValue())) .filter(JsonNode::canConvertToExactIntegral); if (minNode.isPresent()) { currentMin = minNode.get().intValue(); @@ -114,13 +114,13 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode m = this.min; } if (actual < m) { - boundsViolated(executionContext, isMinV201909 ? Keywords.MIN_CONTAINS : Keywords.CONTAINS, + boundsViolated(executionContext, isMinV201909 ? KeywordType.MIN_CONTAINS : KeywordType.CONTAINS, executionContext.getExecutionConfig().getLocale(), node, instanceLocation, m); } if (this.max != null && actual > this.max) { - boundsViolated(executionContext, isMinV201909 ? Keywords.MAX_CONTAINS : Keywords.CONTAINS, + boundsViolated(executionContext, isMinV201909 ? KeywordType.MAX_CONTAINS : KeywordType.CONTAINS, executionContext.getExecutionConfig().getLocale(), node, instanceLocation, this.max); } @@ -184,12 +184,12 @@ public void preloadSchema() { collectAnnotations(); // cache the flag } - private void boundsViolated(ExecutionContext executionContext, Keywords validatorTypeCode, Locale locale, + private void boundsViolated(ExecutionContext executionContext, KeywordType validatorTypeCode, Locale locale, JsonNode instanceNode, NodePath instanceLocation, int bounds) { String messageKey = "contains"; - if (Keywords.MIN_CONTAINS.equals(validatorTypeCode)) { + if (KeywordType.MIN_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MIN; - } else if (Keywords.MAX_CONTAINS.equals(validatorTypeCode)) { + } else if (KeywordType.MAX_CONTAINS.equals(validatorTypeCode)) { messageKey = CONTAINS_MAX; } executionContext.addError(error().instanceNode(instanceNode).instanceLocation(instanceLocation).messageKey(messageKey) diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 39d7e39af..aa0656dcd 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -47,7 +47,7 @@ public class ContentEncodingValidator extends BaseKeywordValidator { */ public ContentEncodingValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, + super(KeywordType.CONTENT_ENCODING, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentEncoding = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index e581e178e..48e3a3c6b 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -52,7 +52,7 @@ public class ContentMediaTypeValidator extends BaseKeywordValidator { */ public ContentMediaTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.CONTENT_MEDIA_TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.contentMediaType = schemaNode.textValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 807402ad9..60ad5c0e3 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -43,7 +43,7 @@ public class DependenciesValidator extends BaseKeywordValidator implements Keywo */ public DependenciesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 2d4e6a1c4..8e3b9dc13 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -33,7 +33,7 @@ public class DependentRequired extends BaseKeywordValidator implements KeywordVa public DependentRequired(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.DEPENDENT_REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 252dd6d0f..6d5020e19 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -33,7 +33,7 @@ public class DependentSchemas extends BaseKeywordValidator { public DependentSchemas(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.DEPENDENT_SCHEMAS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator it = schemaNode.fieldNames(); it.hasNext(); ) { String pname = it.next(); diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 824ef63cb..7486b64e9 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -41,7 +41,7 @@ public class DiscriminatorValidator extends BaseKeywordValidator { public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, + super(KeywordType.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; if (discriminator != null) { diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 50a4b7489..a07656d71 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -37,7 +37,7 @@ public class DynamicRefValidator extends BaseKeywordValidator { protected final SchemaRef schema; public DynamicRefValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); String refValue = schemaNode.asText(); this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath); } @@ -99,7 +99,7 @@ private static String resolve(Schema parentSchema, String refValue) { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { Schema refSchema = this.schema.getSchema(); if (refSchema == null) { - Error error = error().keyword(Keywords.DYNAMIC_REF.getValue()) + Error error = error().keyword(KeywordType.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); @@ -115,7 +115,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // with the latest config. Reset the config. Schema refSchema = this.schema.getSchema(); if (refSchema == null) { - Error error = error().keyword(Keywords.DYNAMIC_REF.getValue()) + Error error = error().keyword(KeywordType.DYNAMIC_REF.getValue()) .messageKey("internal.unresolvedRef").message("Reference {0} cannot be resolved") .instanceLocation(instanceLocation).evaluationPath(getEvaluationPath()) .arguments(schemaNode.asText()).build(); diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index 5654fc151..efa5f97cf 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -49,7 +49,7 @@ static String asText(JsonNode node) { } public EnumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ENUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.isArray()) { nodes = new HashSet<>(); StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 4d2e90373..d382a1f4a 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -37,7 +37,7 @@ public class ExclusiveMaximumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMaximum; public ExclusiveMaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.EXCLUSIVE_MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMaximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index e50b83ed7..5498ec8cf 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -41,7 +41,7 @@ public class ExclusiveMinimumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMinimum; public ExclusiveMinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.EXCLUSIVE_MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("exclusiveMinimum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index ac864a0d0..ebba6ed22 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -29,7 +29,7 @@ public class FalseValidator extends BaseKeywordValidator implements KeywordValid private final String reason; public FalseValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.FALSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.reason = this.evaluationPath.getParent().getName(-1); } diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 54b13b72d..6af98ac52 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -35,7 +35,7 @@ public class FormatKeyword implements Keyword { private final Map formats; public FormatKeyword(Map formats) { - this(Keywords.FORMAT, formats); + this(KeywordType.FORMAT, formats); } public FormatKeyword(Keyword type, Map formats) { diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index 110c9bb5f..cf18ea960 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -37,7 +37,7 @@ public class IfValidator extends BaseKeywordValidator { private final Schema elseSchema; public IfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.IF_THEN_ELSE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Schema foundIfSchema = null; Schema foundThenSchema = null; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 5d9d14bf4..cca954a0f 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -47,7 +47,7 @@ public class ItemsValidator extends BaseKeywordValidator { private final JsonNode additionalItemsSchemaNode; public ItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Boolean additionalItems = null; @@ -242,10 +242,10 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root n = defaultNode; } } - walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, Keywords.ITEMS.getValue()); + walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, KeywordType.ITEMS.getValue()); } } else { - walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, Keywords.ITEMS.getValue()); + walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, KeywordType.ITEMS.getValue()); } } else if (this.tupleSchema != null) { @@ -266,10 +266,10 @@ else if (this.tupleSchema != null) { } } walkSchema(executionContext, this.tupleSchema.get(i), n, rootNode, instanceLocation.append(i), - shouldValidateSchema, Keywords.ITEMS.getValue()); + shouldValidateSchema, KeywordType.ITEMS.getValue()); } else { walkSchema(executionContext, this.tupleSchema.get(i), null, rootNode, instanceLocation.append(i), - shouldValidateSchema, Keywords.ITEMS.getValue()); + shouldValidateSchema, KeywordType.ITEMS.getValue()); } } if (this.additionalSchema != null) { diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index b820df321..234dc2211 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -39,7 +39,7 @@ public class ItemsValidator202012 extends BaseKeywordValidator { public ItemsValidator202012(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, + super(KeywordType.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); @@ -151,7 +151,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, - Keywords.ITEMS.getValue(), + KeywordType.ITEMS.getValue(), node, rootNode, instanceLocation, @@ -163,7 +163,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js } executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, - Keywords.ITEMS.getValue(), + KeywordType.ITEMS.getValue(), node, rootNode, instanceLocation, diff --git a/src/main/java/com/networknt/schema/keyword/Keywords.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java similarity index 92% rename from src/main/java/com/networknt/schema/keyword/Keywords.java rename to src/main/java/com/networknt/schema/keyword/KeywordType.java index bfe4931ea..72c864353 100644 --- a/src/main/java/com/networknt/schema/keyword/Keywords.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -35,7 +35,7 @@ KeywordValidator newInstance(SchemaLocation schemaLocation, NodePath evaluationP Schema parentSchema, SchemaContext schemaContext); } -public enum Keywords implements Keyword { +public enum KeywordType implements Keyword { ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, SpecificationVersionRange.MaxV7), ALL_OF("allOf", AllOfValidator::new, SpecificationVersionRange.MaxV7), ANY_OF("anyOf", AnyOfValidator::new, SpecificationVersionRange.MaxV7), @@ -93,10 +93,10 @@ public enum Keywords implements Keyword { WRITE_ONLY("writeOnly", WriteOnlyValidator::new, SpecificationVersionRange.V7), ; - private static final Map CONSTANTS = new HashMap<>(); + private static final Map CONSTANTS = new HashMap<>(); static { - for (Keywords c : values()) { + for (KeywordType c : values()) { CONSTANTS.put(c.value, c); } } @@ -105,15 +105,15 @@ public enum Keywords implements Keyword { private final ValidatorFactory validatorFactory; private final SpecificationVersionRange versionCode; - Keywords(String value, ValidatorFactory validatorFactory, SpecificationVersionRange versionCode) { + KeywordType(String value, ValidatorFactory validatorFactory, SpecificationVersionRange versionCode) { this.value = value; this.validatorFactory = validatorFactory; this.versionCode = versionCode; } - public static List getKeywords(SpecificationVersion versionFlag) { - final List result = new ArrayList<>(); - for (Keywords keyword : values()) { + public static List getKeywords(SpecificationVersion versionFlag) { + final List result = new ArrayList<>(); + for (KeywordType keyword : values()) { if (keyword.getVersionCode().getVersions().contains(versionFlag)) { result.add(keyword); } @@ -121,8 +121,8 @@ public static List getKeywords(SpecificationVersion versionFlag) { return result; } - public static Keywords fromValue(String value) { - Keywords constant = CONSTANTS.get(value); + public static KeywordType fromValue(String value) { + KeywordType constant = CONSTANTS.get(value); if (constant == null) { throw new IllegalArgumentException(value); } diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index ca09888e2..5c1a2f35b 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -30,7 +30,7 @@ public class MaxItemsValidator extends BaseKeywordValidator implements KeywordVa private final int max; public MaxItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MAX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { this.max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index ccc1a9d89..28643892a 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -32,7 +32,7 @@ public class MaxLengthValidator extends BaseKeywordValidator implements KeywordV private final int maxLength; public MaxLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MAX_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { this.maxLength = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index fc58b0dec..85f6ee159 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -31,7 +31,7 @@ public class MaxPropertiesValidator extends BaseKeywordValidator implements Keyw public MaxPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MAX_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { max = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index a17dabdbc..1b519e4bd 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -42,7 +42,7 @@ public class MaximumValidator extends BaseKeywordValidator { public MaximumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MAXIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("maximum value is not a number"); } diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index bd0a24a6d..6230165a3 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -30,7 +30,7 @@ public class MinItemsValidator extends BaseKeywordValidator implements KeywordVa private int min = 0; public MinItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MIN_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index 38eef6681..94ed117e9 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -32,7 +32,7 @@ public class MinLengthValidator extends BaseKeywordValidator implements KeywordV private int minLength; public MinLengthValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MIN_LENGTH, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); minLength = Integer.MIN_VALUE; if (schemaNode != null && schemaNode.canConvertToExactIntegral()) { minLength = schemaNode.intValue(); diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 3936ba57b..2c46a26f9 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -22,7 +22,7 @@ public class MinMaxContainsValidator extends BaseKeywordValidator { public MinMaxContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MAX_CONTAINS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); Set analysis = null; int min = 1; diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index fea999e7d..2d8196411 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -31,7 +31,7 @@ public class MinPropertiesValidator extends BaseKeywordValidator implements Keyw public MinPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MIN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.canConvertToExactIntegral()) { min = schemaNode.intValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index 4e234b9db..b84714b4d 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -45,7 +45,7 @@ public class MinimumValidator extends BaseKeywordValidator { private final ThresholdMixin typedMinimum; public MinimumValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MINIMUM, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isNumber()) { throw new SchemaException("minimum value is not a number"); diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index c6e96d072..5e4bb272a 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -34,7 +34,7 @@ public class MultipleOfValidator extends BaseKeywordValidator implements Keyword public MultipleOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.MULTIPLE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.divisor = getDivisor(schemaNode); } diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index 94bd8b598..d24233e40 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -32,7 +32,7 @@ public class NotAllowedValidator extends BaseKeywordValidator implements Keyword private final List fieldNames; public NotAllowedValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.NOT_ALLOWED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { int size = schemaNode.size(); this.fieldNames = new ArrayList<>(size); diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index b7501c530..9d5f55926 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -33,7 +33,7 @@ public class NotValidator extends BaseKeywordValidator { private final Schema schema; public NotValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.NOT, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 35dbc4a1f..32691129c 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -41,7 +41,7 @@ public class OneOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; public OneOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); throw new SchemaException(error().instanceNode(schemaNode) diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 85eb266fe..4f8571207 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -38,7 +38,7 @@ public class PatternPropertiesValidator extends BaseKeywordValidator { public PatternPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.PATTERN_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isObject()) { throw new SchemaException("patternProperties must be an object node"); } diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index e1b6d6632..1742f0886 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -38,7 +38,7 @@ public class PatternValidator extends BaseKeywordValidator { private final RegularExpression compiledPattern; public PatternValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.PATTERN, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.pattern = Optional.ofNullable(schemaNode).filter(JsonNode::isTextual).map(JsonNode::textValue).orElse(null); try { diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index 244dd6262..bf3d1d7eb 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -39,7 +39,7 @@ public class PrefixItemsValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedItemsValidator = null; public PrefixItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.PREFIX_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode instanceof ArrayNode && !schemaNode.isEmpty()) { int i = 0; @@ -156,7 +156,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js //@formatter:off boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, - Keywords.PREFIX_ITEMS.getValue(), + KeywordType.PREFIX_ITEMS.getValue(), node, rootNode, instanceLocation, @@ -168,7 +168,7 @@ private void walkSchema(ExecutionContext executionContext, Schema walkSchema, Js } executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, - Keywords.PREFIX_ITEMS.getValue(), + KeywordType.PREFIX_ITEMS.getValue(), node, rootNode, instanceLocation, diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index bc4539668..982929730 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -47,7 +47,7 @@ public class PropertiesValidator extends BaseKeywordValidator { private Boolean hasUnevaluatedPropertiesValidator; public PropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); for (Iterator> it = schemaNode.fields(); it.hasNext();) { Entry entry = it.next(); String pname = entry.getKey(); @@ -167,7 +167,7 @@ private void walkSchema(ExecutionContext executionContext, Map.Entry fieldNames; public RequiredValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.REQUIRED, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isArray()) { this.fieldNames = new ArrayList<>(schemaNode.size()); for (JsonNode fieldNme : schemaNode) { diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index 40bfca9b4..f387869e5 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -27,7 +27,7 @@ */ public class TrueValidator extends BaseKeywordValidator implements KeywordValidator { public TrueValidator(SchemaLocation schemaLocation, NodePath evaluationPath, final JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.TRUE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index c8a3af0ed..8ebeacc24 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -34,7 +34,7 @@ public class TypeValidator extends BaseKeywordValidator { private final UnionTypeValidator unionTypeValidator; public TypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); this.schemaType = TypeFactory.getSchemaNodeType(schemaNode); if (this.schemaType == JsonType.UNION) { this.unionTypeValidator = new UnionTypeValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 4fd734d85..3feb2c909 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -40,7 +40,7 @@ public class UnevaluatedItemsValidator extends BaseKeywordValidator { public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, + super(KeywordType.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecificationVersion()); if (schemaNode.isObject() || schemaNode.isBoolean()) { diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 69ba55799..4e8cf9923 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -39,7 +39,7 @@ public class UnevaluatedPropertiesValidator extends BaseKeywordValidator { private final Schema schema; public UnevaluatedPropertiesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.UNEVALUATED_PROPERTIES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 694180c37..017d2ecf3 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -39,7 +39,7 @@ public class UnionTypeValidator extends BaseKeywordValidator implements KeywordV private final String error; public UnionTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.TYPE, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); StringBuilder errorBuilder = new StringBuilder(); String sep = ""; @@ -57,8 +57,8 @@ public UnionTypeValidator(SchemaLocation schemaLocation, NodePath evaluationPath sep = ", "; if (n.isObject()) { - schemas.add(schemaContext.newSchema(schemaLocation.append(Keywords.TYPE.getValue()), - evaluationPath.append(Keywords.TRUE.getValue()), n, parentSchema)); + schemas.add(schemaContext.newSchema(schemaLocation.append(KeywordType.TYPE.getValue()), + evaluationPath.append(KeywordType.TRUE.getValue()), n, parentSchema)); } else { schemas.add(new TypeValidator(schemaLocation.append(i), evaluationPath.append(i), n, parentSchema, schemaContext)); diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index 924d813e0..a9a179a5d 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -33,7 +33,7 @@ public class UniqueItemsValidator extends BaseKeywordValidator implements Keywor private final boolean unique; public UniqueItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.UNIQUE_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (schemaNode.isBoolean()) { unique = schemaNode.booleanValue(); } else { diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index 6b9b5ccf4..4b5a2ad98 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -17,7 +17,7 @@ public class WriteOnlyValidator extends BaseKeywordValidator { private static final Logger logger = LoggerFactory.getLogger(WriteOnlyValidator.class); public WriteOnlyValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(Keywords.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.WRITE_ONLY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); logger.debug("Loaded WriteOnlyValidator for property {} as {}", parentSchema, "write mode"); } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index b4299c4b3..2c1a92e96 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.serialization.JsonMapperFactory; import java.io.IOException; @@ -30,7 +30,7 @@ protected List validate(String dataPath) { return getJsonSchemaFromDataNode(dataNode).validate(dataNode); } - protected void assertValidatorType(String filename, Keywords validatorTypeCode) { + protected void assertValidatorType(String filename, KeywordType validatorTypeCode) { List errors = validate(getDataTestFolder() + filename); assertTrue( diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 552c2977e..0ee0a6432 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; @@ -50,7 +50,7 @@ void walkValidateThen() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -95,7 +95,7 @@ void walkValidateElse() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -141,7 +141,7 @@ void walkValidateNull() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -185,7 +185,7 @@ void walkNoValidate() { + " }\r\n" + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.TYPE.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.TYPE.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index 7fcbec3ea..72cbee461 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; @@ -26,7 +26,7 @@ protected Schema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { @Test void shouldWalkWithValidation() throws IOException { KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.PROPERTIES.getValue(), new Walker()) + .keywordWalkListener(KeywordType.PROPERTIES.getValue(), new Walker()) .build(); WalkConfig walkConfig = WalkConfig.builder() .keywordWalkListenerRunner(keywordWalkListenerRunner) diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 5dce23a6b..10598eab0 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.PropertyWalkListenerRunner; @@ -49,7 +49,7 @@ void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { properties.add(walkEvent.getSchema().getEvaluationPath().append(walkEvent.getKeyword())); diff --git a/src/test/java/com/networknt/schema/Issue769ContainsTest.java b/src/test/java/com/networknt/schema/Issue769ContainsTest.java index e6c0c6a77..19a551a2f 100644 --- a/src/test/java/com/networknt/schema/Issue769ContainsTest.java +++ b/src/test/java/com/networknt/schema/Issue769ContainsTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.keyword.ContainsValidator; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** *

Test class for issue #769

@@ -21,22 +21,22 @@ protected String getDataTestFolder() { @Test void shouldReturnMinContainsKeyword() { - assertValidatorType("min-contains.json", Keywords.MIN_CONTAINS); + assertValidatorType("min-contains.json", KeywordType.MIN_CONTAINS); } @Test void shouldReturnContainsKeywordForMinContainsV7() { - assertValidatorType("min-contains-v7.json", Keywords.CONTAINS); + assertValidatorType("min-contains-v7.json", KeywordType.CONTAINS); } @Test void shouldReturnMaxContainsKeyword() { - assertValidatorType("max-contains.json", Keywords.MAX_CONTAINS); + assertValidatorType("max-contains.json", KeywordType.MAX_CONTAINS); } @Test void shouldReturnContainsKeywordForMaxContainsV7() { - assertValidatorType("max-contains-v7.json", Keywords.CONTAINS); + assertValidatorType("max-contains-v7.json", KeywordType.CONTAINS); } } diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 347dbe5a1..2820a7893 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -9,7 +9,7 @@ import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; @@ -51,8 +51,8 @@ private void setupSchema() { KeywordWalkListenerRunner.Builder keywordWalkListenerRunnerBuilder = KeywordWalkListenerRunner.builder(); keywordWalkListenerRunnerBuilder.keywordWalkListener(new AllKeywordListener()); - keywordWalkListenerRunnerBuilder.keywordWalkListener(Keywords.REF.getValue(), new RefKeywordListener()); - keywordWalkListenerRunnerBuilder.keywordWalkListener(Keywords.PROPERTIES.getValue(), + keywordWalkListenerRunnerBuilder.keywordWalkListener(KeywordType.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunnerBuilder.keywordWalkListener(KeywordType.PROPERTIES.getValue(), new PropertiesKeywordListener()); SchemaRegistry schemaFactory = SchemaRegistry.withDialect(dialect); this.jsonSchema = schemaFactory.getSchema(getSchema()); @@ -60,8 +60,8 @@ private void setupSchema() { // Create another Schema. KeywordWalkListenerRunner.Builder keywordWalkListenerRunner1Builder = KeywordWalkListenerRunner.builder(); - keywordWalkListenerRunner1Builder.keywordWalkListener(Keywords.REF.getValue(), new RefKeywordListener()); - keywordWalkListenerRunner1Builder.keywordWalkListener(Keywords.PROPERTIES.getValue(), + keywordWalkListenerRunner1Builder.keywordWalkListener(KeywordType.REF.getValue(), new RefKeywordListener()); + keywordWalkListenerRunner1Builder.keywordWalkListener(KeywordType.PROPERTIES.getValue(), new PropertiesKeywordListener()); schemaFactory = SchemaRegistry.withDialect(dialect); this.jsonSchema1 = schemaFactory.getSchema(getSchema()); diff --git a/src/test/java/com/networknt/schema/KeywordsTest.java b/src/test/java/com/networknt/schema/KeywordsTest.java index 83558a694..844449cb4 100644 --- a/src/test/java/com/networknt/schema/KeywordsTest.java +++ b/src/test/java/com/networknt/schema/KeywordsTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import java.util.List; @@ -29,24 +29,24 @@ class KeywordsTest { @Test void testFromValueString() { - assertEquals(Keywords.ADDITIONAL_PROPERTIES, Keywords.fromValue("additionalProperties")); + assertEquals(KeywordType.ADDITIONAL_PROPERTIES, KeywordType.fromValue("additionalProperties")); } @Test void testFromValueMissing() { - Assertions.assertThrows(IllegalArgumentException.class, () -> assertEquals(Keywords.ADDITIONAL_PROPERTIES, Keywords.fromValue("missing"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> assertEquals(KeywordType.ADDITIONAL_PROPERTIES, KeywordType.fromValue("missing"))); } @Test void testIfThenElseNotInV4() { - List list = Keywords.getKeywords(SpecificationVersion.DRAFT_4); - Assertions.assertFalse(list.contains(Keywords.fromValue("if"))); + List list = KeywordType.getKeywords(SpecificationVersion.DRAFT_4); + Assertions.assertFalse(list.contains(KeywordType.fromValue("if"))); } @Test void testExclusiveMaximumNotInV4() { - List list = Keywords.getKeywords(SpecificationVersion.DRAFT_4); - Assertions.assertFalse(list.contains(Keywords.fromValue("exclusiveMaximum"))); + List list = KeywordType.getKeywords(SpecificationVersion.DRAFT_4); + Assertions.assertFalse(list.contains(KeywordType.fromValue("exclusiveMaximum"))); } } diff --git a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java index 10f713748..8147e6b4f 100644 --- a/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java +++ b/src/test/java/com/networknt/schema/NotAllowedValidatorTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.keyword.NotAllowedValidator; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; /** @@ -23,6 +23,6 @@ protected String getDataTestFolder() { */ @Test void testNotAllowedValidatorWorks() { - assertValidatorType("notAllowedJson.json", Keywords.NOT_ALLOWED); + assertValidatorType("notAllowedJson.json", KeywordType.NOT_ALLOWED); } } diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 4dcc7861b..0a9cd4530 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -45,7 +45,7 @@ import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; -import com.networknt.schema.keyword.Keywords; +import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; import com.networknt.schema.utils.SchemaRefs; @@ -86,7 +86,7 @@ void keywordListener() { + "}"; KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") @@ -386,7 +386,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { @Test void draft201909() { KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @SuppressWarnings("unchecked") @@ -723,7 +723,7 @@ void missingRequired() throws JsonProcessingException { + "}"; Map missingSchemaNode = new LinkedHashMap<>(); KeywordWalkListenerRunner keywordWalkListenerRunner = KeywordWalkListenerRunner.builder() - .keywordWalkListener(Keywords.PROPERTIES.getValue(), new WalkListener() { + .keywordWalkListener(KeywordType.PROPERTIES.getValue(), new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { JsonNode requiredNode = walkEvent.getSchema().getSchemaNode().get("required"); From 40f742500d5ced0b5481e2bbed371ff82e98c165 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 09:51:35 +0800 Subject: [PATCH 34/74] Move ThresholdMixin to keyword package --- .../networknt/schema/keyword/ExclusiveMaximumValidator.java | 1 - .../networknt/schema/keyword/ExclusiveMinimumValidator.java | 1 - .../java/com/networknt/schema/keyword/MaximumValidator.java | 1 - .../java/com/networknt/schema/keyword/MinimumValidator.java | 1 - .../com/networknt/schema/{ => keyword}/ThresholdMixin.java | 2 +- .../schema/{ => keyword}/ThresholdMixinPerfTest.java | 4 +++- 6 files changed, 4 insertions(+), 6 deletions(-) rename src/main/java/com/networknt/schema/{ => keyword}/ThresholdMixin.java (95%) rename src/test/java/com/networknt/schema/{ => keyword}/ThresholdMixinPerfTest.java (99%) diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index d382a1f4a..26e0f2138 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -23,7 +23,6 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ThresholdMixin; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 5498ec8cf..e88476803 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -23,7 +23,6 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ThresholdMixin; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 1b519e4bd..c47364855 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -23,7 +23,6 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ThresholdMixin; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index b84714b4d..a6c2bcf9c 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -23,7 +23,6 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.ThresholdMixin; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/ThresholdMixin.java b/src/main/java/com/networknt/schema/keyword/ThresholdMixin.java similarity index 95% rename from src/main/java/com/networknt/schema/ThresholdMixin.java rename to src/main/java/com/networknt/schema/keyword/ThresholdMixin.java index 99399fb23..de67ea498 100644 --- a/src/main/java/com/networknt/schema/ThresholdMixin.java +++ b/src/main/java/com/networknt/schema/keyword/ThresholdMixin.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java b/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java similarity index 99% rename from src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java rename to src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java index 98cae3484..836a676cb 100644 --- a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java +++ b/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.*; +import com.networknt.schema.keyword.ThresholdMixin; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; From 73b2860c4aad1ed8283d80e18c2c94afed3bd1f3 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:03:49 +0800 Subject: [PATCH 35/74] Move Vocabulary to vocabulary package --- .../java/com/networknt/schema/dialect/Dialect.java | 7 ++++--- .../schema/{ => vocabulary}/Vocabularies.java | 2 +- .../networknt/schema/{ => vocabulary}/Vocabulary.java | 2 +- .../schema/{ => vocabulary}/VocabularyFactory.java | 2 +- src/test/java/com/networknt/schema/Issue994Test.java | 1 + .../schema/{ => vocabulary}/VocabularyTest.java | 11 ++++++++++- 6 files changed, 18 insertions(+), 7 deletions(-) rename src/main/java/com/networknt/schema/{ => vocabulary}/Vocabularies.java (96%) rename src/main/java/com/networknt/schema/{ => vocabulary}/Vocabulary.java (97%) rename src/main/java/com/networknt/schema/{ => vocabulary}/VocabularyFactory.java (92%) rename src/test/java/com/networknt/schema/{ => vocabulary}/VocabularyTest.java (94%) diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 26e869573..4ce5f71cf 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -25,9 +25,6 @@ import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; -import com.networknt.schema.Vocabularies; -import com.networknt.schema.Vocabulary; -import com.networknt.schema.VocabularyFactory; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.Keyword; @@ -36,6 +33,10 @@ import com.networknt.schema.keyword.UnknownKeywordFactory; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.StringUtils; +import com.networknt.schema.vocabulary.Vocabularies; +import com.networknt.schema.vocabulary.Vocabulary; +import com.networknt.schema.vocabulary.VocabularyFactory; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/Vocabularies.java b/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java similarity index 96% rename from src/main/java/com/networknt/schema/Vocabularies.java rename to src/main/java/com/networknt/schema/vocabulary/Vocabularies.java index 0c9f33528..73fa835fd 100644 --- a/src/main/java/com/networknt/schema/Vocabularies.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.vocabulary; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/networknt/schema/Vocabulary.java b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java similarity index 97% rename from src/main/java/com/networknt/schema/Vocabulary.java rename to src/main/java/com/networknt/schema/vocabulary/Vocabulary.java index 786de196c..b3f4e31f1 100644 --- a/src/main/java/com/networknt/schema/Vocabulary.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.vocabulary; import java.util.Arrays; import java.util.LinkedHashSet; diff --git a/src/main/java/com/networknt/schema/VocabularyFactory.java b/src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java similarity index 92% rename from src/main/java/com/networknt/schema/VocabularyFactory.java rename to src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java index a451c0d3a..8169ac090 100644 --- a/src/main/java/com/networknt/schema/VocabularyFactory.java +++ b/src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.vocabulary; /** * Factory for {@link Vocabulary}. diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index 4fc1d23dd..f5576a98f 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -25,6 +25,7 @@ import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.vocabulary.Vocabulary; class Issue994Test { @Test diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java similarity index 94% rename from src/test/java/com/networknt/schema/VocabularyTest.java rename to src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java index ff87bfc88..c8aae2c80 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.vocabulary; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -25,11 +25,20 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.Error; +import com.networknt.schema.InputFormat; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.OutputFormat; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaRegistry; +import com.networknt.schema.SpecificationVersion; import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.output.OutputUnit; +import com.networknt.schema.vocabulary.Vocabulary; +import com.networknt.schema.vocabulary.VocabularyFactory; /** * Tests for vocabulary support in meta schemas. From 15f7fa65858a79bd760c53b4dff0ad1087a18055 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:04:53 +0800 Subject: [PATCH 36/74] Move ApplyDefaultsStrategy to walk package --- .../com/networknt/schema/{ => walk}/ApplyDefaultsStrategy.java | 2 +- src/main/java/com/networknt/schema/walk/WalkConfig.java | 1 - src/test/java/com/networknt/schema/Issue604Test.java | 1 + src/test/java/com/networknt/schema/ItemsValidatorTest.java | 1 + .../java/com/networknt/schema/JsonWalkApplyDefaultsTest.java | 1 + .../java/com/networknt/schema/PrefixItemsValidatorTest.java | 1 + src/test/java/com/networknt/schema/PropertiesValidatorTest.java | 1 + src/test/java/com/networknt/schema/walk/WalkListenerTest.java | 1 - 8 files changed, 6 insertions(+), 3 deletions(-) rename src/main/java/com/networknt/schema/{ => walk}/ApplyDefaultsStrategy.java (98%) diff --git a/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java b/src/main/java/com/networknt/schema/walk/ApplyDefaultsStrategy.java similarity index 98% rename from src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java rename to src/main/java/com/networknt/schema/walk/ApplyDefaultsStrategy.java index 514e11ede..bbd80f0bd 100644 --- a/src/main/java/com/networknt/schema/ApplyDefaultsStrategy.java +++ b/src/main/java/com/networknt/schema/walk/ApplyDefaultsStrategy.java @@ -1,4 +1,4 @@ -package com.networknt.schema; +package com.networknt.schema.walk; public class ApplyDefaultsStrategy { public static final ApplyDefaultsStrategy EMPTY_APPLY_DEFAULTS_STRATEGY = new ApplyDefaultsStrategy(false, false, false); diff --git a/src/main/java/com/networknt/schema/walk/WalkConfig.java b/src/main/java/com/networknt/schema/walk/WalkConfig.java index c8d0d1b3e..8955b6324 100644 --- a/src/main/java/com/networknt/schema/walk/WalkConfig.java +++ b/src/main/java/com/networknt/schema/walk/WalkConfig.java @@ -19,7 +19,6 @@ import java.util.List; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.NodePath; diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index db6c7db6f..60872c733 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -1,6 +1,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.WalkConfig; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 5c90903a7..83fc1e942 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.WalkConfig; diff --git a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java index 9e3b127ee..12d67548b 100644 --- a/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkApplyDefaultsTest.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.WalkConfig; import java.io.IOException; diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 5e713ab92..7c31120de 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.keyword.PrefixItemsValidator; import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.WalkConfig; diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 616012acc..035081c0a 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -1,6 +1,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.WalkConfig; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 0a9cd4530..2e7ea4881 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -33,7 +33,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.ApplyDefaultsStrategy; import com.networknt.schema.InputFormat; import com.networknt.schema.NodePath; import com.networknt.schema.Schema; From 82dc2dccb06e348f821678d5f51452bfbe5eb0ae Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:07:27 +0800 Subject: [PATCH 37/74] Move Format and Formats to format package --- .../com/networknt/schema/dialect/Dialect.java | 2 +- .../networknt/schema/dialect/Draft201909.java | 2 +- .../networknt/schema/dialect/Draft202012.java | 2 +- .../com/networknt/schema/dialect/Draft4.java | 2 +- .../com/networknt/schema/dialect/Draft6.java | 2 +- .../com/networknt/schema/dialect/Draft7.java | 2 +- .../com/networknt/schema/dialect/OpenApi30.java | 2 +- .../com/networknt/schema/dialect/OpenApi31.java | 2 +- .../schema/format/AbstractRFC3986Format.java | 1 - .../com/networknt/schema/format/BaseFormat.java | 2 -- .../com/networknt/schema/format/DateFormat.java | 1 - .../networknt/schema/format/DateTimeFormat.java | 1 - .../networknt/schema/format/DurationFormat.java | 1 - .../networknt/schema/format/EmailFormat.java | 1 - .../networknt/schema/{ => format}/Format.java | 9 ++++++++- .../networknt/schema/{ => format}/Formats.java | 17 +---------------- .../com/networknt/schema/format/IPv6Format.java | 1 - .../networknt/schema/format/IdnEmailFormat.java | 1 - .../schema/format/IdnHostnameFormat.java | 1 - .../networknt/schema/format/PatternFormat.java | 1 - .../networknt/schema/format/RegexFormat.java | 1 - .../com/networknt/schema/format/TimeFormat.java | 1 - .../networknt/schema/keyword/FormatKeyword.java | 2 +- .../schema/keyword/FormatValidator.java | 2 +- .../networknt/schema/CollectorContextTest.java | 1 + .../schema/FormatKeywordFactoryTest.java | 1 + .../networknt/schema/FormatValidatorTest.java | 1 + .../java/com/networknt/schema/Issue784Test.java | 1 + .../java/com/networknt/schema/Issue832Test.java | 1 + 29 files changed, 24 insertions(+), 40 deletions(-) rename src/main/java/com/networknt/schema/{ => format}/Format.java (93%) rename src/main/java/com/networknt/schema/{ => format}/Formats.java (82%) diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 4ce5f71cf..c29901d50 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; -import com.networknt.schema.Format; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.NodePath; import com.networknt.schema.Schema; @@ -26,6 +25,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Format; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordFactory; diff --git a/src/main/java/com/networknt/schema/dialect/Draft201909.java b/src/main/java/com/networknt/schema/dialect/Draft201909.java index 8185ea055..67f45119e 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft201909.java +++ b/src/main/java/com/networknt/schema/dialect/Draft201909.java @@ -4,8 +4,8 @@ import java.util.HashMap; import java.util.Map; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/Draft202012.java b/src/main/java/com/networknt/schema/dialect/Draft202012.java index 19a88ce2f..e7f9cbcff 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft202012.java +++ b/src/main/java/com/networknt/schema/dialect/Draft202012.java @@ -4,8 +4,8 @@ import java.util.HashMap; import java.util.Map; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/Draft4.java b/src/main/java/com/networknt/schema/dialect/Draft4.java index 0c24a08ab..5a55098f1 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft4.java +++ b/src/main/java/com/networknt/schema/dialect/Draft4.java @@ -2,8 +2,8 @@ import java.util.Arrays; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/Draft6.java b/src/main/java/com/networknt/schema/dialect/Draft6.java index 84dad325b..0c6463139 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft6.java +++ b/src/main/java/com/networknt/schema/dialect/Draft6.java @@ -2,8 +2,8 @@ import java.util.Arrays; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/Draft7.java b/src/main/java/com/networknt/schema/dialect/Draft7.java index a9a68cb54..edbdc3ab5 100644 --- a/src/main/java/com/networknt/schema/dialect/Draft7.java +++ b/src/main/java/com/networknt/schema/dialect/Draft7.java @@ -2,8 +2,8 @@ import java.util.Arrays; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index 7bb2e46fd..28c17b057 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -2,8 +2,8 @@ import java.util.Arrays; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi31.java b/src/main/java/com/networknt/schema/dialect/OpenApi31.java index 4499f94b4..a51934cb6 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi31.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi31.java @@ -4,8 +4,8 @@ import java.util.HashMap; import java.util.Map; -import com.networknt.schema.Formats; import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.format.Formats; import com.networknt.schema.keyword.NonValidationKeyword; import com.networknt.schema.keyword.KeywordType; diff --git a/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java b/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java index b08dd9ba0..2eacc9a04 100644 --- a/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java +++ b/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java @@ -5,7 +5,6 @@ import java.util.regex.Pattern; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * {@link AbstractFormat} for RFC 3986. diff --git a/src/main/java/com/networknt/schema/format/BaseFormat.java b/src/main/java/com/networknt/schema/format/BaseFormat.java index d8310bb4c..207c66212 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormat.java +++ b/src/main/java/com/networknt/schema/format/BaseFormat.java @@ -16,8 +16,6 @@ package com.networknt.schema.format; -import com.networknt.schema.Format; - /** * Base implementation of {@link Format}. */ diff --git a/src/main/java/com/networknt/schema/format/DateFormat.java b/src/main/java/com/networknt/schema/format/DateFormat.java index c5d921c9e..3e30e499b 100644 --- a/src/main/java/com/networknt/schema/format/DateFormat.java +++ b/src/main/java/com/networknt/schema/format/DateFormat.java @@ -4,7 +4,6 @@ import java.time.format.DateTimeParseException; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * Format for date. diff --git a/src/main/java/com/networknt/schema/format/DateTimeFormat.java b/src/main/java/com/networknt/schema/format/DateTimeFormat.java index a739c9c71..a12faa665 100644 --- a/src/main/java/com/networknt/schema/format/DateTimeFormat.java +++ b/src/main/java/com/networknt/schema/format/DateTimeFormat.java @@ -10,7 +10,6 @@ import com.ethlo.time.ITU; import com.ethlo.time.LeapSecondException; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import com.networknt.schema.utils.Classes; /** diff --git a/src/main/java/com/networknt/schema/format/DurationFormat.java b/src/main/java/com/networknt/schema/format/DurationFormat.java index 9b62b10ed..0d1f04411 100644 --- a/src/main/java/com/networknt/schema/format/DurationFormat.java +++ b/src/main/java/com/networknt/schema/format/DurationFormat.java @@ -4,7 +4,6 @@ import java.util.regex.Pattern; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/format/EmailFormat.java b/src/main/java/com/networknt/schema/format/EmailFormat.java index 3a329e4d0..86cbb5106 100644 --- a/src/main/java/com/networknt/schema/format/EmailFormat.java +++ b/src/main/java/com/networknt/schema/format/EmailFormat.java @@ -18,7 +18,6 @@ import com.networknt.org.apache.commons.validator.routines.EmailValidator; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * Format for email. diff --git a/src/main/java/com/networknt/schema/Format.java b/src/main/java/com/networknt/schema/format/Format.java similarity index 93% rename from src/main/java/com/networknt/schema/Format.java rename to src/main/java/com/networknt/schema/format/Format.java index aae09c425..02b8c4b19 100644 --- a/src/main/java/com/networknt/schema/Format.java +++ b/src/main/java/com/networknt/schema/format/Format.java @@ -14,11 +14,18 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.format; import java.util.function.Supplier; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonType; +import com.networknt.schema.MessageSourceError; +import com.networknt.schema.NodePath; +import com.networknt.schema.SchemaContext; +import com.networknt.schema.TypeFactory; +import com.networknt.schema.MessageSourceError.Builder; import com.networknt.schema.keyword.FormatValidator; /** diff --git a/src/main/java/com/networknt/schema/Formats.java b/src/main/java/com/networknt/schema/format/Formats.java similarity index 82% rename from src/main/java/com/networknt/schema/Formats.java rename to src/main/java/com/networknt/schema/format/Formats.java index c9dd0bda9..7ef566e17 100644 --- a/src/main/java/com/networknt/schema/Formats.java +++ b/src/main/java/com/networknt/schema/format/Formats.java @@ -13,27 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.format; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.networknt.schema.format.DateFormat; -import com.networknt.schema.format.DateTimeFormat; -import com.networknt.schema.format.DurationFormat; -import com.networknt.schema.format.EmailFormat; -import com.networknt.schema.format.IPv6Format; -import com.networknt.schema.format.IdnEmailFormat; -import com.networknt.schema.format.IdnHostnameFormat; -import com.networknt.schema.format.IriFormat; -import com.networknt.schema.format.IriReferenceFormat; -import com.networknt.schema.format.PatternFormat; -import com.networknt.schema.format.RegexFormat; -import com.networknt.schema.format.TimeFormat; -import com.networknt.schema.format.UriFormat; -import com.networknt.schema.format.UriReferenceFormat; - /** * Formats. */ diff --git a/src/main/java/com/networknt/schema/format/IPv6Format.java b/src/main/java/com/networknt/schema/format/IPv6Format.java index ddcd2ce55..15298cb33 100644 --- a/src/main/java/com/networknt/schema/format/IPv6Format.java +++ b/src/main/java/com/networknt/schema/format/IPv6Format.java @@ -3,7 +3,6 @@ import java.util.regex.Pattern; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * Format for ipv6. diff --git a/src/main/java/com/networknt/schema/format/IdnEmailFormat.java b/src/main/java/com/networknt/schema/format/IdnEmailFormat.java index 855ba2180..880071082 100644 --- a/src/main/java/com/networknt/schema/format/IdnEmailFormat.java +++ b/src/main/java/com/networknt/schema/format/IdnEmailFormat.java @@ -2,7 +2,6 @@ import com.networknt.org.apache.commons.validator.routines.EmailValidator; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * Format for idn-email. diff --git a/src/main/java/com/networknt/schema/format/IdnHostnameFormat.java b/src/main/java/com/networknt/schema/format/IdnHostnameFormat.java index 7ba0e8606..e5f46808f 100644 --- a/src/main/java/com/networknt/schema/format/IdnHostnameFormat.java +++ b/src/main/java/com/networknt/schema/format/IdnHostnameFormat.java @@ -1,7 +1,6 @@ package com.networknt.schema.format; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import com.networknt.schema.utils.RFC5892; /** diff --git a/src/main/java/com/networknt/schema/format/PatternFormat.java b/src/main/java/com/networknt/schema/format/PatternFormat.java index 79fa91753..4b2e584dc 100644 --- a/src/main/java/com/networknt/schema/format/PatternFormat.java +++ b/src/main/java/com/networknt/schema/format/PatternFormat.java @@ -19,7 +19,6 @@ import java.util.regex.Pattern; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; /** * Format using a regex pattern. diff --git a/src/main/java/com/networknt/schema/format/RegexFormat.java b/src/main/java/com/networknt/schema/format/RegexFormat.java index c8bffe841..dbb920cf8 100644 --- a/src/main/java/com/networknt/schema/format/RegexFormat.java +++ b/src/main/java/com/networknt/schema/format/RegexFormat.java @@ -14,7 +14,6 @@ package com.networknt.schema.format; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import com.networknt.schema.SchemaContext; import com.networknt.schema.regex.RegularExpression; diff --git a/src/main/java/com/networknt/schema/format/TimeFormat.java b/src/main/java/com/networknt/schema/format/TimeFormat.java index 17327ddc5..7b539b9ea 100644 --- a/src/main/java/com/networknt/schema/format/TimeFormat.java +++ b/src/main/java/com/networknt/schema/format/TimeFormat.java @@ -20,7 +20,6 @@ import java.time.temporal.TemporalAccessor; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import static java.time.format.DateTimeFormatter.ISO_LOCAL_TIME; import static java.time.temporal.ChronoField.*; diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 6af98ac52..960bd12f6 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -17,10 +17,10 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Format; import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.format.Format; import com.networknt.schema.SchemaContext; import java.util.Collection; diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index af4211877..0b1a2fd92 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -18,12 +18,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Format; import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.format.BaseFormatValidator; +import com.networknt.schema.format.Format; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index d79b463bc..9b022b976 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.format.Format; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index ca85350b9..af2870433 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.format.Format; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.KeywordValidator; diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 6d862f6c0..4ccb108d1 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -30,6 +30,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.format.Format; import com.networknt.schema.format.PatternFormat; import com.networknt.schema.output.OutputUnit; diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index e38e2b999..71fb99917 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.format.Format; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index bf152f347..bb0a9daaa 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.format.Format; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; From f58168225c7d37fe3e68ae4a13ed73115b9664f7 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:15:07 +0800 Subject: [PATCH 38/74] Remove AbstractFormat and BaseFormat --- .../schema/format/AbstractFormat.java | 42 ------------------- .../networknt/schema/format/BaseFormat.java | 41 ------------------ 2 files changed, 83 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/format/AbstractFormat.java delete mode 100644 src/main/java/com/networknt/schema/format/BaseFormat.java diff --git a/src/main/java/com/networknt/schema/format/AbstractFormat.java b/src/main/java/com/networknt/schema/format/AbstractFormat.java deleted file mode 100644 index 73d85e909..000000000 --- a/src/main/java/com/networknt/schema/format/AbstractFormat.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.format; - -import com.networknt.schema.ExecutionContext; - -/** - * Used for Formats that do not need to use the {@link ExecutionContext}. - */ -@Deprecated -public abstract class AbstractFormat extends BaseFormat { - /** - * Constructor. - * - * @param name the name - * @param errorMessageDescription the error message description - */ - public AbstractFormat(String name, String errorMessageDescription) { - super(name, errorMessageDescription); - } - - @Override - public boolean matches(ExecutionContext executionContext, String value) { - return matches(value); - } - - abstract public boolean matches(String value); -} diff --git a/src/main/java/com/networknt/schema/format/BaseFormat.java b/src/main/java/com/networknt/schema/format/BaseFormat.java deleted file mode 100644 index 207c66212..000000000 --- a/src/main/java/com/networknt/schema/format/BaseFormat.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.format; - -/** - * Base implementation of {@link Format}. - */ -@Deprecated -public abstract class BaseFormat implements Format { - private final String name; - private final String errorMessageDescription; - - public BaseFormat(String name, String errorMessageDescription) { - this.name = name; - this.errorMessageDescription = errorMessageDescription; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getErrorMessageDescription() { - return errorMessageDescription; - } -} From 6b011d3fbe9c31da8c4b28db4ade3e71ae5c5722 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:57:37 +0800 Subject: [PATCH 39/74] Refactor format --- .../schema/format/AbstractRFC3986Format.java | 2 +- .../com/networknt/schema/format/Format.java | 25 +++---------- .../schema/format/PatternFormat.java | 20 ++--------- src/main/resources/jsv-messages.properties | 2 +- src/main/resources/jsv-messages_ar.properties | 2 +- src/main/resources/jsv-messages_cs.properties | 2 +- src/main/resources/jsv-messages_da.properties | 2 +- src/main/resources/jsv-messages_de.properties | 2 +- src/main/resources/jsv-messages_es.properties | 2 +- src/main/resources/jsv-messages_fa.properties | 2 +- src/main/resources/jsv-messages_fi.properties | 2 +- src/main/resources/jsv-messages_fr.properties | 2 +- src/main/resources/jsv-messages_he.properties | 2 +- src/main/resources/jsv-messages_hr.properties | 2 +- src/main/resources/jsv-messages_hu.properties | 2 +- src/main/resources/jsv-messages_it.properties | 2 +- src/main/resources/jsv-messages_ja.properties | 2 +- src/main/resources/jsv-messages_ko.properties | 2 +- src/main/resources/jsv-messages_nb.properties | 2 +- src/main/resources/jsv-messages_nl.properties | 2 +- src/main/resources/jsv-messages_pl.properties | 2 +- src/main/resources/jsv-messages_pt.properties | 2 +- src/main/resources/jsv-messages_ro.properties | 2 +- src/main/resources/jsv-messages_ru.properties | 2 +- src/main/resources/jsv-messages_sk.properties | 2 +- src/main/resources/jsv-messages_sv.properties | 2 +- src/main/resources/jsv-messages_th.properties | 2 +- src/main/resources/jsv-messages_tr.properties | 2 +- src/main/resources/jsv-messages_uk.properties | 2 +- src/main/resources/jsv-messages_vi.properties | 2 +- .../resources/jsv-messages_zh_CN.properties | 2 +- .../resources/jsv-messages_zh_TW.properties | 2 +- .../schema/CollectorContextTest.java | 6 ---- .../networknt/schema/FormatValidatorTest.java | 36 ++++--------------- .../com/networknt/schema/Issue784Test.java | 5 --- .../com/networknt/schema/Issue832Test.java | 2 +- 36 files changed, 44 insertions(+), 110 deletions(-) diff --git a/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java b/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java index 2eacc9a04..a97a053ab 100644 --- a/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java +++ b/src/main/java/com/networknt/schema/format/AbstractRFC3986Format.java @@ -7,7 +7,7 @@ import com.networknt.schema.ExecutionContext; /** - * {@link AbstractFormat} for RFC 3986. + * {@link Format} for RFC 3986 Uniform Resource Identifier (URI): Generic Syntax. */ public abstract class AbstractRFC3986Format implements Format { private static final Pattern VALID = Pattern.compile("([A-Za-z0-9+-\\.]*:)?//|[A-Za-z0-9+-\\.]+:"); diff --git a/src/main/java/com/networknt/schema/format/Format.java b/src/main/java/com/networknt/schema/format/Format.java index 02b8c4b19..18c81c209 100644 --- a/src/main/java/com/networknt/schema/format/Format.java +++ b/src/main/java/com/networknt/schema/format/Format.java @@ -25,7 +25,6 @@ import com.networknt.schema.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.TypeFactory; -import com.networknt.schema.MessageSourceError.Builder; import com.networknt.schema.keyword.FormatValidator; /** @@ -47,10 +46,10 @@ public interface Format { * See jsv-messages.properties. *

* The following are the arguments.
- * {0} The instance location
- * {1} The format name
- * {2} The error message description
- * {3} The input value + * {0} The format name
+ * {1} The input value + *

+ * Note that the default localized messages do not use the input value. * * @return the message key */ @@ -58,20 +57,6 @@ default String getMessageKey() { return "format"; } - /** - * Gets the error message description. - *

- * Deprecated. Override getMessageKey() and set the localized message in the - * resource bundle or message source. - * - * @return the error message description. - */ - @Deprecated - default String getErrorMessageDescription() { - return ""; - } - - /** * Determines if the value matches the format. *

@@ -154,7 +139,7 @@ default void validate(ExecutionContext executionContext, SchemaContext schemaCon if (!matches(executionContext, schemaContext, node, rootNode, instanceLocation, assertionsEnabled, formatValidator)) { executionContext.addError(message.get() - .arguments(this.getName(), this.getErrorMessageDescription(), node.asText()).build()); + .arguments(this.getName(), node.asText()).build()); } } } diff --git a/src/main/java/com/networknt/schema/format/PatternFormat.java b/src/main/java/com/networknt/schema/format/PatternFormat.java index 4b2e584dc..c980da7ab 100644 --- a/src/main/java/com/networknt/schema/format/PatternFormat.java +++ b/src/main/java/com/networknt/schema/format/PatternFormat.java @@ -27,7 +27,6 @@ public class PatternFormat implements Format { private final String name; private final Pattern pattern; private final String messageKey; - private final String errorMessageDescription; /** * Constructor. @@ -36,19 +35,9 @@ public class PatternFormat implements Format { * * @param name the name * @param regex the regex - * @param errorMessageDescription the error message description */ - @Deprecated - public PatternFormat(String name, String regex, String errorMessageDescription) { + private PatternFormat(String name, String regex, String messageKey) { this.name = name; - this.errorMessageDescription = errorMessageDescription != null ? errorMessageDescription : regex; - this.messageKey = "format"; - this.pattern = Pattern.compile(regex); - } - - private PatternFormat(String name, String regex, String errorMessageDescription, String messageKey) { - this.name = name; - this.errorMessageDescription = errorMessageDescription != null ? errorMessageDescription : regex; this.messageKey = messageKey; this.pattern = Pattern.compile(regex); } @@ -62,7 +51,7 @@ private PatternFormat(String name, String regex, String errorMessageDescription, * @return the pattern format */ public static PatternFormat of(String name, String regex, String messageKey) { - return new PatternFormat(name, regex, null, messageKey != null ? messageKey : "format"); + return new PatternFormat(name, regex, messageKey != null ? messageKey : "format"); } @Override @@ -79,9 +68,4 @@ public String getName() { public String getMessageKey() { return this.messageKey; } - - @Override - public String getErrorMessageDescription() { - return this.errorMessageDescription; - } } diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 8e3d3d845..53e054b24 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -14,7 +14,7 @@ enum = does not have a value in the enumeration {0} exclusiveMaximum = must have an exclusive maximum value of {0} exclusiveMinimum = must have an exclusive minimum value of {0} false = schema for ''{0}'' is false -format = does not match the {0} pattern {1} +format = does not match the {0} pattern format.date = does not match the {0} pattern must be a valid RFC 3339 full-date format.date-time = does not match the {0} pattern must be a valid RFC 3339 date-time format.duration = does not match the {0} pattern must be a valid ISO 8601 duration diff --git a/src/main/resources/jsv-messages_ar.properties b/src/main/resources/jsv-messages_ar.properties index d6e0e0e47..6016c7319 100644 --- a/src/main/resources/jsv-messages_ar.properties +++ b/src/main/resources/jsv-messages_ar.properties @@ -14,7 +14,7 @@ enum = \u0644\u0627 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u06 exclusiveMaximum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0644\u0647 \u0642\u064A\u0645\u0629 \u0642\u0635\u0648\u0649 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {0} exclusiveMinimum = \u064A\u062C\u0628 \u0623\u0646 \u064A\u062D\u062A\u0648\u064A \u0639\u0644\u0649 \u0642\u064A\u0645\u0629 \u062F\u0646\u064A\u0627 \u062D\u0635\u0631\u064A\u0629 \u062A\u0628\u0644\u063A {0} false = \u0645\u062E\u0637\u0637 ''{0}'' \u063A\u064A\u0631 \u0635\u062D\u064A\u062D -format = \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 {0} {1} +format = \u0644\u0627 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 {0} format.date = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0643\u0627\u0645\u0644\u0627\u064B \u0635\u0627\u0644\u062D\u064B\u0627 \u0644\u0640 RFC 3339 format.date-time = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u062A\u0627\u0631\u064A\u062E\u064B\u0627 \u0648\u0648\u0642\u062A\u064B\u0627 \u0635\u0627\u0644\u062D\u064B\u0627 \u0641\u064A RFC 3339 format.duration = \u0644\u0627 \u064A\u062A\u0637\u0627\u0628\u0642 \u0645\u0639 \u0627\u0644\u0646\u0645\u0637 {0} \u0648\u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0645\u062F\u0629 ISO 8601 \u0635\u0627\u0644\u062D\u0629 diff --git a/src/main/resources/jsv-messages_cs.properties b/src/main/resources/jsv-messages_cs.properties index f704ac45a..d6b35668c 100644 --- a/src/main/resources/jsv-messages_cs.properties +++ b/src/main/resources/jsv-messages_cs.properties @@ -14,7 +14,7 @@ enum = nem exclusiveMaximum = musí mít exkluzivní maximální hodnotu {0} exclusiveMinimum = musí mít exkluzivní minimální hodnotu {0} false = schéma pro ''{0}'' je nepravdivé -format = neodpovídá vzoru {0} {1} +format = neodpovídá vzoru {0} format.date = neodpovídá vzoru {0} musí být platné plné datum RFC 3339 format.date-time = neodpovídá vzoru {0} musí být platné datum a \u010Das RFC 3339 format.duration = neodpovídá vzoru {0}, musí mít platnou dobu trvání ISO 8601 diff --git a/src/main/resources/jsv-messages_da.properties b/src/main/resources/jsv-messages_da.properties index 790a7bf8b..f1eaa1375 100644 --- a/src/main/resources/jsv-messages_da.properties +++ b/src/main/resources/jsv-messages_da.properties @@ -14,7 +14,7 @@ enum = har ikke en v exclusiveMaximum = skal have en eksklusiv maksimumværdi på {0} exclusiveMinimum = skal have en eksklusiv minimumsværdi på {0} false = skemaet for ''{0}'' er falsk -format = matcher ikke {0}-mønsteret {1} +format = matcher ikke {0}-mønsteret format.date = matcher ikke {0}-mønsteret skal være en gyldig RFC 3339 fuld-dato format.date-time = matcher ikke {0}-mønsteret skal være en gyldig RFC 3339 dato-tid format.duration = matcher ikke {0}-mønsteret skal være en gyldig ISO 8601-varighed diff --git a/src/main/resources/jsv-messages_de.properties b/src/main/resources/jsv-messages_de.properties index 5daed1825..7eae3b691 100644 --- a/src/main/resources/jsv-messages_de.properties +++ b/src/main/resources/jsv-messages_de.properties @@ -14,7 +14,7 @@ enum = hat keinen Wert in der Aufz exclusiveMaximum = muss einen exklusiven Maximalwert von {0} haben exclusiveMinimum = muss einen exklusiven Mindestwert von {0} haben false = Schema für ''{0}'' ist falsch -format = entspricht nicht dem Muster {0} {1} +format = entspricht nicht dem Muster {0} format.date = stimmt nicht mit dem {0}-Muster überein, muss ein gültiges RFC 3339-Volldatum sein format.date-time = entspricht nicht dem {0}-Muster. Es muss sich um ein gültiges RFC 3339-Datum/Uhrzeit-Format handeln format.duration = stimmt nicht mit dem {0}-Muster überein, muss eine gültige ISO 8601-Dauer sein diff --git a/src/main/resources/jsv-messages_es.properties b/src/main/resources/jsv-messages_es.properties index f16d03c8a..18a08cf9f 100644 --- a/src/main/resources/jsv-messages_es.properties +++ b/src/main/resources/jsv-messages_es.properties @@ -14,7 +14,7 @@ enum = no tiene un valor en la enumeraci\u00f3n {0} exclusiveMaximum = debe tener un valor m\u00e1ximo exclusivo de {0} exclusiveMinimum = debe tener un valor m\u00ednimo exclusivo de {0} false = el esquema para ''{0}'' es falso -format = no coincide con el patr\u00f3n {0} {1} +format = no coincide con el patr\u00f3n {0} format.date = no coincide con el patr\u00f3n {0}; debe ser un RFC 3339 con fecha completa v\u00e1lido format.date-time = no coincide con el patr\u00f3n {0}; debe ser un RFC 3339 con fecha y hora v\u00e1lido format.duration = no coincide con el patr\u00f3n {0}; debe ser un ISO 8601 de duraci\u00f3n v\u00e1lido diff --git a/src/main/resources/jsv-messages_fa.properties b/src/main/resources/jsv-messages_fa.properties index bc337be39..aa62ea930 100644 --- a/src/main/resources/jsv-messages_fa.properties +++ b/src/main/resources/jsv-messages_fa.properties @@ -14,7 +14,7 @@ enum = \u0645\u0642\u062F\u0627\u0631\u06CC \u062F\u0631 \u0634\u0645\u0627\u063 exclusiveMaximum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u06A9\u062B\u0631 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F exclusiveMinimum = \u0628\u0627\u06CC\u062F \u062D\u062F\u0627\u0642\u0644 \u0645\u0642\u062F\u0627\u0631 \u0627\u0646\u062D\u0635\u0627\u0631\u06CC {0} \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F false = \u0637\u0631\u062D\u0648\u0627\u0631\u0647 ''{0}'' \u0646\u0627\u062F\u0631\u0633\u062A \u0627\u0633\u062A -format = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} {1} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F +format = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F format.date = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u06A9\u0627\u0645\u0644 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F format.date-time = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 RFC 3339 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F format.duration = \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC {0} \u0645\u0637\u0627\u0628\u0642\u062A \u0646\u062F\u0627\u0631\u062F \u0628\u0627\u06CC\u062F \u0645\u062F\u062A \u0632\u0645\u0627\u0646 ISO 8601 \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F diff --git a/src/main/resources/jsv-messages_fi.properties b/src/main/resources/jsv-messages_fi.properties index 93ec79336..7c21d02c0 100644 --- a/src/main/resources/jsv-messages_fi.properties +++ b/src/main/resources/jsv-messages_fi.properties @@ -14,7 +14,7 @@ enum = sill exclusiveMaximum = eksklusiivisen enimmäisarvon on oltava {0} exclusiveMinimum = on oltava yksinomainen vähimmäisarvo {0} false = kaava kohteelle ''{0}'' on epätosi -format = ei vastaa mallia {0} {1} +format = ei vastaa mallia {0} format.date = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3339:n täysi päivämäärä format.date-time = ei vastaa mallia {0}, ja sen on oltava kelvollinen RFC 3339 päivämäärä-aika format.duration = ei vastaa mallia {0}. Sen on oltava kelvollinen ISO 8601 -kesto diff --git a/src/main/resources/jsv-messages_fr.properties b/src/main/resources/jsv-messages_fr.properties index f365b1e6f..e3cb7668b 100644 --- a/src/main/resources/jsv-messages_fr.properties +++ b/src/main/resources/jsv-messages_fr.properties @@ -14,7 +14,7 @@ enum = n''a pas de valeur dans l'' exclusiveMaximum = doit avoir une valeur maximale exclusive de {0} exclusiveMinimum = doit avoir une valeur minimale exclusive de {0} false = le schéma de ''{0}'' est faux -format = ne correspond pas au modèle {0} {1} +format = ne correspond pas au modèle {0} format.date = ne correspond pas au modèle {0} doit être une date complète RFC 3339 valide format.date-time = ne correspond pas au modèle {0} doit être une date-heure RFC 3339 valide format.duration = ne correspond pas au modèle {0} doit être une durée ISO 8601 valide diff --git a/src/main/resources/jsv-messages_he.properties b/src/main/resources/jsv-messages_he.properties index fab7ac4f2..4626eced6 100644 --- a/src/main/resources/jsv-messages_he.properties +++ b/src/main/resources/jsv-messages_he.properties @@ -14,7 +14,7 @@ enum = \u05D0\u05D9\u05DF \u05E2\u05E8\u05DA \u05D1\u05E1\u05E4\u05D9\u05E8\u05D exclusiveMaximum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05E7\u05E1\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {0} exclusiveMinimum = \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05D1\u05E2\u05DC \u05E2\u05E8\u05DA \u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9 \u05D1\u05DC\u05E2\u05D3\u05D9 \u05E9\u05DC {0} false = \u05D4\u05E1\u05DB\u05D9\u05DE\u05D4 \u05E2\u05D1\u05D5\u05E8 ''{0}'' \u05D4\u05D9\u05D0 \u05E9\u05E7\u05E8 -format = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} {1} +format = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} format.date = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05EA\u05D0\u05E8\u05D9\u05DA \u05DE\u05DC\u05D0 RFC 3339 \u05D7\u05D5\u05E7\u05D9 format.date-time = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA RFC 3339 \u05EA\u05D0\u05E8\u05D9\u05DA-\u05E9\u05E2\u05D4 \u05D7\u05D5\u05E7\u05D9 format.duration = \u05D0\u05D9\u05E0\u05D5 \u05EA\u05D5\u05D0\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA {0} \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05E9\u05DA ISO 8601 \u05D7\u05D5\u05E7\u05D9 diff --git a/src/main/resources/jsv-messages_hr.properties b/src/main/resources/jsv-messages_hr.properties index 2ba81a440..6b2060ef3 100644 --- a/src/main/resources/jsv-messages_hr.properties +++ b/src/main/resources/jsv-messages_hr.properties @@ -14,7 +14,7 @@ enum = nema vrijednost u enumeraciji {0} exclusiveMaximum = mora imati isklju\u010Divu maksimalnu vrijednost od {0} exclusiveMinimum = mora imati isklju\u010Divu minimalnu vrijednost od {0} false = shema za ''{0}'' je false -format = ne odgovara {0} uzorku {1} +format = ne odgovara {0} uzorku format.date = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i puni datum RFC 3339 format.date-time = ne odgovara uzorku {0} mora biti va\u017Ee\u0107i RFC 3339 datum-vrijeme format.duration = ne odgovara uzorku {0} mora biti va\u017Ee\u0107e ISO 8601 trajanje diff --git a/src/main/resources/jsv-messages_hu.properties b/src/main/resources/jsv-messages_hu.properties index 9455b2766..2902a37d9 100644 --- a/src/main/resources/jsv-messages_hu.properties +++ b/src/main/resources/jsv-messages_hu.properties @@ -14,7 +14,7 @@ enum = nincs exclusiveMaximum = kizárólagos maximális értéke {0} exclusiveMinimum = kizárólagos minimális értéke {0} false = ''{0}'' séma hamis -format = nem egyezik a {0} mintával {1} +format = nem egyezik a {0} mintával format.date = nem egyezik a(z) {0} mintával, érvényes RFC 3339 teljes dátumúnak kell lennie format.date-time = nem egyezik a {0} mintával, érvényes RFC 3339 dátum-id\u0151 format.duration = nem egyezik a {0} mintával, érvényes ISO 8601 id\u0151tartamnak kell lennie diff --git a/src/main/resources/jsv-messages_it.properties b/src/main/resources/jsv-messages_it.properties index c3ed9dad3..e5738ffbc 100644 --- a/src/main/resources/jsv-messages_it.properties +++ b/src/main/resources/jsv-messages_it.properties @@ -14,7 +14,7 @@ enum = non ha un valore nell''enumerazione {0} exclusiveMaximum = deve avere un valore massimo esclusivo di {0} exclusiveMinimum = deve avere un valore minimo esclusivo di {0} false = lo schema per ''{0}'' è falso -format = non corrisponde al modello {0} {1} +format = non corrisponde al modello {0} format.date = non corrisponde al modello {0} deve essere una data completa RFC 3339 valida format.date-time = non corrisponde al modello {0} deve essere una data-ora RFC 3339 valida format.duration = non corrisponde al modello {0} deve essere una durata ISO 8601 valida diff --git a/src/main/resources/jsv-messages_ja.properties b/src/main/resources/jsv-messages_ja.properties index 36a9ef794..cb2a3259b 100644 --- a/src/main/resources/jsv-messages_ja.properties +++ b/src/main/resources/jsv-messages_ja.properties @@ -14,7 +14,7 @@ enum = \u5217\u6319\u578B {0} \u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093 exclusiveMaximum = \u6392\u4ED6\u7684\u306A\u6700\u5927\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 exclusiveMinimum = \u6392\u4ED6\u7684\u306A\u6700\u5C0F\u5024\u306F {0} \u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093 false = ''{0}'' \u306E\u30B9\u30AD\u30FC\u30DE\u306F false \u3067\u3059 -format = {0} \u30D1\u30BF\u30FC\u30F3 {1} \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 +format = {0} \u30D1\u30BF\u30FC\u30F3 \u306B\u4E00\u81F4\u3057\u307E\u305B\u3093 format.date = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u306E\u5B8C\u5168\u306A\u65E5\u4ED8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 format.date-time = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A RFC 3339 \u65E5\u4ED8/\u6642\u523B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 format.duration = {0} \u30D1\u30BF\u30FC\u30F3\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u6709\u52B9\u306A ISO 8601 \u671F\u9593\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 diff --git a/src/main/resources/jsv-messages_ko.properties b/src/main/resources/jsv-messages_ko.properties index 4bc1605cc..9a61c08aa 100644 --- a/src/main/resources/jsv-messages_ko.properties +++ b/src/main/resources/jsv-messages_ko.properties @@ -14,7 +14,7 @@ enum = \uC5F4\uAC70\uD615 {0}\uC5D0 \uAC12\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. exclusiveMaximum = {0}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uB300\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. exclusiveMinimum = {0}\uC758 \uBC30\uD0C0\uC801 \uCD5C\uC18C\uAC12\uC744 \uAC00\uC838\uC57C \uD569\uB2C8\uB2E4. false = ''{0}''\uC5D0 \uB300\uD55C \uC2A4\uD0A4\uB9C8\uAC00 false\uC785\uB2C8\uB2E4. -format = {0} \uD328\uD134 {1}\uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. +format = {0} \uD328\uD134 \uACFC(\uC640) \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. format.date = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uC804\uCCB4 \uB0A0\uC9DC\uC5EC\uC57C \uD569\uB2C8\uB2E4. format.date-time = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C RFC 3339 \uB0A0\uC9DC-\uC2DC\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. format.duration = {0} \uD328\uD134\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC720\uD6A8\uD55C ISO 8601 \uAE30\uAC04\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. diff --git a/src/main/resources/jsv-messages_nb.properties b/src/main/resources/jsv-messages_nb.properties index 5cad08f72..b536ed4f1 100644 --- a/src/main/resources/jsv-messages_nb.properties +++ b/src/main/resources/jsv-messages_nb.properties @@ -14,7 +14,7 @@ enum = har ikke en verdi i oppregningen {0} exclusiveMaximum = må ha en eksklusiv maksimumsverdi på {0} exclusiveMinimum = må ha en eksklusiv minimumsverdi på {0} false = skjemaet for ''{0}'' er usant -format = samsvarer ikke med {0}-mønsteret {1} +format = samsvarer ikke med {0}-mønsteret format.date = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3339 full-dato format.date-time = samsvarer ikke med {0}-mønsteret må være en gyldig RFC 3339 dato-klokkeslett format.duration = samsvarer ikke med {0}-mønsteret må være en gyldig ISO 8601-varighet diff --git a/src/main/resources/jsv-messages_nl.properties b/src/main/resources/jsv-messages_nl.properties index 800c43e5a..437d94429 100644 --- a/src/main/resources/jsv-messages_nl.properties +++ b/src/main/resources/jsv-messages_nl.properties @@ -14,7 +14,7 @@ enum = heeft geen waarde in de opsomming {0} exclusiveMaximum = moet een exclusieve maximumwaarde hebben van {0} exclusiveMinimum = moet een exclusieve minimumwaarde hebben van {0} false = schema voor ''{0}'' is false -format = komt niet overeen met het {0} patroon {1} +format = komt niet overeen met het {0} patroon format.date = komt niet overeen met het {0}-patroon moet een geldige RFC 3339-volledige datum zijn format.date-time = komt niet overeen met het {0}-patroon moet een geldige RFC 3339-datum-tijd zijn format.duration = komt niet overeen met het patroon {0} moet een geldige ISO 8601-duur hebben diff --git a/src/main/resources/jsv-messages_pl.properties b/src/main/resources/jsv-messages_pl.properties index e68a00d30..4717b151b 100644 --- a/src/main/resources/jsv-messages_pl.properties +++ b/src/main/resources/jsv-messages_pl.properties @@ -14,7 +14,7 @@ enum = nie ma warto\u015Bci w wyliczeniu {0} exclusiveMaximum = musi mie\u0107 wy\u0142\u0105czn\u0105 warto\u015B\u0107 maksymaln\u0105 wynosz\u0105c\u0105 {0} exclusiveMinimum = musi mie\u0107 wy\u0142\u0105czn\u0105 minimaln\u0105 warto\u015B\u0107 {0} false = schemat dla \u201E{0}\u201D jest fa\u0142szywy -format = nie pasuje do wzorca {0} {1} +format = nie pasuje do wzorca {0} format.date = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 pe\u0142n\u0105 dat\u0105 RFC 3339 format.date-time = nie pasuje do wzorca {0} musi by\u0107 prawid\u0142ow\u0105 dat\u0105 i godzin\u0105 RFC 3339 format.duration = nie pasuje do wzorca {0}, musi mie\u0107 prawid\u0142owy czas trwania ISO 8601 diff --git a/src/main/resources/jsv-messages_pt.properties b/src/main/resources/jsv-messages_pt.properties index c3dedcbe2..39b130852 100644 --- a/src/main/resources/jsv-messages_pt.properties +++ b/src/main/resources/jsv-messages_pt.properties @@ -14,7 +14,7 @@ enum = n exclusiveMaximum = deve ter um valor máximo exclusivo de {0} exclusiveMinimum = deve ter um valor mínimo exclusivo de {0} false = o esquema para ''{0}'' é falso -format = não corresponde ao padrão {0} {1} +format = não corresponde ao padrão {0} format.date = não corresponde ao padrão {0} deve ser uma data completa RFC 3339 válida format.date-time = não corresponde ao padrão {0} deve ser uma data e hora RFC 3339 válida format.duration = não corresponde ao padrão {0} deve ter uma duração ISO 8601 válida diff --git a/src/main/resources/jsv-messages_ro.properties b/src/main/resources/jsv-messages_ro.properties index c0978f555..2c5fcbe72 100644 --- a/src/main/resources/jsv-messages_ro.properties +++ b/src/main/resources/jsv-messages_ro.properties @@ -14,7 +14,7 @@ enum = nu are o valoare exclusiveMaximum = trebuie s\u0103 aib\u0103 o valoare maxim\u0103 exclusiv\u0103 de {0} exclusiveMinimum = trebuie s\u0103 aib\u0103 o valoare minim\u0103 exclusiv\u0103 de {0} false = schema pentru \u201E{0}\u201D este fals\u0103 -format = nu se potrive\u0219te cu modelul {0} {1} +format = nu se potrive\u0219te cu modelul {0} format.date = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o dat\u0103 complet\u0103 RFC 3339 valid\u0103 format.date-time = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie un RFC 3339 data-ora valid format.duration = nu se potrive\u0219te cu modelul {0} trebuie s\u0103 fie o durat\u0103 ISO 8601 valid\u0103 diff --git a/src/main/resources/jsv-messages_ru.properties b/src/main/resources/jsv-messages_ru.properties index 23c171413..b0e9eaf13 100644 --- a/src/main/resources/jsv-messages_ru.properties +++ b/src/main/resources/jsv-messages_ru.properties @@ -14,7 +14,7 @@ enum = \u043D\u0435 \u0438\u043C\u0435\u0435\u0442 \u0437\u043D\u0430\u0447\u043 exclusiveMaximum = \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u044D\u043A\u0441\u043A\u043B\u044E\u0437\u0438\u0432\u043D\u043E\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {0}. exclusiveMinimum = \u0434\u043E\u043B\u0436\u043D\u043E \u0438\u043C\u0435\u0442\u044C \u0438\u0441\u043A\u043B\u044E\u0447\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 {0}. false = \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{0}'' \u043D\u0435\u0432\u0435\u0440\u043D\u0430 -format = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} {1} +format = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} format.date = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u043E\u043B\u043D\u0430\u044F \u0434\u0430\u0442\u0430 RFC 3339. format.date-time = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u0430\u044F \u0434\u0430\u0442\u0430-\u0432\u0440\u0435\u043C\u044F RFC 3339. format.duration = \u043D\u0435 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C ISO 8601. diff --git a/src/main/resources/jsv-messages_sk.properties b/src/main/resources/jsv-messages_sk.properties index a027a6988..68a4d5732 100644 --- a/src/main/resources/jsv-messages_sk.properties +++ b/src/main/resources/jsv-messages_sk.properties @@ -14,7 +14,7 @@ enum = nem exclusiveMaximum = musí ma\u0165 výlu\u010Dnú maximálnu hodnotu {0} exclusiveMinimum = musí ma\u0165 výlu\u010Dnú minimálnu hodnotu {0} false = schéma pre ''{0}'' je nepravda -format = nezhoduje sa so vzorom {0} {1} +format = nezhoduje sa so vzorom {0} format.date = nezhoduje sa so vzorom {0}, musí to by\u0165 platný úplný dátum RFC 3339 format.date-time = nezhoduje sa so vzorom {0}, musí to by\u0165 platný dátum a \u010Das RFC 3339 format.duration = nezhoduje sa so vzorom {0}, musí ma\u0165 platné trvanie ISO 8601 diff --git a/src/main/resources/jsv-messages_sv.properties b/src/main/resources/jsv-messages_sv.properties index f99caa869..7d969a797 100644 --- a/src/main/resources/jsv-messages_sv.properties +++ b/src/main/resources/jsv-messages_sv.properties @@ -14,7 +14,7 @@ enum = har inget v exclusiveMaximum = måste ha ett exklusivt maxvärde på {0} exclusiveMinimum = måste ha ett exklusivt lägsta värde på {0} false = schemat för ''{0}'' är falskt -format = matchar inte {0}-mönstret {1} +format = matchar inte {0}-mönstret format.date = matchar inte {0}-mönstret måste vara ett giltigt RFC 3339 fulldatum format.date-time = matchar inte {0}-mönstret måste vara ett giltigt RFC 3339 datum-tid format.duration = matchar inte {0}-mönstret måste vara en giltig ISO 8601-varaktighet diff --git a/src/main/resources/jsv-messages_th.properties b/src/main/resources/jsv-messages_th.properties index 201a6191d..214954654 100644 --- a/src/main/resources/jsv-messages_th.properties +++ b/src/main/resources/jsv-messages_th.properties @@ -14,7 +14,7 @@ enum = \u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32\u0E43\u0E19\u0E01\u0E32\ exclusiveMaximum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {0} exclusiveMinimum = \u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E2A\u0E38\u0E14\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E40\u0E1B\u0E47\u0E19 {0} false = \u0E2A\u0E04\u0E35\u0E21\u0E32\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A ''{0}'' \u0E40\u0E1B\u0E47\u0E19\u0E40\u0E17\u0E47\u0E08 -format = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} {1} +format = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} format.date = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E15\u0E47\u0E21 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 format.date-time = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48-\u0E40\u0E27\u0E25\u0E32 RFC 3339 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 format.duration = \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A {0} \u0E08\u0E30\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E23\u0E30\u0E22\u0E30\u0E40\u0E27\u0E25\u0E32 ISO 8601 \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 diff --git a/src/main/resources/jsv-messages_tr.properties b/src/main/resources/jsv-messages_tr.properties index 08823b951..f9e69bf7a 100644 --- a/src/main/resources/jsv-messages_tr.properties +++ b/src/main/resources/jsv-messages_tr.properties @@ -14,7 +14,7 @@ enum = {0} numaraland\u0131rmas\u0131nda bir de\u011Fer yok exclusiveMaximum = özel maksimum de\u011Feri {0} olmal\u0131d\u0131r exclusiveMinimum = özel minimum de\u011Feri {0} olmal\u0131d\u0131r false = ''{0}'' \u015Femas\u0131 yanl\u0131\u015F -format = {0} modeliyle {1} e\u015Fle\u015Fmiyor +format = {0} modeliyle e\u015Fle\u015Fmiyor format.date = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tam tarihi olmal\u0131d\u0131r format.date-time = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir RFC 3339 tarih-saat olmal\u0131d\u0131r format.duration = {0} modeliyle e\u015Fle\u015Fmiyor, geçerli bir ISO 8601 süresi olmal\u0131d\u0131r diff --git a/src/main/resources/jsv-messages_uk.properties b/src/main/resources/jsv-messages_uk.properties index 2e8d1b464..0a2734405 100644 --- a/src/main/resources/jsv-messages_uk.properties +++ b/src/main/resources/jsv-messages_uk.properties @@ -14,7 +14,7 @@ enum = \u043D\u0435 \u043C\u0430\u0454 \u0437\u043D\u0430\u0447\u0435\u043D\u043 exclusiveMaximum = \u043C\u0430\u0454 \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} exclusiveMinimum = \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u043C\u0430\u0442\u0438 \u0432\u0438\u043D\u044F\u0442\u043A\u043E\u0432\u0435 \u043C\u0456\u043D\u0456\u043C\u0430\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F {0} false = \u0441\u0445\u0435\u043C\u0430 \u0434\u043B\u044F ''{0}'' \u043D\u0435\u0432\u0456\u0440\u043D\u0430 -format = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} {1} +format = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} format.date = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u043F\u043E\u0432\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E RFC 3339 format.date-time = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0} \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0434\u0430\u0442\u043E\u044E-\u0447\u0430\u0441\u043E\u043C RFC 3339 format.duration = \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 {0}, \u043C\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u0456\u0439\u0441\u043D\u043E\u044E \u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044E ISO 8601 diff --git a/src/main/resources/jsv-messages_vi.properties b/src/main/resources/jsv-messages_vi.properties index aa18b6e53..7e7f33ec5 100644 --- a/src/main/resources/jsv-messages_vi.properties +++ b/src/main/resources/jsv-messages_vi.properties @@ -14,7 +14,7 @@ enum = kh exclusiveMaximum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i \u0111a \u0111\u1ED9c quy\u1EC1n là {0} exclusiveMinimum = ph\u1EA3i có giá tr\u1ECB t\u1ED1i thi\u1EC3u duy nh\u1EA5t là {0} false = l\u01B0\u1EE3c \u0111\u1ED3 cho ''{0}'' là sai -format = không kh\u1EDBp v\u1EDBi m\u1EABu {0} {1} +format = không kh\u1EDBp v\u1EDBi m\u1EABu {0} format.date = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là ngày \u0111\u1EA7y \u0111\u1EE7 RFC 3339 h\u1EE3p l\u1EC7 format.date-time = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i là ngày gi\u1EDD h\u1EE3p l\u1EC7 RFC 3339 format.duration = không kh\u1EDBp v\u1EDBi m\u1EABu {0} ph\u1EA3i có th\u1EDDi l\u01B0\u1EE3ng ISO 8601 h\u1EE3p l\u1EC7 diff --git a/src/main/resources/jsv-messages_zh_CN.properties b/src/main/resources/jsv-messages_zh_CN.properties index 30caad9b3..be6defbbe 100644 --- a/src/main/resources/jsv-messages_zh_CN.properties +++ b/src/main/resources/jsv-messages_zh_CN.properties @@ -14,7 +14,7 @@ enum = \u679A\u4E3E {0} \u4E2D\u6CA1\u6709\u503C exclusiveMaximum = \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5927\u503C {0} exclusiveMinimum = \u5FC5\u987B\u5177\u6709\u72EC\u5360\u6700\u5C0F\u503C {0} false = \u201C{0}\u201D\u7684\u67B6\u6784\u4E3A false -format = \u4E0E {0} \u6A21\u5F0F {1} \u4E0D\u5339\u914D +format = \u4E0E {0} \u6A21\u5F0F \u4E0D\u5339\u914D format.date = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F format.date-time = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u65F6\u95F4 format.duration = \u4E0E {0} \u6A21\u5F0F\u4E0D\u5339\u914D\u5FC5\u987B\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7EED\u65F6\u95F4 diff --git a/src/main/resources/jsv-messages_zh_TW.properties b/src/main/resources/jsv-messages_zh_TW.properties index 14c1dde19..122306ed3 100644 --- a/src/main/resources/jsv-messages_zh_TW.properties +++ b/src/main/resources/jsv-messages_zh_TW.properties @@ -14,7 +14,7 @@ enum = \u679A\u8209 {0} \u4E2D\u6C92\u6709\u503C exclusiveMaximum = \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5927\u503C {0} exclusiveMinimum = \u5FC5\u9808\u5177\u6709\u7368\u4F54\u6700\u5C0F\u503C {0} false = \u300C{0}\u300D\u7684\u67B6\u69CB\u70BA false -format = \u8207 {0} \u6A21\u5F0F {1} \u4E0D\u5339\u914D +format = \u8207 {0} \u6A21\u5F0F \u4E0D\u5339\u914D format.date = \u8207 {0} \u6A21\u5F0F\u4E0D\u5339\u914D\uFF0C\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u5B8C\u6574\u65E5\u671F format.date-time = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 RFC 3339 \u65E5\u671F\u6642\u9593 format.duration = \u8207 {0} \u6A21\u5F0F\u4E0D\u7B26\u5FC5\u9808\u662F\u6709\u6548\u7684 ISO 8601 \u6301\u7E8C\u6642\u9593 diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 9b022b976..146769a37 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -142,12 +142,6 @@ public boolean matches(ExecutionContext executionContext, String value) { public String getName() { return "sample-format"; } - - // Return null. As are just testing collection context. - @Override - public String getErrorMessageDescription() { - return null; - } }).build(); return dialect; } diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 4ccb108d1..f2196352a 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -31,7 +31,6 @@ import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.format.Format; -import com.networknt.schema.format.PatternFormat; import com.networknt.schema.output.OutputUnit; /** @@ -151,34 +150,6 @@ void formatAssertions(FormatInput formatInput) { assertFalse(messages.isEmpty()); } - /** - * This tests that the changes to use message key doesn't cause a regression to - * the existing message. - */ - @SuppressWarnings("deprecation") - @Test - void patternFormatDeprecated() { - Dialect customDialect = Dialect - .builder("https://www.example.com/schema", Dialects.getDraft7()) - .formats(formats -> { - PatternFormat format = new PatternFormat("custom", "test", "must be test"); - formats.put(format.getName(), format); - }) - .build(); - - SchemaRegistry factory = SchemaRegistry.withDialect(customDialect); - String formatSchema = "{\r\n" - + " \"type\": \"string\",\r\n" - + " \"format\": \"custom\"\r\n" - + "}"; - Schema schema = factory.getSchema(formatSchema); - List messages = schema.validate("\"inval!i:d^(abc]\"", InputFormat.JSON, executionConfiguration -> { - executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); - }); - assertFalse(messages.isEmpty()); - assertEquals(": does not match the custom pattern must be test", messages.iterator().next().toString()); - } - static class CustomNumberFormat implements Format { private final BigDecimal compare; @@ -201,6 +172,11 @@ public boolean matches(ExecutionContext executionContext, SchemaContext schemaCo public String getName() { return "custom-number"; } + + @Override + public String getMessageKey() { + return "does not match the {0} pattern"; + } } @Test @@ -223,7 +199,7 @@ void shouldAllowNumberFormat() { executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); assertFalse(messages.isEmpty()); - assertEquals(": does not match the custom-number pattern ", messages.iterator().next().toString()); + assertEquals(": does not match the custom-number pattern", messages.iterator().next().toString()); messages = schema.validate("12345", InputFormat.JSON, executionConfiguration -> { executionConfiguration.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); }); diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 71fb99917..da483abe1 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -29,11 +29,6 @@ public String getName() { public boolean matches(ExecutionContext executionContext, String value) { return value.equals(FOO_BAR); } - - @Override - public String getErrorMessageDescription() { - return null; - } } @Test diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index bb0a9daaa..9065decdf 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -27,7 +27,7 @@ public String getName() { } @Override - public String getErrorMessageDescription() { + public String getMessageKey() { return "always fail match"; } } From 2b5fdd7e999ea3f9125435d3fdd20b6edcd1f3c8 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 11:02:44 +0800 Subject: [PATCH 40/74] Move CachedSupplier to utils package --- .../java/com/networknt/schema/keyword/DynamicRefValidator.java | 2 +- .../com/networknt/schema/keyword/RecursiveRefValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/RefValidator.java | 2 +- .../java/com/networknt/schema/{ => utils}/CachedSupplier.java | 2 +- .../com/networknt/schema/{ => utils}/CachedSupplierTest.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/com/networknt/schema/{ => utils}/CachedSupplier.java (93%) rename src/test/java/com/networknt/schema/{ => utils}/CachedSupplierTest.java (95%) diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index a07656d71..19ca2d2bc 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -17,7 +17,6 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.CachedSupplier; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; @@ -25,6 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.utils.CachedSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 3d117debf..c2aa830df 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -17,7 +17,6 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.CachedSupplier; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; @@ -25,6 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.utils.CachedSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 826272403..f8bd39f4a 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -17,7 +17,6 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.CachedSupplier; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; @@ -25,6 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.utils.CachedSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/CachedSupplier.java b/src/main/java/com/networknt/schema/utils/CachedSupplier.java similarity index 93% rename from src/main/java/com/networknt/schema/CachedSupplier.java rename to src/main/java/com/networknt/schema/utils/CachedSupplier.java index 4411bdd05..e14af7690 100644 --- a/src/main/java/com/networknt/schema/CachedSupplier.java +++ b/src/main/java/com/networknt/schema/utils/CachedSupplier.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.utils; import java.util.function.Supplier; diff --git a/src/test/java/com/networknt/schema/CachedSupplierTest.java b/src/test/java/com/networknt/schema/utils/CachedSupplierTest.java similarity index 95% rename from src/test/java/com/networknt/schema/CachedSupplierTest.java rename to src/test/java/com/networknt/schema/utils/CachedSupplierTest.java index f0b8cfab5..6f99d1b3c 100644 --- a/src/test/java/com/networknt/schema/CachedSupplierTest.java +++ b/src/test/java/com/networknt/schema/utils/CachedSupplierTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.utils; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; From cc89fd19ad2bbdab0b810e42558312be6f0947ec Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 11:12:12 +0800 Subject: [PATCH 41/74] Rename CachedSupplier to ThreadSafeCachingSupplier and refactor --- .../schema/keyword/DynamicRefValidator.java | 4 ++-- .../schema/keyword/RecursiveRefValidator.java | 4 ++-- .../schema/keyword/RefValidator.java | 4 ++-- .../schema/utils/CachingSupplier.java | 19 ++++++++++--------- ...er.java => ThreadSafeCachingSupplier.java} | 8 ++++---- ...ava => ThreadSafeCachingSupplierTest.java} | 6 +++--- 6 files changed, 23 insertions(+), 22 deletions(-) rename src/main/java/com/networknt/schema/utils/{CachedSupplier.java => ThreadSafeCachingSupplier.java} (80%) rename src/test/java/com/networknt/schema/utils/{CachedSupplierTest.java => ThreadSafeCachingSupplierTest.java} (89%) diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 19ca2d2bc..55727c370 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; -import com.networknt.schema.utils.CachedSupplier; +import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -83,7 +83,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, } static Supplier getSupplier(Supplier supplier, boolean cache) { - return cache ? new CachedSupplier<>(supplier) : supplier; + return cache ? new ThreadSafeCachingSupplier<>(supplier) : supplier; } private static String resolve(Schema parentSchema, String refValue) { diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index c2aa830df..39a49d51a 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; -import com.networknt.schema.utils.CachedSupplier; +import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -57,7 +57,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, } static Supplier getSupplier(Supplier supplier, boolean cache) { - return cache ? new CachedSupplier<>(supplier) : supplier; + return cache ? new ThreadSafeCachingSupplier<>(supplier) : supplier; } static Schema getSchema(Schema parentSchema, SchemaContext schemaContext, String refValue, diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index f8bd39f4a..15df346a3 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; -import com.networknt.schema.utils.CachedSupplier; +import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; @@ -126,7 +126,7 @@ static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, } static Supplier getSupplier(Supplier supplier, boolean cache) { - return cache ? new CachedSupplier<>(supplier) : supplier; + return cache ? new ThreadSafeCachingSupplier<>(supplier) : supplier; } private static void copySchemaResources(SchemaContext schemaContext, Schema schemaResource) { diff --git a/src/main/java/com/networknt/schema/utils/CachingSupplier.java b/src/main/java/com/networknt/schema/utils/CachingSupplier.java index 0f43f9478..bd64d3b97 100644 --- a/src/main/java/com/networknt/schema/utils/CachingSupplier.java +++ b/src/main/java/com/networknt/schema/utils/CachingSupplier.java @@ -22,22 +22,23 @@ * {@link Supplier} that caches the value. *

* This is not threadsafe. - * - * @param the type of results supplied by this supplier + * + * @param the type of results cached by this supplier */ public class CachingSupplier implements Supplier { - private final Supplier delegate; - private T cached = null; + private Supplier delegate; + private T cache = null; - public CachingSupplier(Supplier supplier) { - this.delegate = supplier; + public CachingSupplier(Supplier delegate) { + this.delegate = delegate; } @Override public T get() { - if (this.cached == null) { - this.cached = this.delegate.get(); + if (this.cache == null && this.delegate != null) { + this.cache = this.delegate.get(); + this.delegate = null; } - return this.cached; + return this.cache; } } diff --git a/src/main/java/com/networknt/schema/utils/CachedSupplier.java b/src/main/java/com/networknt/schema/utils/ThreadSafeCachingSupplier.java similarity index 80% rename from src/main/java/com/networknt/schema/utils/CachedSupplier.java rename to src/main/java/com/networknt/schema/utils/ThreadSafeCachingSupplier.java index e14af7690..d4a9c1f63 100644 --- a/src/main/java/com/networknt/schema/utils/CachedSupplier.java +++ b/src/main/java/com/networknt/schema/utils/ThreadSafeCachingSupplier.java @@ -18,15 +18,15 @@ import java.util.function.Supplier; /** - * Supplier that caches the output. + * {@link Supplier} that caches the value. * - * @param the type cached + * @param the type of results cached by this supplier */ -public class CachedSupplier implements Supplier { +public class ThreadSafeCachingSupplier implements Supplier { private volatile Supplier delegate; private volatile T cache = null; - public CachedSupplier(Supplier delegate) { + public ThreadSafeCachingSupplier(Supplier delegate) { this.delegate = delegate; } diff --git a/src/test/java/com/networknt/schema/utils/CachedSupplierTest.java b/src/test/java/com/networknt/schema/utils/ThreadSafeCachingSupplierTest.java similarity index 89% rename from src/test/java/com/networknt/schema/utils/CachedSupplierTest.java rename to src/test/java/com/networknt/schema/utils/ThreadSafeCachingSupplierTest.java index 6f99d1b3c..3c52f11a0 100644 --- a/src/test/java/com/networknt/schema/utils/CachedSupplierTest.java +++ b/src/test/java/com/networknt/schema/utils/ThreadSafeCachingSupplierTest.java @@ -28,10 +28,10 @@ /** * Test for CachedSupplier. */ -class CachedSupplierTest { +class ThreadSafeCachingSupplierTest { @Test void nullValue() { - CachedSupplier supplier = new CachedSupplier<>(null); + ThreadSafeCachingSupplier supplier = new ThreadSafeCachingSupplier<>(null); assertNull(supplier.get()); } @@ -39,7 +39,7 @@ void nullValue() { void concurrency() throws Exception { AtomicInteger value = new AtomicInteger(0); - CachedSupplier supplier = new CachedSupplier<>(() -> { + ThreadSafeCachingSupplier supplier = new ThreadSafeCachingSupplier<>(() -> { return value.addAndGet(1); }); Exception[] instance = new Exception[1]; From 3194331f2c92a260e9616d29d6ee5b53478cde3f Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 11:38:50 +0800 Subject: [PATCH 42/74] Move NodePath and PathType to path package --- src/main/java/com/networknt/schema/Error.java | 1 + src/main/java/com/networknt/schema/ExecutionContext.java | 1 + src/main/java/com/networknt/schema/Schema.java | 2 ++ src/main/java/com/networknt/schema/SchemaContext.java | 1 + src/main/java/com/networknt/schema/SchemaLocation.java | 3 +++ src/main/java/com/networknt/schema/SchemaRegistry.java | 1 + src/main/java/com/networknt/schema/SchemaRegistryConfig.java | 1 + src/main/java/com/networknt/schema/Validator.java | 1 + src/main/java/com/networknt/schema/annotation/Annotation.java | 2 +- .../com/networknt/schema/annotation/AnnotationPredicate.java | 2 +- src/main/java/com/networknt/schema/annotation/Annotations.java | 2 +- src/main/java/com/networknt/schema/dialect/Dialect.java | 2 +- .../java/com/networknt/schema/format/BaseFormatValidator.java | 2 +- src/main/java/com/networknt/schema/format/Format.java | 2 +- .../com/networknt/schema/keyword/AbstractKeywordValidator.java | 2 +- .../schema/keyword/AdditionalPropertiesValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/AllOfValidator.java | 2 +- .../java/com/networknt/schema/keyword/AnnotationKeyword.java | 2 +- src/main/java/com/networknt/schema/keyword/AnyOfValidator.java | 2 +- .../com/networknt/schema/keyword/BaseKeywordValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/ConstValidator.java | 2 +- .../java/com/networknt/schema/keyword/ContainsValidator.java | 2 +- .../com/networknt/schema/keyword/ContentEncodingValidator.java | 2 +- .../networknt/schema/keyword/ContentMediaTypeValidator.java | 2 +- .../com/networknt/schema/keyword/DependenciesValidator.java | 2 +- .../java/com/networknt/schema/keyword/DependentRequired.java | 2 +- .../java/com/networknt/schema/keyword/DependentSchemas.java | 2 +- .../com/networknt/schema/keyword/DiscriminatorValidator.java | 2 +- .../java/com/networknt/schema/keyword/DynamicRefValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/EnumValidator.java | 2 +- .../networknt/schema/keyword/ExclusiveMaximumValidator.java | 2 +- .../networknt/schema/keyword/ExclusiveMinimumValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/FalseValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/FormatKeyword.java | 2 +- .../java/com/networknt/schema/keyword/FormatValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/IfValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/ItemsValidator.java | 2 +- .../com/networknt/schema/keyword/ItemsValidator202012.java | 2 +- src/main/java/com/networknt/schema/keyword/Keyword.java | 2 +- src/main/java/com/networknt/schema/keyword/KeywordType.java | 2 +- .../java/com/networknt/schema/keyword/MaxItemsValidator.java | 2 +- .../java/com/networknt/schema/keyword/MaxLengthValidator.java | 2 +- .../com/networknt/schema/keyword/MaxPropertiesValidator.java | 2 +- .../java/com/networknt/schema/keyword/MaximumValidator.java | 2 +- .../java/com/networknt/schema/keyword/MinItemsValidator.java | 2 +- .../java/com/networknt/schema/keyword/MinLengthValidator.java | 2 +- .../com/networknt/schema/keyword/MinMaxContainsValidator.java | 2 +- .../com/networknt/schema/keyword/MinPropertiesValidator.java | 2 +- .../java/com/networknt/schema/keyword/MinimumValidator.java | 2 +- .../java/com/networknt/schema/keyword/MultipleOfValidator.java | 2 +- .../com/networknt/schema/keyword/NonValidationKeyword.java | 2 +- .../java/com/networknt/schema/keyword/NotAllowedValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/NotValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/OneOfValidator.java | 2 +- .../networknt/schema/keyword/PatternPropertiesValidator.java | 2 +- .../java/com/networknt/schema/keyword/PatternValidator.java | 2 +- .../com/networknt/schema/keyword/PrefixItemsValidator.java | 2 +- .../java/com/networknt/schema/keyword/PropertiesValidator.java | 2 +- .../com/networknt/schema/keyword/PropertyNamesValidator.java | 2 +- .../java/com/networknt/schema/keyword/ReadOnlyValidator.java | 2 +- .../com/networknt/schema/keyword/RecursiveRefValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/RefValidator.java | 2 +- .../java/com/networknt/schema/keyword/RequiredValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/TrueValidator.java | 2 +- src/main/java/com/networknt/schema/keyword/TypeValidator.java | 2 +- .../networknt/schema/keyword/UnevaluatedItemsValidator.java | 2 +- .../schema/keyword/UnevaluatedPropertiesValidator.java | 2 +- .../java/com/networknt/schema/keyword/UnionTypeValidator.java | 2 +- .../com/networknt/schema/keyword/UniqueItemsValidator.java | 2 +- .../java/com/networknt/schema/keyword/WriteOnlyValidator.java | 2 +- .../schema/output/HierarchicalOutputUnitFormatter.java | 2 +- src/main/java/com/networknt/schema/output/OutputUnitKey.java | 2 +- src/main/java/com/networknt/schema/{ => path}/NodePath.java | 2 +- src/main/java/com/networknt/schema/{ => path}/PathType.java | 2 +- src/main/java/com/networknt/schema/result/SchemaResult.java | 2 +- src/main/java/com/networknt/schema/result/SchemaResults.java | 2 +- src/main/java/com/networknt/schema/utils/JsonNodeUtil.java | 2 +- src/main/java/com/networknt/schema/utils/JsonNodes.java | 2 +- .../com/networknt/schema/walk/AbstractWalkListenerRunner.java | 2 +- .../java/com/networknt/schema/walk/ItemWalkListenerRunner.java | 2 +- .../com/networknt/schema/walk/KeywordWalkListenerRunner.java | 2 +- .../com/networknt/schema/walk/PropertyWalkListenerRunner.java | 2 +- src/main/java/com/networknt/schema/walk/WalkConfig.java | 2 +- src/main/java/com/networknt/schema/walk/WalkEvent.java | 2 +- .../java/com/networknt/schema/walk/WalkListenerRunner.java | 2 +- src/main/java/com/networknt/schema/walk/Walker.java | 2 +- src/test/java/com/networknt/schema/AnnotationsTest.java | 2 ++ src/test/java/com/networknt/schema/CollectorContextTest.java | 1 + src/test/java/com/networknt/schema/CustomMetaSchemaTest.java | 1 + .../java/com/networknt/schema/FormatKeywordFactoryTest.java | 1 + src/test/java/com/networknt/schema/IfValidatorTest.java | 1 + src/test/java/com/networknt/schema/Issue467Test.java | 1 + src/test/java/com/networknt/schema/Issue687Test.java | 2 ++ .../java/com/networknt/schema/ItemsValidator202012Test.java | 1 + src/test/java/com/networknt/schema/ItemsValidatorTest.java | 1 + src/test/java/com/networknt/schema/JsonWalkTest.java | 1 + src/test/java/com/networknt/schema/MessageTest.java | 1 + src/test/java/com/networknt/schema/NodePathTest.java | 3 +++ src/test/java/com/networknt/schema/OneOfValidatorTest.java | 1 + .../com/networknt/schema/OverwritingCustomMessageBugTest.java | 1 + .../java/com/networknt/schema/PrefixItemsValidatorTest.java | 1 + .../schema/RecursiveReferenceValidatorExceptionTest.java | 2 ++ src/test/java/com/networknt/schema/SchemaLocationTest.java | 2 ++ src/test/java/com/networknt/schema/oas/OpenApi30Test.java | 2 +- .../java/com/networknt/schema/{ => path}/PathTypeTest.java | 2 +- src/test/java/com/networknt/schema/walk/WalkListenerTest.java | 2 +- 106 files changed, 115 insertions(+), 81 deletions(-) rename src/main/java/com/networknt/schema/{ => path}/NodePath.java (96%) rename src/main/java/com/networknt/schema/{ => path}/PathType.java (99%) rename src/test/java/com/networknt/schema/{ => path}/PathTypeTest.java (96%) diff --git a/src/main/java/com/networknt/schema/Error.java b/src/main/java/com/networknt/schema/Error.java index 843abf393..5d71aa77b 100644 --- a/src/main/java/com/networknt/schema/Error.java +++ b/src/main/java/com/networknt/schema/Error.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.networknt.schema.i18n.MessageFormatter; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.CachingSupplier; import com.networknt.schema.utils.StringUtils; diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 931348c96..4f9d6a07e 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -17,6 +17,7 @@ package com.networknt.schema; import com.networknt.schema.annotation.Annotations; +import com.networknt.schema.path.NodePath; import com.networknt.schema.result.SchemaResults; import com.networknt.schema.walk.WalkConfig; diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 314c44675..1a7a4f248 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -34,6 +34,8 @@ import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.path.PathType; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.JsonNodes; diff --git a/src/main/java/com/networknt/schema/SchemaContext.java b/src/main/java/com/networknt/schema/SchemaContext.java index 53539a3a0..7ff84923d 100644 --- a/src/main/java/com/networknt/schema/SchemaContext.java +++ b/src/main/java/com/networknt/schema/SchemaContext.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.dialect.Dialect; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; /** * The schema context associated with a schema and all its validators. diff --git a/src/main/java/com/networknt/schema/SchemaLocation.java b/src/main/java/com/networknt/schema/SchemaLocation.java index dfedd3d6b..ecbbb3099 100644 --- a/src/main/java/com/networknt/schema/SchemaLocation.java +++ b/src/main/java/com/networknt/schema/SchemaLocation.java @@ -20,6 +20,9 @@ import java.nio.charset.StandardCharsets; import java.util.Objects; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.path.PathType; + /** * The schema location is the canonical IRI of the schema object plus a JSON * Pointer fragment indicating the subschema that produced a result. In contrast diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 9bd7e1854..51d0d5190 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -22,6 +22,7 @@ import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.DialectId; import com.networknt.schema.dialect.DialectRegistry; +import com.networknt.schema.path.NodePath; import com.networknt.schema.resource.DefaultSchemaLoader; import com.networknt.schema.resource.SchemaLoader; import com.networknt.schema.resource.SchemaLoaders; diff --git a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java index b51cc9ac1..053f03a62 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistryConfig.java +++ b/src/main/java/com/networknt/schema/SchemaRegistryConfig.java @@ -18,6 +18,7 @@ import com.networknt.schema.i18n.DefaultMessageSource; import com.networknt.schema.i18n.MessageSource; +import com.networknt.schema.path.PathType; import com.networknt.schema.regex.ECMAScriptRegularExpressionFactory; import com.networknt.schema.regex.JDKRegularExpressionFactory; import com.networknt.schema.regex.RegularExpressionFactory; diff --git a/src/main/java/com/networknt/schema/Validator.java b/src/main/java/com/networknt/schema/Validator.java index 837a668d1..84d295dc5 100644 --- a/src/main/java/com/networknt/schema/Validator.java +++ b/src/main/java/com/networknt/schema/Validator.java @@ -17,6 +17,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.path.NodePath; import com.networknt.schema.walk.Walker; /** diff --git a/src/main/java/com/networknt/schema/annotation/Annotation.java b/src/main/java/com/networknt/schema/annotation/Annotation.java index 6649b05f0..a3638498d 100644 --- a/src/main/java/com/networknt/schema/annotation/Annotation.java +++ b/src/main/java/com/networknt/schema/annotation/Annotation.java @@ -17,9 +17,9 @@ import java.util.Objects; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.path.NodePath; /** * The annotation. diff --git a/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java b/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java index 2fe8f44ad..c9268e17c 100644 --- a/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java +++ b/src/main/java/com/networknt/schema/annotation/AnnotationPredicate.java @@ -17,8 +17,8 @@ import java.util.function.Predicate; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; /** * A predicate for filtering annotations. diff --git a/src/main/java/com/networknt/schema/annotation/Annotations.java b/src/main/java/com/networknt/schema/annotation/Annotations.java index f1fdbeb82..581f73b8f 100644 --- a/src/main/java/com/networknt/schema/annotation/Annotations.java +++ b/src/main/java/com/networknt/schema/annotation/Annotations.java @@ -21,7 +21,7 @@ import java.util.Map; import com.fasterxml.jackson.core.JsonProcessingException; -import com.networknt.schema.NodePath; +import com.networknt.schema.path.NodePath; import com.networknt.schema.serialization.JsonMapperFactory; /** diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index c29901d50..4d9ac99e2 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; @@ -31,6 +30,7 @@ import com.networknt.schema.keyword.KeywordFactory; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.UnknownKeywordFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.StringUtils; import com.networknt.schema.vocabulary.Vocabularies; diff --git a/src/main/java/com/networknt/schema/format/BaseFormatValidator.java b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java index ae79b1f57..31cda4d2b 100644 --- a/src/main/java/com/networknt/schema/format/BaseFormatValidator.java +++ b/src/main/java/com/networknt/schema/format/BaseFormatValidator.java @@ -4,13 +4,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; +import com.networknt.schema.path.NodePath; public abstract class BaseFormatValidator extends BaseKeywordValidator { protected final boolean assertionsEnabled; diff --git a/src/main/java/com/networknt/schema/format/Format.java b/src/main/java/com/networknt/schema/format/Format.java index 18c81c209..3aeffb14c 100644 --- a/src/main/java/com/networknt/schema/format/Format.java +++ b/src/main/java/com/networknt/schema/format/Format.java @@ -22,10 +22,10 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.JsonType; import com.networknt.schema.MessageSourceError; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.TypeFactory; import com.networknt.schema.keyword.FormatValidator; +import com.networknt.schema.path.NodePath; /** * Used to implement the various formats for the format keyword. diff --git a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java index 894319663..9de8740fe 100644 --- a/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AbstractKeywordValidator.java @@ -20,9 +20,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; /** * Abstract {@link KeywordValidator}. diff --git a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java index 66a49e21f..6359ef392 100644 --- a/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AdditionalPropertiesValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.regex.RegularExpression; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index c931ebcbc..063e67a37 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -22,12 +22,12 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java index 946756ff0..1a0b17af0 100644 --- a/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/AnnotationKeyword.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 99203fa88..385026f41 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -20,12 +20,12 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java index 23eab3c0c..c58d4b8eb 100644 --- a/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java +++ b/src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java @@ -18,10 +18,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ErrorMessages; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.Collection; diff --git a/src/main/java/com/networknt/schema/keyword/ConstValidator.java b/src/main/java/com/networknt/schema/keyword/ConstValidator.java index 782c5f631..d1d1fec9f 100644 --- a/src/main/java/com/networknt/schema/keyword/ConstValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ConstValidator.java @@ -17,9 +17,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index 2fb624459..a9c43deaf 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -19,11 +19,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import static com.networknt.schema.SpecificationVersionRange.MinV201909; diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index aa0656dcd..925085807 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.Base64; diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 48e3a3c6b..6ae7d7fc6 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.serialization.JsonMapperFactory; diff --git a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java index 60ad5c0e3..c3426f70c 100644 --- a/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DependenciesValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/DependentRequired.java b/src/main/java/com/networknt/schema/keyword/DependentRequired.java index 8e3b9dc13..d6848c438 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentRequired.java +++ b/src/main/java/com/networknt/schema/keyword/DependentRequired.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java index 6d5020e19..fb27538d2 100644 --- a/src/main/java/com/networknt/schema/keyword/DependentSchemas.java +++ b/src/main/java/com/networknt/schema/keyword/DependentSchemas.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 7486b64e9..d7a7e5a43 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -26,10 +26,10 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java index 55727c370..35648c6f4 100644 --- a/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java @@ -20,10 +20,10 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index efa5f97cf..d1e2c3f63 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -21,11 +21,11 @@ import com.fasterxml.jackson.databind.node.DecimalNode; import com.fasterxml.jackson.databind.node.NullNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.math.BigDecimal; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index 26e0f2138..bfaf9f55e 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index e88476803..43f21f18a 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/FalseValidator.java b/src/main/java/com/networknt/schema/keyword/FalseValidator.java index ebba6ed22..dd1aaf578 100644 --- a/src/main/java/com/networknt/schema/keyword/FalseValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FalseValidator.java @@ -17,9 +17,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java index 960bd12f6..1c21e4f13 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/FormatKeyword.java @@ -17,10 +17,10 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.format.Format; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.Collection; diff --git a/src/main/java/com/networknt/schema/keyword/FormatValidator.java b/src/main/java/com/networknt/schema/keyword/FormatValidator.java index 0b1a2fd92..aa26df6d4 100644 --- a/src/main/java/com/networknt/schema/keyword/FormatValidator.java +++ b/src/main/java/com/networknt/schema/keyword/FormatValidator.java @@ -18,12 +18,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.format.BaseFormatValidator; import com.networknt.schema.format.Format; +import com.networknt.schema.path.NodePath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/keyword/IfValidator.java b/src/main/java/com/networknt/schema/keyword/IfValidator.java index cf18ea960..65923bdc6 100644 --- a/src/main/java/com/networknt/schema/keyword/IfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/IfValidator.java @@ -19,9 +19,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index cca954a0f..40693607d 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.SchemaRefs; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java index 234dc2211..99289a180 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.SchemaRefs; /** diff --git a/src/main/java/com/networknt/schema/keyword/Keyword.java b/src/main/java/com/networknt/schema/keyword/Keyword.java index f5cbf91b3..93a01b666 100644 --- a/src/main/java/com/networknt/schema/keyword/Keyword.java +++ b/src/main/java/com/networknt/schema/keyword/Keyword.java @@ -17,10 +17,10 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/KeywordType.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java index 72c864353..5446cce6c 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordType.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -17,11 +17,11 @@ package com.networknt.schema.keyword; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.SpecificationVersionRange; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java index 5c1a2f35b..11b405213 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxItemsValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 28643892a..25ac5acbb 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java index 85f6ee159..20719d936 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxPropertiesValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index c47364855..a4fb0509e 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java index 6230165a3..48181b1a5 100644 --- a/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinItemsValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index 94ed117e9..43ce44d47 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java index 2c46a26f9..68d0b3564 100644 --- a/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinMaxContainsValidator.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.LinkedHashSet; diff --git a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java index 2d8196411..bf6142746 100644 --- a/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinPropertiesValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index a6c2bcf9c..4a46e4a73 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index 5e4bb272a..bcf12d111 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java index 8ddba73da..83c857e0c 100644 --- a/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/keyword/NonValidationKeyword.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.Iterator; diff --git a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java index d24233e40..332650609 100644 --- a/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotAllowedValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index 9d5f55926..e3d41782b 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -19,9 +19,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 32691129c..55e9594e9 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -24,12 +24,12 @@ import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java index 4f8571207..2af8ee6d2 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternPropertiesValidator.java @@ -18,12 +18,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.regex.RegularExpression; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index 1742f0886..3a2945b71 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.FailFastAssertionException; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.regex.RegularExpression; import org.slf4j.Logger; diff --git a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java index bf3d1d7eb..2db49e477 100644 --- a/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.SchemaRefs; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java index 982929730..ba92c18fa 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertiesValidator.java @@ -21,12 +21,12 @@ import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRef; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.SchemaRefs; import com.networknt.schema.walk.WalkListenerRunner; import java.util.Collections; diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 30dc871e5..1819b038a 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -23,9 +23,9 @@ import com.fasterxml.jackson.databind.node.TextNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { diff --git a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java index c9097cacb..530711df3 100644 --- a/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ReadOnlyValidator.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java index 39a49d51a..e864d3aef 100644 --- a/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java @@ -20,10 +20,10 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/keyword/RefValidator.java b/src/main/java/com/networknt/schema/keyword/RefValidator.java index 15df346a3..105744cb8 100644 --- a/src/main/java/com/networknt/schema/keyword/RefValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RefValidator.java @@ -20,10 +20,10 @@ import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; import com.networknt.schema.InvalidSchemaRefException; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaRef; +import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.ThreadSafeCachingSupplier; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java index 658ef6937..ca5c337b8 100644 --- a/src/main/java/com/networknt/schema/keyword/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/keyword/RequiredValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.*; diff --git a/src/main/java/com/networknt/schema/keyword/TrueValidator.java b/src/main/java/com/networknt/schema/keyword/TrueValidator.java index f387869e5..71347de9d 100644 --- a/src/main/java/com/networknt/schema/keyword/TrueValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TrueValidator.java @@ -17,9 +17,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index 8ebeacc24..134ab7128 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 3feb2c909..96714df03 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -18,11 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; import static com.networknt.schema.SpecificationVersionRange.MinV202012; diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 4e8cf9923..96aa4f295 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -26,11 +26,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaContext; import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; /** * {@link KeywordValidator} for unevaluatedProperties. diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 017d2ecf3..61a5bed10 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; import com.networknt.schema.JsonType; @@ -27,6 +26,7 @@ import com.networknt.schema.TypeFactory; import com.networknt.schema.SchemaContext; import com.networknt.schema.Validator; +import com.networknt.schema.path.NodePath; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java index a9a179a5d..5ee628164 100644 --- a/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UniqueItemsValidator.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import java.util.HashSet; diff --git a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java index 4b5a2ad98..e7bc5db9c 100644 --- a/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/keyword/WriteOnlyValidator.java @@ -5,9 +5,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index ac083642c..736d79882 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -27,9 +27,9 @@ import java.util.Set; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaContext; +import com.networknt.schema.path.NodePath; import com.networknt.schema.Error; /** diff --git a/src/main/java/com/networknt/schema/output/OutputUnitKey.java b/src/main/java/com/networknt/schema/output/OutputUnitKey.java index fac292647..b5b23ebc5 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitKey.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitKey.java @@ -20,8 +20,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; import com.networknt.schema.serialization.JsonMapperFactory; /** diff --git a/src/main/java/com/networknt/schema/NodePath.java b/src/main/java/com/networknt/schema/path/NodePath.java similarity index 96% rename from src/main/java/com/networknt/schema/NodePath.java rename to src/main/java/com/networknt/schema/path/NodePath.java index bea845709..e81472ad9 100644 --- a/src/main/java/com/networknt/schema/NodePath.java +++ b/src/main/java/com/networknt/schema/path/NodePath.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.path; import java.util.Objects; diff --git a/src/main/java/com/networknt/schema/PathType.java b/src/main/java/com/networknt/schema/path/PathType.java similarity index 99% rename from src/main/java/com/networknt/schema/PathType.java rename to src/main/java/com/networknt/schema/path/PathType.java index 869ee4f21..f86f87e5e 100644 --- a/src/main/java/com/networknt/schema/PathType.java +++ b/src/main/java/com/networknt/schema/path/PathType.java @@ -1,4 +1,4 @@ -package com.networknt.schema; +package com.networknt.schema.path; import java.util.function.BiFunction; import java.util.function.IntPredicate; diff --git a/src/main/java/com/networknt/schema/result/SchemaResult.java b/src/main/java/com/networknt/schema/result/SchemaResult.java index a1eae6ba3..009e7b9af 100644 --- a/src/main/java/com/networknt/schema/result/SchemaResult.java +++ b/src/main/java/com/networknt/schema/result/SchemaResult.java @@ -17,8 +17,8 @@ import java.util.Objects; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; /** * Sub schema results. diff --git a/src/main/java/com/networknt/schema/result/SchemaResults.java b/src/main/java/com/networknt/schema/result/SchemaResults.java index 9c2514a44..bafb27499 100644 --- a/src/main/java/com/networknt/schema/result/SchemaResults.java +++ b/src/main/java/com/networknt/schema/result/SchemaResults.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; -import com.networknt.schema.NodePath; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; /** * Sub schema results. diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 7f19f615a..874005fca 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -6,10 +6,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Schema; import com.networknt.schema.JsonType; -import com.networknt.schema.PathType; import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.TypeFactory; +import com.networknt.schema.path.PathType; import com.networknt.schema.SchemaContext; public class JsonNodeUtil { diff --git a/src/main/java/com/networknt/schema/utils/JsonNodes.java b/src/main/java/com/networknt/schema/utils/JsonNodes.java index 9891f5a56..4ef33dc17 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodes.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodes.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.networknt.schema.NodePath; +import com.networknt.schema.path.NodePath; import com.networknt.schema.serialization.node.JsonLocationAware; import com.networknt.schema.serialization.node.JsonNodeFactoryFactory; diff --git a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java index 9dd30f45b..b7ef458f2 100644 --- a/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.Error; import java.util.List; diff --git a/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java index dec947645..62522e20d 100644 --- a/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/ItemWalkListenerRunner.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.Error; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java index 9835d52e9..9a22e2340 100644 --- a/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/KeywordWalkListenerRunner.java @@ -25,10 +25,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; /** * A {@link WalkListenerRunner} for walking keywords. diff --git a/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java index dc7a45c28..d10fb10bb 100644 --- a/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/PropertyWalkListenerRunner.java @@ -18,9 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.Error; import java.util.ArrayList; diff --git a/src/main/java/com/networknt/schema/walk/WalkConfig.java b/src/main/java/com/networknt/schema/walk/WalkConfig.java index 8955b6324..d008abad9 100644 --- a/src/main/java/com/networknt/schema/walk/WalkConfig.java +++ b/src/main/java/com/networknt/schema/walk/WalkConfig.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; /** * Configuration used when walking a schema. diff --git a/src/main/java/com/networknt/schema/walk/WalkEvent.java b/src/main/java/com/networknt/schema/walk/WalkEvent.java index 14900e7f6..93549d4fe 100644 --- a/src/main/java/com/networknt/schema/walk/WalkEvent.java +++ b/src/main/java/com/networknt/schema/walk/WalkEvent.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; /** * Encapsulation of Walk data that is passed into the {@link WalkListener}. diff --git a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java index 171d516ae..66f2a6ad3 100644 --- a/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java +++ b/src/main/java/com/networknt/schema/walk/WalkListenerRunner.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.Error; import java.util.List; diff --git a/src/main/java/com/networknt/schema/walk/Walker.java b/src/main/java/com/networknt/schema/walk/Walker.java index b5cddea8d..bb250d426 100644 --- a/src/main/java/com/networknt/schema/walk/Walker.java +++ b/src/main/java/com/networknt/schema/walk/Walker.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Validator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.NodePath; public interface Walker { /** diff --git a/src/test/java/com/networknt/schema/AnnotationsTest.java b/src/test/java/com/networknt/schema/AnnotationsTest.java index 734b37ba9..e147ef12a 100644 --- a/src/test/java/com/networknt/schema/AnnotationsTest.java +++ b/src/test/java/com/networknt/schema/AnnotationsTest.java @@ -21,6 +21,8 @@ import com.networknt.schema.annotation.Annotation; import com.networknt.schema.annotation.Annotations; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.path.PathType; /** * AnnotationsTest. diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index 146769a37..f2ecfc7e7 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -25,6 +25,7 @@ import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index c2529c144..7f7c06c00 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -23,6 +23,7 @@ import com.networknt.schema.keyword.AbstractKeyword; import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index af2870433..e780962d2 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -27,6 +27,7 @@ import com.networknt.schema.format.Format; import com.networknt.schema.keyword.FormatKeyword; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; class FormatKeywordFactoryTest { diff --git a/src/test/java/com/networknt/schema/IfValidatorTest.java b/src/test/java/com/networknt/schema/IfValidatorTest.java index 0ee0a6432..68b3a593c 100644 --- a/src/test/java/com/networknt/schema/IfValidatorTest.java +++ b/src/test/java/com/networknt/schema/IfValidatorTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.keyword.KeywordType; +import com.networknt.schema.path.NodePath; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.WalkConfig; diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index 10598eab0..f32c0bb32 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.keyword.KeywordType; +import com.networknt.schema.path.NodePath; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; import com.networknt.schema.walk.PropertyWalkListenerRunner; diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index 5a26f4570..a4dcaa866 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.path.PathType; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index c055dd485..babd08fd5 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.path.NodePath; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.WalkConfig; diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 83fc1e942..391178af4 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.path.NodePath; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.ItemWalkListenerRunner; diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index 2820a7893..87329f64e 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -9,6 +9,7 @@ import com.networknt.schema.keyword.AbstractKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.KeywordWalkListenerRunner; diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 5ad5b5846..3e2a08f70 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -27,6 +27,7 @@ import com.networknt.schema.keyword.BaseKeywordValidator; import com.networknt.schema.keyword.Keyword; import com.networknt.schema.keyword.KeywordValidator; +import com.networknt.schema.path.NodePath; /** * Test for messages. diff --git a/src/test/java/com/networknt/schema/NodePathTest.java b/src/test/java/com/networknt/schema/NodePathTest.java index 5483127ae..ffc9e82ce 100644 --- a/src/test/java/com/networknt/schema/NodePathTest.java +++ b/src/test/java/com/networknt/schema/NodePathTest.java @@ -24,6 +24,9 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.path.PathType; + class NodePathTest { @Test diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 0fbd219eb..ae80691cc 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.path.PathType; /** * OneOfValidatorTest. diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index 2466b1fbe..3b14f3032 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.path.PathType; import com.networknt.schema.regex.JDKRegularExpressionFactory; import java.io.InputStream; diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 7c31120de..dc1281286 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.keyword.PrefixItemsValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.ItemWalkListenerRunner; diff --git a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java index 9cacaa226..d4f9d373a 100644 --- a/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java +++ b/src/test/java/com/networknt/schema/RecursiveReferenceValidatorExceptionTest.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.keyword.RecursiveRefValidator; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.path.PathType; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/networknt/schema/SchemaLocationTest.java b/src/test/java/com/networknt/schema/SchemaLocationTest.java index 6551fda67..fc14ce2e2 100644 --- a/src/test/java/com/networknt/schema/SchemaLocationTest.java +++ b/src/test/java/com/networknt/schema/SchemaLocationTest.java @@ -21,6 +21,8 @@ import org.junit.jupiter.api.Test; +import com.networknt.schema.path.NodePath; + class SchemaLocationTest { @Test diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 820ec040e..dbe246c40 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -28,10 +28,10 @@ import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.OutputFormat; -import com.networknt.schema.PathType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.dialect.Dialects; +import com.networknt.schema.path.PathType; import com.networknt.schema.Error; /** diff --git a/src/test/java/com/networknt/schema/PathTypeTest.java b/src/test/java/com/networknt/schema/path/PathTypeTest.java similarity index 96% rename from src/test/java/com/networknt/schema/PathTypeTest.java rename to src/test/java/com/networknt/schema/path/PathTypeTest.java index 0f317e2b7..278bf4008 100644 --- a/src/test/java/com/networknt/schema/PathTypeTest.java +++ b/src/test/java/com/networknt/schema/path/PathTypeTest.java @@ -1,4 +1,4 @@ -package com.networknt.schema; +package com.networknt.schema.path; import static org.junit.jupiter.api.Assertions.*; diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 2e7ea4881..02c5e0ee5 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -34,7 +34,6 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.InputFormat; -import com.networknt.schema.NodePath; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaRef; @@ -44,6 +43,7 @@ import com.networknt.schema.keyword.ItemsValidator; import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; +import com.networknt.schema.path.NodePath; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.utils.JsonNodes; From f9c8d56205803604ff68c3548d5305157a61ec05 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:39:08 +0800 Subject: [PATCH 43/74] Refactor and fix discriminator --- .../networknt/schema/ExecutionContext.java | 11 +- .../schema/keyword/AnyOfValidator.java | 112 ++++++---- .../schema/keyword/DiscriminatorState.java | 52 +++++ .../keyword/DiscriminatorValidator.java | 28 ++- .../schema/DiscriminatorValidatorTest.java | 207 +++++++++++++++++- .../schema/OpenAPI30JsonSchemaTest.java | 7 +- 6 files changed, 371 insertions(+), 46 deletions(-) create mode 100644 src/main/java/com/networknt/schema/keyword/DiscriminatorState.java diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 4f9d6a07e..6dba7e305 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -17,12 +17,15 @@ package com.networknt.schema; import com.networknt.schema.annotation.Annotations; +import com.networknt.schema.keyword.DiscriminatorState; import com.networknt.schema.path.NodePath; import com.networknt.schema.result.SchemaResults; import com.networknt.schema.walk.WalkConfig; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Stack; import java.util.function.Consumer; @@ -38,8 +41,14 @@ public class ExecutionContext { private Annotations annotations = null; private SchemaResults results = null; private List errors = new ArrayList<>(); + + private Map discriminatorMapping = new HashMap<>(); - /** + public Map getDiscriminatorMapping() { + return discriminatorMapping; + } + + /** * This is used during the execution to determine if the validator should fail fast. *

* This valid is determined by the previous validator. diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 385026f41..3eba0ee20 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -34,8 +34,6 @@ * {@link KeywordValidator} for anyOf. */ public class AnyOfValidator extends BaseKeywordValidator { - private static final String DISCRIMINATOR_REMARK = "and the discriminator-selected candidate schema didn't pass validation"; - private final List schemas; private Boolean canShortCircuit = null; @@ -71,7 +69,8 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } int numberOfValidSubSchemas = 0; List existingErrors = executionContext.getErrors(); - List allErrors = null; + List allErrors = null; // Keeps track of all the errors for reporting if in the end none of the schemas match + List discriminatorErrors = null; List errors = new ArrayList<>(); executionContext.setErrors(errors); try { @@ -109,54 +108,82 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo if (errors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) && canShortCircuit() && canShortCircuit(executionContext)) { - // Clear all errors. Note that this is checked in finally. - allErrors = null; + // Successful so return only the existing errors, ie. no new errors executionContext.setErrors(existingErrors); return; } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - DiscriminatorContext currentDiscriminatorContext = executionContext.getCurrentDiscriminatorContext(); - if (currentDiscriminatorContext.isDiscriminatorMatchFound() - || currentDiscriminatorContext.isDiscriminatorIgnore()) { - if (!errors.isEmpty()) { - // The following is to match the previous logic adding to all errors - // which is generally discarded as it returns errors but the allErrors - // is getting processed in finally - if (allErrors == null) { - allErrors = new ArrayList<>(); - } - allErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .arguments(DISCRIMINATOR_REMARK) - .build()); - } else { - // Clear all errors. Note that this is checked in finally. - allErrors = null; - } - existingErrors.addAll(errors); - executionContext.setErrors(existingErrors); - return; + JsonNode refNode = schema.getSchemaNode().get("$ref"); + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + boolean discriminatorMatchFound = false; + if (refNode != null) { + // Check if there is a match + String discriminatingValue = state.getDiscriminatingValue(); + if (discriminatingValue != null) { + String ref = refNode.asText(); + if (state.isExplicitMapping() && ref.equals(discriminatingValue)) { + // Explicit matching + discriminatorMatchFound = true; + state.setMatch(ref); + } else if (!state.isExplicitMapping() && ref.endsWith(discriminatingValue)) { + // Implicit matching + discriminatorMatchFound = true; + state.setMatch(ref); + } + } + } + if (discriminatorMatchFound) { + /* + * Note that discriminator cannot change the outcome of the evaluation but can be used to filter off + * any additional messages + */ + if (!errors.isEmpty()) { + /* + * This means that the discriminated value has errors and doesn't match so these errors + * are the only ones that will be reported *IF* there are no other schemas that successfully + * validate to meet the requirement of anyOf. + * + * If there are any successful schemas as per anyOf, all these errors will be discarded. + */ + discriminatorErrors = new ArrayList<>(errors); + allErrors = null; // This is no longer needed + } } } - if (allErrors == null) { - allErrors = new ArrayList<>(); + + /* + * This adds all the errors for this schema to the list that contains all the errors for later reporting. + * + * There's no need to add these if there was a discriminator match with errors as only the discriminator + * errors will be reported if all the schemas fail. + */ + if (!errors.isEmpty() && discriminatorErrors == null) { + if (allErrors == null) { + allErrors = new ArrayList<>(); + } + allErrors.addAll(errors); } - allErrors.addAll(errors); } } finally { // Restore flag executionContext.setFailFast(failFast); } - if (this.schemaContext.isDiscriminatorKeywordEnabled() - && executionContext.getCurrentDiscriminatorContext().isActive() - && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { - existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .arguments( - "based on the provided discriminator. No alternative could be chosen based on the discriminator property") - .build()); - executionContext.setErrors(existingErrors); - return; + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { + // https://spec.openapis.org/oas/v3.1.0#discriminator-object + // If the discriminator value does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. + + /* + * The only case where the discriminator can change the outcome of the result is if the discriminator value does not match an implicit or explicit mapping + */ + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + if (state != null && state.getMatch() == null && state.getPropertyValue() != null) { + // state.getPropertyValue() == null means there is no value at propertyName + existingErrors.add(error().keyword("discriminator").instanceNode(node).instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) + .arguments( + "based on the provided discriminator. No alternative could be chosen based on the discriminator property") + .build()); + } } } finally { if (this.schemaContext.isDiscriminatorKeywordEnabled()) { @@ -164,9 +191,14 @@ && canShortCircuit() && canShortCircuit(executionContext)) { } } if (numberOfValidSubSchemas >= 1) { + // Successful so return only the existing errors, ie. no new errors executionContext.setErrors(existingErrors); } else { - if (allErrors != null) { + if (discriminatorErrors != null) { + // If errors are present matching the discriminator, only these errors should be reported + existingErrors.addAll(discriminatorErrors); + } else if (allErrors != null) { + // As the anyOf has failed, report all the errors existingErrors.addAll(allErrors); } executionContext.setErrors(existingErrors); diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java new file mode 100644 index 000000000..c63cb16cc --- /dev/null +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java @@ -0,0 +1,52 @@ +package com.networknt.schema.keyword; + +/** + * Discriminator state for an instance location. + */ +public class DiscriminatorState { + private String propertyName; + private String propertyValue; + private String discriminatingValue = null; + private boolean explicitMapping = false; + private String match; + + public String getPropertyName() { + return propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public String getPropertyValue() { + return propertyValue; + } + + public void setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + } + + public String getDiscriminatingValue() { + return discriminatingValue; + } + + public void setDiscriminatingValue(String discriminatingValue) { + this.discriminatingValue = discriminatingValue; + } + + public boolean isExplicitMapping() { + return explicitMapping; + } + + public void setExplicitMapping(boolean explicitMapping) { + this.explicitMapping = explicitMapping; + } + + public void setMatch(String match) { + this.match = match; + } + + public String getMatch() { + return this.match; + } +} diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index d7a7e5a43..8e2099cdd 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -67,7 +67,31 @@ public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluation @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - // Do nothing + // Check for discriminator mapping + if ("".equals(this.propertyName)) { + // Invalid discriminator as propertyName cannot be empty + return; + } + JsonNode propertyValue = node.get(this.propertyName); + DiscriminatorState state = new DiscriminatorState(); + DiscriminatorState existing = executionContext.getDiscriminatorMapping().put(instanceLocation, state); + state.setPropertyName(this.propertyName); + if (propertyValue != null && propertyValue.isTextual()) { + String value = propertyValue.asText(); + state.setPropertyValue(value); + // Check for explicit mapping + String mapped = mapping.get(value); + if (mapped == null) { + // If explicit mapping not found use implicit value + state.setDiscriminatingValue(value); + state.setExplicitMapping(false); + } else { + state.setDiscriminatingValue(mapped); + state.setExplicitMapping(true); + } + } else { + // discriminator property name is missing so the property value in the state is null + } } /** @@ -162,7 +186,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr final JsonNode mappingValueToAdd = fieldToAdd.getValue(); final JsonNode currentMappingValue = mappingOnContextDiscriminator.get(mappingKeyToAdd); - if (null != currentMappingValue && currentMappingValue != mappingValueToAdd) { + if (null != currentMappingValue && !currentMappingValue.equals(mappingValueToAdd)) { throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd + "/" + currentMappingValue + " to " + mappingValueToAdd); } else if (null == currentMappingValue) { diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index b70feac2a..2558ddbda 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -241,7 +241,7 @@ void discriminatorInArrayInvalidDiscriminatorPropertyAnyOf() { SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); - assertEquals(1, messages.size()); + assertEquals(1, messages.size()); // RECHECK THIS } /** @@ -768,4 +768,209 @@ void anyOfMissingDiscriminatorValue() { List list = messages.stream().collect(Collectors.toList()); assertEquals("required", list.get(0).getKeyword()); } + + /** + * See issue 436. + */ + @Test + void anyOfRedefinedDiscriminatorAndDiscriminatorWithMissingPropertyName() { + String schemaData = "{\r\n" + + " \"anyOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Room\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/BedRoom\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/KidsBedRoom\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Kitchen\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/GuestRoom\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"components\": {\r\n" + + " \"schemas\": {\r\n" + + " \"Room\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"@type\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"floor\": {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"@type\"\r\n" + + " ],\r\n" + + " \"discriminator\": {\r\n" + + " \"propertyName\": \"@type\",\r\n" + + " \"mapping\": {\r\n" + + " \"bed\": \"#/components/schemas/BedRoom\",\r\n" + + " \"guest\": \"#/components/schemas/GuestRoom\"\r\n" + + " }\r\n" + + " }\r\n" + + " },\r\n" + + " \"BedRoom\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Room\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"numberOfBeds\": {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"numberOfBeds\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ],\r\n" + + " \"discriminator\": {\r\n" + + " \"mapping\": {\r\n" + + " \"guest\": \"#/components/schemas/GuestRoom\"\r\n" + + " }\r\n" + + " }\r\n" + + " },\r\n" + + " \"KidsBedRoom\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/BedRoom\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"isTidy\": {\r\n" + + " \"type\": \"boolean\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"isTidy\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ]\r\n" + + " },\r\n" + + " \"GuestRoom\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/BedRoom\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"guest\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"guest\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ]\r\n" + + " },\r\n" + + " \"Kitchen\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Room\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"hasMicrowaveOven\": {\r\n" + + " \"type\": \"boolean\"\r\n" + + " },\r\n" + + " \"equipment\": {\r\n" + + " \"type\": \"array\",\r\n" + + " \"items\": {\r\n" + + " \"anyOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Pot\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/Blender\"\r\n" + + " }\r\n" + + " ]\r\n" + + " }\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"hasMicrowaveOven\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ]\r\n" + + " },\r\n" + + " \"KitchenEquipment\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"@type\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"@type\"\r\n" + + " ],\r\n" + + " \"discriminator\": {\r\n" + + " \"propertyName\": \"@type\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"Pot\": {\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/KitchenEquipment\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"capacity\": {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"capacity\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ]\r\n" + + " },\r\n" + + " \"Blender\": {\r\n" + + " \"allOf\": [\r\n" + + " {\r\n" + + " \"$ref\": \"#/components/schemas/KitchenEquipment\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"maxSpeed\": {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [\r\n" + + " \"maxSpeed\"\r\n" + + " ]\r\n" + + " }\r\n" + + " ]\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + "}"; + + String inputData = "{\"@type\":\"bed\"}"; + + SchemaRegistry factory = SchemaRegistry.withDialect(Dialects.getOpenApi31()); + Schema schema = factory.getSchema(schemaData); + List messages = schema.validate(inputData, InputFormat.JSON); + List list = messages.stream().collect(Collectors.toList()); + // : required property 'numberOfBeds' not found + assertTrue(list.isEmpty()); + } + } diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 947574c1d..2c100d681 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -29,11 +29,13 @@ private void runTestFile(String testCaseFile) throws Exception { for (int j = 0; j < testCases.size(); j++) { try { JsonNode testCase = testCases.get(j); - + System.out.println("Test Case ["+(j+1)+"]: "+testCase.get("description")); + System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testCase.get("schema"))); + System.out.println("Tests:"); ArrayNode testNodes = (ArrayNode) testCase.get("tests"); for (int i = 0; i < testNodes.size(); i++) { JsonNode test = testNodes.get(i); - System.out.println("=== " + test.get("description")); + System.out.println(test); JsonNode node = test.get("data"); JsonNode typeLooseNode = test.get("isTypeLoose"); // Configure the schemaValidator to set typeLoose's value based on the test file, @@ -59,6 +61,7 @@ private void runTestFile(String testCaseFile) throws Exception { } assertEquals(0, errors.size()); } else { +// System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testCase.get("schema"))); if (errors.isEmpty()) { System.out.println("---- test case failed ----"); System.out.println("schema: " + schema); From 4880a7130730e848608439be99dee86e44a1fea7 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 20:13:26 +0800 Subject: [PATCH 44/74] Refactor discriminator --- .../schema/keyword/AnyOfValidator.java | 127 ++++++------ .../schema/keyword/DiscriminatorState.java | 124 +++++++----- .../keyword/DiscriminatorValidator.java | 185 +++++++++++------- src/main/resources/jsv-messages.properties | 3 +- 4 files changed, 267 insertions(+), 172 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 3eba0ee20..745285df3 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -106,55 +106,56 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo numberOfValidSubSchemas++; } - if (errors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) - && canShortCircuit() && canShortCircuit(executionContext)) { + if (errors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) && canShortCircuit() + && canShortCircuit(executionContext)) { // Successful so return only the existing errors, ie. no new errors executionContext.setErrors(existingErrors); return; } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - JsonNode refNode = schema.getSchemaNode().get("$ref"); - DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); - boolean discriminatorMatchFound = false; - if (refNode != null) { - // Check if there is a match - String discriminatingValue = state.getDiscriminatingValue(); - if (discriminatingValue != null) { - String ref = refNode.asText(); - if (state.isExplicitMapping() && ref.equals(discriminatingValue)) { - // Explicit matching - discriminatorMatchFound = true; - state.setMatch(ref); - } else if (!state.isExplicitMapping() && ref.endsWith(discriminatingValue)) { - // Implicit matching - discriminatorMatchFound = true; - state.setMatch(ref); - } - } - } + JsonNode refNode = schema.getSchemaNode().get("$ref"); + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + boolean discriminatorMatchFound = false; + if (refNode != null) { + // Check if there is a match + String discriminatingValue = state.getMappedSchema(); + if (discriminatingValue != null) { + String ref = refNode.asText(); + if (state.isExplicitMapping() && ref.equals(discriminatingValue)) { + // Explicit matching + discriminatorMatchFound = true; + state.setMatchedSchema(ref); + } else if (!state.isExplicitMapping() && ref.endsWith(discriminatingValue)) { + // Implicit matching + discriminatorMatchFound = true; + state.setMatchedSchema(ref); + } + } + } if (discriminatorMatchFound) { - /* - * Note that discriminator cannot change the outcome of the evaluation but can be used to filter off - * any additional messages - */ - if (!errors.isEmpty()) { - /* - * This means that the discriminated value has errors and doesn't match so these errors - * are the only ones that will be reported *IF* there are no other schemas that successfully - * validate to meet the requirement of anyOf. - * - * If there are any successful schemas as per anyOf, all these errors will be discarded. - */ - discriminatorErrors = new ArrayList<>(errors); - allErrors = null; // This is no longer needed - } + /* + * Note that discriminator cannot change the outcome of the evaluation but can + * be used to filter off any additional messages + */ + if (!errors.isEmpty()) { + /* + * This means that the discriminated value has errors and doesn't match so these + * errors are the only ones that will be reported *IF* there are no other + * schemas that successfully validate to meet the requirement of anyOf. + * + * If there are any successful schemas as per anyOf, all these errors will be + * discarded. + */ + discriminatorErrors = new ArrayList<>(errors); + allErrors = null; // This is no longer needed + } } } - /* - * This adds all the errors for this schema to the list that contains all the errors for later reporting. + * This adds all the errors for this schema to the list that contains all the + * errors for later reporting. * - * There's no need to add these if there was a discriminator match with errors as only the discriminator - * errors will be reported if all the schemas fail. + * There's no need to add these if there was a discriminator match with errors + * as only the discriminator errors will be reported if all the schemas fail. */ if (!errors.isEmpty() && discriminatorErrors == null) { if (allErrors == null) { @@ -169,21 +170,28 @@ && canShortCircuit() && canShortCircuit(executionContext)) { } if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - // https://spec.openapis.org/oas/v3.1.0#discriminator-object - // If the discriminator value does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. - - /* - * The only case where the discriminator can change the outcome of the result is if the discriminator value does not match an implicit or explicit mapping - */ - DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); - if (state != null && state.getMatch() == null && state.getPropertyValue() != null) { - // state.getPropertyValue() == null means there is no value at propertyName - existingErrors.add(error().keyword("discriminator").instanceNode(node).instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .arguments( - "based on the provided discriminator. No alternative could be chosen based on the discriminator property") - .build()); - } + /* + * The only case where the discriminator can change the outcome of the result is + * if the discriminator value does not match an implicit or explicit mapping + */ + /* + * If the discriminator value does not match an implicit or explicit mapping, no + * schema can be determined and validation SHOULD fail. Mapping keys MUST be + * string values, but tooling MAY convert response values to strings for + * comparison. + * + * https://spec.openapis.org/oas/v3.1.0#discriminator-object + */ + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + if (state != null && state.getMatchedSchema() == null && state.getDiscriminatingValue() != null) { + // state.getPropertyValue() == null means there is no value at propertyName + existingErrors.add(error().keyword("discriminator").instanceNode(node) + .instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) + .arguments( + "based on the provided discriminator. No alternative could be chosen based on the discriminator property") + .build()); + } } } finally { if (this.schemaContext.isDiscriminatorKeywordEnabled()) { @@ -194,11 +202,12 @@ && canShortCircuit() && canShortCircuit(executionContext)) { // Successful so return only the existing errors, ie. no new errors executionContext.setErrors(existingErrors); } else { - if (discriminatorErrors != null) { - // If errors are present matching the discriminator, only these errors should be reported + if (discriminatorErrors != null) { + // If errors are present matching the discriminator, only these errors should be + // reported existingErrors.addAll(discriminatorErrors); - } else if (allErrors != null) { - // As the anyOf has failed, report all the errors + } else if (allErrors != null) { + // As the anyOf has failed, report all the errors existingErrors.addAll(allErrors); } executionContext.setErrors(existingErrors); diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java index c63cb16cc..329faca40 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java @@ -4,49 +4,83 @@ * Discriminator state for an instance location. */ public class DiscriminatorState { - private String propertyName; - private String propertyValue; - private String discriminatingValue = null; - private boolean explicitMapping = false; - private String match; - - public String getPropertyName() { - return propertyName; - } - - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; - } - - public String getPropertyValue() { - return propertyValue; - } - - public void setPropertyValue(String propertyValue) { - this.propertyValue = propertyValue; - } - - public String getDiscriminatingValue() { - return discriminatingValue; - } - - public void setDiscriminatingValue(String discriminatingValue) { - this.discriminatingValue = discriminatingValue; - } - - public boolean isExplicitMapping() { - return explicitMapping; - } - - public void setExplicitMapping(boolean explicitMapping) { - this.explicitMapping = explicitMapping; - } - - public void setMatch(String match) { - this.match = match; - } - - public String getMatch() { - return this.match; - } + private String propertyName; + private String discriminatingValue; + private String mappedSchema = null; + private boolean explicitMapping = false; + private String matchedSchema; + + /** + * Gets the property name defined in the discriminator keyword schema. + * + * @return + */ + public String getPropertyName() { + return propertyName; + } + + /** + * Sets the property name defined in the discriminator keyword schema. + * + * @param propertyName the property name + */ + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + /** + * Gets the discriminating value, which is the value in the payload + * corresponding with the property name. + * + * @return the discriminating value + */ + public String getDiscriminatingValue() { + return discriminatingValue; + } + + /** + * Sets the discriminating value, which is the value in the payload + * corresponding with the property name. + * + * @param discriminatingValue + */ + public void setDiscriminatingValue(String discriminatingValue) { + this.discriminatingValue = discriminatingValue; + } + + /** + * Gets the mapped schema which is the discriminating value mapped to the schema + * name or uri. + * + * @return the mapped schema + */ + public String getMappedSchema() { + return mappedSchema; + } + + /** + * Sets the mapped schema which is the discriminating value mapped to the schema + * name or uri. + * + * @param mappedSchema the mapped schema + */ + public void setMappedSchema(String mappedSchema) { + this.mappedSchema = mappedSchema; + } + + public boolean isExplicitMapping() { + return explicitMapping; + } + + public void setExplicitMapping(boolean explicitMapping) { + this.explicitMapping = explicitMapping; + } + + public void setMatchedSchema(String matchedSchema) { + this.matchedSchema = matchedSchema; + } + + public String getMatchedSchema() { + return this.matchedSchema; + } } diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 8e2099cdd..ba0827497 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -36,16 +36,29 @@ * {@link KeywordValidator} that resolves discriminator. */ public class DiscriminatorValidator extends BaseKeywordValidator { + /** + * The name of the property in the payload that will hold the discriminating + * value. This property SHOULD be required in the payload schema, as the + * behavior when the property is absent is undefined. + */ private final String propertyName; + /** + * An object to hold mappings between payload values and schema names or URI + * references. + */ private final Map mapping; public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(KeywordType.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, - evaluationPath); + super(KeywordType.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); ObjectNode discriminator = schemaNode.isObject() ? (ObjectNode) schemaNode : null; if (discriminator != null) { JsonNode propertyName = discriminator.get("propertyName"); + /* + * There really should be a parse error if propertyName is not defined in the + * schema but there is non-specification compliant behavior if there are + * multiple discriminators on the same path if the propertyName is not defined. + */ this.propertyName = propertyName != null ? propertyName.asText() : ""; JsonNode mappingNode = discriminator.get("mapping"); ObjectNode mapping = mappingNode != null && mappingNode.isObject() ? (ObjectNode) mappingNode : null; @@ -67,31 +80,67 @@ public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluation @Override public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - // Check for discriminator mapping - if ("".equals(this.propertyName)) { - // Invalid discriminator as propertyName cannot be empty - return; - } - JsonNode propertyValue = node.get(this.propertyName); - DiscriminatorState state = new DiscriminatorState(); - DiscriminatorState existing = executionContext.getDiscriminatorMapping().put(instanceLocation, state); - state.setPropertyName(this.propertyName); - if (propertyValue != null && propertyValue.isTextual()) { - String value = propertyValue.asText(); - state.setPropertyValue(value); - // Check for explicit mapping - String mapped = mapping.get(value); - if (mapped == null) { - // If explicit mapping not found use implicit value - state.setDiscriminatingValue(value); - state.setExplicitMapping(false); - } else { - state.setDiscriminatingValue(mapped); - state.setExplicitMapping(true); - } - } else { - // discriminator property name is missing so the property value in the state is null - } + DiscriminatorState state = null; + DiscriminatorState existing = executionContext.getDiscriminatorMapping().get(instanceLocation); + if (existing != null) { + /* + * This allows a new discriminator keyword if the propertyName is empty or if + * the propertyName value is the same as the existing one. + * + * This is not specification compliant. There shouldn't be multiple matching + * discriminator keywords for the same instance. + * + * Also propertyName for the discriminator keyword should not be empty according + * to the specification. + */ + if (!"".equals(this.propertyName) && !existing.getPropertyName().equals(this.propertyName)) { + throw new SchemaException("Schema at " + this.schemaLocation + + " is redefining the discriminator property that has already been set for " + + instanceLocation); + } + state = existing; + } else { + state = new DiscriminatorState(); + state.setPropertyName(this.propertyName); + executionContext.getDiscriminatorMapping().put(instanceLocation, state); + } + JsonNode discriminatingValueNode = node.get(state.getPropertyName()); + if (discriminatingValueNode != null && discriminatingValueNode.isTextual()) { + String discriminatingValue = discriminatingValueNode.asText(); + state.setDiscriminatingValue(discriminatingValue); + // Check for explicit mapping + String mappedSchema = mapping.get(discriminatingValue); + if (existing != null && mappedSchema != null) { + /* + * If the existing already has an explicit mapping and this doesn't tally with + * this one this is an issue as well. + */ + if (existing.isExplicitMapping() && !existing.getMappedSchema().equals(mappedSchema)) { + throw new SchemaException( + "Schema at " + this.schemaLocation + " is mapping that has already been set for " + + instanceLocation + " from " + existing.getMappedSchema() + " to " + mappedSchema); + } + } + if (mappedSchema != null) { + // Explicit mapping found + state.setMappedSchema(mappedSchema); + state.setExplicitMapping(true); + } else { + // If explicit mapping not found use implicit value + state.setMappedSchema(discriminatingValue); + state.setExplicitMapping(false); + } + } else { + /* + * The property is not present in the payload. This property SHOULD be required + * in the payload schema, as the behavior when the property is absent is + * undefined. + */ + if (this.schemaContext.getSchemaRegistryConfig().isStrict("discriminator", Boolean.FALSE)) { + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) + .messageKey("discriminator.missing_discriminating_value").arguments(this.propertyName).build()); + } + } } /** @@ -113,18 +162,19 @@ public Map getMapping() { } /** - * Checks based on the current {@link DiscriminatorContext} whether the provided {@link Schema} a match against - * the current discriminator. + * Checks based on the current {@link DiscriminatorContext} whether the provided + * {@link Schema} a match against the current discriminator. * - * @param currentDiscriminatorContext the currently active {@link DiscriminatorContext} + * @param currentDiscriminatorContext the currently active + * {@link DiscriminatorContext} * @param discriminator the discriminator to use for the check - * @param discriminatorPropertyValue the value of the discriminator/propertyName field + * @param discriminatorPropertyValue the value of the + * discriminator/propertyName + * field * @param jsonSchema the {@link Schema} to check */ public static void checkDiscriminatorMatch(final DiscriminatorContext currentDiscriminatorContext, - final ObjectNode discriminator, - final String discriminatorPropertyValue, - final Schema jsonSchema) { + final ObjectNode discriminator, final String discriminatorPropertyValue, final Schema jsonSchema) { if (discriminatorPropertyValue == null) { currentDiscriminatorContext.markIgnore(); return; @@ -132,52 +182,54 @@ public static void checkDiscriminatorMatch(final DiscriminatorContext currentDis final JsonNode discriminatorMapping = discriminator.get("mapping"); if (null == discriminatorMapping) { - checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, - discriminatorPropertyValue, + checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, jsonSchema); } else { - checkForExplicitDiscriminatorMappingMatch(currentDiscriminatorContext, - discriminatorPropertyValue, - discriminatorMapping, - jsonSchema); + checkForExplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, + discriminatorMapping, jsonSchema); if (!currentDiscriminatorContext.isDiscriminatorMatchFound() && noExplicitDiscriminatorKeyOverride(discriminatorMapping, jsonSchema)) { - checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, - discriminatorPropertyValue, + checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, jsonSchema); } } } /** - * Rolls up all nested and compatible discriminators to the root discriminator of the type. Detects attempts to redefine - * the propertyName or mappings. + * Rolls up all nested and compatible discriminators to the root discriminator + * of the type. Detects attempts to redefine the propertyName or + * mappings. * - * @param currentDiscriminatorContext the currently active {@link DiscriminatorContext} + * @param currentDiscriminatorContext the currently active + * {@link DiscriminatorContext} * @param discriminator the discriminator to use for the check - * @param schema the value of the discriminator/propertyName field - * @param instanceLocation the logging prefix + * @param schema the value of the + * discriminator/propertyName + * field + * @param instanceLocation the logging prefix */ public static void registerAndMergeDiscriminator(final DiscriminatorContext currentDiscriminatorContext, - final ObjectNode discriminator, - final Schema schema, - final NodePath instanceLocation) { + final ObjectNode discriminator, final Schema schema, final NodePath instanceLocation) { final JsonNode discriminatorOnSchema = schema.getSchemaNode().get("discriminator"); - if (null != discriminatorOnSchema && null != currentDiscriminatorContext - .getDiscriminatorForPath(schema.getSchemaLocation())) { - // this is where A -> B -> C inheritance exists, A has the root discriminator and B adds to the mapping + if (null != discriminatorOnSchema + && null != currentDiscriminatorContext.getDiscriminatorForPath(schema.getSchemaLocation())) { + // this is where A -> B -> C inheritance exists, A has the root discriminator + // and B adds to the mapping final JsonNode propertyName = discriminatorOnSchema.get("propertyName"); if (null != propertyName) { - throw new SchemaException(instanceLocation + " schema " + schema + " attempts redefining the discriminator property"); + throw new SchemaException( + instanceLocation + " schema " + schema + " attempts redefining the discriminator property"); } final ObjectNode mappingOnContextDiscriminator = (ObjectNode) discriminator.get("mapping"); final ObjectNode mappingOnCurrentSchemaDiscriminator = (ObjectNode) discriminatorOnSchema.get("mapping"); if (null == mappingOnContextDiscriminator && null != mappingOnCurrentSchemaDiscriminator) { - // here we have a mapping on a nested discriminator and none on the root discriminator, so we can simply + // here we have a mapping on a nested discriminator and none on the root + // discriminator, so we can simply // make it the root's discriminator.set("mapping", discriminatorOnSchema); } else if (null != mappingOnContextDiscriminator && null != mappingOnCurrentSchemaDiscriminator) { - // here we have to merge. The spec doesn't specify anything on this, but here we don't accept redefinition of + // here we have to merge. The spec doesn't specify anything on this, but here we + // don't accept redefinition of // mappings that already exist final Iterator> fieldsToAdd = mappingOnCurrentSchemaDiscriminator.fields(); while (fieldsToAdd.hasNext()) { @@ -187,8 +239,8 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr final JsonNode currentMappingValue = mappingOnContextDiscriminator.get(mappingKeyToAdd); if (null != currentMappingValue && !currentMappingValue.equals(mappingValueToAdd)) { - throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd - + "/" + currentMappingValue + " to " + mappingValueToAdd); + throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " + + mappingKeyToAdd + "/" + currentMappingValue + " to " + mappingValueToAdd); } else if (null == currentMappingValue) { mappingOnContextDiscriminator.set(mappingKeyToAdd, mappingValueToAdd); } @@ -198,18 +250,17 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr currentDiscriminatorContext.registerDiscriminator(schema.getSchemaLocation(), discriminator); } - private static void checkForImplicitDiscriminatorMappingMatch(final DiscriminatorContext currentDiscriminatorContext, - final String discriminatorPropertyValue, - final Schema schema) { + private static void checkForImplicitDiscriminatorMappingMatch( + final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, + final Schema schema) { if (schema.getSchemaLocation().getFragment().getName(-1).equals(discriminatorPropertyValue)) { currentDiscriminatorContext.markMatch(); } } - private static void checkForExplicitDiscriminatorMappingMatch(final DiscriminatorContext currentDiscriminatorContext, - final String discriminatorPropertyValue, - final JsonNode discriminatorMapping, - final Schema schema) { + private static void checkForExplicitDiscriminatorMappingMatch( + final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, + final JsonNode discriminatorMapping, final Schema schema) { final Iterator> explicitMappings = discriminatorMapping.fields(); while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); @@ -223,7 +274,7 @@ private static void checkForExplicitDiscriminatorMappingMatch(final Discriminato } private static boolean noExplicitDiscriminatorKeyOverride(final JsonNode discriminatorMapping, - final Schema parentSchema) { + final Schema parentSchema) { final Iterator> explicitMappings = discriminatorMapping.fields(); while (explicitMappings.hasNext()) { final Map.Entry candidateExplicitMapping = explicitMappings.next(); @@ -233,5 +284,5 @@ private static boolean noExplicitDiscriminatorKeyOverride(final JsonNode discrim } } return true; - } + } } diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 53e054b24..8b5a3431a 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -67,4 +67,5 @@ unionType = {0} found, {1} expected uniqueItems = must have only unique items in the array writeOnly = is a write-only field, it cannot appear in the data contentEncoding = does not match content encoding {0} -contentMediaType = is not a content media type \ No newline at end of file +contentMediaType = is not a content media type +discriminator.missing_discriminating_value = required property ''{0}'' for discriminator not found \ No newline at end of file From c046145eb5bc291be748724898abaa9d3160b2ab Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 24 Sep 2025 21:41:59 +0800 Subject: [PATCH 45/74] Refactor discriminator --- .../schema/keyword/AnyOfValidator.java | 16 +++-- .../schema/keyword/DiscriminatorState.java | 67 +++++++++++++++++++ .../keyword/DiscriminatorValidator.java | 42 ++++++++++-- src/main/resources/jsv-messages.properties | 3 +- .../schema/DiscriminatorValidatorTest.java | 3 + .../schema/OpenAPI30JsonSchemaTest.java | 28 ++++---- 6 files changed, 130 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 745285df3..f72600256 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -117,14 +117,14 @@ && canShortCircuit(executionContext)) { boolean discriminatorMatchFound = false; if (refNode != null) { // Check if there is a match - String discriminatingValue = state.getMappedSchema(); - if (discriminatingValue != null) { + String mappedSchema = state.getMappedSchema(); + if (mappedSchema != null) { String ref = refNode.asText(); - if (state.isExplicitMapping() && ref.equals(discriminatingValue)) { + if (state.isExplicitMapping() && ref.equals(mappedSchema)) { // Explicit matching discriminatorMatchFound = true; state.setMatchedSchema(ref); - } else if (!state.isExplicitMapping() && ref.endsWith(discriminatingValue)) { + } else if (!state.isExplicitMapping() && ref.endsWith(mappedSchema)) { // Implicit matching discriminatorMatchFound = true; state.setMatchedSchema(ref); @@ -180,11 +180,13 @@ && canShortCircuit(executionContext)) { * string values, but tooling MAY convert response values to strings for * comparison. * - * https://spec.openapis.org/oas/v3.1.0#discriminator-object + * https://spec.openapis.org/oas/v3.1.2#examples-0 */ DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); - if (state != null && state.getMatchedSchema() == null && state.getDiscriminatingValue() != null) { - // state.getPropertyValue() == null means there is no value at propertyName + if (state != null && !state.hasMatchedSchema() && state.hasDiscriminatingValue()) { + // The check for state.hasDiscriminatingValue is due to issue 988 + // Note that this is related to the DiscriminatorValidator by default not generating an assertion + // if the discriminatingValue is not set in the payload existingErrors.add(error().keyword("discriminator").instanceNode(node) .instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java index 329faca40..8db78e028 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.networknt.schema.keyword; /** @@ -48,6 +64,17 @@ public void setDiscriminatingValue(String discriminatingValue) { this.discriminatingValue = discriminatingValue; } + /** + * Returns ture if the discriminating value is found in the payload + * corresponding to the property name. + * + * @return true if the discriminating value is found in the payload + * corresponding to the property name + */ + public boolean hasDiscriminatingValue() { + return this.discriminatingValue != null; + } + /** * Gets the mapped schema which is the discriminating value mapped to the schema * name or uri. @@ -68,19 +95,59 @@ public void setMappedSchema(String mappedSchema) { this.mappedSchema = mappedSchema; } + /** + * Gets whether the mapping is explicit using the mappings on the discriminator + * keyword. + * + * @return true if the mapping is explicitly mapped using mappings + */ public boolean isExplicitMapping() { return explicitMapping; } + /** + * Sets whether the mapping is explicit using the mappings on the discriminator + * keyword. + * + * @param explicitMapping true if explicitly mapped using mappings + */ public void setExplicitMapping(boolean explicitMapping) { this.explicitMapping = explicitMapping; } + /** + * Sets the matched schema $ref. + * + * @param matchedSchema the matched schema $ref + */ public void setMatchedSchema(String matchedSchema) { this.matchedSchema = matchedSchema; } + /** + * Gets the matched schema $ref. + * + * @return the matched schema $ref + */ public String getMatchedSchema() { return this.matchedSchema; } + + /** + * Returns true if there was a schema that matched the discriminating value. + *

+ * If the discriminating value does not match an implicit or explicit mapping, + * no schema can be determined and validation SHOULD fail. Therefore if this + * returns false validation should fail. + *

+ * 4.8.25.4 + * Examples + * + * @return true if there was a schema that matched the discriminating value. + */ + public boolean hasMatchedSchema() { + return this.matchedSchema != null; + } + + } diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index ba0827497..491ba31b9 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -33,7 +33,13 @@ import com.networknt.schema.SchemaContext; /** - * {@link KeywordValidator} that resolves discriminator. + * {@link KeywordValidator} for discriminator. + *

+ * Note that discriminator MUST NOT change the validation outcome of the schema. + *

+ * Discriminator + * Object */ public class DiscriminatorValidator extends BaseKeywordValidator { /** @@ -83,19 +89,31 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode DiscriminatorState state = null; DiscriminatorState existing = executionContext.getDiscriminatorMapping().get(instanceLocation); if (existing != null) { + /* + * By default this does not throw an exception unless strict for discriminator + * is set to true. + * + * This default is in line with the fact that the discriminator keyword doesn't + * affect validation but just helps to filter the messages. + */ + if (this.schemaContext.getSchemaRegistryConfig().isStrict("discriminator", Boolean.FALSE)) { + throw new SchemaException("Schema at " + this.schemaLocation + + " has a discriminator keyword for which another discriminator keyword has already been set for at " + + instanceLocation); + } /* * This allows a new discriminator keyword if the propertyName is empty or if * the propertyName value is the same as the existing one. * - * This is not specification compliant. There shouldn't be multiple matching - * discriminator keywords for the same instance. + * In the specification the behavior of this is undefined. There shouldn't be + * multiple matching discriminator keywords for the same instance. * * Also propertyName for the discriminator keyword should not be empty according * to the specification. */ if (!"".equals(this.propertyName) && !existing.getPropertyName().equals(this.propertyName)) { throw new SchemaException("Schema at " + this.schemaLocation - + " is redefining the discriminator property that has already been set for " + + " is redefining the discriminator property that has already been set for at " + instanceLocation); } state = existing; @@ -126,9 +144,11 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode state.setMappedSchema(mappedSchema); state.setExplicitMapping(true); } else { - // If explicit mapping not found use implicit value - state.setMappedSchema(discriminatingValue); - state.setExplicitMapping(false); + if (!state.isExplicitMapping()) { // only sets implicit if an explicit mapping was not previously set + // If explicit mapping not found use implicit value + state.setMappedSchema(discriminatingValue); + state.setExplicitMapping(false); + } } } else { /* @@ -136,6 +156,14 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode * in the payload schema, as the behavior when the property is absent is * undefined. */ + /* + * By default this does not generate an assertion unless strict for + * discriminator is set to true. + * + * This default is in line with the intent that discriminator should be an + * annotation and not an assertion and shouldn't change the result which was why + * the specification changed from MUST to SHOULD. + */ if (this.schemaContext.getSchemaRegistryConfig().isStrict("discriminator", Boolean.FALSE)) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .messageKey("discriminator.missing_discriminating_value").arguments(this.propertyName).build()); diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 8b5a3431a..3ef92ee9b 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -68,4 +68,5 @@ uniqueItems = must have only unique items in the array writeOnly = is a write-only field, it cannot appear in the data contentEncoding = does not match content encoding {0} contentMediaType = is not a content media type -discriminator.missing_discriminating_value = required property ''{0}'' for discriminator not found \ No newline at end of file +discriminator.missing_discriminating_value = required property ''{0}'' for discriminator not found +discriminator.anyOf. \ No newline at end of file diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 2558ddbda..2a65d1dff 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -969,7 +969,10 @@ void anyOfRedefinedDiscriminatorAndDiscriminatorWithMissingPropertyName() { Schema schema = factory.getSchema(schemaData); List messages = schema.validate(inputData, InputFormat.JSON); List list = messages.stream().collect(Collectors.toList()); + // There should be no errors as discriminator should not affect the validation result of anyOf + // Although the matched schema has the following error // : required property 'numberOfBeds' not found + // There is still a schema in the anyOf that matches assertTrue(list.isEmpty()); } diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index 2c100d681..09075e756 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -30,12 +30,11 @@ private void runTestFile(String testCaseFile) throws Exception { try { JsonNode testCase = testCases.get(j); System.out.println("Test Case ["+(j+1)+"]: "+testCase.get("description")); - System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testCase.get("schema"))); - System.out.println("Tests:"); + //System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testCase.get("schema"))); ArrayNode testNodes = (ArrayNode) testCase.get("tests"); for (int i = 0; i < testNodes.size(); i++) { JsonNode test = testNodes.get(i); - System.out.println(test); + System.out.println("> Test Data ["+(i+1)+"]: "+test); JsonNode node = test.get("data"); JsonNode typeLooseNode = test.get("isTypeLoose"); // Configure the schemaValidator to set typeLoose's value based on the test file, @@ -51,10 +50,10 @@ private void runTestFile(String testCaseFile) throws Exception { if (test.get("valid").asBoolean()) { if (!errors.isEmpty()) { - System.out.println("---- test case failed ----"); - System.out.println("schema: " + schema); - System.out.println("data: " + test.get("data")); - System.out.println("errors:"); + System.out.println("---- Test Data ["+(i+1)+"] FAILED [Unexpected Errors] ----"); + System.out.println("> Schema: " + schema); + System.out.println("> Data : " + test.get("data")); + System.out.println("> Errors:"); for (Error error : errors) { System.out.println(error); } @@ -63,16 +62,17 @@ private void runTestFile(String testCaseFile) throws Exception { } else { // System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testCase.get("schema"))); if (errors.isEmpty()) { - System.out.println("---- test case failed ----"); - System.out.println("schema: " + schema); - System.out.println("data: " + test.get("data")); + System.out.println("---- Test Data ["+(i+1)+"] FAILED [Unexpected Success] ----"); + System.out.println("> Schema: " + schema); + System.out.println("> Data : " + test.get("data")); } else { JsonNode errorCount = test.get("errorCount"); if (errorCount != null && errorCount.isInt() && errors.size() != errorCount.asInt()) { - System.out.println("---- test case failed ----"); - System.out.println("schema: " + schema); - System.out.println("data: " + test.get("data")); - System.out.println("errors: " + errors); + System.out.println("---- Test Data [" + (i + 1) + "] FAILED [Expected " + + errorCount.asInt() + " Errors but was " + errors.size() + "] ----"); + System.out.println("> Schema: " + schema); + System.out.println("> Data : " + test.get("data")); + System.out.println("> Errors: " + errors); for (Error error : errors) { System.out.println(error); } From bf23a13273ec22e1679144442a95d5f39d099772 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Thu, 25 Sep 2025 01:34:45 +0800 Subject: [PATCH 46/74] Refactor discriminator --- .../schema/keyword/AnyOfValidator.java | 18 +---- .../schema/keyword/DiscriminatorState.java | 69 ++++++++++++++++++- .../keyword/DiscriminatorValidator.java | 30 ++++++++ 3 files changed, 101 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index f72600256..a36ece0e0 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -113,23 +113,11 @@ && canShortCircuit(executionContext)) { return; } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { JsonNode refNode = schema.getSchemaNode().get("$ref"); - DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + DiscriminatorState discriminator = executionContext.getDiscriminatorMapping() + .get(instanceLocation); boolean discriminatorMatchFound = false; if (refNode != null) { - // Check if there is a match - String mappedSchema = state.getMappedSchema(); - if (mappedSchema != null) { - String ref = refNode.asText(); - if (state.isExplicitMapping() && ref.equals(mappedSchema)) { - // Explicit matching - discriminatorMatchFound = true; - state.setMatchedSchema(ref); - } else if (!state.isExplicitMapping() && ref.endsWith(mappedSchema)) { - // Implicit matching - discriminatorMatchFound = true; - state.setMatchedSchema(ref); - } - } + discriminatorMatchFound = discriminator.matches(refNode.asText()); } if (discriminatorMatchFound) { /* diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java index 8db78e028..4feacf276 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java @@ -20,12 +20,80 @@ * Discriminator state for an instance location. */ public class DiscriminatorState { + /** + * The propertyName field defined in the discriminator keyword schema. + */ private String propertyName; + /** + * The discriminating value from the payload matching the property name. + */ private String discriminatingValue; + /** + * The mapped schema from the mapping or the discriminating value if there is no + * mapping. + */ private String mappedSchema = null; + + /** + * Whether the mapped schema is explicitly mapped using mapping or is the + * discriminating value. + */ private boolean explicitMapping = false; + + /** + * The matched schema for the instance. + */ private String matchedSchema; + /** + * Determines if there is a match of the mapped schema to the ref and update the + * matched schema if there is a match. + * + * @param refSchema the $ref value + * @return true if there is a match + */ + public boolean matches(String refSchema) { + boolean discriminatorMatchFound = false; + String mappedSchema = getMappedSchema(); + if (mappedSchema != null) { + if (isExplicitMapping() && refSchema.equals(mappedSchema)) { + // Explicit matching + discriminatorMatchFound = true; + setMatchedSchema(refSchema); + } else if (!isExplicitMapping() && isImplicitMatch(refSchema, mappedSchema)) { + // Implicit matching + discriminatorMatchFound = true; + setMatchedSchema(refSchema); + } + } + return discriminatorMatchFound; + } + + /** + * Determine if there is an implicit match of the mapped schema to the ref. + * + * @param refSchema the $ref value + * @param mappedSchema the mapped schema + * @return true if there is a match + */ + private static boolean isImplicitMatch(String refSchema, String mappedSchema) { + /* + * To ensure that an ambiguous value (e.g. "foo") is treated as a relative URI + * reference by all implementations, authors MUST prefix it with the "." path + * segment (e.g. "./foo"). + */ + if (mappedSchema.startsWith(".")) { + return refSchema.equals(mappedSchema); + } else { + int found = refSchema.lastIndexOf('/'); + if (found == -1) { + return refSchema.equals(mappedSchema); + } else { + return refSchema.substring(found + 1).equals(mappedSchema); + } + } + } + /** * Gets the property name defined in the discriminator keyword schema. * @@ -149,5 +217,4 @@ public boolean hasMatchedSchema() { return this.matchedSchema != null; } - } diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 491ba31b9..53f00d9ca 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -54,6 +54,16 @@ public class DiscriminatorValidator extends BaseKeywordValidator { */ private final Map mapping; + /** + * The schema name or URI reference to a schema that is expected to validate the + * structure of the model when the discriminating property is not present in the + * payload or contains a value for which there is no explicit or implicit + * mapping. + *

+ * Since OpenAPI 3.2.0 + */ + private final String defaultMapping; + public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { super(KeywordType.DISCRIMINATOR, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); @@ -77,9 +87,19 @@ public DiscriminatorValidator(SchemaLocation schemaLocation, NodePath evaluation } else { this.mapping = Collections.emptyMap(); } + + // Check if OpenAPI 3.2.0 + JsonNode defaultMapping = discriminator.get("defaultMapping"); + if (defaultMapping != null) { + this.defaultMapping = defaultMapping.asText(); + } else { + this.defaultMapping = null; + } + } else { this.propertyName = ""; this.mapping = Collections.emptyMap(); + this.defaultMapping = null; } } @@ -151,6 +171,15 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } } } else { + /* + * Since OpenAPI 3.2.0 if defaultMapping is set, then the property is optional. + */ + if (this.defaultMapping != null) { + state.setMappedSchema(defaultMapping); + state.setExplicitMapping(true); + return; + } + /* * The property is not present in the payload. This property SHOULD be required * in the payload schema, as the behavior when the property is absent is @@ -166,6 +195,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode */ if (this.schemaContext.getSchemaRegistryConfig().isStrict("discriminator", Boolean.FALSE)) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) .messageKey("discriminator.missing_discriminating_value").arguments(this.propertyName).build()); } } From b2f32f6e8c9dd599098de8044de7f2c15c58874d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:33:27 +0800 Subject: [PATCH 47/74] Refactor discriminator --- .../schema/DiscriminatorContext.java | 58 ----- .../networknt/schema/ExecutionContext.java | 36 +-- .../java/com/networknt/schema/Schema.java | 43 +--- .../schema/keyword/AllOfValidator.java | 58 ++--- .../schema/keyword/AnyOfValidator.java | 223 +++++++++--------- .../schema/keyword/DiscriminatorState.java | 51 ++-- .../keyword/DiscriminatorValidator.java | 130 +--------- .../schema/keyword/OneOfValidator.java | 193 +++++++-------- src/main/resources/jsv-messages.properties | 3 +- .../schema/DiscriminatorValidatorTest.java | 7 +- .../resources/openapi3/discriminator.json | 24 +- 11 files changed, 276 insertions(+), 550 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/DiscriminatorContext.java diff --git a/src/main/java/com/networknt/schema/DiscriminatorContext.java b/src/main/java/com/networknt/schema/DiscriminatorContext.java deleted file mode 100644 index 1ab2ddd76..000000000 --- a/src/main/java/com/networknt/schema/DiscriminatorContext.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.networknt.schema; - -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class DiscriminatorContext { - private final Map discriminators = new HashMap<>(); - - private boolean discriminatorMatchFound = false; - - private boolean discriminatorIgnore = false; - - public void registerDiscriminator(final SchemaLocation schemaLocation, final ObjectNode discriminator) { - this.discriminators.put("#" + schemaLocation.getFragment().toString(), discriminator); - } - - public ObjectNode getDiscriminatorForPath(final SchemaLocation schemaLocation) { - return this.discriminators.get("#" + schemaLocation.getFragment().toString()); - } - - public ObjectNode getDiscriminatorForPath(final String schemaLocation) { - return this.discriminators.get(schemaLocation); - } - - public void markMatch() { - this.discriminatorMatchFound = true; - } - - /** - * Indicate that discriminator processing should be ignored. - *

- * This is used when the discriminator property value is missing from the data. - *

- * See issue #436 for background. - */ - public void markIgnore() { - this.discriminatorIgnore = true; - } - - public boolean isDiscriminatorMatchFound() { - return this.discriminatorMatchFound; - } - - public boolean isDiscriminatorIgnore() { - return this.discriminatorIgnore; - } - - /** - * Returns true if we have a discriminator active. In this case no valid match in anyOf should lead to validation failure - * - * @return true in case there are discriminator candidates - */ - public boolean isActive() { - return !this.discriminators.isEmpty(); - } -} \ No newline at end of file diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 6dba7e305..e8e6f5c06 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -16,19 +16,18 @@ package com.networknt.schema; -import com.networknt.schema.annotation.Annotations; -import com.networknt.schema.keyword.DiscriminatorState; -import com.networknt.schema.path.NodePath; -import com.networknt.schema.result.SchemaResults; -import com.networknt.schema.walk.WalkConfig; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Stack; import java.util.function.Consumer; +import com.networknt.schema.annotation.Annotations; +import com.networknt.schema.keyword.DiscriminatorState; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.result.SchemaResults; +import com.networknt.schema.walk.WalkConfig; + /** * Stores the execution context for the validation run. */ @@ -37,7 +36,6 @@ public class ExecutionContext { private WalkConfig walkConfig = null; private CollectorContext collectorContext = null; - private Stack discriminatorContexts = null; private Annotations annotations = null; private SchemaResults results = null; private List errors = new ArrayList<>(); @@ -190,28 +188,6 @@ public void setFailFast(boolean failFast) { this.failFast = failFast; } - public DiscriminatorContext getCurrentDiscriminatorContext() { - if (this.discriminatorContexts == null) { - return null; - } - - if (!this.discriminatorContexts.empty()) { - return this.discriminatorContexts.peek(); - } - return null; // this is the case when we get on a schema that has a discriminator, but it's not used in anyOf - } - - public void enterDiscriminatorContext(final DiscriminatorContext ctx, @SuppressWarnings("unused") NodePath instanceLocation) { - if (this.discriminatorContexts == null) { - this.discriminatorContexts = new Stack<>(); - } - this.discriminatorContexts.push(ctx); - } - - public void leaveDiscriminatorContextImmediately(@SuppressWarnings("unused") NodePath instanceLocation) { - this.discriminatorContexts.pop(); - } - public List getErrors() { return this.errors; } diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 1a7a4f248..26a50afb5 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -30,8 +30,6 @@ import java.util.function.Consumer; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.keyword.DiscriminatorValidator; import com.networknt.schema.keyword.KeywordValidator; import com.networknt.schema.keyword.TypeValidator; import com.networknt.schema.path.NodePath; @@ -678,6 +676,10 @@ private List read(JsonNode schemaNode) { if (lhsName.equals(rhsName)) return 0; + // Discriminator needs to run first to set state in the execution context + if (lhsName.equals("discriminator")) return -1; + if (rhsName.equals("discriminator")) return 1; + if (lhsName.equals("properties")) return -1; if (rhsName.equals("properties")) return 1; if (lhsName.equals("patternProperties")) return -1; @@ -694,47 +696,10 @@ private List read(JsonNode schemaNode) { @Override public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonNode rootNode, NodePath instanceLocation) { - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - ObjectNode discriminator = (ObjectNode) schemaNode.get("discriminator"); - if (null != discriminator && null != executionContext.getCurrentDiscriminatorContext()) { - executionContext.getCurrentDiscriminatorContext().registerDiscriminator(schemaLocation, - discriminator); - } - } int currentErrors = executionContext.getErrors().size(); for (KeywordValidator v : getValidators()) { v.validate(executionContext, jsonNode, rootNode, instanceLocation); } - - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - ObjectNode discriminator = (ObjectNode) this.schemaNode.get("discriminator"); - if (null != discriminator) { - final DiscriminatorContext discriminatorContext = executionContext - .getCurrentDiscriminatorContext(); - if (null != discriminatorContext) { - final ObjectNode discriminatorToUse; - final ObjectNode discriminatorFromContext = discriminatorContext - .getDiscriminatorForPath(this.schemaLocation); - if (null == discriminatorFromContext) { - // register the current discriminator. This can only happen when the current context discriminator - // was not registered via allOf. In that case we have a $ref to the schema with discriminator that gets - // used for validation before allOf validation has kicked in - discriminatorContext.registerDiscriminator(this.schemaLocation, discriminator); - discriminatorToUse = discriminator; - } else { - discriminatorToUse = discriminatorFromContext; - } - - final String discriminatorPropertyName = discriminatorToUse.get("propertyName").asText(); - final JsonNode discriminatorNode = jsonNode.get(discriminatorPropertyName); - final String discriminatorPropertyValue = discriminatorNode == null ? null - : discriminatorNode.asText(); - DiscriminatorValidator.checkDiscriminatorMatch(discriminatorContext, discriminatorToUse, discriminatorPropertyValue, - this); - } - } - } - if (executionContext.getErrors().size() > currentErrors) { // Failed with assertion set result and drop all annotations from this schema // and all subschemas diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index 063e67a37..09373abab 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -16,19 +16,18 @@ package com.networknt.schema.keyword; -import java.util.*; +import java.util.ArrayList; +import java.util.List; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonType; import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; -import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for allOf. @@ -36,15 +35,13 @@ public class AllOfValidator extends BaseKeywordValidator { private final List schemas; - public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + Schema parentSchema, SchemaContext schemaContext) { super(KeywordType.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new SchemaException(error().instanceNode(schemaNode) - .instanceLocation(schemaLocation.getFragment()) - .messageKey("type") - .arguments(nodeType.toString(), "array") - .build()); + throw new SchemaException(error().instanceNode(schemaNode).instanceLocation(schemaLocation.getFragment()) + .messageKey("type").arguments(nodeType.toString(), "array").build()); } int size = schemaNode.size(); this.schemas = new ArrayList<>(size); @@ -55,50 +52,25 @@ public AllOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, Js } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation) { validate(executionContext, node, rootNode, instanceLocation, false); } - protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean walk) { + protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation, boolean walk) { for (Schema schema : this.schemas) { if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); } else { schema.walk(executionContext, node, rootNode, instanceLocation, true); } - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - final Iterator arrayElements = this.schemaNode.elements(); - while (arrayElements.hasNext()) { - final ObjectNode allOfEntry = (ObjectNode) arrayElements.next(); - final JsonNode $ref = allOfEntry.get("$ref"); - if (null != $ref) { - final DiscriminatorContext currentDiscriminatorContext = executionContext - .getCurrentDiscriminatorContext(); - if (null != currentDiscriminatorContext) { - final ObjectNode discriminator = currentDiscriminatorContext - .getDiscriminatorForPath(allOfEntry.get("$ref").asText()); - if (null != discriminator) { - DiscriminatorValidator.registerAndMergeDiscriminator(currentDiscriminatorContext, discriminator, - this.parentSchema, instanceLocation); - // now we have to check whether we have hit the right target - final String discriminatorPropertyName = discriminator.get("propertyName").asText(); - final JsonNode discriminatorNode = node.get(discriminatorPropertyName); - final String discriminatorPropertyValue = discriminatorNode == null ? null - : discriminatorNode.textValue(); - - final Schema jsonSchema = this.parentSchema; - DiscriminatorValidator.checkDiscriminatorMatch(currentDiscriminatorContext, discriminator, - discriminatorPropertyValue, jsonSchema); - } - } - } - } - } } } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, + boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; @@ -107,7 +79,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root // Walk through the schema schema.walk(executionContext, node, rootNode, instanceLocation, false); } - } + } @Override public void preloadSchema() { diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index a36ece0e0..2bf6604d7 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -16,19 +16,19 @@ package com.networknt.schema.keyword; +import java.util.ArrayList; +import java.util.List; + import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonType; import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; -import com.networknt.schema.SchemaContext; - -import java.util.*; /** * {@link KeywordValidator} for anyOf. @@ -38,15 +38,13 @@ public class AnyOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public AnyOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public AnyOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + Schema parentSchema, SchemaContext schemaContext) { super(KeywordType.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new SchemaException(error().instanceNode(schemaNode) - .instanceLocation(schemaLocation.getFragment()) - .messageKey("type") - .arguments(nodeType.toString(), "array") - .build()); + throw new SchemaException(error().instanceNode(schemaNode).instanceLocation(schemaLocation.getFragment()) + .messageKey("type").arguments(nodeType.toString(), "array").build()); } int size = schemaNode.size(); this.schemas = new ArrayList<>(size); @@ -64,130 +62,122 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean walk) { - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - executionContext.enterDiscriminatorContext(new DiscriminatorContext(), instanceLocation); - } int numberOfValidSubSchemas = 0; List existingErrors = executionContext.getErrors(); - List allErrors = null; // Keeps track of all the errors for reporting if in the end none of the schemas match - List discriminatorErrors = null; - List errors = new ArrayList<>(); - executionContext.setErrors(errors); + List allErrors = null; // Keeps track of all the errors for reporting if in the end none of the schemas + // match + List discriminatorErrors = null; // The errors from the sub schema that match the discriminator + List subSchemaErrors = new ArrayList<>(); // Temporary errors from each sub schema execution + executionContext.setErrors(subSchemaErrors); + + // Save flag as nested schema evaluation shouldn't trigger fail fast + boolean failFast = executionContext.isFailFast(); try { - // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.isFailFast(); - try { - executionContext.setFailFast(false); - for (Schema schema : this.schemas) { - errors.clear(); - TypeValidator typeValidator = schema.getTypeValidator(); - if (typeValidator != null) { - // If schema has type validator and node type doesn't match with schemaType then - // ignore it - // For union type, it is a must to call TypeValidator - if (typeValidator.getSchemaType() != JsonType.UNION && !typeValidator.equalsToSchemaType(node)) { - typeValidator.validate(executionContext, node, rootNode, instanceLocation); - if (allErrors == null) { - allErrors = new ArrayList<>(); - } - allErrors.addAll(errors); - continue; + executionContext.setFailFast(false); + for (Schema schema : this.schemas) { + subSchemaErrors.clear(); // Reuse and clear for each run + TypeValidator typeValidator = schema.getTypeValidator(); + if (typeValidator != null) { + // If schema has type validator and node type doesn't match with schemaType then + // ignore it + // For union type, it is a must to call TypeValidator + if (typeValidator.getSchemaType() != JsonType.UNION && !typeValidator.equalsToSchemaType(node)) { + typeValidator.validate(executionContext, node, rootNode, instanceLocation); + if (allErrors == null) { + allErrors = new ArrayList<>(); } + allErrors.addAll(subSchemaErrors); + continue; } - if (!walk) { - schema.validate(executionContext, node, rootNode, instanceLocation); - } else { - schema.walk(executionContext, node, rootNode, instanceLocation, true); - } + } + if (!walk) { + schema.validate(executionContext, node, rootNode, instanceLocation); + } else { + schema.walk(executionContext, node, rootNode, instanceLocation, true); + } - // check if any validation errors have occurred - if (errors.isEmpty()) { - // we found a valid subschema, so increase counter - numberOfValidSubSchemas++; - } + // check if any validation errors have occurred + if (subSchemaErrors.isEmpty()) { + // we found a valid subschema, so increase counter + numberOfValidSubSchemas++; + } - if (errors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) && canShortCircuit() - && canShortCircuit(executionContext)) { - // Successful so return only the existing errors, ie. no new errors - executionContext.setErrors(existingErrors); - return; - } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - JsonNode refNode = schema.getSchemaNode().get("$ref"); - DiscriminatorState discriminator = executionContext.getDiscriminatorMapping() - .get(instanceLocation); - boolean discriminatorMatchFound = false; - if (refNode != null) { - discriminatorMatchFound = discriminator.matches(refNode.asText()); - } - if (discriminatorMatchFound) { + if (subSchemaErrors.isEmpty() && (!this.schemaContext.isDiscriminatorKeywordEnabled()) + && canShortCircuit() && canShortCircuit(executionContext)) { + // Successful so return only the existing errors, ie. no new errors + executionContext.setErrors(existingErrors); + return; + } else if (this.schemaContext.isDiscriminatorKeywordEnabled()) { + boolean discriminatorMatchFound = false; + DiscriminatorState discriminator = executionContext.getDiscriminatorMapping().get(instanceLocation); + JsonNode refNode = schema.getSchemaNode().get("$ref"); + if (discriminator != null && refNode != null) { + discriminatorMatchFound = discriminator.matches(refNode.asText()); + } + if (discriminatorMatchFound) { + /* + * Note that discriminator cannot change the outcome of the evaluation but can + * be used to filter off any additional messages + */ + if (!subSchemaErrors.isEmpty()) { /* - * Note that discriminator cannot change the outcome of the evaluation but can - * be used to filter off any additional messages + * This means that the discriminated value has errors and doesn't match so these + * errors are the only ones that will be reported *IF* there are no other + * schemas that successfully validate to meet the requirement of anyOf. + * + * If there are any successful schemas as per anyOf, all these errors will be + * discarded. */ - if (!errors.isEmpty()) { - /* - * This means that the discriminated value has errors and doesn't match so these - * errors are the only ones that will be reported *IF* there are no other - * schemas that successfully validate to meet the requirement of anyOf. - * - * If there are any successful schemas as per anyOf, all these errors will be - * discarded. - */ - discriminatorErrors = new ArrayList<>(errors); - allErrors = null; // This is no longer needed - } - } - } - /* - * This adds all the errors for this schema to the list that contains all the - * errors for later reporting. - * - * There's no need to add these if there was a discriminator match with errors - * as only the discriminator errors will be reported if all the schemas fail. - */ - if (!errors.isEmpty() && discriminatorErrors == null) { - if (allErrors == null) { - allErrors = new ArrayList<>(); + discriminatorErrors = new ArrayList<>(subSchemaErrors); + allErrors = null; // This is no longer needed } - allErrors.addAll(errors); } } - } finally { - // Restore flag - executionContext.setFailFast(failFast); - } - - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { /* - * The only case where the discriminator can change the outcome of the result is - * if the discriminator value does not match an implicit or explicit mapping - */ - /* - * If the discriminator value does not match an implicit or explicit mapping, no - * schema can be determined and validation SHOULD fail. Mapping keys MUST be - * string values, but tooling MAY convert response values to strings for - * comparison. + * This adds all the errors for this schema to the list that contains all the + * errors for later reporting. * - * https://spec.openapis.org/oas/v3.1.2#examples-0 + * There's no need to add these if there was a discriminator match with errors + * as only the discriminator errors will be reported if all the schemas fail. */ - DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); - if (state != null && !state.hasMatchedSchema() && state.hasDiscriminatingValue()) { - // The check for state.hasDiscriminatingValue is due to issue 988 - // Note that this is related to the DiscriminatorValidator by default not generating an assertion - // if the discriminatingValue is not set in the payload - existingErrors.add(error().keyword("discriminator").instanceNode(node) - .instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .arguments( - "based on the provided discriminator. No alternative could be chosen based on the discriminator property") - .build()); + if (!subSchemaErrors.isEmpty() && discriminatorErrors == null) { + if (allErrors == null) { + allErrors = new ArrayList<>(); + } + allErrors.addAll(subSchemaErrors); } } } finally { - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - executionContext.leaveDiscriminatorContextImmediately(instanceLocation); + // Restore flag + executionContext.setFailFast(failFast); + } + + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { + /* + * The only case where the discriminator can change the outcome of the result is + * if the discriminator value does not match an implicit or explicit mapping + */ + /* + * If the discriminator value does not match an implicit or explicit mapping, no + * schema can be determined and validation SHOULD fail. Mapping keys MUST be + * string values, but tooling MAY convert response values to strings for + * comparison. + * + * https://spec.openapis.org/oas/v3.1.2#examples-0 + */ + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + if (state != null && !state.hasMatchedSchema() && state.hasDiscriminatingValue()) { + // The check for state.hasDiscriminatingValue is due to issue 988 + // Note that this is related to the DiscriminatorValidator by default not + // generating an assertion + // if the discriminatingValue is not set in the payload + existingErrors.add(error().keyword("discriminator").instanceNode(node) + .instanceLocation(instanceLocation).locale(executionContext.getExecutionConfig().getLocale()) + .messageKey("discriminator.anyOf.no_match_found").arguments(state.getDiscriminatingValue()) + .build()); } } + if (numberOfValidSubSchemas >= 1) { // Successful so return only the existing errors, ie. no new errors executionContext.setErrors(existingErrors); @@ -205,7 +195,8 @@ && canShortCircuit(executionContext)) { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, + boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); return; diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java index 4feacf276..a92095c3b 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorState.java @@ -69,31 +69,6 @@ public boolean matches(String refSchema) { return discriminatorMatchFound; } - /** - * Determine if there is an implicit match of the mapped schema to the ref. - * - * @param refSchema the $ref value - * @param mappedSchema the mapped schema - * @return true if there is a match - */ - private static boolean isImplicitMatch(String refSchema, String mappedSchema) { - /* - * To ensure that an ambiguous value (e.g. "foo") is treated as a relative URI - * reference by all implementations, authors MUST prefix it with the "." path - * segment (e.g. "./foo"). - */ - if (mappedSchema.startsWith(".")) { - return refSchema.equals(mappedSchema); - } else { - int found = refSchema.lastIndexOf('/'); - if (found == -1) { - return refSchema.equals(mappedSchema); - } else { - return refSchema.substring(found + 1).equals(mappedSchema); - } - } - } - /** * Gets the property name defined in the discriminator keyword schema. * @@ -133,7 +108,7 @@ public void setDiscriminatingValue(String discriminatingValue) { } /** - * Returns ture if the discriminating value is found in the payload + * Returns true if the discriminating value is found in the payload * corresponding to the property name. * * @return true if the discriminating value is found in the payload @@ -217,4 +192,28 @@ public boolean hasMatchedSchema() { return this.matchedSchema != null; } + /** + * Determine if there is an implicit match of the mapped schema to the ref. + * + * @param refSchema the $ref value + * @param mappedSchema the mapped schema + * @return true if there is a match + */ + private static boolean isImplicitMatch(String refSchema, String mappedSchema) { + /* + * To ensure that an ambiguous value (e.g. "foo") is treated as a relative URI + * reference by all implementations, authors MUST prefix it with the "." path + * segment (e.g. "./foo"). + */ + if (mappedSchema.startsWith(".")) { + return refSchema.equals(mappedSchema); + } else { + int found = refSchema.lastIndexOf('/'); + if (found == -1) { + return refSchema.equals(mappedSchema); + } else { + return refSchema.substring(found + 1).equals(mappedSchema); + } + } + } } diff --git a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java index 53f00d9ca..cdce9ac1d 100644 --- a/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java +++ b/src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java @@ -24,13 +24,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; -import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for discriminator. @@ -39,7 +38,7 @@ *

* Discriminator - * Object + * Object */ public class DiscriminatorValidator extends BaseKeywordValidator { /** @@ -218,129 +217,4 @@ public String getPropertyName() { public Map getMapping() { return mapping; } - - /** - * Checks based on the current {@link DiscriminatorContext} whether the provided - * {@link Schema} a match against the current discriminator. - * - * @param currentDiscriminatorContext the currently active - * {@link DiscriminatorContext} - * @param discriminator the discriminator to use for the check - * @param discriminatorPropertyValue the value of the - * discriminator/propertyName - * field - * @param jsonSchema the {@link Schema} to check - */ - public static void checkDiscriminatorMatch(final DiscriminatorContext currentDiscriminatorContext, - final ObjectNode discriminator, final String discriminatorPropertyValue, final Schema jsonSchema) { - if (discriminatorPropertyValue == null) { - currentDiscriminatorContext.markIgnore(); - return; - } - - final JsonNode discriminatorMapping = discriminator.get("mapping"); - if (null == discriminatorMapping) { - checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, - jsonSchema); - } else { - checkForExplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, - discriminatorMapping, jsonSchema); - if (!currentDiscriminatorContext.isDiscriminatorMatchFound() - && noExplicitDiscriminatorKeyOverride(discriminatorMapping, jsonSchema)) { - checkForImplicitDiscriminatorMappingMatch(currentDiscriminatorContext, discriminatorPropertyValue, - jsonSchema); - } - } - } - - /** - * Rolls up all nested and compatible discriminators to the root discriminator - * of the type. Detects attempts to redefine the propertyName or - * mappings. - * - * @param currentDiscriminatorContext the currently active - * {@link DiscriminatorContext} - * @param discriminator the discriminator to use for the check - * @param schema the value of the - * discriminator/propertyName - * field - * @param instanceLocation the logging prefix - */ - public static void registerAndMergeDiscriminator(final DiscriminatorContext currentDiscriminatorContext, - final ObjectNode discriminator, final Schema schema, final NodePath instanceLocation) { - final JsonNode discriminatorOnSchema = schema.getSchemaNode().get("discriminator"); - if (null != discriminatorOnSchema - && null != currentDiscriminatorContext.getDiscriminatorForPath(schema.getSchemaLocation())) { - // this is where A -> B -> C inheritance exists, A has the root discriminator - // and B adds to the mapping - final JsonNode propertyName = discriminatorOnSchema.get("propertyName"); - if (null != propertyName) { - throw new SchemaException( - instanceLocation + " schema " + schema + " attempts redefining the discriminator property"); - } - final ObjectNode mappingOnContextDiscriminator = (ObjectNode) discriminator.get("mapping"); - final ObjectNode mappingOnCurrentSchemaDiscriminator = (ObjectNode) discriminatorOnSchema.get("mapping"); - if (null == mappingOnContextDiscriminator && null != mappingOnCurrentSchemaDiscriminator) { - // here we have a mapping on a nested discriminator and none on the root - // discriminator, so we can simply - // make it the root's - discriminator.set("mapping", discriminatorOnSchema); - } else if (null != mappingOnContextDiscriminator && null != mappingOnCurrentSchemaDiscriminator) { - // here we have to merge. The spec doesn't specify anything on this, but here we - // don't accept redefinition of - // mappings that already exist - final Iterator> fieldsToAdd = mappingOnCurrentSchemaDiscriminator.fields(); - while (fieldsToAdd.hasNext()) { - final Map.Entry fieldToAdd = fieldsToAdd.next(); - final String mappingKeyToAdd = fieldToAdd.getKey(); - final JsonNode mappingValueToAdd = fieldToAdd.getValue(); - - final JsonNode currentMappingValue = mappingOnContextDiscriminator.get(mappingKeyToAdd); - if (null != currentMappingValue && !currentMappingValue.equals(mappingValueToAdd)) { - throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " - + mappingKeyToAdd + "/" + currentMappingValue + " to " + mappingValueToAdd); - } else if (null == currentMappingValue) { - mappingOnContextDiscriminator.set(mappingKeyToAdd, mappingValueToAdd); - } - } - } - } - currentDiscriminatorContext.registerDiscriminator(schema.getSchemaLocation(), discriminator); - } - - private static void checkForImplicitDiscriminatorMappingMatch( - final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, - final Schema schema) { - if (schema.getSchemaLocation().getFragment().getName(-1).equals(discriminatorPropertyValue)) { - currentDiscriminatorContext.markMatch(); - } - } - - private static void checkForExplicitDiscriminatorMappingMatch( - final DiscriminatorContext currentDiscriminatorContext, final String discriminatorPropertyValue, - final JsonNode discriminatorMapping, final Schema schema) { - final Iterator> explicitMappings = discriminatorMapping.fields(); - while (explicitMappings.hasNext()) { - final Map.Entry candidateExplicitMapping = explicitMappings.next(); - if (candidateExplicitMapping.getKey().equals(discriminatorPropertyValue) - && ("#" + schema.getSchemaLocation().getFragment().toString()) - .equals(candidateExplicitMapping.getValue().asText())) { - currentDiscriminatorContext.markMatch(); - break; - } - } - } - - private static boolean noExplicitDiscriminatorKeyOverride(final JsonNode discriminatorMapping, - final Schema parentSchema) { - final Iterator> explicitMappings = discriminatorMapping.fields(); - while (explicitMappings.hasNext()) { - final Map.Entry candidateExplicitMapping = explicitMappings.next(); - if (candidateExplicitMapping.getValue().asText() - .equals(parentSchema.getSchemaLocation().getFragment().toString())) { - return false; - } - } - return true; - } } diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 55e9594e9..3d82ea94f 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -20,17 +20,15 @@ import java.util.List; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.DiscriminatorContext; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; +import com.networknt.schema.JsonType; import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; -import com.networknt.schema.SchemaContext; /** * {@link KeywordValidator} for oneOf. @@ -40,21 +38,20 @@ public class OneOfValidator extends BaseKeywordValidator { private Boolean canShortCircuit = null; - public OneOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + public OneOfValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + Schema parentSchema, SchemaContext schemaContext) { super(KeywordType.ONE_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); if (!schemaNode.isArray()) { JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig()); - throw new SchemaException(error().instanceNode(schemaNode) - .instanceLocation(schemaLocation.getFragment()) - .messageKey("type") - .arguments(nodeType.toString(), "array") - .build()); + throw new SchemaException(error().instanceNode(schemaNode).instanceLocation(schemaLocation.getFragment()) + .messageKey("type").arguments(nodeType.toString(), "array").build()); } int size = schemaNode.size(); this.schemas = new ArrayList<>(size); for (int i = 0; i < size; i++) { JsonNode childNode = schemaNode.get(i); - this.schemas.add(schemaContext.newSchema( schemaLocation.append(i), evaluationPath.append(i), childNode, parentSchema)); + this.schemas.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), childNode, + parentSchema)); } } @@ -66,35 +63,22 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean walk) { - int numberOfValidSchema = 0; int index = 0; List indexes = null; List existingErrors = executionContext.getErrors(); - List childErrors = null; - List schemaErrors = new ArrayList<>(); - executionContext.setErrors(schemaErrors); + List allErrors = null; // Keeps track of all the errors for reporting if in the end none or more than + // one sub schema matches + List discriminatorErrors = null; // The errors from the sub schema that match the discriminator + List subSchemaErrors = new ArrayList<>(); // Temporary errors from each sub schema execution + + executionContext.setErrors(subSchemaErrors); // Save flag as nested schema evaluation shouldn't trigger fail fast boolean failFast = executionContext.isFailFast(); - boolean addMessages = true; try { - DiscriminatorValidator discriminator = null; - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - DiscriminatorContext discriminatorContext = new DiscriminatorContext(); - executionContext.enterDiscriminatorContext(discriminatorContext, instanceLocation); - - // check if discriminator present - discriminator = (DiscriminatorValidator) this.getParentSchema().getValidators().stream() - .filter(v -> "discriminator".equals(v.getKeyword())).findFirst().orElse(null); - if (discriminator != null) { - // this is just to make the discriminator context active - discriminatorContext.registerDiscriminator(discriminator.getSchemaLocation(), - (ObjectNode) discriminator.getSchemaNode()); - } - } executionContext.setFailFast(false); for (Schema schema : this.schemas) { - schemaErrors.clear(); + subSchemaErrors.clear(); if (!walk) { schema.validate(executionContext, node, rootNode, instanceLocation); } else { @@ -102,99 +86,115 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo } // check if any validation errors have occurred - if (schemaErrors.isEmpty()) { // No new errors + if (subSchemaErrors.isEmpty()) { // No new errors numberOfValidSchema++; if (indexes == null) { indexes = new ArrayList<>(); } indexes.add(Integer.toString(index)); } - + if (numberOfValidSchema > 1 && canShortCircuit()) { // short-circuit - // note that the short circuit means that only 2 valid schemas are reported even if could be more + // note that the short circuit means that only 2 valid schemas are reported even + // if could be more break; } - + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - // The discriminator will cause all messages other than the one with the - // matching discriminator to be discarded. Note that the discriminator cannot - // affect the actual validation result. - if (discriminator != null && !discriminator.getPropertyName().isEmpty()) { - JsonNode discriminatorPropertyNode = node.get(discriminator.getPropertyName()); - if (discriminatorPropertyNode != null) { - String discriminatorPropertyValue = discriminatorPropertyNode.asText(); - discriminatorPropertyValue = discriminator.getMapping().getOrDefault(discriminatorPropertyValue, - discriminatorPropertyValue); - JsonNode refNode = schema.getSchemaNode().get("$ref"); - if (refNode != null) { - String ref = refNode.asText(); - if (ref.equals(discriminatorPropertyValue) || ref.endsWith("/" + discriminatorPropertyValue)) { - executionContext.getCurrentDiscriminatorContext().markMatch(); - } - } - } else { - // See issue 436 where the condition was relaxed to not cause an assertion - // due to missing discriminator property value - // Also see BaseJsonValidator#checkDiscriminatorMatch - executionContext.getCurrentDiscriminatorContext().markIgnore(); - } + boolean discriminatorMatchFound = false; + DiscriminatorState discriminator = executionContext.getDiscriminatorMapping().get(instanceLocation); + JsonNode refNode = schema.getSchemaNode().get("$ref"); + if (discriminator != null && refNode != null) { + discriminatorMatchFound = discriminator.matches(refNode.asText()); } - DiscriminatorContext currentDiscriminatorContext = executionContext.getCurrentDiscriminatorContext(); - if (currentDiscriminatorContext.isDiscriminatorMatchFound() && childErrors == null) { - // Note that the match is set if found and not reset so checking if childErrors - // found is null triggers on the correct schema - childErrors = new ArrayList<>(); - childErrors.addAll(schemaErrors); - } else if (currentDiscriminatorContext.isDiscriminatorIgnore() - || !currentDiscriminatorContext.isActive()) { + if (discriminatorMatchFound) { + /* + * Note that discriminator cannot change the outcome of the evaluation but can + * be used to filter off any additional messages + * + * The discriminator will cause all messages other than the one with the // + * matching discriminator to be discarded. + */ + if (!subSchemaErrors.isEmpty()) { + /* + * This means that the discriminated value has errors and doesn't match so these + * errors are the only ones that will be reported *IF* there are no other + * schemas that successfully validate to meet the requirement of anyOf. + * + * If there are any successful schemas as per anyOf, all these errors will be + * discarded. + */ + discriminatorErrors = new ArrayList<>(subSchemaErrors); + allErrors = null; // This is no longer needed + } + } else { // This is the normal handling when discriminators aren't enabled - if (childErrors == null) { - childErrors = new ArrayList<>(); + if (discriminatorErrors == null) { + if (allErrors == null) { + allErrors = new ArrayList<>(); + } + allErrors.addAll(subSchemaErrors); } - childErrors.addAll(schemaErrors); } - } else if (!schemaErrors.isEmpty() && reportChildErrors(executionContext)) { + } else if (!subSchemaErrors.isEmpty() && reportChildErrors(executionContext)) { // This is the normal handling when discriminators aren't enabled - if (childErrors == null) { - childErrors = new ArrayList<>(); + if (allErrors == null) { + allErrors = new ArrayList<>(); } - childErrors.addAll(schemaErrors); + allErrors.addAll(subSchemaErrors); } index++; } - if (this.schemaContext.isDiscriminatorKeywordEnabled() - && (discriminator != null || executionContext.getCurrentDiscriminatorContext().isActive()) - && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorMatchFound() - && !executionContext.getCurrentDiscriminatorContext().isDiscriminatorIgnore()) { - addMessages = false; - existingErrors.add(error().instanceNode(node).instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .arguments( - "based on the provided discriminator. No alternative could be chosen based on the discriminator property") - .build()); + if (this.schemaContext.isDiscriminatorKeywordEnabled()) { + /* + * The only case where the discriminator can change the outcome of the result is + * if the discriminator value does not match an implicit or explicit mapping + */ + /* + * If the discriminator value does not match an implicit or explicit mapping, no + * schema can be determined and validation SHOULD fail. Mapping keys MUST be + * string values, but tooling MAY convert response values to strings for + * comparison. + * + * https://spec.openapis.org/oas/v3.1.2#examples-0 + */ + DiscriminatorState state = executionContext.getDiscriminatorMapping().get(instanceLocation); + if (state != null && !state.hasMatchedSchema() && state.hasDiscriminatingValue()) { + // The check for state.hasDiscriminatingValue is due to issue 988 + // Note that this is related to the DiscriminatorValidator by default not + // generating an assertion + // if the discriminatingValue is not set in the payload + existingErrors + .add(error().keyword("discriminator").instanceNode(node).instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) + .messageKey("discriminator.oneOf.no_match_found") + .arguments(state.getDiscriminatingValue()).build()); + } } } finally { // Restore flag executionContext.setFailFast(failFast); - - if (this.schemaContext.isDiscriminatorKeywordEnabled()) { - executionContext.leaveDiscriminatorContextImmediately(instanceLocation); - } } - // ensure there is always an "OneOf" error reported if number of valid schemas - // is not equal to 1. - // errors will only not be null in the discriminator case where no match is found - if (numberOfValidSchema != 1 && addMessages) { + if (numberOfValidSchema != 1) { + /* + * Ensure there is always an "oneOf" error reported if number of valid schemas + * is not equal to 1 + */ Error message = error().instanceNode(node).instanceLocation(instanceLocation) .messageKey(numberOfValidSchema > 1 ? "oneOf.indexes" : "oneOf") .locale(executionContext.getExecutionConfig().getLocale()) - .arguments(Integer.toString(numberOfValidSchema), numberOfValidSchema > 1 ? String.join(", ", indexes) : "").build(); + .arguments(Integer.toString(numberOfValidSchema), + numberOfValidSchema > 1 ? String.join(", ", indexes) : "") + .build(); existingErrors.add(message); - if (childErrors != null) { - existingErrors.addAll(childErrors); + + if (discriminatorErrors != null) { + existingErrors.addAll(discriminatorErrors); + } else if (allErrors != null) { + existingErrors.addAll(allErrors); } } executionContext.setErrors(existingErrors); @@ -212,7 +212,7 @@ protected boolean reportChildErrors(ExecutionContext executionContext) { // no point aggregating all the errors return !executionContext.getExecutionConfig().isFailFast(); } - + protected boolean canShortCircuit() { if (this.canShortCircuit == null) { boolean canShortCircuit = true; @@ -228,7 +228,8 @@ protected boolean canShortCircuit() { } @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, + boolean shouldValidateSchema) { if (shouldValidateSchema && node != null) { validate(executionContext, node, rootNode, instanceLocation, true); } else { @@ -240,7 +241,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root @Override public void preloadSchema() { - for (Schema schema: this.schemas) { + for (Schema schema : this.schemas) { schema.initializeValidators(); } canShortCircuit(); // cache the flag diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 3ef92ee9b..773da5783 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -69,4 +69,5 @@ writeOnly = is a write-only field, it cannot appear in the data contentEncoding = does not match content encoding {0} contentMediaType = is not a content media type discriminator.missing_discriminating_value = required property ''{0}'' for discriminator not found -discriminator.anyOf. \ No newline at end of file +discriminator.anyOf.no_match_found = no matching schema found for discriminator value ''{0}'' +discriminator.oneOf.no_match_found = no matching schema found for discriminator value ''{0}'' \ No newline at end of file diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 2a65d1dff..1c4857c08 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -770,7 +770,12 @@ void anyOfMissingDiscriminatorValue() { } /** - * See issue 436. + * Mapped to Bedroom with missing number of beds, however the discriminator is + * not supposed to change the result of anyOf and the data passes for "/anyOf/0" + * : {"$ref":"#/components/schemas/Room"}. + * + * This case is an example of the actual implementation for undefined behavior + * eg. multiple discriminators for an instance location. */ @Test void anyOfRedefinedDiscriminatorAndDiscriminatorWithMissingPropertyName() { diff --git a/src/test/resources/openapi3/discriminator.json b/src/test/resources/openapi3/discriminator.json index 6d55ece6c..f09912f8d 100644 --- a/src/test/resources/openapi3/discriminator.json +++ b/src/test/resources/openapi3/discriminator.json @@ -232,27 +232,27 @@ "valid": true }, { - "description": "mapped to Bedroom with missing number of beds", + "description": "mapped to Bedroom with missing number of beds but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "bed" }, - "valid": false + "valid": true }, { - "description": "mapped to KidsBedroom with missing number of beds", + "description": "mapped to KidsBedroom with missing number of beds but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "KidsBedRoom", "isTidy": true }, - "valid": false + "valid": true }, { - "description": "mapped to KidsBedroom with missing tidiness", + "description": "mapped to KidsBedroom with missing tidiness but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "KidsBedRoom", "numberOfBeds": 1 }, - "valid": false + "valid": true }, { "description": "mapped to GuestRoom with correct @type (mapping override on BedRoom)", @@ -264,12 +264,12 @@ "valid": true }, { - "description": "mapped to GuestRoom with incorrect @type (mapping override on BedRoom)", + "description": "mapped to GuestRoom with incorrect @type (mapping override on BedRoom) but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "GuestRoom", "guest": "Steve" }, - "valid": false + "valid": true }, { "description": "mapped to invalid Room", @@ -409,7 +409,7 @@ "valid": true }, { - "description": "schema with discriminator and recursion with invalid BedRoom", + "description": "schema with discriminator and recursion with invalid BedRoom but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "can be ignored - discriminator not in use on root schema", "numberOfBeds": 42, @@ -418,7 +418,7 @@ "floor": 1 } }, - "valid": false + "valid": true } ] }, @@ -506,7 +506,7 @@ "valid": true }, { - "description": "schema with discriminator and recursion with invalid BedRoom", + "description": "schema with discriminator and recursion with invalid BedRoom but #/components/schemas/Room matches and discriminator cannot change the validation result", "data": { "@type": "can be ignored - discriminator not in use on root schema", "numberOfBeds": 42, @@ -515,7 +515,7 @@ "floor": 1 } }, - "valid": false + "valid": true } ] }, From 18445ab651132ede045cb95830fddc3bc605ce6b Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Thu, 25 Sep 2025 17:33:29 +0800 Subject: [PATCH 48/74] Refactor SchemaLoader --- .../com/networknt/schema/SchemaRegistry.java | 215 +++++++++--------- .../schema/resource/AllowSchemaLoader.java | 49 ---- ...ader.java => ClasspathResourceLoader.java} | 12 +- .../schema/resource/DefaultSchemaLoader.java | 73 ------ .../schema/resource/DisallowSchemaLoader.java | 48 ---- ...hemaLoader.java => IriResourceLoader.java} | 16 +- ...hemaLoader.java => MapResourceLoader.java} | 22 +- ...maMapper.java => MapSchemaIdResolver.java} | 12 +- ...aMapper.java => MetaSchemaIdResolver.java} | 4 +- ...apper.java => PrefixSchemaIdResolver.java} | 8 +- ...{SchemaMapper.java => ResourceLoader.java} | 13 +- ...chemaLoaders.java => ResourceLoaders.java} | 32 +-- .../schema/resource/SchemaIdResolver.java | 33 +++ ...emaMappers.java => SchemaIdResolvers.java} | 32 +-- .../schema/resource/SchemaLoader.java | 211 ++++++++++++++++- .../schema/AbstractJsonSchemaTestSuite.java | 10 +- .../com/networknt/schema/CustomUriTest.java | 8 +- .../com/networknt/schema/ExampleTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 2 +- .../com/networknt/schema/Issue285Test.java | 2 +- .../com/networknt/schema/Issue475Test.java | 10 +- .../com/networknt/schema/Issue619Test.java | 8 +- .../com/networknt/schema/Issue665Test.java | 4 +- .../com/networknt/schema/Issue824Test.java | 4 +- .../com/networknt/schema/Issue928Test.java | 2 +- .../com/networknt/schema/Issue943Test.java | 2 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 8 +- .../schema/MetaSchemaValidationTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 8 +- .../com/networknt/schema/OutputUnitTest.java | 2 +- .../networknt/schema/RefValidatorTest.java | 8 +- .../java/com/networknt/schema/SampleTest.java | 6 +- .../networknt/schema/SchemaRegistryTest.java | 2 +- .../java/com/networknt/schema/SchemaTest.java | 4 +- .../UnevaluatedPropertiesValidatorTest.java | 2 +- .../com/networknt/schema/UriMappingTest.java | 32 +-- .../java/com/networknt/schema/UrnTest.java | 2 +- .../NetworkntTestSuiteTestCases.java | 25 +- .../networknt/schema/oas/OpenApi31Test.java | 2 +- .../resource/DisallowSchemaLoaderTest.java | 43 ---- ...erTest.java => IriResourceLoaderTest.java} | 14 +- ...erTest.java => MapResourceLoaderTest.java} | 8 +- ...Test.java => MapSchemaIdResolverTest.java} | 8 +- ...est.java => MetaSchemaIdResolverTest.java} | 10 +- ...aLoaderTest.java => SchemaLoaderTest.java} | 26 ++- .../schema/vocabulary/VocabularyTest.java | 12 +- 46 files changed, 543 insertions(+), 515 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java rename src/main/java/com/networknt/schema/resource/{ClasspathSchemaLoader.java => ClasspathResourceLoader.java} (83%) delete mode 100644 src/main/java/com/networknt/schema/resource/DefaultSchemaLoader.java delete mode 100644 src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java rename src/main/java/com/networknt/schema/resource/{UriSchemaLoader.java => IriResourceLoader.java} (86%) rename src/main/java/com/networknt/schema/resource/{MapSchemaLoader.java => MapResourceLoader.java} (63%) rename src/main/java/com/networknt/schema/resource/{MapSchemaMapper.java => MapSchemaIdResolver.java} (65%) rename src/main/java/com/networknt/schema/resource/{MetaSchemaMapper.java => MetaSchemaIdResolver.java} (91%) rename src/main/java/com/networknt/schema/resource/{PrefixSchemaMapper.java => PrefixSchemaIdResolver.java} (66%) rename src/main/java/com/networknt/schema/resource/{SchemaMapper.java => ResourceLoader.java} (66%) rename src/main/java/com/networknt/schema/resource/{SchemaLoaders.java => ResourceLoaders.java} (73%) create mode 100644 src/main/java/com/networknt/schema/resource/SchemaIdResolver.java rename src/main/java/com/networknt/schema/resource/{SchemaMappers.java => SchemaIdResolvers.java} (74%) delete mode 100644 src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java rename src/test/java/com/networknt/schema/resource/{UriSchemaLoaderTest.java => IriResourceLoaderTest.java} (76%) rename src/test/java/com/networknt/schema/resource/{MapSchemaLoaderTest.java => MapResourceLoaderTest.java} (81%) rename src/test/java/com/networknt/schema/resource/{MapSchemaMapperTest.java => MapSchemaIdResolverTest.java} (73%) rename src/test/java/com/networknt/schema/resource/{MetaSchemaMapperTest.java => MetaSchemaIdResolverTest.java} (80%) rename src/test/java/com/networknt/schema/resource/{AllowSchemaLoaderTest.java => SchemaLoaderTest.java} (65%) diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 51d0d5190..2fa25336c 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -23,11 +23,9 @@ import com.networknt.schema.dialect.DialectId; import com.networknt.schema.dialect.DialectRegistry; import com.networknt.schema.path.NodePath; -import com.networknt.schema.resource.DefaultSchemaLoader; +import com.networknt.schema.resource.ResourceLoaders; +import com.networknt.schema.resource.SchemaIdResolvers; import com.networknt.schema.resource.SchemaLoader; -import com.networknt.schema.resource.SchemaLoaders; -import com.networknt.schema.resource.SchemaMapper; -import com.networknt.schema.resource.SchemaMappers; import com.networknt.schema.serialization.BasicJsonNodeReader; import com.networknt.schema.serialization.JsonNodeReader; @@ -37,7 +35,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; @@ -61,8 +58,7 @@ public static class Builder { private String defaultDialectId; private DialectRegistry dialectRegistry = null; private JsonNodeReader jsonNodeReader = null; - private SchemaLoaders.Builder schemaLoadersBuilder = null; - private SchemaMappers.Builder schemaMappersBuilder = null; + private SchemaLoader schemaLoader = null; private boolean enableSchemaCache = true; private SchemaRegistryConfig schemaRegistryConfig = null; @@ -71,7 +67,8 @@ public static class Builder { *

* If set this takes precedence over the configured json mapper and yaml mapper. *

- * A location aware object reader can be created using JsonNodeReader.builder().locationAware().build(). + * A location aware object reader can be created using + * JsonNodeReader.builder().locationAware().build(). * * @param jsonNodeReader the object reader * @return the builder @@ -81,12 +78,12 @@ public Builder jsonNodeReader(JsonNodeReader jsonNodeReader) { return this; } - public Builder defaultDialectId(final String defaultDialectId) { + public Builder defaultDialectId(String defaultDialectId) { this.defaultDialectId = defaultDialectId; return this; } - public Builder dialectRegistry(final DialectRegistry dialectRegistry) { + public Builder dialectRegistry(DialectRegistry dialectRegistry) { this.dialectRegistry = dialectRegistry; return this; } @@ -95,20 +92,45 @@ public Builder enableSchemaCache(boolean enableSchemaCache) { this.enableSchemaCache = enableSchemaCache; return this; } - - public Builder schemaLoaders(Consumer schemaLoadersBuilderCustomizer) { - if (this.schemaLoadersBuilder == null) { - this.schemaLoadersBuilder = SchemaLoaders.builder(); + + public Builder schemaLoader(SchemaLoader schemaLoader) { + this.schemaLoader = schemaLoader; + return this; + } + + public Builder schemaLoader(Consumer customizer) { + SchemaLoader.Builder builder = null; + if (this.schemaLoader != null) { + builder = SchemaLoader.builder(this.schemaLoader); + } else { + builder = SchemaLoader.builder(); + } + customizer.accept(builder); + this.schemaLoader = builder.build(); + return this; + } + + public Builder resourceLoaders(Consumer customizer) { + SchemaLoader.Builder builder = null; + if (this.schemaLoader != null) { + builder = SchemaLoader.builder(this.schemaLoader); + } else { + builder = SchemaLoader.builder(); } - schemaLoadersBuilderCustomizer.accept(this.schemaLoadersBuilder); + customizer.accept(builder.getResourceLoadersBuilder()); + this.schemaLoader = builder.build(); return this; } - - public Builder schemaMappers(Consumer schemaMappersBuilderCustomizer) { - if (this.schemaMappersBuilder == null) { - this.schemaMappersBuilder = SchemaMappers.builder(); + + public Builder schemaIdResolvers(Consumer customizer) { + SchemaLoader.Builder builder = null; + if (this.schemaLoader != null) { + builder = SchemaLoader.builder(this.schemaLoader); + } else { + builder = SchemaLoader.builder(); } - schemaMappersBuilderCustomizer.accept(this.schemaMappersBuilder); + customizer.accept(builder.getSchemaIdResolversBuilder()); + this.schemaLoader = builder.build(); return this; } @@ -118,63 +140,39 @@ public Builder schemaRegistryConfig(SchemaRegistryConfig schemaRegistryConfig) { } public SchemaRegistry build() { - return new SchemaRegistry( - jsonNodeReader != null ? jsonNodeReader : BasicJsonNodeReader.getInstance(), - defaultDialectId, - schemaLoadersBuilder, - schemaMappersBuilder, - enableSchemaCache, - dialectRegistry, - schemaRegistryConfig - ); + return new SchemaRegistry(jsonNodeReader, defaultDialectId, schemaLoader, enableSchemaCache, + dialectRegistry, schemaRegistryConfig); } } private final JsonNodeReader jsonNodeReader; private final String defaultDialectId; - private final SchemaLoaders.Builder schemaLoadersBuilder; - private final SchemaMappers.Builder schemaMappersBuilder; private final SchemaLoader schemaLoader; private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); private final boolean enableSchemaCache; private final DialectRegistry dialectRegistry; private final SchemaRegistryConfig schemaRegistryConfig; - - private static final List DEFAULT_SCHEMA_LOADERS = SchemaLoaders.builder().build(); - private static final List DEFAULT_SCHEMA_MAPPERS = SchemaMappers.builder().build(); - - private SchemaRegistry( - JsonNodeReader jsonNodeReader, - String defaultDialectId, - SchemaLoaders.Builder schemaLoadersBuilder, - SchemaMappers.Builder schemaMappersBuilder, - boolean enableSchemaCache, - DialectRegistry dialectRegistry, - SchemaRegistryConfig schemaRegistryConfig) { + + private SchemaRegistry(JsonNodeReader jsonNodeReader, String defaultDialectId, SchemaLoader schemaLoader, + boolean enableSchemaCache, DialectRegistry dialectRegistry, SchemaRegistryConfig schemaRegistryConfig) { if (defaultDialectId == null || defaultDialectId.trim().isEmpty()) { throw new IllegalArgumentException("defaultDialectId must not be null or empty"); } - this.jsonNodeReader = jsonNodeReader; + this.jsonNodeReader = jsonNodeReader != null ? jsonNodeReader : BasicJsonNodeReader.getInstance(); this.defaultDialectId = defaultDialectId; - this.schemaLoadersBuilder = schemaLoadersBuilder; - this.schemaMappersBuilder = schemaMappersBuilder; - this.schemaLoader = new DefaultSchemaLoader( - schemaLoadersBuilder != null ? schemaLoadersBuilder.build() : DEFAULT_SCHEMA_LOADERS, - schemaMappersBuilder != null ? schemaMappersBuilder.build() : DEFAULT_SCHEMA_MAPPERS); + this.schemaLoader = schemaLoader != null ? schemaLoader : SchemaLoader.getDefault(); this.enableSchemaCache = enableSchemaCache; this.dialectRegistry = dialectRegistry != null ? dialectRegistry : new DefaultDialectRegistry(); - this.schemaRegistryConfig = schemaRegistryConfig != null ? schemaRegistryConfig : SchemaRegistryConfig.getInstance(); - } - - public SchemaLoader getSchemaLoader() { - return this.schemaLoader; + this.schemaRegistryConfig = schemaRegistryConfig != null ? schemaRegistryConfig + : SchemaRegistryConfig.getInstance(); } /** * Builder without keywords or formats. *

* Typically {@link #builder(SchemaRegistry)} or - * {@link #withDefaultDialect(SpecificationVersion)} or {@link #withDialect(Dialect)} would be used instead. + * {@link #withDefaultDialect(SpecificationVersion)} or + * {@link #withDialect(Dialect)} would be used instead. * * @return a builder instance without any keywords or formats - usually not what * one needs. @@ -184,8 +182,8 @@ public static Builder builder() { } /** - * Creates a new schema registry with a default schema dialect. The schema dialect - * will only be used if the input does not specify a $schema. + * Creates a new schema registry with a default schema dialect. The schema + * dialect will only be used if the input does not specify a $schema. * * @param specificationVersion the default dialect id corresponding to the * specification version used when the schema does @@ -197,8 +195,8 @@ public static SchemaRegistry withDefaultDialect(SpecificationVersion specificati } /** - * Creates a new schema registry with a default schema dialect. The schema dialect - * will only be used if the input does not specify a $schema. + * Creates a new schema registry with a default schema dialect. The schema + * dialect will only be used if the input does not specify a $schema. * * @param specificationVersion the default dialect id corresponding to the * specification version used when the schema does @@ -213,8 +211,8 @@ public static SchemaRegistry withDefaultDialect(SpecificationVersion specificati } /** - * Creates a new schema registry with a default schema dialect. The schema dialect - * will only be used if the input does not specify a $schema. + * Creates a new schema registry with a default schema dialect. The schema + * dialect will only be used if the input does not specify a $schema. * * @param dialectId the default dialect id used when the schema does not * specify the $schema keyword @@ -246,7 +244,7 @@ public static SchemaRegistry withDialect(Dialect dialect) { *

* Schemas that do not specify dialect using $schema will use the dialect. * - * @param dialect the dialect + * @param dialect the dialect * @param customizer to customize the registry * @return the schema registry */ @@ -269,27 +267,29 @@ public static SchemaRegistry withDialect(Dialect dialect, Consumer - * This is typically the same schema context unless the schema has a - * different $schema from the parent. + * This is typically the same schema context unless the schema has a different + * $schema from the parent. *

* If the schema does not define a $schema, the parent should be used. * * @param schemaContext the parent schema context - * @param schemaNode the schema node + * @param schemaNode the schema node * @return the schema context to use */ private SchemaContext withDialect(SchemaContext schemaContext, JsonNode schemaNode) { Dialect dialect = getDialect(schemaNode, schemaContext.getSchemaRegistryConfig()); if (dialect != null && !dialect.getId().equals(schemaContext.getDialect().getId())) { - return new SchemaContext(dialect, schemaContext.getSchemaRegistry(), - schemaContext.getSchemaReferences(), schemaContext.getSchemaResources(), - schemaContext.getDynamicAnchors()); + return new SchemaContext(dialect, schemaContext.getSchemaRegistry(), schemaContext.getSchemaReferences(), + schemaContext.getSchemaResources(), schemaContext.getDynamicAnchors()); } return schemaContext; } @@ -427,7 +428,7 @@ public Schema getSchema(final String schema) { * Using this is not recommended as there is potentially no base IRI for * resolving references to the absolute IRI. * - * @param schema the schema data as a string + * @param schema the schema data as a string * @param inputFormat input format * @return the schema */ @@ -461,7 +462,7 @@ public Schema getSchema(final InputStream schemaStream) { * resolving references to the absolute IRI. * * @param schemaStream the input stream with the schema data - * @param inputFormat input format + * @param inputFormat input format * @return the schema */ public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat) { @@ -477,7 +478,8 @@ public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat) /** * Gets the schema. * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. + * @param schemaUri the absolute IRI of the schema which can map to the + * retrieval IRI. * @return the schema */ public Schema getSchema(final SchemaLocation schemaUri) { @@ -489,7 +491,8 @@ public Schema getSchema(final SchemaLocation schemaUri) { /** * Loads the schema. * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. + * @param schemaUri the absolute IRI of the schema which can map to the + * retrieval IRI. * @return the schema */ public Schema loadSchema(final SchemaLocation schemaUri) { @@ -515,7 +518,8 @@ public Schema loadSchema(final SchemaLocation schemaUri) { } protected Schema getMappedSchema(final SchemaLocation schemaUri) { - try (InputStream inputStream = this.schemaLoader.getSchema(schemaUri.getAbsoluteIri()).getInputStream()) { + try (InputStream inputStream = this.schemaLoader.getSchemaResource(schemaUri.getAbsoluteIri()) + .getInputStream()) { if (inputStream == null) { throw new IOException("Cannot load schema at " + schemaUri); } @@ -528,11 +532,11 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { final Dialect dialect = getDialectOrDefault(schemaNode); NodePath evaluationPath = new NodePath(getSchemaRegistryConfig().getPathType()); - if (schemaUri.getFragment() == null - || schemaUri.getFragment().getNameCount() == 0) { + if (schemaUri.getFragment() == null || schemaUri.getFragment().getNameCount() == 0) { // Schema without fragment SchemaContext schemaContext = new SchemaContext(dialect, this); - return doCreate(schemaContext, schemaUri, evaluationPath, schemaNode, null, true /* retrieved via id, resolving will not change anything */); + return doCreate(schemaContext, schemaUri, evaluationPath, schemaNode, null, + true /* retrieved via id, resolving will not change anything */); } else { // Schema with fragment pointing to sub schema final SchemaContext schemaContext = createSchemaContext(schemaNode); @@ -542,7 +546,8 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { } } catch (IOException e) { logger.error("Failed to load json schema from {}", schemaUri.getAbsoluteIri(), e); - SchemaException exception = new SchemaException("Failed to load json schema from "+schemaUri.getAbsoluteIri()); + SchemaException exception = new SchemaException( + "Failed to load json schema from " + schemaUri.getAbsoluteIri()); exception.initCause(e); throw exception; } @@ -551,7 +556,8 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { /** * Gets the schema. * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. + * @param schemaUri the absolute IRI of the schema which can map to the + * retrieval IRI. * @return the schema */ public Schema getSchema(final URI schemaUri) { @@ -561,8 +567,9 @@ public Schema getSchema(final URI schemaUri) { /** * Gets the schema. * - * @param schemaUri the absolute IRI of the schema which can map to the retrieval IRI. - * @param jsonNode the node + * @param schemaUri the absolute IRI of the schema which can map to the + * retrieval IRI. + * @param jsonNode the node * @return the schema */ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { @@ -573,21 +580,21 @@ public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { * Gets the schema. * * @param schemaUri the base absolute IRI - * @param jsonNode the node + * @param jsonNode the node * @return the schema */ public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { return newSchema(schemaUri, jsonNode); } - + /** * Gets the schema. *

* Using this is not recommended as there is potentially no base IRI for * resolving references to the absolute IRI. *

- * Prefer {@link #getSchema(SchemaLocation, JsonNode)} - * instead to ensure the base IRI if no id is present. + * Prefer {@link #getSchema(SchemaLocation, JsonNode)} instead to ensure the + * base IRI if no id is present. * * @param jsonNode the node * @return the schema @@ -629,7 +636,7 @@ private boolean isYaml(final SchemaLocation schemaUri) { static protected String normalizeDialectId(String id) { boolean found = false; for (SpecificationVersion flag : SpecificationVersion.values()) { - if(flag.getDialectId().equals(id)) { + if (flag.getDialectId().equals(id)) { found = true; break; } @@ -647,7 +654,7 @@ static protected String normalizeDialectId(String id) { id = DialectId.DRAFT_4; } else if (id.contains("/draft-06/")) { id = DialectId.DRAFT_6; - } + } } } return id; diff --git a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java deleted file mode 100644 index 3580771de..000000000 --- a/src/main/java/com/networknt/schema/resource/AllowSchemaLoader.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema.resource; - -import java.util.function.Predicate; - -import com.networknt.schema.AbsoluteIri; -import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.Error; - -/** - * {@link SchemaLoader} that allows loading external resources. - */ -public class AllowSchemaLoader implements SchemaLoader { - private final Predicate allowed; - - /** - * Constructor. - * - * @param allowed the predicate to determine which external resource is allowed - * to be loaded - */ - public AllowSchemaLoader(Predicate allowed) { - this.allowed = allowed; - } - - @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { - if (this.allowed.test(absoluteIri)) { - // Allow to delegate to the next schema loader - return null; - } - throw new InvalidSchemaException(Error.builder() - .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); - } -} diff --git a/src/main/java/com/networknt/schema/resource/ClasspathSchemaLoader.java b/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java similarity index 83% rename from src/main/java/com/networknt/schema/resource/ClasspathSchemaLoader.java rename to src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java index 9cb41b94c..4e7b305f1 100644 --- a/src/main/java/com/networknt/schema/resource/ClasspathSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java @@ -24,14 +24,14 @@ /** * Loads from classpath. */ -public class ClasspathSchemaLoader implements SchemaLoader { +public class ClasspathResourceLoader implements ResourceLoader { private final Supplier classLoaderSource; /** * Constructor. */ - public ClasspathSchemaLoader() { - this(ClasspathSchemaLoader::getClassLoader); + public ClasspathResourceLoader() { + this(ClasspathResourceLoader::getClassLoader); } /** @@ -39,12 +39,12 @@ public ClasspathSchemaLoader() { * * @param classLoaderSource the class loader source */ - public ClasspathSchemaLoader(Supplier classLoaderSource) { + public ClasspathResourceLoader(Supplier classLoaderSource) { this.classLoaderSource = classLoaderSource; } @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { String iri = absoluteIri != null ? absoluteIri.toString() : ""; String name = null; if (iri.startsWith("classpath:")) { @@ -75,7 +75,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { protected static ClassLoader getClassLoader() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { - classLoader = SchemaLoader.class.getClassLoader(); + classLoader = ResourceLoader.class.getClassLoader(); } return classLoader; } diff --git a/src/main/java/com/networknt/schema/resource/DefaultSchemaLoader.java b/src/main/java/com/networknt/schema/resource/DefaultSchemaLoader.java deleted file mode 100644 index a090719b8..000000000 --- a/src/main/java/com/networknt/schema/resource/DefaultSchemaLoader.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema.resource; - -import java.util.ArrayList; -import java.util.List; - -import com.networknt.schema.AbsoluteIri; - -/** - * Default {@link SchemaLoader}. - */ -public class DefaultSchemaLoader implements SchemaLoader { - private static final List DEFAULT; - private static final MetaSchemaMapper META_SCHEMA_MAPPER = new MetaSchemaMapper(); - - static { - List result = new ArrayList<>(); - result.add(new ClasspathSchemaLoader()); - result.add(new UriSchemaLoader()); - DEFAULT = result; - } - - private final List schemaLoaders; - private final List schemaMappers; - - public DefaultSchemaLoader(List schemaLoaders, List schemaMappers) { - this.schemaLoaders = schemaLoaders; - this.schemaMappers = schemaMappers; - } - - @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { - AbsoluteIri mappedResult = absoluteIri; - for (SchemaMapper mapper : schemaMappers) { - AbsoluteIri mapped = mapper.map(mappedResult); - if (mapped != null) { - mappedResult = mapped; - } - } - AbsoluteIri mapped = META_SCHEMA_MAPPER.map(absoluteIri); - if (mapped != null) { - mappedResult = mapped; - } - for (SchemaLoader loader : schemaLoaders) { - InputStreamSource result = loader.getSchema(mappedResult); - if (result != null) { - return result; - } - } - for (SchemaLoader loader : DEFAULT) { - InputStreamSource result = loader.getSchema(mappedResult); - if (result != null) { - return result; - } - } - return null; - } - -} diff --git a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java b/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java deleted file mode 100644 index b07118192..000000000 --- a/src/main/java/com/networknt/schema/resource/DisallowSchemaLoader.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema.resource; - -import com.networknt.schema.AbsoluteIri; -import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.Error; - -/** - * {@link SchemaLoader} that disallows loading external resources. - */ -public class DisallowSchemaLoader implements SchemaLoader { - private static final DisallowSchemaLoader INSTANCE = new DisallowSchemaLoader(); - - /** - * Disallows loading schemas from external resources. - * - * @return the disallow schema loader - */ - public static DisallowSchemaLoader getInstance() { - return INSTANCE; - } - - /** - * Constructor. - */ - private DisallowSchemaLoader() { - } - - @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { - throw new InvalidSchemaException(Error.builder() - .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); - } -} diff --git a/src/main/java/com/networknt/schema/resource/UriSchemaLoader.java b/src/main/java/com/networknt/schema/resource/IriResourceLoader.java similarity index 86% rename from src/main/java/com/networknt/schema/resource/UriSchemaLoader.java rename to src/main/java/com/networknt/schema/resource/IriResourceLoader.java index 082535357..456c61dfe 100644 --- a/src/main/java/com/networknt/schema/resource/UriSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/IriResourceLoader.java @@ -27,11 +27,19 @@ import com.networknt.schema.utils.AbsoluteIris; /** - * Loads from uri. + * Loads from iri. */ -public class UriSchemaLoader implements SchemaLoader { +public class IriResourceLoader implements ResourceLoader { + private static class Holder { + private static final IriResourceLoader INSTANCE = new IriResourceLoader(); + } + + public static IriResourceLoader getInstance() { + return Holder.INSTANCE; + } + @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { URI uri = toURI(absoluteIri); URL url = toURL(uri); return () -> { @@ -97,7 +105,7 @@ protected InputStream openConnectionCheckRedirects(URLConnection c) throws IOExc // and should be limited to 5 redirections at most. if (target == null || !(target.getProtocol().equals("http") || target.getProtocol().equals("https")) || redirects >= 5) { - throw new SecurityException("illegal URL redirect"); + throw new SecurityException("Maximum number of redirects exceeded"); } redir = true; c = target.openConnection(); diff --git a/src/main/java/com/networknt/schema/resource/MapSchemaLoader.java b/src/main/java/com/networknt/schema/resource/MapResourceLoader.java similarity index 63% rename from src/main/java/com/networknt/schema/resource/MapSchemaLoader.java rename to src/main/java/com/networknt/schema/resource/MapResourceLoader.java index 6d4b32f53..24912f3f9 100644 --- a/src/main/java/com/networknt/schema/resource/MapSchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/MapResourceLoader.java @@ -8,42 +8,42 @@ import com.networknt.schema.AbsoluteIri; /** - * Map implementation of {@link SchemaLoader}. + * Map implementation of {@link ResourceLoader}. */ -public class MapSchemaLoader implements SchemaLoader { +public class MapResourceLoader implements ResourceLoader { private final Function mappings; /** - * Sets the schema data by absolute IRI. + * Sets the resource data by absolute IRI. * * @param mappings the mappings */ - public MapSchemaLoader(Map mappings) { + public MapResourceLoader(Map mappings) { this(mappings::get); } /** - * Sets the schema data by absolute IRI function. + * Sets the resource data by absolute IRI function. * * @param mappings the mappings */ - public MapSchemaLoader(Function mappings) { + public MapResourceLoader(Function mappings) { this.mappings = mappings; } /** - * Sets the schema data by using two mapping functions. + * Sets the resource data by using two mapping functions. *

* Firstly to map the IRI to an object. If the object is null no mapping is * performed. *

- * Next to map the object to the schema data. + * Next to map the object to the resource data. * * @param the type of the object * @param mapIriToObject the mapping of IRI to object - * @param mapObjectToData the mappingof object to schema data + * @param mapObjectToData the mappingof object to resource data */ - public MapSchemaLoader(Function mapIriToObject, Function mapObjectToData) { + public MapResourceLoader(Function mapIriToObject, Function mapObjectToData) { this.mappings = iri -> { T result = mapIriToObject.apply(iri); if (result != null) { @@ -54,7 +54,7 @@ public MapSchemaLoader(Function mapIriToObject, Function mappings; - public MapSchemaMapper(Map mappings) { + public MapSchemaIdResolver(Map mappings) { this(mappings::get); } - public MapSchemaMapper(Function mappings) { + public MapSchemaIdResolver(Function mappings) { this.mappings = mappings; } @@ -26,7 +26,7 @@ public MapSchemaMapper(Function mappings) { * @param test the predicate * @param mappings the mapping */ - public MapSchemaMapper(Predicate test, Function mappings) { + public MapSchemaIdResolver(Predicate test, Function mappings) { this.mappings = iri -> { if (test.test(iri)) { return mappings.apply(iri); @@ -36,7 +36,7 @@ public MapSchemaMapper(Predicate test, Function mappings } @Override - public AbsoluteIri map(AbsoluteIri absoluteIRI) { + public AbsoluteIri resolve(AbsoluteIri absoluteIRI) { String mapped = this.mappings.apply(absoluteIRI.toString()); if (mapped != null) { return AbsoluteIri.of(mapped); diff --git a/src/main/java/com/networknt/schema/resource/MetaSchemaMapper.java b/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java similarity index 91% rename from src/main/java/com/networknt/schema/resource/MetaSchemaMapper.java rename to src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java index 7881eced6..3ca0f23cf 100644 --- a/src/main/java/com/networknt/schema/resource/MetaSchemaMapper.java +++ b/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java @@ -20,14 +20,14 @@ /** * Maps the JSON Schema meta schema to the class path location. */ -public class MetaSchemaMapper implements SchemaMapper { +public class MetaSchemaIdResolver implements SchemaIdResolver { private static final char ANCHOR = '#'; private static final String CLASSPATH_PREFIX = "classpath:"; private static final String HTTP_JSON_SCHEMA_ORG_PREFIX = "http://json-schema.org/"; private static final String HTTPS_JSON_SCHEMA_ORG_PREFIX = "https://json-schema.org/"; @Override - public AbsoluteIri map(AbsoluteIri absoluteIRI) { + public AbsoluteIri resolve(AbsoluteIri absoluteIRI) { String absoluteIRIString = absoluteIRI != null ? absoluteIRI.toString() : null; if (absoluteIRIString != null) { if (absoluteIRIString.startsWith(HTTPS_JSON_SCHEMA_ORG_PREFIX)) { diff --git a/src/main/java/com/networknt/schema/resource/PrefixSchemaMapper.java b/src/main/java/com/networknt/schema/resource/PrefixSchemaIdResolver.java similarity index 66% rename from src/main/java/com/networknt/schema/resource/PrefixSchemaMapper.java rename to src/main/java/com/networknt/schema/resource/PrefixSchemaIdResolver.java index 46f4f805b..13caa7664 100644 --- a/src/main/java/com/networknt/schema/resource/PrefixSchemaMapper.java +++ b/src/main/java/com/networknt/schema/resource/PrefixSchemaIdResolver.java @@ -3,19 +3,19 @@ import com.networknt.schema.AbsoluteIri; /** - * Prefix implementation of {@link SchemaMapper}. + * Prefix implementation of {@link SchemaIdResolver}. */ -public class PrefixSchemaMapper implements SchemaMapper { +public class PrefixSchemaIdResolver implements SchemaIdResolver { private final String source; private final String replacement; - public PrefixSchemaMapper(String source, String replacement) { + public PrefixSchemaIdResolver(String source, String replacement) { this.source = source; this.replacement = replacement; } @Override - public AbsoluteIri map(AbsoluteIri absoluteIRI) { + public AbsoluteIri resolve(AbsoluteIri absoluteIRI) { String absoluteIRIString = absoluteIRI != null ? absoluteIRI.toString() : null; if (absoluteIRIString != null && absoluteIRIString.startsWith(source)) { return AbsoluteIri.of(replacement + absoluteIRIString.substring(source.length())); diff --git a/src/main/java/com/networknt/schema/resource/SchemaMapper.java b/src/main/java/com/networknt/schema/resource/ResourceLoader.java similarity index 66% rename from src/main/java/com/networknt/schema/resource/SchemaMapper.java rename to src/main/java/com/networknt/schema/resource/ResourceLoader.java index be6813a16..aff14b9f5 100644 --- a/src/main/java/com/networknt/schema/resource/SchemaMapper.java +++ b/src/main/java/com/networknt/schema/resource/ResourceLoader.java @@ -18,16 +18,15 @@ import com.networknt.schema.AbsoluteIri; /** - * Schema Mapper used to map an ID indicated by an absolute IRI to a retrieval - * IRI. + * Resource Loader used to load data using a retrieval IRI. */ @FunctionalInterface -public interface SchemaMapper { +public interface ResourceLoader { /** - * Maps an ID indicated by an absolute IRI to a retrieval IRI. + * Loads data given the retrieval IRI. * - * @param absoluteIRI the ID - * @return the retrieval IRI or null if this mapper doesn't support the mapping + * @param location the retrieval IRI + * @return the input stream source */ - AbsoluteIri map(AbsoluteIri absoluteIRI); + InputStreamSource getResource(AbsoluteIri location); } diff --git a/src/main/java/com/networknt/schema/resource/SchemaLoaders.java b/src/main/java/com/networknt/schema/resource/ResourceLoaders.java similarity index 73% rename from src/main/java/com/networknt/schema/resource/SchemaLoaders.java rename to src/main/java/com/networknt/schema/resource/ResourceLoaders.java index 8a18a8871..c53036e59 100644 --- a/src/main/java/com/networknt/schema/resource/SchemaLoaders.java +++ b/src/main/java/com/networknt/schema/resource/ResourceLoaders.java @@ -23,20 +23,20 @@ import java.util.function.Function; /** - * Schema Loaders used to load a schema given the retrieval IRI. + * Schema Loaders used to load a resource given the retrieval IRI. */ -public class SchemaLoaders extends ArrayList { +public class ResourceLoaders extends ArrayList { private static final long serialVersionUID = 1L; - public SchemaLoaders() { + public ResourceLoaders() { super(); } - public SchemaLoaders(Collection c) { + public ResourceLoaders(Collection c) { super(c); } - public SchemaLoaders(int initialCapacity) { + public ResourceLoaders(int initialCapacity) { super(initialCapacity); } @@ -45,7 +45,7 @@ public static Builder builder() { } public static class Builder { - private final SchemaLoaders values = new SchemaLoaders(); + private final ResourceLoaders values = new ResourceLoaders(); public Builder() { } @@ -67,7 +67,7 @@ public Builder with(Builder builder) { * @param customizer the customizer * @return the builder */ - public Builder values(Consumer> customizer) { + public Builder values(Consumer> customizer) { customizer.accept(this.values); return this; } @@ -78,7 +78,7 @@ public Builder values(Consumer> customizer) { * @param schemaLoader the schema loader * @return the builder */ - public Builder add(SchemaLoader schemaLoader) { + public Builder add(ResourceLoader schemaLoader) { this.values.add(schemaLoader); return this; } @@ -86,11 +86,11 @@ public Builder add(SchemaLoader schemaLoader) { /** * Sets the schema data by absolute IRI. * - * @param schemas the map of IRI to schema data + * @param resources the map of IRI to schema data * @return the builder */ - public Builder schemas(Map schemas) { - this.values.add(new MapSchemaLoader(schemas)); + public Builder resources(Map resources) { + this.values.add(new MapResourceLoader(resources)); return this; } @@ -100,8 +100,8 @@ public Builder schemas(Map schemas) { * @param schemas the function that returns schema data given IRI * @return the builder */ - public Builder schemas(Function schemas) { - this.values.add(new MapSchemaLoader(schemas)); + public Builder resources(Function schemas) { + this.values.add(new MapResourceLoader(schemas)); return this; } @@ -119,16 +119,16 @@ public Builder schemas(Function schemas) { * @return the builder */ public Builder schemas(Function mapIriToObject, Function mapObjectToData) { - this.values.add(new MapSchemaLoader(mapIriToObject, mapObjectToData)); + this.values.add(new MapResourceLoader(mapIriToObject, mapObjectToData)); return this; } /** - * Builds a {@link SchemaLoaders}. + * Builds a {@link ResourceLoaders}. * * @return the schema loaders */ - public SchemaLoaders build() { + public ResourceLoaders build() { return values; } } diff --git a/src/main/java/com/networknt/schema/resource/SchemaIdResolver.java b/src/main/java/com/networknt/schema/resource/SchemaIdResolver.java new file mode 100644 index 000000000..f5b307563 --- /dev/null +++ b/src/main/java/com/networknt/schema/resource/SchemaIdResolver.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema.resource; + +import com.networknt.schema.AbsoluteIri; + +/** + * Schema ID resolver used to map the schema $id indicated by an absolute IRI to a retrieval + * IRI. + */ +@FunctionalInterface +public interface SchemaIdResolver { + /** + * Resolves a schema $id indicated by an absolute IRI to a retrieval IRI. + * + * @param schemaId the $id of the schema + * @return the retrieval IRI or null if this resolver doesn't support the mapping + */ + AbsoluteIri resolve(AbsoluteIri schemaId); +} diff --git a/src/main/java/com/networknt/schema/resource/SchemaMappers.java b/src/main/java/com/networknt/schema/resource/SchemaIdResolvers.java similarity index 74% rename from src/main/java/com/networknt/schema/resource/SchemaMappers.java rename to src/main/java/com/networknt/schema/resource/SchemaIdResolvers.java index 9757c6837..f56ad8991 100644 --- a/src/main/java/com/networknt/schema/resource/SchemaMappers.java +++ b/src/main/java/com/networknt/schema/resource/SchemaIdResolvers.java @@ -27,18 +27,18 @@ * Schema Mappers used to map an ID indicated by an absolute IRI to a retrieval * IRI. */ -public class SchemaMappers extends ArrayList { +public class SchemaIdResolvers extends ArrayList { private static final long serialVersionUID = 1L; - public SchemaMappers() { + public SchemaIdResolvers() { super(); } - public SchemaMappers(Collection c) { + public SchemaIdResolvers(Collection c) { super(c); } - public SchemaMappers(int initialCapacity) { + public SchemaIdResolvers(int initialCapacity) { super(initialCapacity); } @@ -47,7 +47,7 @@ public static Builder builder() { } public static class Builder { - private final SchemaMappers values = new SchemaMappers(); + private final SchemaIdResolvers values = new SchemaIdResolvers(); public Builder() { } @@ -64,12 +64,12 @@ public Builder with(Builder builder) { } /** - * Customize the schema mappers. + * Customize the schema id resolvers. * * @param customizer the customizer * @return the builder */ - public Builder values(Consumer> customizer) { + public Builder values(Consumer> customizer) { customizer.accept(this.values); return this; } @@ -77,11 +77,11 @@ public Builder values(Consumer> customizer) { /** * Adds a schema mapper. * - * @param schemaMapper the schema mapper + * @param schemaIdResolver the schema mapper * @return the builder */ - public Builder add(SchemaMapper schemaMapper) { - this.values.add(schemaMapper); + public Builder add(SchemaIdResolver schemaIdResolver) { + this.values.add(schemaIdResolver); return this; } @@ -93,7 +93,7 @@ public Builder add(SchemaMapper schemaMapper) { * @return the builder */ public Builder mapPrefix(String source, String replacement) { - this.values.add(new PrefixSchemaMapper(source, replacement)); + this.values.add(new PrefixSchemaIdResolver(source, replacement)); return this; } @@ -104,7 +104,7 @@ public Builder mapPrefix(String source, String replacement) { * @return the builder */ public Builder mappings(Map mappings) { - this.values.add(new MapSchemaMapper(mappings)); + this.values.add(new MapSchemaIdResolver(mappings)); return this; } @@ -115,7 +115,7 @@ public Builder mappings(Map mappings) { * @return the builder */ public Builder mappings(Function mappings) { - this.values.add(new MapSchemaMapper(mappings)); + this.values.add(new MapSchemaIdResolver(mappings)); return this; } @@ -127,16 +127,16 @@ public Builder mappings(Function mappings) { * @return the builder */ public Builder mappings(Predicate test, Function mappings) { - this.values.add(new MapSchemaMapper(test, mappings)); + this.values.add(new MapSchemaIdResolver(test, mappings)); return this; } /** - * Builds a {@link SchemaMappers} + * Builds a {@link SchemaIdResolvers} * * @return the schema mappers */ - public SchemaMappers build() { + public SchemaIdResolvers build() { return values; } } diff --git a/src/main/java/com/networknt/schema/resource/SchemaLoader.java b/src/main/java/com/networknt/schema/resource/SchemaLoader.java index 86aa0f748..481e1a399 100644 --- a/src/main/java/com/networknt/schema/resource/SchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/SchemaLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 the original author or authors. + * Copyright (c) 2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,213 @@ */ package com.networknt.schema.resource; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Predicate; + import com.networknt.schema.AbsoluteIri; +import com.networknt.schema.Error; +import com.networknt.schema.InvalidSchemaException; /** - * Schema Loader used to load a schema given the retrieval IRI. + * Schema Loader used to load the schema resource from the schema $id. + *

+ * By default the SchemaLoader does not fetch remote resources. This must be + * explicitly configured using {@link Builder#fetchRemoteResources}. */ -@FunctionalInterface -public interface SchemaLoader { +public class SchemaLoader { + private static final MetaSchemaIdResolver META_SCHEMA_ID_RESOLVER = new MetaSchemaIdResolver(); + private static final ClasspathResourceLoader CLASSPATH_RESOURCE_LOADER = new ClasspathResourceLoader(); + + private static class DefaultHolder { + private static final SchemaLoader DEFAULT = new SchemaLoader(Collections.emptyList(), Collections.emptyList()); + } + + private static class RemoteFetcher { + private static final SchemaLoader REMOTE_FETCHER = SchemaLoader.builder().fetchRemoteResources().build(); + } + + /** + * Gets the default schema loader. + *

+ * By default this does not fetch remote resources and must be explicitly + * configured to do so. + * + * @return the default schema loader + */ + public static SchemaLoader getDefault() { + return DefaultHolder.DEFAULT; + } + /** - * Loads a schema given the retrieval IRI. + * Gets the schema loader the does remote fetching. * - * @param absoluteIri the retrieval IRI - * @return the input stream source + * @return the schema loader that does remote fetching */ - InputStreamSource getSchema(AbsoluteIri absoluteIri); + public static SchemaLoader getRemoteFetcher() { + return RemoteFetcher.REMOTE_FETCHER; + } + + protected final List resourceLoaders; + protected final List schemaIdResolvers; + protected final Predicate allow; + protected final Predicate block; + + public SchemaLoader(ResourceLoader resourceLoader) { + this(Collections.emptyList(), Collections.singletonList(resourceLoader)); + } + + public SchemaLoader(SchemaIdResolver schemaIdResolver, ResourceLoader resourceLoader) { + this(Collections.singletonList(schemaIdResolver), Collections.singletonList(resourceLoader)); + } + + public SchemaLoader(List schemaIdResolvers, List resourceLoaders) { + this(schemaIdResolvers, resourceLoaders, null, null); + } + + public SchemaLoader(List schemaIdResolvers, List resourceLoaders, + Predicate allow, Predicate block) { + this.schemaIdResolvers = schemaIdResolvers; + this.resourceLoaders = resourceLoaders; + this.allow = allow; + this.block = block; + } + + public SchemaLoader(SchemaLoader copy) { + this(new ArrayList<>(copy.schemaIdResolvers), new ArrayList<>(copy.resourceLoaders)); + } + + public InputStreamSource getSchemaResource(AbsoluteIri absoluteIri) { + if (this.allow != null) { + if (!this.allow.test(absoluteIri)) { + throw new InvalidSchemaException(Error.builder() + .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); + } + } + if (this.block != null) { + if (this.block.test(absoluteIri)) { + throw new InvalidSchemaException(Error.builder() + .message("Schema from ''{0}'' is not allowed to be loaded.").arguments(absoluteIri).build()); + } + } + AbsoluteIri mappedResult = absoluteIri; + for (SchemaIdResolver mapper : schemaIdResolvers) { + AbsoluteIri mapped = mapper.resolve(mappedResult); + if (mapped != null) { + mappedResult = mapped; + } + } + AbsoluteIri mapped = resolveMetaSchemaId(absoluteIri); + if (mapped != null) { + mappedResult = mapped; + } + InputStreamSource result = getClasspathResource(mappedResult); + if (result != null) { + return result; + } + for (ResourceLoader loader : resourceLoaders) { + result = loader.getResource(mappedResult); + if (result != null) { + return result; + } + } + return null; + } + + protected AbsoluteIri resolveMetaSchemaId(AbsoluteIri absoluteIri) { + return META_SCHEMA_ID_RESOLVER.resolve(absoluteIri); + } + + protected InputStreamSource getClasspathResource(AbsoluteIri absoluteIri) { + return CLASSPATH_RESOURCE_LOADER.getResource(absoluteIri); + } + + public List getResourceLoaders() { + return this.resourceLoaders; + } + + public List getSchemaIdResolvers() { + return this.schemaIdResolvers; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(SchemaLoader copy) { + Builder builder = new Builder(); + if (!copy.getResourceLoaders().isEmpty()) { + builder.resourceLoaders(r -> r.values(c -> c.addAll(copy.resourceLoaders))); + } + if (!copy.getSchemaIdResolvers().isEmpty()) { + builder.schemaIdResolvers(r -> r.values(c -> c.addAll(copy.schemaIdResolvers))); + } + builder.allow(copy.allow); + builder.block(copy.block); + return builder; + } + + public static class Builder { + private SchemaIdResolvers.Builder schemaIdResolversBuilder = new SchemaIdResolvers.Builder(); + private ResourceLoaders.Builder resourceLoadersBuilder = new ResourceLoaders.Builder(); + private Predicate allow = null; + private Predicate block = null; + private boolean fetchRemoteResources = false; + + public Builder() { + } + + public Builder schemaIdResolvers(Consumer customizer) { + customizer.accept(schemaIdResolversBuilder); + return this; + } + + public Builder resourceLoaders(Consumer customizer) { + customizer.accept(resourceLoadersBuilder); + return this; + } + + public Builder allow(Predicate allow) { + this.allow = allow; + return this; + } + + public Builder block(Predicate block) { + this.block = block; + return this; + } + + public Builder fetchRemoteResources(boolean fetch) { + this.fetchRemoteResources = fetch; + return this; + } + + /** + * Adds the IriResourceLoader to allow fetching of remote resources. + * + * @return the builder + */ + public Builder fetchRemoteResources() { + return fetchRemoteResources(true); + } + + public SchemaIdResolvers.Builder getSchemaIdResolversBuilder() { + return schemaIdResolversBuilder; + } + + public ResourceLoaders.Builder getResourceLoadersBuilder() { + return resourceLoadersBuilder; + } + + public SchemaLoader build() { + if (this.fetchRemoteResources) { + // This ensures the IriResourceLoader is added at the end + this.resourceLoadersBuilder.add(IriResourceLoader.getInstance()); + } + return new SchemaLoader(schemaIdResolversBuilder.build(), resourceLoadersBuilder.build(), this.allow, + this.block); + } + } } diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 34bdb3456..9ee1b1987 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -19,7 +19,7 @@ import com.networknt.schema.regex.JDKRegularExpressionFactory; import com.networknt.schema.regex.JoniRegularExpressionFactory; import com.networknt.schema.resource.InputStreamSource; -import com.networknt.schema.resource.SchemaLoader; +import com.networknt.schema.resource.ResourceLoader; import com.networknt.schema.suite.TestCase; import com.networknt.schema.suite.TestSource; import com.networknt.schema.suite.TestSpec; @@ -209,9 +209,9 @@ private DynamicNode buildContainer(SpecificationVersion defaultVersion, TestCase private SchemaRegistry buildSchemaRegistry(SpecificationVersion defaultVersion, TestCase testCase, SchemaRegistryConfig schemaRegistryConfig) { if (testCase.isDisabled()) return null; - SchemaLoader schemaLoader = new SchemaLoader() { + ResourceLoader schemaLoader = new ResourceLoader() { @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { String iri = absoluteIri.toString(); if (iri.startsWith("http://localhost:1234")) { return () -> { @@ -230,10 +230,10 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { SchemaRegistry base = SchemaRegistry.withDefaultDialect(specVersion); return SchemaRegistry .builder(base) - .schemaMappers(schemaMappers -> schemaMappers + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers .mapPrefix("https://", "http://") .mapPrefix("http://json-schema.org", "resource:")) - .schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)) + .resourceLoaders(resourceLoaders -> resourceLoaders.add(schemaLoader)) .schemaRegistryConfig(schemaRegistryConfig) .build(); } diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index 0bf01c189..c5790c077 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.resource.InputStreamSource; -import com.networknt.schema.resource.SchemaLoader; +import com.networknt.schema.resource.ResourceLoader; import org.junit.jupiter.api.Test; @@ -32,14 +32,14 @@ void customUri() throws Exception { private SchemaRegistry buildJsonSchemaFactory() { return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) - .schemaLoaders(schemaLoaders -> schemaLoaders.add(new CustomUriFetcher())).build(); + .resourceLoaders(resourceLoaders -> resourceLoaders.add(new CustomUriFetcher())).build(); } - private static class CustomUriFetcher implements SchemaLoader { + private static class CustomUriFetcher implements ResourceLoader { private static final String SCHEMA = "{\"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\"$id\":\"custom:date\",\"type\":\"string\",\"format\":\"date\"}"; @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { return () -> new ByteArrayInputStream(SCHEMA.getBytes(StandardCharsets.UTF_8)); } } diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index b7a79e80d..c12d7014a 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -28,7 +28,7 @@ class ExampleTest { void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> - builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) + builder.schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://www.example.org/", "classpath:schema/")) ); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of("https://www.example.org/example-main.json")); String input = "{\r\n" diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index f2196352a..79cf071e0 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -86,7 +86,7 @@ void unknownFormatAssertionsVocab() { Schema schema = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder - .schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) + .resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections.singletonMap("https://www.example.com/format-assertion/schema", metaSchemaData)))) .getSchema(schemaData); List messages = schema.validate("\"hello\"", InputFormat.JSON); assertEquals(1, messages.size()); diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index 06d5ec873..ca2a87ce8 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -14,7 +14,7 @@ class Issue285Test { private final ObjectMapper mapper = new ObjectMapper(); private final SchemaRegistry schemaFactory = SchemaRegistry .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) - .schemaMappers(schemaMappers -> schemaMappers + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers .mapPrefix("http://json-schema.org", "resource:") .mapPrefix("https://json-schema.org", "resource:")) .build(); diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index e756c3988..69aed0ffd 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -51,7 +51,7 @@ class Issue475Test { @Test void draft4() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_4)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); @@ -64,7 +64,7 @@ void draft4() throws Exception { @Test void draft6() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_6, builder -> builder - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_6)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); @@ -77,7 +77,7 @@ void draft6() throws Exception { @Test void draft7() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("http://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_7)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); @@ -90,7 +90,7 @@ void draft7() throws Exception { @Test void draft201909() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09, builder -> builder - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2019_09)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); @@ -103,7 +103,7 @@ void draft201909() throws Exception { @Test void draft202012() throws Exception { SchemaRegistry jsonSchemaFactory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://json-schema.org", "classpath:"))); Schema schema = jsonSchemaFactory.getSchema(SchemaLocation.of(DialectId.DRAFT_2020_12)); List assertions = schema.validate(JsonMapperFactory.getInstance().readTree(INVALID_INPUT)); diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index 98d4a6d3a..97f569974 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -16,7 +16,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.resource.SchemaLoader; +import com.networknt.schema.resource.ResourceLoader; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,9 +39,9 @@ class Issue619Test { @BeforeEach void setup() throws Exception { - SchemaLoader schemaLoader = new SchemaLoader() { + ResourceLoader schemaLoader = new ResourceLoader() { @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { String iri = absoluteIri.toString(); if (iri.startsWith("http://localhost:1234")) { return () -> { @@ -54,7 +54,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { }; factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.add(schemaLoader))); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); three = getJsonNodeFromStringContent("3"); diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index bf07a47de..3baad8214 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -25,8 +25,8 @@ void testUrnUriAsLocalRef() throws IOException { void testUrnUriAsLocalRef_ExternalURN() { SchemaRegistry factory = SchemaRegistry .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7)) - .schemaMappers(schemaMappers -> { - schemaMappers.mappings(Collections.singletonMap("urn:data", + .schemaIdResolvers(schemaIdResolvers -> { + schemaIdResolvers.mappings(Collections.singletonMap("urn:data", "classpath:draft7/urn/issue665_external_urn_subschema.json")); }) .build(); diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index ba11e864c..8ad539afc 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -16,8 +16,8 @@ class Issue824Test { void validate() throws JsonProcessingException { final Schema v201909SpecSchema = SchemaRegistry .builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)) - .schemaMappers(schemaMappers -> { - schemaMappers.mapPrefix("https://json-schema.org", "resource:"); + .schemaIdResolvers(schemaIdResolvers -> { + schemaIdResolvers.mapPrefix("https://json-schema.org", "resource:"); }).build() .getSchema(SchemaLocation.of(Dialects.getDraft201909().getId())); final JsonNode invalidSchema = new ObjectMapper().readTree( diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index ec1fbc131..7bbe0f1e9 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -10,7 +10,7 @@ class Issue928Test { private SchemaRegistry factoryFor(SpecificationVersion version) { return SchemaRegistry .builder(SchemaRegistry.withDefaultDialect(version)) - .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://example.org", "classpath:")) + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://example.org", "classpath:")) .build(); } diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index e7954d5b9..3e85907d7 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -66,7 +66,7 @@ void test() { + " \"coordinates\": [1, 1]\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(external))); Schema schema = factory.getSchema(schemaData); assertTrue(schema.validate(inputData, InputFormat.JSON).isEmpty()); diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index 49001b656..db9176359 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -5,7 +5,7 @@ import com.networknt.schema.dialect.BasicDialectRegistry; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; -import com.networknt.schema.resource.SchemaLoader; +import com.networknt.schema.resource.ResourceLoader; import org.junit.jupiter.api.Test; @@ -48,12 +48,12 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12)) .enableSchemaCache(enableSchemaCache) - .schemaLoaders(schemaLoaders -> schemaLoaders.add(uriFetcher)) + .resourceLoaders(resourceLoaders -> resourceLoaders.add(uriFetcher)) .dialectRegistry(new BasicDialectRegistry(Dialects.getDraft202012())) .build(); } - private class CustomURIFetcher implements SchemaLoader { + private class CustomURIFetcher implements ResourceLoader { private final Map uriToResource = new HashMap<>(); @@ -66,7 +66,7 @@ void addResource(AbsoluteIri uri, InputStream is) { } @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { return () -> uriToResource.get(absoluteIri); } } diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index 944dd7e52..f7443d6c0 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -42,7 +42,7 @@ void oas31() throws IOException { SchemaRegistryConfig config = SchemaRegistryConfig.builder().build(); Schema schema = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaRegistryConfig(config).schemaMappers(schemaMappers -> schemaMappers + builder -> builder.schemaRegistryConfig(config).schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))) .getSchema(SchemaLocation.of("https://spec.openapis.org/oas/3.1/schema-base/2022-10-07")); List messages = schema.validate(inputData); diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index ae80691cc..83b25637c 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -189,8 +189,8 @@ void invalidSwaggerIoExample() { Schema schema = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders - .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders + .resources(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( "http://example.org/example.yaml#/paths/~1pets/patch/requestBody/content/application~1json/schema")); @@ -263,8 +263,8 @@ void fixedSwaggerIoExample() { Schema schema = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders - .schemas(Collections.singletonMap("http://example.org/example.yaml", document)))) + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders + .resources(Collections.singletonMap("http://example.org/example.yaml", document)))) .getSchema(SchemaLocation.of( "http://example.org/example.yaml#/paths/~1pets/patch/requestBody/content/application~1json/schema")); diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index e55231882..b10e5a58b 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -259,7 +259,7 @@ void unevaluatedProperties() throws JsonProcessingException { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(external))); + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(external))); Schema schema = factory.getSchema(schemaData); // The following checks if the heirarchical output format is correct with multiple unevaluated properties diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 984e81da9..fff84afa8 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -39,7 +39,7 @@ void resolveSamePathDotSlash() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); @@ -58,7 +58,7 @@ void resolveSamePath() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( Collections.singletonMap("https://www.example.com/schema/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); @@ -77,7 +77,7 @@ void resolveParent() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( Collections.singletonMap("https://www.example.com/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); @@ -96,7 +96,7 @@ void resolveComplex() { + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( Collections.singletonMap("https://www.example.com/schema/hello/integer.json", otherSchema)))); Schema jsonSchema = factory.getSchema(mainSchema); List messages = jsonSchema.validate("\"string\"", InputFormat.JSON); diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index e3e5eba7b..b2b4ffe5c 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -17,8 +17,8 @@ class SampleTest { @Test void schemaFromSchemaLocationMapping() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaMappers( - schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaIdResolvers( + schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. */ @@ -40,7 +40,7 @@ void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas( + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); /* * This should be cached for performance. diff --git a/src/test/java/com/networknt/schema/SchemaRegistryTest.java b/src/test/java/com/networknt/schema/SchemaRegistryTest.java index 6102f0807..4a569eb47 100644 --- a/src/test/java/com/networknt/schema/SchemaRegistryTest.java +++ b/src/test/java/com/networknt/schema/SchemaRegistryTest.java @@ -46,7 +46,7 @@ void concurrency() { + " { \"$ref\": \"https://json-schema.org/draft/2020-12/meta/core\" }\r\n" + " ]\r\n" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); diff --git a/src/test/java/com/networknt/schema/SchemaTest.java b/src/test/java/com/networknt/schema/SchemaTest.java index 52b9fc693..ff1ac400b 100644 --- a/src/test/java/com/networknt/schema/SchemaTest.java +++ b/src/test/java/com/networknt/schema/SchemaTest.java @@ -56,8 +56,8 @@ void concurrency() throws Exception { SchemaRegistryConfig config = SchemaRegistryConfig.builder().preloadSchema(false).build(); SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.schemaRegistryConfig(config) - .schemaLoaders(schemaLoaders -> schemaLoaders - .schemas(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); + .resourceLoaders(resourceLoaders -> resourceLoaders + .resources(Collections.singletonMap("http://example.org/ref.json", refSchemaData)))); Schema schema = factory.getSchema(schemaData); Exception[] instance = new Exception[1]; CountDownLatch latch = new CountDownLatch(1); diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 6533fd10b..25b4a59b8 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -228,7 +228,7 @@ void nestedRef() { schemas.put("https://www.example.org/DeviceConfiguration.json", deviceConfiguration); Schema schema = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2019_09, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas))) + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(schemas))) .getSchema(schemaData); String inputData = "{ \"isPrimaryDevice\": true, \"roleName\": \"hello\" }"; OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index daaa2ac8d..47821235d 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -33,9 +33,9 @@ import com.networknt.schema.dialect.Dialect; import com.networknt.schema.dialect.Dialects; import com.networknt.schema.resource.InputStreamSource; -import com.networknt.schema.resource.MapSchemaMapper; -import com.networknt.schema.resource.SchemaLoader; -import com.networknt.schema.resource.SchemaMapper; +import com.networknt.schema.resource.MapSchemaIdResolver; +import com.networknt.schema.resource.ResourceLoader; +import com.networknt.schema.resource.SchemaIdResolver; class UriMappingTest { @@ -54,7 +54,7 @@ void testBuilderUriMappingUri() throws IOException { Builder builder = SchemaRegistry.builder() .defaultDialectId(draftV4.getId()) .dialectRegistry(new BasicDialectRegistry(draftV4)) - .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(getUriMappingsFromUrl(mappings))); SchemaRegistry instance = builder.build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); @@ -71,9 +71,9 @@ void testBuilderUriMappingUri() throws IOException { */ @Test void testBuilderExampleMappings() throws IOException { - SchemaLoader schemaLoader = new SchemaLoader() { + ResourceLoader schemaLoader = new ResourceLoader() { @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { String iri = absoluteIri.toString(); if ("https://example.com/invalid/schema/url".equals(iri)) { return () -> { @@ -84,7 +84,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { } }; SchemaRegistry instance = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))); + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.add(schemaLoader))); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error try { @@ -105,7 +105,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { Builder builder = SchemaRegistry.builder() .defaultDialectId(draftV4.getId()) .dialectRegistry(new BasicDialectRegistry(draftV4)) - .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(getUriMappingsFromUrl(mappings))); instance = builder.build(); Schema schema = instance.getSchema(example); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); @@ -121,7 +121,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/uri-mapping.json"); SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) - .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of( "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json")); assertEquals(0, schema.validate(mapper.readTree(mappings)).size()); @@ -137,9 +137,9 @@ void testValidatorConfigUriMappingUri() throws IOException { */ @Test void testValidatorConfigExampleMappings() throws IOException { - SchemaLoader schemaLoader = new SchemaLoader() { + ResourceLoader schemaLoader = new ResourceLoader() { @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { + public InputStreamSource getResource(AbsoluteIri absoluteIri) { String iri = absoluteIri.toString(); if ("https://example.com/invalid/schema/url".equals(iri)) { return () -> { @@ -151,7 +151,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { }; URL mappings = UriMappingTest.class.getResource("/uri_mapping/invalid-schema-uri.json"); SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader)))).build(); + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.add(schemaLoader)))).build(); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error try { @@ -168,7 +168,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { fail("Unexpected exception thrown"); } instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) - .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(example); assertEquals(0, schema.validate(mapper.createObjectNode()).size()); } @@ -177,13 +177,13 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/uri_mapping/schema-with-ref-mapping.json"); SchemaRegistry instance = SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)) - .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(getUriMappingsFromUrl(mappings))).build(); Schema schema = instance.getSchema(SchemaLocation.of("resource:uri_mapping/schema-with-ref.json") ); assertEquals(0, schema.validate(mapper.readTree("[]")).size()); } - private SchemaMapper getUriMappingsFromUrl(URL url) { + private SchemaIdResolver getUriMappingsFromUrl(URL url) { HashMap map = new HashMap(); try { for (JsonNode mapping : mapper.readTree(url)) { @@ -193,6 +193,6 @@ private SchemaMapper getUriMappingsFromUrl(URL url) { } catch (IOException e) { throw new UncheckedIOException(e); } - return new MapSchemaMapper(map); + return new MapSchemaIdResolver(map); } } diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 4b907548e..6deca91e6 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -33,7 +33,7 @@ void testURNToURI() throws Exception { SchemaRegistry.Builder builder = SchemaRegistry.builder() .defaultDialectId(draftV7.getId()) .dialectRegistry(new BasicDialectRegistry(draftV7)) - .schemaMappers(schemaMappers -> schemaMappers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) + .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) ); SchemaRegistry instance = builder.build(); Schema schema = instance.getSchema(is); diff --git a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java index 67cc08578..c54e99dab 100644 --- a/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java +++ b/src/test/java/com/networknt/schema/benchmark/NetworkntTestSuiteTestCases.java @@ -13,14 +13,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.networknt.schema.AbsoluteIri; import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.regex.JoniRegularExpressionFactory; -import com.networknt.schema.resource.InputStreamSource; import com.networknt.schema.resource.SchemaLoader; import com.networknt.schema.suite.TestCase; import com.networknt.schema.suite.TestSource; @@ -44,19 +42,16 @@ public static List findTestCases(SpecificationVersio public static List findTestCases(SpecificationVersion defaultVersion, String basePath, Predicate filter) { - SchemaLoader schemaLoader = new SchemaLoader() { - @Override - public InputStreamSource getSchema(AbsoluteIri absoluteIri) { - String iri = absoluteIri.toString(); - if (iri.startsWith("http://localhost:1234")) { - return () -> { - String path = iri.substring("http://localhost:1234".length()); - return new FileInputStream("src/test/suite/remotes" + path); - }; - } - return null; + SchemaLoader schemaLoader = new SchemaLoader(location -> { + String iri = location.toString(); + if (iri.startsWith("http://localhost:1234")) { + return () -> { + String path = iri.substring("http://localhost:1234".length()); + return new FileInputStream("src/test/suite/remotes" + path); + }; } - }; + return null; + }); List results = new ArrayList<>(); List testCasePaths = findTestCasePaths(basePath, filter); for (Path path : testCasePaths) { @@ -71,7 +66,7 @@ public InputStreamSource getSchema(AbsoluteIri absoluteIri) { Schema schema = SchemaRegistry .withDefaultDialect(defaultVersion, builder -> builder.schemaRegistryConfig(config) - .schemaLoaders(schemaLoaders -> schemaLoaders.add(schemaLoader))) + .schemaLoader(schemaLoader)) .getSchema(testCaseFileUri, testCase.getSchema()); results.add(new NetworkntTestSuiteTestCase(schema, testCase, testCase.getSource().getPath().getParent().toString().endsWith("format") ? true : null)); diff --git a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java index f92bd9c22..84ab471b2 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi31Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi31Test.java @@ -40,7 +40,7 @@ class OpenApi31Test { @Test void validateVocabulary() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaMappers(schemaMappers -> schemaMappers + builder -> builder.schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers .mapPrefix("https://spec.openapis.org/oas/3.1", "classpath:oas/3.1"))); Schema schema = factory .getSchema(SchemaLocation.of("classpath:schema/oas/3.1/petstore.yaml#/components/schemas/PetResponse")); diff --git a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java deleted file mode 100644 index 15f2ed6c3..000000000 --- a/src/test/java/com/networknt/schema/resource/DisallowSchemaLoaderTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema.resource; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.junit.jupiter.api.Test; - -import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SpecificationVersion; - -/** - * Test for DisallowSchemaLoader. - */ -class DisallowSchemaLoaderTest { - - @Test - void integration() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder - .schemaLoaders(schemaLoaders -> schemaLoaders.add(DisallowSchemaLoader.getInstance()))); - InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, - () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); - assertEquals("classpath:schema/example-main.json", - invalidSchemaException.getError().getArguments()[0].toString()); - } - -} diff --git a/src/test/java/com/networknt/schema/resource/UriSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/IriResourceLoaderTest.java similarity index 76% rename from src/test/java/com/networknt/schema/resource/UriSchemaLoaderTest.java rename to src/test/java/com/networknt/schema/resource/IriResourceLoaderTest.java index dc3e3f70f..04eab650e 100644 --- a/src/test/java/com/networknt/schema/resource/UriSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/IriResourceLoaderTest.java @@ -33,7 +33,7 @@ /** * Tests for URI schema Loader. */ -class UriSchemaLoaderTest { +class IriResourceLoaderTest { /** * This test should only be run manually so as not to always hit the remote * server. @@ -43,8 +43,8 @@ class UriSchemaLoaderTest { @Test @Disabled("manual") void shouldLoadAbsoluteIri() throws IOException { - UriSchemaLoader schemaLoader = new UriSchemaLoader(); - InputStreamSource inputStreamSource = schemaLoader.getSchema(AbsoluteIri.of("https://ç§ã®å›£ä½“ã‚‚.jp/")); + IriResourceLoader schemaLoader = new IriResourceLoader(); + InputStreamSource inputStreamSource = schemaLoader.getResource(AbsoluteIri.of("https://ç§ã®å›£ä½“ã‚‚.jp/")); try (InputStream inputStream = inputStreamSource.getInputStream()) { String result = new BufferedReader(new InputStreamReader(inputStream)).lines() .collect(Collectors.joining("\n")); @@ -54,13 +54,13 @@ void shouldLoadAbsoluteIri() throws IOException { @Test void shouldNotThrowAbsoluteIri() throws IOException { - UriSchemaLoader schemaLoader = new UriSchemaLoader(); - assertDoesNotThrow(() -> schemaLoader.getSchema(AbsoluteIri.of("https://ç§ã®å›£ä½“ã‚‚.jp/"))); + IriResourceLoader schemaLoader = new IriResourceLoader(); + assertDoesNotThrow(() -> schemaLoader.getResource(AbsoluteIri.of("https://ç§ã®å›£ä½“ã‚‚.jp/"))); } @Test void shouldThrowRelativeIri() throws IOException { - UriSchemaLoader schemaLoader = new UriSchemaLoader(); - assertThrows(IllegalArgumentException.class, () -> schemaLoader.getSchema(AbsoluteIri.of("ç§ã®å›£ä½“ã‚‚.jp/"))); + IriResourceLoader schemaLoader = new IriResourceLoader(); + assertThrows(IllegalArgumentException.class, () -> schemaLoader.getResource(AbsoluteIri.of("ç§ã®å›£ä½“ã‚‚.jp/"))); } } diff --git a/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/MapResourceLoaderTest.java similarity index 81% rename from src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java rename to src/test/java/com/networknt/schema/resource/MapResourceLoaderTest.java index 9fe9a7078..ba02ed9fb 100644 --- a/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/MapResourceLoaderTest.java @@ -27,7 +27,7 @@ import com.networknt.schema.AbsoluteIri; -class MapSchemaLoaderTest { +class MapResourceLoaderTest { static class Result { private final String schema; @@ -46,8 +46,8 @@ void testMappingsWithTwoFunctions() throws IOException { mappings.put("http://www.example.org/test.json", new Result("test")); mappings.put("http://www.example.org/hello.json", new Result("hello")); - MapSchemaLoader loader = new MapSchemaLoader(mappings::get, Result::getSchema); - InputStreamSource source = loader.getSchema(AbsoluteIri.of("http://www.example.org/test.json")); + MapResourceLoader loader = new MapResourceLoader(mappings::get, Result::getSchema); + InputStreamSource source = loader.getResource(AbsoluteIri.of("http://www.example.org/test.json")); try (InputStream inputStream = source.getInputStream()) { byte[] r = new byte[4]; inputStream.read(r); @@ -55,7 +55,7 @@ void testMappingsWithTwoFunctions() throws IOException { assertEquals("test", value); } - InputStreamSource result = loader.getSchema(AbsoluteIri.of("http://www.example.org/not-found.json")); + InputStreamSource result = loader.getResource(AbsoluteIri.of("http://www.example.org/not-found.json")); assertNull(result); } } diff --git a/src/test/java/com/networknt/schema/resource/MapSchemaMapperTest.java b/src/test/java/com/networknt/schema/resource/MapSchemaIdResolverTest.java similarity index 73% rename from src/test/java/com/networknt/schema/resource/MapSchemaMapperTest.java rename to src/test/java/com/networknt/schema/resource/MapSchemaIdResolverTest.java index d9697b6b1..896bf6299 100644 --- a/src/test/java/com/networknt/schema/resource/MapSchemaMapperTest.java +++ b/src/test/java/com/networknt/schema/resource/MapSchemaIdResolverTest.java @@ -21,15 +21,15 @@ import com.networknt.schema.AbsoluteIri; -class MapSchemaMapperTest { +class MapSchemaIdResolverTest { @Test void predicateMapping() { - MapSchemaMapper mapper = new MapSchemaMapper(test -> test.startsWith("http://www.example.org/"), + MapSchemaIdResolver mapper = new MapSchemaIdResolver(test -> test.startsWith("http://www.example.org/"), original -> original.replaceFirst("http://www.example.org/", "classpath:")); - AbsoluteIri result = mapper.map(AbsoluteIri.of("http://www.example.org/hello")); + AbsoluteIri result = mapper.resolve(AbsoluteIri.of("http://www.example.org/hello")); assertEquals("classpath:hello", result.toString()); - result = mapper.map(AbsoluteIri.of("notmatchingprefixhttp://www.example.org/hello")); + result = mapper.resolve(AbsoluteIri.of("notmatchingprefixhttp://www.example.org/hello")); assertNull(result); } diff --git a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java b/src/test/java/com/networknt/schema/resource/MetaSchemaIdResolverTest.java similarity index 80% rename from src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java rename to src/test/java/com/networknt/schema/resource/MetaSchemaIdResolverTest.java index aa7a61e13..8aac3c8ea 100644 --- a/src/test/java/com/networknt/schema/resource/MetaSchemaMapperTest.java +++ b/src/test/java/com/networknt/schema/resource/MetaSchemaIdResolverTest.java @@ -30,7 +30,7 @@ /** * MetaSchemaMapperTest. */ -class MetaSchemaMapperTest { +class MetaSchemaIdResolverTest { enum MapInput { V4(DialectId.DRAFT_4), @@ -49,10 +49,10 @@ enum MapInput { @ParameterizedTest @EnumSource(MapInput.class) void map(MapInput input) throws IOException { - MetaSchemaMapper mapper = new MetaSchemaMapper(); - AbsoluteIri result = mapper.map(AbsoluteIri.of(input.iri)); - ClasspathSchemaLoader loader = new ClasspathSchemaLoader(); - InputStreamSource source = loader.getSchema(result); + MetaSchemaIdResolver mapper = new MetaSchemaIdResolver(); + AbsoluteIri result = mapper.resolve(AbsoluteIri.of(input.iri)); + ClasspathResourceLoader loader = new ClasspathResourceLoader(); + InputStreamSource source = loader.getResource(result); assertNotNull(source); try (InputStream inputStream = source.getInputStream()) { inputStream.read(); diff --git a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/SchemaLoaderTest.java similarity index 65% rename from src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java rename to src/test/java/com/networknt/schema/resource/SchemaLoaderTest.java index ec1e71f75..4174a7ba8 100644 --- a/src/test/java/com/networknt/schema/resource/AllowSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/SchemaLoaderTest.java @@ -23,26 +23,30 @@ import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.Schema; -import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SchemaRegistry; import com.networknt.schema.SpecificationVersion; -/** - * Test for AllowSchemaLoader. - */ -class AllowSchemaLoaderTest { - +public class SchemaLoaderTest { @Test - void integration() { + void allow() { SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders - .add(new AllowSchemaLoader(iri -> iri.toString().startsWith("classpath:"))))); + builder -> builder.schemaLoader( + schemaLoader -> schemaLoader.allow(iri -> iri.toString().startsWith("classpath:")))); InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, () -> factory.getSchema(SchemaLocation.of("http://www.example.org/schema"))); - assertEquals("http://www.example.org/schema", - invalidSchemaException.getError().getArguments()[0].toString()); + assertEquals("http://www.example.org/schema", invalidSchemaException.getError().getArguments()[0].toString()); Schema schema = factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json")); assertNotNull(schema); } + @Test + void block() { + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, + builder -> builder.schemaLoader(schemaLoader -> schemaLoader.block(iri -> true))); + InvalidSchemaException invalidSchemaException = assertThrows(InvalidSchemaException.class, + () -> factory.getSchema(SchemaLocation.of("classpath:schema/example-main.json"))); + assertEquals("classpath:schema/example-main.json", + invalidSchemaException.getError().getArguments()[0].toString()); + } } diff --git a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java index c8aae2c80..004002df3 100644 --- a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java @@ -71,7 +71,7 @@ void noValidation() { + "}"; Schema schema = SchemaRegistry .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) .getSchema(schemaData); @@ -86,7 +86,7 @@ void noValidation() { // Set validation vocab schema = SchemaRegistry .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/validation", Vocabulary.DRAFT_2020_12_VALIDATION.getIri()))))) @@ -123,7 +123,7 @@ void noFormatValidation() { + "}"; Schema schema = SchemaRegistry .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))) .getSchema(schemaData); @@ -139,7 +139,7 @@ void noFormatValidation() { // Set format assertion vocab schema = SchemaRegistry .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/format", Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getIri()))))) @@ -175,7 +175,7 @@ void requiredUnknownVocabulary() { + "}"; SchemaRegistry factory = SchemaRegistry .withDefaultDialectId("https://www.example.com/no-validation-no-format/schema", - builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); assertThrows(InvalidSchemaException.class, () -> factory.getSchema(schemaData)); @@ -218,7 +218,7 @@ void customVocabulary() { .build(); SchemaRegistry factory = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.dialectRegistry(new BasicDialectRegistry(dialect)).schemaLoaders(schemaLoaders -> schemaLoaders.schemas(Collections + builder -> builder.dialectRegistry(new BasicDialectRegistry(dialect)).resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); Schema schema = factory.getSchema(schemaData); From 2939e879c490e79346db9b03cc2bf73766364af6 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Fri, 26 Sep 2025 13:12:45 +0800 Subject: [PATCH 49/74] Refactor path type --- .../com/networknt/schema/path/NodePath.java | 39 +++++++++++--- .../com/networknt/schema/path/PathType.java | 53 +++++++++++-------- .../networknt/schema/utils/JsonNodeUtil.java | 10 +++- .../com/networknt/schema/Issue687Test.java | 10 +++- 4 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/networknt/schema/path/NodePath.java b/src/main/java/com/networknt/schema/path/NodePath.java index e81472ad9..8e4cd118d 100644 --- a/src/main/java/com/networknt/schema/path/NodePath.java +++ b/src/main/java/com/networknt/schema/path/NodePath.java @@ -15,6 +15,7 @@ */ package com.networknt.schema.path; +import java.util.ArrayDeque; import java.util.Objects; /** @@ -202,14 +203,40 @@ public boolean contains(String segment) { @Override public String toString() { if (this.value == null) { - String parentValue = this.parent == null ? type.getRoot() : this.parent.toString(); + if (pathSegmentIndex == -1 && this.pathSegment == null) { + this.value = type.getRoot(); + return this.value; + } + + ArrayDeque pathSegments = new ArrayDeque(); if (pathSegmentIndex != -1) { - this.value = this.type.append(parentValue, pathSegmentIndex); - } else if (pathSegment != null) { - this.value = this.type.append(parentValue, pathSegment); - } else { - this.value = parentValue; + pathSegments.push(this.pathSegmentIndex); + } else if (this.pathSegment != null) { + pathSegments.push(this.pathSegment); + } + NodePath parent = getParent(); + while (parent != null) { + if (parent.pathSegmentIndex != -1) { + pathSegments.push(parent.pathSegmentIndex); + } else if (parent.pathSegment != null) { + pathSegments.push(parent.pathSegment); + } + parent = parent.getParent(); + } + + StringBuilder builder = new StringBuilder(); + String root = type.getRoot(); + if (root != null) { + builder.append(root); + } + for (Object pathSegment : pathSegments) { + if (pathSegment instanceof Number) { + type.append(builder, ((Number) pathSegment).intValue()); + } else { + type.append(builder, pathSegment.toString()); + } } + this.value = builder.toString(); } return this.value; } diff --git a/src/main/java/com/networknt/schema/path/PathType.java b/src/main/java/com/networknt/schema/path/PathType.java index f86f87e5e..f1c637f48 100644 --- a/src/main/java/com/networknt/schema/path/PathType.java +++ b/src/main/java/com/networknt/schema/path/PathType.java @@ -1,6 +1,6 @@ package com.networknt.schema.path; -import java.util.function.BiFunction; +import java.util.function.BiConsumer; import java.util.function.IntPredicate; /** @@ -11,18 +11,19 @@ public enum PathType { /** * The legacy approach, loosely based on JSONPath (but not guaranteed to give valid JSONPath expressions). */ - LEGACY("$", (currentPath, token) -> currentPath + "." + replaceCommonSpecialCharactersIfPresent(token), - (currentPath, index) -> currentPath + "[" + index + "]"), + LEGACY("$", (currentPath, token) -> { + currentPath.append(".").append(replaceCommonSpecialCharactersIfPresent(token)); + }, (currentPath, index) -> { + currentPath.append("[").append(index).append("]"); + }), /** * Paths as JSONPath expressions. */ JSON_PATH("$", (currentPath, token) -> { - if (token.isEmpty()) { throw new IllegalArgumentException("A JSONPath selector cannot be empty"); } - /* * Accepted characters for shorthand paths: * - 'a' through 'z' @@ -32,16 +33,18 @@ public enum PathType { * - any non-ASCII Unicode character */ if (JSONPath.isShorthand(token)) { - return currentPath + "." + token; + currentPath.append(".").append(token); + return; } // Replace single quote (used to wrap property names when not shorthand form). if (token.indexOf('\'') != -1) token = token.replace("'", "\\'"); // Replace other special characters. token = replaceCommonSpecialCharactersIfPresent(token); - - return currentPath + "['" + token + "']"; - }, (currentPath, index) -> currentPath + "[" + index + "]"), + currentPath.append("['").append(token).append("']"); + }, (currentPath, index) -> { + currentPath.append("[").append(index).append("]"); + }), /** * Paths as JSONPointer expressions. @@ -54,21 +57,31 @@ public enum PathType { if (token.indexOf('/') != -1) token = token.replace("/", "~1"); // Replace other special characters. token = replaceCommonSpecialCharactersIfPresent(token); - return currentPath + "/" + token; - }, (currentPath, index) -> currentPath + "/" + index), + currentPath.append("/").append(token); + }, (currentPath, index) -> { + currentPath.append("/").append(index); + }), /** * Paths as a URI reference. */ - URI_REFERENCE("", (currentPath, token) -> !currentPath.isEmpty() ? currentPath + "/" + token : token, (currentPath, index) -> currentPath + "/" + index); + URI_REFERENCE("", (currentPath, token) -> { + if (!(currentPath.length() == 0)) { + currentPath.append("/").append(token); + } else { + currentPath.append(token); + } + }, (currentPath, index) -> { + currentPath.append("/").append(index); + }); /** * The default path generation approach to use. */ public static final PathType DEFAULT = LEGACY; private final String rootToken; - private final BiFunction appendTokenFn; - private final BiFunction appendIndexFn; + private final BiConsumer appendTokenFn; + private final BiConsumer appendIndexFn; /** * Constructor. @@ -77,7 +90,7 @@ public enum PathType { * @param appendTokenFn A function used to define the path fragment used to append a token (e.g. property) to an existing path. * @param appendIndexFn A function used to append an index (for arrays) to an existing path. */ - PathType(String rootToken, BiFunction appendTokenFn, BiFunction appendIndexFn) { + PathType(String rootToken, BiConsumer appendTokenFn, BiConsumer appendIndexFn) { this.rootToken = rootToken; this.appendTokenFn = appendTokenFn; this.appendIndexFn = appendIndexFn; @@ -103,10 +116,9 @@ private static String replaceCommonSpecialCharactersIfPresent(String token) { * * @param currentPath The path to append to. * @param child The child token. - * @return The resulting complete path. */ - public String append(String currentPath, String child) { - return this.appendTokenFn.apply(currentPath, child); + public void append(StringBuilder currentPath, String child) { + this.appendTokenFn.accept(currentPath, child); } /** @@ -114,10 +126,9 @@ public String append(String currentPath, String child) { * * @param currentPath The path to append to. * @param index The index to append. - * @return The resulting complete path. */ - public String append(String currentPath, int index) { - return this.appendIndexFn.apply(currentPath, index); + public void append(StringBuilder currentPath, int index) { + this.appendIndexFn.accept(currentPath, index); } /** diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 874005fca..2cdf6db0e 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -37,7 +37,10 @@ private static void visitNode(PathType pathType, String root, JsonNode node, Col private static void visitArray(PathType pathType, String root, JsonNode node, Collection collector) { int size = node.size(); for (int i = 0; i < size; ++i) { - String path = pathType.append(root, i); + StringBuilder builder = new StringBuilder(); + builder.append(root); + pathType.append(builder, i); + String path = builder.toString(); collector.add(path); visitNode(pathType, path, node.get(i), collector); } @@ -45,7 +48,10 @@ private static void visitArray(PathType pathType, String root, JsonNode node, Co private static void visitObject(PathType pathType, String root, JsonNode node, Collection collector) { node.fields().forEachRemaining(entry -> { - String path = pathType.append(root, entry.getKey()); + StringBuilder builder = new StringBuilder(); + builder.append(root); + pathType.append(builder, entry.getKey()); + String path = builder.toString(); collector.add(path); visitNode(pathType, path, entry.getValue(), collector); }); diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index a4dcaa866..8995df5bd 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -70,13 +70,19 @@ static Stream errors() { @ParameterizedTest @MethodSource("appendTokens") void testAppendToken(PathType pathType, String currentPath, String token, String expected) { - assertEquals(expected, pathType.append(currentPath, token)); + StringBuilder builder = new StringBuilder(); + builder.append(currentPath); + pathType.append(builder, token); + assertEquals(expected, builder.toString()); } @ParameterizedTest @MethodSource("appendIndexes") void testAppendIndex(PathType pathType, String currentPath, Integer index, String expected) { - assertEquals(expected, pathType.append(currentPath, index)); + StringBuilder builder = new StringBuilder(); + builder.append(currentPath); + pathType.append(builder, index); + assertEquals(expected, builder.toString()); } @ParameterizedTest From 66757a436d81ea7b4be1f878de2c128d96b471cd Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Fri, 26 Sep 2025 22:19:16 +0800 Subject: [PATCH 50/74] Rename SchemaResult to InstanceResult --- .../com/networknt/schema/ExecutionContext.java | 12 ++++++------ src/main/java/com/networknt/schema/Schema.java | 2 +- .../schema/keyword/UnevaluatedItemsValidator.java | 2 +- .../keyword/UnevaluatedPropertiesValidator.java | 2 +- .../networknt/schema/output/OutputUnitData.java | 2 +- .../{SchemaResult.java => InstanceResult.java} | 8 ++++---- .../{SchemaResults.java => InstanceResults.java} | 14 +++++++------- 7 files changed, 21 insertions(+), 21 deletions(-) rename src/main/java/com/networknt/schema/result/{SchemaResult.java => InstanceResult.java} (88%) rename src/main/java/com/networknt/schema/result/{SchemaResults.java => InstanceResults.java} (73%) diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index e8e6f5c06..5cb78dba1 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -25,7 +25,7 @@ import com.networknt.schema.annotation.Annotations; import com.networknt.schema.keyword.DiscriminatorState; import com.networknt.schema.path.NodePath; -import com.networknt.schema.result.SchemaResults; +import com.networknt.schema.result.InstanceResults; import com.networknt.schema.walk.WalkConfig; /** @@ -37,7 +37,7 @@ public class ExecutionContext { private CollectorContext collectorContext = null; private Annotations annotations = null; - private SchemaResults results = null; + private InstanceResults instanceResults = null; private List errors = new ArrayList<>(); private Map discriminatorMapping = new HashMap<>(); @@ -156,11 +156,11 @@ public Annotations getAnnotations() { return annotations; } - public SchemaResults getResults() { - if (this.results == null) { - this.results = new SchemaResults(); + public InstanceResults getInstanceResults() { + if (this.instanceResults == null) { + this.instanceResults = new InstanceResults(); } - return results; + return instanceResults; } /** diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index 26a50afb5..b548f67e0 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -703,7 +703,7 @@ public void validate(ExecutionContext executionContext, JsonNode jsonNode, JsonN if (executionContext.getErrors().size() > currentErrors) { // Failed with assertion set result and drop all annotations from this schema // and all subschemas - executionContext.getResults().setResult(instanceLocation, getSchemaLocation(), getEvaluationPath(), false); + executionContext.getInstanceResults().setResult(instanceLocation, getSchemaLocation(), getEvaluationPath(), false); } } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index 96714df03..e15c5ecd3 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -73,7 +73,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode boolean evaluated = false; // Get all the valid adjacent annotations - Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); + Predicate validEvaluationPathFilter = a -> executionContext.getInstanceResults().isValid(instanceLocation, a.getEvaluationPath()); Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() .startsWith(this.evaluationPath.getParent()); diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java index 96aa4f295..fbdfa4dee 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedPropertiesValidator.java @@ -56,7 +56,7 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode // Get all the valid adjacent annotations - Predicate validEvaluationPathFilter = a -> executionContext.getResults().isValid(instanceLocation, a.getEvaluationPath()); + Predicate validEvaluationPathFilter = a -> executionContext.getInstanceResults().isValid(instanceLocation, a.getEvaluationPath()); Predicate adjacentEvaluationPathFilter = a -> a.getEvaluationPath() .startsWith(this.evaluationPath.getParent()); diff --git a/src/main/java/com/networknt/schema/output/OutputUnitData.java b/src/main/java/com/networknt/schema/output/OutputUnitData.java index 42ceddebe..a2464e9cb 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitData.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitData.java @@ -100,7 +100,7 @@ public static OutputUnitData from(List validationErrors, ExecutionContext OutputUnitKey key = new OutputUnitKey(annotation.getEvaluationPath().getParent(), annotationSchemaLocation, annotation.getInstanceLocation()); - boolean validResult = executionContext.getResults().isValid(annotation.getInstanceLocation(), + boolean validResult = executionContext.getInstanceResults().isValid(annotation.getInstanceLocation(), annotation.getEvaluationPath()); valid.put(key, validResult); if (validResult) { diff --git a/src/main/java/com/networknt/schema/result/SchemaResult.java b/src/main/java/com/networknt/schema/result/InstanceResult.java similarity index 88% rename from src/main/java/com/networknt/schema/result/SchemaResult.java rename to src/main/java/com/networknt/schema/result/InstanceResult.java index 009e7b9af..7925d13c9 100644 --- a/src/main/java/com/networknt/schema/result/SchemaResult.java +++ b/src/main/java/com/networknt/schema/result/InstanceResult.java @@ -21,15 +21,15 @@ import com.networknt.schema.path.NodePath; /** - * Sub schema results. + * Instance results. */ -public class SchemaResult { +public class InstanceResult { private final NodePath instanceLocation; private final SchemaLocation schemaLocation; private final NodePath evaluationPath; private final boolean valid; - public SchemaResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, + public InstanceResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { super(); this.instanceLocation = instanceLocation; @@ -73,7 +73,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - SchemaResult other = (SchemaResult) obj; + InstanceResult other = (InstanceResult) obj; return Objects.equals(evaluationPath, other.evaluationPath) && Objects.equals(instanceLocation, other.instanceLocation) && Objects.equals(schemaLocation, other.schemaLocation) && valid == other.valid; diff --git a/src/main/java/com/networknt/schema/result/SchemaResults.java b/src/main/java/com/networknt/schema/result/InstanceResults.java similarity index 73% rename from src/main/java/com/networknt/schema/result/SchemaResults.java rename to src/main/java/com/networknt/schema/result/InstanceResults.java index bafb27499..88e446ea6 100644 --- a/src/main/java/com/networknt/schema/result/SchemaResults.java +++ b/src/main/java/com/networknt/schema/result/InstanceResults.java @@ -24,26 +24,26 @@ import com.networknt.schema.path.NodePath; /** - * Sub schema results. + * Instance results. */ -public class SchemaResults { +public class InstanceResults { /** * Stores the invalid results. */ - private final Map> values = new HashMap<>(); + private final Map> values = new HashMap<>(); public void setResult(NodePath instanceLocation, SchemaLocation schemaLocation, NodePath evaluationPath, boolean valid) { - SchemaResult result = new SchemaResult(instanceLocation, schemaLocation, evaluationPath, valid); - List v = values.computeIfAbsent(instanceLocation, k -> new ArrayList<>()); + InstanceResult result = new InstanceResult(instanceLocation, schemaLocation, evaluationPath, valid); + List v = values.computeIfAbsent(instanceLocation, k -> new ArrayList<>()); v.add(result); } public boolean isValid(NodePath instanceLocation, NodePath evaluationPath) { - List instance = values.get(instanceLocation); + List instance = values.get(instanceLocation); if (instance != null) { - for (SchemaResult result : instance) { + for (InstanceResult result : instance) { if (evaluationPath.startsWith(result.getEvaluationPath())) { if(!result.isValid()) { return false; From ae7bb22cf81bfc74266913d1d2b173938208ce05 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 01:13:26 +0800 Subject: [PATCH 51/74] Move SpecificationVersionDetector to test --- .../java/com/networknt/schema/SpecificationVersionDetector.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{main => test}/java/com/networknt/schema/SpecificationVersionDetector.java (100%) diff --git a/src/main/java/com/networknt/schema/SpecificationVersionDetector.java b/src/test/java/com/networknt/schema/SpecificationVersionDetector.java similarity index 100% rename from src/main/java/com/networknt/schema/SpecificationVersionDetector.java rename to src/test/java/com/networknt/schema/SpecificationVersionDetector.java From cfca9b1a05ed7c39c0081edc995737f5de070e15 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 08:34:00 +0800 Subject: [PATCH 52/74] Move JsonType and TypeFactory to utils package --- src/main/java/com/networknt/schema/format/Format.java | 4 ++-- .../java/com/networknt/schema/keyword/AllOfValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/AnyOfValidator.java | 4 ++-- .../networknt/schema/keyword/ContentEncodingValidator.java | 4 ++-- .../networknt/schema/keyword/ContentMediaTypeValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/EnumValidator.java | 4 ++-- .../networknt/schema/keyword/ExclusiveMaximumValidator.java | 2 +- .../networknt/schema/keyword/ExclusiveMinimumValidator.java | 2 +- .../com/networknt/schema/keyword/MaxLengthValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/MaximumValidator.java | 2 +- .../com/networknt/schema/keyword/MinLengthValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/MinimumValidator.java | 2 +- .../java/com/networknt/schema/keyword/OneOfValidator.java | 4 ++-- .../java/com/networknt/schema/keyword/PatternValidator.java | 5 +++-- .../java/com/networknt/schema/keyword/TypeValidator.java | 4 ++-- .../com/networknt/schema/keyword/UnionTypeValidator.java | 4 ++-- src/main/java/com/networknt/schema/utils/JsonNodeUtil.java | 2 -- src/main/java/com/networknt/schema/{ => utils}/JsonType.java | 2 +- .../java/com/networknt/schema/{ => utils}/TypeFactory.java | 3 ++- src/test/java/com/networknt/schema/FormatValidatorTest.java | 2 ++ src/test/java/com/networknt/schema/TypeFactoryTest.java | 5 +++-- 21 files changed, 37 insertions(+), 34 deletions(-) rename src/main/java/com/networknt/schema/{ => utils}/JsonType.java (92%) rename src/main/java/com/networknt/schema/{ => utils}/TypeFactory.java (94%) diff --git a/src/main/java/com/networknt/schema/format/Format.java b/src/main/java/com/networknt/schema/format/Format.java index 3aeffb14c..cf8064c61 100644 --- a/src/main/java/com/networknt/schema/format/Format.java +++ b/src/main/java/com/networknt/schema/format/Format.java @@ -20,12 +20,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonType; import com.networknt.schema.MessageSourceError; import com.networknt.schema.SchemaContext; -import com.networknt.schema.TypeFactory; import com.networknt.schema.keyword.FormatValidator; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * Used to implement the various formats for the format keyword. diff --git a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java index 09373abab..279cbd62b 100644 --- a/src/main/java/com/networknt/schema/keyword/AllOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AllOfValidator.java @@ -21,13 +21,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonType; import com.networknt.schema.Schema; import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * {@link KeywordValidator} for allOf. diff --git a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java index 2bf6604d7..45c1bf72a 100644 --- a/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/AnyOfValidator.java @@ -22,13 +22,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonType; import com.networknt.schema.Schema; import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * {@link KeywordValidator} for anyOf. diff --git a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java index 925085807..d384c9fee 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentEncodingValidator.java @@ -19,10 +19,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; import com.networknt.schema.SchemaContext; import java.util.Base64; diff --git a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java index 6ae7d7fc6..f4fe1044a 100644 --- a/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContentMediaTypeValidator.java @@ -24,12 +24,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * {@link KeywordValidator} for contentMediaType. diff --git a/src/main/java/com/networknt/schema/keyword/EnumValidator.java b/src/main/java/com/networknt/schema/keyword/EnumValidator.java index d1e2c3f63..6ad8d9d50 100644 --- a/src/main/java/com/networknt/schema/keyword/EnumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/EnumValidator.java @@ -22,10 +22,10 @@ import com.fasterxml.jackson.databind.node.NullNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; import com.networknt.schema.SchemaContext; import java.math.BigDecimal; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index bfaf9f55e..dd98158ad 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -20,11 +20,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 43f21f18a..719858012 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -20,11 +20,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java index 25ac5acbb..bb6312092 100644 --- a/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaxLengthValidator.java @@ -19,10 +19,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index a4fb0509e..04c1ba215 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -20,11 +20,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java index 43ce44d47..456367bb9 100644 --- a/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinLengthValidator.java @@ -19,10 +19,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; import com.networknt.schema.SchemaContext; /** diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index 4a46e4a73..c03ca6ca4 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -20,11 +20,11 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index 3d82ea94f..ef41ffdac 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -22,13 +22,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Error; import com.networknt.schema.ExecutionContext; -import com.networknt.schema.JsonType; import com.networknt.schema.Schema; import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaException; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * {@link KeywordValidator} for oneOf. diff --git a/src/main/java/com/networknt/schema/keyword/PatternValidator.java b/src/main/java/com/networknt/schema/keyword/PatternValidator.java index 3a2945b71..3af2bb054 100644 --- a/src/main/java/com/networknt/schema/keyword/PatternValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PatternValidator.java @@ -21,12 +21,13 @@ import com.networknt.schema.FailFastAssertionException; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.regex.RegularExpression; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index 134ab7128..05f8d56f5 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * {@link KeywordValidator} for type. diff --git a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java index 61a5bed10..c42b3018b 100644 --- a/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java @@ -21,12 +21,12 @@ import com.networknt.schema.ExecutionContext; import com.networknt.schema.Schema; import com.networknt.schema.SchemaException; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaLocation; -import com.networknt.schema.TypeFactory; import com.networknt.schema.SchemaContext; import com.networknt.schema.Validator; import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 2cdf6db0e..4eb20bd49 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -5,10 +5,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Schema; -import com.networknt.schema.JsonType; import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.SpecificationVersion; -import com.networknt.schema.TypeFactory; import com.networknt.schema.path.PathType; import com.networknt.schema.SchemaContext; diff --git a/src/main/java/com/networknt/schema/JsonType.java b/src/main/java/com/networknt/schema/utils/JsonType.java similarity index 92% rename from src/main/java/com/networknt/schema/JsonType.java rename to src/main/java/com/networknt/schema/utils/JsonType.java index ddf933670..709001a3b 100644 --- a/src/main/java/com/networknt/schema/JsonType.java +++ b/src/main/java/com/networknt/schema/utils/JsonType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.utils; /** * Indicates the type. diff --git a/src/main/java/com/networknt/schema/TypeFactory.java b/src/main/java/com/networknt/schema/utils/TypeFactory.java similarity index 94% rename from src/main/java/com/networknt/schema/TypeFactory.java rename to src/main/java/com/networknt/schema/utils/TypeFactory.java index 2401e89bf..ec2808c0c 100644 --- a/src/main/java/com/networknt/schema/TypeFactory.java +++ b/src/main/java/com/networknt/schema/utils/TypeFactory.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.utils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.networknt.schema.SchemaRegistryConfig; /** * Type factory. diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 79cf071e0..37a80e6ca 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -32,6 +32,8 @@ import com.networknt.schema.dialect.Dialects; import com.networknt.schema.format.Format; import com.networknt.schema.output.OutputUnit; +import com.networknt.schema.utils.JsonType; +import com.networknt.schema.utils.TypeFactory; /** * Test for format validator. diff --git a/src/test/java/com/networknt/schema/TypeFactoryTest.java b/src/test/java/com/networknt/schema/TypeFactoryTest.java index 763ff5c2a..b25a9a6f3 100755 --- a/src/test/java/com/networknt/schema/TypeFactoryTest.java +++ b/src/test/java/com/networknt/schema/TypeFactoryTest.java @@ -16,8 +16,8 @@ package com.networknt.schema; -import static com.networknt.schema.TypeFactory.getSchemaNodeType; -import static com.networknt.schema.TypeFactory.getValueNodeType; +import static com.networknt.schema.utils.TypeFactory.getSchemaNodeType; +import static com.networknt.schema.utils.TypeFactory.getValueNodeType; import static org.junit.jupiter.api.Assertions.assertSame; import java.math.BigDecimal; @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.databind.node.TextNode; import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.utils.JsonType; /** * Test for TypeFactory. From e79fdade2d33e6632e68179943618f62062e4043 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 08:55:11 +0800 Subject: [PATCH 53/74] Rename JsonNodeReader to NodeReader --- .../com/networknt/schema/SchemaRegistry.java | 80 ++++++++++++++----- ...onNodeReader.java => BasicNodeReader.java} | 10 +-- ...NodeReader.java => DefaultNodeReader.java} | 18 ++--- .../{JsonNodeReader.java => NodeReader.java} | 8 +- ...erTest.java => DefaultNodeReaderTest.java} | 8 +- .../networknt/schema/utils/JsonNodesTest.java | 6 +- 6 files changed, 87 insertions(+), 43 deletions(-) rename src/main/java/com/networknt/schema/serialization/{BasicJsonNodeReader.java => BasicNodeReader.java} (84%) rename src/main/java/com/networknt/schema/serialization/{DefaultJsonNodeReader.java => DefaultNodeReader.java} (87%) rename src/main/java/com/networknt/schema/serialization/{JsonNodeReader.java => NodeReader.java} (86%) rename src/test/java/com/networknt/schema/serialization/{DefaultJsonNodeReaderTest.java => DefaultNodeReaderTest.java} (89%) diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 2fa25336c..fb88e40d0 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -26,8 +26,9 @@ import com.networknt.schema.resource.ResourceLoaders; import com.networknt.schema.resource.SchemaIdResolvers; import com.networknt.schema.resource.SchemaLoader; -import com.networknt.schema.serialization.BasicJsonNodeReader; -import com.networknt.schema.serialization.JsonNodeReader; +import com.networknt.schema.serialization.BasicNodeReader; +import com.networknt.schema.serialization.DefaultNodeReader; +import com.networknt.schema.serialization.NodeReader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +58,7 @@ public class SchemaRegistry { public static class Builder { private String defaultDialectId; private DialectRegistry dialectRegistry = null; - private JsonNodeReader jsonNodeReader = null; + private NodeReader nodeReader = null; private SchemaLoader schemaLoader = null; private boolean enableSchemaCache = true; private SchemaRegistryConfig schemaRegistryConfig = null; @@ -65,16 +66,38 @@ public static class Builder { /** * Sets the json node reader to read the data. *

- * If set this takes precedence over the configured json mapper and yaml mapper. - *

* A location aware object reader can be created using - * JsonNodeReader.builder().locationAware().build(). + * NodeReader.builder().locationAware().build(). * - * @param jsonNodeReader the object reader + * @param nodeReader the object reader * @return the builder */ - public Builder jsonNodeReader(JsonNodeReader jsonNodeReader) { - this.jsonNodeReader = jsonNodeReader; + public Builder nodeReader(NodeReader nodeReader) { + this.nodeReader = nodeReader; + return this; + } + + /** + * Sets the json node reader to read the data. + * + *

+         * A location aware object reader can be created using
+         * schemaRegistryBuilder.nodeReader(nodeReader -> nodeReader.locationAware()).
+         * 
+ * + * A json ObjectMapper can be set using + * + *
+         * schemaRegistryBuilder.nodeReader(nodeReader -> nodeReader.jsonMapper(objectMapper))
+         * 
+ * + * @param customizer + * @return the builder + */ + public Builder nodeReader(Consumer customizer) { + DefaultNodeReader.Builder builder = NodeReader.builder(); + customizer.accept(builder); + this.nodeReader = builder.build(); return this; } @@ -140,12 +163,12 @@ public Builder schemaRegistryConfig(SchemaRegistryConfig schemaRegistryConfig) { } public SchemaRegistry build() { - return new SchemaRegistry(jsonNodeReader, defaultDialectId, schemaLoader, enableSchemaCache, + return new SchemaRegistry(nodeReader, defaultDialectId, schemaLoader, enableSchemaCache, dialectRegistry, schemaRegistryConfig); } } - private final JsonNodeReader jsonNodeReader; + private final NodeReader nodeReader; private final String defaultDialectId; private final SchemaLoader schemaLoader; private final ConcurrentMap schemaCache = new ConcurrentHashMap<>(); @@ -153,12 +176,12 @@ public SchemaRegistry build() { private final DialectRegistry dialectRegistry; private final SchemaRegistryConfig schemaRegistryConfig; - private SchemaRegistry(JsonNodeReader jsonNodeReader, String defaultDialectId, SchemaLoader schemaLoader, + private SchemaRegistry(NodeReader nodeReader, String defaultDialectId, SchemaLoader schemaLoader, boolean enableSchemaCache, DialectRegistry dialectRegistry, SchemaRegistryConfig schemaRegistryConfig) { if (defaultDialectId == null || defaultDialectId.trim().isEmpty()) { throw new IllegalArgumentException("defaultDialectId must not be null or empty"); } - this.jsonNodeReader = jsonNodeReader != null ? jsonNodeReader : BasicJsonNodeReader.getInstance(); + this.nodeReader = nodeReader != null ? nodeReader : BasicNodeReader.getInstance(); this.defaultDialectId = defaultDialectId; this.schemaLoader = schemaLoader != null ? schemaLoader : SchemaLoader.getDefault(); this.enableSchemaCache = enableSchemaCache; @@ -184,6 +207,10 @@ public static Builder builder() { /** * Creates a new schema registry with a default schema dialect. The schema * dialect will only be used if the input does not specify a $schema. + *

+ * This uses a dialect registry that contains all the supported standard + * specification dialects, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft + * 2020-12. * * @param specificationVersion the default dialect id corresponding to the * specification version used when the schema does @@ -197,6 +224,10 @@ public static SchemaRegistry withDefaultDialect(SpecificationVersion specificati /** * Creates a new schema registry with a default schema dialect. The schema * dialect will only be used if the input does not specify a $schema. + *

+ * This uses a dialect registry that contains all the supported standard + * specification dialects, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft + * 2020-12. * * @param specificationVersion the default dialect id corresponding to the * specification version used when the schema does @@ -213,6 +244,10 @@ public static SchemaRegistry withDefaultDialect(SpecificationVersion specificati /** * Creates a new schema registry with a default schema dialect. The schema * dialect will only be used if the input does not specify a $schema. + *

+ * This uses a dialect registry that contains all the supported standard + * specification dialects, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft + * 2020-12. * * @param dialectId the default dialect id used when the schema does not * specify the $schema keyword @@ -231,6 +266,9 @@ public static SchemaRegistry withDefaultDialectId(String dialectId, Consumer * Schemas that do not specify dialect using $schema will use the dialect. + *

+ * This uses a dialect registry that only contains this dialect and will throw + * an exception for unknown dialects. * * @param dialect the dialect * @return the schema registry @@ -243,6 +281,9 @@ public static SchemaRegistry withDialect(Dialect dialect) { * Gets a new schema registry that supports a specific dialect only. *

* Schemas that do not specify dialect using $schema will use the dialect. + *

+ * This uses a dialect registry that only contains this dialect and will throw + * an exception for unknown dialects. * * @param dialect the dialect * @param customizer to customize the registry @@ -261,15 +302,18 @@ public static SchemaRegistry withDialect(Dialect dialect, Consumer * - * SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(Specification.Version.DRAFT_2019_09)); + * SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09)); * * * @param blueprint the existing factory * @return the builder */ public static Builder builder(SchemaRegistry blueprint) { - Builder builder = builder().schemaLoader(blueprint.schemaLoader).defaultDialectId(blueprint.defaultDialectId) - .jsonNodeReader(blueprint.jsonNodeReader); + Builder builder = builder().schemaLoader(blueprint.schemaLoader) + .defaultDialectId(blueprint.defaultDialectId) + .nodeReader(blueprint.nodeReader) + .dialectRegistry(blueprint.dialectRegistry) + .schemaRegistryConfig(blueprint.schemaRegistryConfig); return builder; } @@ -402,11 +446,11 @@ public Dialect getDialect(String dialectId) { } JsonNode readTree(String content, InputFormat inputFormat) throws IOException { - return this.jsonNodeReader.readTree(content, inputFormat); + return this.nodeReader.readTree(content, inputFormat); } JsonNode readTree(InputStream content, InputFormat inputFormat) throws IOException { - return this.jsonNodeReader.readTree(content, inputFormat); + return this.nodeReader.readTree(content, inputFormat); } /** diff --git a/src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java b/src/main/java/com/networknt/schema/serialization/BasicNodeReader.java similarity index 84% rename from src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java rename to src/main/java/com/networknt/schema/serialization/BasicNodeReader.java index e90509169..08d8c106a 100644 --- a/src/main/java/com/networknt/schema/serialization/BasicJsonNodeReader.java +++ b/src/main/java/com/networknt/schema/serialization/BasicNodeReader.java @@ -24,18 +24,18 @@ import com.networknt.schema.InputFormat; /** - * BasicJsonNodeReader. + * Basic implementation of {@link NodeReader}. */ -public class BasicJsonNodeReader implements JsonNodeReader { +public class BasicNodeReader implements NodeReader { private static class Holder { - private static final BasicJsonNodeReader INSTANCE = new BasicJsonNodeReader(); + private static final BasicNodeReader INSTANCE = new BasicNodeReader(); } - public static BasicJsonNodeReader getInstance() { + public static BasicNodeReader getInstance() { return Holder.INSTANCE; } - protected BasicJsonNodeReader() { + protected BasicNodeReader() { } @Override diff --git a/src/main/java/com/networknt/schema/serialization/DefaultJsonNodeReader.java b/src/main/java/com/networknt/schema/serialization/DefaultNodeReader.java similarity index 87% rename from src/main/java/com/networknt/schema/serialization/DefaultJsonNodeReader.java rename to src/main/java/com/networknt/schema/serialization/DefaultNodeReader.java index 10707edca..242887fd5 100644 --- a/src/main/java/com/networknt/schema/serialization/DefaultJsonNodeReader.java +++ b/src/main/java/com/networknt/schema/serialization/DefaultNodeReader.java @@ -11,9 +11,9 @@ import com.networknt.schema.utils.JsonNodes; /** - * Default {@link JsonNodeReader}. + * Default {@link NodeReader}. */ -public class DefaultJsonNodeReader implements JsonNodeReader { +public class DefaultNodeReader implements NodeReader { protected final ObjectMapper jsonMapper; protected final ObjectMapper yamlMapper; protected final JsonNodeFactoryFactory jsonNodeFactoryFactory; @@ -25,7 +25,7 @@ public class DefaultJsonNodeReader implements JsonNodeReader { * @param yamlMapper the yaml mapper * @param jsonNodeFactoryFactory the json node factory factory */ - protected DefaultJsonNodeReader(ObjectMapper jsonMapper, ObjectMapper yamlMapper, + protected DefaultNodeReader(ObjectMapper jsonMapper, ObjectMapper yamlMapper, JsonNodeFactoryFactory jsonNodeFactoryFactory) { this.jsonMapper = jsonMapper; this.yamlMapper = yamlMapper; @@ -84,7 +84,7 @@ protected ObjectMapper getObjectMapper(InputFormat inputFormat) { } /** - * Gets the builder for {@link DefaultJsonNodeReader}. + * Gets the builder for {@link DefaultNodeReader}. * * @return the builder */ @@ -93,7 +93,7 @@ public static Builder builder() { } /** - * Builder support for {@link JsonNodeReader}. + * Builder support for {@link NodeReader}. * * @param the super type */ @@ -143,7 +143,7 @@ public T jsonNodeFactoryFactory(JsonNodeFactoryFactory jsonNodeFactoryFactory) { } /** - * Builder for {@link DefaultJsonNodeReader}. + * Builder for {@link DefaultNodeReader}. */ public static class Builder extends BuilderSupport { @@ -162,12 +162,12 @@ public Builder locationAware() { } /** - * Builds the {@link JsonNodeReader}. + * Builds the {@link NodeReader}. * * @return the object reader */ - public JsonNodeReader build() { - return new DefaultJsonNodeReader(this.jsonMapper, this.yamlMapper, this.jsonNodeFactoryFactory); + public NodeReader build() { + return new DefaultNodeReader(this.jsonMapper, this.yamlMapper, this.jsonNodeFactoryFactory); } } } diff --git a/src/main/java/com/networknt/schema/serialization/JsonNodeReader.java b/src/main/java/com/networknt/schema/serialization/NodeReader.java similarity index 86% rename from src/main/java/com/networknt/schema/serialization/JsonNodeReader.java rename to src/main/java/com/networknt/schema/serialization/NodeReader.java index cb4b53f36..39cff35d1 100644 --- a/src/main/java/com/networknt/schema/serialization/JsonNodeReader.java +++ b/src/main/java/com/networknt/schema/serialization/NodeReader.java @@ -24,7 +24,7 @@ /** * Reader for reading content to {@link JsonNode}. */ -public interface JsonNodeReader { +public interface NodeReader { /** * Deserialize content as a tree. @@ -47,11 +47,11 @@ public interface JsonNodeReader { JsonNode readTree(InputStream content, InputFormat inputFormat) throws IOException; /** - * Creates a builder for {@link JsonNodeReader}. + * Creates a builder for {@link NodeReader}. * * @return the builder */ - static DefaultJsonNodeReader.Builder builder() { - return DefaultJsonNodeReader.builder(); + static DefaultNodeReader.Builder builder() { + return DefaultNodeReader.builder(); } } diff --git a/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java b/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java similarity index 89% rename from src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java rename to src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java index b508cf167..9e3a0b950 100644 --- a/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java +++ b/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java @@ -29,7 +29,7 @@ /** * Test for Default Object Reader. */ -class DefaultJsonNodeReaderTest { +class DefaultNodeReaderTest { @Test void location() throws JsonParseException, IOException { String schemaData = "{\r\n" @@ -41,7 +41,7 @@ void location() throws JsonParseException, IOException { + " }\r\n" + " }\r\n" + "}"; - JsonNode jsonNode = JsonNodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); + JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); JsonNode idNode = jsonNode.at("/$id"); JsonLocation location = JsonNodes.tokenLocationOf(idNode); assertEquals(2, location.getLineNr()); @@ -69,7 +69,7 @@ void jsonLocation() throws IOException { + " }\r\n" + " }\r\n" + "}"; - JsonNode jsonNode = JsonNodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); + JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/format")); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/minLength")); @@ -89,7 +89,7 @@ void yamlLocation() throws IOException { + " startDate:\r\n" + " format: 'date'\r\n" + " minLength: 6\r\n"; - JsonNode jsonNode = JsonNodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.YAML); + JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.YAML); JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/format")); JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/minLength")); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 207203b3f..056c8b4d0 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -37,7 +37,7 @@ import com.networknt.schema.SpecificationVersion; import com.networknt.schema.Error; import com.networknt.schema.serialization.JsonMapperFactory; -import com.networknt.schema.serialization.JsonNodeReader; +import com.networknt.schema.serialization.NodeReader; import com.networknt.schema.serialization.node.LocationJsonNodeFactoryFactory; /** * Tests for JsonNodes. @@ -87,7 +87,7 @@ void jsonLocation() { + " \"startDate\": \"1\"\r\n" + "}"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); + builder -> builder.nodeReader(nodeReader -> nodeReader.locationAware())); Schema schema = factory.getSchema(schemaData, InputFormat.JSON); List messages = schema.validate(inputData, InputFormat.JSON, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); @@ -132,7 +132,7 @@ void yamlLocation() { String inputData = "---\r\n" + "startDate: '1'\r\n"; SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); + builder -> builder.nodeReader(NodeReader.builder().locationAware().build())); Schema schema = factory.getSchema(schemaData, InputFormat.YAML); List messages = schema.validate(inputData, InputFormat.YAML, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true)); From db1ac3061afe8f0e33f5864dc6b9644426b6831d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 12:04:30 +0800 Subject: [PATCH 54/74] Refactor SchemaRegistry and ResourceLoaders --- .../com/networknt/schema/SchemaRegistry.java | 39 ++++++++++++++ .../schema/resource/ResourceLoaders.java | 30 +++++------ .../{SampleTest.java => QuickStartTest.java} | 54 ++++++++++--------- 3 files changed, 83 insertions(+), 40 deletions(-) rename src/test/java/com/networknt/schema/{SampleTest.java => QuickStartTest.java} (61%) diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index fb88e40d0..258fc7211 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -36,9 +36,11 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; +import java.util.function.Function; /** * Registry for loading and registering {@link Schema} instances. @@ -162,6 +164,43 @@ public Builder schemaRegistryConfig(SchemaRegistryConfig schemaRegistryConfig) { return this; } + /** + * Sets the schema data by absolute IRI. + * + * @param schemas the map of IRI to schema data + * @return the builder + */ + public Builder schemas(Map schemas) { + return this.resourceLoaders(resourceLoaders -> resourceLoaders.resources(schemas)); + } + + /** + * Sets the schema data by absolute IRI function. + * + * @param schemas the function that returns schema data given IRI + * @return the builder + */ + public Builder schemas(Function schemas) { + return this.resourceLoaders(resourceLoaders -> resourceLoaders.resources(schemas)); + } + + /** + * Sets the schema data by using two mapping functions. + *

+ * Firstly to map the IRI to an object. If the object is null no mapping is + * performed. + *

+ * Next to map the object to the schema data. + * + * @param the type of the object + * @param mapIriToObject the mapping of IRI to object + * @param mapObjectToData the mappingof object to schema data + * @return the builder + */ + public Builder schemas(Function mapIriToObject, Function mapObjectToData) { + return this.resourceLoaders(resourceLoaders -> resourceLoaders.resources(mapIriToObject, mapObjectToData)); + } + public SchemaRegistry build() { return new SchemaRegistry(nodeReader, defaultDialectId, schemaLoader, enableSchemaCache, dialectRegistry, schemaRegistryConfig); diff --git a/src/main/java/com/networknt/schema/resource/ResourceLoaders.java b/src/main/java/com/networknt/schema/resource/ResourceLoaders.java index c53036e59..85525b53f 100644 --- a/src/main/java/com/networknt/schema/resource/ResourceLoaders.java +++ b/src/main/java/com/networknt/schema/resource/ResourceLoaders.java @@ -23,7 +23,7 @@ import java.util.function.Function; /** - * Schema Loaders used to load a resource given the retrieval IRI. + * Resource Loaders used to load a resource given the retrieval IRI. */ public class ResourceLoaders extends ArrayList { private static final long serialVersionUID = 1L; @@ -62,7 +62,7 @@ public Builder with(Builder builder) { } /** - * Customize the schema loaders. + * Customize the resource loaders. * * @param customizer the customizer * @return the builder @@ -73,20 +73,20 @@ public Builder values(Consumer> customizer) { } /** - * Adds a schema loader. + * Adds a resource loader. * - * @param schemaLoader the schema loader + * @param resourceLoader the resource loader * @return the builder */ - public Builder add(ResourceLoader schemaLoader) { - this.values.add(schemaLoader); + public Builder add(ResourceLoader resourceLoader) { + this.values.add(resourceLoader); return this; } /** - * Sets the schema data by absolute IRI. + * Sets the resource data by absolute IRI. * - * @param resources the map of IRI to schema data + * @param resources the map of IRI to resource data * @return the builder */ public Builder resources(Map resources) { @@ -95,18 +95,18 @@ public Builder resources(Map resources) { } /** - * Sets the schema data by absolute IRI function. + * Sets the resource data by absolute IRI function. * - * @param schemas the function that returns schema data given IRI + * @param resources the function that returns resource data given IRI * @return the builder */ - public Builder resources(Function schemas) { - this.values.add(new MapResourceLoader(schemas)); + public Builder resources(Function resources) { + this.values.add(new MapResourceLoader(resources)); return this; } /** - * Sets the schema data by using two mapping functions. + * Sets the resource data by using two mapping functions. *

* Firstly to map the IRI to an object. If the object is null no mapping is * performed. @@ -118,7 +118,7 @@ public Builder resources(Function schemas) { * @param mapObjectToData the mappingof object to schema data * @return the builder */ - public Builder schemas(Function mapIriToObject, Function mapObjectToData) { + public Builder resources(Function mapIriToObject, Function mapObjectToData) { this.values.add(new MapResourceLoader(mapIriToObject, mapObjectToData)); return this; } @@ -126,7 +126,7 @@ public Builder schemas(Function mapIriToObject, Function builder.schemaIdResolvers( - schemaIdResolvers -> schemaIdResolvers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, + builder -> builder.schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers + .mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* * This should be cached for performance. */ - Schema schemaFromSchemaLocation = factory + Schema schemaFromSchemaLocation = schemaRegistry .getSchema(SchemaLocation.of("https://www.example.com/schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not @@ -31,21 +32,22 @@ void schemaFromSchemaLocationMapping() { */ schemaFromSchemaLocation.initializeValidators(); List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); + executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @Test void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; - - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, - builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources( - Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData)))); + + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, + builder -> builder.schemas( + Collections.singletonMap("https://www.example.com/schema/example-ref.json", schemaData))); /* * This should be cached for performance. */ - Schema schemaFromSchemaLocation = factory + Schema schemaFromSchemaLocation = schemaRegistry .getSchema(SchemaLocation.of("https://www.example.com/schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not @@ -54,20 +56,21 @@ void schemaFromSchemaLocationContent() { */ schemaFromSchemaLocation.initializeValidators(); List errors = schemaFromSchemaLocation.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); + executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @Test void schemaFromClasspath() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); /* * This should be cached for performance. * * Loading from using the retrieval IRI is not recommended as it may cause * confusing when resolving relative $ref when $id is also used. */ - Schema schemaFromClasspath = factory.getSchema(SchemaLocation.of("classpath:schema/example-ref.json")); + Schema schemaFromClasspath = schemaRegistry.getSchema(SchemaLocation.of("classpath:schema/example-ref.json")); /* * By default all schemas are preloaded eagerly but ref resolve failures are not * thrown. You check if there are issues with ref resolving using @@ -75,29 +78,29 @@ void schemaFromClasspath() { */ schemaFromClasspath.initializeValidators(); List errors = schemaFromClasspath.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); + executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @Test void schemaFromString() { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); /* * This should be cached for performance. * * Loading from a String is not recommended as there is no base IRI to use for * resolving relative $ref. */ - Schema schemaFromString = factory - .getSchema("{\"enum\":[1, 2, 3, 4]}"); - List errors = schemaFromString.validate("7", InputFormat.JSON, - executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); + Schema schemaFromString = schemaRegistry.getSchema("{\"enum\":[1, 2, 3, 4]}"); + List errors = schemaFromString.validate("7", InputFormat.JSON, executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } @Test void schemaFromJsonNode() throws JsonProcessingException { - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); /* @@ -106,10 +109,10 @@ void schemaFromJsonNode() throws JsonProcessingException { * Loading from a JsonNode is not recommended as there is no base IRI to use for * resolving relative $ref. * - * Note that the V202012 from the factory is the default version if $schema is not - * specified. As $schema is specified in the data, V6 is used. + * Note that the V202012 from the schemaRegistry is the default version if $schema is + * not specified. As $schema is specified in the data, V6 is used. */ - Schema schemaFromNode = factory.getSchema(schemaNode); + Schema schemaFromNode = schemaRegistry.getSchema(schemaNode); /* * By default all schemas are preloaded eagerly but ref resolve failures are not * thrown. You check if there are issues with ref resolving using @@ -117,7 +120,8 @@ void schemaFromJsonNode() throws JsonProcessingException { */ schemaFromNode.initializeValidators(); List errors = schemaFromNode.validate("{\"id\": \"2\"}", InputFormat.JSON, - executionContext -> executionContext.executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); + executionContext -> executionContext + .executionConfig(executionConfig -> executionConfig.formatAssertionsEnabled(true))); assertEquals(1, errors.size()); } } From 6dd21ceaa6f9acdfc01fc347b8be10d10a730584 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 12:16:16 +0800 Subject: [PATCH 55/74] Fix UrnTest --- .../java/com/networknt/schema/UrnTest.java | 61 +++++++------------ 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 6deca91e6..78bbb57a6 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -1,50 +1,31 @@ package com.networknt.schema; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.dialect.BasicDialectRegistry; -import com.networknt.schema.dialect.Dialect; -import com.networknt.schema.dialect.Dialects; - -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.io.InputStream; -import java.net.URL; -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; -class UrnTest -{ - private final ObjectMapper mapper = new ObjectMapper(); +class UrnTest { + private final ObjectMapper mapper = new ObjectMapper(); - /** - * Validate that a JSON URI Mapping file containing the URI Mapping schema is - * schema valid. - * - * @throws IOException if unable to parse the mapping file - */ - @Test - void testURNToURI() throws Exception { - InputStream urlTestData = UrnTest.class.getResourceAsStream("/draft7/urn/test.json"); - InputStream is = null; - try { - is = new URL("https://raw.githubusercontent.com/francesc79/json-schema-validator/feature/urn-management/src/test/resources/draft7/urn/urn.schema.json").openStream(); - Dialect draftV7 = Dialects.getDraft7(); - SchemaRegistry.Builder builder = SchemaRegistry.builder() - .defaultDialectId(draftV7.getId()) - .dialectRegistry(new BasicDialectRegistry(draftV7)) - .schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(value -> AbsoluteIri.of(String.format("resource:draft7/urn/%s.schema.json", value.toString()))) - ); - SchemaRegistry instance = builder.build(); - Schema schema = instance.getSchema(is); - assertEquals(0, schema.validate(mapper.readTree(urlTestData)).size()); - } catch( Exception e) { - e.printStackTrace(); - } - finally { - if (is != null) { - is.close(); - } + /** + * Validate that a JSON URI Mapping file containing the URI Mapping schema is + * schema valid. + * + * @throws IOException if unable to parse the mapping file + */ + @Test + void testURNToURI() throws Exception { + InputStream urlTestData = UrnTest.class.getResourceAsStream("/draft7/urn/test.json"); + SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, + builder -> builder.schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(value -> { + return AbsoluteIri.of(String.format("%s.schema.json", value.toString())); + }))); + Schema schema = schemaRegistry.getSchema(SchemaLocation.of("classpath:/draft7/urn/urn")); + assertEquals(0, schema.validate(mapper.readTree(urlTestData)).size()); } - } } From d964f00dcaab5e3a53ea3971c0a025bae77f3398 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 13:09:28 +0800 Subject: [PATCH 56/74] Refactor Dialect Registry and Schema Registry --- .../com/networknt/schema/SchemaRegistry.java | 87 ++++++++++++++++++- .../dialect/AbstractDialectRegistry.java | 63 ++++++++++++++ .../schema/dialect/BasicDialectRegistry.java | 22 ++++- .../dialect/DefaultDialectRegistry.java | 71 ++++++--------- .../com/networknt/schema/QuickStartTest.java | 69 +++++++++++++++ 5 files changed, 263 insertions(+), 49 deletions(-) create mode 100644 src/main/java/com/networknt/schema/dialect/AbstractDialectRegistry.java diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 258fc7211..15e8ef49f 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -300,6 +301,45 @@ public static SchemaRegistry withDefaultDialectId(String dialectId, Consumer + * This uses a dialect registry that contains all the supported standard + * specification dialects, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft + * 2020-12. + * + * @param dialect the default dialect used when the schema does not specify the + * $schema keyword + * @return the factory + */ + public static SchemaRegistry withDefaultDialect(Dialect dialect) { + return withDefaultDialect(dialect, null); + } + + /** + * Creates a new schema registry with a default schema dialect. The schema + * dialect will only be used if the input does not specify a $schema. + *

+ * This uses a dialect registry that contains all the supported standard + * specification dialects, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft + * 2020-12. + * + * @param dialect the default dialect used when the schema does not specify + * the $schema keyword + * @param customizer to customize the registry + * @return the factory + */ + public static SchemaRegistry withDefaultDialect(Dialect dialect, Consumer customizer) { + SchemaRegistry.Builder builder = builder().defaultDialectId(dialect.getId()) + .dialectRegistry(new DefaultDialectRegistry(dialect)); + if (customizer != null) { + customizer.accept(builder); + } + return builder.build(); + } /** * Gets a new schema registry that supports a specific dialect only. @@ -317,12 +357,13 @@ public static SchemaRegistry withDialect(Dialect dialect) { } /** - * Gets a new schema registry that supports a specific dialect only. + * Gets a new schema registry that supports a list of specific dialects only. *

- * Schemas that do not specify dialect using $schema will use the dialect. + * Schemas that do not specify dialect using $schema will use the first dialect + * on the list. *

- * This uses a dialect registry that only contains this dialect and will throw - * an exception for unknown dialects. + * This uses a dialect registry that only contains the list of dialects and will + * throw an exception for unknown dialects. * * @param dialect the dialect * @param customizer to customize the registry @@ -336,6 +377,44 @@ public static SchemaRegistry withDialect(Dialect dialect, Consumer + * Schemas that do not specify dialect using $schema will use the first dialect + * on the list. + *

+ * This uses a dialect registry that only contains the list of dialects and will + * throw an exception for unknown dialects. + * + * @param dialects the dialects with the first being the default dialect + * @return the schema registry + */ + public static SchemaRegistry withDialects(List dialects) { + return withDialects(dialects, null); + } + + /** + * Gets a new schema registry that supports a specific dialect only. + *

+ * Schemas that do not specify dialect using $schema will use the dialect. + *

+ * This uses a dialect registry that only contains this dialect and will throw + * an exception for unknown dialects. + * + * @param dialects the dialects with the first being the default dialect + * @param customizer to customize the registry + * @return the schema registry + */ + public static SchemaRegistry withDialects(List dialects, Consumer customizer) { + SchemaRegistry.Builder builder = builder().defaultDialectId(dialects.get(0).getId()) + .dialectRegistry(new BasicDialectRegistry(dialects)); + if (customizer != null) { + customizer.accept(builder); + } + return builder.build(); + } + /** * Builder from an existing {@link SchemaRegistry}. diff --git a/src/main/java/com/networknt/schema/dialect/AbstractDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/AbstractDialectRegistry.java new file mode 100644 index 000000000..7bddaacfa --- /dev/null +++ b/src/main/java/com/networknt/schema/dialect/AbstractDialectRegistry.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema.dialect; + +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.Error; +import com.networknt.schema.InvalidSchemaException; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SchemaRegistry; +import com.networknt.schema.SpecificationVersion; + +/** + * Abstract {@link DialectRegistry}. + */ +public abstract class AbstractDialectRegistry implements DialectRegistry { + protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory) { + try { + Dialect result = loadDialectBuilder(iri, schemaFactory).build(); + return result; + } catch (InvalidSchemaException e) { + throw e; + } catch (Exception e) { + Error error = Error.builder().message("Failed to load dialect ''{0}''").arguments(iri).build(); + throw new InvalidSchemaException(error, e); + } + } + + protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory) { + Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri)); + Dialect.Builder builder = Dialect.builder(iri, schema.getSchemaContext().getDialect()); + SpecificationVersion specification = schema.getSchemaContext().getDialect().getSpecificationVersion(); + if (specification != null) { + if (specification.getOrder() >= SpecificationVersion.DRAFT_2019_09.getOrder()) { + // Process vocabularies + JsonNode vocabulary = schema.getSchemaNode().get("$vocabulary"); + if (vocabulary != null) { + builder.vocabularies(Map::clear); + for (Entry vocabs : vocabulary.properties()) { + builder.vocabulary(vocabs.getKey(), vocabs.getValue().booleanValue()); + } + } + } + } + return builder; + } +} diff --git a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java index 0eac88636..137b78a15 100644 --- a/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/BasicDialectRegistry.java @@ -15,14 +15,24 @@ */ package com.networknt.schema.dialect; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.function.Function; import com.networknt.schema.Error; import com.networknt.schema.InvalidSchemaException; import com.networknt.schema.SchemaRegistry; -public class BasicDialectRegistry implements DialectRegistry { - private Function dialects; +/** + * Basic {@link DialectRegistry}. + */ +public class BasicDialectRegistry extends AbstractDialectRegistry { + protected final Function dialects; + + protected BasicDialectRegistry() { + this.dialects = null; + } public BasicDialectRegistry(Function dialects) { this.dialects = dialects; @@ -32,6 +42,14 @@ public BasicDialectRegistry(Dialect dialect) { this.dialects = dialectId -> dialect.getId().equals(dialectId) ? dialect : null; } + public BasicDialectRegistry(Collection dialects) { + Map result = new HashMap<>(); + for (Dialect dialect : dialects) { + result.put(dialect.getId(), dialect); + } + this.dialects = result::get; + } + @Override public Dialect getDialect(String dialectId, SchemaRegistry schemaRegistry) { Dialect dialect = dialects.apply(dialectId); diff --git a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java index 021cf5709..d66d0f39e 100644 --- a/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java +++ b/src/main/java/com/networknt/schema/dialect/DefaultDialectRegistry.java @@ -15,65 +15,50 @@ */ package com.networknt.schema.dialect; -import java.util.Map; -import java.util.Map.Entry; +import java.util.Collection; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.function.Function; -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.schema.Error; -import com.networknt.schema.InvalidSchemaException; -import com.networknt.schema.Schema; import com.networknt.schema.SchemaRegistry; -import com.networknt.schema.SchemaLocation; import com.networknt.schema.Specification; -import com.networknt.schema.SpecificationVersion; /** * Default {@link DialectRegistry}. */ -public class DefaultDialectRegistry implements DialectRegistry { - private final ConcurrentMap dialects = new ConcurrentHashMap<>(); - +public class DefaultDialectRegistry extends BasicDialectRegistry { + private final ConcurrentMap loadedDialects = new ConcurrentHashMap<>(); + + public DefaultDialectRegistry() { + super(); + } + + public DefaultDialectRegistry(Function dialects) { + super(dialects); + } + + public DefaultDialectRegistry(Dialect dialect) { + super(dialect); + } + + public DefaultDialectRegistry(Collection dialects) { + super(dialects); + } + @Override public Dialect getDialect(String dialectId, SchemaRegistry schemaFactory) { + if (this.dialects != null) { + Dialect dialect = dialects.apply(dialectId); + if (dialect != null) { + return dialect; + } + } // Is it a well-known dialect? Dialect dialect = Specification.getDialect(dialectId); if (dialect != null) { return dialect; } - return dialects.computeIfAbsent(dialectId, id -> loadDialect(id, schemaFactory)); - } - - protected Dialect loadDialect(String iri, SchemaRegistry schemaFactory) { - try { - Dialect result = loadDialectBuilder(iri, schemaFactory).build(); - return result; - } catch (InvalidSchemaException e) { - throw e; - } catch (Exception e) { - Error error = Error.builder().message("Failed to load dialect ''{0}''").arguments(iri).build(); - throw new InvalidSchemaException(error, e); - } - } - - protected Dialect.Builder loadDialectBuilder(String iri, SchemaRegistry schemaFactory) { - Schema schema = schemaFactory.getSchema(SchemaLocation.of(iri)); - Dialect.Builder builder = Dialect.builder(iri, schema.getSchemaContext().getDialect()); - SpecificationVersion specification = schema.getSchemaContext().getDialect().getSpecificationVersion(); - if (specification != null) { - if (specification.getOrder() >= SpecificationVersion.DRAFT_2019_09.getOrder()) { - // Process vocabularies - JsonNode vocabulary = schema.getSchemaNode().get("$vocabulary"); - if (vocabulary != null) { - builder.vocabularies(Map::clear); - for (Entry vocabs : vocabulary.properties()) { - builder.vocabulary(vocabs.getKey(), vocabs.getValue().booleanValue()); - } - } - } - } - return builder; + return loadedDialects.computeIfAbsent(dialectId, id -> loadDialect(id, schemaFactory)); } private static class Holder { diff --git a/src/test/java/com/networknt/schema/QuickStartTest.java b/src/test/java/com/networknt/schema/QuickStartTest.java index 2736b23a2..6b10c883d 100644 --- a/src/test/java/com/networknt/schema/QuickStartTest.java +++ b/src/test/java/com/networknt/schema/QuickStartTest.java @@ -3,18 +3,87 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.dialect.Dialects; import com.networknt.schema.serialization.JsonMapperFactory; /** * Quick start test. */ class QuickStartTest { + @Test + void addressExample() { + String schemaData = "{\r\n" + + " \"$id\": \"https://example.com/address.schema.json\",\r\n" + + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + + " \"description\": \"An address similar to http://microformats.org/wiki/h-card\",\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"postOfficeBox\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"extendedAddress\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"streetAddress\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"locality\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"region\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"postalCode\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"countryName\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"required\": [ \"locality\", \"region\", \"countryName\" ],\r\n" + + " \"dependentRequired\": {\r\n" + + " \"postOfficeBox\": [ \"streetAddress\" ],\r\n" + + " \"extendedAddress\": [ \"streetAddress\" ]\r\n" + + " }\r\n" + + "}\r\n" + + "\r\n" + + ""; + String instanceData = "{\r\n" + + " \"postOfficeBox\": \"123\",\r\n" + + " \"streetAddress\": \"456 Main St\",\r\n" + + " \"locality\": \"Cityville\",\r\n" + + " \"region\": \"State\",\r\n" + + " \"postalCode\": \"12345\",\r\n" + + " \"countryName\": \"Country\"\r\n" + + "}"; + Map schemas = new HashMap<>(); + schemas.put("https://example.com/address.schema.json", schemaData); + SchemaRegistry schemaRegistry = SchemaRegistry.withDialect(Dialects.getDraft202012(), + builder -> builder.schemas(schemas)); + Schema schema = schemaRegistry.getSchema(SchemaLocation.of("https://example.com/address.schema.json")); + List errors = schema.validate(instanceData, InputFormat.JSON); + assertEquals(0, errors.size()); + + String invalidInstanceData = "{\r\n" + + " \"postOfficeBox\": \"123\",\r\n" + + " \"streetAddress\": \"456 Main St\",\r\n" + + " \"region\": \"State\",\r\n" + + " \"postalCode\": \"12345\",\r\n" + + " \"countryName\": \"Country\"\r\n" + + "}"; + errors = schema.validate(invalidInstanceData, InputFormat.JSON); + assertEquals(1, errors.size()); + assertEquals("required", errors.get(0).getKeyword()); + } + @Test void schemaFromSchemaLocationMapping() { SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12, From 0f34bde9847c1147a2b7949473135a3e0e8b48f4 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:47:05 +0800 Subject: [PATCH 57/74] Rename ItemsValidator to ItemsLegacyValidator and ItemsValidator202012 to ItemsValidator --- .../networknt/schema/dialect/OpenApi30.java | 2 +- .../schema/keyword/ItemsLegacyValidator.java | 373 ++++++++++++++++++ .../schema/keyword/ItemsValidator.java | 366 +++++------------ .../schema/keyword/ItemsValidator202012.java | 197 --------- .../networknt/schema/keyword/KeywordType.java | 4 +- .../schema/vocabulary/Vocabulary.java | 4 +- .../schema/ItemsLegacyValidatorTest.java | 358 +++++++++++++++++ .../schema/ItemsValidator202012Test.java | 145 ------- .../networknt/schema/ItemsValidatorTest.java | 245 +----------- .../schema/walk/WalkListenerTest.java | 6 +- 10 files changed, 850 insertions(+), 850 deletions(-) create mode 100644 src/main/java/com/networknt/schema/keyword/ItemsLegacyValidator.java delete mode 100644 src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java create mode 100644 src/test/java/com/networknt/schema/ItemsLegacyValidatorTest.java delete mode 100644 src/test/java/com/networknt/schema/ItemsValidator202012Test.java diff --git a/src/main/java/com/networknt/schema/dialect/OpenApi30.java b/src/main/java/com/networknt/schema/dialect/OpenApi30.java index 28c17b057..62ef933e2 100644 --- a/src/main/java/com/networknt/schema/dialect/OpenApi30.java +++ b/src/main/java/com/networknt/schema/dialect/OpenApi30.java @@ -41,7 +41,7 @@ private static class Holder { KeywordType.TYPE, KeywordType.FORMAT, new AnnotationKeyword("description"), - KeywordType.ITEMS, + KeywordType.ITEMS_LEGACY, KeywordType.PROPERTIES, KeywordType.ADDITIONAL_PROPERTIES, new AnnotationKeyword("default"), diff --git a/src/main/java/com/networknt/schema/keyword/ItemsLegacyValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsLegacyValidator.java new file mode 100644 index 000000000..92ead9533 --- /dev/null +++ b/src/main/java/com/networknt/schema/keyword/ItemsLegacyValidator.java @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2016 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.keyword; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaRef; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SchemaContext; +import com.networknt.schema.annotation.Annotation; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.utils.SchemaRefs; + +import java.util.*; + +/** + * {@link KeywordValidator} for items Draft 4 to Draft 2019-09. + */ +public class ItemsLegacyValidator extends BaseKeywordValidator { + private static final String PROPERTY_ADDITIONAL_ITEMS = "additionalItems"; + + private final Schema schema; + private final List tupleSchema; + private final Boolean additionalItems; + private final Schema additionalSchema; + + private Boolean hasUnevaluatedItemsValidator = null; + + private final NodePath additionalItemsEvaluationPath; + private final SchemaLocation additionalItemsSchemaLocation; + private final JsonNode additionalItemsSchemaNode; + + public ItemsLegacyValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { + super(KeywordType.ITEMS_LEGACY, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + + Boolean additionalItems = null; + + Schema foundSchema = null; + Schema foundAdditionalSchema = null; + JsonNode additionalItemsSchemaNode = null; + + if (schemaNode.isObject() || schemaNode.isBoolean()) { + foundSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); + this.tupleSchema = Collections.emptyList(); + } else { + int i = 0; + this.tupleSchema = new ArrayList<>(schemaNode.size()); + for (JsonNode s : schemaNode) { + this.tupleSchema.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), + s, parentSchema)); + i++; + } + + JsonNode addItemNode = getParentSchema().getSchemaNode().get(PROPERTY_ADDITIONAL_ITEMS); + if (addItemNode != null) { + additionalItemsSchemaNode = addItemNode; + if (addItemNode.isBoolean()) { + additionalItems = addItemNode.asBoolean(); + } else if (addItemNode.isObject()) { + foundAdditionalSchema = schemaContext.newSchema( + parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS), + parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS), addItemNode, parentSchema); + } + } + } + this.additionalItems = additionalItems; + this.schema = foundSchema; + this.additionalSchema = foundAdditionalSchema; + this.additionalItemsEvaluationPath = parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsSchemaLocation = parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsSchemaNode = additionalItemsSchemaNode; + } + + @Override + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { + + + if (!node.isArray() && !this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { + // ignores non-arrays + return; + } + boolean collectAnnotations = collectAnnotations(); + + // Add items annotation + if (collectAnnotations || collectAnnotations(executionContext)) { + if (this.schema != null) { + // Applies to all + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(true).build()); + } else if (this.tupleSchema != null) { + // Tuples + int items = node.isArray() ? node.size() : 1; + int schemas = this.tupleSchema.size(); + if (items > schemas) { + // More items than schemas so the keyword only applied to the number of schemas + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(schemas).build()); + } else { + // Applies to all + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(true).build()); + } + } + } + + boolean hasAdditionalItem = false; + if (node.isArray()) { + int i = 0; + for (JsonNode n : node) { + if (doValidate(executionContext, i, n, rootNode, instanceLocation)) { + hasAdditionalItem = true; + } + i++; + } + } else { + if (doValidate(executionContext, 0, node, rootNode, instanceLocation)) { + hasAdditionalItem = true; + } + } + + if (hasAdditionalItem) { + if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.additionalItemsEvaluationPath) + .schemaLocation(this.additionalItemsSchemaLocation) + .keyword("additionalItems").value(true).build()); + } + } + } + + private boolean doValidate(ExecutionContext executionContext, int i, JsonNode node, + JsonNode rootNode, NodePath instanceLocation) { + boolean isAdditionalItem = false; + NodePath path = instanceLocation.append(i); + + if (this.schema != null) { + // validate with item schema (the whole array has the same item + // schema) + this.schema.validate(executionContext, node, rootNode, path); + } else if (this.tupleSchema != null) { + if (i < this.tupleSchema.size()) { + // validate against tuple schema + this.tupleSchema.get(i).validate(executionContext, node, rootNode, path); + } else { + if ((this.additionalItems != null && this.additionalItems) || this.additionalSchema != null) { + isAdditionalItem = true; + } + + if (this.additionalSchema != null) { + // validate against additional item schema + this.additionalSchema.validate(executionContext, node, rootNode, path); + } else if (this.additionalItems != null) { + if (this.additionalItems) { +// evaluatedItems.add(path); + } else { + // no additional item allowed, return error + executionContext.addError(error().instanceNode(rootNode).instanceLocation(instanceLocation) + .keyword("additionalItems") + .messageKey("additionalItems") + .evaluationPath(this.additionalItemsEvaluationPath) + .schemaLocation(this.additionalItemsSchemaLocation) + .schemaNode(this.additionalItemsSchemaNode) + .locale(executionContext.getExecutionConfig().getLocale()) + .index(i) + .arguments(i).build()); + } + } + } + } + return isAdditionalItem; + } + + @Override + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { + boolean collectAnnotations = collectAnnotations(); + + // Add items annotation + if (collectAnnotations || collectAnnotations(executionContext)) { + if (this.schema != null) { + // Applies to all + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(true).build()); + } else if (this.tupleSchema != null) { + // Tuples + int items = node.isArray() ? node.size() : 1; + int schemas = this.tupleSchema.size(); + if (items > schemas) { + // More items than schemas so the keyword only applied to the number of schemas + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(schemas).build()); + } else { + // Applies to all + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .keyword(getKeyword()).value(true).build()); + } + } + } + + if (this.schema != null) { + // Walk the schema. + if (node instanceof ArrayNode) { + int count = Math.max(1, node.size()); + ArrayNode arrayNode = (ArrayNode) node; + JsonNode defaultNode = null; + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + defaultNode = getDefaultNode(this.schema); + } + for (int i = 0; i < count; i++) { + JsonNode n = arrayNode.get(i); + if (n != null) { + if (n.isNull() && defaultNode != null) { + arrayNode.set(i, defaultNode); + n = defaultNode; + } + } + walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, KeywordType.ITEMS_LEGACY.getValue()); + } + } else { + walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, KeywordType.ITEMS_LEGACY.getValue()); + } + } + else if (this.tupleSchema != null) { + int prefixItems = this.tupleSchema.size(); + for (int i = 0; i < prefixItems; i++) { + // walk tuple schema + if (node instanceof ArrayNode) { + ArrayNode arrayNode = (ArrayNode) node; + JsonNode defaultNode = null; + JsonNode n = arrayNode.get(i); + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + defaultNode = getDefaultNode(this.tupleSchema.get(i)); + } + if (n != null) { + if (n.isNull() && defaultNode != null) { + arrayNode.set(i, defaultNode); + n = defaultNode; + } + } + walkSchema(executionContext, this.tupleSchema.get(i), n, rootNode, instanceLocation.append(i), + shouldValidateSchema, KeywordType.ITEMS_LEGACY.getValue()); + } else { + walkSchema(executionContext, this.tupleSchema.get(i), null, rootNode, instanceLocation.append(i), + shouldValidateSchema, KeywordType.ITEMS_LEGACY.getValue()); + } + } + if (this.additionalSchema != null) { + boolean hasAdditionalItem = false; + + int additionalItems = Math.max(1, (node != null ? node.size() : 0) - prefixItems); + for (int x = 0; x < additionalItems; x++) { + int i = x + prefixItems; + // walk additional item schema + if (node instanceof ArrayNode) { + ArrayNode arrayNode = (ArrayNode) node; + JsonNode defaultNode = null; + JsonNode n = arrayNode.get(i); + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { + defaultNode = getDefaultNode(this.additionalSchema); + } + if (n != null) { + if (n.isNull() && defaultNode != null) { + arrayNode.set(i, defaultNode); + n = defaultNode; + } + } + walkSchema(executionContext, this.additionalSchema, n, rootNode, instanceLocation.append(i), + shouldValidateSchema, PROPERTY_ADDITIONAL_ITEMS); + if (n != null) { + hasAdditionalItem = true; + } + } else { + walkSchema(executionContext, this.additionalSchema, null, rootNode, instanceLocation.append(i), + shouldValidateSchema, PROPERTY_ADDITIONAL_ITEMS); + } + } + + if (hasAdditionalItem) { + if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { + executionContext.getAnnotations() + .put(Annotation.builder().instanceLocation(instanceLocation) + .evaluationPath(this.additionalItemsEvaluationPath) + .schemaLocation(this.additionalItemsSchemaLocation) + .keyword("additionalItems").value(true).build()); + } + } + } + } + } + + private static JsonNode getDefaultNode(Schema schema) { + JsonNode result = schema.getSchemaNode().get("default"); + if (result == null) { + SchemaRef schemaRef = SchemaRefs.from(schema); + if (schemaRef != null) { + result = getDefaultNode(schemaRef.getSchema()); + } + } + return result; + } + + private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, + NodePath instanceLocation, boolean shouldValidateSchema, String keyword) { + boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, + node, rootNode, instanceLocation, walkSchema, this); + int currentErrors = executionContext.getErrors().size(); + if (executeWalk) { + walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); + } + executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners(executionContext, keyword, node, rootNode, + instanceLocation, walkSchema, this, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size())); + + } + + public List getTupleSchema() { + return this.tupleSchema; + } + + public Schema getSchema() { + return this.schema; + } + + private boolean collectAnnotations() { + return hasUnevaluatedItemsValidator(); + } + + private boolean hasUnevaluatedItemsValidator() { + if (this.hasUnevaluatedItemsValidator == null) { + this.hasUnevaluatedItemsValidator = hasAdjacentKeywordInEvaluationPath("unevaluatedItems"); + } + return hasUnevaluatedItemsValidator; + } + + @Override + public void preloadSchema() { + if (null != this.schema) { + this.schema.initializeValidators(); + } + preloadSchemas(this.tupleSchema); + if (null != this.additionalSchema) { + this.additionalSchema.initializeValidators(); + } + collectAnnotations(); // cache the flag + } +} diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java index 40693607d..644f2e62d 100644 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ItemsValidator.java @@ -27,95 +27,64 @@ import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.SchemaRefs; -import java.util.*; - /** - * {@link KeywordValidator} for items V4 to V2019-09. + * {@link KeywordValidator} for items from Draft 2012-12. */ public class ItemsValidator extends BaseKeywordValidator { - private static final String PROPERTY_ADDITIONAL_ITEMS = "additionalItems"; - private final Schema schema; - private final List tupleSchema; - private final Boolean additionalItems; - private final Schema additionalSchema; - + private final int prefixCount; + private final boolean additionalItems; + private Boolean hasUnevaluatedItemsValidator = null; - private final NodePath additionalItemsEvaluationPath; - private final SchemaLocation additionalItemsSchemaLocation; - private final JsonNode additionalItemsSchemaNode; - - public ItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(KeywordType.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + public ItemsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + Schema parentSchema, SchemaContext schemaContext) { + super(KeywordType.ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, + evaluationPath); - Boolean additionalItems = null; - - Schema foundSchema = null; - Schema foundAdditionalSchema = null; - JsonNode additionalItemsSchemaNode = null; + JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); + if (prefixItems instanceof ArrayNode) { + this.prefixCount = prefixItems.size(); + } else if (null == prefixItems) { + this.prefixCount = 0; + } else { + throw new IllegalArgumentException("The value of 'prefixItems' must be an array of JSON Schema."); + } if (schemaNode.isObject() || schemaNode.isBoolean()) { - foundSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); - this.tupleSchema = Collections.emptyList(); + this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { - int i = 0; - this.tupleSchema = new ArrayList<>(schemaNode.size()); - for (JsonNode s : schemaNode) { - this.tupleSchema.add(schemaContext.newSchema(schemaLocation.append(i), evaluationPath.append(i), - s, parentSchema)); - i++; - } - - JsonNode addItemNode = getParentSchema().getSchemaNode().get(PROPERTY_ADDITIONAL_ITEMS); - if (addItemNode != null) { - additionalItemsSchemaNode = addItemNode; - if (addItemNode.isBoolean()) { - additionalItems = addItemNode.asBoolean(); - } else if (addItemNode.isObject()) { - foundAdditionalSchema = schemaContext.newSchema( - parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS), - parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS), addItemNode, parentSchema); - } - } + throw new IllegalArgumentException("The value of 'items' MUST be a valid JSON Schema."); } - this.additionalItems = additionalItems; - this.schema = foundSchema; - this.additionalSchema = foundAdditionalSchema; - this.additionalItemsEvaluationPath = parentSchema.getEvaluationPath().append(PROPERTY_ADDITIONAL_ITEMS); - this.additionalItemsSchemaLocation = parentSchema.getSchemaLocation().append(PROPERTY_ADDITIONAL_ITEMS); - this.additionalItemsSchemaNode = additionalItemsSchemaNode; + + this.additionalItems = schemaNode.isBoolean() ? schemaNode.booleanValue() : true; } @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation) { - if (!node.isArray() && !this.schemaContext.getSchemaRegistryConfig().isTypeLoose()) { - // ignores non-arrays - return; - } - boolean collectAnnotations = collectAnnotations(); - - // Add items annotation - if (collectAnnotations || collectAnnotations(executionContext)) { - if (this.schema != null) { - // Applies to all - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(true).build()); - } else if (this.tupleSchema != null) { - // Tuples - int items = node.isArray() ? node.size() : 1; - int schemas = this.tupleSchema.size(); - if (items > schemas) { - // More items than schemas so the keyword only applied to the number of schemas - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(schemas).build()); + // ignores non-arrays + if (node.isArray()) { + boolean evaluated = false; + for (int i = this.prefixCount; i < node.size(); ++i) { + NodePath path = instanceLocation.append(i); + // validate with item schema (the whole array has the same item schema) + if (additionalItems) { + this.schema.validate(executionContext, node.get(i), rootNode, path); } else { + // This handles the case where "items": false as the boolean false schema doesn't + // generate a helpful message + int x = i; + executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) + .index(x).arguments(x).build()); + } + evaluated = true; + } + if (evaluated) { + if (collectAnnotations() || collectAnnotations(executionContext)) { // Applies to all executionContext.getAnnotations() .put(Annotation.builder().instanceLocation(instanceLocation) @@ -124,98 +93,33 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode } } } - - boolean hasAdditionalItem = false; - if (node.isArray()) { - int i = 0; - for (JsonNode n : node) { - if (doValidate(executionContext, i, n, rootNode, instanceLocation)) { - hasAdditionalItem = true; - } - i++; - } - } else { - if (doValidate(executionContext, 0, node, rootNode, instanceLocation)) { - hasAdditionalItem = true; - } - } - - if (hasAdditionalItem) { - if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.additionalItemsEvaluationPath) - .schemaLocation(this.additionalItemsSchemaLocation) - .keyword("additionalItems").value(true).build()); - } - } } - private boolean doValidate(ExecutionContext executionContext, int i, JsonNode node, - JsonNode rootNode, NodePath instanceLocation) { - boolean isAdditionalItem = false; - NodePath path = instanceLocation.append(i); - - if (this.schema != null) { - // validate with item schema (the whole array has the same item - // schema) - this.schema.validate(executionContext, node, rootNode, path); - } else if (this.tupleSchema != null) { - if (i < this.tupleSchema.size()) { - // validate against tuple schema - this.tupleSchema.get(i).validate(executionContext, node, rootNode, path); - } else { - if ((this.additionalItems != null && this.additionalItems) || this.additionalSchema != null) { - isAdditionalItem = true; + @Override + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation, boolean shouldValidateSchema) { + if (node instanceof ArrayNode) { + ArrayNode arrayNode = (ArrayNode) node; + JsonNode defaultNode = null; + if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() + && this.schema != null) { + defaultNode = getDefaultNode(this.schema); + } + boolean evaluated = false; + for (int i = this.prefixCount; i < node.size(); ++i) { + JsonNode n = node.get(i); + if (n.isNull() && defaultNode != null) { + arrayNode.set(i, defaultNode); + n = defaultNode; } - - if (this.additionalSchema != null) { - // validate against additional item schema - this.additionalSchema.validate(executionContext, node, rootNode, path); - } else if (this.additionalItems != null) { - if (this.additionalItems) { -// evaluatedItems.add(path); - } else { - // no additional item allowed, return error - executionContext.addError(error().instanceNode(rootNode).instanceLocation(instanceLocation) - .keyword("additionalItems") - .messageKey("additionalItems") - .evaluationPath(this.additionalItemsEvaluationPath) - .schemaLocation(this.additionalItemsSchemaLocation) - .schemaNode(this.additionalItemsSchemaNode) - .locale(executionContext.getExecutionConfig().getLocale()) - .index(i) - .arguments(i).build()); - } + // Walk the schema. + walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema); + if (n != null) { + evaluated = true; } } - } - return isAdditionalItem; - } - - @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, boolean shouldValidateSchema) { - boolean collectAnnotations = collectAnnotations(); - - // Add items annotation - if (collectAnnotations || collectAnnotations(executionContext)) { - if (this.schema != null) { - // Applies to all - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(true).build()); - } else if (this.tupleSchema != null) { - // Tuples - int items = node.isArray() ? node.size() : 1; - int schemas = this.tupleSchema.size(); - if (items > schemas) { - // More items than schemas so the keyword only applied to the number of schemas - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(schemas).build()); - } else { + if (evaluated) { + if (collectAnnotations() || collectAnnotations(executionContext)) { // Applies to all executionContext.getAnnotations() .put(Annotation.builder().instanceLocation(instanceLocation) @@ -223,96 +127,11 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root .keyword(getKeyword()).value(true).build()); } } - } - - if (this.schema != null) { - // Walk the schema. - if (node instanceof ArrayNode) { - int count = Math.max(1, node.size()); - ArrayNode arrayNode = (ArrayNode) node; - JsonNode defaultNode = null; - if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { - defaultNode = getDefaultNode(this.schema); - } - for (int i = 0; i < count; i++) { - JsonNode n = arrayNode.get(i); - if (n != null) { - if (n.isNull() && defaultNode != null) { - arrayNode.set(i, defaultNode); - n = defaultNode; - } - } - walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, KeywordType.ITEMS.getValue()); - } - } else { - walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(0), shouldValidateSchema, KeywordType.ITEMS.getValue()); - } - } - else if (this.tupleSchema != null) { - int prefixItems = this.tupleSchema.size(); - for (int i = 0; i < prefixItems; i++) { - // walk tuple schema - if (node instanceof ArrayNode) { - ArrayNode arrayNode = (ArrayNode) node; - JsonNode defaultNode = null; - JsonNode n = arrayNode.get(i); - if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { - defaultNode = getDefaultNode(this.tupleSchema.get(i)); - } - if (n != null) { - if (n.isNull() && defaultNode != null) { - arrayNode.set(i, defaultNode); - n = defaultNode; - } - } - walkSchema(executionContext, this.tupleSchema.get(i), n, rootNode, instanceLocation.append(i), - shouldValidateSchema, KeywordType.ITEMS.getValue()); - } else { - walkSchema(executionContext, this.tupleSchema.get(i), null, rootNode, instanceLocation.append(i), - shouldValidateSchema, KeywordType.ITEMS.getValue()); - } - } - if (this.additionalSchema != null) { - boolean hasAdditionalItem = false; - - int additionalItems = Math.max(1, (node != null ? node.size() : 0) - prefixItems); - for (int x = 0; x < additionalItems; x++) { - int i = x + prefixItems; - // walk additional item schema - if (node instanceof ArrayNode) { - ArrayNode arrayNode = (ArrayNode) node; - JsonNode defaultNode = null; - JsonNode n = arrayNode.get(i); - if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults()) { - defaultNode = getDefaultNode(this.additionalSchema); - } - if (n != null) { - if (n.isNull() && defaultNode != null) { - arrayNode.set(i, defaultNode); - n = defaultNode; - } - } - walkSchema(executionContext, this.additionalSchema, n, rootNode, instanceLocation.append(i), - shouldValidateSchema, PROPERTY_ADDITIONAL_ITEMS); - if (n != null) { - hasAdditionalItem = true; - } - } else { - walkSchema(executionContext, this.additionalSchema, null, rootNode, instanceLocation.append(i), - shouldValidateSchema, PROPERTY_ADDITIONAL_ITEMS); - } - } - - if (hasAdditionalItem) { - if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.additionalItemsEvaluationPath) - .schemaLocation(this.additionalItemsSchemaLocation) - .keyword("additionalItems").value(true).build()); - } - } - } + } else { + // If the node is not an ArrayNode, e.g. ObjectNode or null then the instance is null. + // The instance location starts at the end of the prefix count. + walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(this.prefixCount), + shouldValidateSchema); } } @@ -328,26 +147,42 @@ private static JsonNode getDefaultNode(Schema schema) { } private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, - NodePath instanceLocation, boolean shouldValidateSchema, String keyword) { - boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, keyword, - node, rootNode, instanceLocation, walkSchema, this); + NodePath instanceLocation, boolean shouldValidateSchema) { + //@formatter:off + boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( + executionContext, + KeywordType.ITEMS_LEGACY.getValue(), + node, + rootNode, + instanceLocation, + walkSchema, this + ); int currentErrors = executionContext.getErrors().size(); if (executeWalk) { walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); } - executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners(executionContext, keyword, node, rootNode, - instanceLocation, walkSchema, this, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size())); - - } - - public List getTupleSchema() { - return this.tupleSchema; + executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( + executionContext, + KeywordType.ITEMS_LEGACY.getValue(), + node, + rootNode, + instanceLocation, + walkSchema, + this, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size()) + ); + //@formatter:on } public Schema getSchema() { return this.schema; } - + + @Override + public void preloadSchema() { + this.schema.initializeValidators(); + collectAnnotations(); // cache the flag + } + private boolean collectAnnotations() { return hasUnevaluatedItemsValidator(); } @@ -359,15 +194,4 @@ private boolean hasUnevaluatedItemsValidator() { return hasUnevaluatedItemsValidator; } - @Override - public void preloadSchema() { - if (null != this.schema) { - this.schema.initializeValidators(); - } - preloadSchemas(this.tupleSchema); - if (null != this.additionalSchema) { - this.additionalSchema.initializeValidators(); - } - collectAnnotations(); // cache the flag - } } diff --git a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java b/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java deleted file mode 100644 index 99289a180..000000000 --- a/src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2016 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.keyword; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.networknt.schema.ExecutionContext; -import com.networknt.schema.Schema; -import com.networknt.schema.SchemaRef; -import com.networknt.schema.SchemaLocation; -import com.networknt.schema.SchemaContext; -import com.networknt.schema.annotation.Annotation; -import com.networknt.schema.path.NodePath; -import com.networknt.schema.utils.SchemaRefs; - -/** - * {@link KeywordValidator} for items from V2012-12. - */ -public class ItemsValidator202012 extends BaseKeywordValidator { - private final Schema schema; - private final int prefixCount; - private final boolean additionalItems; - - private Boolean hasUnevaluatedItemsValidator = null; - - public ItemsValidator202012(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, - Schema parentSchema, SchemaContext schemaContext) { - super(KeywordType.ITEMS_202012, schemaNode, schemaLocation, parentSchema, schemaContext, - evaluationPath); - - JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); - if (prefixItems instanceof ArrayNode) { - this.prefixCount = prefixItems.size(); - } else if (null == prefixItems) { - this.prefixCount = 0; - } else { - throw new IllegalArgumentException("The value of 'prefixItems' must be an array of JSON Schema."); - } - - if (schemaNode.isObject() || schemaNode.isBoolean()) { - this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); - } else { - throw new IllegalArgumentException("The value of 'items' MUST be a valid JSON Schema."); - } - - this.additionalItems = schemaNode.isBoolean() ? schemaNode.booleanValue() : true; - } - - @Override - public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - NodePath instanceLocation) { - - - // ignores non-arrays - if (node.isArray()) { - boolean evaluated = false; - for (int i = this.prefixCount; i < node.size(); ++i) { - NodePath path = instanceLocation.append(i); - // validate with item schema (the whole array has the same item schema) - if (additionalItems) { - this.schema.validate(executionContext, node.get(i), rootNode, path); - } else { - // This handles the case where "items": false as the boolean false schema doesn't - // generate a helpful message - int x = i; - executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) - .locale(executionContext.getExecutionConfig().getLocale()) - .index(x).arguments(x).build()); - } - evaluated = true; - } - if (evaluated) { - if (collectAnnotations() || collectAnnotations(executionContext)) { - // Applies to all - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(true).build()); - } - } - } - } - - @Override - public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, - NodePath instanceLocation, boolean shouldValidateSchema) { - if (node instanceof ArrayNode) { - ArrayNode arrayNode = (ArrayNode) node; - JsonNode defaultNode = null; - if (executionContext.getWalkConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() - && this.schema != null) { - defaultNode = getDefaultNode(this.schema); - } - boolean evaluated = false; - for (int i = this.prefixCount; i < node.size(); ++i) { - JsonNode n = node.get(i); - if (n.isNull() && defaultNode != null) { - arrayNode.set(i, defaultNode); - n = defaultNode; - } - // Walk the schema. - walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema); - if (n != null) { - evaluated = true; - } - } - if (evaluated) { - if (collectAnnotations() || collectAnnotations(executionContext)) { - // Applies to all - executionContext.getAnnotations() - .put(Annotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) - .keyword(getKeyword()).value(true).build()); - } - } - } else { - // If the node is not an ArrayNode, e.g. ObjectNode or null then the instance is null. - // The instance location starts at the end of the prefix count. - walkSchema(executionContext, this.schema, null, rootNode, instanceLocation.append(this.prefixCount), - shouldValidateSchema); - } - } - - private static JsonNode getDefaultNode(Schema schema) { - JsonNode result = schema.getSchemaNode().get("default"); - if (result == null) { - SchemaRef schemaRef = SchemaRefs.from(schema); - if (schemaRef != null) { - result = getDefaultNode(schemaRef.getSchema()); - } - } - return result; - } - - private void walkSchema(ExecutionContext executionContext, Schema walkSchema, JsonNode node, JsonNode rootNode, - NodePath instanceLocation, boolean shouldValidateSchema) { - //@formatter:off - boolean executeWalk = executionContext.getWalkConfig().getItemWalkListenerRunner().runPreWalkListeners( - executionContext, - KeywordType.ITEMS.getValue(), - node, - rootNode, - instanceLocation, - walkSchema, this - ); - int currentErrors = executionContext.getErrors().size(); - if (executeWalk) { - walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema); - } - executionContext.getWalkConfig().getItemWalkListenerRunner().runPostWalkListeners( - executionContext, - KeywordType.ITEMS.getValue(), - node, - rootNode, - instanceLocation, - walkSchema, - this, executionContext.getErrors().subList(currentErrors, executionContext.getErrors().size()) - ); - //@formatter:on - } - - public Schema getSchema() { - return this.schema; - } - - @Override - public void preloadSchema() { - this.schema.initializeValidators(); - collectAnnotations(); // cache the flag - } - - private boolean collectAnnotations() { - return hasUnevaluatedItemsValidator(); - } - - private boolean hasUnevaluatedItemsValidator() { - if (this.hasUnevaluatedItemsValidator == null) { - this.hasUnevaluatedItemsValidator = hasAdjacentKeywordInEvaluationPath("unevaluatedItems"); - } - return hasUnevaluatedItemsValidator; - } - -} diff --git a/src/main/java/com/networknt/schema/keyword/KeywordType.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java index 5446cce6c..ea57df4c8 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordType.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -59,8 +59,8 @@ public enum KeywordType implements Keyword { }, ID("id", null, SpecificationVersionRange.AllVersions), IF_THEN_ELSE("if", IfValidator::new, SpecificationVersionRange.V7), - ITEMS_202012("items", ItemsValidator202012::new, SpecificationVersionRange.None), - ITEMS("items", ItemsValidator::new, SpecificationVersionRange.MaxV7), + ITEMS("items", ItemsValidator::new, SpecificationVersionRange.None), + ITEMS_LEGACY("items", ItemsLegacyValidator::new, SpecificationVersionRange.MaxV7), MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, SpecificationVersionRange.None), MAX_ITEMS("maxItems", MaxItemsValidator::new, SpecificationVersionRange.MaxV7), MAX_LENGTH("maxLength", MaxLengthValidator::new, SpecificationVersionRange.MaxV7), diff --git a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java index b3f4e31f1..9a43b2a00 100644 --- a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java @@ -40,7 +40,7 @@ KeywordType.REF, KeywordType.RECURSIVE_REF, new NonValidationKeyword("$recursive new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"), - KeywordType.UNEVALUATED_ITEMS, KeywordType.ITEMS, KeywordType.CONTAINS, + KeywordType.UNEVALUATED_ITEMS, KeywordType.ITEMS_LEGACY, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, KeywordType.UNEVALUATED_PROPERTIES, KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), @@ -73,7 +73,7 @@ KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("t new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs")); public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary( "https://json-schema.org/draft/2020-12/vocab/applicator", KeywordType.PREFIX_ITEMS, - KeywordType.ITEMS_202012, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, + KeywordType.ITEMS, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF, diff --git a/src/test/java/com/networknt/schema/ItemsLegacyValidatorTest.java b/src/test/java/com/networknt/schema/ItemsLegacyValidatorTest.java new file mode 100644 index 000000000..4c90f6ddb --- /dev/null +++ b/src/test/java/com/networknt/schema/ItemsLegacyValidatorTest.java @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.path.NodePath; +import com.networknt.schema.serialization.JsonMapperFactory; +import com.networknt.schema.walk.ApplyDefaultsStrategy; +import com.networknt.schema.walk.ItemWalkListenerRunner; +import com.networknt.schema.walk.WalkListener; +import com.networknt.schema.walk.WalkConfig; +import com.networknt.schema.walk.WalkEvent; +import com.networknt.schema.walk.WalkFlow; + +/** + * ItemsLegacyValidatorTest. + */ +class ItemsLegacyValidatorTest { + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": {\"type\": \"integer\"}" + + "}"; + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + String inputData = "[1, \"x\"]"; + List messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + Error message = messages.iterator().next(); + assertEquals("/items/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); + assertEquals("/1", message.getInstanceLocation().toString()); + assertEquals("\"integer\"", message.getSchemaNode().toString()); + assertEquals("\"x\"", message.getInstanceNode().toString()); + assertEquals("/1: string found, integer expected", message.toString()); + assertNull(message.getProperty()); + } + + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageAdditionalItemsInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": [{}]," + + " \"additionalItems\": {\"type\": \"integer\"}" + + "}"; + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + String inputData = "[ null, 2, 3, \"foo\" ]"; + List messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + Error message = messages.iterator().next(); + assertEquals("/additionalItems/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalItems/type", message.getSchemaLocation().toString()); + assertEquals("/3", message.getInstanceLocation().toString()); + assertEquals("\"integer\"", message.getSchemaNode().toString()); + assertEquals("\"foo\"", message.getInstanceNode().toString()); + assertEquals("/3: string found, integer expected", message.toString()); + assertNull(message.getProperty()); + } + + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageAdditionalItemsFalseInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": [{}]," + + " \"additionalItems\": false" + + "}"; + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + String inputData = "[ null, 2, 3, \"foo\" ]"; + List messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + Error message = messages.iterator().next(); + assertEquals("/additionalItems", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalItems", message.getSchemaLocation().toString()); + assertEquals("", message.getInstanceLocation().toString()); + assertEquals("false", message.getSchemaNode().toString()); + assertEquals("[null,2,3,\"foo\"]", message.getInstanceNode().toString()); + assertEquals(": index '1' is not defined in the schema and the schema does not allow additional items", message.toString()); + assertNull(message.getProperty()); + } + + @Test + void walk() { + String schemaData = "{\r\n" + + " \"items\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + "}"; + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } + + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext() + .getCollectorContext() + .getData() + .computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + Result result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + assertTrue(result.getErrors().isEmpty()); + + @SuppressWarnings("unchecked") + List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + assertEquals(3, items.size()); + assertEquals("/0", items.get(0).getInstanceLocation().toString()); + assertEquals("/1", items.get(1).getInstanceLocation().toString()); + assertEquals("/2", items.get(2).getInstanceLocation().toString()); + } + + @Test + void walkNull() { + String schemaData = "{\r\n" + + " \"items\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + "}"; + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } + + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext() + .getCollectorContext() + .getData() + .computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + assertTrue(result.getErrors().isEmpty()); + + @SuppressWarnings("unchecked") + List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + assertEquals(1, items.size()); + assertEquals("/0", items.get(0).getInstanceLocation().toString()); + } + + @Test + void walkNullTupleItemsAdditional() { + String schemaData = "{\r\n" + + " \"items\": [\r\n" + + " {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n," + + " {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"additionalItems\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + "}"; + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } + + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext() + .getCollectorContext() + .getData() + .computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + assertTrue(result.getErrors().isEmpty()); + + @SuppressWarnings("unchecked") + List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + assertEquals(3, items.size()); + assertEquals("/0", items.get(0).getInstanceLocation().toString()); + assertEquals("items", items.get(0).getKeyword()); + assertNull(items.get(0).getInstanceNode()); + assertEquals("/1", items.get(1).getInstanceLocation().toString()); + assertEquals("items", items.get(1).getKeyword()); + assertNull(items.get(1).getInstanceNode()); + assertEquals("/2", items.get(2).getInstanceLocation().toString()); + assertEquals("additionalItems", items.get(2).getKeyword()); + assertNull(items.get(2).getInstanceNode()); + } + + @Test + void walkTupleItemsAdditional() throws JsonProcessingException { + String schemaData = "{\r\n" + + " \"items\": [\r\n" + + " {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n," + + " {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"additionalItems\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + "}"; + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } + + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext() + .getCollectorContext() + .getData() + .computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); + Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + assertTrue(result.getErrors().isEmpty()); + + @SuppressWarnings("unchecked") + List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + assertEquals(3, items.size()); + assertEquals("/0", items.get(0).getInstanceLocation().toString()); + assertEquals("items", items.get(0).getKeyword()); + assertEquals("hello", items.get(0).getInstanceNode().textValue()); + assertEquals("/1", items.get(1).getInstanceLocation().toString()); + assertEquals("items", items.get(1).getKeyword()); + assertNull(items.get(1).getInstanceNode()); + assertEquals("/2", items.get(2).getInstanceLocation().toString()); + assertEquals("additionalItems", items.get(2).getKeyword()); + assertNull(items.get(2).getInstanceNode()); + } + + @Test + void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { + String schemaData = "{\r\n" + + " \"items\": [\r\n" + + " {\r\n" + + " \"type\": \"string\",\r\n" + + " \"default\": \"1\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"type\": \"integer\",\r\n" + + " \"default\": 2\r\n" + + " }\r\n" + + " ],\r\n" + + " \"additionalItems\": {\r\n" + + " \"type\": \"string\",\r\n" + + " \"default\": \"additional\"\r\n" + + " }\r\n" + + "}"; + + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() + .itemWalkListener(new WalkListener() { + @Override + public WalkFlow onWalkStart(WalkEvent walkEvent) { + return WalkFlow.CONTINUE; + } + + @Override + public void onWalkEnd(WalkEvent walkEvent, List errors) { + @SuppressWarnings("unchecked") + List items = (List) walkEvent.getExecutionContext().getCollectorContext() + .getData().computeIfAbsent("items", key -> new ArrayList()); + items.add(walkEvent); + } + }).build(); + WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) + .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + Schema schema = factory.getSchema(schemaData); + JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); + Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); + assertTrue(result.getErrors().isEmpty()); + + @SuppressWarnings("unchecked") + List items = (List) result.getExecutionContext().getCollectorContext().get("items"); + assertEquals(4, items.size()); + assertEquals("/0", items.get(0).getInstanceLocation().toString()); + assertEquals("items", items.get(0).getKeyword()); + assertEquals("1", items.get(0).getInstanceNode().textValue()); + assertEquals("/1", items.get(1).getInstanceLocation().toString()); + assertEquals("items", items.get(1).getKeyword()); + assertEquals(2, items.get(1).getInstanceNode().intValue()); + assertEquals("/2", items.get(2).getInstanceLocation().toString()); + assertEquals("additionalItems", items.get(2).getKeyword()); + assertEquals("additional", items.get(2).getInstanceNode().asText()); + assertEquals("/3", items.get(3).getInstanceLocation().toString()); + assertEquals("additionalItems", items.get(3).getKeyword()); + assertEquals("additional", items.get(3).getInstanceNode().asText()); + } +} diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java deleted file mode 100644 index babd08fd5..000000000 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.networknt.schema; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import com.networknt.schema.path.NodePath; -import com.networknt.schema.walk.ItemWalkListenerRunner; -import com.networknt.schema.walk.WalkListener; -import com.networknt.schema.walk.WalkConfig; -import com.networknt.schema.walk.WalkEvent; -import com.networknt.schema.walk.WalkFlow; - -/** - * ItemsValidatorTest. - */ -class ItemsValidator202012Test { - /** - * Tests that the message contains the correct values when there are invalid - * items. - */ - @Test - void messageInvalid() { - String schemaData = "{\r\n" - + " \"$id\": \"https://www.example.org/schema\",\r\n" - + " \"items\": {\"type\": \"integer\"}" - + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); - Schema schema = factory.getSchema(schemaData); - String inputData = "[1, \"x\"]"; - List messages = schema.validate(inputData, InputFormat.JSON); - assertFalse(messages.isEmpty()); - Error message = messages.iterator().next(); - assertEquals("/items/type", message.getEvaluationPath().toString()); - assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); - assertEquals("/1", message.getInstanceLocation().toString()); - assertEquals("\"integer\"", message.getSchemaNode().toString()); - assertEquals("\"x\"", message.getInstanceNode().toString()); - assertEquals("/1: string found, integer expected", message.toString()); - assertNull(message.getProperty()); - } - - @Test - void walkNull() { - String schemaData = "{\r\n" - + " \"items\": {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n" - + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } - - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getData() - .computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }).build(); - WalkConfig walkConfig = WalkConfig.builder() - .itemWalkListenerRunner(itemWalkListenerRunner) - .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); - Schema schema = factory.getSchema(schemaData); - Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); - assertTrue(result.getErrors().isEmpty()); - - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(1, items.size()); - assertEquals("/0", items.get(0).getInstanceLocation().toString()); - } - - @Test - void walkNullPrefixItems() { - String schemaData = "{\r\n" - + " \"prefixItems\": [\r\n" - + " {\r\n" - + " \"type\": \"integer\"\r\n" - + " }\r\n" - + " ],\r\n" - + " \"items\": {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n" - + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } - - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getData() - .computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }).build(); - WalkConfig walkConfig = WalkConfig.builder() - .itemWalkListenerRunner(itemWalkListenerRunner) - .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); - Schema schema = factory.getSchema(schemaData); - Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); - assertTrue(result.getErrors().isEmpty()); - - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(2, items.size()); - assertEquals("/0", items.get(0).getInstanceLocation().toString()); - assertEquals("prefixItems", items.get(0).getKeyword()); - assertEquals("/1", items.get(1).getInstanceLocation().toString()); - assertEquals("items", items.get(1).getKeyword()); - } -} diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 391178af4..75d1bed58 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -25,11 +25,7 @@ import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.path.NodePath; -import com.networknt.schema.serialization.JsonMapperFactory; -import com.networknt.schema.walk.ApplyDefaultsStrategy; import com.networknt.schema.walk.ItemWalkListenerRunner; import com.networknt.schema.walk.WalkListener; import com.networknt.schema.walk.WalkConfig; @@ -50,7 +46,7 @@ void messageInvalid() { + " \"$id\": \"https://www.example.org/schema\",\r\n" + " \"items\": {\"type\": \"integer\"}" + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); String inputData = "[1, \"x\"]"; List messages = schema.validate(inputData, InputFormat.JSON); @@ -65,96 +61,6 @@ void messageInvalid() { assertNull(message.getProperty()); } - /** - * Tests that the message contains the correct values when there are invalid - * items. - */ - @Test - void messageAdditionalItemsInvalid() { - String schemaData = "{\r\n" - + " \"$id\": \"https://www.example.org/schema\",\r\n" - + " \"items\": [{}]," - + " \"additionalItems\": {\"type\": \"integer\"}" - + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); - Schema schema = factory.getSchema(schemaData); - String inputData = "[ null, 2, 3, \"foo\" ]"; - List messages = schema.validate(inputData, InputFormat.JSON); - assertFalse(messages.isEmpty()); - Error message = messages.iterator().next(); - assertEquals("/additionalItems/type", message.getEvaluationPath().toString()); - assertEquals("https://www.example.org/schema#/additionalItems/type", message.getSchemaLocation().toString()); - assertEquals("/3", message.getInstanceLocation().toString()); - assertEquals("\"integer\"", message.getSchemaNode().toString()); - assertEquals("\"foo\"", message.getInstanceNode().toString()); - assertEquals("/3: string found, integer expected", message.toString()); - assertNull(message.getProperty()); - } - - /** - * Tests that the message contains the correct values when there are invalid - * items. - */ - @Test - void messageAdditionalItemsFalseInvalid() { - String schemaData = "{\r\n" - + " \"$id\": \"https://www.example.org/schema\",\r\n" - + " \"items\": [{}]," - + " \"additionalItems\": false" - + "}"; - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); - Schema schema = factory.getSchema(schemaData); - String inputData = "[ null, 2, 3, \"foo\" ]"; - List messages = schema.validate(inputData, InputFormat.JSON); - assertFalse(messages.isEmpty()); - Error message = messages.iterator().next(); - assertEquals("/additionalItems", message.getEvaluationPath().toString()); - assertEquals("https://www.example.org/schema#/additionalItems", message.getSchemaLocation().toString()); - assertEquals("", message.getInstanceLocation().toString()); - assertEquals("false", message.getSchemaNode().toString()); - assertEquals("[null,2,3,\"foo\"]", message.getInstanceNode().toString()); - assertEquals(": index '1' is not defined in the schema and the schema does not allow additional items", message.toString()); - assertNull(message.getProperty()); - } - - @Test - void walk() { - String schemaData = "{\r\n" - + " \"items\": {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n" - + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() - .itemWalkListener(new WalkListener() { - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } - - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getData() - .computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }).build(); - WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); - Schema schema = factory.getSchema(schemaData); - Result result = schema.walk("[\"the\",\"quick\",\"brown\"]", InputFormat.JSON, true, executionContext -> executionContext.setWalkConfig(walkConfig)); - assertTrue(result.getErrors().isEmpty()); - - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(3, items.size()); - assertEquals("/0", items.get(0).getInstanceLocation().toString()); - assertEquals("/1", items.get(1).getInstanceLocation().toString()); - assertEquals("/2", items.get(2).getInstanceLocation().toString()); - } - @Test void walkNull() { String schemaData = "{\r\n" @@ -162,8 +68,7 @@ void walkNull() { + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() - .itemWalkListener(new WalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -179,8 +84,10 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); @@ -192,22 +99,18 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { } @Test - void walkNullTupleItemsAdditional() { + void walkNullPrefixItems() { String schemaData = "{\r\n" - + " \"items\": [\r\n" - + " {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n," + + " \"prefixItems\": [\r\n" + " {\r\n" + " \"type\": \"integer\"\r\n" + " }\r\n" + " ],\r\n" - + " \"additionalItems\": {\r\n" + + " \"items\": {\r\n" + " \"type\": \"string\"\r\n" + " }\r\n" + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() - .itemWalkListener(new WalkListener() { + ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder().itemWalkListener(new WalkListener() { @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { return WalkFlow.CONTINUE; @@ -223,136 +126,20 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { items.add(walkEvent); } }).build(); - WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); + WalkConfig walkConfig = WalkConfig.builder() + .itemWalkListenerRunner(itemWalkListenerRunner) + .build(); + SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); Schema schema = factory.getSchema(schemaData); Result result = schema.walk(null, true, executionContext -> executionContext.setWalkConfig(walkConfig)); assertTrue(result.getErrors().isEmpty()); - - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(3, items.size()); - assertEquals("/0", items.get(0).getInstanceLocation().toString()); - assertEquals("items", items.get(0).getKeyword()); - assertNull(items.get(0).getInstanceNode()); - assertEquals("/1", items.get(1).getInstanceLocation().toString()); - assertEquals("items", items.get(1).getKeyword()); - assertNull(items.get(1).getInstanceNode()); - assertEquals("/2", items.get(2).getInstanceLocation().toString()); - assertEquals("additionalItems", items.get(2).getKeyword()); - assertNull(items.get(2).getInstanceNode()); - } - - @Test - void walkTupleItemsAdditional() throws JsonProcessingException { - String schemaData = "{\r\n" - + " \"items\": [\r\n" - + " {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n," - + " {\r\n" - + " \"type\": \"integer\"\r\n" - + " }\r\n" - + " ],\r\n" - + " \"additionalItems\": {\r\n" - + " \"type\": \"string\"\r\n" - + " }\r\n" - + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() - .itemWalkListener(new WalkListener() { - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } - - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext() - .getCollectorContext() - .getData() - .computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }).build(); - WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) - .build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); - Schema schema = factory.getSchema(schemaData); - JsonNode input = JsonMapperFactory.getInstance().readTree("[\"hello\"]"); - Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); - assertTrue(result.getErrors().isEmpty()); - - @SuppressWarnings("unchecked") - List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(3, items.size()); - assertEquals("/0", items.get(0).getInstanceLocation().toString()); - assertEquals("items", items.get(0).getKeyword()); - assertEquals("hello", items.get(0).getInstanceNode().textValue()); - assertEquals("/1", items.get(1).getInstanceLocation().toString()); - assertEquals("items", items.get(1).getKeyword()); - assertNull(items.get(1).getInstanceNode()); - assertEquals("/2", items.get(2).getInstanceLocation().toString()); - assertEquals("additionalItems", items.get(2).getKeyword()); - assertNull(items.get(2).getInstanceNode()); - } - - @Test - void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { - String schemaData = "{\r\n" - + " \"items\": [\r\n" - + " {\r\n" - + " \"type\": \"string\",\r\n" - + " \"default\": \"1\"\r\n" - + " },\r\n" - + " {\r\n" - + " \"type\": \"integer\",\r\n" - + " \"default\": 2\r\n" - + " }\r\n" - + " ],\r\n" - + " \"additionalItems\": {\r\n" - + " \"type\": \"string\",\r\n" - + " \"default\": \"additional\"\r\n" - + " }\r\n" - + "}"; - ItemWalkListenerRunner itemWalkListenerRunner = ItemWalkListenerRunner.builder() - .itemWalkListener(new WalkListener() { - @Override - public WalkFlow onWalkStart(WalkEvent walkEvent) { - return WalkFlow.CONTINUE; - } - - @Override - public void onWalkEnd(WalkEvent walkEvent, List errors) { - @SuppressWarnings("unchecked") - List items = (List) walkEvent.getExecutionContext().getCollectorContext() - .getData().computeIfAbsent("items", key -> new ArrayList()); - items.add(walkEvent); - } - }).build(); - WalkConfig walkConfig = WalkConfig.builder().itemWalkListenerRunner(itemWalkListenerRunner) - .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, true, true)).build(); - SchemaRegistry factory = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2019_09); - Schema schema = factory.getSchema(schemaData); - JsonNode input = JsonMapperFactory.getInstance().readTree("[null, null, null, null]"); - Result result = schema.walk(input, true, executionContext -> executionContext.setWalkConfig(walkConfig)); - assertTrue(result.getErrors().isEmpty()); - @SuppressWarnings("unchecked") List items = (List) result.getExecutionContext().getCollectorContext().get("items"); - assertEquals(4, items.size()); + assertEquals(2, items.size()); assertEquals("/0", items.get(0).getInstanceLocation().toString()); - assertEquals("items", items.get(0).getKeyword()); - assertEquals("1", items.get(0).getInstanceNode().textValue()); + assertEquals("prefixItems", items.get(0).getKeyword()); assertEquals("/1", items.get(1).getInstanceLocation().toString()); assertEquals("items", items.get(1).getKeyword()); - assertEquals(2, items.get(1).getInstanceNode().intValue()); - assertEquals("/2", items.get(2).getInstanceLocation().toString()); - assertEquals("additionalItems", items.get(2).getKeyword()); - assertEquals("additional", items.get(2).getInstanceNode().asText()); - assertEquals("/3", items.get(3).getInstanceLocation().toString()); - assertEquals("additionalItems", items.get(3).getKeyword()); - assertEquals("additional", items.get(3).getInstanceNode().asText()); } } diff --git a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java index 02c5e0ee5..c3efecda7 100644 --- a/src/test/java/com/networknt/schema/walk/WalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/WalkListenerTest.java @@ -40,8 +40,8 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.SpecificationVersion; import com.networknt.schema.dialect.DialectId; +import com.networknt.schema.keyword.ItemsLegacyValidator; import com.networknt.schema.keyword.ItemsValidator; -import com.networknt.schema.keyword.ItemsValidator202012; import com.networknt.schema.keyword.PropertiesValidator; import com.networknt.schema.path.NodePath; import com.networknt.schema.keyword.KeywordType; @@ -297,7 +297,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(2, items.size()); assertEquals("items", items.get(0).getValidator().getKeyword()); - assertInstanceOf(ItemsValidator.class, items.get(0).getValidator()); + assertInstanceOf(ItemsLegacyValidator.class, items.get(0).getValidator()); assertEquals("/tags/0", items.get(0).getInstanceLocation().toString()); assertEquals("/properties/tags/items", items.get(0).getSchema().getEvaluationPath().toString()); @@ -373,7 +373,7 @@ public void onWalkEnd(WalkEvent walkEvent, List errors) { List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(2, items.size()); assertEquals("items", items.get(0).getValidator().getKeyword()); - assertInstanceOf(ItemsValidator202012.class, items.get(0).getValidator()); + assertInstanceOf(ItemsValidator.class, items.get(0).getValidator()); assertEquals("/tags/0", items.get(0).getInstanceLocation().toString()); assertEquals("/properties/tags/items", items.get(0).getSchema().getEvaluationPath().toString()); From 9e5f9c4fcf445a1171fa059ab75f12798907f26d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:53:36 +0800 Subject: [PATCH 58/74] Refactor StringUtils and StringChecker into Strings --- src/main/java/com/networknt/schema/Error.java | 4 +- .../com/networknt/schema/dialect/Dialect.java | 6 +- .../networknt/schema/utils/JsonNodeUtil.java | 8 +-- .../networknt/schema/utils/StringUtils.java | 32 --------- .../{StringChecker.java => Strings.java} | 71 +++++++++++++------ .../StringsTest.java} | 9 ++- 6 files changed, 61 insertions(+), 69 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/utils/StringUtils.java rename src/main/java/com/networknt/schema/utils/{StringChecker.java => Strings.java} (53%) rename src/test/java/com/networknt/schema/{StringCheckerTest.java => utils/StringsTest.java} (88%) diff --git a/src/main/java/com/networknt/schema/Error.java b/src/main/java/com/networknt/schema/Error.java index 5d71aa77b..6e117af76 100644 --- a/src/main/java/com/networknt/schema/Error.java +++ b/src/main/java/com/networknt/schema/Error.java @@ -26,7 +26,7 @@ import com.networknt.schema.i18n.MessageFormatter; import com.networknt.schema.path.NodePath; import com.networknt.schema.utils.CachingSupplier; -import com.networknt.schema.utils.StringUtils; +import com.networknt.schema.utils.Strings; import java.text.MessageFormat; import java.util.Arrays; @@ -371,7 +371,7 @@ public Error build() { Supplier messageSupplier = this.messageSupplier; String messageKey = this.messageKey; - if (StringUtils.isNotBlank(this.message)) { + if (!Strings.isBlank(this.message)) { messageKey = this.message; if (this.message.contains("{")) { messageSupplier = new CachingSupplier<>(() -> { diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 4d9ac99e2..e45de2ac6 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -32,7 +32,7 @@ import com.networknt.schema.keyword.UnknownKeywordFactory; import com.networknt.schema.path.NodePath; import com.networknt.schema.keyword.KeywordType; -import com.networknt.schema.utils.StringUtils; +import com.networknt.schema.utils.Strings; import com.networknt.schema.vocabulary.Vocabularies; import com.networknt.schema.vocabulary.Vocabulary; import com.networknt.schema.vocabulary.VocabularyFactory; @@ -326,10 +326,10 @@ public Dialect build() { private final Builder builder; Dialect(String dialectId, String idKeyword, Map keywords, Map vocabularies, SpecificationVersion specification, Builder builder) { - if (StringUtils.isBlank(dialectId)) { + if (Strings.isBlank(dialectId)) { throw new IllegalArgumentException("dialect id must not be null or blank"); } - if (StringUtils.isBlank(idKeyword)) { + if (Strings.isBlank(idKeyword)) { throw new IllegalArgumentException("idKeyword must not be null or blank"); } if (keywords == null) { diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 4eb20bd49..741d09ddf 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -109,11 +109,11 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch } if (nodeType == JsonType.STRING) { if (schemaType == JsonType.INTEGER) { - return StringChecker.isInteger(node.textValue()); + return Strings.isInteger(node.textValue()); } else if (schemaType == JsonType.BOOLEAN) { - return StringChecker.isBoolean(node.textValue()); + return Strings.isBoolean(node.textValue()); } else if (schemaType == JsonType.NUMBER) { - return StringChecker.isNumeric(node.textValue()); + return Strings.isNumeric(node.textValue()); } } } @@ -140,7 +140,7 @@ public static boolean isNumber(JsonNode node, SchemaRegistryConfig config) { return true; } else if (config.isTypeLoose()) { if (TypeFactory.getValueNodeType(node, config) == JsonType.STRING) { - return StringChecker.isNumeric(node.textValue()); + return Strings.isNumeric(node.textValue()); } } return false; diff --git a/src/main/java/com/networknt/schema/utils/StringUtils.java b/src/main/java/com/networknt/schema/utils/StringUtils.java deleted file mode 100644 index 230f92c36..000000000 --- a/src/main/java/com/networknt/schema/utils/StringUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 Network New Technologies Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.utils; - -public final class StringUtils { - - private StringUtils() { - } - - public static boolean isBlank(String s) { - return null == s || s.trim().isEmpty(); - } - - public static boolean isNotBlank(String s) { - return null != s && !s.trim().isEmpty(); - } - -} diff --git a/src/main/java/com/networknt/schema/utils/StringChecker.java b/src/main/java/com/networknt/schema/utils/Strings.java similarity index 53% rename from src/main/java/com/networknt/schema/utils/StringChecker.java rename to src/main/java/com/networknt/schema/utils/Strings.java index 4ba6388bf..0858655a3 100644 --- a/src/main/java/com/networknt/schema/utils/StringChecker.java +++ b/src/main/java/com/networknt/schema/utils/Strings.java @@ -1,7 +1,25 @@ -package com.networknt.schema.utils; +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -public class StringChecker { +package com.networknt.schema.utils; +/** + * Utility methods for working with Strings. + */ +public final class Strings { private static final char CHAR_0 = '0'; private static final char CHAR_1 = '1'; private static final char CHAR_9 = '9'; @@ -11,22 +29,25 @@ public class StringChecker { private static final char CHAR_E = 'E'; private static final char CHAR_e = 'e'; - public static boolean isInteger(String str) { - if (str == null || str.isEmpty()) { + private Strings() { + } + + public static boolean isInteger(String string) { + if (string == null || string.isEmpty()) { return false; } // all code below could be replaced with //return str.matrch("[-+]?(?:0|[1-9]\\d*)") int i = 0; - if (str.charAt(0) == '-' || str.charAt(0) == '+') { - if (str.length() == 1) { + if (string.charAt(0) == '-' || string.charAt(0) == '+') { + if (string.length() == 1) { return false; } i = 1; } - for (; i < str.length(); i++) { - char c = str.charAt(i); + for (; i < string.length(); i++) { + char c = string.charAt(i); if (c < '0' || c > '9') { return false; } @@ -34,40 +55,40 @@ public static boolean isInteger(String str) { return true; } - public static boolean isBoolean(String s) { - return "true".equals(s) || "false".equals(s); + public static boolean isBoolean(String string) { + return "true".equals(string) || "false".equals(string); } - public static boolean isNumeric(String str) { - if (str == null || str.isEmpty()) { + public static boolean isNumeric(String string) { + if (string == null || string.isEmpty()) { return false; } // all code below could be replaced with //return str.matrch("[-+]?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?") int i = 0; - int len = str.length(); + int len = string.length(); - if (str.charAt(i) == MINUS || str.charAt(i) == PLUS) { - if (str.length() == 1) { + if (string.charAt(i) == MINUS || string.charAt(i) == PLUS) { + if (string.length() == 1) { return false; } i = 1; } - char character = str.charAt(i++); + char character = string.charAt(i++); if (character == CHAR_0) { // TODO: if leading zeros are supported (counter to JSON spec) handle it here if (i < len) { - character = str.charAt(i++); + character = string.charAt(i++); if (character != DOT && character != CHAR_E && character != CHAR_e) { return false; } } } else if (CHAR_1 <= character && character <= CHAR_9) { while (i < len && CHAR_0 <= character && character <= CHAR_9) { - character = str.charAt(i++); + character = string.charAt(i++); } } else { return false; @@ -77,9 +98,9 @@ public static boolean isNumeric(String str) { if (i >= len) { return false; } - character = str.charAt(i++); + character = string.charAt(i++); while (i < len && CHAR_0 <= character && character <= CHAR_9) { - character = str.charAt(i++); + character = string.charAt(i++); } } @@ -87,18 +108,22 @@ public static boolean isNumeric(String str) { if (i >= len) { return false; } - character = str.charAt(i++); + character = string.charAt(i++); if (character == PLUS || character == MINUS) { if (i >= len) { return false; } - character = str.charAt(i++); + character = string.charAt(i++); } while (i < len && CHAR_0 <= character && character <= CHAR_9) { - character = str.charAt(i++); + character = string.charAt(i++); } } return i >= len && (CHAR_0 <= character && character <= CHAR_9); } + + public static boolean isBlank(String string) { + return null == string || string.trim().isEmpty(); + } } diff --git a/src/test/java/com/networknt/schema/StringCheckerTest.java b/src/test/java/com/networknt/schema/utils/StringsTest.java similarity index 88% rename from src/test/java/com/networknt/schema/StringCheckerTest.java rename to src/test/java/com/networknt/schema/utils/StringsTest.java index 6978a03e1..cac42ceda 100755 --- a/src/test/java/com/networknt/schema/StringCheckerTest.java +++ b/src/test/java/com/networknt/schema/utils/StringsTest.java @@ -14,15 +14,14 @@ * limitations under the License. */ -package com.networknt.schema; +package com.networknt.schema.utils; import org.junit.jupiter.api.Test; -import static com.networknt.schema.utils.StringChecker.isNumeric; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -class StringCheckerTest { +class StringsTest { private static final String[] validNumericValues = { "1", "-1", "1.1", "-1.1", "0E+1", "0E-1", "0E1", "-0E+1", "-0E-1", "-0E1", "0.1E+1", "0.1E-1", "0.1E1", @@ -39,14 +38,14 @@ class StringCheckerTest { @Test void testNumericValues() { for (String validValue : validNumericValues) { - assertTrue(isNumeric(validValue), validValue); + assertTrue(Strings.isNumeric(validValue), validValue); } } @Test void testNonNumericValues() { for (String invalidValue : invalidNumericValues) { - assertFalse(isNumeric(invalidValue), invalidValue); + assertFalse(Strings.isNumeric(invalidValue), invalidValue); } } } From d7b23d8cffb56017fb162f59fa19c2b6e2e35654 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:31:40 +0800 Subject: [PATCH 59/74] Refactor Schema to allow loading input from iri --- .../java/com/networknt/schema/Schema.java | 315 +++++++++++++++++- .../resource/ClasspathResourceLoader.java | 8 + .../schema/resource/MetaSchemaIdResolver.java | 8 + .../schema/resource/SchemaLoader.java | 4 +- .../java/com/networknt/schema/UrnTest.java | 8 +- 5 files changed, 332 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/networknt/schema/Schema.java b/src/main/java/com/networknt/schema/Schema.java index b548f67e0..b11dd60ee 100644 --- a/src/main/java/com/networknt/schema/Schema.java +++ b/src/main/java/com/networknt/schema/Schema.java @@ -16,7 +16,10 @@ package com.networknt.schema; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; @@ -34,6 +37,9 @@ import com.networknt.schema.keyword.TypeValidator; import com.networknt.schema.path.NodePath; import com.networknt.schema.path.PathType; +import com.networknt.schema.resource.ClasspathResourceLoader; +import com.networknt.schema.resource.InputStreamSource; +import com.networknt.schema.resource.ResourceLoader; import com.networknt.schema.keyword.KeywordType; import com.networknt.schema.utils.JsonNodes; @@ -936,6 +942,250 @@ public T validate(String input, InputFormat inputFormat, OutputFormat for return validate(createExecutionContext(), deserialize(input, inputFormat), format, (executionContext, schemaContext) -> executionCustomizer.accept(executionContext)); } + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param input the input + * @param inputFormat the inputFormat + * @return A list of Error if there is any validation error, or an + * empty list if there is no error. + */ + public List validate(AbsoluteIri input, InputFormat inputFormat) { + return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT); + } + + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param input the input + * @param inputFormat the inputFormat + * @param executionCustomizer the execution customizer + * @return the assertions + */ + public List validate(AbsoluteIri input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer) { + return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); + } + + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param input the input + * @param inputFormat the inputFormat + * @param executionCustomizer the execution customizer + * @return the assertions + */ + public List validate(AbsoluteIri input, InputFormat inputFormat, Consumer executionCustomizer) { + return validate(deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @return the result + */ + public T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat format) { + return validate(deserialize(input, inputFormat), format, (ExecutionContextCustomizer) null); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @param executionCustomizer the execution customizer + * @return the result + */ + public T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat format, ExecutionContextCustomizer executionCustomizer) { + return validate(createExecutionContext(), deserialize(input, inputFormat), format, executionCustomizer); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @param executionCustomizer the execution customizer + * @return the result + */ + public T validate(AbsoluteIri input, InputFormat inputFormat, OutputFormat format, Consumer executionCustomizer) { + return validate(createExecutionContext(), deserialize(input, inputFormat), format, (executionContext, schemaContext) -> executionCustomizer.accept(executionContext)); + } + + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @return A list of Error if there is any validation error, or an + * empty list if there is no error. + */ + public List validate(ExecutionContext executionContext, String input, InputFormat inputFormat) { + return validate(executionContext, deserialize(input, inputFormat), OutputFormat.DEFAULT); + } + + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @param executionCustomizer the execution customizer + * @return the assertions + */ + public List validate(ExecutionContext executionContext, String input, InputFormat inputFormat, ExecutionContextCustomizer executionCustomizer) { + return validate(executionContext, deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); + } + + /** + * Validate the given input string using the input format, starting at the root + * of the data path. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @param executionCustomizer the execution customizer + * @return the assertions + */ + public List validate(ExecutionContext executionContext, String input, InputFormat inputFormat, Consumer executionCustomizer) { + return validate(executionContext, deserialize(input, inputFormat), OutputFormat.DEFAULT, executionCustomizer); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @return the result + */ + public T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat format) { + return validate(executionContext, deserialize(input, inputFormat), format, (ExecutionContextCustomizer) null); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @param executionCustomizer the execution customizer + * @return the result + */ + public T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat format, ExecutionContextCustomizer executionCustomizer) { + return validate(executionContext, deserialize(input, inputFormat), format, executionCustomizer); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param executionContext the execution context + * @param input the input + * @param inputFormat the inputFormat + * @param format the formatter + * @param executionCustomizer the execution customizer + * @return the result + */ + public T validate(ExecutionContext executionContext, String input, InputFormat inputFormat, OutputFormat format, Consumer executionCustomizer) { + return validate(executionContext, deserialize(input, inputFormat), format, (execContext, schemaContext) -> executionCustomizer.accept(execContext)); + } + /** * Validates to a format. * @@ -946,7 +1196,28 @@ public T validate(String input, InputFormat inputFormat, OutputFormat for * @return the result */ public T validate(ExecutionContext executionContext, JsonNode node, OutputFormat format) { - return validate(executionContext, node, format, null); + return validate(executionContext, node, format, (ExecutionContextCustomizer) null); + } + + /** + * Validates the given input string using the input format, starting at the root + * of the data path. The output will be formatted using the formatter specified. + *

+ * Note that since Draft 2019-09 by default format generates only annotations + * and not assertions. + *

+ * Use {@link ExecutionConfig.Builder#formatAssertionsEnabled(Boolean)} to override + * the default. + * + * @param the result type + * @param executionContext the execution context + * @param node the node + * @param format the formatter + * @param executionCustomizer the execution customizer + * @return the result + */ + public T validate(ExecutionContext executionContext, JsonNode node, OutputFormat format, Consumer executionCustomizer) { + return validate(executionContext, node, format, (execContext, schemaContext) -> executionCustomizer.accept(execContext)); } /** @@ -984,8 +1255,48 @@ private JsonNode deserialize(String input, InputFormat inputFormat) { try { return this.getSchemaContext().getSchemaRegistry().readTree(input, inputFormat); } catch (IOException e) { - throw new IllegalArgumentException("Invalid input", e); + throw new UncheckedIOException("Invalid input", e); + } + } + + /** + * Loads the resource from the input iri and deserialize to JsonNode. + * + * @param input the input + * @param inputFormat the format + * @return the JsonNode. + */ + private JsonNode deserialize(AbsoluteIri input, InputFormat inputFormat) { + try { + InputStreamSource result = getInputResource(input); + if (result == null) { + throw new UncheckedIOException(new FileNotFoundException(input.toString() + " not found")); + } + try (InputStream inputStream = result.getInputStream()) { + return this.getSchemaContext().getSchemaRegistry().readTree(inputStream, inputFormat); + } + } catch (IOException e) { + throw new UncheckedIOException("Invalid input", e); + } + } + + /** + * Loads the resource from the input iri. + * + * @param input the input + * @return the input stream source + */ + private InputStreamSource getInputResource(AbsoluteIri input) { + InputStreamSource result = null; + List resourceLoaders = this.getSchemaContext().getSchemaRegistry().getSchemaLoader() + .getResourceLoaders(); + for (ResourceLoader loader : resourceLoaders) { + result = loader.getResource(input); + if (result != null) { + return result; + } } + return ClasspathResourceLoader.getInstance().getResource(input); } /************************ END OF VALIDATE METHODS **********************************/ diff --git a/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java b/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java index 4e7b305f1..1c283a444 100644 --- a/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java +++ b/src/main/java/com/networknt/schema/resource/ClasspathResourceLoader.java @@ -25,6 +25,14 @@ * Loads from classpath. */ public class ClasspathResourceLoader implements ResourceLoader { + private static class Holder { + private static final ClasspathResourceLoader INSTANCE = new ClasspathResourceLoader(); + } + + public static ClasspathResourceLoader getInstance() { + return Holder.INSTANCE; + } + private final Supplier classLoaderSource; /** diff --git a/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java b/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java index 3ca0f23cf..f26d18ae5 100644 --- a/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java +++ b/src/main/java/com/networknt/schema/resource/MetaSchemaIdResolver.java @@ -21,6 +21,14 @@ * Maps the JSON Schema meta schema to the class path location. */ public class MetaSchemaIdResolver implements SchemaIdResolver { + private static class Holder { + private static MetaSchemaIdResolver INSTANCE = new MetaSchemaIdResolver(); + } + + public static MetaSchemaIdResolver getInstance() { + return Holder.INSTANCE; + } + private static final char ANCHOR = '#'; private static final String CLASSPATH_PREFIX = "classpath:"; private static final String HTTP_JSON_SCHEMA_ORG_PREFIX = "http://json-schema.org/"; diff --git a/src/main/java/com/networknt/schema/resource/SchemaLoader.java b/src/main/java/com/networknt/schema/resource/SchemaLoader.java index 481e1a399..d6cb49d7d 100644 --- a/src/main/java/com/networknt/schema/resource/SchemaLoader.java +++ b/src/main/java/com/networknt/schema/resource/SchemaLoader.java @@ -32,8 +32,8 @@ * explicitly configured using {@link Builder#fetchRemoteResources}. */ public class SchemaLoader { - private static final MetaSchemaIdResolver META_SCHEMA_ID_RESOLVER = new MetaSchemaIdResolver(); - private static final ClasspathResourceLoader CLASSPATH_RESOURCE_LOADER = new ClasspathResourceLoader(); + private static final MetaSchemaIdResolver META_SCHEMA_ID_RESOLVER = MetaSchemaIdResolver.getInstance(); + private static final ClasspathResourceLoader CLASSPATH_RESOURCE_LOADER = ClasspathResourceLoader.getInstance(); private static class DefaultHolder { private static final SchemaLoader DEFAULT = new SchemaLoader(Collections.emptyList(), Collections.emptyList()); diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index 78bbb57a6..b60430674 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -3,15 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import java.io.InputStream; import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.databind.ObjectMapper; - class UrnTest { - private final ObjectMapper mapper = new ObjectMapper(); - /** * Validate that a JSON URI Mapping file containing the URI Mapping schema is * schema valid. @@ -20,12 +15,11 @@ class UrnTest { */ @Test void testURNToURI() throws Exception { - InputStream urlTestData = UrnTest.class.getResourceAsStream("/draft7/urn/test.json"); SchemaRegistry schemaRegistry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7, builder -> builder.schemaIdResolvers(schemaIdResolvers -> schemaIdResolvers.add(value -> { return AbsoluteIri.of(String.format("%s.schema.json", value.toString())); }))); Schema schema = schemaRegistry.getSchema(SchemaLocation.of("classpath:/draft7/urn/urn")); - assertEquals(0, schema.validate(mapper.readTree(urlTestData)).size()); + assertEquals(0, schema.validate(AbsoluteIri.of("classpath:/draft7/urn/test.json"), InputFormat.JSON).size()); } } From 074b2159cc7befe253103ec15e3f5226192e4d65 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:34:46 +0800 Subject: [PATCH 60/74] Refactor Vocabulary rename iri to id --- .../schema/vocabulary/Vocabularies.java | 30 +++++++++---------- .../schema/vocabulary/Vocabulary.java | 24 +++++++-------- .../com/networknt/schema/Issue994Test.java | 2 +- .../schema/vocabulary/VocabularyTest.java | 6 ++-- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java b/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java index 73fa835fd..f54d1e2c4 100644 --- a/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabularies.java @@ -26,23 +26,23 @@ public class Vocabularies { static { Map mapping = new HashMap<>(); - mapping.put(Vocabulary.DRAFT_2019_09_CORE.getIri(), Vocabulary.DRAFT_2019_09_CORE); - mapping.put(Vocabulary.DRAFT_2019_09_APPLICATOR.getIri(), Vocabulary.DRAFT_2019_09_APPLICATOR); - mapping.put(Vocabulary.DRAFT_2019_09_VALIDATION.getIri(), Vocabulary.DRAFT_2019_09_VALIDATION); - mapping.put(Vocabulary.DRAFT_2019_09_META_DATA.getIri(), Vocabulary.DRAFT_2019_09_META_DATA); - mapping.put(Vocabulary.DRAFT_2019_09_FORMAT.getIri(), Vocabulary.DRAFT_2019_09_FORMAT); - mapping.put(Vocabulary.DRAFT_2019_09_CONTENT.getIri(), Vocabulary.DRAFT_2019_09_CONTENT); + mapping.put(Vocabulary.DRAFT_2019_09_CORE.getId(), Vocabulary.DRAFT_2019_09_CORE); + mapping.put(Vocabulary.DRAFT_2019_09_APPLICATOR.getId(), Vocabulary.DRAFT_2019_09_APPLICATOR); + mapping.put(Vocabulary.DRAFT_2019_09_VALIDATION.getId(), Vocabulary.DRAFT_2019_09_VALIDATION); + mapping.put(Vocabulary.DRAFT_2019_09_META_DATA.getId(), Vocabulary.DRAFT_2019_09_META_DATA); + mapping.put(Vocabulary.DRAFT_2019_09_FORMAT.getId(), Vocabulary.DRAFT_2019_09_FORMAT); + mapping.put(Vocabulary.DRAFT_2019_09_CONTENT.getId(), Vocabulary.DRAFT_2019_09_CONTENT); - mapping.put(Vocabulary.DRAFT_2020_12_CORE.getIri(), Vocabulary.DRAFT_2020_12_CORE); - mapping.put(Vocabulary.DRAFT_2020_12_APPLICATOR.getIri(), Vocabulary.DRAFT_2020_12_APPLICATOR); - mapping.put(Vocabulary.DRAFT_2020_12_UNEVALUATED.getIri(), Vocabulary.DRAFT_2020_12_UNEVALUATED); - mapping.put(Vocabulary.DRAFT_2020_12_VALIDATION.getIri(), Vocabulary.DRAFT_2020_12_VALIDATION); - mapping.put(Vocabulary.DRAFT_2020_12_META_DATA.getIri(), Vocabulary.DRAFT_2020_12_META_DATA); - mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION.getIri(), Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION); - mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getIri(), Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION); - mapping.put(Vocabulary.DRAFT_2020_12_CONTENT.getIri(), Vocabulary.DRAFT_2020_12_CONTENT); + mapping.put(Vocabulary.DRAFT_2020_12_CORE.getId(), Vocabulary.DRAFT_2020_12_CORE); + mapping.put(Vocabulary.DRAFT_2020_12_APPLICATOR.getId(), Vocabulary.DRAFT_2020_12_APPLICATOR); + mapping.put(Vocabulary.DRAFT_2020_12_UNEVALUATED.getId(), Vocabulary.DRAFT_2020_12_UNEVALUATED); + mapping.put(Vocabulary.DRAFT_2020_12_VALIDATION.getId(), Vocabulary.DRAFT_2020_12_VALIDATION); + mapping.put(Vocabulary.DRAFT_2020_12_META_DATA.getId(), Vocabulary.DRAFT_2020_12_META_DATA); + mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION.getId(), Vocabulary.DRAFT_2020_12_FORMAT_ANNOTATION); + mapping.put(Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getId(), Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION); + mapping.put(Vocabulary.DRAFT_2020_12_CONTENT.getId(), Vocabulary.DRAFT_2020_12_CONTENT); - mapping.put(Vocabulary.OPENAPI_3_1_BASE.getIri(), Vocabulary.OPENAPI_3_1_BASE); + mapping.put(Vocabulary.OPENAPI_3_1_BASE.getId(), Vocabulary.OPENAPI_3_1_BASE); VALUES = mapping; } diff --git a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java index 9a43b2a00..ef8083810 100644 --- a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java @@ -28,7 +28,7 @@ /** * Represents a vocabulary in meta-schema. *

- * This contains the IRI and the keywords in the vocabulary. + * This contains the id and the keywords in the vocabulary. */ public class Vocabulary { @@ -106,28 +106,28 @@ KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("t new AnnotationKeyword("example"), KeywordType.DISCRIMINATOR, new AnnotationKeyword("externalDocs"), new AnnotationKeyword("xml")); - private final String iri; + private final String id; private final Set keywords; /** * Constructor. * - * @param iri the iri + * @param id the id * @param keywords the keywords */ - public Vocabulary(String iri, Keyword... keywords) { - this.iri = iri; + public Vocabulary(String id, Keyword... keywords) { + this.id = id; this.keywords = new LinkedHashSet<>(); this.keywords.addAll(Arrays.asList(keywords)); } /** - * The iri of the vocabulary. + * The id of the vocabulary. * - * @return the iri + * @return the id */ - public String getIri() { - return iri; + public String getId() { + return id; } /** @@ -141,7 +141,7 @@ public Set getKeywords() { @Override public int hashCode() { - return Objects.hash(iri, keywords); + return Objects.hash(id, keywords); } @Override @@ -153,12 +153,12 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; Vocabulary other = (Vocabulary) obj; - return Objects.equals(iri, other.iri) && Objects.equals(keywords, other.keywords); + return Objects.equals(id, other.id) && Objects.equals(keywords, other.keywords); } @Override public String toString() { - return "Vocabulary [iri=" + iri + ", keywords=" + keywords + "]"; + return "Vocabulary [id=" + id + ", keywords=" + keywords + "]"; } } diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index f5576a98f..f1c4156fe 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -44,7 +44,7 @@ void test() throws JsonProcessingException { + " }\r\n" + "}"; Dialect dialect = Dialect.builder(Dialects.getDraft202012()).vocabularies(vocabularies -> { - vocabularies.remove(Vocabulary.DRAFT_2020_12_VALIDATION.getIri()); + vocabularies.remove(Vocabulary.DRAFT_2020_12_VALIDATION.getId()); }).build(); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree(schemaData); Schema schema = SchemaRegistry diff --git a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java index 004002df3..0294cdca7 100644 --- a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java @@ -37,8 +37,6 @@ import com.networknt.schema.dialect.Dialects; import com.networknt.schema.keyword.AnnotationKeyword; import com.networknt.schema.output.OutputUnit; -import com.networknt.schema.vocabulary.Vocabulary; -import com.networknt.schema.vocabulary.VocabularyFactory; /** * Tests for vocabulary support in meta schemas. @@ -89,7 +87,7 @@ void noValidation() { builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/validation", - Vocabulary.DRAFT_2020_12_VALIDATION.getIri()))))) + Vocabulary.DRAFT_2020_12_VALIDATION.getId()))))) .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); @@ -142,7 +140,7 @@ void noFormatValidation() { builder -> builder.resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData.replace("https://www.example.com/vocab/format", - Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getIri()))))) + Vocabulary.DRAFT_2020_12_FORMAT_ASSERTION.getId()))))) .getSchema(schemaData); messages = schema.validate(inputDataNoValidation, InputFormat.JSON); assertEquals(1, messages.size()); From 05cabe2db654b29bead101edb3152ebd4f53ccef Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:36:07 +0800 Subject: [PATCH 61/74] Allow adding keyword to dialect to override vocabulary keywords --- src/main/java/com/networknt/schema/dialect/Dialect.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index e45de2ac6..8ec0aa4d8 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -301,7 +301,9 @@ public Dialect build() { } if (vocabulary != null) { for (Keyword keyword : vocabulary.getKeywords()) { - keywords.put(keyword.getValue(), keyword); + // Only add keyword from vocabulary if not already + // ie. allow overriding the keyword by explicitly adding it + keywords.putIfAbsent(keyword.getValue(), keyword); } } else if (Boolean.TRUE.equals(entry.getValue())) { Error error = Error.builder() From 854110096791b22f6945500f720312c8a858eba6 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 08:26:47 +0800 Subject: [PATCH 62/74] Rename JsonNodeUtil to JsonNodeTypes --- .../keyword/ExclusiveMaximumValidator.java | 4 +- .../keyword/ExclusiveMinimumValidator.java | 4 +- .../schema/keyword/MaximumValidator.java | 4 +- .../schema/keyword/MinimumValidator.java | 4 +- .../schema/keyword/MultipleOfValidator.java | 4 +- .../schema/keyword/TypeValidator.java | 4 +- .../{JsonNodeUtil.java => JsonNodeTypes.java} | 58 ++----------------- 7 files changed, 16 insertions(+), 66 deletions(-) rename src/main/java/com/networknt/schema/utils/{JsonNodeUtil.java => JsonNodeTypes.java} (69%) diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java index dd98158ad..bc05fd9ae 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; @@ -98,7 +98,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, schemaContext.getSchemaRegistryConfig())) { + if (!JsonNodeTypes.isNumber(node, schemaContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java index 719858012..297259121 100644 --- a/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; @@ -105,7 +105,7 @@ public String thresholdValue() { } public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { + if (!JsonNodeTypes.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java index 04c1ba215..c7d6e3a78 100644 --- a/src/main/java/com/networknt/schema/keyword/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MaximumValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; @@ -113,7 +113,7 @@ public String thresholdValue() { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { + if (!JsonNodeTypes.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // maximum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java index c03ca6ca4..2d9f7f3cd 100644 --- a/src/main/java/com/networknt/schema/keyword/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MinimumValidator.java @@ -23,7 +23,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import com.networknt.schema.utils.JsonType; import java.math.BigDecimal; @@ -120,7 +120,7 @@ public String thresholdValue() { public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation) { - if (!JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { + if (!JsonNodeTypes.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // minimum only applies to numbers return; } diff --git a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java index bcf12d111..a69c41121 100644 --- a/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/MultipleOfValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import java.math.BigDecimal; @@ -84,7 +84,7 @@ protected BigDecimal getDividend(JsonNode node) { // division and multiple return node.isBigDecimal() ? node.decimalValue() : BigDecimal.valueOf(node.doubleValue()); } else if (this.schemaContext.getSchemaRegistryConfig().isTypeLoose() - && JsonNodeUtil.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { + && JsonNodeTypes.isNumber(node, this.schemaContext.getSchemaRegistryConfig())) { // handling for type loose return new BigDecimal(node.textValue()); } diff --git a/src/main/java/com/networknt/schema/keyword/TypeValidator.java b/src/main/java/com/networknt/schema/keyword/TypeValidator.java index 05f8d56f5..0c67413c6 100644 --- a/src/main/java/com/networknt/schema/keyword/TypeValidator.java +++ b/src/main/java/com/networknt/schema/keyword/TypeValidator.java @@ -22,7 +22,7 @@ import com.networknt.schema.SchemaLocation; import com.networknt.schema.path.NodePath; import com.networknt.schema.SchemaContext; -import com.networknt.schema.utils.JsonNodeUtil; +import com.networknt.schema.utils.JsonNodeTypes; import com.networknt.schema.utils.JsonType; import com.networknt.schema.utils.TypeFactory; @@ -48,7 +48,7 @@ public JsonType getSchemaType() { } public boolean equalsToSchemaType(JsonNode node) { - return JsonNodeUtil.equalsToSchemaType(node, this.schemaType, this.parentSchema, this.schemaContext); + return JsonNodeTypes.equalsToSchemaType(node, this.schemaType, this.parentSchema, this.schemaContext); } @Override diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java similarity index 69% rename from src/main/java/com/networknt/schema/utils/JsonNodeUtil.java rename to src/main/java/com/networknt/schema/utils/JsonNodeTypes.java index 741d09ddf..ab641df96 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java @@ -1,16 +1,12 @@ package com.networknt.schema.utils; -import java.util.ArrayList; -import java.util.Collection; - import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; import com.networknt.schema.SchemaRegistryConfig; import com.networknt.schema.SpecificationVersion; -import com.networknt.schema.path.PathType; -import com.networknt.schema.SchemaContext; -public class JsonNodeUtil { +public class JsonNodeTypes { private static final long V6_VALUE = SpecificationVersion.DRAFT_6.getOrder(); private static final String TYPE = "type"; @@ -18,57 +14,11 @@ public class JsonNodeUtil { private static final String REF = "$ref"; private static final String NULLABLE = "nullable"; - public static Collection allPaths(PathType pathType, String root, JsonNode node) { - Collection collector = new ArrayList<>(); - visitNode(pathType, root, node, collector); - return collector; - } - - private static void visitNode(PathType pathType, String root, JsonNode node, Collection collector) { - if (node.isObject()) { - visitObject(pathType, root, node, collector); - } else if (node.isArray()) { - visitArray(pathType, root, node, collector); - } - } - - private static void visitArray(PathType pathType, String root, JsonNode node, Collection collector) { - int size = node.size(); - for (int i = 0; i < size; ++i) { - StringBuilder builder = new StringBuilder(); - builder.append(root); - pathType.append(builder, i); - String path = builder.toString(); - collector.add(path); - visitNode(pathType, path, node.get(i), collector); - } - } - - private static void visitObject(PathType pathType, String root, JsonNode node, Collection collector) { - node.fields().forEachRemaining(entry -> { - StringBuilder builder = new StringBuilder(); - builder.append(root); - pathType.append(builder, entry.getKey()); - String path = builder.toString(); - collector.add(path); - visitNode(pathType, path, entry.getValue(), collector); - }); - } - public static boolean isNodeNullable(JsonNode schema){ JsonNode nullable = schema.get(NULLABLE); return nullable != null && nullable.asBoolean(); } - //Check to see if a JsonNode is nullable with checking the isHandleNullableField - public static boolean isNodeNullable(JsonNode schema, SchemaContext schemaContext) { - // check if the parent schema declares the fields as nullable - if (schemaContext.isNullableKeywordEnabled()) { - return isNodeNullable(schema); - } - return false; - } - public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, SchemaContext schemaContext) { SchemaRegistryConfig config = schemaContext.getSchemaRegistryConfig(); JsonType nodeType = TypeFactory.getValueNodeType(node, config); @@ -90,8 +40,8 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch if (nodeType == JsonType.NULL) { if (parentSchema != null && schemaContext.isNullableKeywordEnabled()) { Schema grandParentSchema = parentSchema.getParentSchema(); - if (grandParentSchema != null && JsonNodeUtil.isNodeNullable(grandParentSchema.getSchemaNode()) - || JsonNodeUtil.isNodeNullable(parentSchema.getSchemaNode())) { + if (grandParentSchema != null && JsonNodeTypes.isNodeNullable(grandParentSchema.getSchemaNode()) + || JsonNodeTypes.isNodeNullable(parentSchema.getSchemaNode())) { return true; } } From 3934554a0077fec3430984d71d6ec9c591480331 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 08:27:07 +0800 Subject: [PATCH 63/74] Remove SetView --- .../com/networknt/schema/utils/SetView.java | 204 ----------------- .../networknt/schema/utils/SetViewTest.java | 209 ------------------ 2 files changed, 413 deletions(-) delete mode 100644 src/main/java/com/networknt/schema/utils/SetView.java delete mode 100644 src/test/java/com/networknt/schema/utils/SetViewTest.java diff --git a/src/main/java/com/networknt/schema/utils/SetView.java b/src/main/java/com/networknt/schema/utils/SetView.java deleted file mode 100644 index a7385f02a..000000000 --- a/src/main/java/com/networknt/schema/utils/SetView.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.networknt.schema.utils; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -/** - * View of a list of sets. - *

- * This is used for performance to reduce copies but breaks the semantics of the - * set where the elements must all be unique. - * - * @param the type contains in the set - */ -public class SetView implements Set { - private final List> sets = new ArrayList<>(); - - /** - * Adds a set to the view. - * - * @param set to add to the view - * @return the view - */ - public SetView union(Set set) { - if (set != null && !set.isEmpty()) { - this.sets.add(set); - } - return this; - } - - @Override - public int size() { - int size = 0; - for (Set set : sets) { - size += set.size(); - } - return size; - } - - @Override - public boolean isEmpty() { - return sets.isEmpty(); - } - - @Override - public boolean contains(Object o) { - for (Set set : sets) { - if (set.contains(o)) { - return true; - } - } - return false; - } - - @Override - public Iterator iterator() { - return new SetViewIterator<>(this); - } - - @Override - public Object[] toArray() { - int size = size(); - Object[] result = new Object[size]; - Iterator iterator = iterator(); - for (int x = 0; x < size; x++) { - result[x] = iterator.hasNext() ? iterator.next() : null; - } - return result; - } - - @SuppressWarnings("unchecked") - @Override - public T[] toArray(T[] a) { - int size = size(); - T[] result = size <= a.length ? a : (T[]) Array.newInstance(a.getClass().getComponentType(), size); - Iterator iterator = iterator(); - for (int x = 0; x < size; x++) { - result[x] = iterator.hasNext() ? (T) iterator.next() : null; - } - return result; - } - - @Override - public boolean containsAll(Collection c) { - for (Object e : c) { - if (!contains(e)) { - return false; - } - } - return true; - } - - @Override - public boolean add(E e) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(Collection coll) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeAll(Collection coll) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean retainAll(Collection coll) { - throw new UnsupportedOperationException(); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(); - } - - /** - * Iterator. - * - * @param the type contains in the set - */ - public static class SetViewIterator implements Iterator { - private Iterator> sets = null; - private Iterator current = null; - - public SetViewIterator(SetView view) { - this.sets = view.sets.iterator(); - if (this.sets.hasNext()) { - this.current = this.sets.next().iterator(); - } - } - - @Override - public boolean hasNext() { - if (this.current.hasNext()) { - return true; - } - while (this.sets.hasNext()) { - this.current = this.sets.next().iterator(); - if (this.current.hasNext()) { - return true; - } - } - return false; - } - - @Override - public E next() { - return this.current.next(); - } - } - - @Override - public int hashCode() { - return Objects.hash(sets); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Set)) { - return false; - } - Collection collection = (Collection) obj; - if (collection.size() != size()) { - return false; - } - try { - return containsAll(collection); - } catch (ClassCastException ignore) { - return false; - } catch (NullPointerException ignore) { - return false; - } - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append('['); - Iterator iterator = iterator(); - if (iterator.hasNext()) { - builder.append(iterator.next().toString()); - } - while (iterator.hasNext()) { - builder.append(", "); - builder.append(iterator.next().toString()); - } - builder.append(']'); - return builder.toString(); - } -} diff --git a/src/test/java/com/networknt/schema/utils/SetViewTest.java b/src/test/java/com/networknt/schema/utils/SetViewTest.java deleted file mode 100644 index 7b039cc85..000000000 --- a/src/test/java/com/networknt/schema/utils/SetViewTest.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.networknt.schema.utils; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Test; - -/** - * Test for SetView. - */ -class SetViewTest { - - @Test - void testUnion() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - assertEquals(3, view.size()); - List values = view.stream().collect(Collectors.toList()); - assertEquals(1, values.get(0)); - assertEquals(2, values.get(1)); - assertEquals(3, values.get(2)); - } - - @Test - void testToString() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - String value = view.toString(); - assertEquals("[1, 2, 3]", value); - } - - @Test - void testIsEmpty() { - Set a = new LinkedHashSet<>(); - a.add(1); - a.add(2); - - SetView view = new SetView<>(); - assertTrue(view.isEmpty()); - view.union(a); - assertFalse(view.isEmpty()); - } - - @Test - void testEquals() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - assertEquals(3, view.size()); - - Set result = new HashSet<>(); - result.add(1); - result.add(2); - result.add(3); - assertEquals(result, view); - } - - @Test - void testContains() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - assertTrue(view.contains(1)); - assertTrue(view.contains(2)); - assertTrue(view.contains(3)); - assertFalse(view.contains(4)); - } - - @Test - void testContainsAll() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - Set result = new HashSet<>(); - result.add(1); - result.add(2); - result.add(3); - assertTrue(view.containsAll(result)); - result.add(4); - assertFalse(view.containsAll(result)); - } - - @Test - void testToArray() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - assertEquals(3, view.size()); - - Object[] result = view.toArray(); - assertEquals(3, result.length); - assertEquals(1, result[0]); - assertEquals(2, result[1]); - assertEquals(3, result[2]); - } - - @Test - void testToArrayArray() { - Set a = new LinkedHashSet<>(); - Set b = new LinkedHashSet<>(); - Set c = new LinkedHashSet<>(); - a.add(1); - a.add(2); - c.add(3); - - Set view = new SetView().union(a).union(b).union(c); - assertEquals(3, view.size()); - - Integer[] result = view.toArray(new Integer[0]); - assertEquals(3, result.length); - assertEquals(1, result[0]); - assertEquals(2, result[1]); - assertEquals(3, result[2]); - } - - @Test - void testAddAll() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.addAll(Collections.singleton(1))); - } - - @Test - void testAdd() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.add(1)); - } - - @Test - void testClear() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.clear()); - } - - @Test - void testRemove() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.remove(1)); - } - - @Test - void testRemoveAll() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.removeAll(Collections.singleton(1))); - } - - @Test - void testRetainAll() { - Set view = new SetView<>(); - assertThrows(UnsupportedOperationException.class, () -> view.retainAll(Collections.singleton(1))); - } - -} From 0424fe355222e2e53bc674fd4adae6c11300a5f9 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 08:28:58 +0800 Subject: [PATCH 64/74] Suppress warnings for ThresholdMixinPerfTest --- .../keyword/ThresholdMixinPerfTest.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java b/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java index 836a676cb..014c117e0 100644 --- a/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java +++ b/src/test/java/com/networknt/schema/keyword/ThresholdMixinPerfTest.java @@ -15,18 +15,21 @@ */ package com.networknt.schema.keyword; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.*; -import com.networknt.schema.keyword.ThresholdMixin; +import static java.lang.System.out; + +import java.math.BigDecimal; +import java.math.BigInteger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.math.BigDecimal; -import java.math.BigInteger; - -import static java.lang.System.out; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.BigIntegerNode; +import com.fasterxml.jackson.databind.node.DecimalNode; +import com.fasterxml.jackson.databind.node.DoubleNode; +import com.fasterxml.jackson.databind.node.LongNode; +import com.fasterxml.jackson.databind.node.TextNode; @Disabled class ThresholdMixinPerfTest { @@ -34,9 +37,11 @@ class ThresholdMixinPerfTest { private final LongNode maximumLong = new LongNode(thresholdIntegral); + @SuppressWarnings("unused") private final BigIntegerNode maximumBigInt = new BigIntegerNode(BigInteger.valueOf(thresholdIntegral)); private final LongNode valueLong = new LongNode(Long.MAX_VALUE); + @SuppressWarnings("unused") private final BigIntegerNode valueBigInt = new BigIntegerNode(BigInteger.valueOf(Long.MAX_VALUE)); // private final double threshold = Double.MAX_VALUE - 1; @@ -206,6 +211,7 @@ public String thresholdValue() { } ThresholdMixin asDouble = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { double lm = maximumDouble.doubleValue(); @@ -220,6 +226,7 @@ public String thresholdValue() { }; ThresholdMixin asLong = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { long lm = maximumLong.longValue(); @@ -234,6 +241,7 @@ public String thresholdValue() { }; ThresholdMixin typedThreshold = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { if (node.isDouble()) { @@ -260,6 +268,7 @@ public String thresholdValue() { }; ThresholdMixin currentImplementationDouble = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { if (maximumDouble.isDouble() && maximumDouble.doubleValue() == Double.POSITIVE_INFINITY) { @@ -288,6 +297,7 @@ public String thresholdValue() { ThresholdMixin currentImplementationDecimal = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { if (maximumDecimal.isDouble() && maximumDecimal.doubleValue() == Double.POSITIVE_INFINITY) { @@ -315,6 +325,7 @@ public String thresholdValue() { }; ThresholdMixin oneMixinForIntegerAndNumber = new ThresholdMixin() { + @SuppressWarnings("unused") @Override public boolean crossesThreshold(JsonNode node) { BigDecimal value = new BigDecimal(node.asText()); From 5a971afaed85cde03ef862196fc3bf07fbcc6dc4 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 09:44:36 +0800 Subject: [PATCH 65/74] Add propertyDependencies keyword --- .../networknt/schema/keyword/KeywordType.java | 1 + .../PropertyDependenciesValidator.java | 114 ++++++++++++++++++ .../PropertyDependenciesValidatorTest.java | 58 +++++++++ 3 files changed, 173 insertions(+) create mode 100644 src/main/java/com/networknt/schema/keyword/PropertyDependenciesValidator.java create mode 100644 src/test/java/com/networknt/schema/keyword/PropertyDependenciesValidatorTest.java diff --git a/src/main/java/com/networknt/schema/keyword/KeywordType.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java index ea57df4c8..d52be9df6 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordType.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -79,6 +79,7 @@ public enum KeywordType implements Keyword { PATTERN("pattern", PatternValidator::new, SpecificationVersionRange.MaxV7), PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, SpecificationVersionRange.None), PROPERTIES("properties", PropertiesValidator::new, SpecificationVersionRange.MaxV7), + PROPERTY_DEPENDENCIES("propertyDependencies", PropertyDependenciesValidator::new, SpecificationVersionRange.None), PROPERTYNAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.MinV6MaxV7), READ_ONLY("readOnly", ReadOnlyValidator::new, SpecificationVersionRange.V7), RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, SpecificationVersionRange.None), diff --git a/src/main/java/com/networknt/schema/keyword/PropertyDependenciesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyDependenciesValidator.java new file mode 100644 index 000000000..4d13cdd42 --- /dev/null +++ b/src/main/java/com/networknt/schema/keyword/PropertyDependenciesValidator.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.networknt.schema.keyword; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.ExecutionContext; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaContext; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.path.NodePath; + +/** + * {@link KeywordValidator} for propertyDependencies. + */ +public class PropertyDependenciesValidator extends BaseKeywordValidator implements KeywordValidator { + /* + * Property Name -> Property Value -> Schema + */ + private final Map> propertyDependencies; + + public PropertyDependenciesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, + Schema parentSchema, SchemaContext schemaContext) { + super(KeywordType.PROPERTY_DEPENDENCIES, schemaNode, schemaLocation, parentSchema, schemaContext, + evaluationPath); + Set> properties = schemaNode.properties(); + this.propertyDependencies = new LinkedHashMap<>(properties.size()); + for (Entry property : properties) { + String propertyName = property.getKey(); + SchemaLocation propertySchemaLocation = schemaLocation.append(propertyName); + NodePath propertyEvaluationPath = evaluationPath.append(propertyName); + + Set> propertyValues = property.getValue().properties(); + for (Entry propertyValue : propertyValues) { + Map valueSchemas = this.propertyDependencies.computeIfAbsent(propertyName, + key -> new LinkedHashMap<>()); + valueSchemas.put(propertyValue.getKey(), + schemaContext.newSchema(propertySchemaLocation.append(propertyValue.getKey()), + propertyEvaluationPath.append(propertyValue.getKey()), propertyValue.getValue(), + parentSchema)); + } + } + } + + @Override + public void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation) { + validate(executionContext, node, rootNode, instanceLocation, false); + } + + protected void validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + NodePath instanceLocation, boolean walk) { + Set> properties = node.properties(); + for (Entry property : properties) { + String propertyName = property.getKey(); + String propertyValue = property.getValue().asText(); + if (propertyValue != null) { + Map propertySchemas = this.propertyDependencies.get(propertyName); + if (propertySchemas != null) { + Schema schema = propertySchemas.get(propertyValue); + if (schema != null) { + if (!walk) { + schema.validate(executionContext, node, rootNode, instanceLocation); + } else { + schema.walk(executionContext, node, rootNode, instanceLocation, true); + } + } + } + } + } + } + + @Override + public void walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, NodePath instanceLocation, + boolean shouldValidateSchema) { + if (shouldValidateSchema) { + validate(executionContext, node, rootNode, instanceLocation, true); + return; + } + + for (Map properties : this.propertyDependencies.values()) { + for (Schema schema : properties.values()) { + schema.walk(executionContext, node, rootNode, instanceLocation, false); + } + } + } + + @Override + public void preloadSchema() { + for (Map properties : propertyDependencies.values()) { + for (Schema schema : properties.values()) { + schema.initializeValidators(); + } + } + } +} diff --git a/src/test/java/com/networknt/schema/keyword/PropertyDependenciesValidatorTest.java b/src/test/java/com/networknt/schema/keyword/PropertyDependenciesValidatorTest.java new file mode 100644 index 000000000..6e086c549 --- /dev/null +++ b/src/test/java/com/networknt/schema/keyword/PropertyDependenciesValidatorTest.java @@ -0,0 +1,58 @@ +package com.networknt.schema.keyword; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import com.networknt.schema.Error; +import com.networknt.schema.InputFormat; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaRegistry; +import com.networknt.schema.dialect.Dialect; +import com.networknt.schema.dialect.Dialects; + +/** + * Test for propertyDependencies. + */ +public class PropertyDependenciesValidatorTest { + @Test + void basicTest() { + Dialect dialect = Dialect.builder(Dialects.getDraft202012()).keyword(KeywordType.PROPERTY_DEPENDENCIES).build(); + SchemaRegistry schemaRegistry = SchemaRegistry.withDialect(dialect); + String schemaData = "{\r\n" + + " \"propertyDependencies\": {\r\n" + + " \"foo\": {\r\n" + + " \"aaa\": {\r\n" + + " \"$ref\": \"#/$defs/foo-aaa\"\r\n" + + " }\r\n" + + " }\r\n" + + " },\r\n" + + " \"$defs\": {\r\n" + + " \"foo-aaa\": {\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"foo\": {\r\n" + + " \"type\": \"string\"\r\n" + + " },\r\n" + + " \"bar\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + "}"; + String instanceData = "{\r\n" + + " \"foo\": \"aaa\",\r\n" + + " \"bar\": 1\r\n" + + "}"; + Schema schema = schemaRegistry.getSchema(schemaData, InputFormat.JSON); + List errors = schema.validate(instanceData, InputFormat.JSON); + assertEquals(1, errors.size()); + assertEquals("/propertyDependencies/foo/aaa/$ref/properties/bar/type", errors.get(0).getEvaluationPath().toString()); + assertEquals("#/$defs/foo-aaa/properties/bar/type", errors.get(0).getSchemaLocation().toString()); + assertEquals("type", errors.get(0).getKeyword()); + } + +} From cfd0e6d8b94ec73c35dacf26f79d8f9d7eb8002e Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 09:45:10 +0800 Subject: [PATCH 66/74] Rename PROPERTYNAMES KeywordType to PROPERTY_NAMES --- src/main/java/com/networknt/schema/keyword/KeywordType.java | 2 +- .../com/networknt/schema/keyword/PropertyNamesValidator.java | 2 +- src/main/java/com/networknt/schema/vocabulary/Vocabulary.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/KeywordType.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java index d52be9df6..ed79703c4 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordType.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -80,7 +80,7 @@ public enum KeywordType implements Keyword { PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, SpecificationVersionRange.None), PROPERTIES("properties", PropertiesValidator::new, SpecificationVersionRange.MaxV7), PROPERTY_DEPENDENCIES("propertyDependencies", PropertyDependenciesValidator::new, SpecificationVersionRange.None), - PROPERTYNAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.MinV6MaxV7), + PROPERTY_NAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.MinV6MaxV7), READ_ONLY("readOnly", ReadOnlyValidator::new, SpecificationVersionRange.V7), RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, SpecificationVersionRange.None), REF("$ref", RefValidator::new, SpecificationVersionRange.MaxV7), diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index 1819b038a..a29ec29f6 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -31,7 +31,7 @@ public class PropertyNamesValidator extends BaseKeywordValidator implements KeywordValidator { private final Schema innerSchema; public PropertyNamesValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { - super(KeywordType.PROPERTYNAMES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); + super(KeywordType.PROPERTY_NAMES, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); innerSchema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } diff --git a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java index ef8083810..1505b9016 100644 --- a/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java +++ b/src/main/java/com/networknt/schema/vocabulary/Vocabulary.java @@ -43,7 +43,7 @@ KeywordType.REF, KeywordType.RECURSIVE_REF, new NonValidationKeyword("$recursive KeywordType.UNEVALUATED_ITEMS, KeywordType.ITEMS_LEGACY, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, KeywordType.UNEVALUATED_PROPERTIES, KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, - KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), + KeywordType.PROPERTY_NAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF, KeywordType.ONE_OF, KeywordType.NOT); public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary( @@ -75,7 +75,7 @@ KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("t "https://json-schema.org/draft/2020-12/vocab/applicator", KeywordType.PREFIX_ITEMS, KeywordType.ITEMS, KeywordType.CONTAINS, KeywordType.ADDITIONAL_PROPERTIES, KeywordType.PROPERTIES, KeywordType.PATTERN_PROPERTIES, KeywordType.DEPENDENT_SCHEMAS, - KeywordType.PROPERTYNAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), + KeywordType.PROPERTY_NAMES, KeywordType.IF_THEN_ELSE, new NonValidationKeyword("then"), new NonValidationKeyword("else"), KeywordType.ALL_OF, KeywordType.ANY_OF, KeywordType.ONE_OF, KeywordType.NOT); public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary( From 6315c2764fdfc3e1439c3f04a3fc588a986143f1 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Sun, 28 Sep 2025 09:52:46 +0800 Subject: [PATCH 67/74] Refactor SpecificationVersionRange and rename constants --- .../schema/SpecificationVersionRange.java | 22 ++-- .../schema/keyword/ContainsValidator.java | 4 +- .../networknt/schema/keyword/KeywordType.java | 118 +++++++++--------- .../keyword/UnevaluatedItemsValidator.java | 4 +- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/networknt/schema/SpecificationVersionRange.java b/src/main/java/com/networknt/schema/SpecificationVersionRange.java index e7bb94e6a..846872f51 100644 --- a/src/main/java/com/networknt/schema/SpecificationVersionRange.java +++ b/src/main/java/com/networknt/schema/SpecificationVersionRange.java @@ -7,17 +7,17 @@ * SpecificationVersionRange. */ public enum SpecificationVersionRange { - None(new SpecificationVersion[] { }), - AllVersions(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV6(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV6MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), - MinV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MaxV7(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), - MaxV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09 }), - MinV201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), - MinV202012(new SpecificationVersion[] { SpecificationVersion.DRAFT_2020_12 }), - V201909(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09 }), - V7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7 }); + NONE(new SpecificationVersion[] { }), + ALL_VERSIONS(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MIN_DRAFT_6(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + DRAFT_6_TO_DRAFT_7(new SpecificationVersion[] { SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MIN_DRAFT_7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MAX_DRAFT_7(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7 }), + MAX_DRAFT_2019_09(new SpecificationVersion[] { SpecificationVersion.DRAFT_4, SpecificationVersion.DRAFT_6, SpecificationVersion.DRAFT_7, SpecificationVersion.DRAFT_2019_09 }), + MIN_DRAFT_2019_09(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09, SpecificationVersion.DRAFT_2020_12 }), + MIN_DRAFT_2020_12(new SpecificationVersion[] { SpecificationVersion.DRAFT_2020_12 }), + DRAFT_2019_09(new SpecificationVersion[] { SpecificationVersion.DRAFT_2019_09 }), + DRAFT_7(new SpecificationVersion[] { SpecificationVersion.DRAFT_7 }); private final EnumSet versions; diff --git a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java index a9c43deaf..381c72cbf 100644 --- a/src/main/java/com/networknt/schema/keyword/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/ContainsValidator.java @@ -25,7 +25,7 @@ import com.networknt.schema.annotation.Annotation; import com.networknt.schema.path.NodePath; -import static com.networknt.schema.SpecificationVersionRange.MinV201909; +import static com.networknt.schema.SpecificationVersionRange.MIN_DRAFT_2019_09; import java.util.ArrayList; import java.util.List; @@ -53,7 +53,7 @@ public ContainsValidator(SchemaLocation schemaLocation, NodePath evaluationPath, // Draft 6 added the contains keyword but maxContains and minContains first // appeared in Draft 2019-09 so the semantics of the validation changes // slightly. - this.isMinV201909 = MinV201909.getVersions().contains(this.schemaContext.getDialect().getSpecificationVersion()); + this.isMinV201909 = MIN_DRAFT_2019_09.getVersions().contains(this.schemaContext.getDialect().getSpecificationVersion()); Integer currentMax = null; Integer currentMin = null; diff --git a/src/main/java/com/networknt/schema/keyword/KeywordType.java b/src/main/java/com/networknt/schema/keyword/KeywordType.java index ed79703c4..d89e4b1ca 100644 --- a/src/main/java/com/networknt/schema/keyword/KeywordType.java +++ b/src/main/java/com/networknt/schema/keyword/KeywordType.java @@ -36,62 +36,62 @@ KeywordValidator newInstance(SchemaLocation schemaLocation, NodePath evaluationP } public enum KeywordType implements Keyword { - ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, SpecificationVersionRange.MaxV7), - ALL_OF("allOf", AllOfValidator::new, SpecificationVersionRange.MaxV7), - ANY_OF("anyOf", AnyOfValidator::new, SpecificationVersionRange.MaxV7), - CONST("const", ConstValidator::new, SpecificationVersionRange.MinV6MaxV7), - CONTAINS("contains", ContainsValidator::new, SpecificationVersionRange.MinV6MaxV7), - CONTENT_ENCODING("contentEncoding", ContentEncodingValidator::new, SpecificationVersionRange.V7), - CONTENT_MEDIA_TYPE("contentMediaType", ContentMediaTypeValidator::new, SpecificationVersionRange.V7), - DEPENDENCIES("dependencies", DependenciesValidator::new, SpecificationVersionRange.AllVersions), - DEPENDENT_REQUIRED("dependentRequired", DependentRequired::new, SpecificationVersionRange.None), - DEPENDENT_SCHEMAS("dependentSchemas", DependentSchemas::new, SpecificationVersionRange.None), - DISCRIMINATOR("discriminator", DiscriminatorValidator::new, SpecificationVersionRange.None), - DYNAMIC_REF("$dynamicRef", DynamicRefValidator::new, SpecificationVersionRange.None), - ENUM("enum", EnumValidator::new, SpecificationVersionRange.MaxV7), - EXCLUSIVE_MAXIMUM("exclusiveMaximum", ExclusiveMaximumValidator::new, SpecificationVersionRange.MinV6MaxV7), - EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, SpecificationVersionRange.MinV6MaxV7), - FALSE("false", FalseValidator::new, SpecificationVersionRange.MinV6), - FORMAT("format", null, SpecificationVersionRange.MaxV7) { + ADDITIONAL_PROPERTIES("additionalProperties", AdditionalPropertiesValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + ALL_OF("allOf", AllOfValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + ANY_OF("anyOf", AnyOfValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + CONST("const", ConstValidator::new, SpecificationVersionRange.DRAFT_6_TO_DRAFT_7), + CONTAINS("contains", ContainsValidator::new, SpecificationVersionRange.DRAFT_6_TO_DRAFT_7), + CONTENT_ENCODING("contentEncoding", ContentEncodingValidator::new, SpecificationVersionRange.DRAFT_7), + CONTENT_MEDIA_TYPE("contentMediaType", ContentMediaTypeValidator::new, SpecificationVersionRange.DRAFT_7), + DEPENDENCIES("dependencies", DependenciesValidator::new, SpecificationVersionRange.ALL_VERSIONS), + DEPENDENT_REQUIRED("dependentRequired", DependentRequired::new, SpecificationVersionRange.NONE), + DEPENDENT_SCHEMAS("dependentSchemas", DependentSchemas::new, SpecificationVersionRange.NONE), + DISCRIMINATOR("discriminator", DiscriminatorValidator::new, SpecificationVersionRange.NONE), + DYNAMIC_REF("$dynamicRef", DynamicRefValidator::new, SpecificationVersionRange.NONE), + ENUM("enum", EnumValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + EXCLUSIVE_MAXIMUM("exclusiveMaximum", ExclusiveMaximumValidator::new, SpecificationVersionRange.DRAFT_6_TO_DRAFT_7), + EXCLUSIVE_MINIMUM("exclusiveMinimum", ExclusiveMinimumValidator::new, SpecificationVersionRange.DRAFT_6_TO_DRAFT_7), + FALSE("false", FalseValidator::new, SpecificationVersionRange.MIN_DRAFT_6), + FORMAT("format", null, SpecificationVersionRange.MAX_DRAFT_7) { @Override public KeywordValidator newValidator(SchemaLocation schemaLocation, NodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) { throw new UnsupportedOperationException("Use FormatKeyword instead"); } }, - ID("id", null, SpecificationVersionRange.AllVersions), - IF_THEN_ELSE("if", IfValidator::new, SpecificationVersionRange.V7), - ITEMS("items", ItemsValidator::new, SpecificationVersionRange.None), - ITEMS_LEGACY("items", ItemsLegacyValidator::new, SpecificationVersionRange.MaxV7), - MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, SpecificationVersionRange.None), - MAX_ITEMS("maxItems", MaxItemsValidator::new, SpecificationVersionRange.MaxV7), - MAX_LENGTH("maxLength", MaxLengthValidator::new, SpecificationVersionRange.MaxV7), - MAX_PROPERTIES("maxProperties", MaxPropertiesValidator::new, SpecificationVersionRange.MaxV7), - MAXIMUM("maximum", MaximumValidator::new, SpecificationVersionRange.MaxV7), - MIN_CONTAINS("minContains", MinMaxContainsValidator::new, SpecificationVersionRange.None), - MIN_ITEMS("minItems", MinItemsValidator::new, SpecificationVersionRange.MaxV7), - MIN_LENGTH("minLength", MinLengthValidator::new, SpecificationVersionRange.MaxV7), - MIN_PROPERTIES("minProperties", MinPropertiesValidator::new, SpecificationVersionRange.MaxV7), - MINIMUM("minimum", MinimumValidator::new, SpecificationVersionRange.MaxV7), - MULTIPLE_OF("multipleOf", MultipleOfValidator::new, SpecificationVersionRange.MaxV7), - NOT_ALLOWED("notAllowed", NotAllowedValidator::new, SpecificationVersionRange.AllVersions), - NOT("not", NotValidator::new, SpecificationVersionRange.MaxV7), - ONE_OF("oneOf", OneOfValidator::new, SpecificationVersionRange.MaxV7), - PATTERN_PROPERTIES("patternProperties", PatternPropertiesValidator::new, SpecificationVersionRange.MaxV7), - PATTERN("pattern", PatternValidator::new, SpecificationVersionRange.MaxV7), - PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, SpecificationVersionRange.None), - PROPERTIES("properties", PropertiesValidator::new, SpecificationVersionRange.MaxV7), - PROPERTY_DEPENDENCIES("propertyDependencies", PropertyDependenciesValidator::new, SpecificationVersionRange.None), - PROPERTY_NAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.MinV6MaxV7), - READ_ONLY("readOnly", ReadOnlyValidator::new, SpecificationVersionRange.V7), - RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, SpecificationVersionRange.None), - REF("$ref", RefValidator::new, SpecificationVersionRange.MaxV7), - REQUIRED("required", RequiredValidator::new, SpecificationVersionRange.MaxV7), - TRUE("true", TrueValidator::new, SpecificationVersionRange.MinV6), - TYPE("type", TypeValidator::new, SpecificationVersionRange.MaxV7), - UNEVALUATED_ITEMS("unevaluatedItems", UnevaluatedItemsValidator::new, SpecificationVersionRange.None), - UNEVALUATED_PROPERTIES("unevaluatedProperties",UnevaluatedPropertiesValidator::new,SpecificationVersionRange.None), - UNION_TYPE("unionType", UnionTypeValidator::new, SpecificationVersionRange.None), - UNIQUE_ITEMS("uniqueItems", UniqueItemsValidator::new, SpecificationVersionRange.MaxV7), - WRITE_ONLY("writeOnly", WriteOnlyValidator::new, SpecificationVersionRange.V7), + ID("id", null, SpecificationVersionRange.ALL_VERSIONS), + IF_THEN_ELSE("if", IfValidator::new, SpecificationVersionRange.DRAFT_7), + ITEMS("items", ItemsValidator::new, SpecificationVersionRange.NONE), + ITEMS_LEGACY("items", ItemsLegacyValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MAX_CONTAINS("maxContains",MinMaxContainsValidator::new, SpecificationVersionRange.NONE), + MAX_ITEMS("maxItems", MaxItemsValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MAX_LENGTH("maxLength", MaxLengthValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MAX_PROPERTIES("maxProperties", MaxPropertiesValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MAXIMUM("maximum", MaximumValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MIN_CONTAINS("minContains", MinMaxContainsValidator::new, SpecificationVersionRange.NONE), + MIN_ITEMS("minItems", MinItemsValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MIN_LENGTH("minLength", MinLengthValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MIN_PROPERTIES("minProperties", MinPropertiesValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MINIMUM("minimum", MinimumValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + MULTIPLE_OF("multipleOf", MultipleOfValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + NOT_ALLOWED("notAllowed", NotAllowedValidator::new, SpecificationVersionRange.ALL_VERSIONS), + NOT("not", NotValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + ONE_OF("oneOf", OneOfValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + PATTERN_PROPERTIES("patternProperties", PatternPropertiesValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + PATTERN("pattern", PatternValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + PREFIX_ITEMS("prefixItems", PrefixItemsValidator::new, SpecificationVersionRange.NONE), + PROPERTIES("properties", PropertiesValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + PROPERTY_DEPENDENCIES("propertyDependencies", PropertyDependenciesValidator::new, SpecificationVersionRange.NONE), + PROPERTY_NAMES("propertyNames", PropertyNamesValidator::new, SpecificationVersionRange.DRAFT_6_TO_DRAFT_7), + READ_ONLY("readOnly", ReadOnlyValidator::new, SpecificationVersionRange.DRAFT_7), + RECURSIVE_REF("$recursiveRef", RecursiveRefValidator::new, SpecificationVersionRange.NONE), + REF("$ref", RefValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + REQUIRED("required", RequiredValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + TRUE("true", TrueValidator::new, SpecificationVersionRange.MIN_DRAFT_6), + TYPE("type", TypeValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + UNEVALUATED_ITEMS("unevaluatedItems", UnevaluatedItemsValidator::new, SpecificationVersionRange.NONE), + UNEVALUATED_PROPERTIES("unevaluatedProperties",UnevaluatedPropertiesValidator::new,SpecificationVersionRange.NONE), + UNION_TYPE("unionType", UnionTypeValidator::new, SpecificationVersionRange.NONE), + UNIQUE_ITEMS("uniqueItems", UniqueItemsValidator::new, SpecificationVersionRange.MAX_DRAFT_7), + WRITE_ONLY("writeOnly", WriteOnlyValidator::new, SpecificationVersionRange.DRAFT_7), ; private static final Map CONSTANTS = new HashMap<>(); @@ -104,18 +104,18 @@ public enum KeywordType implements Keyword { private final String value; private final ValidatorFactory validatorFactory; - private final SpecificationVersionRange versionCode; + private final SpecificationVersionRange specificationVersionRange; - KeywordType(String value, ValidatorFactory validatorFactory, SpecificationVersionRange versionCode) { + KeywordType(String value, ValidatorFactory validatorFactory, SpecificationVersionRange specificationVersionRange) { this.value = value; this.validatorFactory = validatorFactory; - this.versionCode = versionCode; + this.specificationVersionRange = specificationVersionRange; } - public static List getKeywords(SpecificationVersion versionFlag) { + public static List getKeywords(SpecificationVersion specificationVersion) { final List result = new ArrayList<>(); for (KeywordType keyword : values()) { - if (keyword.getVersionCode().getVersions().contains(versionFlag)) { + if (keyword.getSpecificationVersionRange().getVersions().contains(specificationVersion)) { result.add(keyword); } } @@ -150,7 +150,7 @@ public String getValue() { return this.value; } - public SpecificationVersionRange getVersionCode() { - return this.versionCode; + public SpecificationVersionRange getSpecificationVersionRange() { + return this.specificationVersionRange; } } diff --git a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java index e15c5ecd3..f596ad7f9 100644 --- a/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/keyword/UnevaluatedItemsValidator.java @@ -24,7 +24,7 @@ import com.networknt.schema.annotation.Annotation; import com.networknt.schema.path.NodePath; -import static com.networknt.schema.SpecificationVersionRange.MinV202012; +import static com.networknt.schema.SpecificationVersionRange.MIN_DRAFT_2020_12; import java.util.*; import java.util.function.Predicate; @@ -42,7 +42,7 @@ public UnevaluatedItemsValidator(SchemaLocation schemaLocation, NodePath evaluat Schema parentSchema, SchemaContext schemaContext) { super(KeywordType.UNEVALUATED_ITEMS, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath); - isMinV202012 = MinV202012.getVersions().contains(schemaContext.getDialect().getSpecificationVersion()); + isMinV202012 = MIN_DRAFT_2020_12.getVersions().contains(schemaContext.getDialect().getSpecificationVersion()); if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = schemaContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { From 0641aa920879eaa26e3d1cb64200275b65533808 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:22:29 +0800 Subject: [PATCH 68/74] Fix propertyNames and not messages --- .../java/com/networknt/schema/keyword/NotValidator.java | 2 +- .../networknt/schema/keyword/PropertyNamesValidator.java | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/NotValidator.java b/src/main/java/com/networknt/schema/keyword/NotValidator.java index e3d41782b..36b53c760 100644 --- a/src/main/java/com/networknt/schema/keyword/NotValidator.java +++ b/src/main/java/com/networknt/schema/keyword/NotValidator.java @@ -68,7 +68,7 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo if (test.isEmpty()) { executionContext.addError(error().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .arguments(this.schema.toString()) + .arguments(this.schemaNode.toString()) .build()); } } diff --git a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java index a29ec29f6..a3502cee8 100644 --- a/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/keyword/PropertyNamesValidator.java @@ -46,15 +46,10 @@ public void validate(ExecutionContext executionContext, JsonNode node, JsonNode final TextNode pnameText = TextNode.valueOf(pname); innerSchema.validate(executionContext, pnameText, node, instanceLocation.append(pname)); for (final Error schemaError : schemaErrors) { - final String path = schemaError.getInstanceLocation().toString(); - String msg = schemaError.getMessage(); - if (msg.startsWith(path)) { - msg = msg.substring(path.length()).replaceFirst("^:\\s*", ""); - } existingErrors.add( error().property(pname).instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .arguments(pname, msg).build()); + .arguments(pname, schemaError.getMessage()).build()); } schemaErrors.clear(); } From ccebd93f577413b19c8e6e5d15069ec14b4e5d8d Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:53:31 +0800 Subject: [PATCH 69/74] Rename VocabularyFactory to VocabularyRegistry --- .../com/networknt/schema/dialect/Dialect.java | 18 +++++++++--------- ...aryFactory.java => VocabularyRegistry.java} | 10 +++++----- .../schema/vocabulary/VocabularyTest.java | 10 +++++----- 3 files changed, 19 insertions(+), 19 deletions(-) rename src/main/java/com/networknt/schema/vocabulary/{VocabularyFactory.java => VocabularyRegistry.java} (75%) diff --git a/src/main/java/com/networknt/schema/dialect/Dialect.java b/src/main/java/com/networknt/schema/dialect/Dialect.java index 8ec0aa4d8..ebe04b2bc 100644 --- a/src/main/java/com/networknt/schema/dialect/Dialect.java +++ b/src/main/java/com/networknt/schema/dialect/Dialect.java @@ -35,7 +35,7 @@ import com.networknt.schema.utils.Strings; import com.networknt.schema.vocabulary.Vocabularies; import com.networknt.schema.vocabulary.Vocabulary; -import com.networknt.schema.vocabulary.VocabularyFactory; +import com.networknt.schema.vocabulary.VocabularyRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +81,7 @@ public static class Builder { private final Map formats = new HashMap<>(); private final Map vocabularies = new HashMap<>(); private FormatKeywordFactory formatKeywordFactory = null; - private VocabularyFactory vocabularyFactory = null; + private VocabularyRegistry vocabularyRegistry = null; private KeywordFactory unknownKeywordFactory = null; public Builder(String id) { @@ -124,13 +124,13 @@ public Builder formatKeywordFactory(FormatKeywordFactory formatKeywordFactory) { } /** - * Sets the vocabulary factory for handling custom vocabularies. + * Sets the vocabulary registry for handling custom vocabularies. * - * @param vocabularyFactory the factory + * @param vocabularyRegistry the registry * @return the builder */ - public Builder vocabularyFactory(VocabularyFactory vocabularyFactory) { - this.vocabularyFactory = vocabularyFactory; + public Builder vocabularyRegistry(VocabularyRegistry vocabularyRegistry) { + this.vocabularyRegistry = vocabularyRegistry; return this; } @@ -293,8 +293,8 @@ public Dialect build() { for(Entry entry : this.vocabularies.entrySet()) { Vocabulary vocabulary = null; String id = entry.getKey(); - if (this.vocabularyFactory != null) { - vocabulary = this.vocabularyFactory.getVocabulary(id); + if (this.vocabularyRegistry != null) { + vocabulary = this.vocabularyRegistry.getVocabulary(id); } if (vocabulary == null) { vocabulary = Vocabularies.getVocabulary(id); @@ -385,7 +385,7 @@ public static Builder builder(Dialect blueprint) { .formats(blueprint.builder.formats.values()) .specificationVersion(blueprint.getSpecificationVersion()) .vocabularies(vocabularies) - .vocabularyFactory(blueprint.builder.vocabularyFactory) + .vocabularyRegistry(blueprint.builder.vocabularyRegistry) .formatKeywordFactory(blueprint.builder.formatKeywordFactory) .unknownKeywordFactory(blueprint.builder.unknownKeywordFactory) ; diff --git a/src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java b/src/main/java/com/networknt/schema/vocabulary/VocabularyRegistry.java similarity index 75% rename from src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java rename to src/main/java/com/networknt/schema/vocabulary/VocabularyRegistry.java index 8169ac090..e712c652f 100644 --- a/src/main/java/com/networknt/schema/vocabulary/VocabularyFactory.java +++ b/src/main/java/com/networknt/schema/vocabulary/VocabularyRegistry.java @@ -16,15 +16,15 @@ package com.networknt.schema.vocabulary; /** - * Factory for {@link Vocabulary}. + * Registry for {@link Vocabulary}. */ @FunctionalInterface -public interface VocabularyFactory { +public interface VocabularyRegistry { /** - * Gets the vocabulary given the vocabulary iri. + * Gets the vocabulary given the vocabulary id. * - * @param iri the vocabulary iri + * @param id the vocabulary id which is an iri * @return the vocabulary */ - Vocabulary getVocabulary(String iri); + Vocabulary getVocabulary(String id); } diff --git a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java index 0294cdca7..b90e5d205 100644 --- a/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/vocabulary/VocabularyTest.java @@ -203,8 +203,8 @@ void customVocabulary() { + " }\r\n" + " }\r\n" + "}"; - VocabularyFactory vocabularyFactory = uri -> { - if ("https://www.example.com/vocab/format".equals(uri)) { + VocabularyRegistry vocabularyRegistry = id -> { + if ("https://www.example.com/vocab/format".equals(id)) { return new Vocabulary("https://www.example.com/vocab/format", new AnnotationKeyword("hello")); } return null; @@ -212,14 +212,14 @@ void customVocabulary() { Dialect dialect = Dialect .builder("https://www.example.com/no-validation-no-format/schema", Dialects.getDraft202012()) - .vocabularyFactory(vocabularyFactory) + .vocabularyRegistry(vocabularyRegistry) .build(); - SchemaRegistry factory = SchemaRegistry + SchemaRegistry schemaRegistry = SchemaRegistry .withDefaultDialect(SpecificationVersion.DRAFT_2020_12, builder -> builder.dialectRegistry(new BasicDialectRegistry(dialect)).resourceLoaders(resourceLoaders -> resourceLoaders.resources(Collections .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); - Schema schema = factory.getSchema(schemaData); + Schema schema = schemaRegistry.getSchema(schemaData); OutputUnit outputUnit = schema.validate("{}", InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { executionContext.executionConfig(executionConfig -> executionConfig .annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true)); From a1853508bce5422cc124677a6dc1d17e0b191193 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:55:49 +0800 Subject: [PATCH 70/74] Rename enableSchemaCache to schemaCacheEnabled in SchemaRegistry --- .../com/networknt/schema/SchemaRegistry.java | 16 ++++++++-------- .../schema/JsonSchemaFactoryUriCacheTest.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/networknt/schema/SchemaRegistry.java b/src/main/java/com/networknt/schema/SchemaRegistry.java index 15e8ef49f..dfcfb80d9 100644 --- a/src/main/java/com/networknt/schema/SchemaRegistry.java +++ b/src/main/java/com/networknt/schema/SchemaRegistry.java @@ -63,7 +63,7 @@ public static class Builder { private DialectRegistry dialectRegistry = null; private NodeReader nodeReader = null; private SchemaLoader schemaLoader = null; - private boolean enableSchemaCache = true; + private boolean schemaCacheEnabled = true; private SchemaRegistryConfig schemaRegistryConfig = null; /** @@ -114,8 +114,8 @@ public Builder dialectRegistry(DialectRegistry dialectRegistry) { return this; } - public Builder enableSchemaCache(boolean enableSchemaCache) { - this.enableSchemaCache = enableSchemaCache; + public Builder schemaCacheEnabled(boolean schemaCacheEnabled) { + this.schemaCacheEnabled = schemaCacheEnabled; return this; } @@ -203,7 +203,7 @@ public Builder schemas(Function mapIriToObject, Function schemaCache = new ConcurrentHashMap<>(); - private final boolean enableSchemaCache; + private final boolean schemaCacheEnabled; private final DialectRegistry dialectRegistry; private final SchemaRegistryConfig schemaRegistryConfig; private SchemaRegistry(NodeReader nodeReader, String defaultDialectId, SchemaLoader schemaLoader, - boolean enableSchemaCache, DialectRegistry dialectRegistry, SchemaRegistryConfig schemaRegistryConfig) { + boolean schemaCacheEnabled, DialectRegistry dialectRegistry, SchemaRegistryConfig schemaRegistryConfig) { if (defaultDialectId == null || defaultDialectId.trim().isEmpty()) { throw new IllegalArgumentException("defaultDialectId must not be null or empty"); } this.nodeReader = nodeReader != null ? nodeReader : BasicNodeReader.getInstance(); this.defaultDialectId = defaultDialectId; this.schemaLoader = schemaLoader != null ? schemaLoader : SchemaLoader.getDefault(); - this.enableSchemaCache = enableSchemaCache; + this.schemaCacheEnabled = schemaCacheEnabled; this.dialectRegistry = dialectRegistry != null ? dialectRegistry : new DefaultDialectRegistry(); this.schemaRegistryConfig = schemaRegistryConfig != null ? schemaRegistryConfig : SchemaRegistryConfig.getInstance(); @@ -658,7 +658,7 @@ public Schema getSchema(final SchemaLocation schemaUri) { * @return the schema */ public Schema loadSchema(final SchemaLocation schemaUri) { - if (enableSchemaCache) { + if (schemaCacheEnabled) { // ConcurrentHashMap computeIfAbsent does not allow calls that result in a // recursive update to the map. // The getMapperSchema potentially recurses to call back to getSchema again diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index db9176359..99fd3a603 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -47,7 +47,7 @@ private void runCacheTest(boolean enableCache) throws JsonProcessingException { private SchemaRegistry buildJsonSchemaFactory(CustomURIFetcher uriFetcher, boolean enableSchemaCache) { return SchemaRegistry.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12)) - .enableSchemaCache(enableSchemaCache) + .schemaCacheEnabled(enableSchemaCache) .resourceLoaders(resourceLoaders -> resourceLoaders.add(uriFetcher)) .dialectRegistry(new BasicDialectRegistry(Dialects.getDraft202012())) .build(); From f9dbc78816b611b1cdd6d6dd6bfaac358186d8b6 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:08:47 +0800 Subject: [PATCH 71/74] Fix discriminator --- .../schema/keyword/OneOfValidator.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java index ef41ffdac..eee38b822 100644 --- a/src/main/java/com/networknt/schema/keyword/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/keyword/OneOfValidator.java @@ -105,28 +105,28 @@ protected void validate(ExecutionContext executionContext, JsonNode node, JsonNo boolean discriminatorMatchFound = false; DiscriminatorState discriminator = executionContext.getDiscriminatorMapping().get(instanceLocation); JsonNode refNode = schema.getSchemaNode().get("$ref"); - if (discriminator != null && refNode != null) { + if (discriminator != null && refNode != null && discriminator.hasDiscriminatingValue()) { discriminatorMatchFound = discriminator.matches(refNode.asText()); - } - if (discriminatorMatchFound) { - /* - * Note that discriminator cannot change the outcome of the evaluation but can - * be used to filter off any additional messages - * - * The discriminator will cause all messages other than the one with the // - * matching discriminator to be discarded. - */ - if (!subSchemaErrors.isEmpty()) { + if (discriminatorMatchFound) { /* - * This means that the discriminated value has errors and doesn't match so these - * errors are the only ones that will be reported *IF* there are no other - * schemas that successfully validate to meet the requirement of anyOf. + * Note that discriminator cannot change the outcome of the evaluation but can + * be used to filter off any additional messages * - * If there are any successful schemas as per anyOf, all these errors will be - * discarded. + * The discriminator will cause all messages other than the one with the // + * matching discriminator to be discarded. */ - discriminatorErrors = new ArrayList<>(subSchemaErrors); - allErrors = null; // This is no longer needed + if (!subSchemaErrors.isEmpty()) { + /* + * This means that the discriminated value has errors and doesn't match so these + * errors are the only ones that will be reported *IF* there are no other + * schemas that successfully validate to meet the requirement of anyOf. + * + * If there are any successful schemas as per anyOf, all these errors will be + * discarded. + */ + discriminatorErrors = new ArrayList<>(subSchemaErrors); + allErrors = null; // This is no longer needed + } } } else { // This is the normal handling when discriminators aren't enabled From 81b99862d3feef6816a96d3b0ae816d0ebecb5a4 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Thu, 2 Oct 2025 21:01:42 +0800 Subject: [PATCH 72/74] Fix enum --- .../java/com/networknt/schema/utils/JsonNodeTypes.java | 2 +- .../com/networknt/schema/AbstractJsonSchemaTestSuite.java | 1 + src/test/java/com/networknt/schema/Issue404Test.java | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java b/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java index ab641df96..cdd9bd818 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeTypes.java @@ -49,7 +49,7 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch // Skip the type validation when the schema is an enum object schema. Since the current type // of node itself can be used for type validation. - if (isEnumObjectSchema(parentSchema)) { + if (isEnumObjectSchema(parentSchema) && !config.isStrict("type", Boolean.TRUE)) { return true; } if (config != null && config.isTypeLoose()) { diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 9ee1b1987..9bb76ed27 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -183,6 +183,7 @@ private DynamicNode buildContainer(SpecificationVersion defaultVersion, TestCase @SuppressWarnings("deprecation") boolean typeLoose = testSpec.isTypeLoose(); SchemaRegistryConfig.Builder configBuilder = SchemaRegistryConfig.builder(); + configBuilder.strict("type", false); configBuilder.typeLoose(typeLoose); configBuilder.regularExpressionFactory( TestSpec.RegexKind.JDK == testSpec.getRegex() ? JDKRegularExpressionFactory.getInstance() diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 5cc37ebe9..f9b560ebe 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import java.io.InputStream; @@ -29,7 +29,11 @@ void expectObjectNotIntegerV7() throws Exception { InputStream dataInputStream = getClass().getResourceAsStream(dataPath); JsonNode node = getJsonNodeFromStreamContent(dataInputStream); List errors = schema.validate(node); - Assertions.assertEquals(0, errors.size()); + assertEquals(1, errors.size()); + assertEquals("type", errors.get(0).getKeyword()); + assertEquals("/bar", errors.get(0).getInstanceLocation().toString()); + assertEquals("/properties/bar/$ref/type", errors.get(0).getEvaluationPath().toString()); + assertEquals("https://example.com/address.schema.json#/properties/foo/type", errors.get(0).getSchemaLocation().toString()); } } From 8f605b52d363bb04cb27f69bfc6f550b8c54bcf0 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Fri, 3 Oct 2025 22:22:01 +0800 Subject: [PATCH 73/74] Rename JsonLocationAware to TokenStreamLocationAware to align with v3 --- .../node/LocationJsonNodeFactory.java | 38 +++++++++---------- ...are.java => TokenStreamLocationAware.java} | 4 +- ...=> TokenStreamLocationAwareArrayNode.java} | 22 +++++------ ...kenStreamLocationAwareBigIntegerNode.java} | 14 +++---- ...> TokenStreamLocationAwareBinaryNode.java} | 18 ++++----- ... TokenStreamLocationAwareBooleanNode.java} | 14 +++---- ... TokenStreamLocationAwareDecimalNode.java} | 14 +++---- ...> TokenStreamLocationAwareDoubleNode.java} | 14 +++---- ...=> TokenStreamLocationAwareFloatNode.java} | 14 +++---- ...a => TokenStreamLocationAwareIntNode.java} | 14 +++---- ... => TokenStreamLocationAwareLongNode.java} | 14 +++---- ... => TokenStreamLocationAwareNullNode.java} | 14 +++---- ...> TokenStreamLocationAwareObjectNode.java} | 18 ++++----- ... => TokenStreamLocationAwarePOJONode.java} | 14 +++---- ...=> TokenStreamLocationAwareShortNode.java} | 14 +++---- ... => TokenStreamLocationAwareTextNode.java} | 14 +++---- .../com/networknt/schema/utils/JsonNodes.java | 10 ++--- .../serialization/DefaultNodeReaderTest.java | 14 +++---- .../networknt/schema/utils/JsonNodesTest.java | 34 ++++++++--------- 19 files changed, 156 insertions(+), 156 deletions(-) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAware.java => TokenStreamLocationAware.java} (88%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareArrayNode.java => TokenStreamLocationAwareArrayNode.java} (56%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareBigIntegerNode.java => TokenStreamLocationAwareBigIntegerNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareBinaryNode.java => TokenStreamLocationAwareBinaryNode.java} (58%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareBooleanNode.java => TokenStreamLocationAwareBooleanNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareDecimalNode.java => TokenStreamLocationAwareDecimalNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareDoubleNode.java => TokenStreamLocationAwareDoubleNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareFloatNode.java => TokenStreamLocationAwareFloatNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareIntNode.java => TokenStreamLocationAwareIntNode.java} (65%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareLongNode.java => TokenStreamLocationAwareLongNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareNullNode.java => TokenStreamLocationAwareNullNode.java} (65%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareObjectNode.java => TokenStreamLocationAwareObjectNode.java} (60%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwarePOJONode.java => TokenStreamLocationAwarePOJONode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareShortNode.java => TokenStreamLocationAwareShortNode.java} (64%) rename src/main/java/com/networknt/schema/serialization/node/{JsonLocationAwareTextNode.java => TokenStreamLocationAwareTextNode.java} (64%) diff --git a/src/main/java/com/networknt/schema/serialization/node/LocationJsonNodeFactory.java b/src/main/java/com/networknt/schema/serialization/node/LocationJsonNodeFactory.java index 1f027fb71..87fa9ec75 100644 --- a/src/main/java/com/networknt/schema/serialization/node/LocationJsonNodeFactory.java +++ b/src/main/java/com/networknt/schema/serialization/node/LocationJsonNodeFactory.java @@ -32,7 +32,7 @@ import com.fasterxml.jackson.databind.util.RawValue; /** - * {@link JsonNodeFactory} that creates {@link JsonLocationAware} nodes. + * {@link JsonNodeFactory} that creates {@link TokenStreamLocationAware} nodes. *

* Note that this will adversely affect performance as nodes with the same value * can no longer be cached and reused. @@ -57,12 +57,12 @@ public LocationJsonNodeFactory(JsonParser jsonParser) { @Override public BooleanNode booleanNode(boolean v) { - return new JsonLocationAwareBooleanNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareBooleanNode(v, this.jsonParser.currentTokenLocation()); } @Override public NullNode nullNode() { - return new JsonLocationAwareNullNode(this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareNullNode(this.jsonParser.currentTokenLocation()); } @Override @@ -72,7 +72,7 @@ public JsonNode missingNode() { @Override public NumericNode numberNode(byte v) { - return new JsonLocationAwareIntNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareIntNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -82,7 +82,7 @@ public ValueNode numberNode(Byte v) { @Override public NumericNode numberNode(short v) { - return new JsonLocationAwareShortNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareShortNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -92,7 +92,7 @@ public ValueNode numberNode(Short value) { @Override public NumericNode numberNode(int v) { - return new JsonLocationAwareIntNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareIntNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -102,7 +102,7 @@ public ValueNode numberNode(Integer v) { @Override public NumericNode numberNode(long v) { - return new JsonLocationAwareLongNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareLongNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -112,12 +112,12 @@ public ValueNode numberNode(Long v) { @Override public ValueNode numberNode(BigInteger v) { - return (v == null) ? nullNode() : new JsonLocationAwareBigIntegerNode(v, this.jsonParser.currentTokenLocation()); + return (v == null) ? nullNode() : new TokenStreamLocationAwareBigIntegerNode(v, this.jsonParser.currentTokenLocation()); } @Override public NumericNode numberNode(float v) { - return new JsonLocationAwareFloatNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareFloatNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -127,7 +127,7 @@ public ValueNode numberNode(Float v) { @Override public NumericNode numberNode(double v) { - return new JsonLocationAwareDoubleNode(v, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareDoubleNode(v, this.jsonParser.currentTokenLocation()); } @Override @@ -137,47 +137,47 @@ public ValueNode numberNode(Double v) { @Override public ValueNode numberNode(BigDecimal v) { - return (v == null) ? nullNode() : new JsonLocationAwareDecimalNode(v, this.jsonParser.currentTokenLocation()); + return (v == null) ? nullNode() : new TokenStreamLocationAwareDecimalNode(v, this.jsonParser.currentTokenLocation()); } @Override public TextNode textNode(String text) { - return new JsonLocationAwareTextNode(text, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareTextNode(text, this.jsonParser.currentTokenLocation()); } @Override public BinaryNode binaryNode(byte[] data) { - return new JsonLocationAwareBinaryNode(data, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareBinaryNode(data, this.jsonParser.currentTokenLocation()); } @Override public BinaryNode binaryNode(byte[] data, int offset, int length) { - return new JsonLocationAwareBinaryNode(data, offset, length, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareBinaryNode(data, offset, length, this.jsonParser.currentTokenLocation()); } @Override public ArrayNode arrayNode() { - return new JsonLocationAwareArrayNode(this, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareArrayNode(this, this.jsonParser.currentTokenLocation()); } @Override public ArrayNode arrayNode(int capacity) { - return new JsonLocationAwareArrayNode(this, capacity, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareArrayNode(this, capacity, this.jsonParser.currentTokenLocation()); } @Override public ObjectNode objectNode() { - return new JsonLocationAwareObjectNode(this, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwareObjectNode(this, this.jsonParser.currentTokenLocation()); } @Override public ValueNode pojoNode(Object pojo) { - return new JsonLocationAwarePOJONode(pojo, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwarePOJONode(pojo, this.jsonParser.currentTokenLocation()); } @Override public ValueNode rawValueNode(RawValue value) { - return new JsonLocationAwarePOJONode(value, this.jsonParser.currentTokenLocation()); + return new TokenStreamLocationAwarePOJONode(value, this.jsonParser.currentTokenLocation()); } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAware.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAware.java similarity index 88% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAware.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAware.java index 5e70699d8..073970292 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAware.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAware.java @@ -20,11 +20,11 @@ /** * JsonNodes that are aware of the token location will implement this interface. */ -public interface JsonLocationAware { +public interface TokenStreamLocationAware { /** * Gets the token location. * * @return the token location */ - JsonLocation tokenLocation(); + JsonLocation tokenStreamLocation(); } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareArrayNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareArrayNode.java similarity index 56% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareArrayNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareArrayNode.java index 1e59f8f2f..cfa6569d2 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareArrayNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareArrayNode.java @@ -23,32 +23,32 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; /** - * {@link ArrayNode} that is {@link JsonLocationAware}. + * {@link ArrayNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareArrayNode extends ArrayNode implements JsonLocationAware { +public class TokenStreamLocationAwareArrayNode extends ArrayNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareArrayNode(JsonNodeFactory nf, int capacity, JsonLocation tokenLocation) { + public TokenStreamLocationAwareArrayNode(JsonNodeFactory nf, int capacity, JsonLocation tokenStreamLocation) { super(nf, capacity); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } - public JsonLocationAwareArrayNode(JsonNodeFactory nf, List children, JsonLocation tokenLocation) { + public TokenStreamLocationAwareArrayNode(JsonNodeFactory nf, List children, JsonLocation tokenStreamLocation) { super(nf, children); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } - public JsonLocationAwareArrayNode(JsonNodeFactory nf, JsonLocation tokenLocation) { + public TokenStreamLocationAwareArrayNode(JsonNodeFactory nf, JsonLocation tokenStreamLocation) { super(nf); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBigIntegerNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBigIntegerNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBigIntegerNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBigIntegerNode.java index d1cd995fa..c3b621a98 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBigIntegerNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBigIntegerNode.java @@ -21,22 +21,22 @@ import com.fasterxml.jackson.databind.node.BigIntegerNode; /** - * {@link BigIntegerNode} that is {@link JsonLocationAware}. + * {@link BigIntegerNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareBigIntegerNode extends BigIntegerNode implements JsonLocationAware { +public class TokenStreamLocationAwareBigIntegerNode extends BigIntegerNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareBigIntegerNode(BigInteger v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareBigIntegerNode(BigInteger v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBinaryNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBinaryNode.java similarity index 58% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBinaryNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBinaryNode.java index 04bec537a..dc0e46019 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBinaryNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBinaryNode.java @@ -19,28 +19,28 @@ import com.fasterxml.jackson.databind.node.BinaryNode; /** - * {@link BinaryNode} that is {@link JsonLocationAware}. + * {@link BinaryNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareBinaryNode extends BinaryNode implements JsonLocationAware { +public class TokenStreamLocationAwareBinaryNode extends BinaryNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareBinaryNode(byte[] data, JsonLocation tokenLocation) { + public TokenStreamLocationAwareBinaryNode(byte[] data, JsonLocation tokenStreamLocation) { super(data); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } - public JsonLocationAwareBinaryNode(byte[] data, int offset, int length, JsonLocation tokenLocation) { + public TokenStreamLocationAwareBinaryNode(byte[] data, int offset, int length, JsonLocation tokenStreamLocation) { super(data, offset, length); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBooleanNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBooleanNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBooleanNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBooleanNode.java index 2b6fee413..867d38445 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareBooleanNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareBooleanNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.BooleanNode; /** - * {@link BooleanNode} that is {@link JsonLocationAware}. + * {@link BooleanNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareBooleanNode extends BooleanNode implements JsonLocationAware { +public class TokenStreamLocationAwareBooleanNode extends BooleanNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareBooleanNode(boolean v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareBooleanNode(boolean v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDecimalNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDecimalNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDecimalNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDecimalNode.java index f850cb4a5..5da546b1c 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDecimalNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDecimalNode.java @@ -21,22 +21,22 @@ import com.fasterxml.jackson.databind.node.DecimalNode; /** - * {@link DecimalNode} that is {@link JsonLocationAware}. + * {@link DecimalNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareDecimalNode extends DecimalNode implements JsonLocationAware { +public class TokenStreamLocationAwareDecimalNode extends DecimalNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareDecimalNode(BigDecimal v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareDecimalNode(BigDecimal v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDoubleNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDoubleNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDoubleNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDoubleNode.java index 110a0836b..5c07ef536 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareDoubleNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareDoubleNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.DoubleNode; /** - * {@link DoubleNode} that is {@link JsonLocationAware}. + * {@link DoubleNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareDoubleNode extends DoubleNode implements JsonLocationAware { +public class TokenStreamLocationAwareDoubleNode extends DoubleNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareDoubleNode(double v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareDoubleNode(double v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareFloatNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareFloatNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareFloatNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareFloatNode.java index 54067ae0f..654d5d0bb 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareFloatNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareFloatNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.FloatNode; /** - * {@link FloatNode} that is {@link JsonLocationAware}. + * {@link FloatNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareFloatNode extends FloatNode implements JsonLocationAware { +public class TokenStreamLocationAwareFloatNode extends FloatNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareFloatNode(float v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareFloatNode(float v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareIntNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareIntNode.java similarity index 65% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareIntNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareIntNode.java index e72fd28dc..5c5e29b9d 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareIntNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareIntNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.IntNode; /** - * {@link IntNode} that is {@link JsonLocationAware}. + * {@link IntNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareIntNode extends IntNode implements JsonLocationAware { +public class TokenStreamLocationAwareIntNode extends IntNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareIntNode(int v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareIntNode(int v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareLongNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareLongNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareLongNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareLongNode.java index 0ceb5714d..5d107717f 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareLongNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareLongNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.LongNode; /** - * {@link LongNode} that is {@link JsonLocationAware}. + * {@link LongNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareLongNode extends LongNode implements JsonLocationAware { +public class TokenStreamLocationAwareLongNode extends LongNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareLongNode(long v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareLongNode(long v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareNullNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareNullNode.java similarity index 65% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareNullNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareNullNode.java index e73463488..329ebab3c 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareNullNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareNullNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.NullNode; /** - * {@link NullNode} that is {@link JsonLocationAware}. + * {@link NullNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareNullNode extends NullNode implements JsonLocationAware { +public class TokenStreamLocationAwareNullNode extends NullNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareNullNode(JsonLocation tokenLocation) { + public TokenStreamLocationAwareNullNode(JsonLocation tokenStreamLocation) { super(); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareObjectNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareObjectNode.java similarity index 60% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareObjectNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareObjectNode.java index 6bf776c3a..b33c04741 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareObjectNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareObjectNode.java @@ -23,27 +23,27 @@ import com.fasterxml.jackson.databind.node.ObjectNode; /** - * {@link ObjectNode} that is {@link JsonLocationAware}. + * {@link ObjectNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareObjectNode extends ObjectNode implements JsonLocationAware { +public class TokenStreamLocationAwareObjectNode extends ObjectNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareObjectNode(JsonNodeFactory nc, Map children, JsonLocation tokenLocation) { + public TokenStreamLocationAwareObjectNode(JsonNodeFactory nc, Map children, JsonLocation tokenStreamLocation) { super(nc, children); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } - public JsonLocationAwareObjectNode(JsonNodeFactory nc, JsonLocation tokenLocation) { + public TokenStreamLocationAwareObjectNode(JsonNodeFactory nc, JsonLocation tokenStreamLocation) { super(nc); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwarePOJONode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwarePOJONode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwarePOJONode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwarePOJONode.java index 7ca728363..5d4c89cdb 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwarePOJONode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwarePOJONode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.POJONode; /** - * {@link POJONode} that is {@link JsonLocationAware}. + * {@link POJONode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwarePOJONode extends POJONode implements JsonLocationAware { +public class TokenStreamLocationAwarePOJONode extends POJONode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwarePOJONode(Object v, JsonLocation tokenLocation) { + public TokenStreamLocationAwarePOJONode(Object v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareShortNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareShortNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareShortNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareShortNode.java index 60027c05d..64c7ad886 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareShortNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareShortNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.ShortNode; /** - * {@link ShortNode} that is {@link JsonLocationAware}. + * {@link ShortNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareShortNode extends ShortNode implements JsonLocationAware { +public class TokenStreamLocationAwareShortNode extends ShortNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareShortNode(short v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareShortNode(short v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareTextNode.java b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareTextNode.java similarity index 64% rename from src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareTextNode.java rename to src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareTextNode.java index 6f3b16cec..32ebea8c1 100644 --- a/src/main/java/com/networknt/schema/serialization/node/JsonLocationAwareTextNode.java +++ b/src/main/java/com/networknt/schema/serialization/node/TokenStreamLocationAwareTextNode.java @@ -19,22 +19,22 @@ import com.fasterxml.jackson.databind.node.TextNode; /** - * {@link TextNode} that is {@link JsonLocationAware}. + * {@link TextNode} that is {@link TokenStreamLocationAware}. */ -public class JsonLocationAwareTextNode extends TextNode implements JsonLocationAware { +public class TokenStreamLocationAwareTextNode extends TextNode implements TokenStreamLocationAware { /** * */ private static final long serialVersionUID = 1L; - private final JsonLocation tokenLocation; + private final JsonLocation tokenStreamLocation; - public JsonLocationAwareTextNode(String v, JsonLocation tokenLocation) { + public TokenStreamLocationAwareTextNode(String v, JsonLocation tokenStreamLocation) { super(v); - this.tokenLocation = tokenLocation; + this.tokenStreamLocation = tokenStreamLocation; } @Override - public JsonLocation tokenLocation() { - return this.tokenLocation; + public JsonLocation tokenStreamLocation() { + return this.tokenStreamLocation; } } diff --git a/src/main/java/com/networknt/schema/utils/JsonNodes.java b/src/main/java/com/networknt/schema/utils/JsonNodes.java index 4ef33dc17..e0e76d17c 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodes.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodes.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.networknt.schema.path.NodePath; -import com.networknt.schema.serialization.node.JsonLocationAware; +import com.networknt.schema.serialization.node.TokenStreamLocationAware; import com.networknt.schema.serialization.node.JsonNodeFactoryFactory; /** @@ -118,14 +118,14 @@ public static JsonNode readTree(ObjectMapper objectMapper, InputStream inputStre } /** - * Gets the token location of the {@link JsonNode} that implements {@link JsonLocationAware}. + * Gets the token location of the {@link JsonNode} that implements {@link TokenStreamLocationAware}. * * @param jsonNode the node * @return the JsonLocation */ - public static JsonLocation tokenLocationOf(JsonNode jsonNode) { - if (jsonNode instanceof JsonLocationAware) { - return ((JsonLocationAware) jsonNode).tokenLocation(); + public static JsonLocation tokenStreamLocationOf(JsonNode jsonNode) { + if (jsonNode instanceof TokenStreamLocationAware) { + return ((TokenStreamLocationAware) jsonNode).tokenStreamLocation(); } throw new IllegalArgumentException("JsonNode does not contain the location information."); } diff --git a/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java b/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java index 9e3a0b950..e6a61f0e9 100644 --- a/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java +++ b/src/test/java/com/networknt/schema/serialization/DefaultNodeReaderTest.java @@ -43,17 +43,17 @@ void location() throws JsonParseException, IOException { + "}"; JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); JsonNode idNode = jsonNode.at("/$id"); - JsonLocation location = JsonNodes.tokenLocationOf(idNode); + JsonLocation location = JsonNodes.tokenStreamLocationOf(idNode); assertEquals(2, location.getLineNr()); assertEquals(10, location.getColumnNr()); JsonNode formatNode = jsonNode.at("/properties/startDate/format"); - location = JsonNodes.tokenLocationOf(formatNode); + location = JsonNodes.tokenStreamLocationOf(formatNode); assertEquals(5, location.getLineNr()); assertEquals(17, location.getColumnNr()); JsonNode minLengthNode = jsonNode.at("/properties/startDate/minLength"); - location = JsonNodes.tokenLocationOf(minLengthNode); + location = JsonNodes.tokenStreamLocationOf(minLengthNode); assertEquals(6, location.getLineNr()); assertEquals(20, location.getColumnNr()); } @@ -71,8 +71,8 @@ void jsonLocation() throws IOException { + "}"; JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.JSON); - JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/format")); - JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/minLength")); + JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(jsonNode.at("/properties/startDate/format")); + JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(jsonNode.at("/properties/startDate/minLength")); assertEquals(5, formatSchemaNodeTokenLocation.getLineNr()); assertEquals(17, formatSchemaNodeTokenLocation.getColumnNr()); @@ -91,8 +91,8 @@ void yamlLocation() throws IOException { + " minLength: 6\r\n"; JsonNode jsonNode = NodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.YAML); - JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/format")); - JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/minLength")); + JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(jsonNode.at("/properties/startDate/format")); + JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(jsonNode.at("/properties/startDate/minLength")); assertEquals(5, formatSchemaNodeTokenLocation.getLineNr()); assertEquals(13, formatSchemaNodeTokenLocation.getColumnNr()); diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index 056c8b4d0..fef8bfc6f 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -57,17 +57,17 @@ void location() throws JsonParseException, IOException { JsonNode jsonNode = JsonNodes.readTree(JsonMapperFactory.getInstance(), schemaData, LocationJsonNodeFactoryFactory.getInstance()); JsonNode idNode = jsonNode.at("/$id"); - JsonLocation location = JsonNodes.tokenLocationOf(idNode); + JsonLocation location = JsonNodes.tokenStreamLocationOf(idNode); assertEquals(2, location.getLineNr()); assertEquals(10, location.getColumnNr()); JsonNode formatNode = jsonNode.at("/properties/startDate/format"); - location = JsonNodes.tokenLocationOf(formatNode); + location = JsonNodes.tokenStreamLocationOf(formatNode); assertEquals(5, location.getLineNr()); assertEquals(17, location.getColumnNr()); JsonNode minLengthNode = jsonNode.at("/properties/startDate/minLength"); - location = JsonNodes.tokenLocationOf(minLengthNode); + location = JsonNodes.tokenStreamLocationOf(minLengthNode); assertEquals(6, location.getLineNr()); assertEquals(20, location.getColumnNr()); } @@ -94,11 +94,11 @@ void jsonLocation() { }); List list = messages.stream().collect(Collectors.toList()); Error format = list.get(0); - JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(format.getInstanceNode()); - JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(format.getSchemaNode()); + JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenStreamLocationOf(format.getInstanceNode()); + JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(format.getSchemaNode()); Error minLength = list.get(1); - JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); - JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); + JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenStreamLocationOf(minLength.getInstanceNode()); + JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(minLength.getSchemaNode()); assertEquals("format", format.getKeyword()); @@ -139,11 +139,11 @@ void yamlLocation() { }); List list = messages.stream().collect(Collectors.toList()); Error format = list.get(0); - JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(format.getInstanceNode()); - JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(format.getSchemaNode()); + JsonLocation formatInstanceNodeTokenLocation = JsonNodes.tokenStreamLocationOf(format.getInstanceNode()); + JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(format.getSchemaNode()); Error minLength = list.get(1); - JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getInstanceNode()); - JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(minLength.getSchemaNode()); + JsonLocation minLengthInstanceNodeTokenLocation = JsonNodes.tokenStreamLocationOf(minLength.getInstanceNode()); + JsonLocation minLengthSchemaNodeTokenLocation = JsonNodes.tokenStreamLocationOf(minLength.getSchemaNode()); assertEquals("format", format.getKeyword()); @@ -191,16 +191,16 @@ void types() { .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); JsonNode root = JsonNodes.readTree(objectMapper, json, LocationJsonNodeFactoryFactory.getInstance()); JsonNode numberNode = root.at("/properties/number"); - assertEquals(3, JsonNodes.tokenLocationOf(numberNode).getLineNr()); + assertEquals(3, JsonNodes.tokenStreamLocationOf(numberNode).getLineNr()); JsonNode stringNode = root.at("/properties/string"); - assertEquals(4, JsonNodes.tokenLocationOf(stringNode).getLineNr()); + assertEquals(4, JsonNodes.tokenStreamLocationOf(stringNode).getLineNr()); JsonNode booleanNode = root.at("/properties/boolean"); - assertEquals(5, JsonNodes.tokenLocationOf(booleanNode).getLineNr()); + assertEquals(5, JsonNodes.tokenStreamLocationOf(booleanNode).getLineNr()); JsonNode arrayNode = root.at("/properties/array"); - assertEquals(6, JsonNodes.tokenLocationOf(arrayNode).getLineNr()); + assertEquals(6, JsonNodes.tokenStreamLocationOf(arrayNode).getLineNr()); JsonNode objectNode = root.at("/properties/object"); - assertEquals(7, JsonNodes.tokenLocationOf(objectNode).getLineNr()); + assertEquals(7, JsonNodes.tokenStreamLocationOf(objectNode).getLineNr()); JsonNode nullNode = root.at("/properties/null"); - assertEquals(8, JsonNodes.tokenLocationOf(nullNode).getLineNr()); + assertEquals(8, JsonNodes.tokenStreamLocationOf(nullNode).getLineNr()); } } From 8c31de400adcf46d6d492b4f3ed5642dda695349 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:18:13 +0800 Subject: [PATCH 74/74] migration docs --- doc/migration-2.0.0.md | 138 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 doc/migration-2.0.0.md diff --git a/doc/migration-2.0.0.md b/doc/migration-2.0.0.md new file mode 100644 index 000000000..8294847f9 --- /dev/null +++ b/doc/migration-2.0.0.md @@ -0,0 +1,138 @@ +## Migration to 2.0.0 from 1.5.x + +### Compatibility + +| Version | Java Compatibility | Jackson Version | Comments | +| ----------------- | ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | +| `2.0.0` | Java 8 | Jackson 2 | This allows clients that still require to use Java 8 to have an incremental upgrade path to 3.0.0. | +| `3.0.0` (Planned) | Java 17 | Jackson 3 | The change to Java compatibility is because Jackson 3 requires Java 17. | + +### Major Changes + +- Removal of deprecated methods and functionality from 1.x. +- Major renaming of many of the public APIs and moving of classes into sub-packages. +- Errors are returned as a `List` instead of a `Set`. +- External resources will not be automatically fetched by default. This now requires opt-in via configuration. + - This is to conform to the specification that requires such functionality to be disabled by default to prefer offline operation. Note however that classpath resources will still be automatically loaded. + +#### Renaming and Refactoring + +| Old | New | Comments | +| ----------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `com.networknt.schema.JsonMetaSchema` | `com.networknt.schema.dialect.Dialect` | Renamed to convey that this represents the dialect which has a set of keywords and vocabularies with precise semantics. The dialect id is used to identify the meta-schema which can be used to validate that a schema conforms to this dialect. | +| `com.networknt.schema.JsonMetaSchemaFactory` | `com.networknt.schema.dialect.DialectRegistry` | Renamed to convey that this stores a set of registered dialects that will be used when `$schema` is found in a schema. For instance it is possible to override a standard dialect specified by a specification by registering a dialect using that dialect id. | +| `com.networknt.schema.JsonSchema` | `com.networknt.schema.Schema` | Simplify naming. It is no longer possible to associate a configuration with a specific schema. | +| `com.networknt.schema.JsonSchemaFactory` | `com.networknt.schema.SchemaRegistry` | Renamed to convey that this stores a set of registered schema resources. All schemas created will use the same configuration used for the registry. Therefore all the keywords of the schemas in the registry will be consistent configured. If there is a need for different configuration, a separate schema registry should be used. | +| `com.networknt.schema.ValidationMessage` | `com.networknt.schema.Error` | Renamed to convey the intent better as a validation error raised by assertion keywords when processing instance data, or as a parse error when processing the schema data. The instance location has also been removed from the message. Therefore calling `error.getMessage()` no longer has the instance location pre-pended to the message. Calling `error.toString()` will return the message with the instance location prepended if the instance location exists. | +| `com.networknt.schema.SchemaValidatorsConfig` | `com.networknt.schema.SchemaRegistryConfig` | Renamed to convey that this configuration is shared by all schemas from the same schema registry. The walk configuration has been moved out. | +| `com.networknt.schema.SchemaValidatorsConfig` | `com.networknt.schema.walk.WalkConfig` | The walk configuration has been moved to a separate class. | +| `com.networknt.schema.ErrorMessageType` | No replacement | The concept of error codes have been removed, instead the message keys used for generating the localised messages can be used instead to distinguish the error messages. | +| `com.networknt.schema.ValidationContext` | `com.networknt.schema.SchemaContext` | Renamed to convey that this is the schema context shared for all the schemas and validators for the same overall schema with the same dialect. | +| `com.networknt.schema.ValidatorTypeCode` | `com.networknt.schema.keyword.KeywordType` | Renamed to convey that these are keywords as the error codes have been removed. | +| `com.networknt.schema.JsonSchemaValidator` | `com.networknt.schema.Validator` | Simplify naming. | +| `com.networknt.schema.JsonValidator` | `com.networknt.schema.keyword.KeywordValidator` | Renamed to convey the intent that this is the validator created for keywords. | +| `com.networknt.schema.walk.JsonSchemaWalker` | `com.networknt.schema.walk.Walker` | Simplify naming. | +| `com.networknt.schema.SpecVersion.VersionFlag` | `com.networknt.schema.SpecificationVersion` | Renamed and flatten the hierarchy. | +| `com.networknt.schema.SchemaId` | `com.networknt.schema.dialect.DialectId` | Renamed to convey that this is the dialect id used for the `$schema` keyword in schemas and `$id` keyword in meta-schemas. | +| `com.networknt.schema.VocabularyFactory` | `com.networknt.schema.vocabulary.VocabularyRegistry` | Renamed to convey that this stores a set of registered vocabularies that contain keywords. | +| `com.networknt.schema.JsonSchemaIdValidator` | `com.networknt.schema.SchemaIdValidator` | Simplify naming. | +| `com.networknt.schema.JsonSchemaRef` | `com.networknt.schema.SchemaRef` | Simplify naming. | +| `com.networknt.schema.JsonSchemaException` | `com.networknt.schema.SchemaException` | Simplify naming. | +| `com.networknt.schema.JsonNodePath` | `com.networknt.schema.NodePath` | Simplify naming. | +| `com.networknt.schema.serialization.JsonNodeReader` | `com.networknt.schema.serialization.NodeReader` | Simplify naming. | +| `com.networknt.schema.annotation.JsonNodeAnnotation` | `com.networknt.schema.annotation.Annotation` | Simplify naming. | +| `com.networknt.schema.annotation.JsonNodeAnnotations` | `com.networknt.schema.annotation.Annotations` | Simplify naming. | +| `com.networknt.schema.ValidationResult` | `com.networknt.schema.Result` | Renamed to convey that this stores not just validation results but the output from walking. | +| `com.networknt.schema.VersionCode` | `com.networknt.schema.SpecificationVersionRange` | Renamed to convey that this contains specification version ranges. | + +#### Configuration + +##### Schema Validators Configuration + +The `com.networknt.schema.SchemaValidatorsConfig` file has been replaced by either `com.networknt.schema.SchemaRegistryConfig` or `com.networknt.schema.walk.WalkConfig` or moved to `com.networknt.schema.ExecutionConfig` and can no longer be configured on a per schema basis. + +| Name | Migration | +| ------------------------------------- | -------------------------------------------------------- | +| `applyDefaultsStrategy` | `com.networknt.schema.walk.WalkConfig` | +| `cacheRefs` | `com.networknt.schema.SchemaRegistryConfig` | +| `discriminatorKeywordEnabled` | Removed. Dialect must contain a `discriminator` keyword. | +| `errorMessageKeyword` | `com.networknt.schema.SchemaRegistryConfig` | +| `executionContextCustomizer` | `com.networknt.schema.SchemaRegistryConfig` | +| `failFast` | `com.networknt.schema.SchemaRegistryConfig` | +| `formatAssertionsEnabled` | `com.networknt.schema.SchemaRegistryConfig` | +| `javaSemantics` | `com.networknt.schema.SchemaRegistryConfig` | +| `locale` | `com.networknt.schema.SchemaRegistryConfig` | +| `losslessNarrowing` | `com.networknt.schema.SchemaRegistryConfig` | +| `messageSource` | `com.networknt.schema.SchemaRegistryConfig` | +| `nullableKeywordEnabled` | Removed. Dialect must contain a `nullable` keyword. | +| `pathType` | `com.networknt.schema.SchemaRegistryConfig` | +| `preloadJsonSchema` | `com.networknt.schema.SchemaRegistryConfig` | +| `preloadJsonSchemaRefMaxNestingDepth` | `com.networknt.schema.SchemaRegistryConfig` | +| `readOnly` | `com.networknt.schema.ExecutionConfig` | +| `regularExpressionFactory` | `com.networknt.schema.SchemaRegistryConfig` | +| `schemaIdValidator` | `com.networknt.schema.SchemaRegistryConfig` | +| `strict` | `com.networknt.schema.SchemaRegistryConfig` | +| `typeLoose` | `com.networknt.schema.SchemaRegistryConfig` | +| `writeOnly` | `com.networknt.schema.ExecutionConfig` | +| `itemWalkListeners` | `com.networknt.schema.walk.WalkConfig` | +| `keywordWalkListeners` | `com.networknt.schema.walk.WalkConfig` | +| `propertyWalkListeners` | `com.networknt.schema.walk.WalkConfig` | + +#### API + +```java +package com.example.demo; + +import java.util.List; +import java.util.Map; + +import com.networknt.schema.Error; +import com.networknt.schema.InputFormat; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaLocation; +import com.networknt.schema.SchemaRegistry; +import com.networknt.schema.dialect.Dialects; + +public class Demo { + public static void main(String[] args) { + String schemaData = """ + { + "$id": "https://example.com/address.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "streetAddress": { + "type": "string" + }, + "locality": { + "type": "string" + }, + "region": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "countryName": { + "type": "string" + } + }, + "required": [ "locality", "region", "countryName" ] + } + """; + String instanceData = """ + { + "streetAddress": "456 Main St", + "region": "State", + "postalCode": "12345", + "countryName": "Country" + } + """; + SchemaRegistry schemaRegistry = SchemaRegistry.withDialect(Dialects.getDraft202012(), + builder -> builder.schemas(Map.of("https://example.com/address.schema.json", schemaData))); + Schema schema = schemaRegistry.getSchema(SchemaLocation.of("https://example.com/address.schema.json")); + List errors = schema.validate(instanceData, InputFormat.JSON); + System.out.println(errors); + } +} +```