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

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) {