-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
58 lines (48 loc) · 1.31 KB
/
index.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
/* eslint no-param-reassign: [2, { "props": false }] */
const djvDraft04 = ({
properties,
keywords,
validators,
formats,
keys,
transformation,
}) => {
Object.assign(properties, {
minimum(schema) {
return `%s <${schema.exclusiveMinimum ? '=' : ''} ${schema.minimum}`;
},
maximum(schema) {
return `%s >${schema.exclusiveMaximum ? '=' : ''} ${schema.maximum}`;
},
});
delete properties.exclusiveMaximum;
delete properties.exclusiveMinimum;
['$id', 'contains', 'const', 'examples'].forEach((key) => {
const index = keywords.indexOf(key);
if (index === -1) {
return;
}
keywords.splice(index, 1);
});
if (keywords.indexOf('exclusiveMaximum') === -1) {
keywords.push('exclusiveMaximum', 'exclusiveMininum', 'id');
}
['contains', 'constant', 'propertyNames'].forEach((key) => {
const validator = validators.name[key];
delete validators.name[key];
const index = validators.list.indexOf(validator);
if (index === -1) {
return;
}
validators.list.splice(index, 1);
});
delete formats['json-pointer'];
delete formats['uri-reference'];
delete formats['uri-template'];
Object.assign(keys, { id: 'id' });
Object.assign(transformation, {
ANY_SCHEMA: true,
NOT_ANY_SCHEMA: false,
});
};
module.exports = djvDraft04;