@kubb/plugin-ts 4.18.4 → 4.18.5
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/components-BgXQceYE.js.map +1 -1
- package/dist/components-ORNo_nJW.cjs.map +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{types-BmA-vXVc.d.cts → types-BMfQRWAb.d.cts} +82 -69
- package/dist/{types-e1TzqRgL.d.ts → types-DpL83O8r.d.ts} +82 -69
- package/package.json +4 -4
- package/src/parser.ts +1 -1
- package/src/types.ts +33 -23
|
@@ -38,7 +38,7 @@ declare class Oas extends BaseOas {
|
|
|
38
38
|
getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
|
|
39
39
|
getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
|
|
40
40
|
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
41
|
-
|
|
41
|
+
validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
42
42
|
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
@@ -340,7 +340,7 @@ type Config<TInput = Input> = {
|
|
|
340
340
|
input: TInput;
|
|
341
341
|
output: {
|
|
342
342
|
/**
|
|
343
|
-
* The path where all generated files
|
|
343
|
+
* The path where all generated files receives exported.
|
|
344
344
|
* This can be an absolute path or a path relative to the specified root option.
|
|
345
345
|
*/
|
|
346
346
|
path: string;
|
|
@@ -355,41 +355,39 @@ type Config<TInput = Input> = {
|
|
|
355
355
|
write?: boolean;
|
|
356
356
|
/**
|
|
357
357
|
* Specifies the formatting tool to be used.
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
* - '
|
|
362
|
-
* -
|
|
363
|
-
*
|
|
364
|
-
*
|
|
358
|
+
* - 'auto' automatically detects and uses biome or prettier (in that order of preference).
|
|
359
|
+
* - 'prettier' uses Prettier for code formatting.
|
|
360
|
+
* - 'biome' uses Biome for code formatting.
|
|
361
|
+
* - 'oxfmt' uses Oxfmt for code formatting.
|
|
362
|
+
* - false disables code formatting.
|
|
363
|
+
* @default 'prettier'
|
|
365
364
|
*/
|
|
366
365
|
format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
|
|
367
366
|
/**
|
|
368
367
|
* Specifies the linter that should be used to analyze the code.
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* - '
|
|
373
|
-
* -
|
|
374
|
-
*
|
|
375
|
-
* - 'oxlint': Represents the Oxlint tool for linting purposes.
|
|
376
|
-
*
|
|
368
|
+
* - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
|
|
369
|
+
* - 'eslint' uses ESLint for linting.
|
|
370
|
+
* - 'biome' uses Biome for linting.
|
|
371
|
+
* - 'oxlint' uses Oxlint for linting.
|
|
372
|
+
* - false disables linting.
|
|
373
|
+
* @default 'auto'
|
|
377
374
|
*/
|
|
378
375
|
lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
|
|
379
376
|
/**
|
|
380
|
-
*
|
|
377
|
+
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
381
378
|
* @default { '.ts': '.ts'}
|
|
382
379
|
*/
|
|
383
380
|
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
384
381
|
/**
|
|
385
|
-
*
|
|
382
|
+
* 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
383
|
* @default 'named'
|
|
387
384
|
*/
|
|
388
385
|
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
389
386
|
/**
|
|
390
|
-
*
|
|
391
|
-
* - 'simple'
|
|
392
|
-
* - 'full'
|
|
387
|
+
* Adds a default banner to the start of every generated file indicating it was generated by Kubb.
|
|
388
|
+
* - 'simple' adds banner with link to Kubb.
|
|
389
|
+
* - 'full' adds source, title, description, and OpenAPI version.
|
|
390
|
+
* - false disables banner generation.
|
|
393
391
|
* @default 'simple'
|
|
394
392
|
*/
|
|
395
393
|
defaultBanner?: 'simple' | 'full' | false;
|
|
@@ -402,17 +400,17 @@ type Config<TInput = Input> = {
|
|
|
402
400
|
override?: boolean;
|
|
403
401
|
};
|
|
404
402
|
/**
|
|
405
|
-
* An array of Kubb plugins that
|
|
403
|
+
* An array of Kubb plugins that used in the generation.
|
|
406
404
|
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
407
|
-
* If a plugin depends on another plugin, an error
|
|
405
|
+
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
408
406
|
*/
|
|
409
407
|
plugins?: Array<Plugin>;
|
|
410
408
|
/**
|
|
411
|
-
* Hooks
|
|
409
|
+
* Hooks triggered when a specific action occurs in Kubb.
|
|
412
410
|
*/
|
|
413
411
|
hooks?: {
|
|
414
412
|
/**
|
|
415
|
-
* Hook that
|
|
413
|
+
* Hook that triggers at the end of all executions.
|
|
416
414
|
* Useful for running Prettier or ESLint to format/lint your code.
|
|
417
415
|
*/
|
|
418
416
|
done?: string | Array<string>;
|
|
@@ -441,7 +439,7 @@ TContext = any,
|
|
|
441
439
|
TResolvePathOptions extends object = object> = {
|
|
442
440
|
name: TName;
|
|
443
441
|
/**
|
|
444
|
-
* Same
|
|
442
|
+
* Same behavior like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
445
443
|
*/
|
|
446
444
|
key: PluginKey<TName | string>;
|
|
447
445
|
options: TOptions;
|
|
@@ -462,12 +460,12 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
462
460
|
*/
|
|
463
461
|
options: TOptions['resolvedOptions'];
|
|
464
462
|
/**
|
|
465
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
463
|
+
* 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
464
|
* Can be used to validate dependent plugins.
|
|
467
465
|
*/
|
|
468
466
|
pre?: Array<string>;
|
|
469
467
|
/**
|
|
470
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
468
|
+
* 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
469
|
*/
|
|
472
470
|
post?: Array<string>;
|
|
473
471
|
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
@@ -485,12 +483,12 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
485
483
|
*/
|
|
486
484
|
key: TOptions['key'];
|
|
487
485
|
/**
|
|
488
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
486
|
+
* 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
487
|
* Can be used to validate dependent plugins.
|
|
490
488
|
*/
|
|
491
489
|
pre?: Array<string>;
|
|
492
490
|
/**
|
|
493
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
491
|
+
* 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
492
|
*/
|
|
495
493
|
post?: Array<string>;
|
|
496
494
|
/**
|
|
@@ -540,10 +538,12 @@ type ResolveNameParams = {
|
|
|
540
538
|
name: string;
|
|
541
539
|
pluginKey?: Plugin['key'];
|
|
542
540
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
541
|
+
* Specifies the type of entity being named.
|
|
542
|
+
* - 'file' customizes the name of the created file (uses camelCase).
|
|
543
|
+
* - 'function' customizes the exported function names (uses camelCase).
|
|
544
|
+
* - 'type' customizes TypeScript types (uses PascalCase).
|
|
545
|
+
* - 'const' customizes variable names (uses camelCase).
|
|
546
|
+
* @default undefined
|
|
547
547
|
*/
|
|
548
548
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
549
549
|
};
|
|
@@ -598,11 +598,14 @@ type GroupContext = {
|
|
|
598
598
|
};
|
|
599
599
|
type Group = {
|
|
600
600
|
/**
|
|
601
|
-
*
|
|
601
|
+
* Defines the type where to group the files.
|
|
602
|
+
* - 'tag' groups files by OpenAPI tags.
|
|
603
|
+
* - 'path' groups files by OpenAPI paths.
|
|
604
|
+
* @default undefined
|
|
602
605
|
*/
|
|
603
606
|
type: 'tag' | 'path';
|
|
604
607
|
/**
|
|
605
|
-
* Return the name of a group based on the group name, this
|
|
608
|
+
* Return the name of a group based on the group name, this used for the file and name generation
|
|
606
609
|
*/
|
|
607
610
|
name?: (context: GroupContext) => string;
|
|
608
611
|
};
|
|
@@ -674,7 +677,7 @@ declare class PluginManager {
|
|
|
674
677
|
parameters: PluginParameter<H>;
|
|
675
678
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
676
679
|
/**
|
|
677
|
-
*
|
|
680
|
+
* Returns the first non-null result.
|
|
678
681
|
*/
|
|
679
682
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
680
683
|
hookName,
|
|
@@ -686,7 +689,7 @@ declare class PluginManager {
|
|
|
686
689
|
skipped?: ReadonlySet<Plugin> | null;
|
|
687
690
|
}): Promise<SafeParseResult<H>>;
|
|
688
691
|
/**
|
|
689
|
-
*
|
|
692
|
+
* Returns the first non-null result.
|
|
690
693
|
*/
|
|
691
694
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
692
695
|
hookName,
|
|
@@ -698,15 +701,15 @@ declare class PluginManager {
|
|
|
698
701
|
skipped?: ReadonlySet<Plugin> | null;
|
|
699
702
|
}): SafeParseResult<H>;
|
|
700
703
|
/**
|
|
701
|
-
*
|
|
704
|
+
* Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
|
|
702
705
|
*/
|
|
703
|
-
hookParallel<H extends PluginLifecycleHooks,
|
|
706
|
+
hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
|
|
704
707
|
hookName,
|
|
705
708
|
parameters
|
|
706
709
|
}: {
|
|
707
710
|
hookName: H;
|
|
708
711
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
709
|
-
}): Promise<Awaited<
|
|
712
|
+
}): Promise<Awaited<TOutput>[]>;
|
|
710
713
|
/**
|
|
711
714
|
* Chains plugins
|
|
712
715
|
*/
|
|
@@ -975,8 +978,8 @@ type SchemaKeywordMapper = {
|
|
|
975
978
|
*/
|
|
976
979
|
path: KubbFile.Path;
|
|
977
980
|
/**
|
|
978
|
-
* When true `File.Import`
|
|
979
|
-
* When false a reference
|
|
981
|
+
* When true `File.Import` is used.
|
|
982
|
+
* When false a reference is used inside the current file.
|
|
980
983
|
*/
|
|
981
984
|
isImportable: boolean;
|
|
982
985
|
};
|
|
@@ -1108,7 +1111,7 @@ type SchemaGeneratorOptions = {
|
|
|
1108
1111
|
*/
|
|
1109
1112
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1110
1113
|
/**
|
|
1111
|
-
* Receive schema and name(
|
|
1114
|
+
* Receive schema and name(propertyName) and return FakerMeta array
|
|
1112
1115
|
* TODO TODO add docs
|
|
1113
1116
|
* @beta
|
|
1114
1117
|
*/
|
|
@@ -1187,7 +1190,7 @@ type Options = {
|
|
|
1187
1190
|
output?: Output<Oas>;
|
|
1188
1191
|
/**
|
|
1189
1192
|
* Define which contentType should be used.
|
|
1190
|
-
* By default, the first
|
|
1193
|
+
* By default, uses the first valid JSON media type.
|
|
1191
1194
|
*/
|
|
1192
1195
|
contentType?: contentType;
|
|
1193
1196
|
/**
|
|
@@ -1207,29 +1210,31 @@ type Options = {
|
|
|
1207
1210
|
*/
|
|
1208
1211
|
override?: Array<Override<ResolvedOptions>>;
|
|
1209
1212
|
/**
|
|
1210
|
-
* Choose to use
|
|
1211
|
-
* -
|
|
1212
|
-
* -
|
|
1213
|
-
* -
|
|
1214
|
-
* -
|
|
1215
|
-
* -
|
|
1216
|
-
* -
|
|
1213
|
+
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
1214
|
+
* - 'enum' generates TypeScript enum declarations.
|
|
1215
|
+
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
1216
|
+
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
1217
|
+
* - 'constEnum' generates TypeScript const enum declarations.
|
|
1218
|
+
* - 'literal' generates literal union types.
|
|
1219
|
+
* - 'inlineLiteral' inlines enum values directly into the type (default in v5).
|
|
1217
1220
|
* @default 'asConst'
|
|
1218
|
-
* @note In Kubb v5,
|
|
1221
|
+
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
1219
1222
|
*/
|
|
1220
1223
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
1221
1224
|
/**
|
|
1222
1225
|
* Choose the casing for enum key names.
|
|
1223
|
-
* -
|
|
1224
|
-
* -
|
|
1225
|
-
* -
|
|
1226
|
-
* -
|
|
1227
|
-
* -
|
|
1226
|
+
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
1227
|
+
* - 'snakeCase' generates keys in snake_case format.
|
|
1228
|
+
* - 'pascalCase' generates keys in PascalCase format.
|
|
1229
|
+
* - 'camelCase' generates keys in camelCase format.
|
|
1230
|
+
* - 'none' uses the enum value as-is without transformation.
|
|
1228
1231
|
* @default 'none'
|
|
1229
1232
|
*/
|
|
1230
1233
|
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
1231
1234
|
/**
|
|
1232
|
-
* Switch between type or interface for creating TypeScript types
|
|
1235
|
+
* Switch between type or interface for creating TypeScript types.
|
|
1236
|
+
* - 'type' generates type alias declarations.
|
|
1237
|
+
* - 'interface' generates interface declarations.
|
|
1233
1238
|
* @default 'type'
|
|
1234
1239
|
*/
|
|
1235
1240
|
syntaxType?: 'type' | 'interface';
|
|
@@ -1239,32 +1244,40 @@ type Options = {
|
|
|
1239
1244
|
*/
|
|
1240
1245
|
enumSuffix?: string;
|
|
1241
1246
|
/**
|
|
1242
|
-
* Choose to use
|
|
1247
|
+
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
1248
|
+
* - 'string' represents dates as string values.
|
|
1249
|
+
* - 'date' represents dates as JavaScript Date objects.
|
|
1243
1250
|
* @default 'string'
|
|
1244
1251
|
*/
|
|
1245
1252
|
dateType?: 'string' | 'date';
|
|
1246
1253
|
/**
|
|
1247
1254
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
1255
|
+
* - 'any' allows any value.
|
|
1256
|
+
* - 'unknown' requires type narrowing before use.
|
|
1257
|
+
* - 'void' represents no value.
|
|
1248
1258
|
* @default 'any'
|
|
1249
1259
|
*/
|
|
1250
1260
|
unknownType?: 'any' | 'unknown' | 'void';
|
|
1251
1261
|
/**
|
|
1252
|
-
* Which type to use for empty schema values
|
|
1262
|
+
* Which type to use for empty schema values.
|
|
1263
|
+
* - 'any' allows any value.
|
|
1264
|
+
* - 'unknown' requires type narrowing before use.
|
|
1265
|
+
* - 'void' represents no value.
|
|
1253
1266
|
* @default `unknownType`
|
|
1254
1267
|
*/
|
|
1255
1268
|
emptySchemaType?: 'any' | 'unknown' | 'void';
|
|
1256
1269
|
/**
|
|
1257
1270
|
* Choose what to use as mode for an optional value.
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1271
|
+
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
1272
|
+
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
1273
|
+
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
1261
1274
|
* @default 'questionToken'
|
|
1262
1275
|
*/
|
|
1263
1276
|
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
1264
1277
|
/**
|
|
1265
|
-
* Choose between
|
|
1266
|
-
* -
|
|
1267
|
-
* -
|
|
1278
|
+
* Choose between Array<string> or string[] for array types.
|
|
1279
|
+
* - 'generic' generates Array<Type> syntax.
|
|
1280
|
+
* - 'array' generates Type[] syntax.
|
|
1268
1281
|
* @default 'array'
|
|
1269
1282
|
*/
|
|
1270
1283
|
arrayType?: 'generic' | 'array';
|
|
@@ -1313,4 +1326,4 @@ type ResolvedOptions = {
|
|
|
1313
1326
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1314
1327
|
//#endregion
|
|
1315
1328
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, Options as t };
|
|
1316
|
-
//# sourceMappingURL=types-
|
|
1329
|
+
//# sourceMappingURL=types-DpL83O8r.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.5",
|
|
4
4
|
"description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"natural-orderby": "^5.0.0",
|
|
70
70
|
"remeda": "^2.33.4",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
|
-
"@kubb/core": "4.18.
|
|
73
|
-
"@kubb/oas": "4.18.
|
|
74
|
-
"@kubb/plugin-oas": "4.18.
|
|
72
|
+
"@kubb/core": "4.18.5",
|
|
73
|
+
"@kubb/oas": "4.18.5",
|
|
74
|
+
"@kubb/plugin-oas": "4.18.5"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@kubb/react-fabric": "0.12.4",
|
package/src/parser.ts
CHANGED
|
@@ -155,7 +155,7 @@ type ParserOptions = {
|
|
|
155
155
|
* - `literal`: literal union type
|
|
156
156
|
* - `inlineLiteral`: inline enum values directly into the type (default in v5)
|
|
157
157
|
* @default `'asConst'`
|
|
158
|
-
* @note In Kubb v5, `inlineLiteral`
|
|
158
|
+
* @note In Kubb v5, `inlineLiteral` becomes the default.
|
|
159
159
|
*/
|
|
160
160
|
enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral'
|
|
161
161
|
mapper?: Record<string, ts.PropertySignature>
|
package/src/types.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type Options = {
|
|
|
12
12
|
output?: Output<Oas>
|
|
13
13
|
/**
|
|
14
14
|
* Define which contentType should be used.
|
|
15
|
-
* By default, the first
|
|
15
|
+
* By default, uses the first valid JSON media type.
|
|
16
16
|
*/
|
|
17
17
|
contentType?: contentType
|
|
18
18
|
/**
|
|
@@ -32,29 +32,31 @@ export type Options = {
|
|
|
32
32
|
*/
|
|
33
33
|
override?: Array<Override<ResolvedOptions>>
|
|
34
34
|
/**
|
|
35
|
-
* Choose to use
|
|
36
|
-
* -
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
39
|
-
* -
|
|
40
|
-
* -
|
|
41
|
-
* -
|
|
35
|
+
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
36
|
+
* - 'enum' generates TypeScript enum declarations.
|
|
37
|
+
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
38
|
+
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
39
|
+
* - 'constEnum' generates TypeScript const enum declarations.
|
|
40
|
+
* - 'literal' generates literal union types.
|
|
41
|
+
* - 'inlineLiteral' inlines enum values directly into the type (default in v5).
|
|
42
42
|
* @default 'asConst'
|
|
43
|
-
* @note In Kubb v5,
|
|
43
|
+
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
44
44
|
*/
|
|
45
45
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral'
|
|
46
46
|
/**
|
|
47
47
|
* Choose the casing for enum key names.
|
|
48
|
-
* -
|
|
49
|
-
* -
|
|
50
|
-
* -
|
|
51
|
-
* -
|
|
52
|
-
* -
|
|
48
|
+
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
49
|
+
* - 'snakeCase' generates keys in snake_case format.
|
|
50
|
+
* - 'pascalCase' generates keys in PascalCase format.
|
|
51
|
+
* - 'camelCase' generates keys in camelCase format.
|
|
52
|
+
* - 'none' uses the enum value as-is without transformation.
|
|
53
53
|
* @default 'none'
|
|
54
54
|
*/
|
|
55
55
|
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none'
|
|
56
56
|
/**
|
|
57
|
-
* Switch between type or interface for creating TypeScript types
|
|
57
|
+
* Switch between type or interface for creating TypeScript types.
|
|
58
|
+
* - 'type' generates type alias declarations.
|
|
59
|
+
* - 'interface' generates interface declarations.
|
|
58
60
|
* @default 'type'
|
|
59
61
|
*/
|
|
60
62
|
syntaxType?: 'type' | 'interface'
|
|
@@ -64,32 +66,40 @@ export type Options = {
|
|
|
64
66
|
*/
|
|
65
67
|
enumSuffix?: string
|
|
66
68
|
/**
|
|
67
|
-
* Choose to use
|
|
69
|
+
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
70
|
+
* - 'string' represents dates as string values.
|
|
71
|
+
* - 'date' represents dates as JavaScript Date objects.
|
|
68
72
|
* @default 'string'
|
|
69
73
|
*/
|
|
70
74
|
dateType?: 'string' | 'date'
|
|
71
75
|
/**
|
|
72
76
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
77
|
+
* - 'any' allows any value.
|
|
78
|
+
* - 'unknown' requires type narrowing before use.
|
|
79
|
+
* - 'void' represents no value.
|
|
73
80
|
* @default 'any'
|
|
74
81
|
*/
|
|
75
82
|
unknownType?: 'any' | 'unknown' | 'void'
|
|
76
83
|
/**
|
|
77
|
-
* Which type to use for empty schema values
|
|
84
|
+
* Which type to use for empty schema values.
|
|
85
|
+
* - 'any' allows any value.
|
|
86
|
+
* - 'unknown' requires type narrowing before use.
|
|
87
|
+
* - 'void' represents no value.
|
|
78
88
|
* @default `unknownType`
|
|
79
89
|
*/
|
|
80
90
|
emptySchemaType?: 'any' | 'unknown' | 'void'
|
|
81
91
|
/**
|
|
82
92
|
* Choose what to use as mode for an optional value.
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
93
|
+
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
94
|
+
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
95
|
+
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
86
96
|
* @default 'questionToken'
|
|
87
97
|
*/
|
|
88
98
|
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'
|
|
89
99
|
/**
|
|
90
|
-
* Choose between
|
|
91
|
-
* -
|
|
92
|
-
* -
|
|
100
|
+
* Choose between Array<string> or string[] for array types.
|
|
101
|
+
* - 'generic' generates Array<Type> syntax.
|
|
102
|
+
* - 'array' generates Type[] syntax.
|
|
93
103
|
* @default 'array'
|
|
94
104
|
*/
|
|
95
105
|
arrayType?: 'generic' | 'array'
|