@kubb/adapter-oas 5.0.0-beta.13 → 5.0.0-beta.15

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
@@ -960,21 +960,20 @@ function extractSchemaFromContent(content, preferredContentType) {
960
960
  /**
961
961
  * Walks a schema tree and collects the names of all `#/components/schemas/<name>` `$ref`s.
962
962
  */
963
- function collectRefs(schema, refs = /* @__PURE__ */ new Set()) {
963
+ function* collectRefs(schema) {
964
964
  if (Array.isArray(schema)) {
965
- for (const item of schema) collectRefs(item, refs);
966
- return refs;
965
+ for (const item of schema) yield* collectRefs(item);
966
+ return;
967
967
  }
968
968
  if (schema && typeof schema === "object") for (const key in schema) {
969
969
  const value = schema[key];
970
970
  if (key === "$ref" && typeof value === "string") {
971
971
  if (value.startsWith("#/components/schemas/")) {
972
972
  const name = value.slice(21);
973
- if (name) refs.add(name);
973
+ if (name) yield name;
974
974
  }
975
- } else collectRefs(value, refs);
975
+ } else yield* collectRefs(value);
976
976
  }
977
- return refs;
978
977
  }
979
978
  /**
980
979
  * Returns a copy of `schemas` topologically sorted by `$ref` dependency.
@@ -990,7 +989,7 @@ function collectRefs(schema, refs = /* @__PURE__ */ new Set()) {
990
989
  */
991
990
  function sortSchemas(schemas) {
992
991
  const deps = /* @__PURE__ */ new Map();
993
- for (const [name, schema] of Object.entries(schemas)) deps.set(name, Array.from(collectRefs(schema)));
992
+ for (const [name, schema] of Object.entries(schemas)) deps.set(name, [...new Set(collectRefs(schema))]);
994
993
  const sorted = [];
995
994
  const visited = /* @__PURE__ */ new Set();
996
995
  function visit(name, stack) {
@@ -1193,7 +1192,7 @@ function createSchemaParser(ctx) {
1193
1192
  * blowup — `customer` alone may be referenced from dozens of top-level schemas,
1194
1193
  * each triggering a fresh recursive expansion of its entire sub-tree.
1195
1194
  *
1196
- * Memoising by `$ref` path reduces the overall work from O(2^depth) to O(N)
1195
+ * Memoizing by `$ref` path reduces the overall work from O(2^depth) to O(N)
1197
1196
  * where N is the number of unique schema names.
1198
1197
  */
1199
1198
  const resolvedRefCache = /* @__PURE__ */ new Map();
@@ -1304,7 +1303,7 @@ function createSchemaParser(ctx) {
1304
1303
  }));
1305
1304
  return ast.createSchema({
1306
1305
  type: "intersection",
1307
- members: [...ast.mergeAdjacentObjects(allOfMembers.slice(0, syntheticStart)), ...ast.mergeAdjacentObjects(allOfMembers.slice(syntheticStart))],
1306
+ members: [...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))],
1308
1307
  ...buildSchemaNode(schema, name, nullable, defaultValue)
1309
1308
  });
1310
1309
  }
@@ -1882,7 +1881,7 @@ function parseOas(document, options = {}) {
1882
1881
  name
1883
1882
  }, mergedOptions));
1884
1883
  const paths = new BaseOas(document).getPaths();
1885
- const operations = Object.entries(paths).flatMap(([_path, methods]) => Object.entries(methods).map(([, operation]) => operation ? _parseOperation(mergedOptions, operation) : null).filter((op) => op !== null));
1884
+ const operations = Object.entries(paths).flatMap(([, methods]) => Object.entries(methods).map(([, operation]) => operation ? _parseOperation(mergedOptions, operation) : null).filter((op) => op !== null));
1886
1885
  return {
1887
1886
  root: ast.createInput({
1888
1887
  schemas,