summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2022-09-08 09:04:19 +0300
committerJulian Berman <Julian@GrayVines.com>2022-09-08 09:04:19 +0300
commit8cec498ad54bbecf38b7eaf304308d500bcda9db (patch)
treebc6a24f1e79724a15afdec2cb18a69cc65774ad6 /json
parent05b18609db84954d7309d69d7628cd882ba90dc3 (diff)
parentf5f839a5995c8005373214271989daae3537d70e (diff)
downloadjsonschema-8cec498ad54bbecf38b7eaf304308d500bcda9db.tar.gz
Merge commit 'f5f839a5995c8005373214271989daae3537d70e'
* commit 'f5f839a5995c8005373214271989daae3537d70e': Squashed 'json/' changes from 6eaf7dff4..ed0b855e7
Diffstat (limited to 'json')
-rw-r--r--json/remotes/different-id-ref-string.json5
-rw-r--r--json/remotes/nested-absolute-ref-to-string.json9
-rw-r--r--json/remotes/urn-ref-string.json5
-rw-r--r--json/tests/draft-next/propertyDependencies.json161
-rw-r--r--json/tests/draft-next/ref.json25
-rw-r--r--json/tests/draft-next/refRemote.json48
-rw-r--r--json/tests/draft2019-09/ref.json25
-rw-r--r--json/tests/draft2019-09/refRemote.json48
-rw-r--r--json/tests/draft2020-12/ref.json25
-rw-r--r--json/tests/draft2020-12/refRemote.json48
10 files changed, 399 insertions, 0 deletions
diff --git a/json/remotes/different-id-ref-string.json b/json/remotes/different-id-ref-string.json
new file mode 100644
index 0000000..7f88860
--- /dev/null
+++ b/json/remotes/different-id-ref-string.json
@@ -0,0 +1,5 @@
+{
+ "$id": "http://localhost:1234/real-id-ref-string.json",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+}
diff --git a/json/remotes/nested-absolute-ref-to-string.json b/json/remotes/nested-absolute-ref-to-string.json
new file mode 100644
index 0000000..f46c761
--- /dev/null
+++ b/json/remotes/nested-absolute-ref-to-string.json
@@ -0,0 +1,9 @@
+{
+ "$defs": {
+ "bar": {
+ "$id": "http://localhost:1234/the-nested-id.json",
+ "type": "string"
+ }
+ },
+ "$ref": "http://localhost:1234/the-nested-id.json"
+}
diff --git a/json/remotes/urn-ref-string.json b/json/remotes/urn-ref-string.json
new file mode 100644
index 0000000..aca2211
--- /dev/null
+++ b/json/remotes/urn-ref-string.json
@@ -0,0 +1,5 @@
+{
+ "$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+}
diff --git a/json/tests/draft-next/propertyDependencies.json b/json/tests/draft-next/propertyDependencies.json
new file mode 100644
index 0000000..9efa2b4
--- /dev/null
+++ b/json/tests/draft-next/propertyDependencies.json
@@ -0,0 +1,161 @@
+[
+ {
+ "description": "propertyDependencies doesn't act on non-objects",
+ "schema": {
+ "propertyDependencies": {
+ "foo": {"bar": false}
+ }
+ },
+ "tests": [
+ {
+ "description": "ignores booleans",
+ "data": true,
+ "valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores strings",
+ "data": "abc",
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "propertyDependencies doesn't act on non-string property values",
+ "schema": {
+ "propertyDependencies": {
+ "foo": {"bar": false}
+ }
+ },
+ "tests": [
+ {
+ "description": "ignores booleans",
+ "data": {"foo": false},
+ "valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": {"foo": 2},
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": {"foo": 1.1},
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {"foo": {}},
+ "valid": true
+ },
+ {
+ "description": "ignores objects wth a key of the expected value",
+ "data": {"foo": {"bar": "baz"}},
+ "valid": true
+ },
+ {
+ "description": "ignores objects with the expected value nested in structure",
+ "data": {"foo": {"baz": "bar"}},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": {"foo": []},
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "multiple options selects the right one",
+ "schema": {
+ "propertyDependencies": {
+ "foo": {
+ "bar": {
+ "minProperties": 2,
+ "maxProperties": 2
+ },
+ "baz": {"maxProperties": 1},
+ "qux": true,
+ "quux": false
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "bar with exactly 2 properties is valid",
+ "data": {
+ "foo": "bar",
+ "other-foo": "other-bar"
+ },
+ "valid": true
+ },
+ {
+ "description": "bar with more than 2 properties is invalid",
+ "data": {
+ "foo": "bar",
+ "other-foo": "other-bar",
+ "too": "many"
+ },
+ "valid": false
+ },
+ {
+ "description": "bar with fewer than 2 properties is invalid",
+ "data": {"foo": "bar"},
+ "valid": false
+ },
+ {
+ "description": "baz alone is valid",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "baz with other properties is invalid",
+ "data": {
+ "foo": "baz",
+ "other-foo": "other-bar"
+ },
+ "valid": false
+ },
+ {
+ "description": "anything allowed with qux",
+ "data": {
+ "foo": "qux",
+ "blah": ["some other property"],
+ "more": "properties"
+ },
+ "valid": true
+ },
+ {
+ "description": "quux is disallowed",
+ "data": {
+ "foo": "quux"
+ },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft-next/ref.json b/json/tests/draft-next/ref.json
index 2a58ef8..8e0fbb6 100644
--- a/json/tests/draft-next/ref.json
+++ b/json/tests/draft-next/ref.json
@@ -858,5 +858,30 @@
"valid": false
}
]
+ },
+ {
+ "description": "URN ref with nested pointer ref",
+ "schema": {
+ "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {
+ "foo": {
+ "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": "bar",
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": 12,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/refRemote.json b/json/tests/draft-next/refRemote.json
index 43070a8..ca5b8c4 100644
--- a/json/tests/draft-next/refRemote.json
+++ b/json/tests/draft-next/refRemote.json
@@ -243,5 +243,53 @@
"valid": true
}
]
+ },
+ {
+ "description": "remote HTTP ref with different $id",
+ "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with different URN $id",
+ "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with nested absolute ref",
+ "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json
index 8501152..3142cd9 100644
--- a/json/tests/draft2019-09/ref.json
+++ b/json/tests/draft2019-09/ref.json
@@ -858,5 +858,30 @@
"valid": false
}
]
+ },
+ {
+ "description": "URN ref with nested pointer ref",
+ "schema": {
+ "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {
+ "foo": {
+ "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": "bar",
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": 12,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/refRemote.json b/json/tests/draft2019-09/refRemote.json
index 944820f..7f45b0b 100644
--- a/json/tests/draft2019-09/refRemote.json
+++ b/json/tests/draft2019-09/refRemote.json
@@ -243,5 +243,53 @@
"valid": true
}
]
+ },
+ {
+ "description": "remote HTTP ref with different $id",
+ "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with different URN $id",
+ "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with nested absolute ref",
+ "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/ref.json b/json/tests/draft2020-12/ref.json
index 232cc7d..2b9c481 100644
--- a/json/tests/draft2020-12/ref.json
+++ b/json/tests/draft2020-12/ref.json
@@ -858,5 +858,30 @@
"valid": false
}
]
+ },
+ {
+ "description": "URN ref with nested pointer ref",
+ "schema": {
+ "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {
+ "foo": {
+ "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": "bar",
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": 12,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/refRemote.json b/json/tests/draft2020-12/refRemote.json
index 433eb1d..d3cc401 100644
--- a/json/tests/draft2020-12/refRemote.json
+++ b/json/tests/draft2020-12/refRemote.json
@@ -243,5 +243,53 @@
"valid": true
}
]
+ },
+ {
+ "description": "remote HTTP ref with different $id",
+ "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with different URN $id",
+ "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with nested absolute ref",
+ "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
}
]