@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.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/adapter-oas",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.14",
|
|
4
4
|
"description": "OpenAPI and Swagger adapter for Kubb. Parses and validates OAS 2.0/3.x specifications into a @kubb/ast RootNode for downstream code generation plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"registry": "https://registry.npmjs.org/"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@redocly/openapi-core": "^2.30.
|
|
46
|
+
"@redocly/openapi-core": "^2.30.5",
|
|
47
47
|
"oas": "^32.1.18",
|
|
48
48
|
"oas-normalize": "^16.0.4",
|
|
49
49
|
"swagger2openapi": "^7.0.8",
|
|
50
|
-
"@kubb/core": "5.0.0-beta.
|
|
50
|
+
"@kubb/core": "5.0.0-beta.14"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/swagger2openapi": "^7.0.4",
|
package/src/resolvers.ts
CHANGED
|
@@ -305,10 +305,10 @@ export function extractSchemaFromContent(content: Record<string, unknown> | unde
|
|
|
305
305
|
/**
|
|
306
306
|
* Walks a schema tree and collects the names of all `#/components/schemas/<name>` `$ref`s.
|
|
307
307
|
*/
|
|
308
|
-
function collectRefs(schema: unknown
|
|
308
|
+
function* collectRefs(schema: unknown): Generator<string, void, undefined> {
|
|
309
309
|
if (Array.isArray(schema)) {
|
|
310
|
-
for (const item of schema) collectRefs(item
|
|
311
|
-
return
|
|
310
|
+
for (const item of schema) yield* collectRefs(item)
|
|
311
|
+
return
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
if (schema && typeof schema === 'object') {
|
|
@@ -317,15 +317,13 @@ function collectRefs(schema: unknown, refs = new Set<string>()): Set<string> {
|
|
|
317
317
|
if (key === '$ref' && typeof value === 'string') {
|
|
318
318
|
if (value.startsWith(SCHEMA_REF_PREFIX)) {
|
|
319
319
|
const name = value.slice(SCHEMA_REF_PREFIX.length)
|
|
320
|
-
if (name)
|
|
320
|
+
if (name) yield name
|
|
321
321
|
}
|
|
322
322
|
} else {
|
|
323
|
-
collectRefs(value
|
|
323
|
+
yield* collectRefs(value)
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
|
|
328
|
-
return refs
|
|
329
327
|
}
|
|
330
328
|
|
|
331
329
|
/**
|
|
@@ -344,7 +342,7 @@ export function sortSchemas(schemas: Record<string, SchemaObject>): Record<strin
|
|
|
344
342
|
const deps = new Map<string, string[]>()
|
|
345
343
|
|
|
346
344
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
347
|
-
deps.set(name,
|
|
345
|
+
deps.set(name, [...new Set(collectRefs(schema))])
|
|
348
346
|
}
|
|
349
347
|
|
|
350
348
|
const sorted: string[] = []
|