@kubb/plugin-zod 4.18.4 → 4.19.0

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.
@@ -20,16 +20,21 @@ type Operation$1 = Operation;
20
20
  type DiscriminatorObject$1 = DiscriminatorObject;
21
21
  //#endregion
22
22
  //#region ../oas/src/Oas.d.ts
23
- type Options$2 = {
23
+ type OasOptions = {
24
24
  contentType?: contentType;
25
25
  discriminator?: 'strict' | 'inherit';
26
+ /**
27
+ * Resolve name collisions when schemas from different components share the same name (case-insensitive).
28
+ * @default false
29
+ */
30
+ collisionDetection?: boolean;
26
31
  };
27
32
  declare class Oas extends BaseOas {
28
33
  #private;
29
34
  document: Document;
30
35
  constructor(document: Document);
31
- setOptions(options: Options$2): void;
32
- get options(): Options$2;
36
+ setOptions(options: OasOptions): void;
37
+ get options(): OasOptions;
33
38
  get<T = unknown>($ref: string): T | null;
34
39
  getKey($ref: string): string | undefined;
35
40
  set($ref: string, value: unknown): false | undefined;
@@ -38,8 +43,20 @@ declare class Oas extends BaseOas {
38
43
  getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
39
44
  getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
40
45
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
41
- valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
46
+ validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
42
47
  flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
48
+ /**
49
+ * Get schemas from OpenAPI components (schemas, responses, requestBodies).
50
+ * Returns schemas in dependency order along with name mapping for collision resolution.
51
+ */
52
+ getSchemas(options?: {
53
+ contentType?: contentType;
54
+ includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
55
+ collisionDetection?: boolean;
56
+ }): {
57
+ schemas: Record<string, SchemaObject$1>;
58
+ nameMapping: Map<string, string>;
59
+ };
43
60
  }
44
61
  //#endregion
45
62
  //#region ../core/src/BaseGenerator.d.ts
@@ -340,7 +357,7 @@ type Config<TInput = Input> = {
340
357
  input: TInput;
341
358
  output: {
342
359
  /**
343
- * The path where all generated files will be exported.
360
+ * The path where all generated files receives exported.
344
361
  * This can be an absolute path or a path relative to the specified root option.
345
362
  */
346
363
  path: string;
@@ -355,41 +372,39 @@ type Config<TInput = Input> = {
355
372
  write?: boolean;
356
373
  /**
357
374
  * Specifies the formatting tool to be used.
358
- * @default prettier
359
- *
360
- * Possible values:
361
- * - 'auto': Automatically detects and uses biome or prettier (in that order of preference).
362
- * - 'prettier': Uses Prettier for code formatting.
363
- * - 'biome': Uses Biome for code formatting.
364
- *
375
+ * - 'auto' automatically detects and uses biome or prettier (in that order of preference).
376
+ * - 'prettier' uses Prettier for code formatting.
377
+ * - 'biome' uses Biome for code formatting.
378
+ * - 'oxfmt' uses Oxfmt for code formatting.
379
+ * - false disables code formatting.
380
+ * @default 'prettier'
365
381
  */
366
382
  format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
367
383
  /**
368
384
  * Specifies the linter that should be used to analyze the code.
369
- * The accepted values indicate different linting tools.
370
- *
371
- * Possible values:
372
- * - 'auto': Automatically detects and uses biome, oxlint, or eslint (in that order of preference).
373
- * - 'eslint': Represents the use of ESLint, a widely used JavaScript linter.
374
- * - 'biome': Represents the Biome linter, a modern tool for code scanning.
375
- * - 'oxlint': Represents the Oxlint tool for linting purposes.
376
- *
385
+ * - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
386
+ * - 'eslint' uses ESLint for linting.
387
+ * - 'biome' uses Biome for linting.
388
+ * - 'oxlint' uses Oxlint for linting.
389
+ * - false disables linting.
390
+ * @default 'auto'
377
391
  */
378
392
  lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
379
393
  /**
380
- * Override the extension to the generated imports and exports, by default each plugin will add an extension
394
+ * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
381
395
  * @default { '.ts': '.ts'}
382
396
  */
383
397
  extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
384
398
  /**
385
- * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
399
+ * Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
386
400
  * @default 'named'
387
401
  */
388
402
  barrelType?: Exclude<BarrelType, 'propagate'> | false;
389
403
  /**
390
- * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
391
- * - 'simple': will only add banner with link to Kubb
392
- * - 'full': will add source, title, description and the OpenAPI version used
404
+ * Adds a default banner to the start of every generated file indicating it was generated by Kubb.
405
+ * - 'simple' adds banner with link to Kubb.
406
+ * - 'full' adds source, title, description, and OpenAPI version.
407
+ * - false disables banner generation.
393
408
  * @default 'simple'
394
409
  */
395
410
  defaultBanner?: 'simple' | 'full' | false;
@@ -402,17 +417,17 @@ type Config<TInput = Input> = {
402
417
  override?: boolean;
403
418
  };
404
419
  /**
405
- * An array of Kubb plugins that will be used in the generation.
420
+ * An array of Kubb plugins that used in the generation.
406
421
  * Each plugin may include additional configurable options(defined in the plugin itself).
407
- * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
422
+ * If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
408
423
  */
409
424
  plugins?: Array<Plugin>;
410
425
  /**
411
- * Hooks that will be called when a specific action is triggered in Kubb.
426
+ * Hooks triggered when a specific action occurs in Kubb.
412
427
  */
413
428
  hooks?: {
414
429
  /**
415
- * Hook that will be triggered at the end of all executions.
430
+ * Hook that triggers at the end of all executions.
416
431
  * Useful for running Prettier or ESLint to format/lint your code.
417
432
  */
418
433
  done?: string | Array<string>;
@@ -441,7 +456,7 @@ TContext = any,
441
456
  TResolvePathOptions extends object = object> = {
442
457
  name: TName;
443
458
  /**
444
- * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
459
+ * Same behavior like what has been done with `QueryKey` in `@tanstack/react-query`
445
460
  */
446
461
  key: PluginKey<TName | string>;
447
462
  options: TOptions;
@@ -462,12 +477,12 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
462
477
  */
463
478
  options: TOptions['resolvedOptions'];
464
479
  /**
465
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
480
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
466
481
  * Can be used to validate dependent plugins.
467
482
  */
468
483
  pre?: Array<string>;
469
484
  /**
470
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
485
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
471
486
  */
472
487
  post?: Array<string>;
473
488
  inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
@@ -485,12 +500,12 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
485
500
  */
486
501
  key: TOptions['key'];
487
502
  /**
488
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
503
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
489
504
  * Can be used to validate dependent plugins.
490
505
  */
491
506
  pre?: Array<string>;
492
507
  /**
493
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
508
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
494
509
  */
495
510
  post?: Array<string>;
496
511
  /**
@@ -540,10 +555,12 @@ type ResolveNameParams = {
540
555
  name: string;
541
556
  pluginKey?: Plugin['key'];
542
557
  /**
543
- * `file` will be used to customize the name of the created file(use of camelCase)
544
- * `function` can be used to customize the exported functions(use of camelCase)
545
- * `type` is a special type for TypeScript(use of PascalCase)
546
- * `const` can be used for variables(use of camelCase)
558
+ * Specifies the type of entity being named.
559
+ * - 'file' customizes the name of the created file (uses camelCase).
560
+ * - 'function' customizes the exported function names (uses camelCase).
561
+ * - 'type' customizes TypeScript types (uses PascalCase).
562
+ * - 'const' customizes variable names (uses camelCase).
563
+ * @default undefined
547
564
  */
548
565
  type?: 'file' | 'function' | 'type' | 'const';
549
566
  };
@@ -598,11 +615,14 @@ type GroupContext = {
598
615
  };
599
616
  type Group = {
600
617
  /**
601
- * Define a type where to group the files on
618
+ * Defines the type where to group the files.
619
+ * - 'tag' groups files by OpenAPI tags.
620
+ * - 'path' groups files by OpenAPI paths.
621
+ * @default undefined
602
622
  */
603
623
  type: 'tag' | 'path';
604
624
  /**
605
- * Return the name of a group based on the group name, this will be used for the file and name generation
625
+ * Return the name of a group based on the group name, this used for the file and name generation
606
626
  */
607
627
  name?: (context: GroupContext) => string;
608
628
  };
@@ -674,7 +694,7 @@ declare class PluginManager {
674
694
  parameters: PluginParameter<H>;
675
695
  }): Array<ReturnType<ParseResult<H>>> | null;
676
696
  /**
677
- * First non-null result stops and will return it's value.
697
+ * Returns the first non-null result.
678
698
  */
679
699
  hookFirst<H extends PluginLifecycleHooks>({
680
700
  hookName,
@@ -686,7 +706,7 @@ declare class PluginManager {
686
706
  skipped?: ReadonlySet<Plugin> | null;
687
707
  }): Promise<SafeParseResult<H>>;
688
708
  /**
689
- * First non-null result stops and will return it's value.
709
+ * Returns the first non-null result.
690
710
  */
691
711
  hookFirstSync<H extends PluginLifecycleHooks>({
692
712
  hookName,
@@ -698,15 +718,15 @@ declare class PluginManager {
698
718
  skipped?: ReadonlySet<Plugin> | null;
699
719
  }): SafeParseResult<H>;
700
720
  /**
701
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
721
+ * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
702
722
  */
703
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
723
+ hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
704
724
  hookName,
705
725
  parameters
706
726
  }: {
707
727
  hookName: H;
708
728
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
709
- }): Promise<Awaited<TOuput>[]>;
729
+ }): Promise<Awaited<TOutput>[]>;
710
730
  /**
711
731
  * Chains plugins
712
732
  */
@@ -842,8 +862,8 @@ type SchemaKeywordMapper = {
842
862
  */
843
863
  path: KubbFile.Path;
844
864
  /**
845
- * When true `File.Import` will be used.
846
- * When false a reference will be used inside the current file.
865
+ * When true `File.Import` is used.
866
+ * When false a reference is used inside the current file.
847
867
  */
848
868
  isImportable: boolean;
849
869
  };
@@ -1075,7 +1095,7 @@ type SchemaGeneratorOptions = {
1075
1095
  */
1076
1096
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1077
1097
  /**
1078
- * Receive schema and name(propertName) and return FakerMeta array
1098
+ * Receive schema and name(propertyName) and return FakerMeta array
1079
1099
  * TODO TODO add docs
1080
1100
  * @beta
1081
1101
  */
@@ -1186,7 +1206,7 @@ type Options = {
1186
1206
  output?: Output<Oas>;
1187
1207
  /**
1188
1208
  * Define which contentType should be used.
1189
- * By default, the first JSON valid mediaType will be used
1209
+ * By default, the first JSON valid mediaType is used
1190
1210
  */
1191
1211
  contentType?: contentType;
1192
1212
  /**
@@ -1207,25 +1227,36 @@ type Options = {
1207
1227
  override?: Array<Override<ResolvedOptions>>;
1208
1228
  /**
1209
1229
  * Path to Zod
1210
- * It will be used as `import { z } from '${importPath}'`.
1211
- * It allows both relative and absolute path.
1212
- * the path will be applied as is, so relative path should be based on the file being generated.
1230
+ * It used as `import { z } from '${importPath}'`.
1231
+ * Accepts relative and absolute paths.
1232
+ * Path is used as-is; relative paths are based on the generated file location.
1213
1233
  * @default 'zod'
1214
1234
  */
1215
1235
  importPath?: string;
1216
1236
  /**
1217
- * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
1218
- * False will fallback on a simple z.string() format
1219
- * @default 'string' 'stringOffset' will become the default in Kubb v3
1237
+ * Choose to use date or datetime as JavaScript Date instead of string.
1238
+ * - false falls back to a simple z.string() format.
1239
+ * - 'string' uses z.string().datetime() for datetime validation.
1240
+ * - 'stringOffset' uses z.string().datetime({ offset: true }) for datetime with timezone offset validation.
1241
+ * - 'stringLocal' uses z.string().datetime({ local: true }) for local datetime validation.
1242
+ * - 'date' uses z.date() for JavaScript Date objects.
1243
+ * @default 'string'
1244
+ * @note 'stringOffset' will become the default in Kubb v3.
1220
1245
  */
1221
1246
  dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
1222
1247
  /**
1223
- * Which type to use when the Swagger/OpenAPI file is not providing more information
1248
+ * Which type to use when the Swagger/OpenAPI file is not providing more information.
1249
+ * - 'any' allows any value.
1250
+ * - 'unknown' requires type narrowing before use.
1251
+ * - 'void' represents no value.
1224
1252
  * @default 'any'
1225
1253
  */
1226
1254
  unknownType?: 'any' | 'unknown' | 'void';
1227
1255
  /**
1228
- * Which type to use for empty schema values
1256
+ * Which type to use for empty schema values.
1257
+ * - 'any' allows any value.
1258
+ * - 'unknown' requires type narrowing before use.
1259
+ * - 'void' represents no value.
1229
1260
  * @default `unknownType`
1230
1261
  */
1231
1262
  emptySchemaType?: 'any' | 'unknown' | 'void';
@@ -1254,7 +1285,7 @@ type Options = {
1254
1285
  */
1255
1286
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1256
1287
  /**
1257
- * Receive schema and baseName(propertName) and return FakerMeta array
1288
+ * Receive schema and baseName(propertyName) and return FakerMeta array
1258
1289
  * TODO TODO add docs
1259
1290
  * @beta
1260
1291
  */
@@ -1265,14 +1296,16 @@ type Options = {
1265
1296
  }, defaultSchemas: Schema[]) => Schema[] | undefined;
1266
1297
  };
1267
1298
  /**
1268
- * Which version of Zod should be used
1269
- * @default '3
1299
+ * Which version of Zod should be used.
1300
+ * - '3' uses Zod v3.x syntax and features.
1301
+ * - '4' uses Zod v4.x syntax and features.
1302
+ * @default '3'
1270
1303
  */
1271
1304
  version?: '3' | '4';
1272
1305
  /**
1273
1306
  * Use Zod Mini's functional API for better tree-shaking support.
1274
1307
  * When enabled, generates functional syntax (e.g., `z.optional(z.string())`) instead of chainable methods (e.g., `z.string().optional()`).
1275
- * Requires Zod v4 or later. When `mini: true`, `version` will be set to '4' and `importPath` will default to 'zod/mini'.
1308
+ * Requires Zod v4 or later. When `mini: true`, `version` is set to '4' and `importPath` will default to 'zod/mini'.
1276
1309
  * @default false
1277
1310
  */
1278
1311
  mini?: boolean;
@@ -1313,4 +1346,4 @@ type ResolvedOptions = {
1313
1346
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
1314
1347
  //#endregion
1315
1348
  export { UserPluginWithLifeCycle as a, __name as c, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
1316
- //# sourceMappingURL=types-B5e4IaUY.d.cts.map
1349
+ //# sourceMappingURL=types-DOEZUvN2.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "4.18.4",
3
+ "version": "4.19.0",
4
4
  "description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
5
5
  "keywords": [
6
6
  "zod",
@@ -69,10 +69,10 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "@kubb/react-fabric": "0.12.4",
72
- "@kubb/core": "4.18.4",
73
- "@kubb/oas": "4.18.4",
74
- "@kubb/plugin-oas": "4.18.4",
75
- "@kubb/plugin-ts": "4.18.4"
72
+ "@kubb/core": "4.19.0",
73
+ "@kubb/oas": "4.19.0",
74
+ "@kubb/plugin-oas": "4.19.0",
75
+ "@kubb/plugin-ts": "4.19.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@asteasolutions/zod-to-openapi": "^8.4.0",
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import { z } from 'zod'
6
+
7
+ /**
8
+ * @description Success
9
+ */
10
+ export const createItem200 = z.lazy(() => item)
11
+
12
+ /**
13
+ * @description Item to create
14
+ */
15
+ export const createItemMutationRequest = z.union([
16
+ z
17
+ .lazy(() => itemTypeA)
18
+ .and(
19
+ z.object({
20
+ name: z.string(),
21
+ type: z.literal('typeA'),
22
+ }),
23
+ ),
24
+ z
25
+ .lazy(() => itemTypeB)
26
+ .and(
27
+ z.object({
28
+ name: z.string(),
29
+ type: z.literal('typeB'),
30
+ }),
31
+ ),
32
+ ])
33
+
34
+ export const createItemMutationResponse = z.lazy(() => createItem200)
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import { z } from '@hono/zod-openapi'
6
+
7
+ /**
8
+ * @description Success
9
+ */
10
+ export const createItem200 = z.lazy(() => item)
11
+
12
+ /**
13
+ * @description Item to create
14
+ */
15
+ export const createItemMutationRequest = z.union([
16
+ z
17
+ .lazy(() => itemTypeA)
18
+ .and(
19
+ z.object({
20
+ name: z.string(),
21
+ type: z.literal('typeA'),
22
+ }),
23
+ ),
24
+ z
25
+ .lazy(() => itemTypeB)
26
+ .and(
27
+ z.object({
28
+ name: z.string(),
29
+ type: z.literal('typeB'),
30
+ }),
31
+ ),
32
+ ])
33
+
34
+ export const createItemMutationResponse = z.lazy(() => createItem200)
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import { z } from 'zod'
6
+
7
+ export const item = z.union([
8
+ z
9
+ .lazy(() => itemTypeA)
10
+ .and(
11
+ z.object({
12
+ id: z.optional(z.number().int()),
13
+ type: z.literal('typeA'),
14
+ name: z.string(),
15
+ createdAt: z.optional(z.date()),
16
+ }),
17
+ ),
18
+ z
19
+ .lazy(() => itemTypeB)
20
+ .and(
21
+ z.object({
22
+ id: z.optional(z.number().int()),
23
+ type: z.literal('typeB'),
24
+ name: z.string(),
25
+ createdAt: z.optional(z.date()),
26
+ }),
27
+ ),
28
+ ])
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import { z } from 'zod'
6
+
7
+ /**
8
+ * @description Success
9
+ */
10
+ export const updateItem200 = z.lazy(() => item)
11
+
12
+ /**
13
+ * @description Item to update
14
+ */
15
+ export const updateItemMutationRequest = z.union([
16
+ z
17
+ .lazy(() => itemTypeA)
18
+ .and(
19
+ z.object({
20
+ name: z.string(),
21
+ type: z.literal('typeA'),
22
+ }),
23
+ ),
24
+ z
25
+ .lazy(() => itemTypeB)
26
+ .and(
27
+ z.object({
28
+ name: z.string(),
29
+ type: z.literal('typeB'),
30
+ }),
31
+ ),
32
+ ])
33
+
34
+ export const updateItemMutationResponse = z.lazy(() => updateItem200)
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import { z } from '@hono/zod-openapi'
6
+
7
+ /**
8
+ * @description Success
9
+ */
10
+ export const updateItem200 = z.lazy(() => item)
11
+
12
+ /**
13
+ * @description Item to update
14
+ */
15
+ export const updateItemMutationRequest = z.union([
16
+ z
17
+ .lazy(() => itemTypeA)
18
+ .and(
19
+ z.object({
20
+ name: z.string(),
21
+ type: z.literal('typeA'),
22
+ }),
23
+ ),
24
+ z
25
+ .lazy(() => itemTypeB)
26
+ .and(
27
+ z.object({
28
+ name: z.string(),
29
+ type: z.literal('typeB'),
30
+ }),
31
+ ),
32
+ ])
33
+
34
+ export const updateItemMutationResponse = z.lazy(() => updateItem200)
@@ -40,7 +40,27 @@ export const zodGenerator = createReactGenerator<PluginZod>({
40
40
  .flat()
41
41
  .filter(Boolean)
42
42
 
43
- const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {
43
+ const mapOperationSchema = ({ name, schema: schemaOriginal, description, keysToOmit: keysToOmitOriginal, ...options }: OperationSchemaType) => {
44
+ let schemaObject = schemaOriginal
45
+ let keysToOmit = keysToOmitOriginal
46
+
47
+ if ((schemaOriginal.anyOf || schemaOriginal.oneOf) && keysToOmitOriginal && keysToOmitOriginal.length > 0) {
48
+ schemaObject = structuredClone(schemaOriginal)
49
+
50
+ // Remove $ref so the schema parser generates inline schema instead of a reference
51
+ delete schemaObject.$ref
52
+
53
+ for (const key of keysToOmitOriginal) {
54
+ delete schemaObject.properties?.[key]
55
+ }
56
+
57
+ if (Array.isArray(schemaObject.required)) {
58
+ schemaObject.required = schemaObject.required.filter((key) => !keysToOmitOriginal.includes(key))
59
+ }
60
+
61
+ keysToOmit = undefined
62
+ }
63
+
44
64
  const hasProperties = Object.keys(schemaObject || {}).length > 0
45
65
  const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, 'default'))
46
66
 
package/src/types.ts CHANGED
@@ -10,7 +10,7 @@ export type Options = {
10
10
  output?: Output<Oas>
11
11
  /**
12
12
  * Define which contentType should be used.
13
- * By default, the first JSON valid mediaType will be used
13
+ * By default, the first JSON valid mediaType is used
14
14
  */
15
15
  contentType?: contentType
16
16
  /**
@@ -31,26 +31,37 @@ export type Options = {
31
31
  override?: Array<Override<ResolvedOptions>>
32
32
  /**
33
33
  * Path to Zod
34
- * It will be used as `import { z } from '${importPath}'`.
35
- * It allows both relative and absolute path.
36
- * the path will be applied as is, so relative path should be based on the file being generated.
34
+ * It used as `import { z } from '${importPath}'`.
35
+ * Accepts relative and absolute paths.
36
+ * Path is used as-is; relative paths are based on the generated file location.
37
37
  * @default 'zod'
38
38
  */
39
39
  importPath?: string
40
40
 
41
41
  /**
42
- * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
43
- * False will fallback on a simple z.string() format
44
- * @default 'string' 'stringOffset' will become the default in Kubb v3
42
+ * Choose to use date or datetime as JavaScript Date instead of string.
43
+ * - false falls back to a simple z.string() format.
44
+ * - 'string' uses z.string().datetime() for datetime validation.
45
+ * - 'stringOffset' uses z.string().datetime({ offset: true }) for datetime with timezone offset validation.
46
+ * - 'stringLocal' uses z.string().datetime({ local: true }) for local datetime validation.
47
+ * - 'date' uses z.date() for JavaScript Date objects.
48
+ * @default 'string'
49
+ * @note 'stringOffset' will become the default in Kubb v3.
45
50
  */
46
51
  dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date'
47
52
  /**
48
- * Which type to use when the Swagger/OpenAPI file is not providing more information
53
+ * Which type to use when the Swagger/OpenAPI file is not providing more information.
54
+ * - 'any' allows any value.
55
+ * - 'unknown' requires type narrowing before use.
56
+ * - 'void' represents no value.
49
57
  * @default 'any'
50
58
  */
51
59
  unknownType?: 'any' | 'unknown' | 'void'
52
60
  /**
53
- * Which type to use for empty schema values
61
+ * Which type to use for empty schema values.
62
+ * - 'any' allows any value.
63
+ * - 'unknown' requires type narrowing before use.
64
+ * - 'void' represents no value.
54
65
  * @default `unknownType`
55
66
  */
56
67
  emptySchemaType?: 'any' | 'unknown' | 'void'
@@ -81,7 +92,7 @@ export type Options = {
81
92
  */
82
93
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
83
94
  /**
84
- * Receive schema and baseName(propertName) and return FakerMeta array
95
+ * Receive schema and baseName(propertyName) and return FakerMeta array
85
96
  * TODO TODO add docs
86
97
  * @beta
87
98
  */
@@ -95,14 +106,16 @@ export type Options = {
95
106
  ) => Schema[] | undefined
96
107
  }
97
108
  /**
98
- * Which version of Zod should be used
99
- * @default '3
109
+ * Which version of Zod should be used.
110
+ * - '3' uses Zod v3.x syntax and features.
111
+ * - '4' uses Zod v4.x syntax and features.
112
+ * @default '3'
100
113
  */
101
114
  version?: '3' | '4'
102
115
  /**
103
116
  * Use Zod Mini's functional API for better tree-shaking support.
104
117
  * When enabled, generates functional syntax (e.g., `z.optional(z.string())`) instead of chainable methods (e.g., `z.string().optional()`).
105
- * Requires Zod v4 or later. When `mini: true`, `version` will be set to '4' and `importPath` will default to 'zod/mini'.
118
+ * Requires Zod v4 or later. When `mini: true`, `version` is set to '4' and `importPath` will default to 'zod/mini'.
106
119
  * @default false
107
120
  */
108
121
  mini?: boolean