@kubb/adapter-oas 5.0.0-beta.53 → 5.0.0-beta.54
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 +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/stream.ts +13 -3
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.54",
|
|
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",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"oas": "^32.1.18",
|
|
48
48
|
"oas-normalize": "^16.0.5",
|
|
49
49
|
"swagger2openapi": "^7.0.8",
|
|
50
|
-
"@kubb/ast": "5.0.0-beta.
|
|
51
|
-
"@kubb/core": "5.0.0-beta.
|
|
50
|
+
"@kubb/ast": "5.0.0-beta.54",
|
|
51
|
+
"@kubb/core": "5.0.0-beta.54"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/js-yaml": "^4.0.9",
|
package/src/stream.ts
CHANGED
|
@@ -172,7 +172,12 @@ export function preScan({
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
// Enum names that duplicate an earlier schema's content are never emitted, so they are not
|
|
176
|
+
// advertised to plugins either.
|
|
177
|
+
const aliasNames = dedupePlan?.aliasNames
|
|
178
|
+
const emittedEnumNames = aliasNames && aliasNames.size > 0 ? enumNames.filter((name) => !aliasNames.has(name)) : enumNames
|
|
179
|
+
|
|
180
|
+
return { refAliasMap, enumNames: emittedEnumNames, circularNames, discriminatorChildMap, dedupePlan }
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
/**
|
|
@@ -231,7 +236,7 @@ export function createInputStream({
|
|
|
231
236
|
})
|
|
232
237
|
}
|
|
233
238
|
|
|
234
|
-
return ast.applyDedupe(node, dedupePlan
|
|
239
|
+
return ast.applyDedupe(node, dedupePlan, true)
|
|
235
240
|
}
|
|
236
241
|
|
|
237
242
|
const schemasIterable: AsyncIterable<ast.SchemaNode> = {
|
|
@@ -243,6 +248,11 @@ export function createInputStream({
|
|
|
243
248
|
}
|
|
244
249
|
|
|
245
250
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
251
|
+
// A top-level schema whose content duplicates an earlier one is not emitted: every
|
|
252
|
+
// ref to it is repointed at the first schema with that content, so its model would
|
|
253
|
+
// be dead code.
|
|
254
|
+
if (dedupePlan?.aliasNames.has(name)) continue
|
|
255
|
+
|
|
246
256
|
// Inline ref aliases: replace the alias entry with its target's parsed node
|
|
247
257
|
// (keeping the alias name). Skip the first parse entirely for alias entries
|
|
248
258
|
// since that result is never used.
|
|
@@ -267,7 +277,7 @@ export function createInputStream({
|
|
|
267
277
|
for (const operation of Object.values(methods)) {
|
|
268
278
|
if (!operation) continue
|
|
269
279
|
const node = parseOperation(parserOptions, operation)
|
|
270
|
-
if (node) yield dedupePlan ? ast.applyDedupe(node, dedupePlan
|
|
280
|
+
if (node) yield dedupePlan ? ast.applyDedupe(node, dedupePlan) : node
|
|
271
281
|
}
|
|
272
282
|
}
|
|
273
283
|
})()
|