@kubb/oas 4.12.8 → 4.12.10

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.d.cts CHANGED
@@ -34,6 +34,7 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
34
34
  getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
35
35
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
36
36
  valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
37
+ flattenSchema(schema?: SchemaObject$1): SchemaObject$1 | undefined;
37
38
  }
38
39
  //#endregion
39
40
  //#region ../core/src/Kubb.d.ts
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
34
34
  getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
35
35
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
36
36
  valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
37
+ flattenSchema(schema?: SchemaObject$1): SchemaObject$1 | undefined;
37
38
  }
38
39
  //#endregion
39
40
  //#region ../core/src/Kubb.d.ts
package/dist/index.js CHANGED
@@ -4115,6 +4115,15 @@ var require_yaml = /* @__PURE__ */ __commonJSMin(((exports) => {
4115
4115
  //#endregion
4116
4116
  //#region src/utils.ts
4117
4117
  var import_yaml = /* @__PURE__ */ __toESM(require_yaml(), 1);
4118
+ const STRUCTURAL_KEYS = new Set([
4119
+ "properties",
4120
+ "items",
4121
+ "additionalProperties",
4122
+ "oneOf",
4123
+ "anyOf",
4124
+ "allOf",
4125
+ "not"
4126
+ ]);
4118
4127
  function isOpenApiV2Document(doc) {
4119
4128
  return doc && isPlainObject(doc) && !("openapi" in doc);
4120
4129
  }
@@ -4448,6 +4457,16 @@ var Oas = class extends BaseOas {
4448
4457
  colorizeErrors: true
4449
4458
  }).validate({ parser: { validate: { errors: { colorize: true } } } });
4450
4459
  }
4460
+ flattenSchema(schema) {
4461
+ if (!schema?.allOf || schema.allOf.length === 0) return schema;
4462
+ if (schema.allOf.some((item) => isReference(item))) return schema;
4463
+ const isPlainFragment = (item) => !Object.keys(item).some((key) => STRUCTURAL_KEYS.has(key));
4464
+ if (!schema.allOf.every((item) => isPlainFragment(item))) return schema;
4465
+ const merged = { ...schema };
4466
+ delete merged.allOf;
4467
+ for (const fragment of schema.allOf) for (const [key, value] of Object.entries(fragment)) if (merged[key] === void 0) merged[key] = value;
4468
+ return merged;
4469
+ }
4451
4470
  };
4452
4471
 
4453
4472
  //#endregion