summaryrefslogtreecommitdiff
path: root/tests/draft7
diff options
context:
space:
mode:
Diffstat (limited to 'tests/draft7')
-rw-r--r--tests/draft7/contains.json21
-rw-r--r--tests/draft7/id.json10
-rw-r--r--tests/draft7/optional/format/date.json137
-rw-r--r--tests/draft7/propertyNames.json29
-rw-r--r--tests/draft7/ref.json130
-rw-r--r--tests/draft7/refRemote.json23
-rw-r--r--tests/draft7/unknownKeyword.json56
7 files changed, 374 insertions, 32 deletions
diff --git a/tests/draft7/contains.json b/tests/draft7/contains.json
index c5471cc..215da98 100644
--- a/tests/draft7/contains.json
+++ b/tests/draft7/contains.json
@@ -125,5 +125,26 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains with false if subschema",
+ "schema": {
+ "contains": {
+ "if": false,
+ "else": true
+ }
+ },
+ "tests": [
+ {
+ "description": "any non-empty array is valid",
+ "data": ["foo"],
+ "valid": true
+ },
+ {
+ "description": "empty array is invalid",
+ "data": [],
+ "valid": false
+ }
+ ]
}
]
diff --git a/tests/draft7/id.json b/tests/draft7/id.json
index d276001..b58e0d0 100644
--- a/tests/draft7/id.json
+++ b/tests/draft7/id.json
@@ -7,32 +7,32 @@
"id_in_enum": {
"enum": [
{
- "$id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/id/my_identifier.json",
"type": "null"
}
]
},
"real_id_in_schema": {
- "$id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/id/my_identifier.json",
"type": "string"
},
"zzz_id_in_const": {
"const": {
- "$id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/id/my_identifier.json",
"type": "null"
}
}
},
"anyOf": [
{ "$ref": "#/definitions/id_in_enum" },
- { "$ref": "https://localhost:1234/my_identifier.json" }
+ { "$ref": "https://localhost:1234/id/my_identifier.json" }
]
},
"tests": [
{
"description": "exact match to enum, and type matches",
"data": {
- "$id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/id/my_identifier.json",
"type": "null"
},
"valid": true
diff --git a/tests/draft7/optional/format/date.json b/tests/draft7/optional/format/date.json
index 453b51d..554fe54 100644
--- a/tests/draft7/optional/format/date.json
+++ b/tests/draft7/optional/format/date.json
@@ -9,7 +9,142 @@
"valid": true
},
{
- "description": "an invalid date-time string",
+ "description": "a valid date string with 31 days in January",
+ "data": "2020-01-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in January",
+ "data": "2020-01-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 28 days in February (normal)",
+ "data": "2021-02-28",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 29 days in February (normal)",
+ "data": "2021-02-29",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 29 days in February (leap)",
+ "data": "2020-02-29",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 30 days in February (leap)",
+ "data": "2020-02-30",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in March",
+ "data": "2020-03-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in March",
+ "data": "2020-03-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 30 days in April",
+ "data": "2020-04-30",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 31 days in April",
+ "data": "2020-04-31",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in May",
+ "data": "2020-05-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in May",
+ "data": "2020-05-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 30 days in June",
+ "data": "2020-06-30",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 31 days in June",
+ "data": "2020-06-31",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in July",
+ "data": "2020-07-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in July",
+ "data": "2020-07-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in August",
+ "data": "2020-08-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in August",
+ "data": "2020-08-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 30 days in September",
+ "data": "2020-09-30",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 31 days in September",
+ "data": "2020-09-31",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in October",
+ "data": "2020-10-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in October",
+ "data": "2020-10-32",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 30 days in November",
+ "data": "2020-11-30",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 31 days in November",
+ "data": "2020-11-31",
+ "valid": false
+ },
+ {
+ "description": "a valid date string with 31 days in December",
+ "data": "2020-12-31",
+ "valid": true
+ },
+ {
+ "description": "a invalid date string with 32 days in December",
+ "data": "2020-12-32",
+ "valid": false
+ },
+ {
+ "description": "a invalid date string with invalid month",
+ "data": "2020-13-01",
+ "valid": false
+ },
+ {
+ "description": "an invalid date string",
"data": "06/19/1963",
"valid": false
},
diff --git a/tests/draft7/propertyNames.json b/tests/draft7/propertyNames.json
index 8423690..f0788e6 100644
--- a/tests/draft7/propertyNames.json
+++ b/tests/draft7/propertyNames.json
@@ -44,6 +44,35 @@
]
},
{
+ "description": "propertyNames validation with pattern",
+ "schema": {
+ "propertyNames": { "pattern": "^a+$" }
+ },
+ "tests": [
+ {
+ "description": "matching property names valid",
+ "data": {
+ "a": {},
+ "aa": {},
+ "aaa": {}
+ },
+ "valid": true
+ },
+ {
+ "description": "non-matching property name is invalid",
+ "data": {
+ "aaA": {}
+ },
+ "valid": false
+ },
+ {
+ "description": "object without properties is valid",
+ "data": {},
+ "valid": true
+ }
+ ]
+ },
+ {
"description": "propertyNames with boolean schema true",
"schema": {"propertyNames": true},
"tests": [
diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json
index 2ad0193..406ae16 100644
--- a/tests/draft7/ref.json
+++ b/tests/draft7/ref.json
@@ -410,32 +410,6 @@
]
},
{
- "description": "Location-independent identifier with absolute URI",
- "schema": {
- "allOf": [{
- "$ref": "http://localhost:1234/bar#foo"
- }],
- "definitions": {
- "A": {
- "$id": "http://localhost:1234/bar#foo",
- "type": "integer"
- }
- }
- },
- "tests": [
- {
- "data": 1,
- "description": "match",
- "valid": true
- },
- {
- "data": "a",
- "description": "mismatch",
- "valid": false
- }
- ]
- },
- {
"description": "Location-independent identifier with base URI change in subschema",
"schema": {
"$id": "http://localhost:1234/root",
@@ -494,5 +468,109 @@
"valid": true
}
]
+ },
+ {
+ "description": "refs with relative uris and defs",
+ "schema": {
+ "$id": "http://example.com/schema-relative-uri-defs1.json",
+ "properties": {
+ "foo": {
+ "$id": "schema-relative-uri-defs2.json",
+ "definitions": {
+ "inner": {
+ "properties": {
+ "bar": { "type": "string" }
+ }
+ }
+ },
+ "allOf": [ { "$ref": "#/definitions/inner" } ]
+ }
+ },
+ "allOf": [ { "$ref": "schema-relative-uri-defs2.json" } ]
+ },
+ "tests": [
+ {
+ "description": "invalid on inner field",
+ "data": {
+ "foo": {
+ "bar": 1
+ },
+ "bar": "a"
+ },
+ "valid": false
+ },
+ {
+ "description": "invalid on outer field",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid on both fields",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "relative refs with absolute uris and defs",
+ "schema": {
+ "$id": "http://example.com/schema-refs-absolute-uris-defs1.json",
+ "properties": {
+ "foo": {
+ "$id": "http://example.com/schema-refs-absolute-uris-defs2.json",
+ "definitions": {
+ "inner": {
+ "properties": {
+ "bar": { "type": "string" }
+ }
+ }
+ },
+ "allOf": [ { "$ref": "#/definitions/inner" } ]
+ }
+ },
+ "allOf": [ { "$ref": "schema-refs-absolute-uris-defs2.json" } ]
+ },
+ "tests": [
+ {
+ "description": "invalid on inner field",
+ "data": {
+ "foo": {
+ "bar": 1
+ },
+ "bar": "a"
+ },
+ "valid": false
+ },
+ {
+ "description": "invalid on outer field",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid on both fields",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
}
]
diff --git a/tests/draft7/refRemote.json b/tests/draft7/refRemote.json
index 74a7862..9d8057b 100644
--- a/tests/draft7/refRemote.json
+++ b/tests/draft7/refRemote.json
@@ -167,5 +167,28 @@
"valid": false
}
]
+ },
+ {
+ "description": "remote ref with ref to definitions",
+ "schema": {
+ "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json",
+ "$ref": "ref-and-definitions.json"
+ },
+ "tests": [
+ {
+ "description": "invalid",
+ "data": {
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid",
+ "data": {
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
}
]
diff --git a/tests/draft7/unknownKeyword.json b/tests/draft7/unknownKeyword.json
new file mode 100644
index 0000000..1f58d97
--- /dev/null
+++ b/tests/draft7/unknownKeyword.json
@@ -0,0 +1,56 @@
+[
+ {
+ "description": "$id inside an unknown keyword is not a real identifier",
+ "comment": "the implementation must not be confused by an $id in locations we do not know how to parse",
+ "schema": {
+ "definitions": {
+ "id_in_unknown0": {
+ "not": {
+ "array_of_schemas": [
+ {
+ "$id": "https://localhost:1234/unknownKeyword/my_identifier.json",
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "real_id_in_schema": {
+ "$id": "https://localhost:1234/unknownKeyword/my_identifier.json",
+ "type": "string"
+ },
+ "id_in_unknown1": {
+ "not": {
+ "object_of_schemas": {
+ "foo": {
+ "$id": "https://localhost:1234/unknownKeyword/my_identifier.json",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "anyOf": [
+ { "$ref": "#/definitions/id_in_unknown0" },
+ { "$ref": "#/definitions/id_in_unknown1" },
+ { "$ref": "https://localhost:1234/unknownKeyword/my_identifier.json" }
+ ]
+ },
+ "tests": [
+ {
+ "description": "type matches second anyOf, which has a real schema in it",
+ "data": "a string",
+ "valid": true
+ },
+ {
+ "description": "type matches non-schema in first anyOf",
+ "data": null,
+ "valid": false
+ },
+ {
+ "description": "type matches non-schema in third anyOf",
+ "data": 1,
+ "valid": false
+ }
+ ]
+ }
+]