@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.js CHANGED
@@ -660,11 +660,10 @@ async function parseDocument(pathOrApi, { canBundle = true, enablePaths = true }
660
660
  * ```
661
661
  */
662
662
  async function mergeDocuments(pathOrApi) {
663
- const documents = [];
664
- for (const p of pathOrApi) documents.push(await parseDocument(p, {
663
+ const documents = await Promise.all(pathOrApi.map((p) => parseDocument(p, {
665
664
  enablePaths: false,
666
665
  canBundle: false
667
- }));
666
+ })));
668
667
  if (documents.length === 0) throw new Error("No OAS documents provided for merging.");
669
668
  const seed = {
670
669
  openapi: MERGE_OPENAPI_VERSION,
@@ -720,6 +719,7 @@ async function validateDocument(document, { throwOnError = false } = {}) {
720
719
  }
721
720
  //#endregion
722
721
  //#region src/refs.ts
722
+ const _refCache = /* @__PURE__ */ new WeakMap();
723
723
  /**
724
724
  * Resolves a local JSON pointer reference from a document.
725
725
  *
@@ -737,8 +737,15 @@ function resolveRef(document, $ref) {
737
737
  if ($ref === "") return null;
738
738
  if ($ref.startsWith("#")) $ref = globalThis.decodeURIComponent($ref.substring(1));
739
739
  else return null;
740
+ let docCache = _refCache.get(document);
741
+ if (!docCache) {
742
+ docCache = /* @__PURE__ */ new Map();
743
+ _refCache.set(document, docCache);
744
+ }
745
+ if (docCache.has($ref)) return docCache.get($ref);
740
746
  const current = $ref.split("/").filter(Boolean).reduce((obj, key) => obj?.[key], document);
741
747
  if (!current) throw new Error(`Could not find a definition for ${origRef}.`);
748
+ docCache.set($ref, current);
742
749
  return current;
743
750
  }
744
751
  /**