Skip to content

Commit b695cd7

Browse files
committed
Squashed 'json/' changes from 0788c226a..6afa9b38d
6afa9b38d Merge pull request #664 from santhosh-tekuri/empty-tokens e4bceb1ad Bump the python-jsonschema version used for the sanity check. 8025fc0d5 Merge pull request #128 from iainbeeston/foundations-of-json-schema-paper cf7677078 Make all root $ids absolute URIs 07fd389a3 Added test cases from Foundations of JSON Schema research paper 1008edcee ref: test empty tokens in json-pointer 9beb3cfba Merge pull request #627 from json-schema-org/ether/output-readme-fixes f2b0490ba minor edit to trigger gh action c305ce54f Merge pull request #669 from hauner/typo 5e2845c1e Merge pull request #668 from hauner/if-without-then-else-creates-annotations 2f1df2293 typo c1fae0022 test unevaluated* can see annotations from if without then/else 987a4c8fc Merge pull request #666 from json-schema-org/gregsdennis/file-refs 90b2a58ce fix *nix uris 68d18c6ac rename tests to fix sanity check e9166bcbe fix indentation 1d1ec749a add file-id ref tests fb60ed17c Merge pull request #663 from json-schema-org/ether/restore-format-tests f32cd8b80 Revert "Revert "by default, "format" only annotates, not validates"" 47958f82d Merge pull request #654 from santhosh-tekuri/output-escape 5262997e1 Merge pull request #661 from santhosh-tekuri/2019-output ce2c16573 output-tests: correct 2019 output-schema.json c9d943856 output: ensure ~ and / are escaped in json-pointer f6b2324bf minor spelling and markdown formatting fixes; `valid` has also been removed from the tests git-subtree-dir: json git-subtree-split: 6afa9b38d84d45550ec703123eb4e8ec67a8ae75
1 parent c8c0bdd commit b695cd7

33 files changed

+1239
-56
lines changed

bin/jsonschema_suite

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ class SanityTests(unittest.TestCase):
498498
"title",
499499
"type",
500500
"uniqueItems",
501+
502+
# Technically this is wrong, $comment doesn't exist in this
503+
# draft, but the point of this test is to detect mistakes by,
504+
# test authors, whereas the point of the $comment keyword is
505+
# to just standardize a place for a comment, so it's not a
506+
# mistake to use it in earlier drafts in tests per se.
507+
"$comment",
501508
},
502509
"draft3": {
503510
"$ref",
@@ -528,6 +535,13 @@ class SanityTests(unittest.TestCase):
528535
"title",
529536
"type",
530537
"uniqueItems",
538+
539+
# Technically this is wrong, $comment doesn't exist in this
540+
# draft, but the point of this test is to detect mistakes by,
541+
# test authors, whereas the point of the $comment keyword is
542+
# to just standardize a place for a comment, so it's not a
543+
# mistake to use it in earlier drafts in tests per se.
544+
"$comment",
531545
},
532546
}
533547

output-tests/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ These tests are intended to validate that implementations are correctly generati
22

33
Output was initially specified with draft 2019-09. It remained largely unchanged for draft 2020-12, but will receive an update with the next release.
44

5-
***NOTE** Although the formats didn't change between 2019-09 and 2020-12, the tests are replicated for 2020-12 because the `$schema` is different and implementations may (but shouldn't) produce different output.*
5+
_**NOTE** Although the formats didn't change much between 2019-09 and 2020-12, the tests are copied for 2020-12 because the `$schema` is different and implementations may (but shouldn't) produce different output._
66

77
## Organization
88

99
The tests are organized by specification release and then into two categories: content and structure.
1010

11-
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when a error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic` for 2019-09/2020/12 and `list` for later versions.
11+
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when a error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic` for 2019-09/2020-12 and `list` for later versions.
1212

13-
Structure tests verify that the structures of the various formats (i.e. `flag`, `basic`, `detailed`, `verbose` for 2019/2020 and `flag`, `list`, `hierarchical` for later versions) are correct. These tests don't need to cover each keyword; rather they need to sufficiently cover the various aspects of building the output structures by using whatever keywords are necessary to do so.
13+
Structure tests verify that the structures of the various formats (i.e. `flag`, `basic`, `detailed`, `verbose` for 2019-09/2020-12 and `flag`, `list`, `hierarchical` for later versions) are correct. These tests don't need to cover each keyword; rather they need to sufficiently cover the various aspects of building the output structures by using whatever keywords are necessary to do so.
1414

1515
In each release folder, you'll also find an _output-schema.json_ file that contains the schema from the specification repo that describes output for that release. This schema will need to be loaded as the tests reference it.
1616

1717
## Test Files
1818

19-
The content of a test file is the same as the validation tests in `tests/`, however an `output` property has been added to each test case.
19+
The content of a test file is similar to the validation tests in `tests/`: for each test case, the `valid` property has been removed, and an `output` property has been added.
2020

2121
The `output` property itself has a property for each of the output formats where the value is a schema that will successfully validate for compliant output. For the content tests, only `basic`/`list` needs to be present.
2222

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"description": "tilde and forward slash in json-pointer",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2019-09/schema",
6+
"$id": "https://json-schema.org/tests/content/draft2019-09/escape/0",
7+
"properties": {
8+
"~a/b": {"type": "number"}
9+
}
10+
},
11+
"tests": [
12+
{
13+
"description": "incorrect type must be reported, but a message is not required",
14+
"data": {"~a/b": "foobar"},
15+
"output": {
16+
"basic": {
17+
"$id": "https://json-schema.org/tests/content/draft2019-09/escape/0/tests/0/basic",
18+
"$ref": "/draft/2019-09/output/schema",
19+
"properties": {
20+
"errors": {
21+
"contains": {
22+
"properties": {
23+
"keywordLocation": {"const": "/properties/~0a~1b/type"},
24+
"absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/escape/0#/properties/~0a~1b/type"},
25+
"instanceLocation": {"const": "/~0a~1b"},
26+
"annotation": false
27+
},
28+
"required": ["keywordLocation", "instanceLocation"]
29+
}
30+
}
31+
},
32+
"required": ["errors"]
33+
}
34+
}
35+
}
36+
]
37+
}
38+
]

output-tests/draft2019-09/output-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
{
6868
"properties": {
6969
"keywordLocation": {
70-
"pattern": "/\\$dynamicRef/"
70+
"pattern": "/\\$recursiveRef/"
7171
}
7272
}
7373
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"description": "tilde and forward slash in json-pointer",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2020-12/schema",
6+
"$id": "https://json-schema.org/tests/content/draft2020-12/escape/0",
7+
"properties": {
8+
"~a/b": {"type": "number"}
9+
}
10+
},
11+
"tests": [
12+
{
13+
"description": "incorrect type must be reported, but a message is not required",
14+
"data": {"~a/b": "foobar"},
15+
"output": {
16+
"basic": {
17+
"$id": "https://json-schema.org/tests/content/draft2020-12/escape/0/tests/0/basic",
18+
"$ref": "/draft/2020-12/output/schema",
19+
"properties": {
20+
"errors": {
21+
"contains": {
22+
"properties": {
23+
"keywordLocation": {"const": "/properties/~0a~1b/type"},
24+
"absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/escape/0#/properties/~0a~1b/type"},
25+
"instanceLocation": {"const": "/~0a~1b"},
26+
"annotation": false
27+
},
28+
"required": ["keywordLocation", "instanceLocation"]
29+
}
30+
}
31+
},
32+
"required": ["errors"]
33+
}
34+
}
35+
}
36+
]
37+
}
38+
]

tests/draft-next/dependentSchemas.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,43 @@
128128
"valid": false
129129
}
130130
]
131+
},
132+
{
133+
"description": "dependent subschema incompatible with root",
134+
"schema": {
135+
"properties": {
136+
"foo": {}
137+
},
138+
"dependentSchemas": {
139+
"foo": {
140+
"properties": {
141+
"bar": {}
142+
},
143+
"additionalProperties": false
144+
}
145+
}
146+
},
147+
"tests": [
148+
{
149+
"description": "matches root",
150+
"data": {"foo": 1},
151+
"valid": false
152+
},
153+
{
154+
"description": "matches dependency",
155+
"data": {"bar": 1},
156+
"valid": true
157+
},
158+
{
159+
"description": "matches both",
160+
"data": {"foo": 1, "bar": 2},
161+
"valid": false
162+
},
163+
{
164+
"description": "no dependency",
165+
"data": {"baz": 1},
166+
"valid": true
167+
}
168+
]
131169
}
132170
]

0 commit comments

Comments
 (0)