@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.js CHANGED
@@ -991,8 +991,8 @@ function flattenSchema(schema) {
991
991
  const allOfFragments = schema.allOf;
992
992
  if (allOfFragments.some((item) => isReference(item))) return schema;
993
993
  if (allOfFragments.some(hasStructuralKeywords)) return schema;
994
- const merged = { ...schema };
995
- delete merged.allOf;
994
+ const { allOf: _allOf, ...rest } = schema;
995
+ const merged = rest;
996
996
  for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) if (merged[key] === void 0) merged[key] = value;
997
997
  return merged;
998
998
  }
@@ -1118,7 +1118,7 @@ function getSchemas(document, { contentType }) {
1118
1118
  let hasMultipleSources = false;
1119
1119
  if (!isSingle) {
1120
1120
  const firstSource = items[0].source;
1121
- for (let i = 1; i < items.length; i++) if (items[i].source !== firstSource) {
1121
+ for (const item of items) if (item.source !== firstSource) {
1122
1122
  hasMultipleSources = true;
1123
1123
  break;
1124
1124
  }
@@ -2110,7 +2110,6 @@ function collectInlineEnums(roots, topLevelNames) {
2110
2110
  const isSchemaRoot = root.kind === "Schema";
2111
2111
  for (const node of ast.collect(root, { schema: (schemaNode) => schemaNode })) {
2112
2112
  if (node.type !== "enum" || !node.name) continue;
2113
- if ((node.namedEnumValues ?? node.enumValues ?? []).length === 1) continue;
2114
2113
  if (isSchemaRoot && node === root) continue;
2115
2114
  if (topLevelNames.has(node.name)) continue;
2116
2115
  if (!promoted.has(node.name)) promoted.set(node.name, {
@@ -2260,9 +2259,7 @@ function preScan({ schemas, parseSchema, parseOperation, document, parserOptions
2260
2259
  name
2261
2260
  });
2262
2261
  if (node.type === "ref" && node.name && node.name !== name) refAliasMap.set(name, node);
2263
- const enumNode = ast.narrowSchema(node, ast.schemaTypes.enum);
2264
- const isConstEnum = (enumNode?.namedEnumValues ?? enumNode?.enumValues ?? []).length === 1;
2265
- if (enumNode && node.name && !isConstEnum) enumNames.push(node.name);
2262
+ if (ast.narrowSchema(node, ast.schemaTypes.enum) && node.name) enumNames.push(node.name);
2266
2263
  if (discriminator === "propagate" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
2267
2264
  }
2268
2265
  const circularNames = [...findCircularSchemas(allNodes)];
@@ -2496,8 +2493,7 @@ const adapterOas = createAdapter((options) => {
2496
2493
  return collect(node, { schema(schemaNode) {
2497
2494
  const schemaRef = narrowSchema(schemaNode, "ref");
2498
2495
  if (!schemaRef?.ref) return null;
2499
- const rawName = extractRefName(schemaRef.ref);
2500
- const result = resolve(nameMapping.get(rawName) ?? rawName);
2496
+ const result = resolve(nameMapping.get(schemaRef.ref) ?? extractRefName(schemaRef.ref));
2501
2497
  if (!result) return null;
2502
2498
  return ast.factory.createImport({
2503
2499
  name: [result.name],