-
-
Notifications
You must be signed in to change notification settings - Fork 864
/
json-schema.spec.js
60 lines (49 loc) · 1.88 KB
/
json-schema.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
var jsonSchemaTest = require('json-schema-test');
var Ajv = require('../lib/ajv')
, ajv = Ajv({ beautify: true, _debug: false })
, fullAjv = Ajv({ allErrors: true, verbose: true, format: 'full', beautify: true, _debug: false });
var remoteRefs = {
// for JSON-Schema-Test-Suite
'http://localhost:1234/integer.json': require('./JSON-Schema-Test-Suite/remotes/integer.json'),
'http://localhost:1234/subSchemas.json': require('./JSON-Schema-Test-Suite/remotes/subSchemas.json'),
'http://localhost:1234/folder/folderInteger.json': require('./JSON-Schema-Test-Suite/remotes/folder/folderInteger.json'),
// for tests
'http://localhost:1234/name.json': require('./remotes/name.json')
};
var remoteRefsWithIds = [ // order is important
require('./remotes/bar.json'),
require('./remotes/foo.json'),
require('./remotes/buu.json'),
];
addRemoteRefs();
jsonSchemaTest([ ajv, fullAjv ], {
suites: {
'JSON-Schema tests draft4': './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json',
'Advanced schema tests': './tests/{**/,}*.json'
},
only: [
// 'type', 'not', 'allOf', 'anyOf', 'oneOf', 'enum',
// 'maximum', 'minimum', 'multipleOf', 'maxLength', 'minLength', 'pattern',
// 'properties', 'patternProperties', 'additionalProperties',
// 'dependencies', 'required',
// 'maxProperties', 'minProperties', 'maxItems', 'minItems',
// 'items', 'additionalItems', 'uniqueItems',
// 'optional/format', 'optional/bignum',
// 'ref', 'refRemote', 'definitions',
// 'schemas/complex', 'schemas/basic', 'schemas/advanced',
],
skip: [
'optional/zeroTerminatedFloats'
],
cwd: __dirname,
hideFolder: 'draft4/'
});
function addRemoteRefs() {
for (var id in remoteRefs) {
ajv.addSchema(remoteRefs[id], id);
fullAjv.addSchema(remoteRefs[id], id);
}
ajv.addSchema(remoteRefsWithIds);
fullAjv.addSchema(remoteRefsWithIds);
}