@kubb/adapter-oas 5.14.5 → 5.14.6

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/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var compatibility = {
21
21
  };
22
22
  //#endregion
23
23
  //#region package.json
24
- var version = "5.14.5";
24
+ var version = "5.14.6";
25
25
  //#endregion
26
26
  //#region src/constants.ts
27
27
  /**
@@ -699,6 +699,30 @@ function inlinePathRefs(node, resolve, visiting = []) {
699
699
  for (const [key, value] of Object.entries(node)) node[key] = inlinePathRefs(value, resolve, visiting);
700
700
  return node;
701
701
  }
702
+ const namedEntryKeys = /* @__PURE__ */ new Set([
703
+ "properties",
704
+ "patternProperties",
705
+ "headers",
706
+ "schemas",
707
+ "responses",
708
+ "parameters",
709
+ "requestBodies",
710
+ "examples",
711
+ "links",
712
+ "callbacks",
713
+ "securitySchemes",
714
+ "securityDefinitions",
715
+ "pathItems",
716
+ "definitions",
717
+ "$defs"
718
+ ]);
719
+ /**
720
+ * True when `path` runs through an `x-` vendor extension. Kubb never reads an extension, so a `$ref`
721
+ * Kubb cannot read inside one cannot change the output.
722
+ */
723
+ function isExtensionPath(path) {
724
+ return path.some((token, index) => String(token).startsWith("x-") && !namedEntryKeys.has(String(path[index - 1])));
725
+ }
702
726
  /**
703
727
  * Bundles a multi-file OpenAPI document into a single document via `api-ref-bundler`.
704
728
  *
@@ -714,7 +738,7 @@ function inlinePathRefs(node, resolve, visiting = []) {
714
738
  *
715
739
  * `document` stands in for the file at `pathOrUrl`, such as inline input. Every other file or URL
716
740
  * read, including one that fails, lands in `sources`. A `$ref` that cannot be read reports
717
- * `KUBB_REF_NOT_FOUND` at the key that holds it.
741
+ * `KUBB_REF_NOT_FOUND` at the key that holds it, as a warning when it sits inside an `x-` extension.
718
742
  *
719
743
  * @example Local file
720
744
  * `const document = await bundleDocument('./openapi.yaml')`
@@ -741,7 +765,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
741
765
  const pointer = toKey(state.baseFile) === toKey(pathOrUrl) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
742
766
  const diagnostic = {
743
767
  code: Diagnostics.code.refNotFound,
744
- severity: "error",
768
+ severity: isExtensionPath(path) ? "warning" : "error",
745
769
  message: `Could not bundle an external \`$ref\`. ${message}.`,
746
770
  help: "Check that the file or URL the `$ref` points at exists and is readable, or fix the `$ref`.",
747
771
  ...pointer && { location: {
@@ -749,7 +773,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
749
773
  pointer
750
774
  } }
751
775
  };
752
- if (!Diagnostics.report(diagnostic)) throw new Diagnostics.Error(diagnostic);
776
+ if (!Diagnostics.report(diagnostic) && diagnostic.severity === "error") throw new Diagnostics.Error(diagnostic);
753
777
  } } });
754
778
  }
755
779
  const inlineInputName = "<inline input>";