Skip to content

Commit 51653bf

Browse files
committed
Squashed 'json/' changes from 3481a79..73a0593
73a0593 Merge pull request python-jsonschema#169 from epoberezkin/draft6-tests-ajv e2e06d7 update ajv version, test bd14545 Merge branch 'master' into draft6-tests-ajv 8758156 Merge pull request python-jsonschema#172 from epoberezkin/bignum 19a0b46 Merge pull request python-jsonschema#171 from epoberezkin/id b8165b7 draft-06: option/bignum tests exclusiveMaximum/Minimum updated f04ed0e Merge branch 'master' into draft6-tests-ajv 0931c60 test: run draft-04/06 tests with ajv da8b14e Merge pull request python-jsonschema#170 from epoberezkin/boolean 20d706c Merge pull request python-jsonschema#163 from epoberezkin/boundary-point ae72865 Merge pull request python-jsonschema#168 from korzio/patch-1 f809e51 draft-06: $id keyword 04d7e06 Add djv validator to readme e86adb2 draft-06: $ref to boolean schemas d62b754 draft-06: allOf, anyOf, oneOf keywords with boolean schemas b714a18 draft-06: not keyword with boolean schemas b6b00f9 draft-06: contains keyword with boolean schemas 9c05d18 draft-06: propertyNames keyword with boolean schemas fa99135 draft-06: patternProperties keyword with boolean schemas 5a888a6 draft-06: dependencies keyword with boolean subschemas 53858ff draft-06: items keyword with boolean schemas afd6fab Merge pull request python-jsonschema#167 from json-schema-org/revert-123-relative-ref-id 3b9b688 Revert "Test relative reference resolution when ID is not present" 77e0411 draft-06: properties keyword with boolean schemas cff24c1 Merge pull request python-jsonschema#123 from yuloh/relative-ref-id e7c1f4e Merge pull request python-jsonschema#161 from epoberezkin/items 43bfc6b Merge pull request python-jsonschema#165 from epoberezkin/test-schema 6956f20 draft-06: boolean root schema e1139a3 update test-schema to draft-04 042fae9 Merge pull request python-jsonschema#164 from epoberezkin/zero-terminated 78de3a6 draft-06: zero-terminated float is a valid integer 9d998bb draft-04: added maximum/minimum tests for boundary point b8f51ab Merge pull request python-jsonschema#151 from epoberezkin/exclusive-limits 951bd41 Merge pull request python-jsonschema#154 from epoberezkin/property-names b974907 Merge pull request python-jsonschema#159 from epoberezkin/empty-property-list 9b1364e Merge pull request python-jsonschema#158 from epoberezkin/contains 95b4648 Merge pull request python-jsonschema#157 from epoberezkin/const 85efafb draft-06: required and dependencies with empty property arrays 7e40f2e draft-06: exclusiveMaximum and exclusiveMinimum validation 0058644 draft-06: propertyNames validation ba6c582 draft-06: const validation 9867b96 draft-06: contains keyword validation 96fed74 draft-04/06: updated descriptions for items/additionalItems test cases 0799212 Make the URI tests consistent with themselves. 65c18d5 draft-04/06: items/additionalItems tests 12ab007 Update to the new organization. a599e1e Flip protocol-relative URI Reference (not a URI) ed3391c Merge pull request python-jsonschema#150 from handrews/draft6 555dfd3 Initialize draft6 tests from draft4. 5363098 Merge remote-tracking branch 'pboettch/master' 2ba2657 Merge remote-tracking branch 'agebhar1/feature/java+everit-org' f7cec5a Merge remote-tracking branch 'agebhar1/feature/java+networknt' 16a8c1b Merge pull request python-jsonschema#145 from agebhar1/feature/java+json-schema-validator 6d29eb2 add `networknt/json-schema-validator` to test suite users b38690a add `everit-org/json-schema` to test suite users 5637345 update Java's `json-schema-validator` repository 5a2c708 Added 'Modern C++ JSON schema validator' 371977c Merge branch 'develop' e2618a0 Merge pull request python-jsonschema#142 from pipobscure/refOnly b24fae2 When $ref is present other keywords should be ignored cb25a4e Merge pull request python-jsonschema#134 from zloster/develop 1e9db5e Add optional check for non-ECMA 262 regular expressions efb3c89 Merge pull request python-jsonschema#127 from iainbeeston/extra-items-tests 27692ac Merge pull request python-jsonschema#133 from gavinwahl/develop fc7584e add postgres-json-schema 654cc26 Added tests for items when data contains more or less types than the schema 5fb3d9f Merge pull request python-jsonschema#125 from yuloh/ref-property 833a70c Merge pull request python-jsonschema#126 from gregsdennis/develop 302da1e Added Manatee.Json as .Net implementor. dc001c2 Add test for properties named $ref 6d366dc Test relative reference resolution 9355965 Merge pull request python-jsonschema#120 from seagreen/extract-test-schema 42ba0f9 Extract the schema for tests into a JSON file. 2f0d6e3 Merge pull request python-jsonschema#118 from yuloh/ignores-non-objects-required cc52997 Test required ignores non objects 27ed651 Merge pull request python-jsonschema#117 from tatut/develop c9f5dcd Add Clojure json-schema to users 8549899 Merge pull request python-jsonschema#116 from yuloh/patch-1 de70a75 Add league/json-guard implementation for PHP 9723c8f Merge pull request python-jsonschema#111 from Relequestual/patch-1 9d5909a Also check string "1" is not a number in draft 4 e4ab5bd Check that a string of "1" is not a number 5dc71b8 Merge pull request python-jsonschema#108 from duksis/patch-1 6a054cd Adds ex_json_schema validator for Elixir f3d5aeb Merge branch 'develop' 5bcf11a Port to draft4. 3f7ed81 Merge pull request python-jsonschema#103 from Relequestual/patch-1 928d3b0 Fixed incorrect negative description of a sub test 62414e4 Minor shuffling. a7305a6 Merge remote-tracking branch 'legoktm/tox' into develop 5cc622c Merge pull request python-jsonschema#100 from atomiqio/develop 2f51b2e updated node.js info in README.md 8f29757 Add the README note on develop. 338eef3 Merge pull request python-jsonschema#97 from atomiqio/develop 146e291 JavaScript should written in upper camel case 7511038 Merge pull request python-jsonschema#95 from epoberezkin/develop ca28bbb added ajv validator to readme 504f776 Merge pull request python-jsonschema#93 from gelraen/readme 59207fd Add another Go implementation d14cf96 Use tox to run tests git-subtree-dir: json git-subtree-split: 73a05935f5418f4b59fb8084b4ffa6edf8a4eea0
1 parent 7afa6f0 commit 51653bf

Some content is hidden

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

57 files changed

+3494
-42
lines changed

.travis.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
language: python
22
python: "2.7"
3-
install: pip install jsonschema
4-
script: bin/jsonschema_suite check
3+
node_js: "6"
4+
install:
5+
- pip install tox
6+
- npm install
7+
script:
8+
- tox
9+
- npm test

README.md

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite.png?branch=develop)](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite)
1+
JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite.svg?branch=master)](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite)
22
======================
33

44
This repository contains a set of JSON objects that implementors of JSON Schema
@@ -64,17 +64,26 @@ This suite is being used by:
6464

6565
* [jsck](https://github.com/pandastrike/jsck)
6666

67+
### C++ ###
68+
69+
* [Modern C++ JSON schema validator](https://github.com/pboettch/json-schema-validator)
70+
6771
### Dart ###
6872

6973
* [json_schema](https://github.com/patefacio/json_schema)
7074

75+
### Elixir ###
76+
77+
* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
78+
7179
### Erlang ###
7280

7381
* [jesse](https://github.com/klarna/jesse)
7482

7583
### Go ###
7684

7785
* [gojsonschema](https://github.com/sigu-399/gojsonschema)
86+
* [validate-json](https://github.com/cesanta/validate-json)
7887

7988
### Haskell ###
8089

@@ -83,9 +92,11 @@ This suite is being used by:
8392

8493
### Java ###
8594

86-
* [json-schema-validator](https://github.com/fge/json-schema-validator)
95+
* [json-schema-validator](https://github.com/daveclayton/json-schema-validator)
96+
* [everit-org/json-schema](https://github.com/everit-org/json-schema)
97+
* [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator)
8798

88-
### Javascript ###
99+
### JavaScript ###
89100

90101
* [json-schema-benchmark](https://github.com/Muscula/json-schema-benchmark)
91102
* [direct-schema](https://github.com/IreneKnapp/direct-schema)
@@ -100,14 +111,26 @@ This suite is being used by:
100111
* [tv4](https://github.com/geraintluff/tv4)
101112
* [z-schema](https://github.com/zaggino/z-schema)
102113
* [jsen](https://github.com/bugventure/jsen)
114+
* [ajv](https://github.com/epoberezkin/ajv)
115+
* [djv](https://github.com/korzio/djv)
116+
117+
### Node.js ###
118+
119+
The JSON Schema Test Suite is also available as an
120+
[npm](https://www.npmjs.com/package/json-schema-test-suite) package.
121+
Node-specific support is maintained on the [node branch](https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/node).
122+
See [NODE-README.md](https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/node/NODE-README.md)
123+
for more information.
103124

104125
### .NET ###
105126

106127
* [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema)
128+
* [Manatee.Json](https://github.com/gregsdennis/Manatee.Json)
107129

108130
### PHP ###
109131

110132
* [json-schema](https://github.com/justinrainbow/json-schema)
133+
* [json-guard](https://github.com/thephpleague/json-guard)
111134

112135
### Python ###
113136

@@ -125,6 +148,14 @@ This suite is being used by:
125148

126149
* [JSONSchema](https://github.com/kylef/JSONSchema.swift)
127150

151+
### Clojure ###
152+
153+
* [json-schema](https://github.com/tatut/json-schema)
154+
155+
### PostgreSQL ###
156+
157+
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
158+
128159
If you use it as well, please fork and send a pull request adding yourself to
129160
the list :).
130161

@@ -134,5 +165,5 @@ Contributing
134165
If you see something missing or incorrect, a pull request is most welcome!
135166

136167
There are some sanity checks in place for testing the test suite. You can run
137-
them with `bin/jsonschema_suite check`. They will be run automatically by
168+
them with `bin/jsonschema_suite check && npm test` or `tox && npm test`. They will be run automatically by
138169
[Travis CI](https://travis-ci.org/) as well.

bin/jsonschema_suite

+2-27
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:

index.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
var Ajv = require('ajv');
4+
var jsonSchemaTest = require('json-schema-test');
5+
var assert = require('assert');
6+
7+
var refs = {
8+
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
9+
'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
10+
'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json')
11+
};
12+
13+
runTest(4);
14+
runTest(6);
15+
16+
function runTest(draft) {
17+
var opts = {addUsedSchema: false};
18+
if (draft == 4) opts.meta = false;
19+
var ajv = new Ajv(opts);
20+
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
21+
if (draft == 4) ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
22+
for (var uri in refs) ajv.addSchema(refs[uri], uri);
23+
24+
jsonSchemaTest(ajv, {
25+
description: 'Test suite draft-0' + draft,
26+
suites: {tests: './tests/draft' + draft + '/{**/,}*.json'},
27+
skip: draft == 4 ? ['optional/zeroTerminatedFloats'] : [],
28+
cwd: __dirname,
29+
hideFolder: 'tests/'
30+
});
31+
}

package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "json-schema-test-suite",
3+
"version": "0.1.0",
4+
"description": "A language agnostic test suite for the JSON Schema specifications",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha index.js -R spec"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git"
12+
},
13+
"keywords": [
14+
"json-schema",
15+
"tests"
16+
],
17+
"author": "http://json-schema.org",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues"
21+
},
22+
"homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
23+
"devDependencies": {
24+
"ajv": "^5.0.4-beta.0",
25+
"json-schema-test": "^1.3.0",
26+
"mocha": "^3.2.0"
27+
}
28+
}

test-schema.json

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

tests/draft3/optional/format.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
"valid": true
7979
},
8080
{
81-
"description": "a valid protocol-relative URI",
81+
"description": "an invalid protocol-relative URI Reference",
8282
"data": "//foo.bar/?baz=qux#quux",
83-
"valid": true
83+
"valid": false
8484
},
8585
{
8686
"description": "an invalid URI",

tests/draft3/ref.json

+33
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@
140140
}
141141
]
142142
},
143+
{
144+
"description": "ref overrides any sibling keywords",
145+
"schema": {
146+
"definitions": {
147+
"reffed": {
148+
"type": "array"
149+
}
150+
},
151+
"properties": {
152+
"foo": {
153+
"$ref": "#/definitions/reffed",
154+
"maxItems": 2
155+
}
156+
}
157+
},
158+
"tests": [
159+
{
160+
"description": "remote ref valid",
161+
"data": { "foo": [] },
162+
"valid": true
163+
},
164+
{
165+
"description": "remote ref valid, maxItems ignored",
166+
"data": { "foo": [ 1, 2, 3] },
167+
"valid": true
168+
},
169+
{
170+
"description": "ref invalid",
171+
"data": { "foo": "string" },
172+
"valid": false
173+
}
174+
]
175+
},
143176
{
144177
"description": "remote ref, containing refs itself",
145178
"schema": {"$ref": "http://json-schema.org/draft-03/schema#"},

tests/draft3/type.json

+17-2
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": {},
@@ -188,7 +203,7 @@
188203
"valid": false
189204
},
190205
{
191-
"description": "an array is not an array",
206+
"description": "an array is an array",
192207
"data": [],
193208
"valid": true
194209
},
@@ -234,7 +249,7 @@
234249
"valid": false
235250
},
236251
{
237-
"description": "a boolean is not a boolean",
252+
"description": "a boolean is a boolean",
238253
"data": true,
239254
"valid": true
240255
},

tests/draft4/additionalItems.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@
4040
},
4141
"tests": [
4242
{
43-
"description": "no additional items present",
43+
"description": "fewer number of items present",
44+
"data": [ 1, 2 ],
45+
"valid": true
46+
},
47+
{
48+
"description": "equal number of items present",
4449
"data": [ 1, 2, 3 ],
4550
"valid": true
4651
},

tests/draft4/items.json

+32
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
"description": "ignores non-arrays",
2020
"data": {"foo" : "bar"},
2121
"valid": true
22+
},
23+
{
24+
"description": "JavaScript pseudo-array is valid",
25+
"data": {
26+
"0": "invalid",
27+
"length": 1
28+
},
29+
"valid": true
2230
}
2331
]
2432
},
@@ -40,6 +48,30 @@
4048
"description": "wrong types",
4149
"data": [ "foo", 1 ],
4250
"valid": false
51+
},
52+
{
53+
"description": "incomplete array of items",
54+
"data": [ 1 ],
55+
"valid": true
56+
},
57+
{
58+
"description": "array with additional items",
59+
"data": [ 1, "foo", true ],
60+
"valid": true
61+
},
62+
{
63+
"description": "empty array",
64+
"data": [ ],
65+
"valid": true
66+
},
67+
{
68+
"description": "JavaScript pseudo-array is valid",
69+
"data": {
70+
"0": "invalid",
71+
"1": "valid",
72+
"length": 2
73+
},
74+
"valid": true
4375
}
4476
]
4577
}

0 commit comments

Comments
 (0)