Skip to content

Commit 371977c

Browse files
committed
Merge branch 'develop'
* develop: Add optional check for non-ECMA 262 regular expressions add postgres-json-schema Added tests for items when data contains more or less types than the schema Added Manatee.Json as .Net implementor. Add test for properties named $ref Extract the schema for tests into a JSON file. Test required ignores non objects Add Clojure json-schema to users Add league/json-guard implementation for PHP Also check string "1" is not a number in draft 4 Check that a string of "1" is not a number Adds ex_json_schema validator for Elixir
2 parents e2618a0 + cb25a4e commit 371977c

File tree

9 files changed

+125
-27
lines changed

9 files changed

+125
-27
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ This suite is being used by:
6868

6969
* [json_schema](https://github.com/patefacio/json_schema)
7070

71+
### Elixir ###
72+
73+
* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
74+
7175
### Erlang ###
7276

7377
* [jesse](https://github.com/klarna/jesse)
@@ -114,10 +118,12 @@ for more information.
114118
### .NET ###
115119

116120
* [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema)
121+
* [Manatee.Json](https://github.com/gregsdennis/Manatee.Json)
117122

118123
### PHP ###
119124

120125
* [json-schema](https://github.com/justinrainbow/json-schema)
126+
* [json-guard](https://github.com/thephpleague/json-guard)
121127

122128
### Python ###
123129

@@ -135,6 +141,14 @@ for more information.
135141

136142
* [JSONSchema](https://github.com/kylef/JSONSchema.swift)
137143

144+
### Clojure ###
145+
146+
* [json-schema](https://github.com/tatut/json-schema)
147+
148+
### PostgreSQL ###
149+
150+
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
151+
138152
If you use it as well, please fork and send a pull request adding yourself to
139153
the list :).
140154

bin/jsonschema_suite

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,8 @@ REMOTES = {
5252
}
5353
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
5454

55-
TESTSUITE_SCHEMA = {
56-
"$schema": "http://json-schema.org/draft-03/schema#",
57-
"type": "array",
58-
"items": {
59-
"type": "object",
60-
"properties": {
61-
"description": {"type": "string", "required": True},
62-
"schema": {"required": True},
63-
"tests": {
64-
"type": "array",
65-
"items": {
66-
"type": "object",
67-
"properties": {
68-
"description": {"type": "string", "required": True},
69-
"data": {"required": True},
70-
"valid": {"type": "boolean", "required": True}
71-
},
72-
"additionalProperties": False
73-
},
74-
"minItems": 1
75-
}
76-
},
77-
"additionalProperties": False,
78-
"minItems": 1
79-
}
80-
}
81-
55+
with open(os.path.join(ROOT_DIR, "test-schema.json")) as schema:
56+
TESTSUITE_SCHEMA = json.load(schema)
8257

8358
def files(paths):
8459
for path in paths:

test-schema.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-03/schema#",
3+
"type": "array",
4+
"items": {
5+
"type": "object",
6+
"properties": {
7+
"description": {"type": "string", "required": true},
8+
"schema": {"required": true},
9+
"tests": {
10+
"type": "array",
11+
"items": {
12+
"type": "object",
13+
"properties": {
14+
"description": {"type": "string", "required": true},
15+
"data": {"required": true},
16+
"valid": {"type": "boolean", "required": true}
17+
},
18+
"additionalProperties": false
19+
},
20+
"minItems": 1
21+
}
22+
},
23+
"additionalProperties": false,
24+
"minItems": 1
25+
}
26+
}

tests/draft3/type.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"data": "foo",
1919
"valid": false
2020
},
21+
{
22+
"description": "a string is still not an integer, even if it looks like one",
23+
"data": "1",
24+
"valid": false
25+
},
2126
{
2227
"description": "an object is not an integer",
2328
"data": {},
@@ -59,6 +64,11 @@
5964
"data": "foo",
6065
"valid": false
6166
},
67+
{
68+
"description": "a string is still not a number, even if it looks like one",
69+
"data": "1",
70+
"valid": false
71+
},
6272
{
6373
"description": "an object is not a number",
6474
"data": {},
@@ -100,6 +110,11 @@
100110
"data": "foo",
101111
"valid": true
102112
},
113+
{
114+
"description": "a string is still a string, even if it looks like a number",
115+
"data": "1",
116+
"valid": true
117+
},
103118
{
104119
"description": "an object is not a string",
105120
"data": {},

tests/draft4/items.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@
4040
"description": "wrong types",
4141
"data": [ "foo", 1 ],
4242
"valid": false
43+
},
44+
{
45+
"description": "incomplete array of items",
46+
"data": [ 1 ],
47+
"valid": true
48+
},
49+
{
50+
"description": "array with additional items",
51+
"data": [ 1, "foo", true ],
52+
"valid": true
53+
},
54+
{
55+
"description": "empty array",
56+
"data": [ ],
57+
"valid": true
4358
}
4459
]
4560
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"description": "ECMA 262 regex non-compliance",
4+
"schema": { "format": "regex" },
5+
"tests": [
6+
{
7+
"description": "ECMA 262 has no support for \\Z anchor from .NET",
8+
"data": "^\\S(|(.|\\n)*\\S)\\Z",
9+
"valid": false
10+
}
11+
]
12+
}
13+
]

tests/draft4/ref.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,25 @@
188188
"valid": false
189189
}
190190
]
191+
},
192+
{
193+
"description": "property named $ref that is not a reference",
194+
"schema": {
195+
"properties": {
196+
"$ref": {"type": "string"}
197+
}
198+
},
199+
"tests": [
200+
{
201+
"description": "property named $ref valid",
202+
"data": {"$ref": "a"},
203+
"valid": true
204+
},
205+
{
206+
"description": "property named $ref invalid",
207+
"data": {"$ref": 2},
208+
"valid": false
209+
}
210+
]
191211
}
192212
]

tests/draft4/required.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"description": "non-present required property is invalid",
1919
"data": {"bar": 1},
2020
"valid": false
21+
},
22+
{
23+
"description": "ignores non-objects",
24+
"data": 12,
25+
"valid": true
2126
}
2227
]
2328
},

tests/draft4/type.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"data": "foo",
1919
"valid": false
2020
},
21+
{
22+
"description": "a string is still not an integer, even if it looks like one",
23+
"data": "1",
24+
"valid": false
25+
},
2126
{
2227
"description": "an object is not an integer",
2328
"data": {},
@@ -59,6 +64,11 @@
5964
"data": "foo",
6065
"valid": false
6166
},
67+
{
68+
"description": "a string is still not a number, even if it looks like one",
69+
"data": "1",
70+
"valid": false
71+
},
6272
{
6373
"description": "an object is not a number",
6474
"data": {},
@@ -100,6 +110,11 @@
100110
"data": "foo",
101111
"valid": true
102112
},
113+
{
114+
"description": "a string is still a string, even if it looks like a number",
115+
"data": "1",
116+
"valid": true
117+
},
103118
{
104119
"description": "an object is not a string",
105120
"data": {},

0 commit comments

Comments
 (0)