diff --git a/annotations/annotated-instance.js b/annotations/annotated-instance.js index de12e6bd..62c22804 100644 --- a/annotations/annotated-instance.js +++ b/annotations/annotated-instance.js @@ -16,11 +16,11 @@ export const annotation = (node, keyword, dialect = defaultDialectId) => { const keywordUri = getKeywordId(keyword, dialect); let currentNode = node.root; - const errors = Object.keys(node.root.errors); + const errors = [...invalidSchemas(currentNode)]; for (let segment of JsonPointer.pointerSegments(node.pointer)) { segment = segment === "-" && Instance.typeOf(currentNode) === "array" ? Instance.length(currentNode) : segment; currentNode = Instance.step(segment, currentNode); - errors.push(...Object.keys(currentNode.errors)); + errors.push(...invalidSchemas(currentNode)); } const annotations = []; @@ -33,6 +33,14 @@ export const annotation = (node, keyword, dialect = defaultDialectId) => { return annotations; }; +const invalidSchemas = function* (node) { + for (const error in node.errors) { + if (node.errors[error] === "https://json-schema.org/evaluation/validate") { + yield error; + } + } +}; + export const annotatedWith = (instance, keyword, dialectId = defaultDialectId) => { const nodes = []; diff --git a/bundle/snapshots/077aa87e28ba586d7bf9bed115391f1c b/bundle/snapshots/077aa87e28ba586d7bf9bed115391f1c index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/077aa87e28ba586d7bf9bed115391f1c +++ b/bundle/snapshots/077aa87e28ba586d7bf9bed115391f1c @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/0968dc2e0f7f9d0fb95859803d130bcf b/bundle/snapshots/0968dc2e0f7f9d0fb95859803d130bcf index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/0968dc2e0f7f9d0fb95859803d130bcf +++ b/bundle/snapshots/0968dc2e0f7f9d0fb95859803d130bcf @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/1839eb3563f23d86ce8b82968a925bc6 b/bundle/snapshots/1839eb3563f23d86ce8b82968a925bc6 index 776676bc..5b8cca74 100644 --- a/bundle/snapshots/1839eb3563f23d86ce8b82968a925bc6 +++ b/bundle/snapshots/1839eb3563f23d86ce8b82968a925bc6 @@ -1,9 +1,7 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/string#/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/string#": "https://json-schema.org/evaluation/validate", - "https://bundler.hyperjump.io/main#/if/$ref": "https://json-schema.org/keyword/ref", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": { diff --git a/bundle/snapshots/2c8965601028dfe1a687613b46f8ca6f b/bundle/snapshots/2c8965601028dfe1a687613b46f8ca6f index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/2c8965601028dfe1a687613b46f8ca6f +++ b/bundle/snapshots/2c8965601028dfe1a687613b46f8ca6f @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/38e3d0fe6da335bf3be09d75dec08db7 b/bundle/snapshots/38e3d0fe6da335bf3be09d75dec08db7 index 37e3f413..9bfeabdc 100644 --- a/bundle/snapshots/38e3d0fe6da335bf3be09d75dec08db7 +++ b/bundle/snapshots/38e3d0fe6da335bf3be09d75dec08db7 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate", "https://test.json-schema.org/short-string#/maxLength": "https://json-schema.org/keyword/maxLength", "https://test.json-schema.org/short-string#": "https://json-schema.org/evaluation/validate", diff --git a/bundle/snapshots/4e7597c82e2c012d71fc5af69aae016e b/bundle/snapshots/4e7597c82e2c012d71fc5af69aae016e index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/4e7597c82e2c012d71fc5af69aae016e +++ b/bundle/snapshots/4e7597c82e2c012d71fc5af69aae016e @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/54e7e0f163e8df9b57359ebfaa226a94 b/bundle/snapshots/54e7e0f163e8df9b57359ebfaa226a94 index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/54e7e0f163e8df9b57359ebfaa226a94 +++ b/bundle/snapshots/54e7e0f163e8df9b57359ebfaa226a94 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/590bff4705440957e5a8b2ca6d90f7c1 b/bundle/snapshots/590bff4705440957e5a8b2ca6d90f7c1 index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/590bff4705440957e5a8b2ca6d90f7c1 +++ b/bundle/snapshots/590bff4705440957e5a8b2ca6d90f7c1 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/6183fe3ae5936b60f09dda163ec612f0 b/bundle/snapshots/6183fe3ae5936b60f09dda163ec612f0 index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/6183fe3ae5936b60f09dda163ec612f0 +++ b/bundle/snapshots/6183fe3ae5936b60f09dda163ec612f0 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/7add5d300125d4643ff534a1883bb27a b/bundle/snapshots/7add5d300125d4643ff534a1883bb27a index 9833b3e4..981f9c3f 100644 --- a/bundle/snapshots/7add5d300125d4643ff534a1883bb27a +++ b/bundle/snapshots/7add5d300125d4643ff534a1883bb27a @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": {} diff --git a/bundle/snapshots/8a4bd1aa80fd36bbc9f7625ed7d27c08 b/bundle/snapshots/8a4bd1aa80fd36bbc9f7625ed7d27c08 index 73f29199..f2172f06 100644 --- a/bundle/snapshots/8a4bd1aa80fd36bbc9f7625ed7d27c08 +++ b/bundle/snapshots/8a4bd1aa80fd36bbc9f7625ed7d27c08 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/string#/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/string#": "https://json-schema.org/evaluation/validate" }, "annotations": { diff --git a/bundle/snapshots/9b8b596cd673f6acb6020628b64323f5 b/bundle/snapshots/9b8b596cd673f6acb6020628b64323f5 index 9d99db0d..25ca2509 100644 --- a/bundle/snapshots/9b8b596cd673f6acb6020628b64323f5 +++ b/bundle/snapshots/9b8b596cd673f6acb6020628b64323f5 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate", "https://test.json-schema.org/short-string#/maxLength": "https://json-schema.org/keyword/maxLength", "https://test.json-schema.org/short-string#": "https://json-schema.org/evaluation/validate", diff --git a/bundle/snapshots/a6a61ea3cecf6acf4c700df42163592e b/bundle/snapshots/a6a61ea3cecf6acf4c700df42163592e index 776676bc..5b8cca74 100644 --- a/bundle/snapshots/a6a61ea3cecf6acf4c700df42163592e +++ b/bundle/snapshots/a6a61ea3cecf6acf4c700df42163592e @@ -1,9 +1,7 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/string#/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/string#": "https://json-schema.org/evaluation/validate", - "https://bundler.hyperjump.io/main#/if/$ref": "https://json-schema.org/keyword/ref", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": { diff --git a/bundle/snapshots/c0332fa29559fa9f027c2590e4178f98 b/bundle/snapshots/c0332fa29559fa9f027c2590e4178f98 index 37e3f413..9bfeabdc 100644 --- a/bundle/snapshots/c0332fa29559fa9f027c2590e4178f98 +++ b/bundle/snapshots/c0332fa29559fa9f027c2590e4178f98 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate", "https://test.json-schema.org/short-string#/maxLength": "https://json-schema.org/keyword/maxLength", "https://test.json-schema.org/short-string#": "https://json-schema.org/evaluation/validate", diff --git a/bundle/snapshots/c26ca442e0696b06b53a6c155ec67eb0 b/bundle/snapshots/c26ca442e0696b06b53a6c155ec67eb0 index 776676bc..5b8cca74 100644 --- a/bundle/snapshots/c26ca442e0696b06b53a6c155ec67eb0 +++ b/bundle/snapshots/c26ca442e0696b06b53a6c155ec67eb0 @@ -1,9 +1,7 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/string#/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/string#": "https://json-schema.org/evaluation/validate", - "https://bundler.hyperjump.io/main#/if/$ref": "https://json-schema.org/keyword/ref", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate" }, "annotations": { diff --git a/bundle/snapshots/e66fdfb1ce638e361cc818449c04d005 b/bundle/snapshots/e66fdfb1ce638e361cc818449c04d005 index 37e3f413..9bfeabdc 100644 --- a/bundle/snapshots/e66fdfb1ce638e361cc818449c04d005 +++ b/bundle/snapshots/e66fdfb1ce638e361cc818449c04d005 @@ -1,7 +1,6 @@ { "#": { "errors": { - "https://bundler.hyperjump.io/main#/if/type": "https://json-schema.org/keyword/type", "https://bundler.hyperjump.io/main#/if": "https://json-schema.org/evaluation/validate", "https://test.json-schema.org/short-string#/maxLength": "https://json-schema.org/keyword/maxLength", "https://test.json-schema.org/short-string#": "https://json-schema.org/evaluation/validate", diff --git a/lib/keywords/if.js b/lib/keywords/if.js index 1b7b6e05..3832bc7f 100644 --- a/lib/keywords/if.js +++ b/lib/keywords/if.js @@ -5,8 +5,8 @@ const id = "https://json-schema.org/keyword/if"; const compile = (schema, ast) => Validation.compile(schema, ast); -const interpret = (ifSchema, instance, ast, dynamicAnchors, quiet) => { - Validation.interpret(ifSchema, instance, ast, dynamicAnchors, quiet); +const interpret = (ifSchema, instance, ast, dynamicAnchors) => { + Validation.interpret(ifSchema, instance, ast, dynamicAnchors, true); return true; }; diff --git a/lib/keywords/validation.js b/lib/keywords/validation.js index 81f880da..6ac49510 100644 --- a/lib/keywords/validation.js +++ b/lib/keywords/validation.js @@ -62,9 +62,7 @@ const interpret = (url, instance, ast, dynamicAnchors, quiet = false) => { } if (!isSchemaValid) { - if (!quiet) { - instance.errors[url] = id; - } + instance.errors[url] = id; } instance.valid = isSchemaValid; diff --git a/lib/output.js b/lib/output.js index 36d9cce9..ea1b5b06 100644 --- a/lib/output.js +++ b/lib/output.js @@ -25,7 +25,7 @@ outputFormats.BASIC = (instance) => { for (const child of Instance.allNodes(instance)) { for (const [absoluteKeywordLocation, keyword] of Object.entries(child.errors).reverse()) { - if (!child.valid) { + if (keyword !== "https://json-schema.org/evaluation/validate" && !child.valid) { output.errors.unshift({ keyword, absoluteKeywordLocation, @@ -35,8 +35,6 @@ outputFormats.BASIC = (instance) => { } } } - - output.errors.pop(); } return output;