Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Pointer<S extends object = JSONSchema> {
// Crawl the object, one token at a time
this.value = unwrapOrThrow(obj);

const errors: MissingPointerError[] = [];

for (let i = 0; i < tokens.length; i++) {
if (resolveIf$Ref(this, options, pathFromRoot)) {
// The $ref path has changed, so append the remaining tokens to the path
Expand Down Expand Up @@ -120,12 +122,16 @@ class Pointer<S extends object = JSONSchema> {
}

this.value = null;
throw new MissingPointerError(token, decodeURI(this.originalPath));
errors.push(new MissingPointerError(token, decodeURI(this.originalPath)));
} else {
this.value = this.value[token];
}
}

if (errors.length > 0) {
throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple missing pointer errors");
}

// Resolve the final value
if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) {
resolveIf$Ref(this, options, pathFromRoot);
Expand Down