Skip to content

Commit b8cea19

Browse files
committed
Merge commit '2317eb8670e8f2076397159164c240dee846681c'
* commit '2317eb8670e8f2076397159164c240dee846681c': Squashed 'json/' changes from d38ddd54..217bf81b
2 parents c0b7866 + 2317eb8 commit b8cea19

31 files changed

+442
-727
lines changed

json/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ To test a specific version:
109109

110110
* For 2019-09 and later published drafts, implementations that are able to detect the draft of each schema via `$schema` SHOULD be configured to do so
111111
* For draft-07 and earlier, draft-next, and implementations unable to detect via `$schema`, implementations MUST be configured to expect the draft matching the test directory name
112-
* Load any remote references [described below](additional-assumptions) and configure your implementation to retrieve them via their URIs
112+
* Load any remote references [described below](#additional-assumptions) and configure your implementation to retrieve them via their URIs
113113
* Walk the filesystem tree for that version's subdirectory and for each `.json` file found:
114114

115115
* if the file is located in the root of the version directory:
@@ -159,7 +159,7 @@ If your implementation supports multiple versions, run the above procedure for e
159159
```
160160
161161
2. Test cases found within [special subdirectories](#subdirectories-within-each-draft) may require additional configuration to run.
162-
In particular, tests within the `optional/format` subdirectory may require implementations to change the way they treat the `"format"`keyword (particularly on older drafts which did not have a notion of vocabularies).
162+
In particular, when running tests within the `optional/format` subdirectory, test runners should configure implementations to enable format validation, where the implementation supports it.
163163
164164
### Invariants & Guarantees
165165
@@ -254,6 +254,7 @@ This suite is being used by:
254254

255255
### Java
256256

257+
* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations)
257258
* [json-schema-validator](https://github.com/daveclayton/json-schema-validator)
258259
* [everit-org/json-schema](https://github.com/everit-org/json-schema)
259260
* [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator)
@@ -279,6 +280,10 @@ This suite is being used by:
279280
* [ajv](https://github.com/epoberezkin/ajv)
280281
* [djv](https://github.com/korzio/djv)
281282

283+
### Kotlin
284+
285+
* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations)
286+
282287
### Node.js
283288

284289
For node.js developers, the suite is also available as an [npm](https://www.npmjs.com/package/@json-schema-org/tests) package.
@@ -327,6 +332,7 @@ Node-specific support is maintained in a [separate repository](https://github.co
327332

328333
### Scala
329334

335+
* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations)
330336
* [typed-json](https://github.com/frawa/typed-json)
331337

332338
### Swift

json/tests/draft-next/anchor.json

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -81,64 +81,6 @@
8181
}
8282
]
8383
},
84-
{
85-
"description": "$anchor inside an enum is not a real identifier",
86-
"comment": "the implementation must not be confused by an $anchor buried in the enum",
87-
"schema": {
88-
"$schema": "https://json-schema.org/draft/next/schema",
89-
"$defs": {
90-
"anchor_in_enum": {
91-
"enum": [
92-
{
93-
"$anchor": "my_anchor",
94-
"type": "null"
95-
}
96-
]
97-
},
98-
"real_identifier_in_schema": {
99-
"$anchor": "my_anchor",
100-
"type": "string"
101-
},
102-
"zzz_anchor_in_const": {
103-
"const": {
104-
"$anchor": "my_anchor",
105-
"type": "null"
106-
}
107-
}
108-
},
109-
"anyOf": [
110-
{ "$ref": "#/$defs/anchor_in_enum" },
111-
{ "$ref": "#my_anchor" }
112-
]
113-
},
114-
"tests": [
115-
{
116-
"description": "exact match to enum, and type matches",
117-
"data": {
118-
"$anchor": "my_anchor",
119-
"type": "null"
120-
},
121-
"valid": true
122-
},
123-
{
124-
"description": "in implementations that strip $anchor, this may match either $def",
125-
"data": {
126-
"type": "null"
127-
},
128-
"valid": false
129-
},
130-
{
131-
"description": "match $ref to $anchor",
132-
"data": "a string to match #/$defs/anchor_in_enum",
133-
"valid": true
134-
},
135-
{
136-
"description": "no match on enum or $ref to $anchor",
137-
"data": 1,
138-
"valid": false
139-
}
140-
]
141-
},
14284
{
14385
"description": "same $anchor with different base uri",
14486
"schema": {
@@ -175,38 +117,6 @@
175117
}
176118
]
177119
},
178-
{
179-
"description": "non-schema object containing an $anchor property",
180-
"schema": {
181-
"$schema": "https://json-schema.org/draft/next/schema",
182-
"$defs": {
183-
"const_not_anchor": {
184-
"const": {
185-
"$anchor": "not_a_real_anchor"
186-
}
187-
}
188-
},
189-
"if": {
190-
"const": "skip not_a_real_anchor"
191-
},
192-
"then": true,
193-
"else" : {
194-
"$ref": "#/$defs/const_not_anchor"
195-
}
196-
},
197-
"tests": [
198-
{
199-
"description": "skip traversing definition for a valid result",
200-
"data": "skip not_a_real_anchor",
201-
"valid": true
202-
},
203-
{
204-
"description": "const at const_not_anchor does not match",
205-
"data": 1,
206-
"valid": false
207-
}
208-
]
209-
},
210120
{
211121
"description": "invalid anchors",
212122
"schema": {

json/tests/draft-next/contains.json

Lines changed: 17 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,6 @@
3131
"data": [],
3232
"valid": false
3333
},
34-
{
35-
"description": "object with property matching schema (5) is valid",
36-
"data": { "a": 3, "b": 4, "c": 5 },
37-
"valid": true
38-
},
39-
{
40-
"description": "object with property matching schema (6) is valid",
41-
"data": { "a": 3, "b": 4, "c": 6 },
42-
"valid": true
43-
},
44-
{
45-
"description": "object with two properties matching schema (5, 6) is valid",
46-
"data": { "a": 3, "b": 4, "c": 5, "d": 6 },
47-
"valid": true
48-
},
49-
{
50-
"description": "object without properties matching schema is invalid",
51-
"data": { "a": 2, "b": 3, "c": 4 },
52-
"valid": false
53-
},
54-
{
55-
"description": "empty object is invalid",
56-
"data": {},
57-
"valid": false
58-
},
5934
{
6035
"description": "not array or object is valid",
6136
"data": 42,
@@ -84,21 +59,6 @@
8459
"description": "array without item 5 is invalid",
8560
"data": [1, 2, 3, 4],
8661
"valid": false
87-
},
88-
{
89-
"description": "object with property 5 is valid",
90-
"data": { "a": 3, "b": 4, "c": 5 },
91-
"valid": true
92-
},
93-
{
94-
"description": "object with two properties 5 is valid",
95-
"data": { "a": 3, "b": 4, "c": 5, "d": 5 },
96-
"valid": true
97-
},
98-
{
99-
"description": "object without property 5 is invalid",
100-
"data": { "a": 1, "b": 2, "c": 3, "d": 4 },
101-
"valid": false
10262
}
10363
]
10464
},
@@ -118,16 +78,6 @@
11878
"description": "empty array is invalid",
11979
"data": [],
12080
"valid": false
121-
},
122-
{
123-
"description": "any non-empty object is valid",
124-
"data": { "a": "foo" },
125-
"valid": true
126-
},
127-
{
128-
"description": "empty object is invalid",
129-
"data": {},
130-
"valid": false
13181
}
13282
]
13383
},
@@ -149,18 +99,28 @@
14999
"valid": false
150100
},
151101
{
152-
"description": "any non-empty object is invalid",
153-
"data": ["foo"],
154-
"valid": false
102+
"description": "non-arrays are valid - string",
103+
"data": "contains does not apply to strings",
104+
"valid": true
155105
},
156106
{
157-
"description": "empty object is invalid",
107+
"description": "non-arrays are valid - object",
158108
"data": {},
159-
"valid": false
109+
"valid": true
160110
},
161111
{
162-
"description": "non-arrays/objects are valid",
163-
"data": "contains does not apply to strings",
112+
"description": "non-arrays are valid - number",
113+
"data": 42,
114+
"valid": true
115+
},
116+
{
117+
"description": "non-arrays are valid - boolean",
118+
"data": false,
119+
"valid": true
120+
},
121+
{
122+
"description": "non-arrays are valid - null",
123+
"data": null,
164124
"valid": true
165125
}
166126
]
@@ -193,26 +153,6 @@
193153
"description": "matches neither items nor contains",
194154
"data": [1, 5],
195155
"valid": false
196-
},
197-
{
198-
"description": "matches additionalProperties, does not match contains",
199-
"data": { "a": 2, "b": 4, "c": 8 },
200-
"valid": false
201-
},
202-
{
203-
"description": "does not match additionalProperties, matches contains",
204-
"data": { "a": 3, "b": 6, "c": 9 },
205-
"valid": false
206-
},
207-
{
208-
"description": "matches both additionalProperties and contains",
209-
"data": { "a": 6, "b": 12 },
210-
"valid": true
211-
},
212-
{
213-
"description": "matches neither additionalProperties nor contains",
214-
"data": { "a": 1, "b": 5 },
215-
"valid": false
216156
}
217157
]
218158
},
@@ -235,16 +175,6 @@
235175
"description": "empty array is invalid",
236176
"data": [],
237177
"valid": false
238-
},
239-
{
240-
"description": "any non-empty object is valid",
241-
"data": { "a": "foo" },
242-
"valid": true
243-
},
244-
{
245-
"description": "empty object is invalid",
246-
"data": {},
247-
"valid": false
248178
}
249179
]
250180
},

json/tests/draft-next/dynamicRef.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,5 +612,35 @@
612612
"valid": false
613613
}
614614
]
615+
},
616+
{
617+
"description": "$dynamicRef points to a boolean schema",
618+
"schema": {
619+
"$schema": "https://json-schema.org/draft/next/schema",
620+
"$defs": {
621+
"true": true,
622+
"false": false
623+
},
624+
"properties": {
625+
"true": {
626+
"$dynamicRef": "#/$defs/true"
627+
},
628+
"false": {
629+
"$dynamicRef": "#/$defs/false"
630+
}
631+
}
632+
},
633+
"tests": [
634+
{
635+
"description": "follow $dynamicRef to a true schema",
636+
"data": { "true": 1 },
637+
"valid": true
638+
},
639+
{
640+
"description": "follow $dynamicRef to a false schema",
641+
"data": { "false": 1 },
642+
"valid": false
643+
}
644+
]
615645
}
616646
]

0 commit comments

Comments
 (0)