Skip to content

Commit 4a4930a

Browse files
committed
Squashed 'json/' changes from 9d0e0eb..817b724
817b724 add perl implementation and test suite to the user list ca14e01 Merge branch 'pull/382' 3dabf55 move non-format tests out of the format directory, while keeping all ECMA regex tests together 4121aa5 move format tests to their own directory 4bae8aa Add more idn-hostname tests to draft-2019-09 and draft-07 6d91158 [325] Add some more hostname tests e593057 Merge pull request #389 from ssilverman/readme-drafts fb3766d README: Improve issue/PR links 79bef22 README: Update language around drafts ade47e4 README: Add Snow to the list of supporting Java validators fc0c14e README: Update simple JSON example 1167669 README: Update structure, consistency, spacing, and wrapping 9514122 Merge pull request #388 from json-schema-org/ether/maxProperties=0 7646490 test that maxProperties = 0 means the object is empty c3f4319 Merge pull request #384 from ChALkeR/chalker/unique 7766f48 Improve uniqueItems validation 7555d41 Add unnormalized $id tests 11f70eb [300] Add tests for valid use of empty fragments in "$id" b106ff0 [299] Add tests for invalid use of fragments in "$id" 4a74d45 Fix "tilde" spelling 3eca41b Merge pull request #379 from json-schema-org/ether/remove-wrapped-refs d61bae8 remove wrapped refs 536ec07 [359] Add unevaluatedProperties/unevaluatedItems cousin tests ac63eb7 Small README update that introduces the concept of directories 697944e Merge pull request #374 from karenetheridge/ether/allOf-anyOf-oneOf 33f8549 test all the *Of keywords together 44b99ed Merge pull request #373 from karenetheridge/ether/items-and-contains 4a2b52f some tests of items + contains 7f00cc8 add test that was present for other drafts but not 2019-09 a3f9e2e Merge pull request #371 from karenetheridge/ether/if-then-else-boolean aeeaecc some tests with if/then/else and boolean schemas b8a083c Merge pull request #372 from nomnoms12/unique-false-and-zero 85728f1 Add tests for uniqueness [1] and [true] fd01a60 Add tests for uniqueness [1] and [true] 0a8823c Merge pull request #370 from karenetheridge/ether/nul-char fa6f4dd add tests for the NUL character in strings 8bf2f7f Merge pull request #369 from ssilverman/data-desc 2ba7a76 Add data description 4f66078 Merge pull request #367 from karenetheridge/ether/additionalItems 283da7c some more tests for additionalItems 7ba95f3 add tests for keywords maxContains, minContains 2f2e7cf Merge pull request #365 from karenetheridge/ether/move-ecma-regex 8388f27 move ECMA regex tests under format/ git-subtree-dir: json git-subtree-split: 817b724b7a64d7c18a8232aa32b5f1cc1d6dd153
1 parent cc583df commit 4a4930a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2698
-1089
lines changed

README.md

+79-66
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
JSON Schema Test Suite [![Build Status](https://github.com/json-schema-org/JSON-Schema-Test-Suite/workflows/Test%20Suite%20Sanity%20Checking/badge.svg)](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
2-
======
1+
# JSON Schema Test Suite [![Build Status](https://github.com/json-schema-org/JSON-Schema-Test-Suite/workflows/Test%20Suite%20Sanity%20Checking/badge.svg)](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
32

43
This repository contains a set of JSON objects that implementors of JSON Schema
54
validation libraries can use to test their validators.
@@ -9,108 +8,118 @@ It is meant to be language agnostic and should require only a JSON parser.
98
The conversion of the JSON objects into tests within your test framework of
109
choice is still the job of the validator implementor.
1110

12-
Structure of a Test
13-
-------------------
11+
## Structure of a Test
1412

15-
The tests in this suite are contained in the `tests` directory at the
16-
root of this repository.
13+
The tests in this suite are contained in the `tests` directory at the root of
14+
this repository. Inside that directory is a subdirectory for each draft or
15+
version of the specification.
1716

18-
Inside that directory is a subdirectory for each draft or version of the
19-
specification.
17+
Inside each draft directory, there are a number of `.json` files and one or more
18+
special subdirectories. The subdirectories contain `.json` files meant for a
19+
specific testing purpose, and each `.json` file logically groups a set of test
20+
cases together. Often the grouping is by property under test, but not always.
2021

21-
Inside each draft directory, there are a number of `.json` files, which
22-
logically group a set of test cases together. Often the grouping is by
23-
property under test, but not always, especially within optional test
24-
files (discussed below).
22+
The subdirectories are described in the next section.
2523

2624
Inside each `.json` file is a single array containing objects. It's easiest to
2725
illustrate the structure of these with an example:
2826

2927
```json
30-
{
31-
"description": "the description of the test case",
32-
"schema": {"the schema that should" : "be validated against"},
33-
"tests": [
34-
{
35-
"description": "a specific test of a valid instance",
36-
"data": "the instance",
37-
"valid": true
38-
},
39-
{
40-
"description": "another specific test this time, invalid",
41-
"data": 15,
42-
"valid": false
43-
}
44-
]
45-
}
28+
{
29+
"description": "The description of the test case",
30+
"schema": {
31+
"description": "The schema against which the data in each test is validated",
32+
"type": "string"
33+
},
34+
"tests": [
35+
{
36+
"description": "Test for a valid instance",
37+
"data": "the instance to validate",
38+
"valid": true
39+
},
40+
{
41+
"description": "Test for an invalid instance",
42+
"data": 15,
43+
"valid": false
44+
}
45+
]
46+
}
4647
```
4748

48-
In short: a description, a schema under test, and some tests, where each
49-
test in the `tests` array is an objects with a description of the case
50-
itself, the instance under test, and a boolean indicating whether it
51-
should be valid or invalid.
49+
In short: a description, a schema under test, and some tests, where each test
50+
in the `tests` array is an objects with a description of the case itself, the
51+
instance under test, and a boolean indicating whether it should be valid
52+
or invalid.
5253

53-
Coverage
54-
--------
54+
## Test Subdirectories
5555

56-
Drafts 07, 06, 04 and 03 should have full coverage, with drafts 06 and
57-
07 being considered current and actively supported.
56+
There is currently only one subdirectory that may exist within each draft
57+
directory. This is:
5858

59-
Draft 2019-09 support is under development. Contributions are very
60-
welcome, especially from implementers as they add support to their own
61-
implementations.
59+
1. `optional/`: Contains tests that are considered optional.
6260

63-
If you see anything missing from the current supported drafts, or incorrect
64-
on any draft still accepting bug fixes, please file an issue or submit a PR.
61+
## Coverage
6562

66-
Who Uses the Test Suite
67-
-----------------------
63+
Drafts 07, 06, 04, and 03 should have full coverage, with tests for drafts 06,
64+
07, and 2019-09 being considered current and actively supported. Draft 2019-09
65+
is almost fully covered.
66+
67+
Contributions are very welcome, especially from implementers as they add support
68+
to their own implementations.
69+
70+
If you see anything missing from the current supported drafts, or incorrect on
71+
any draft still accepting bug fixes, please
72+
[file an issue](https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues)
73+
or [submit a PR](https://github.com/json-schema-org/JSON-Schema-Test-Suite).
74+
75+
## Who Uses the Test Suite
6876

6977
This suite is being used by:
7078

71-
### Clojure ###
79+
### Clojure
7280

7381
* [jinx](https://github.com/juxt/jinx)
7482
* [json-schema](https://github.com/tatut/json-schema)
7583

76-
### Coffeescript ###
84+
### Coffeescript
7785

7886
* [jsck](https://github.com/pandastrike/jsck)
7987

80-
### C++ ###
88+
### C++
8189

8290
* [Modern C++ JSON schema validator](https://github.com/pboettch/json-schema-validator)
8391

84-
### Dart ###
92+
### Dart
8593

8694
* [json_schema](https://github.com/patefacio/json_schema)
8795

88-
### Elixir ###
96+
### Elixir
8997

9098
* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
9199

92-
### Erlang ###
100+
### Erlang
93101

94102
* [jesse](https://github.com/for-GET/jesse)
95103

96-
### Go ###
104+
### Go
97105

98106
* [gojsonschema](https://github.com/sigu-399/gojsonschema)
99107
* [validate-json](https://github.com/cesanta/validate-json)
100108

101-
### Haskell ###
109+
### Haskell
102110

103111
* [aeson-schema](https://github.com/timjb/aeson-schema)
104112
* [hjsonschema](https://github.com/seagreen/hjsonschema)
105113

106-
### Java ###
114+
### Java
107115

108116
* [json-schema-validator](https://github.com/daveclayton/json-schema-validator)
109117
* [everit-org/json-schema](https://github.com/everit-org/json-schema)
110118
* [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator)
111119
* [Justify](https://github.com/leadpony/justify)
120+
* [Snow](https://github.com/ssilverman/snowy-json)
112121

113-
### JavaScript ###
122+
### JavaScript
114123

115124
* [json-schema-benchmark](https://github.com/Muscula/json-schema-benchmark)
116125
* [direct-schema](https://github.com/IreneKnapp/direct-schema)
@@ -128,7 +137,7 @@ This suite is being used by:
128137
* [ajv](https://github.com/epoberezkin/ajv)
129138
* [djv](https://github.com/korzio/djv)
130139

131-
### Node.js ###
140+
### Node.js
132141

133142
For node.js developers, the suite is also available as an
134143
[npm](https://www.npmjs.com/package/@json-schema-org/tests) package.
@@ -137,49 +146,53 @@ Node-specific support is maintained in a [separate
137146
repository](https://github.com/json-schema-org/json-schema-test-suite-npm)
138147
which also welcomes your contributions!
139148

140-
### .NET ###
149+
### .NET
141150

142151
* [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema)
143152
* [Manatee.Json](https://github.com/gregsdennis/Manatee.Json)
144153

145-
### PHP ###
154+
### Perl
155+
156+
* [JSON::Schema::Draft201909](https://github.com/karenetheridge/JSON-Schema-Draft201909)
157+
* [Test::JSON::Schema::Acceptance](https://github.com/karenetheridge/Test-JSON-Schema-Acceptance)
158+
159+
### PHP
146160

147161
* [json-schema](https://github.com/justinrainbow/json-schema)
148162
* [json-guard](https://github.com/thephpleague/json-guard)
149163

150-
### PostgreSQL ###
164+
### PostgreSQL
151165

152166
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
153167
* [is_jsonb_valid](https://github.com/furstenheim/is_jsonb_valid)
154168

155-
### Python ###
169+
### Python
156170

157171
* [jsonschema](https://github.com/Julian/jsonschema)
158172
* [fastjsonschema](https://github.com/seznam/python-fastjsonschema)
159173
* [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema)
160174

161-
### Ruby ###
175+
### Ruby
162176

163177
* [json-schema](https://github.com/hoxworth/json-schema)
164178
* [json_schemer](https://github.com/davishmcclurg/json_schemer)
165179

166-
### Rust ###
180+
### Rust
167181

168182
* [valico](https://github.com/rustless/valico)
169183

170-
### Swift ###
184+
### Swift
171185

172186
* [JSONSchema](https://github.com/kylef/JSONSchema.swift)
173187

174188
If you use it as well, please fork and send a pull request adding yourself to
175189
the list :).
176190

177-
Contributing
178-
------------
191+
## Contributing
179192

180193
If you see something missing or incorrect, a pull request is most welcome!
181194

182-
There are some sanity checks in place for testing the test suite. You
183-
can run them with `bin/jsonschema_suite check` or `tox`. They will be
184-
run automatically by [GitHub Actions](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
195+
There are some sanity checks in place for testing the test suite. You can run
196+
them with `bin/jsonschema_suite check` or `tox`. They will be run automatically
197+
by [GitHub Actions](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
185198
as well.

test-schema.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@
7171
"description": "Any additional comments about the test",
7272
"type": "string"
7373
},
74-
"data": {},
74+
"data": {
75+
"description": "This is the instance to be validated against the schema in \"schema\"."
76+
},
7577
"valid": { "type": "boolean" },
7678
"output": {
7779
"type": "object",

tests/draft2019-09/additionalItems.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@
4040
},
4141
"tests": [
4242
{
43-
"description": "fewer number of items present",
43+
"description": "empty array",
44+
"data": [ ],
45+
"valid": true
46+
},
47+
{
48+
"description": "fewer number of items present (1)",
49+
"data": [ 1 ],
50+
"valid": true
51+
},
52+
{
53+
"description": "fewer number of items present (2)",
4454
"data": [ 1, 2 ],
4555
"valid": true
4656
},

tests/draft2019-09/allOf.json

+50
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,55 @@
240240
"valid": false
241241
}
242242
]
243+
},
244+
{
245+
"description": "allOf combined with anyOf, oneOf",
246+
"schema": {
247+
"allOf": [ { "multipleOf": 2 } ],
248+
"anyOf": [ { "multipleOf": 3 } ],
249+
"oneOf": [ { "multipleOf": 5 } ]
250+
},
251+
"tests": [
252+
{
253+
"description": "allOf: false, anyOf: false, oneOf: false",
254+
"data": 1,
255+
"valid": false
256+
},
257+
{
258+
"description": "allOf: false, anyOf: false, oneOf: true",
259+
"data": 5,
260+
"valid": false
261+
},
262+
{
263+
"description": "allOf: false, anyOf: true, oneOf: false",
264+
"data": 3,
265+
"valid": false
266+
},
267+
{
268+
"description": "allOf: false, anyOf: true, oneOf: true",
269+
"data": 15,
270+
"valid": false
271+
},
272+
{
273+
"description": "allOf: true, anyOf: false, oneOf: false",
274+
"data": 2,
275+
"valid": false
276+
},
277+
{
278+
"description": "allOf: true, anyOf: false, oneOf: true",
279+
"data": 10,
280+
"valid": false
281+
},
282+
{
283+
"description": "allOf: true, anyOf: true, oneOf: false",
284+
"data": 6,
285+
"valid": false
286+
},
287+
{
288+
"description": "allOf: true, anyOf: true, oneOf: true",
289+
"data": 30,
290+
"valid": true
291+
}
292+
]
243293
}
244294
]

tests/draft2019-09/anchor.json

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
{
33
"description": "Location-independent identifier",
44
"schema": {
5-
"allOf": [{
6-
"$ref": "#foo"
7-
}],
5+
"$ref": "#foo",
86
"$defs": {
97
"A": {
108
"$anchor": "foo",
@@ -28,9 +26,7 @@
2826
{
2927
"description": "Location-independent identifier with absolute URI",
3028
"schema": {
31-
"allOf": [{
32-
"$ref": "http://localhost:1234/bar#foo"
33-
}],
29+
"$ref": "http://localhost:1234/bar#foo",
3430
"$defs": {
3531
"A": {
3632
"$id": "http://localhost:1234/bar",
@@ -56,9 +52,7 @@
5652
"description": "Location-independent identifier with base URI change in subschema",
5753
"schema": {
5854
"$id": "http://localhost:1234/root",
59-
"allOf": [{
60-
"$ref": "http://localhost:1234/nested.json#foo"
61-
}],
55+
"$ref": "http://localhost:1234/nested.json#foo",
6256
"$defs": {
6357
"A": {
6458
"$id": "nested.json",

tests/draft2019-09/const.json

+16
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,21 @@
238238
"valid": false
239239
}
240240
]
241+
},
242+
{
243+
"description": "nul characters in strings",
244+
"schema": { "const": "hello\u0000there" },
245+
"tests": [
246+
{
247+
"description": "match string with nul",
248+
"data": "hello\u0000there",
249+
"valid": true
250+
},
251+
{
252+
"description": "do not match string lacking nul",
253+
"data": "hellothere",
254+
"valid": false
255+
}
256+
]
241257
}
242258
]

0 commit comments

Comments
 (0)