From de0999377da6653fc9de7ce1c2464dadde7a3fb0 Mon Sep 17 00:00:00 2001 From: Faron Dutton Date: Mon, 15 May 2023 12:09:51 -0400 Subject: [PATCH] Adds support for validating uri-template formats Resolves #756 --- src/main/java/com/networknt/schema/JsonMetaSchema.java | 1 + .../java/com/networknt/schema/JsonSchemaTestSuiteTest.java | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java index 65edef3bf..9662cbcf0 100644 --- a/src/main/java/com/networknt/schema/JsonMetaSchema.java +++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java @@ -87,6 +87,7 @@ static PatternFormat pattern(String name, String regex) { COMMON_BUILTIN_FORMATS.add(pattern("utc-millisec", "^[0-9]+(\\.?[0-9]+)?$")); COMMON_BUILTIN_FORMATS.add(pattern("style", "\\s*(.+?):\\s*([^;]+);?")); COMMON_BUILTIN_FORMATS.add(pattern("uuid", "^\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12}$")); + COMMON_BUILTIN_FORMATS.add(pattern("uri-template", "^([^\\p{Cntrl}\"'%<>\\^`\\{|\\}]|%\\p{XDigit}{2}|\\{[+#./;?&=,!@|]?((\\w|%\\p{XDigit}{2})(\\.?(\\w|%\\p{XDigit}{2}))*(:[1-9]\\d{0,3}|\\*)?)(,((\\w|%\\p{XDigit}{2})(\\.?(\\w|%\\p{XDigit}{2}))*(:[1-9]\\d{0,3}|\\*)?))*\\})*$")); COMMON_BUILTIN_FORMATS.add(new DateFormat()); COMMON_BUILTIN_FORMATS.add(new EmailFormat()); COMMON_BUILTIN_FORMATS.add(new RegexFormat()); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java index 026ece757..0889a47de 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java @@ -85,7 +85,6 @@ private void disableV202012Tests() { this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/optional/format/json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/optional/format/relative-json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/optional/format/uri-reference.json")); - this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/optional/format/uri-template.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/ref.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/refRemote.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2020-12/vocabulary.json")); @@ -104,7 +103,6 @@ private void disableV201909Tests() { this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/optional/format/json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/optional/format/relative-json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/optional/format/uri-reference.json")); - this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/optional/format/uri-template.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/recursiveRef.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/ref.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft2019-09/refRemote.json")); @@ -124,7 +122,6 @@ private void disableV7Tests() { this.disabled.add(Paths.get("src/test/suite/tests/draft7/optional/format/json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft7/optional/format/relative-json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft7/optional/format/uri-reference.json")); - this.disabled.add(Paths.get("src/test/suite/tests/draft7/optional/format/uri-template.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft7/ref.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft7/refRemote.json")); } @@ -134,7 +131,6 @@ private void disableV6Tests() { this.disabled.add(Paths.get("src/test/suite/tests/draft6/optional/format.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft6/optional/format/json-pointer.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft6/optional/format/uri-reference.json")); - this.disabled.add(Paths.get("src/test/suite/tests/draft6/optional/format/uri-template.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft6/ref.json")); this.disabled.add(Paths.get("src/test/suite/tests/draft6/refRemote.json")); }