oas 18.4.1 → 18.4.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## <small>18.4.2 (2022-08-19)</small>
2
+
3
+ * fix: error handling in rare oas reducer cases ([9f9a798](https://github.com/readmeio/oas/commit/9f9a798))
4
+
5
+
6
+
1
7
  ## <small>18.4.1 (2022-08-19)</small>
2
8
 
3
9
  * fix: typing issue in the reducer ([332da95](https://github.com/readmeio/oas/commit/332da95))
@@ -24,6 +24,12 @@ function getUsedRefs(schema) {
24
24
  */
25
25
  function accumulateUsedRefs(schema, $refs, $ref) {
26
26
  var $refSchema = jsonpointer_1["default"].get(schema, $ref.substring(1));
27
+ if ($refSchema === undefined) {
28
+ // If the schema we have wasn't fully dereferenced or bundled for whatever reason and this
29
+ // `$ref` that we have doens't exist here we shouldn't try to search for more `$ref` pointers
30
+ // in a schema that doesn't exist.
31
+ return;
32
+ }
27
33
  getUsedRefs($refSchema).forEach(function (currRef) {
28
34
  // If we've already processed this $ref don't send us into an infinite loop.
29
35
  if ($refs.has(currRef)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oas",
3
- "version": "18.4.1",
3
+ "version": "18.4.2",
4
4
  "description": "Working with OpenAPI definitions is hard. This makes it easier.",
5
5
  "license": "MIT",
6
6
  "author": "ReadMe <support@readme.io> (https://readme.com)",
@@ -30,6 +30,13 @@ function getUsedRefs(schema: any) {
30
30
  */
31
31
  function accumulateUsedRefs(schema: Record<string, unknown>, $refs: Set<string>, $ref: string): void {
32
32
  const $refSchema = jsonPointer.get(schema, $ref.substring(1));
33
+ if ($refSchema === undefined) {
34
+ // If the schema we have wasn't fully dereferenced or bundled for whatever reason and this
35
+ // `$ref` that we have doens't exist here we shouldn't try to search for more `$ref` pointers
36
+ // in a schema that doesn't exist.
37
+ return;
38
+ }
39
+
33
40
  getUsedRefs($refSchema).forEach(currRef => {
34
41
  // If we've already processed this $ref don't send us into an infinite loop.
35
42
  if ($refs.has(currRef)) {