Skip to content

Commit b70c562

Browse files
committed
Merge remote-tracking branch 'origin/pr/323'
* origin/pr/323: back out subSchemas.json changes, and instead add subSchemas-defs.json back out ref.json whitespace change and missing referant test update subSchemas.json fixture in bin/jsonschema_suite In draft2019-09, you cannot reference arbitrary locations. Tests for unevaluatedItems. More unevaluatedProperties tests.
2 parents 960f519 + 882688c commit b70c562

File tree

6 files changed

+184
-21
lines changed

6 files changed

+184
-21
lines changed

bin/jsonschema_suite

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ REMOTES = {
4545
u"integer": {u"type": u"integer"},
4646
u"refToInteger": {u"$ref": u"#/integer"},
4747
},
48+
"subSchemas-defs.json": {
49+
u"$defs": {
50+
u"integer": {u"type": u"integer"},
51+
u"refToInteger": {u"$ref": u"#/$defs/integer"},
52+
}
53+
},
4854
"folder/folderInteger.json": {u"type": u"integer"}
4955
}
5056
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")

remotes/subSchemas-defs.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$defs": {
3+
"integer": {
4+
"type": "integer"
5+
},
6+
"refToInteger": {
7+
"$ref": "#/$defs/integer"
8+
}
9+
}
10+
}

tests/draft2019-09/ref.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@
7575
{
7676
"description": "escaped pointer ref",
7777
"schema": {
78-
"tilda~field": {"type": "integer"},
79-
"slash/field": {"type": "integer"},
80-
"percent%field": {"type": "integer"},
78+
"$defs": {
79+
"tilda~field": {"type": "integer"},
80+
"slash/field": {"type": "integer"},
81+
"percent%field": {"type": "integer"}
82+
},
8183
"properties": {
82-
"tilda": {"$ref": "#/tilda~0field"},
83-
"slash": {"$ref": "#/slash~1field"},
84-
"percent": {"$ref": "#/percent%25field"}
84+
"tilda": {"$ref": "#/$defs/tilda~0field"},
85+
"slash": {"$ref": "#/$defs/slash~1field"},
86+
"percent": {"$ref": "#/$defs/percent%25field"}
8587
}
8688
},
8789
"tests": [

tests/draft2019-09/refRemote.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"description": "fragment within remote ref",
20-
"schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
20+
"schema": {"$ref": "http://localhost:1234/subSchemas-defs.json#/$defs/integer"},
2121
"tests": [
2222
{
2323
"description": "remote fragment valid",
@@ -34,7 +34,7 @@
3434
{
3535
"description": "ref within remote ref",
3636
"schema": {
37-
"$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
37+
"$ref": "http://localhost:1234/subSchemas-defs.json#/$defs/refToInteger"
3838
},
3939
"tests": [
4040
{
@@ -76,7 +76,7 @@
7676
"schema": {
7777
"$id": "http://localhost:1234/scope_change_defs1.json",
7878
"type" : "object",
79-
"properties": {"list": {"$ref": "#/$defs/baz"}},
79+
"properties": {"list": {"$ref": "folder/"}},
8080
"$defs": {
8181
"baz": {
8282
"$id": "folder/",
@@ -103,7 +103,7 @@
103103
"schema": {
104104
"$id": "http://localhost:1234/scope_change_defs2.json",
105105
"type" : "object",
106-
"properties": {"list": {"$ref": "#/$defs/baz/$defs/bar"}},
106+
"properties": {"list": {"$ref": "folder/#/$defs/bar"}},
107107
"$defs": {
108108
"baz": {
109109
"$id": "folder/",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[
2+
{
3+
"description": "anyOf with false unevaluatedItems",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2019-09/schema",
6+
"unevaluatedItems": false,
7+
"anyOf": [
8+
{"items": {"type": "string"}},
9+
{"items": [true, true]}
10+
]
11+
},
12+
"tests": [
13+
{
14+
"description": "all strings is valid",
15+
"data": ["foo", "bar", "baz"],
16+
"valid": true
17+
},
18+
{
19+
"description": "one item is valid",
20+
"data": [1],
21+
"valid": true
22+
},
23+
{
24+
"description": "two items are valid",
25+
"data": [1, "two"],
26+
"valid": true
27+
},
28+
{
29+
"description": "three items are invalid",
30+
"data": [1, "two", "three"],
31+
"valid": false
32+
},
33+
{
34+
"description": "four strings are valid",
35+
"data": ["one", "two", "three", "four"],
36+
"valid": true
37+
}
38+
]
39+
},
40+
{
41+
"description": "complex unevaluated schema",
42+
"schema": {
43+
"$schema": "https://json-schema.org/draft/2019-09/schema",
44+
"unevaluatedItems": {
45+
"allOf": [{"minLength": 3}, {"type": "string"}]
46+
},
47+
"if": {"items": [{"type": "integer"}, {"type": "array"}]}
48+
},
49+
"tests": [
50+
{
51+
"description": "empty array",
52+
"data": [],
53+
"valid": true
54+
},
55+
{
56+
"description": "if passes with one item",
57+
"data": [1],
58+
"valid": true
59+
},
60+
{
61+
"description": "if passes with two items",
62+
"data": [1, [2, 3]],
63+
"valid": true
64+
},
65+
{
66+
"description": "if passes with third valid unevaluated item",
67+
"data": [1, [2, 3], "long-string"],
68+
"valid": true
69+
},
70+
{
71+
"description": "if passes with third invalid unevaluated item",
72+
"data": [1, [2, 3], "zz"],
73+
"valid": false
74+
},
75+
{
76+
"description": "if fails with all valid unevaluated items",
77+
"data": ["all", "long", "strings"],
78+
"valid": true
79+
},
80+
{
81+
"description": "if and unevaluated items fail",
82+
"data": ["a", "b", "c"],
83+
"valid": false
84+
}
85+
]
86+
}
87+
]

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[
22
{
3-
"description": "can peer inside allOf, results in no-op",
3+
"description": "allOf with false unevaluatedProperties",
44
"schema": {
55
"$schema": "https://json-schema.org/draft/2019-09/schema",
66
"unevaluatedProperties": false,
77
"allOf": [
8-
{
9-
"properties": {
10-
"foo": { "type": ["string", "null"] },
11-
"bar": { "type": ["string", "null"] }
8+
{
9+
"properties": {
10+
"foo": { "type": ["string", "null"] },
11+
"bar": { "type": ["string", "null"] }
12+
}
13+
},
14+
{
15+
"additionalProperties": {
16+
"not": { "enum": [ null ] }
17+
}
1218
}
13-
},
14-
{
15-
"additionalProperties": {
16-
"not": { "enum": [ null ] }
17-
}
18-
}
1919
]
2020
},
2121
"tests": [
@@ -28,6 +28,64 @@
2828
"description": "null prop is invalid",
2929
"data": { "bar": "foo", "bob": null },
3030
"valid": false
31+
},
32+
{
33+
"description": "named property with wrong type is invalid",
34+
"data": { "bar": "foo", "bob": "who?" },
35+
"valid": true
36+
}
37+
]
38+
},
39+
{
40+
"description": "complex unevaluated schema",
41+
"schema": {
42+
"$schema": "https://json-schema.org/draft/2019-09/schema",
43+
"unevaluatedProperties": {
44+
"allOf": [{"minLength": 3}, {"type": "string"}]
45+
},
46+
"if": {
47+
"properties": {
48+
"foo": {"type": "integer"},
49+
"arr": {"type": "array"}
50+
},
51+
"required": ["foo"]
52+
}
53+
},
54+
"tests": [
55+
{
56+
"description": "empty object",
57+
"data": {},
58+
"valid": true
59+
},
60+
{
61+
"description": "if passes",
62+
"data": {"foo": 3, "arr": [1,2]},
63+
"valid": true
64+
},
65+
{
66+
"description": "if passes with valid uneval",
67+
"data": {"foo": 3, "arr": [1,2], "uneval": "long-string"},
68+
"valid": true
69+
},
70+
{
71+
"description": "if passes with invalid short uneval",
72+
"data": {"foo": 3, "arr": [1,2], "uneval": "zz"},
73+
"valid": false
74+
},
75+
{
76+
"description": "if fails, and uneval fails because of array",
77+
"data": {"foo": "not-an-int", "arr": [1,2], "uneval": "long-string"},
78+
"valid": false
79+
},
80+
{
81+
"description": "if fails with valid uneval",
82+
"data": {"foo": "not-an-int", "uneval": "long-string"},
83+
"valid": true
84+
},
85+
{
86+
"description": "if fails with invalid uneval",
87+
"data": {"foo": "zz", "uneval": "long-string"},
88+
"valid": false
3189
}
3290
]
3391
}

0 commit comments

Comments
 (0)