Skip to content

Commit d545553

Browse files
committed
Merge branch 'master' into format
2 parents e1e1eec + bc4de6c commit d545553

File tree

11 files changed

+461
-17
lines changed

11 files changed

+461
-17
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
language: python
22
python: "2.7"
3-
install: pip install tox
4-
script: tox
3+
node_js: "6"
4+
install:
5+
- pip install tox
6+
- npm install
7+
script:
8+
- tox
9+
- npm test

README.md

Lines changed: 2 additions & 2 deletions
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-org/JSON-Schema-Test-Suite.png?branch=develop)](https://travis-ci.org/json-schema-org/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
@@ -165,5 +165,5 @@ Contributing
165165
If you see something missing or incorrect, a pull request is most welcome!
166166

167167
There are some sanity checks in place for testing the test suite. You can run
168-
them with `bin/jsonschema_suite check` or `tox`. 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
169169
[Travis CI](https://travis-ci.org/) as well.

index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
'http://localhost:1234/name.json': require('./remotes/name.json')
12+
};
13+
14+
runTest(4);
15+
runTest(6);
16+
17+
function runTest(draft) {
18+
var opts = {};
19+
if (draft == 4) opts.meta = false;
20+
var ajv = new Ajv(opts);
21+
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
22+
if (draft == 4) ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
23+
for (var uri in refs) ajv.addSchema(refs[uri], uri);
24+
25+
jsonSchemaTest(ajv, {
26+
description: 'Test suite draft-0' + draft,
27+
suites: {tests: './tests/draft' + draft + '/{**/,}*.json'},
28+
skip: draft == 4 ? ['optional/zeroTerminatedFloats'] : [],
29+
cwd: __dirname,
30+
hideFolder: 'tests/'
31+
});
32+
}

package.json

Lines changed: 28 additions & 0 deletions
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+
}

remotes/name.json

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

tests/draft4/ref.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,93 @@
208208
"valid": false
209209
}
210210
]
211+
},
212+
{
213+
"description": "Recursive references between schemas",
214+
"schema": {
215+
"id": "http://localhost:1234/tree",
216+
"description": "tree of nodes",
217+
"type": "object",
218+
"properties": {
219+
"meta": {"type": "string"},
220+
"nodes": {
221+
"type": "array",
222+
"items": {"$ref": "node"}
223+
}
224+
},
225+
"required": ["meta", "nodes"],
226+
"definitions": {
227+
"node": {
228+
"id": "http://localhost:1234/node",
229+
"description": "node",
230+
"type": "object",
231+
"properties": {
232+
"value": {"type": "number"},
233+
"subtree": {"$ref": "tree"}
234+
},
235+
"required": ["value"]
236+
}
237+
}
238+
},
239+
"tests": [
240+
{
241+
"description": "valid tree",
242+
"data": {
243+
"meta": "root",
244+
"nodes": [
245+
{
246+
"value": 1,
247+
"subtree": {
248+
"meta": "child",
249+
"nodes": [
250+
{"value": 1.1},
251+
{"value": 1.2}
252+
]
253+
}
254+
},
255+
{
256+
"value": 2,
257+
"subtree": {
258+
"meta": "child",
259+
"nodes": [
260+
{"value": 2.1},
261+
{"value": 2.2}
262+
]
263+
}
264+
}
265+
]
266+
},
267+
"valid": true
268+
},
269+
{
270+
"description": "invalid tree",
271+
"data": {
272+
"meta": "root",
273+
"nodes": [
274+
{
275+
"value": 1,
276+
"subtree": {
277+
"meta": "child",
278+
"nodes": [
279+
{"value": "string is invalid"},
280+
{"value": 1.2}
281+
]
282+
}
283+
},
284+
{
285+
"value": 2,
286+
"subtree": {
287+
"meta": "child",
288+
"nodes": [
289+
{"value": 2.1},
290+
{"value": 2.2}
291+
]
292+
}
293+
}
294+
]
295+
},
296+
"valid": false
297+
}
298+
]
211299
}
212300
]

tests/draft4/refRemote.json

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
]
5151
},
5252
{
53-
"description": "change resolution scope",
53+
"description": "base URI change",
5454
"schema": {
5555
"id": "http://localhost:1234/",
5656
"items": {
@@ -60,15 +60,112 @@
6060
},
6161
"tests": [
6262
{
63-
"description": "changed scope ref valid",
63+
"description": "base URI change ref valid",
6464
"data": [[1]],
6565
"valid": true
6666
},
6767
{
68-
"description": "changed scope ref invalid",
68+
"description": "base URI change ref invalid",
6969
"data": [["a"]],
7070
"valid": false
7171
}
7272
]
73+
},
74+
{
75+
"description": "base URI change - change folder",
76+
"schema": {
77+
"id": "http://localhost:1234/scope_change_defs1.json",
78+
"type" : "object",
79+
"properties": {
80+
"list": {"$ref": "#/definitions/baz"}
81+
},
82+
"definitions": {
83+
"baz": {
84+
"id": "folder/",
85+
"type": "array",
86+
"items": {"$ref": "folderInteger.json"}
87+
}
88+
}
89+
},
90+
"tests": [
91+
{
92+
"description": "number is valid",
93+
"data": {"list": [1]},
94+
"valid": true
95+
},
96+
{
97+
"description": "string is invalid",
98+
"data": {"list": ["a"]},
99+
"valid": false
100+
}
101+
]
102+
},
103+
{
104+
"description": "base URI change - change folder in subschema",
105+
"schema": {
106+
"id": "http://localhost:1234/scope_change_defs2.json",
107+
"type" : "object",
108+
"properties": {
109+
"list": {"$ref": "#/definitions/baz/definitions/bar"}
110+
},
111+
"definitions": {
112+
"baz": {
113+
"id": "folder/",
114+
"definitions": {
115+
"bar": {
116+
"type": "array",
117+
"items": {"$ref": "folderInteger.json"}
118+
}
119+
}
120+
}
121+
}
122+
},
123+
"tests": [
124+
{
125+
"description": "number is valid",
126+
"data": {"list": [1]},
127+
"valid": true
128+
},
129+
{
130+
"description": "string is invalid",
131+
"data": {"list": ["a"]},
132+
"valid": false
133+
}
134+
]
135+
},
136+
{
137+
"description": "root ref in remote ref",
138+
"schema": {
139+
"id": "http://localhost:1234/object",
140+
"type": "object",
141+
"properties": {
142+
"name": {"$ref": "name.json#/definitions/orNull"}
143+
}
144+
},
145+
"tests": [
146+
{
147+
"description": "string is valid",
148+
"data": {
149+
"name": "foo"
150+
},
151+
"valid": true
152+
},
153+
{
154+
"description": "null is valid",
155+
"data": {
156+
"name": null
157+
},
158+
"valid": true
159+
},
160+
{
161+
"description": "object is invalid",
162+
"data": {
163+
"name": {
164+
"name": null
165+
}
166+
},
167+
"valid": false
168+
}
169+
]
73170
}
74171
]

tests/draft6/optional/bignum.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@
6868
{
6969
"description": "float comparison with high precision",
7070
"schema": {
71-
"maximum": 972783798187987123879878123.18878137,
72-
"exclusiveMaximum": true
71+
"exclusiveMaximum": 972783798187987123879878123.18878137
7372
},
7473
"tests": [
7574
{
@@ -93,8 +92,7 @@
9392
{
9493
"description": "float comparison with high precision on negative numbers",
9594
"schema": {
96-
"minimum": -972783798187987123879878123.18878137,
97-
"exclusiveMinimum": true
95+
"exclusiveMinimum": -972783798187987123879878123.18878137
9896
},
9997
"tests": [
10098
{

tests/draft6/optional/zeroTerminatedFloats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"tests": [
88
{
9-
"description": "a float is not an integer even without fractional part",
9+
"description": "a float without fractional part is an integer",
1010
"data": 1.0,
1111
"valid": true
1212
}

0 commit comments

Comments
 (0)