@kubb/adapter-oas 5.0.0-beta.76 → 5.0.0-beta.77
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 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1014,8 +1014,8 @@ function flattenSchema(schema) {
|
|
|
1014
1014
|
const allOfFragments = schema.allOf;
|
|
1015
1015
|
if (allOfFragments.some((item) => isReference(item))) return schema;
|
|
1016
1016
|
if (allOfFragments.some(hasStructuralKeywords)) return schema;
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1017
|
+
const { allOf: _allOf, ...rest } = schema;
|
|
1018
|
+
const merged = rest;
|
|
1019
1019
|
for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) if (merged[key] === void 0) merged[key] = value;
|
|
1020
1020
|
return merged;
|
|
1021
1021
|
}
|
|
@@ -1141,7 +1141,7 @@ function getSchemas(document, { contentType }) {
|
|
|
1141
1141
|
let hasMultipleSources = false;
|
|
1142
1142
|
if (!isSingle) {
|
|
1143
1143
|
const firstSource = items[0].source;
|
|
1144
|
-
for (
|
|
1144
|
+
for (const item of items) if (item.source !== firstSource) {
|
|
1145
1145
|
hasMultipleSources = true;
|
|
1146
1146
|
break;
|
|
1147
1147
|
}
|
|
@@ -2133,7 +2133,6 @@ function collectInlineEnums(roots, topLevelNames) {
|
|
|
2133
2133
|
const isSchemaRoot = root.kind === "Schema";
|
|
2134
2134
|
for (const node of _kubb_core.ast.collect(root, { schema: (schemaNode) => schemaNode })) {
|
|
2135
2135
|
if (node.type !== "enum" || !node.name) continue;
|
|
2136
|
-
if ((node.namedEnumValues ?? node.enumValues ?? []).length === 1) continue;
|
|
2137
2136
|
if (isSchemaRoot && node === root) continue;
|
|
2138
2137
|
if (topLevelNames.has(node.name)) continue;
|
|
2139
2138
|
if (!promoted.has(node.name)) promoted.set(node.name, {
|
|
@@ -2283,9 +2282,7 @@ function preScan({ schemas, parseSchema, parseOperation, document, parserOptions
|
|
|
2283
2282
|
name
|
|
2284
2283
|
});
|
|
2285
2284
|
if (node.type === "ref" && node.name && node.name !== name) refAliasMap.set(name, node);
|
|
2286
|
-
|
|
2287
|
-
const isConstEnum = (enumNode?.namedEnumValues ?? enumNode?.enumValues ?? []).length === 1;
|
|
2288
|
-
if (enumNode && node.name && !isConstEnum) enumNames.push(node.name);
|
|
2285
|
+
if (_kubb_core.ast.narrowSchema(node, _kubb_core.ast.schemaTypes.enum) && node.name) enumNames.push(node.name);
|
|
2289
2286
|
if (discriminator === "propagate" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
|
|
2290
2287
|
}
|
|
2291
2288
|
const circularNames = [...(0, _kubb_ast_utils.findCircularSchemas)(allNodes)];
|
|
@@ -2519,8 +2516,7 @@ const adapterOas = (0, _kubb_core.createAdapter)((options) => {
|
|
|
2519
2516
|
return (0, _kubb_ast.collect)(node, { schema(schemaNode) {
|
|
2520
2517
|
const schemaRef = (0, _kubb_ast.narrowSchema)(schemaNode, "ref");
|
|
2521
2518
|
if (!schemaRef?.ref) return null;
|
|
2522
|
-
const
|
|
2523
|
-
const result = resolve(nameMapping.get(rawName) ?? rawName);
|
|
2519
|
+
const result = resolve(nameMapping.get(schemaRef.ref) ?? (0, _kubb_ast_utils.extractRefName)(schemaRef.ref));
|
|
2524
2520
|
if (!result) return null;
|
|
2525
2521
|
return _kubb_core.ast.factory.createImport({
|
|
2526
2522
|
name: [result.name],
|