Skip to content

Commit a39ed5a

Browse files
committed
Merge commit '2024cbfe74024a1ded9daa679b218fe3255b6635'
* commit '2024cbfe74024a1ded9daa679b218fe3255b6635': Squashed 'json/' changes from 812ba486..c09f995c
2 parents e4fa34f + 2024cbf commit a39ed5a

25 files changed

+867
-68
lines changed

json/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ for more information.
152152

153153
* [jsonschema](https://github.com/Julian/jsonschema)
154154
* [fastjsonschema](https://github.com/seznam/python-fastjsonschema)
155+
* [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema)
155156

156157
### Ruby ###
157158

158159
* [json-schema](https://github.com/hoxworth/json-schema)
160+
* [json_schemer](https://github.com/davishmcclurg/json_schemer)
159161

160162
### Rust ###
161163

json/bin/jsonschema_suite

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env python
22
from __future__ import print_function
3+
from pprint import pformat
34
import argparse
45
import errno
56
import fnmatch
@@ -38,6 +39,12 @@ REMOTES = {
3839
u"orNull": {u"anyOf": [{u"type": u"null"}, {u"$ref": u"#"}]},
3940
},
4041
},
42+
"name-defs.json": {
43+
u"type": "string",
44+
u"$defs": {
45+
u"orNull": {u"anyOf": [{u"type": u"null"}, {u"$ref": u"#"}]},
46+
},
47+
},
4148
"subSchemas.json": {
4249
u"integer": {u"type": u"integer"},
4350
u"refToInteger": {u"$ref": u"#/integer"},
@@ -140,11 +147,38 @@ class SanityTests(unittest.TestCase):
140147
with open(absolute_path) as schema_file:
141148
files[absolute_path] = json.load(schema_file)
142149

150+
expected = {
151+
os.path.join(REMOTES_DIR, path): contents
152+
for path, contents in REMOTES.iteritems()
153+
}
154+
155+
missing = set(files).symmetric_difference(expected)
156+
changed = {
157+
path
158+
for path, contents in expected.items()
159+
if path in files
160+
and contents != files[path]
161+
}
162+
143163
self.assertEqual(
144-
files, {
145-
os.path.join(REMOTES_DIR, path): contents
146-
for path, contents in REMOTES.iteritems()
147-
},
164+
files,
165+
expected,
166+
msg=textwrap.dedent(
167+
"""
168+
Remotes in the remotes/ directory do not match those in the
169+
``jsonschema_suite`` Python script.
170+
171+
Unfortunately for the minute, each remote file is duplicated in
172+
two places.""" + ("""
173+
174+
Only present in one location:
175+
176+
{}""".format("\n".join(missing)) if missing else "") + ("""
177+
178+
Conflicting between the two:
179+
180+
{}""".format("\n".join(changed)) if changed else "")
181+
)
148182
)
149183

150184

json/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const refs = {
88
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
99
'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
1010
'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json'),
11-
'http://localhost:1234/name.json': require('./remotes/name.json')
11+
'http://localhost:1234/name.json': require('./remotes/name.json'),
12+
'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json')
1213
};
1314

1415
const SKIP = {

json/remotes/name-defs.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$defs": {
3+
"orNull": {
4+
"anyOf": [
5+
{"type": "null"},
6+
{"$ref": "#"}
7+
]
8+
}
9+
},
10+
"type": "string"
11+
}

json/test-schema.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"definitions": {
4+
"outputItem": {
5+
"type": "object",
6+
"properties": {
7+
"valid": {"type": "boolean"},
8+
"keywordLocation": {"type": "string"},
9+
"absoluteKeywordLocation": {
10+
"type": "string",
11+
"format": "uri"
12+
},
13+
"instanceLocation": {"type": "string"},
14+
"annotations": {
15+
"type": "array",
16+
"items": {"$ref": "#/definitions/outputItem"}
17+
},
18+
"errors": {
19+
"type": "array",
20+
"items": {"$ref": "#/definitions/outputItem"}
21+
}
22+
}
23+
}
24+
},
325
"type": "array",
426
"items": {
527
"type": "object",
@@ -15,7 +37,16 @@
1537
"properties": {
1638
"description": {"type": "string"},
1739
"data": {},
18-
"valid": {"type": "boolean"}
40+
"valid": {"type": "boolean"},
41+
"output": {
42+
"type": "object",
43+
"properties": {
44+
"basic": {"$ref": "#/definitions/outputItem"},
45+
"detailed": {"$ref": "#/definitions/outputItem"},
46+
"verbose": {"$ref": "#/definitions/outputItem"}
47+
},
48+
"required": ["basic", "detailed", "verbose"]
49+
}
1950
},
2051
"additionalProperties": false
2152
},

json/tests/draft2019-06/anyOf.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,31 @@
159159
"valid": true
160160
}
161161
]
162+
},
163+
{
164+
"description": "nested anyOf, to check validation semantics",
165+
"schema": {
166+
"anyOf": [
167+
{
168+
"anyOf": [
169+
{
170+
"type": "null"
171+
}
172+
]
173+
}
174+
]
175+
},
176+
"tests": [
177+
{
178+
"description": "null is valid",
179+
"data": null,
180+
"valid": true
181+
},
182+
{
183+
"description": "anything non-null is invalid",
184+
"data": 123,
185+
"valid": false
186+
}
187+
]
162188
}
163189
]

json/tests/draft2019-06/const.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,89 @@
8282
"valid": false
8383
}
8484
]
85+
},
86+
{
87+
"description": "const with false does not match 0",
88+
"schema": {"const": false},
89+
"tests": [
90+
{
91+
"description": "false is valid",
92+
"data": false,
93+
"valid": true
94+
},
95+
{
96+
"description": "integer zero is invalid",
97+
"data": 0,
98+
"valid": false
99+
},
100+
{
101+
"description": "float zero is invalid",
102+
"data": 0.0,
103+
"valid": false
104+
}
105+
]
106+
},
107+
{
108+
"description": "const with true does not match 1",
109+
"schema": {"const": true},
110+
"tests": [
111+
{
112+
"description": "true is valid",
113+
"data": true,
114+
"valid": true
115+
},
116+
{
117+
"description": "integer one is invalid",
118+
"data": 1,
119+
"valid": false
120+
},
121+
{
122+
"description": "float one is invalid",
123+
"data": 1.0,
124+
"valid": false
125+
}
126+
]
127+
},
128+
{
129+
"description": "const with 0 does not match false",
130+
"schema": {"const": 0},
131+
"tests": [
132+
{
133+
"description": "false is invalid",
134+
"data": false,
135+
"valid": false
136+
},
137+
{
138+
"description": "integer zero is valid",
139+
"data": 0,
140+
"valid": true
141+
},
142+
{
143+
"description": "float zero is valid",
144+
"data": 0.0,
145+
"valid": true
146+
}
147+
]
148+
},
149+
{
150+
"description": "const with 1 does not match true",
151+
"schema": {"const": 1},
152+
"tests": [
153+
{
154+
"description": "true is invalid",
155+
"data": true,
156+
"valid": false
157+
},
158+
{
159+
"description": "integer one is valid",
160+
"data": 1,
161+
"valid": true
162+
},
163+
{
164+
"description": "float one is valid",
165+
"data": 1.0,
166+
"valid": true
167+
}
168+
]
85169
}
86170
]

json/tests/draft2019-06/definitions.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

json/tests/draft2019-06/defs.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[
2+
{
3+
"description": "valid definition",
4+
"schema": {"$ref": "http://json-schema.org/draft/2019-06/schema#"},
5+
"tests": [
6+
{
7+
"description": "valid definition schema",
8+
"data": {"$defs": {"foo": {"type": "integer"}}},
9+
"valid": true
10+
}
11+
]
12+
},
13+
{
14+
"description": "invalid definition",
15+
"schema": {"$ref": "http://json-schema.org/draft/2019-06/schema#"},
16+
"tests": [
17+
{
18+
"description": "invalid definition schema",
19+
"data": {"$defs": {"foo": {"type": 1}}},
20+
"valid": false
21+
}
22+
]
23+
}
24+
]

0 commit comments

Comments
 (0)