Skip to content

Commit f5f839a

Browse files
committed
Squashed 'json/' changes from 6eaf7dff4..ed0b855e7
ed0b855e7 Merge pull request #594 from json-schema-org/differing-uris ae0651398 Merge pull request #593 from json-schema-org/gregsdennis-propertyDependencies-tests 0ba0976d8 more varied test cases b78035ee5 Merge branch 'gregsdennis-propertyDependencies-tests' of github.com:json-schema-org/JSON-Schema-Test-Suite into gregsdennis-propertyDependencies-tests 8c2b46f7a rework functional tests to better illustrate purpose of keyword 33d9c6486 Update tests/draft-next/propertyDependencies.json de3f7691f Add tests for some more differing URI scenarios. e59510507 additional 'ignore' tests with nested matches fc6cee5ab propertyDependencies non-string property value tests 99f3b60c1 add basic propertyDependencies tests git-subtree-dir: json git-subtree-split: ed0b855e7ea80c37d9295002fe436c01d9c65230
1 parent 65802a7 commit f5f839a

File tree

10 files changed

+399
-0
lines changed

10 files changed

+399
-0
lines changed

remotes/different-id-ref-string.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$id": "http://localhost:1234/real-id-ref-string.json",
3+
"$defs": {"bar": {"type": "string"}},
4+
"$ref": "#/$defs/bar"
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$defs": {
3+
"bar": {
4+
"$id": "http://localhost:1234/the-nested-id.json",
5+
"type": "string"
6+
}
7+
},
8+
"$ref": "http://localhost:1234/the-nested-id.json"
9+
}

remotes/urn-ref-string.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef",
3+
"$defs": {"bar": {"type": "string"}},
4+
"$ref": "#/$defs/bar"
5+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
[
2+
{
3+
"description": "propertyDependencies doesn't act on non-objects",
4+
"schema": {
5+
"propertyDependencies": {
6+
"foo": {"bar": false}
7+
}
8+
},
9+
"tests": [
10+
{
11+
"description": "ignores booleans",
12+
"data": true,
13+
"valid": true
14+
},
15+
{
16+
"description": "ignores integers",
17+
"data": 123,
18+
"valid": true
19+
},
20+
{
21+
"description": "ignores floats",
22+
"data": 1.0,
23+
"valid": true
24+
},
25+
{
26+
"description": "ignores strings",
27+
"data": "abc",
28+
"valid": true
29+
},
30+
{
31+
"description": "ignores arrays",
32+
"data": [],
33+
"valid": true
34+
},
35+
{
36+
"description": "ignores null",
37+
"data": null,
38+
"valid": true
39+
}
40+
]
41+
},
42+
{
43+
"description": "propertyDependencies doesn't act on non-string property values",
44+
"schema": {
45+
"propertyDependencies": {
46+
"foo": {"bar": false}
47+
}
48+
},
49+
"tests": [
50+
{
51+
"description": "ignores booleans",
52+
"data": {"foo": false},
53+
"valid": true
54+
},
55+
{
56+
"description": "ignores integers",
57+
"data": {"foo": 2},
58+
"valid": true
59+
},
60+
{
61+
"description": "ignores floats",
62+
"data": {"foo": 1.1},
63+
"valid": true
64+
},
65+
{
66+
"description": "ignores objects",
67+
"data": {"foo": {}},
68+
"valid": true
69+
},
70+
{
71+
"description": "ignores objects wth a key of the expected value",
72+
"data": {"foo": {"bar": "baz"}},
73+
"valid": true
74+
},
75+
{
76+
"description": "ignores objects with the expected value nested in structure",
77+
"data": {"foo": {"baz": "bar"}},
78+
"valid": true
79+
},
80+
{
81+
"description": "ignores arrays",
82+
"data": {"foo": []},
83+
"valid": true
84+
},
85+
{
86+
"description": "ignores null",
87+
"data": {"foo": null},
88+
"valid": true
89+
}
90+
]
91+
},
92+
{
93+
"description": "multiple options selects the right one",
94+
"schema": {
95+
"propertyDependencies": {
96+
"foo": {
97+
"bar": {
98+
"minProperties": 2,
99+
"maxProperties": 2
100+
},
101+
"baz": {"maxProperties": 1},
102+
"qux": true,
103+
"quux": false
104+
}
105+
}
106+
},
107+
"tests": [
108+
{
109+
"description": "bar with exactly 2 properties is valid",
110+
"data": {
111+
"foo": "bar",
112+
"other-foo": "other-bar"
113+
},
114+
"valid": true
115+
},
116+
{
117+
"description": "bar with more than 2 properties is invalid",
118+
"data": {
119+
"foo": "bar",
120+
"other-foo": "other-bar",
121+
"too": "many"
122+
},
123+
"valid": false
124+
},
125+
{
126+
"description": "bar with fewer than 2 properties is invalid",
127+
"data": {"foo": "bar"},
128+
"valid": false
129+
},
130+
{
131+
"description": "baz alone is valid",
132+
"data": {"foo": "baz"},
133+
"valid": true
134+
},
135+
{
136+
"description": "baz with other properties is invalid",
137+
"data": {
138+
"foo": "baz",
139+
"other-foo": "other-bar"
140+
},
141+
"valid": false
142+
},
143+
{
144+
"description": "anything allowed with qux",
145+
"data": {
146+
"foo": "qux",
147+
"blah": ["some other property"],
148+
"more": "properties"
149+
},
150+
"valid": true
151+
},
152+
{
153+
"description": "quux is disallowed",
154+
"data": {
155+
"foo": "quux"
156+
},
157+
"valid": false
158+
}
159+
]
160+
}
161+
]

tests/draft-next/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

tests/draft-next/refRemote.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,53 @@
243243
"valid": true
244244
}
245245
]
246+
},
247+
{
248+
"description": "remote HTTP ref with different $id",
249+
"schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
250+
"tests": [
251+
{
252+
"description": "number is invalid",
253+
"data": 1,
254+
"valid": false
255+
},
256+
{
257+
"description": "string is valid",
258+
"data": "foo",
259+
"valid": true
260+
}
261+
]
262+
},
263+
{
264+
"description": "remote HTTP ref with different URN $id",
265+
"schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
266+
"tests": [
267+
{
268+
"description": "number is invalid",
269+
"data": 1,
270+
"valid": false
271+
},
272+
{
273+
"description": "string is valid",
274+
"data": "foo",
275+
"valid": true
276+
}
277+
]
278+
},
279+
{
280+
"description": "remote HTTP ref with nested absolute ref",
281+
"schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
282+
"tests": [
283+
{
284+
"description": "number is invalid",
285+
"data": 1,
286+
"valid": false
287+
},
288+
{
289+
"description": "string is valid",
290+
"data": "foo",
291+
"valid": true
292+
}
293+
]
246294
}
247295
]

tests/draft2019-09/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

tests/draft2019-09/refRemote.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,53 @@
243243
"valid": true
244244
}
245245
]
246+
},
247+
{
248+
"description": "remote HTTP ref with different $id",
249+
"schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
250+
"tests": [
251+
{
252+
"description": "number is invalid",
253+
"data": 1,
254+
"valid": false
255+
},
256+
{
257+
"description": "string is valid",
258+
"data": "foo",
259+
"valid": true
260+
}
261+
]
262+
},
263+
{
264+
"description": "remote HTTP ref with different URN $id",
265+
"schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
266+
"tests": [
267+
{
268+
"description": "number is invalid",
269+
"data": 1,
270+
"valid": false
271+
},
272+
{
273+
"description": "string is valid",
274+
"data": "foo",
275+
"valid": true
276+
}
277+
]
278+
},
279+
{
280+
"description": "remote HTTP ref with nested absolute ref",
281+
"schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
282+
"tests": [
283+
{
284+
"description": "number is invalid",
285+
"data": 1,
286+
"valid": false
287+
},
288+
{
289+
"description": "string is valid",
290+
"data": "foo",
291+
"valid": true
292+
}
293+
]
246294
}
247295
]

tests/draft2020-12/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

0 commit comments

Comments
 (0)