From 708a04e6e20ea6eb251f04a81edb73d20559267f Mon Sep 17 00:00:00 2001 From: fdutton Date: Tue, 11 Apr 2023 22:18:34 -0400 Subject: [PATCH] Corrects treating 1.0 as an integer --- .../schema/ExclusiveMaximumValidator.java | 6 +- .../schema/ExclusiveMinimumValidator.java | 6 +- .../networknt/schema/MaximumValidator.java | 6 +- .../networknt/schema/MinimumValidator.java | 6 +- .../networknt/schema/SpecVersionDetector.java | 33 ++- .../com/networknt/schema/TypeValidator.java | 218 +----------------- .../networknt/schema/ValidationContext.java | 2 +- .../networknt/schema/utils/JsonNodeUtil.java | 64 ++--- .../schema/JsonSchemaTestSuiteTest.java | 8 +- .../networknt/schema/TypeValidatorTest.java | 2 +- 10 files changed, 71 insertions(+), 280 deletions(-) diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java index 5e4e771e7..33c28d07c 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java @@ -17,6 +17,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.utils.JsonNodeUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +27,7 @@ import java.util.Collections; import java.util.Set; -public class ExclusiveMaximumValidator extends BaseJsonValidator implements JsonValidator { +public class ExclusiveMaximumValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(ExclusiveMaximumValidator.class); private final ThresholdMixin typedMaximum; @@ -99,7 +101,7 @@ public String thresholdValue() { public Set validate(JsonNode node, JsonNode rootNode, String at) { debug(logger, node, rootNode, at); - if (!TypeValidator.isNumber(node, validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, validationContext.getConfig())) { // maximum only applies to numbers return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java index 456447c1f..91f6bbc48 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java @@ -17,6 +17,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.utils.JsonNodeUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +27,7 @@ import java.util.Collections; import java.util.Set; -public class ExclusiveMinimumValidator extends BaseJsonValidator implements JsonValidator { +public class ExclusiveMinimumValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(MinimumValidator.class); /** @@ -106,7 +108,7 @@ public String thresholdValue() { public Set validate(JsonNode node, JsonNode rootNode, String at) { debug(logger, node, rootNode, at); - if (!TypeValidator.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { // minimum only applies to numbers return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/MaximumValidator.java index f5dc36b2c..2e7f216f1 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/MaximumValidator.java @@ -17,6 +17,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.utils.JsonNodeUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +27,7 @@ import java.util.Collections; import java.util.Set; -public class MaximumValidator extends BaseJsonValidator implements JsonValidator { +public class MaximumValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(MaximumValidator.class); private static final String PROPERTY_EXCLUSIVE_MAXIMUM = "exclusiveMaximum"; @@ -108,7 +110,7 @@ public String thresholdValue() { public Set validate(JsonNode node, JsonNode rootNode, String at) { debug(logger, node, rootNode, at); - if (!TypeValidator.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { // maximum only applies to numbers return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/MinimumValidator.java index cc1d304fb..47b902f27 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/MinimumValidator.java @@ -17,6 +17,8 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.utils.JsonNodeUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +27,7 @@ import java.util.Collections; import java.util.Set; -public class MinimumValidator extends BaseJsonValidator implements JsonValidator { +public class MinimumValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(MinimumValidator.class); private static final String PROPERTY_EXCLUSIVE_MINIMUM = "exclusiveMinimum"; @@ -115,7 +117,7 @@ public String thresholdValue() { public Set validate(JsonNode node, JsonNode rootNode, String at) { debug(logger, node, rootNode, at); - if (!TypeValidator.isNumber(node, this.validationContext.getConfig())) { + if (!JsonNodeUtil.isNumber(node, this.validationContext.getConfig())) { // minimum only applies to numbers return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/SpecVersionDetector.java b/src/main/java/com/networknt/schema/SpecVersionDetector.java index 7be7ac29b..d8407a850 100644 --- a/src/main/java/com/networknt/schema/SpecVersionDetector.java +++ b/src/main/java/com/networknt/schema/SpecVersionDetector.java @@ -17,6 +17,7 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.SpecVersion.VersionFlag; import java.util.Optional; @@ -41,7 +42,7 @@ private SpecVersionDetector() { * @param jsonNode JSON Node to read from * @return Spec version if present, otherwise throws an exception */ - public static SpecVersion.VersionFlag detect(JsonNode jsonNode) { + public static VersionFlag detect(JsonNode jsonNode) { return detectOptionalVersion(jsonNode).orElseThrow( () -> new JsonSchemaException("'" + SCHEMA_TAG + "' tag is not present") ); @@ -54,7 +55,7 @@ public static SpecVersion.VersionFlag detect(JsonNode jsonNode) { * @param jsonNode JSON Node to read from * @return Spec version if present, otherwise empty */ - public static Optional detectOptionalVersion(JsonNode jsonNode) { + public static Optional detectOptionalVersion(JsonNode jsonNode) { return Optional.ofNullable(jsonNode.get(SCHEMA_TAG)).map(schemaTag -> { final boolean forceHttps = true; @@ -64,23 +65,37 @@ public static Optional detectOptionalVersion(JsonNode j String schemaUri = JsonSchemaFactory.normalizeMetaSchemaUri(schemaTagValue, forceHttps, removeEmptyFragmentSuffix); + VersionFlag version = detect(schemaUri); + if (null == version) { + throw new JsonSchemaException("'" + schemaTagValue + "' is unrecognizable schema"); + } + return version; + }); + } + + public static Optional detectOptionalVersion(String schemaUri) { + return Optional.ofNullable(detect(schemaUri)); + } + + private static VersionFlag detect(String schemaUri) { + if (null != schemaUri) { if (schemaUri.equals(JsonMetaSchema.getV4().getUri())) { - return SpecVersion.VersionFlag.V4; + return VersionFlag.V4; } if (schemaUri.equals(JsonMetaSchema.getV6().getUri())) { - return SpecVersion.VersionFlag.V6; + return VersionFlag.V6; } if (schemaUri.equals(JsonMetaSchema.getV7().getUri())) { - return SpecVersion.VersionFlag.V7; + return VersionFlag.V7; } if (schemaUri.equals(JsonMetaSchema.getV201909().getUri())) { - return SpecVersion.VersionFlag.V201909; + return VersionFlag.V201909; } if (schemaUri.equals(JsonMetaSchema.getV202012().getUri())) { - return SpecVersion.VersionFlag.V202012; + return VersionFlag.V202012; } - throw new JsonSchemaException("'" + schemaTagValue + "' is unrecognizable schema"); - }); + } + return null; } } diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/TypeValidator.java index c2f54b9ab..0248f5132 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/TypeValidator.java @@ -17,19 +17,13 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.JsonNodeType; -import com.fasterxml.jackson.databind.node.TextNode; import com.networknt.schema.utils.JsonNodeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; -public class TypeValidator extends BaseJsonValidator implements JsonValidator { - private static final String TYPE = "type"; - private static final String ENUM = "enum"; - private static final String REF = "$ref"; - +public class TypeValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(TypeValidator.class); private JsonType schemaType; @@ -53,57 +47,7 @@ public JsonType getSchemaType() { } public boolean equalsToSchemaType(JsonNode node) { - JsonType nodeType = TypeFactory.getValueNodeType(node, validationContext.getConfig()); - // 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 - // string type and we must convert, otherwise, all schema validations will fail. - if (nodeType != schemaType) { - if (schemaType == JsonType.ANY) { - return true; - } - - if (schemaType == JsonType.NUMBER && nodeType == JsonType.INTEGER) { - return true; - } - - ValidatorState state = (ValidatorState) CollectorContext.getInstance().get(ValidatorState.VALIDATOR_STATE_KEY); - if(JsonType.NULL.equals(nodeType) ){ - if ((state.isComplexValidator() && JsonNodeUtil.isNodeNullable(parentSchema.getParentSchema().getSchemaNode(), validationContext.getConfig())) || - JsonNodeUtil.isNodeNullable(this.getParentSchema().getSchemaNode())) { - return true; - } - } - - // 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)) { - return true; - } - if (validationContext.getConfig().isTypeLoose()) { - // if typeLoose is true, everything can be a size 1 array - if (schemaType == JsonType.ARRAY) { - return true; - } - if (nodeType == JsonType.STRING) { - if (schemaType == JsonType.INTEGER) { - if (isInteger(node.textValue())) { - return true; - } - } else if (schemaType == JsonType.BOOLEAN) { - if (isBoolean(node.textValue())) { - return true; - } - } else if (schemaType == JsonType.NUMBER) { - if (isNumeric(node.textValue())) { - return true; - } - } - } - } - - return false; - } - return true; + return JsonNodeUtil.equalsToSchemaType(node,schemaType, parentSchema, validationContext); } public Set validate(JsonNode node, JsonNode rootNode, String at) { @@ -113,8 +57,7 @@ public Set validate(JsonNode node, JsonNode rootNode, String return unionTypeValidator.validate(node, rootNode, at); } - //if (!equalsToSchemaType(node)) { - if(!JsonNodeUtil.equalsToSchemaType(node,schemaType, parentSchema, validationContext.getConfig())){ + if (!equalsToSchemaType(node)) { JsonType nodeType = TypeFactory.getValueNodeType(node, validationContext.getConfig()); return Collections.singleton(buildValidationMessage(at, nodeType.toString(), schemaType.toString())); } @@ -127,157 +70,12 @@ public Set validate(JsonNode node, JsonNode rootNode, String } private void addToEvaluatedProperties(String propertyPath) { - Object evaluatedProperties = CollectorContext.getInstance().get(UnEvaluatedPropertiesValidator.EVALUATED_PROPERTIES); - List evaluatedPropertiesList = null; + @SuppressWarnings("unchecked") + List evaluatedProperties = (List) CollectorContext.getInstance().get(UnEvaluatedPropertiesValidator.EVALUATED_PROPERTIES); if (evaluatedProperties == null) { - evaluatedPropertiesList = new ArrayList<>(); - CollectorContext.getInstance().add(UnEvaluatedPropertiesValidator.EVALUATED_PROPERTIES, evaluatedPropertiesList); - } else { - evaluatedPropertiesList = (List) evaluatedProperties; - } - evaluatedPropertiesList.add(propertyPath); - } - - public static boolean isInteger(String str) { - if (str == null || str.equals("")) { - 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) { - return false; - } - i = 1; - } - for (; i < str.length(); i++) { - char c = str.charAt(i); - if (c < '0' || c > '9') { - return false; - } - } - return true; - } - - public static boolean isBoolean(String s) { - return "true".equals(s) || "false".equals(s); - } - - public static boolean isNumeric(String str) { - if (str == null || str.equals("")) { - 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(); - - if (str.charAt(i) == MINUS || str.charAt(i) == PLUS) { - if (str.length() == 1) { - return false; - } - i = 1; - } - - char c = str.charAt(i++); - - if (c == CHAR_0) { - // TODO: if leading zeros are supported (counter to JSON spec) handle it here - if (i < len) { - c = str.charAt(i++); - if (c != DOT && c != CHAR_E && c != CHAR_e) { - return false; - } - } - } else if (CHAR_1 <= c && c <= CHAR_9) { - while (i < len && CHAR_0 <= c && c <= CHAR_9) { - c = str.charAt(i++); - } - } else { - return false; - } - - if (c == DOT) { - if (i >= len) { - return false; - } - c = str.charAt(i++); - while (i < len && CHAR_0 <= c && c <= CHAR_9) { - c = str.charAt(i++); - } - } - - if (c == CHAR_E || c == CHAR_e) { - if (i >= len) { - return false; - } - c = str.charAt(i++); - if (c == PLUS || c == MINUS) { - if (i >= len) { - return false; - } - c = str.charAt(i++); - } - while (i < len && CHAR_0 <= c && c <= CHAR_9) { - c = str.charAt(i++); - } - } - - return i >= len && (CHAR_0 <= c && c <= CHAR_9); - } - - private static final char CHAR_0 = '0'; - private static final char CHAR_1 = '1'; - private static final char CHAR_9 = '9'; - private static final char MINUS = '-'; - private static final char PLUS = '+'; - private static final char DOT = '.'; - private static final char CHAR_E = 'E'; - private static final char CHAR_e = 'e'; - - /** - * Check if the type of the JsonNode's value is number based on the - * status of typeLoose flag. - * - * @param node the JsonNode to check - * @param config the SchemaValidatorsConfig to depend on - * @return boolean to indicate if it is a number - */ - public static boolean isNumber(JsonNode node, SchemaValidatorsConfig config) { - if (node.isNumber()) { - return true; - } else if (config.isTypeLoose()) { - if (TypeFactory.getValueNodeType(node, config) == JsonType.STRING) { - return isNumeric(node.textValue()); - } - } - return false; - } - - private static boolean isEnumObjectSchema(JsonSchema 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 - // 3. The parent schema if refer from components, which means the corresponding enum object class would be generated - JsonNode typeNode = null; - JsonNode enumNode = null; - JsonNode refNode = null; - - if (jsonSchema != null) { - if (jsonSchema.getSchemaNode() != null) { - typeNode = jsonSchema.getSchemaNode().get(TYPE); - enumNode = jsonSchema.getSchemaNode().get(ENUM); - } - if (jsonSchema.getParentSchema() != null && jsonSchema.getParentSchema().getSchemaNode() != null) { - refNode = jsonSchema.getParentSchema().getSchemaNode().get(REF); - } - } - if (typeNode != null && enumNode != null && refNode != null) { - return TypeFactory.getSchemaNodeType(typeNode) == JsonType.OBJECT && enumNode.isArray(); + evaluatedProperties = new ArrayList<>(); + CollectorContext.getInstance().add(UnEvaluatedPropertiesValidator.EVALUATED_PROPERTIES, evaluatedProperties); } - return false; + evaluatedProperties.add(propertyPath); } } diff --git a/src/main/java/com/networknt/schema/ValidationContext.java b/src/main/java/com/networknt/schema/ValidationContext.java index 150cd51e3..189ad0214 100644 --- a/src/main/java/com/networknt/schema/ValidationContext.java +++ b/src/main/java/com/networknt/schema/ValidationContext.java @@ -107,7 +107,7 @@ public void leaveDiscriminatorContextImmediately(String at) { discriminatorContexts.pop(); } - protected JsonMetaSchema getMetaSchema() { + public JsonMetaSchema getMetaSchema() { return metaSchema; } diff --git a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java index 9d1823660..635d4a09f 100644 --- a/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java +++ b/src/main/java/com/networknt/schema/utils/JsonNodeUtil.java @@ -1,12 +1,17 @@ package com.networknt.schema.utils; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.networknt.schema.*; - -import java.util.Iterator; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonType; +import com.networknt.schema.SchemaValidatorsConfig; +import com.networknt.schema.SpecVersion.VersionFlag; +import com.networknt.schema.SpecVersionDetector; +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 String TYPE = "type"; private static final String ENUM = "enum"; private static final String REF = "$ref"; @@ -29,51 +34,17 @@ public static boolean isNodeNullable(JsonNode schema, SchemaValidatorsConfig con return false; } - //Check to see if any child node for the OneOf SchemaNode is nullable - public static boolean isChildNodeNullable(ArrayNode oneOfSchemaNode,SchemaValidatorsConfig config){ - Iterator iterator = oneOfSchemaNode.elements(); - while(iterator.hasNext()){ - //If one of the child Node for oneOf is nullable, it means the whole oneOf is nullable - if (isNodeNullable((JsonNode)iterator.next(),config)) return true; - } - return false; - } - - public static boolean matchOneOfTypeNode(JsonNode oneOfSchemaNode, JsonType nodeType ){ - Iterator iterator = oneOfSchemaNode.elements(); - while (iterator.hasNext()){ - JsonNode oneOfTypeNode = (JsonNode) iterator.next(); - JsonNode typeTextNode = oneOfTypeNode.get(TYPE); - if(typeTextNode != null && typeTextNode.asText().equals(nodeType.toString())) //If the nodeType is oneOf the type defined in the oneOf , return true - return true; - } - return false; - } - - public static boolean equalsToSchemaType(JsonNode node, JsonSchema schema, SchemaValidatorsConfig 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 - // string type and we must convert, otherwise, all schema validations will fail. - JsonType schemaType = getSchemaJsonType(schema); - return equalsToSchemaType(node,schemaType,schema.getParentSchema(),config); - - } - - public static JsonType getSchemaJsonType(JsonSchema schema){ - JsonNode typeNode = schema.getSchemaNode().get(TYPE); - if(typeNode!= null) return JsonType.valueOf(typeNode.asText().toUpperCase()); - return JsonType.UNKNOWN; - } - - + public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, JsonSchema parentSchema, ValidationContext validationContext) { + SchemaValidatorsConfig config = validationContext.getConfig(); + JsonType nodeType = TypeFactory.getValueNodeType(node, config); + String metaSchema = validationContext.getMetaSchema().getUri(); + long version = SpecVersionDetector.detectOptionalVersion(metaSchema) + .orElse(VersionFlag.V4) + .getVersionFlagValue(); - public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, JsonSchema parentSchema, SchemaValidatorsConfig 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 // string type and we must convert, otherwise, all schema validations will fail. - - JsonType nodeType = TypeFactory.getValueNodeType(node, config); - if (nodeType != schemaType) { if (schemaType == JsonType.ANY) { return true; @@ -82,6 +53,9 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Jso if (schemaType == JsonType.NUMBER && nodeType == JsonType.INTEGER) { return true; } + if (V6_VALUE <= version && schemaType == JsonType.INTEGER && nodeType == JsonType.NUMBER && 1.0 == node.asDouble()) { + return true; + } if(JsonType.NULL.equals(nodeType)) { if(parentSchema != null) { diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java index 1215d0192..d74cc97df 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java @@ -92,7 +92,6 @@ private void disableV202012Tests() { disabled.add(Paths.get("src/test/suite/tests/draft2020-12/optional/format/uri-template.json")); disabled.add(Paths.get("src/test/suite/tests/draft2020-12/ref.json")); disabled.add(Paths.get("src/test/suite/tests/draft2020-12/refRemote.json")); - disabled.add(Paths.get("src/test/suite/tests/draft2020-12/type.json")); disabled.add(Paths.get("src/test/suite/tests/draft2020-12/unevaluatedItems.json")); disabled.add(Paths.get("src/test/suite/tests/draft2020-12/unevaluatedProperties.json")); disabled.add(Paths.get("src/test/suite/tests/draft2020-12/unknownKeyword.json")); @@ -118,7 +117,6 @@ private void disableV201909Tests() { disabled.add(Paths.get("src/test/suite/tests/draft2019-09/recursiveRef.json")); disabled.add(Paths.get("src/test/suite/tests/draft2019-09/ref.json")); disabled.add(Paths.get("src/test/suite/tests/draft2019-09/refRemote.json")); - disabled.add(Paths.get("src/test/suite/tests/draft2019-09/type.json")); disabled.add(Paths.get("src/test/suite/tests/draft2019-09/unevaluatedItems.json")); disabled.add(Paths.get("src/test/suite/tests/draft2019-09/unevaluatedProperties.json")); disabled.add(Paths.get("src/test/suite/tests/draft2019-09/unknownKeyword.json")); @@ -143,7 +141,6 @@ private void disableV7Tests() { disabled.add(Paths.get("src/test/suite/tests/draft7/optional/format/uri-template.json")); disabled.add(Paths.get("src/test/suite/tests/draft7/ref.json")); disabled.add(Paths.get("src/test/suite/tests/draft7/refRemote.json")); - disabled.add(Paths.get("src/test/suite/tests/draft7/type.json")); disabled.add(Paths.get("src/test/suite/tests/draft7/unknownKeyword.json")); } @@ -157,14 +154,13 @@ private void disableV6Tests() { disabled.add(Paths.get("src/test/suite/tests/draft6/optional/format/uri-template.json")); disabled.add(Paths.get("src/test/suite/tests/draft6/ref.json")); disabled.add(Paths.get("src/test/suite/tests/draft6/refRemote.json")); - disabled.add(Paths.get("src/test/suite/tests/draft6/type.json")); disabled.add(Paths.get("src/test/suite/tests/draft6/unknownKeyword.json")); } private void disableV4Tests() { disabled.add(Paths.get("src/test/suite/tests/draft4/id.json")); - disabled.add(Paths.get("src/test/suite/tests/draft4/optional/ecmascript-regex.json")); // TODO: Not included in the original test. - disabled.add(Paths.get("src/test/suite/tests/draft4/ref.json")); // TODO: Not excluded in the original test. + disabled.add(Paths.get("src/test/suite/tests/draft4/optional/ecmascript-regex.json")); + disabled.add(Paths.get("src/test/suite/tests/draft4/ref.json")); disabled.add(Paths.get("src/test/suite/tests/draft4/refRemote.json")); } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index 962ca13c8..a43e67154 100755 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import static com.networknt.schema.TypeValidator.isNumeric; +import static com.networknt.schema.utils.StringChecker.isNumeric; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue;