@hyperjump/json-schema 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -5
- package/annotations/annotated-instance.d.ts +83 -0
- package/annotations/annotated-instance.js +50 -0
- package/annotations/index.d.ts +11 -0
- package/annotations/index.js +123 -0
- package/annotations/tests/applicators.json +375 -0
- package/annotations/tests/content.json +60 -0
- package/annotations/tests/core.json +33 -0
- package/annotations/tests/format.json +21 -0
- package/annotations/tests/meta-data.json +135 -0
- package/annotations/tests/unevaluated.json +557 -0
- package/annotations/tests/unknown.json +91 -0
- package/annotations/tests/validation.json +328 -0
- package/annotations/validation-error.d.ts +8 -0
- package/annotations/validation-error.js +7 -0
- package/bundle/index.js +2 -3
- package/lib/keywords/additionalProperties.js +19 -4
- package/lib/keywords/allOf.js +2 -2
- package/lib/keywords/anyOf.js +2 -2
- package/lib/keywords/contains.js +14 -14
- package/lib/keywords/contentSchema.js +7 -2
- package/lib/keywords/dependentSchemas.js +18 -8
- package/lib/keywords/dynamicRef.js +2 -2
- package/lib/keywords/else.js +12 -19
- package/lib/keywords/if.js +2 -2
- package/lib/keywords/items.js +3 -3
- package/lib/keywords/not.js +1 -1
- package/lib/keywords/oneOf.js +2 -2
- package/lib/keywords/patternProperties.js +20 -3
- package/lib/keywords/prefixItems.js +3 -3
- package/lib/keywords/properties.js +18 -6
- package/lib/keywords/propertyDependencies.js +2 -2
- package/lib/keywords/propertyNames.js +1 -1
- package/lib/keywords/then.js +12 -19
- package/lib/keywords/unevaluatedItems.js +2 -2
- package/lib/keywords/unevaluatedProperties.js +25 -5
- package/lib/keywords/validation.js +43 -53
- package/lib/keywords.js +1 -1
- package/package.json +4 -2
|
@@ -12,16 +12,33 @@ const compile = (schema, ast) => Pact.pipeline([
|
|
|
12
12
|
Pact.all
|
|
13
13
|
], schema);
|
|
14
14
|
|
|
15
|
-
const interpret = (patternProperties, instance, ast, dynamicAnchors) => {
|
|
15
|
+
const interpret = (patternProperties, instance, ast, dynamicAnchors, quiet) => {
|
|
16
16
|
return !Instance.typeOf(instance, "object") || patternProperties.every(([pattern, schemaUrl]) => {
|
|
17
17
|
return Instance.entries(instance)
|
|
18
18
|
.filter(([propertyName]) => pattern.test(propertyName))
|
|
19
|
-
.every(([, propertyValue]) => Validation.interpret(schemaUrl, propertyValue, ast, dynamicAnchors));
|
|
19
|
+
.every(([, propertyValue]) => Validation.interpret(schemaUrl, propertyValue, ast, dynamicAnchors, quiet));
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const collectEvaluatedProperties = (patternProperties, instance, ast, dynamicAnchors) => {
|
|
24
|
-
|
|
24
|
+
if (!Instance.typeOf(instance, "object")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const evaluatedPropertyNames = new Set();
|
|
29
|
+
for (const [pattern, propertySchema] of patternProperties) {
|
|
30
|
+
for (const [propertyName, property] of Instance.entries(instance)) {
|
|
31
|
+
if (pattern.test(propertyName)) {
|
|
32
|
+
if (!Validation.interpret(propertySchema, property, ast, dynamicAnchors, true)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
evaluatedPropertyNames.add(propertyName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return evaluatedPropertyNames;
|
|
25
42
|
};
|
|
26
43
|
|
|
27
44
|
export default { id, compile, interpret, collectEvaluatedProperties };
|
|
@@ -13,16 +13,16 @@ const compile = (schema, ast) => {
|
|
|
13
13
|
], schema);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const interpret = (items, instance, ast, dynamicAnchors) => {
|
|
16
|
+
const interpret = (items, instance, ast, dynamicAnchors, quiet) => {
|
|
17
17
|
if (!Instance.typeOf(instance, "array")) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return Instance.every((item, ndx) => !(ndx in items) || Validation.interpret(items[ndx], item, ast, dynamicAnchors), instance);
|
|
21
|
+
return Instance.every((item, ndx) => !(ndx in items) || Validation.interpret(items[ndx], item, ast, dynamicAnchors, quiet), instance);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const collectEvaluatedItems = (items, instance, ast, dynamicAnchors) => {
|
|
25
|
-
return interpret(items, instance, ast, dynamicAnchors) && new Set(items.map((item, ndx) => ndx));
|
|
25
|
+
return interpret(items, instance, ast, dynamicAnchors, true) && new Set(items.map((item, ndx) => ndx));
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export default { id, compile, interpret, collectEvaluatedItems };
|
|
@@ -14,17 +14,29 @@ const compile = (schema, ast) => Pact.pipeline([
|
|
|
14
14
|
}, Object.create(null))
|
|
15
15
|
], schema);
|
|
16
16
|
|
|
17
|
-
const interpret = (properties, instance, ast, dynamicAnchors) => {
|
|
17
|
+
const interpret = (properties, instance, ast, dynamicAnchors, quiet) => {
|
|
18
18
|
return !Instance.typeOf(instance, "object") || Instance.entries(instance)
|
|
19
19
|
.filter(([propertyName]) => propertyName in properties)
|
|
20
|
-
.every(([propertyName, schemaUrl]) => Validation.interpret(properties[propertyName], schemaUrl, ast, dynamicAnchors));
|
|
20
|
+
.every(([propertyName, schemaUrl]) => Validation.interpret(properties[propertyName], schemaUrl, ast, dynamicAnchors, quiet));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const collectEvaluatedProperties = (properties, instance, ast, dynamicAnchors) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
24
|
+
if (!Instance.typeOf(instance, "object")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const evaluatedPropertyNames = new Set();
|
|
29
|
+
for (const [propertyName, property] of Instance.entries(instance)) {
|
|
30
|
+
if (propertyName in properties) {
|
|
31
|
+
if (!Validation.interpret(properties[propertyName], property, ast, dynamicAnchors, true)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
evaluatedPropertyNames.add(propertyName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return evaluatedPropertyNames;
|
|
40
|
+
};
|
|
29
41
|
|
|
30
42
|
export default { id, compile, interpret, collectEvaluatedProperties };
|
|
@@ -23,12 +23,12 @@ const compile = (schema, ast) => {
|
|
|
23
23
|
], schema);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const interpret = (propertyDependencies, instance, ast, dynamicAnchors) => {
|
|
26
|
+
const interpret = (propertyDependencies, instance, ast, dynamicAnchors, quiet) => {
|
|
27
27
|
return !Instance.typeOf(instance, "object") || Object.entries(propertyDependencies).every(([propertyName, valueMappings]) => {
|
|
28
28
|
const propertyValue = Instance.value(instance)[propertyName];
|
|
29
29
|
return !Instance.has(propertyName, instance)
|
|
30
30
|
|| !(propertyValue in valueMappings)
|
|
31
|
-
|| Validation.interpret(valueMappings[propertyValue], instance, ast, dynamicAnchors);
|
|
31
|
+
|| Validation.interpret(valueMappings[propertyValue], instance, ast, dynamicAnchors, quiet);
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -8,7 +8,7 @@ const compile = (schema, ast) => Validation.compile(schema, ast);
|
|
|
8
8
|
|
|
9
9
|
const interpret = (propertyNames, instance, ast, dynamicAnchors) => {
|
|
10
10
|
return !Instance.typeOf(instance, "object") || Instance.keys(instance)
|
|
11
|
-
.every((key) => Validation.interpret(propertyNames, Instance.cons(key), ast, dynamicAnchors));
|
|
11
|
+
.every((key) => Validation.interpret(propertyNames, Instance.cons(key), ast, dynamicAnchors, true));
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export default { id, compile, interpret };
|
package/lib/keywords/then.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Schema from "../schema.js";
|
|
2
|
-
import { getKeywordName
|
|
2
|
+
import { getKeywordName } from "../keywords.js";
|
|
3
3
|
import Validation from "./validation.js";
|
|
4
4
|
|
|
5
5
|
|
|
@@ -15,33 +15,26 @@ const compile = async (schema, ast, parentSchema) => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const interpret = ([
|
|
19
|
-
return
|
|
18
|
+
const interpret = ([ifSchema, thenSchema], instance, ast, dynamicAnchors, quiet) => {
|
|
19
|
+
return ifSchema === undefined
|
|
20
|
+
|| !Validation.interpret(ifSchema, instance, ast, dynamicAnchors, true)
|
|
21
|
+
|| Validation.interpret(thenSchema, instance, ast, dynamicAnchors, quiet);
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return typeof nodes === "boolean" ? nodes : nodes.every(([keywordId, , keywordValue]) => {
|
|
27
|
-
return getKeyword(keywordId).interpret(keywordValue, instance, ast, dynamicAnchors);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const collectEvaluatedProperties = ([guard, block], instance, ast, dynamicAnchors) => {
|
|
32
|
-
if (guard === undefined || !quietInterpretSchema(guard, instance, ast, dynamicAnchors)) {
|
|
33
|
-
return [];
|
|
24
|
+
const collectEvaluatedProperties = ([ifSchema, thenSchema], instance, ast, dynamicAnchors) => {
|
|
25
|
+
if (ifSchema === undefined || !Validation.interpret(ifSchema, instance, ast, dynamicAnchors, true)) {
|
|
26
|
+
return new Set();
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
return Validation.collectEvaluatedProperties(
|
|
29
|
+
return Validation.collectEvaluatedProperties(thenSchema, instance, ast, dynamicAnchors);
|
|
37
30
|
};
|
|
38
31
|
|
|
39
|
-
const collectEvaluatedItems = ([
|
|
40
|
-
if (
|
|
32
|
+
const collectEvaluatedItems = ([ifSchema, thenSchema], instance, ast, dynamicAnchors) => {
|
|
33
|
+
if (ifSchema === undefined || !Validation.interpret(ifSchema, instance, ast, dynamicAnchors, true)) {
|
|
41
34
|
return new Set();
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
return Validation.collectEvaluatedItems(
|
|
37
|
+
return Validation.collectEvaluatedItems(thenSchema, instance, ast, dynamicAnchors);
|
|
45
38
|
};
|
|
46
39
|
|
|
47
40
|
export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems };
|
|
@@ -9,14 +9,14 @@ const compile = async (schema, ast, parentSchema) => {
|
|
|
9
9
|
return [Schema.uri(parentSchema), await Validation.compile(schema, ast)];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const interpret = ([schemaUrl, unevaluatedItems], instance, ast, dynamicAnchors) => {
|
|
12
|
+
const interpret = ([schemaUrl, unevaluatedItems], instance, ast, dynamicAnchors, quiet) => {
|
|
13
13
|
if (!Instance.typeOf(instance, "array")) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const itemIndexes = Validation.collectEvaluatedItems(schemaUrl, instance, ast, dynamicAnchors, true);
|
|
18
18
|
return itemIndexes === false || Instance.every((item, itemIndex) => {
|
|
19
|
-
return itemIndexes.has(itemIndex) || Validation.interpret(unevaluatedItems, Instance.step(itemIndex, instance), ast, dynamicAnchors);
|
|
19
|
+
return itemIndexes.has(itemIndex) || Validation.interpret(unevaluatedItems, Instance.step(itemIndex, instance), ast, dynamicAnchors, quiet);
|
|
20
20
|
}, instance);
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -9,7 +9,7 @@ const compile = async (schema, ast, parentSchema) => {
|
|
|
9
9
|
return [Schema.uri(parentSchema), await Validation.compile(schema, ast)];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const interpret = ([schemaUrl, unevaluatedProperties], instance, ast, dynamicAnchors) => {
|
|
12
|
+
const interpret = ([schemaUrl, unevaluatedProperties], instance, ast, dynamicAnchors, quiet) => {
|
|
13
13
|
if (!Instance.typeOf(instance, "object")) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
@@ -17,12 +17,32 @@ const interpret = ([schemaUrl, unevaluatedProperties], instance, ast, dynamicAnc
|
|
|
17
17
|
const evaluatedPropertyNames = Validation.collectEvaluatedProperties(schemaUrl, instance, ast, dynamicAnchors, true);
|
|
18
18
|
|
|
19
19
|
return !evaluatedPropertyNames || Instance.entries(instance)
|
|
20
|
-
.filter(([propertyName]) => !evaluatedPropertyNames.
|
|
21
|
-
.every(([, property]) => Validation.interpret(unevaluatedProperties, property, ast, dynamicAnchors));
|
|
20
|
+
.filter(([propertyName]) => !evaluatedPropertyNames.has(propertyName))
|
|
21
|
+
.every(([, property]) => Validation.interpret(unevaluatedProperties, property, ast, dynamicAnchors, quiet));
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const collectEvaluatedProperties = (
|
|
25
|
-
|
|
24
|
+
const collectEvaluatedProperties = ([schemaUrl, unevaluatedProperties], instance, ast, dynamicAnchors) => {
|
|
25
|
+
if (!Instance.typeOf(instance, "object")) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const evaluatedPropertyNames = Validation.collectEvaluatedProperties(schemaUrl, instance, ast, dynamicAnchors, true);
|
|
30
|
+
|
|
31
|
+
if (!evaluatedPropertyNames) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const [propertyName, property] of Instance.entries(instance)) {
|
|
36
|
+
if (!evaluatedPropertyNames.has(propertyName)) {
|
|
37
|
+
if (!Validation.interpret(unevaluatedProperties, property, ast, dynamicAnchors, true)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
evaluatedPropertyNames.add(propertyName);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return evaluatedPropertyNames;
|
|
26
46
|
};
|
|
27
47
|
|
|
28
48
|
export default { id, compile, interpret, collectEvaluatedProperties };
|
|
@@ -30,78 +30,70 @@ const compile = async (schema, ast) => {
|
|
|
30
30
|
throw Error(`No schema found at '${url}'`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
ast[url] = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}),
|
|
55
|
-
Pact.all
|
|
56
|
-
], schema)
|
|
57
|
-
];
|
|
33
|
+
ast[url] = typeof schemaValue === "boolean" ? schemaValue : await Pact.pipeline([
|
|
34
|
+
Schema.entries,
|
|
35
|
+
Pact.map(async ([keyword, keywordSchema]) => {
|
|
36
|
+
const keywordId = getKeywordId(schema.dialectId, keyword);
|
|
37
|
+
if (!keywordId) {
|
|
38
|
+
throw Error(`Encountered unknown keyword '${keyword}' at ${url}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const keywordHandler = getKeyword(keywordId);
|
|
42
|
+
if (!keywordHandler) {
|
|
43
|
+
throw Error(`Encountered unsupported keyword ${keyword} at '${url}'. You can provide an implementation for the '${keywordId}' keyword using the 'addKeyword' function.`);
|
|
44
|
+
}
|
|
45
|
+
if (keywordHandler.experimental && !isExperimentalKeywordEnabled(keywordId)) {
|
|
46
|
+
throw Error(`Encountered experimental keyword ${keyword} at '${url}'. You can enable this keyword with: setExperimentalKeywordEnabled('${keywordId}', true)`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const keywordAst = await keywordHandler.compile(keywordSchema, ast, schema);
|
|
50
|
+
return [keywordId, Schema.uri(keywordSchema), keywordAst];
|
|
51
|
+
}),
|
|
52
|
+
Pact.all
|
|
53
|
+
], schema);
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
return url;
|
|
61
57
|
};
|
|
62
58
|
|
|
63
|
-
const interpret = (url, instance, ast, dynamicAnchors) => {
|
|
64
|
-
const [keywordId, schemaUrl, nodes] = ast[url];
|
|
65
|
-
|
|
59
|
+
const interpret = (url, instance, ast, dynamicAnchors, quiet = false) => {
|
|
66
60
|
dynamicAnchors = { ...ast.metaData[toAbsoluteUri(url)].dynamicAnchors, ...dynamicAnchors };
|
|
67
61
|
|
|
68
|
-
publish("result.start");
|
|
69
|
-
const isValid = typeof
|
|
70
|
-
publish("result.start");
|
|
71
|
-
const isValid = getKeyword(keywordId).interpret(keywordValue, instance, ast, dynamicAnchors);
|
|
62
|
+
!quiet && publish("result.start");
|
|
63
|
+
const isValid = typeof ast[url] === "boolean" ? ast[url] : ast[url].every(([keywordId, schemaUrl, keywordValue]) => {
|
|
64
|
+
!quiet && publish("result.start");
|
|
65
|
+
const isValid = getKeyword(keywordId).interpret(keywordValue, instance, ast, dynamicAnchors, quiet);
|
|
72
66
|
|
|
73
|
-
publish("result", {
|
|
67
|
+
!quiet && publish("result", {
|
|
74
68
|
keyword: keywordId,
|
|
75
69
|
absoluteKeywordLocation: schemaUrl,
|
|
76
70
|
instanceLocation: Instance.uri(instance),
|
|
77
71
|
valid: isValid,
|
|
78
72
|
ast: keywordValue
|
|
79
73
|
});
|
|
80
|
-
publish("result.end");
|
|
74
|
+
!quiet && publish("result.end");
|
|
81
75
|
return isValid;
|
|
82
76
|
});
|
|
83
77
|
|
|
84
|
-
publish("result", {
|
|
85
|
-
keyword:
|
|
86
|
-
absoluteKeywordLocation:
|
|
78
|
+
!quiet && publish("result", {
|
|
79
|
+
keyword: id,
|
|
80
|
+
absoluteKeywordLocation: url,
|
|
87
81
|
instanceLocation: Instance.uri(instance),
|
|
88
82
|
valid: isValid,
|
|
89
83
|
ast: url
|
|
90
84
|
});
|
|
91
|
-
publish("result.end");
|
|
85
|
+
!quiet && publish("result.end");
|
|
92
86
|
return isValid;
|
|
93
87
|
};
|
|
94
88
|
|
|
95
|
-
const emptyPropertyNames =
|
|
89
|
+
const emptyPropertyNames = new Set();
|
|
96
90
|
const collectEvaluatedProperties = (url, instance, ast, dynamicAnchors, isTop = false) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (typeof nodes === "boolean") {
|
|
100
|
-
return nodes ? [] : false;
|
|
91
|
+
if (typeof ast[url] === "boolean") {
|
|
92
|
+
return ast[url] ? [] : false;
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
const accumulatedPropertyNames =
|
|
104
|
-
for (const [keywordId, , keywordValue] of
|
|
95
|
+
const accumulatedPropertyNames = new Set();
|
|
96
|
+
for (const [keywordId, , keywordValue] of ast[url]) {
|
|
105
97
|
if (isTop && keywordId === "https://json-schema.org/keyword/unevaluatedProperties") {
|
|
106
98
|
continue;
|
|
107
99
|
}
|
|
@@ -109,13 +101,13 @@ const collectEvaluatedProperties = (url, instance, ast, dynamicAnchors, isTop =
|
|
|
109
101
|
const keywordHandler = getKeyword(keywordId);
|
|
110
102
|
const propertyNames = "collectEvaluatedProperties" in keywordHandler
|
|
111
103
|
? keywordHandler.collectEvaluatedProperties(keywordValue, instance, ast, dynamicAnchors, isTop)
|
|
112
|
-
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors,
|
|
104
|
+
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, true) && emptyPropertyNames;
|
|
113
105
|
|
|
114
106
|
if (propertyNames === false) {
|
|
115
107
|
return false;
|
|
116
108
|
}
|
|
117
109
|
|
|
118
|
-
|
|
110
|
+
propertyNames.forEach(Set.prototype.add.bind(accumulatedPropertyNames));
|
|
119
111
|
}
|
|
120
112
|
|
|
121
113
|
return accumulatedPropertyNames;
|
|
@@ -123,14 +115,12 @@ const collectEvaluatedProperties = (url, instance, ast, dynamicAnchors, isTop =
|
|
|
123
115
|
|
|
124
116
|
const emptyItemIndexes = new Set();
|
|
125
117
|
const collectEvaluatedItems = (url, instance, ast, dynamicAnchors, isTop = false) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (typeof nodes === "boolean") {
|
|
129
|
-
return nodes ? new Set() : false;
|
|
118
|
+
if (typeof ast[url] === "boolean") {
|
|
119
|
+
return ast[url] ? new Set() : false;
|
|
130
120
|
}
|
|
131
121
|
|
|
132
122
|
const accumulatedItemIndexes = new Set();
|
|
133
|
-
for (const [keywordId, , keywordValue] of
|
|
123
|
+
for (const [keywordId, , keywordValue] of ast[url]) {
|
|
134
124
|
if (isTop && keywordId === "https://json-schema.org/keyword/unevaluatedItems") {
|
|
135
125
|
continue;
|
|
136
126
|
}
|
|
@@ -138,7 +128,7 @@ const collectEvaluatedItems = (url, instance, ast, dynamicAnchors, isTop = false
|
|
|
138
128
|
const keywordHandler = getKeyword(keywordId);
|
|
139
129
|
const itemIndexes = "collectEvaluatedItems" in keywordHandler
|
|
140
130
|
? keywordHandler.collectEvaluatedItems(keywordValue, instance, ast, dynamicAnchors, isTop)
|
|
141
|
-
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors,
|
|
131
|
+
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, true) && emptyItemIndexes;
|
|
142
132
|
|
|
143
133
|
if (itemIndexes === false) {
|
|
144
134
|
return false;
|
package/lib/keywords.js
CHANGED
|
@@ -39,7 +39,7 @@ export const loadDialect = (dialectId, dialect, allowUnknownKeywords = false) =>
|
|
|
39
39
|
}
|
|
40
40
|
_dialects[dialectId][keyword] = keywordId;
|
|
41
41
|
});
|
|
42
|
-
} else {
|
|
42
|
+
} else if (!allowUnknownKeywords || isRequired) {
|
|
43
43
|
delete _dialects[dialectId];
|
|
44
44
|
throw Error(`Unrecognized vocabulary: ${vocabularyId}. You can define this vocabulary with the 'defineVocabulary' function.`);
|
|
45
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperjump/json-schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A JSON Schema validator with support for custom keywords, vocabularies, and dialects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./stable/index.js",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"./experimental": "./lib/experimental.js",
|
|
17
17
|
"./schema/experimental": "./lib/schema.js",
|
|
18
18
|
"./instance/experimental": "./lib/instance.js",
|
|
19
|
+
"./annotations/experimental": "./annotations/index.js",
|
|
20
|
+
"./annotated-instance/experimental": "./annotations/annotated-instance.js",
|
|
19
21
|
"./bundle": "./bundle/index.js"
|
|
20
22
|
},
|
|
21
23
|
"browser": {
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
"scripts": {
|
|
25
27
|
"clean": "xargs -a .gitignore rm -rf",
|
|
26
28
|
"lint": "eslint lib stable draft-* openapi-*",
|
|
27
|
-
"test": "mocha 'lib/**/*.spec.ts' 'stable/**/*.spec.ts' 'draft-*/**/*.spec.ts' 'openapi-*/**/*.spec.ts' 'bundle/**/*.spec.ts'"
|
|
29
|
+
"test": "mocha 'lib/**/*.spec.ts' 'stable/**/*.spec.ts' 'draft-*/**/*.spec.ts' 'openapi-*/**/*.spec.ts' 'bundle/**/*.spec.ts' 'annotations/**/*.spec.ts'"
|
|
28
30
|
},
|
|
29
31
|
"repository": "github:hyperjump-io/json-schema",
|
|
30
32
|
"keywords": [
|