@kubb/oas 4.12.7 → 4.12.9

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
@@ -148,21 +149,21 @@ interface KubbEvents {
148
149
  */
149
150
  'hooks:end': [];
150
151
  /**
151
- * Emitted when a single hook execution starts.
152
- */
153
- 'hook:start': [command: string];
154
- /**
155
- * Emitted to execute a hook command (e.g., format or lint).
152
+ * Emitted when a single hook execution starts. (e.g., format or lint).
156
153
  * The callback should be invoked when the command completes.
157
154
  */
158
- 'hook:execute': [{
159
- command: string | URL;
155
+ 'hook:start': [{
156
+ id?: string;
157
+ command: string;
160
158
  args?: readonly string[];
161
- }, cb: () => void];
159
+ }];
162
160
  /**
163
161
  * Emitted when a single hook execution completes.
164
162
  */
165
- 'hook:end': [command: string];
163
+ 'hook:end': [{
164
+ id?: string;
165
+ command: string;
166
+ }];
166
167
  /**
167
168
  * Emitted when a new version of Kubb is available.
168
169
  */
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
@@ -148,21 +149,21 @@ interface KubbEvents {
148
149
  */
149
150
  'hooks:end': [];
150
151
  /**
151
- * Emitted when a single hook execution starts.
152
- */
153
- 'hook:start': [command: string];
154
- /**
155
- * Emitted to execute a hook command (e.g., format or lint).
152
+ * Emitted when a single hook execution starts. (e.g., format or lint).
156
153
  * The callback should be invoked when the command completes.
157
154
  */
158
- 'hook:execute': [{
159
- command: string | URL;
155
+ 'hook:start': [{
156
+ id?: string;
157
+ command: string;
160
158
  args?: readonly string[];
161
- }, cb: () => void];
159
+ }];
162
160
  /**
163
161
  * Emitted when a single hook execution completes.
164
162
  */
165
- 'hook:end': [command: string];
163
+ 'hook:end': [{
164
+ id?: string;
165
+ command: string;
166
+ }];
166
167
  /**
167
168
  * Emitted when a new version of Kubb is available.
168
169
  */
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