@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.cjs +28 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,7 @@ var compatibility = {
|
|
|
37
37
|
};
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region package.json
|
|
40
|
-
var version = "5.14.
|
|
40
|
+
var version = "5.14.6";
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/constants.ts
|
|
43
43
|
/**
|
|
@@ -715,6 +715,30 @@ function inlinePathRefs(node, resolve, visiting = []) {
|
|
|
715
715
|
for (const [key, value] of Object.entries(node)) node[key] = inlinePathRefs(value, resolve, visiting);
|
|
716
716
|
return node;
|
|
717
717
|
}
|
|
718
|
+
const namedEntryKeys = /* @__PURE__ */ new Set([
|
|
719
|
+
"properties",
|
|
720
|
+
"patternProperties",
|
|
721
|
+
"headers",
|
|
722
|
+
"schemas",
|
|
723
|
+
"responses",
|
|
724
|
+
"parameters",
|
|
725
|
+
"requestBodies",
|
|
726
|
+
"examples",
|
|
727
|
+
"links",
|
|
728
|
+
"callbacks",
|
|
729
|
+
"securitySchemes",
|
|
730
|
+
"securityDefinitions",
|
|
731
|
+
"pathItems",
|
|
732
|
+
"definitions",
|
|
733
|
+
"$defs"
|
|
734
|
+
]);
|
|
735
|
+
/**
|
|
736
|
+
* True when `path` runs through an `x-` vendor extension. Kubb never reads an extension, so a `$ref`
|
|
737
|
+
* Kubb cannot read inside one cannot change the output.
|
|
738
|
+
*/
|
|
739
|
+
function isExtensionPath(path) {
|
|
740
|
+
return path.some((token, index) => String(token).startsWith("x-") && !namedEntryKeys.has(String(path[index - 1])));
|
|
741
|
+
}
|
|
718
742
|
/**
|
|
719
743
|
* Bundles a multi-file OpenAPI document into a single document via `api-ref-bundler`.
|
|
720
744
|
*
|
|
@@ -730,7 +754,7 @@ function inlinePathRefs(node, resolve, visiting = []) {
|
|
|
730
754
|
*
|
|
731
755
|
* `document` stands in for the file at `pathOrUrl`, such as inline input. Every other file or URL
|
|
732
756
|
* read, including one that fails, lands in `sources`. A `$ref` that cannot be read reports
|
|
733
|
-
* `KUBB_REF_NOT_FOUND` at the key that holds it.
|
|
757
|
+
* `KUBB_REF_NOT_FOUND` at the key that holds it, as a warning when it sits inside an `x-` extension.
|
|
734
758
|
*
|
|
735
759
|
* @example Local file
|
|
736
760
|
* `const document = await bundleDocument('./openapi.yaml')`
|
|
@@ -757,7 +781,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
|
|
|
757
781
|
const pointer = toKey(state.baseFile) === toKey(pathOrUrl) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
|
|
758
782
|
const diagnostic = {
|
|
759
783
|
code: _kubb_kit.Diagnostics.code.refNotFound,
|
|
760
|
-
severity: "error",
|
|
784
|
+
severity: isExtensionPath(path) ? "warning" : "error",
|
|
761
785
|
message: `Could not bundle an external \`$ref\`. ${message}.`,
|
|
762
786
|
help: "Check that the file or URL the `$ref` points at exists and is readable, or fix the `$ref`.",
|
|
763
787
|
...pointer && { location: {
|
|
@@ -765,7 +789,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
|
|
|
765
789
|
pointer
|
|
766
790
|
} }
|
|
767
791
|
};
|
|
768
|
-
if (!_kubb_kit.Diagnostics.report(diagnostic)) throw new _kubb_kit.Diagnostics.Error(diagnostic);
|
|
792
|
+
if (!_kubb_kit.Diagnostics.report(diagnostic) && diagnostic.severity === "error") throw new _kubb_kit.Diagnostics.Error(diagnostic);
|
|
769
793
|
} } });
|
|
770
794
|
}
|
|
771
795
|
const inlineInputName = "<inline input>";
|