summaryrefslogtreecommitdiff
path: root/json/tests/draft2020-12
diff options
context:
space:
mode:
Diffstat (limited to 'json/tests/draft2020-12')
-rw-r--r--json/tests/draft2020-12/dependentSchemas.json38
-rw-r--r--json/tests/draft2020-12/format.json95
-rw-r--r--json/tests/draft2020-12/ref.json89
-rw-r--r--json/tests/draft2020-12/unevaluatedItems.json23
-rw-r--r--json/tests/draft2020-12/unevaluatedProperties.json30
-rw-r--r--json/tests/draft2020-12/uniqueItems.json5
6 files changed, 274 insertions, 6 deletions
diff --git a/json/tests/draft2020-12/dependentSchemas.json b/json/tests/draft2020-12/dependentSchemas.json
index bf7aa53..66ac0eb 100644
--- a/json/tests/draft2020-12/dependentSchemas.json
+++ b/json/tests/draft2020-12/dependentSchemas.json
@@ -128,5 +128,43 @@
"valid": false
}
]
+ },
+ {
+ "description": "dependent subschema incompatible with root",
+ "schema": {
+ "properties": {
+ "foo": {}
+ },
+ "dependentSchemas": {
+ "foo": {
+ "properties": {
+ "bar": {}
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "matches root",
+ "data": {"foo": 1},
+ "valid": false
+ },
+ {
+ "description": "matches dependency",
+ "data": {"bar": 1},
+ "valid": true
+ },
+ {
+ "description": "matches both",
+ "data": {"foo": 1, "bar": 2},
+ "valid": false
+ },
+ {
+ "description": "no dependency",
+ "data": {"baz": 1},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/format.json b/json/tests/draft2020-12/format.json
index 6b7904e..01adcbd 100644
--- a/json/tests/draft2020-12/format.json
+++ b/json/tests/draft2020-12/format.json
@@ -35,6 +35,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid email string is only an annotation by default",
+ "data": "2962",
+ "valid": true
}
]
},
@@ -74,6 +79,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid idn-email string is only an annotation by default",
+ "data": "2962",
+ "valid": true
}
]
},
@@ -113,6 +123,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid regex string is only an annotation by default",
+ "data": "^(abc]",
+ "valid": true
}
]
},
@@ -152,6 +167,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid ipv4 string is only an annotation by default",
+ "data": "127.0.0.0.1",
+ "valid": true
}
]
},
@@ -191,6 +211,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid ipv6 string is only an annotation by default",
+ "data": "12345::",
+ "valid": true
}
]
},
@@ -230,6 +255,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid idn-hostname string is only an annotation by default",
+ "data": "〮실례.테스트",
+ "valid": true
}
]
},
@@ -269,6 +299,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid hostname string is only an annotation by default",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": true
}
]
},
@@ -308,6 +343,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid date string is only an annotation by default",
+ "data": "06/19/1963",
+ "valid": true
}
]
},
@@ -347,6 +387,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid date-time string is only an annotation by default",
+ "data": "1990-02-31T15:59:60.123-08:00",
+ "valid": true
}
]
},
@@ -386,6 +431,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid time string is only an annotation by default",
+ "data": "08:30:06 PST",
+ "valid": true
}
]
},
@@ -425,6 +475,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid json-pointer string is only an annotation by default",
+ "data": "/foo/bar~",
+ "valid": true
}
]
},
@@ -464,6 +519,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid relative-json-pointer string is only an annotation by default",
+ "data": "/foo/bar",
+ "valid": true
}
]
},
@@ -503,6 +563,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid iri string is only an annotation by default",
+ "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ "valid": true
}
]
},
@@ -542,6 +607,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid iri-reference string is only an annotation by default",
+ "data": "\\\\WINDOWS\\filëßåré",
+ "valid": true
}
]
},
@@ -581,6 +651,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid uri string is only an annotation by default",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": true
}
]
},
@@ -620,6 +695,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid uri-reference string is only an annotation by default",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": true
}
]
},
@@ -659,6 +739,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid uri-template string is only an annotation by default",
+ "data": "http://example.com/dictionary/{term:1}/{term",
+ "valid": true
}
]
},
@@ -698,6 +783,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid uuid string is only an annotation by default",
+ "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638",
+ "valid": true
}
]
},
@@ -737,6 +827,11 @@
"description": "all string formats ignore nulls",
"data": null,
"valid": true
+ },
+ {
+ "description": "invalid duration string is only an annotation by default",
+ "data": "PT1D",
+ "valid": true
}
]
}
diff --git a/json/tests/draft2020-12/ref.json b/json/tests/draft2020-12/ref.json
index 72c593a..5f6be8c 100644
--- a/json/tests/draft2020-12/ref.json
+++ b/json/tests/draft2020-12/ref.json
@@ -601,16 +601,16 @@
"schema": {
"$comment": "$id must be evaluated before $ref to get the proper $ref destination",
"$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "/draft2020-12/ref-and-id1/base.json",
+ "$id": "https://example.com/draft2020-12/ref-and-id1/base.json",
"$ref": "int.json",
"$defs": {
"bigint": {
- "$comment": "canonical uri: /ref-and-id1/int.json",
+ "$comment": "canonical uri: https://example.com/ref-and-id1/int.json",
"$id": "int.json",
"maximum": 10
},
"smallint": {
- "$comment": "canonical uri: /ref-and-id1-int.json",
+ "$comment": "canonical uri: https://example.com/ref-and-id1-int.json",
"$id": "/draft2020-12/ref-and-id1-int.json",
"maximum": 2
}
@@ -634,7 +634,7 @@
"schema": {
"$comment": "$id must be evaluated before $ref to get the proper $ref destination",
"$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "/draft2020-12/ref-and-id2/base.json",
+ "$id": "https://example.com/draft2020-12/ref-and-id2/base.json",
"$ref": "#bigint",
"$defs": {
"bigint": {
@@ -643,8 +643,8 @@
"maximum": 10
},
"smallint": {
- "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint",
- "$id": "/draft2020-12/ref-and-id2/",
+ "$comment": "canonical uri: https://example.com/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint",
+ "$id": "https://example.com/draft2020-12/ref-and-id2/",
"$anchor": "bigint",
"maximum": 2
}
@@ -978,5 +978,82 @@
"valid": false
}
]
+ },
+ {
+ "description": "$id with file URI still resolves pointers - *nix",
+ "schema": {
+ "$id": "file:///folder/file.json",
+ "$defs": {
+ "foo": {
+ "type": "number"
+ }
+ },
+ "$ref": "#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "$id with file URI still resolves pointers - windows",
+ "schema": {
+ "$id": "file:///c:/folder/file.json",
+ "$defs": {
+ "foo": {
+ "type": "number"
+ }
+ },
+ "$ref": "#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "empty tokens in $ref json-pointer",
+ "schema": {
+ "$defs": {
+ "": {
+ "$defs": {
+ "": { "type": "number" }
+ }
+ }
+ },
+ "allOf": [
+ {
+ "$ref": "#/$defs//$defs/"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/unevaluatedItems.json b/json/tests/draft2020-12/unevaluatedItems.json
index 2b816af..2615c4c 100644
--- a/json/tests/draft2020-12/unevaluatedItems.json
+++ b/json/tests/draft2020-12/unevaluatedItems.json
@@ -692,5 +692,28 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedItems can see annotations from if without then and else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "if": {
+ "prefixItems": [{"const": "a"}]
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "valid in case if is evaluated",
+ "data": [ "a" ],
+ "valid": true
+ },
+ {
+ "description": "invalid in case if is evaluated",
+ "data": [ "b" ],
+ "valid": false
+ }
+
+ ]
}
]
diff --git a/json/tests/draft2020-12/unevaluatedProperties.json b/json/tests/draft2020-12/unevaluatedProperties.json
index 00cb36c..f7fb420 100644
--- a/json/tests/draft2020-12/unevaluatedProperties.json
+++ b/json/tests/draft2020-12/unevaluatedProperties.json
@@ -1441,5 +1441,35 @@
"valid": false
}
]
+ },
+ {
+ "description": "unevaluatedProperties can see annotations from if without then and else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "if": {
+ "patternProperties": {
+ "foo": {
+ "type": "string"
+ }
+ }
+ },
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "valid in case if is evaluated",
+ "data": {
+ "foo": "a"
+ },
+ "valid": true
+ },
+ {
+ "description": "invalid in case if is evaluated",
+ "data": {
+ "bar": "a"
+ },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/uniqueItems.json b/json/tests/draft2020-12/uniqueItems.json
index 707235c..4ea3bf9 100644
--- a/json/tests/draft2020-12/uniqueItems.json
+++ b/json/tests/draft2020-12/uniqueItems.json
@@ -57,6 +57,11 @@
"valid": false
},
{
+ "description": "property order of array of objects is ignored",
+ "data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
+ "valid": false
+ },
+ {
"description": "unique array of nested objects is valid",
"data": [
{"foo": {"bar" : {"baz" : true}}},