@kubb/adapter-oas 5.0.0-beta.7 → 5.0.0-beta.8
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 +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/factory.ts +1 -4
- package/src/refs.ts +15 -0
package/dist/index.cjs
CHANGED
|
@@ -686,11 +686,10 @@ async function parseDocument(pathOrApi, { canBundle = true, enablePaths = true }
|
|
|
686
686
|
* ```
|
|
687
687
|
*/
|
|
688
688
|
async function mergeDocuments(pathOrApi) {
|
|
689
|
-
const documents =
|
|
690
|
-
for (const p of pathOrApi) documents.push(await parseDocument(p, {
|
|
689
|
+
const documents = await Promise.all(pathOrApi.map((p) => parseDocument(p, {
|
|
691
690
|
enablePaths: false,
|
|
692
691
|
canBundle: false
|
|
693
|
-
}));
|
|
692
|
+
})));
|
|
694
693
|
if (documents.length === 0) throw new Error("No OAS documents provided for merging.");
|
|
695
694
|
const seed = {
|
|
696
695
|
openapi: MERGE_OPENAPI_VERSION,
|
|
@@ -746,6 +745,7 @@ async function validateDocument(document, { throwOnError = false } = {}) {
|
|
|
746
745
|
}
|
|
747
746
|
//#endregion
|
|
748
747
|
//#region src/refs.ts
|
|
748
|
+
const _refCache = /* @__PURE__ */ new WeakMap();
|
|
749
749
|
/**
|
|
750
750
|
* Resolves a local JSON pointer reference from a document.
|
|
751
751
|
*
|
|
@@ -763,8 +763,15 @@ function resolveRef(document, $ref) {
|
|
|
763
763
|
if ($ref === "") return null;
|
|
764
764
|
if ($ref.startsWith("#")) $ref = globalThis.decodeURIComponent($ref.substring(1));
|
|
765
765
|
else return null;
|
|
766
|
+
let docCache = _refCache.get(document);
|
|
767
|
+
if (!docCache) {
|
|
768
|
+
docCache = /* @__PURE__ */ new Map();
|
|
769
|
+
_refCache.set(document, docCache);
|
|
770
|
+
}
|
|
771
|
+
if (docCache.has($ref)) return docCache.get($ref);
|
|
766
772
|
const current = $ref.split("/").filter(Boolean).reduce((obj, key) => obj?.[key], document);
|
|
767
773
|
if (!current) throw new Error(`Could not find a definition for ${origRef}.`);
|
|
774
|
+
docCache.set($ref, current);
|
|
768
775
|
return current;
|
|
769
776
|
}
|
|
770
777
|
/**
|