@kubb/adapter-oas 5.0.0-beta.12 → 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.cjs +6 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/resolvers.ts +6 -8
package/dist/index.cjs
CHANGED
|
@@ -986,21 +986,20 @@ function extractSchemaFromContent(content, preferredContentType) {
|
|
|
986
986
|
/**
|
|
987
987
|
* Walks a schema tree and collects the names of all `#/components/schemas/<name>` `$ref`s.
|
|
988
988
|
*/
|
|
989
|
-
function collectRefs(schema
|
|
989
|
+
function* collectRefs(schema) {
|
|
990
990
|
if (Array.isArray(schema)) {
|
|
991
|
-
for (const item of schema) collectRefs(item
|
|
992
|
-
return
|
|
991
|
+
for (const item of schema) yield* collectRefs(item);
|
|
992
|
+
return;
|
|
993
993
|
}
|
|
994
994
|
if (schema && typeof schema === "object") for (const key in schema) {
|
|
995
995
|
const value = schema[key];
|
|
996
996
|
if (key === "$ref" && typeof value === "string") {
|
|
997
997
|
if (value.startsWith("#/components/schemas/")) {
|
|
998
998
|
const name = value.slice(21);
|
|
999
|
-
if (name)
|
|
999
|
+
if (name) yield name;
|
|
1000
1000
|
}
|
|
1001
|
-
} else collectRefs(value
|
|
1001
|
+
} else yield* collectRefs(value);
|
|
1002
1002
|
}
|
|
1003
|
-
return refs;
|
|
1004
1003
|
}
|
|
1005
1004
|
/**
|
|
1006
1005
|
* Returns a copy of `schemas` topologically sorted by `$ref` dependency.
|
|
@@ -1016,7 +1015,7 @@ function collectRefs(schema, refs = /* @__PURE__ */ new Set()) {
|
|
|
1016
1015
|
*/
|
|
1017
1016
|
function sortSchemas(schemas) {
|
|
1018
1017
|
const deps = /* @__PURE__ */ new Map();
|
|
1019
|
-
for (const [name, schema] of Object.entries(schemas)) deps.set(name,
|
|
1018
|
+
for (const [name, schema] of Object.entries(schemas)) deps.set(name, [...new Set(collectRefs(schema))]);
|
|
1020
1019
|
const sorted = [];
|
|
1021
1020
|
const visited = /* @__PURE__ */ new Set();
|
|
1022
1021
|
function visit(name, stack) {
|