@hey-api/json-schema-ref-parser 1.2.2 → 1.2.4

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.
@@ -85,6 +85,7 @@ class Pointer {
85
85
  const tokens = Pointer.parse(this.path, this.originalPath);
86
86
  // Crawl the object, one token at a time
87
87
  this.value = unwrapOrThrow(obj);
88
+ const errors = [];
88
89
  for (let i = 0; i < tokens.length; i++) {
89
90
  if (resolveIf$Ref(this, options, pathFromRoot)) {
90
91
  // The $ref path has changed, so append the remaining tokens to the path
@@ -110,12 +111,15 @@ class Pointer {
110
111
  continue;
111
112
  }
112
113
  this.value = null;
113
- throw new errors_js_1.MissingPointerError(token, decodeURI(this.originalPath));
114
+ errors.push(new errors_js_1.MissingPointerError(token, decodeURI(this.originalPath)));
114
115
  }
115
116
  else {
116
117
  this.value = this.value[token];
117
118
  }
118
119
  }
120
+ if (errors.length > 0) {
121
+ throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple missing pointer errors");
122
+ }
119
123
  // Resolve the final value
120
124
  if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) {
121
125
  resolveIf$Ref(this, options, pathFromRoot);
package/lib/pointer.ts CHANGED
@@ -92,6 +92,8 @@ class Pointer<S extends object = JSONSchema> {
92
92
  // Crawl the object, one token at a time
93
93
  this.value = unwrapOrThrow(obj);
94
94
 
95
+ const errors: MissingPointerError[] = [];
96
+
95
97
  for (let i = 0; i < tokens.length; i++) {
96
98
  if (resolveIf$Ref(this, options, pathFromRoot)) {
97
99
  // The $ref path has changed, so append the remaining tokens to the path
@@ -120,12 +122,16 @@ class Pointer<S extends object = JSONSchema> {
120
122
  }
121
123
 
122
124
  this.value = null;
123
- throw new MissingPointerError(token, decodeURI(this.originalPath));
125
+ errors.push(new MissingPointerError(token, decodeURI(this.originalPath)));
124
126
  } else {
125
127
  this.value = this.value[token];
126
128
  }
127
129
  }
128
130
 
131
+ if (errors.length > 0) {
132
+ throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple missing pointer errors");
133
+ }
134
+
129
135
  // Resolve the final value
130
136
  if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) {
131
137
  resolveIf$Ref(this, options, pathFromRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/json-schema-ref-parser",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5
5
  "homepage": "https://heyapi.dev/",
6
6
  "repository": {
@@ -83,7 +83,7 @@
83
83
  "@jsdevtools/ono": "^7.1.3",
84
84
  "@types/json-schema": "^7.0.15",
85
85
  "js-yaml": "^4.1.1",
86
- "lodash": "^4.17.21"
86
+ "lodash": "^4.17.23"
87
87
  },
88
88
  "release": {
89
89
  "branches": [