@kubb/plugin-ts 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.
- 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-e1TzqRgL.d.ts → types-C6zMTrNH.d.ts} +102 -72
- package/dist/{types-BmA-vXVc.d.cts → types-DQ-FqXlZ.d.cts} +102 -72
- package/package.json +4 -4
- package/src/parser.ts +1 -1
- package/src/types.ts +33 -23
|
@@ -21,16 +21,21 @@ type Operation$1 = Operation;
|
|
|
21
21
|
type DiscriminatorObject$1 = DiscriminatorObject;
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region ../oas/src/Oas.d.ts
|
|
24
|
-
type
|
|
24
|
+
type OasOptions = {
|
|
25
25
|
contentType?: contentType;
|
|
26
26
|
discriminator?: 'strict' | 'inherit';
|
|
27
|
+
/**
|
|
28
|
+
* Resolve name collisions when schemas from different components share the same name (case-insensitive).
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
collisionDetection?: boolean;
|
|
27
32
|
};
|
|
28
33
|
declare class Oas extends BaseOas {
|
|
29
34
|
#private;
|
|
30
35
|
document: Document;
|
|
31
36
|
constructor(document: Document);
|
|
32
|
-
setOptions(options:
|
|
33
|
-
get options():
|
|
37
|
+
setOptions(options: OasOptions): void;
|
|
38
|
+
get options(): OasOptions;
|
|
34
39
|
get<T = unknown>($ref: string): T | null;
|
|
35
40
|
getKey($ref: string): string | undefined;
|
|
36
41
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -39,8 +44,20 @@ declare class Oas extends BaseOas {
|
|
|
39
44
|
getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
|
|
40
45
|
getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
|
|
41
46
|
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
42
|
-
|
|
47
|
+
validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
43
48
|
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
49
|
+
/**
|
|
50
|
+
* Get schemas from OpenAPI components (schemas, responses, requestBodies).
|
|
51
|
+
* Returns schemas in dependency order along with name mapping for collision resolution.
|
|
52
|
+
*/
|
|
53
|
+
getSchemas(options?: {
|
|
54
|
+
contentType?: contentType;
|
|
55
|
+
includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
56
|
+
collisionDetection?: boolean;
|
|
57
|
+
}): {
|
|
58
|
+
schemas: Record<string, SchemaObject$1>;
|
|
59
|
+
nameMapping: Map<string, string>;
|
|
60
|
+
};
|
|
44
61
|
}
|
|
45
62
|
//#endregion
|
|
46
63
|
//#region ../core/src/BaseGenerator.d.ts
|
|
@@ -341,7 +358,7 @@ type Config<TInput = Input> = {
|
|
|
341
358
|
input: TInput;
|
|
342
359
|
output: {
|
|
343
360
|
/**
|
|
344
|
-
* The path where all generated files
|
|
361
|
+
* The path where all generated files receives exported.
|
|
345
362
|
* This can be an absolute path or a path relative to the specified root option.
|
|
346
363
|
*/
|
|
347
364
|
path: string;
|
|
@@ -356,41 +373,39 @@ type Config<TInput = Input> = {
|
|
|
356
373
|
write?: boolean;
|
|
357
374
|
/**
|
|
358
375
|
* Specifies the formatting tool to be used.
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* - '
|
|
363
|
-
* -
|
|
364
|
-
*
|
|
365
|
-
*
|
|
376
|
+
* - 'auto' automatically detects and uses biome or prettier (in that order of preference).
|
|
377
|
+
* - 'prettier' uses Prettier for code formatting.
|
|
378
|
+
* - 'biome' uses Biome for code formatting.
|
|
379
|
+
* - 'oxfmt' uses Oxfmt for code formatting.
|
|
380
|
+
* - false disables code formatting.
|
|
381
|
+
* @default 'prettier'
|
|
366
382
|
*/
|
|
367
383
|
format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
|
|
368
384
|
/**
|
|
369
385
|
* Specifies the linter that should be used to analyze the code.
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* - '
|
|
374
|
-
* -
|
|
375
|
-
*
|
|
376
|
-
* - 'oxlint': Represents the Oxlint tool for linting purposes.
|
|
377
|
-
*
|
|
386
|
+
* - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
|
|
387
|
+
* - 'eslint' uses ESLint for linting.
|
|
388
|
+
* - 'biome' uses Biome for linting.
|
|
389
|
+
* - 'oxlint' uses Oxlint for linting.
|
|
390
|
+
* - false disables linting.
|
|
391
|
+
* @default 'auto'
|
|
378
392
|
*/
|
|
379
393
|
lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
|
|
380
394
|
/**
|
|
381
|
-
*
|
|
395
|
+
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
382
396
|
* @default { '.ts': '.ts'}
|
|
383
397
|
*/
|
|
384
398
|
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
385
399
|
/**
|
|
386
|
-
*
|
|
400
|
+
* 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`).
|
|
387
401
|
* @default 'named'
|
|
388
402
|
*/
|
|
389
403
|
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
390
404
|
/**
|
|
391
|
-
*
|
|
392
|
-
* - 'simple'
|
|
393
|
-
* - 'full'
|
|
405
|
+
* Adds a default banner to the start of every generated file indicating it was generated by Kubb.
|
|
406
|
+
* - 'simple' adds banner with link to Kubb.
|
|
407
|
+
* - 'full' adds source, title, description, and OpenAPI version.
|
|
408
|
+
* - false disables banner generation.
|
|
394
409
|
* @default 'simple'
|
|
395
410
|
*/
|
|
396
411
|
defaultBanner?: 'simple' | 'full' | false;
|
|
@@ -403,17 +418,17 @@ type Config<TInput = Input> = {
|
|
|
403
418
|
override?: boolean;
|
|
404
419
|
};
|
|
405
420
|
/**
|
|
406
|
-
* An array of Kubb plugins that
|
|
421
|
+
* An array of Kubb plugins that used in the generation.
|
|
407
422
|
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
408
|
-
* If a plugin depends on another plugin, an error
|
|
423
|
+
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
409
424
|
*/
|
|
410
425
|
plugins?: Array<Plugin>;
|
|
411
426
|
/**
|
|
412
|
-
* Hooks
|
|
427
|
+
* Hooks triggered when a specific action occurs in Kubb.
|
|
413
428
|
*/
|
|
414
429
|
hooks?: {
|
|
415
430
|
/**
|
|
416
|
-
* Hook that
|
|
431
|
+
* Hook that triggers at the end of all executions.
|
|
417
432
|
* Useful for running Prettier or ESLint to format/lint your code.
|
|
418
433
|
*/
|
|
419
434
|
done?: string | Array<string>;
|
|
@@ -442,7 +457,7 @@ TContext = any,
|
|
|
442
457
|
TResolvePathOptions extends object = object> = {
|
|
443
458
|
name: TName;
|
|
444
459
|
/**
|
|
445
|
-
* Same
|
|
460
|
+
* Same behavior like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
446
461
|
*/
|
|
447
462
|
key: PluginKey<TName | string>;
|
|
448
463
|
options: TOptions;
|
|
@@ -463,12 +478,12 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
463
478
|
*/
|
|
464
479
|
options: TOptions['resolvedOptions'];
|
|
465
480
|
/**
|
|
466
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
481
|
+
* 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.
|
|
467
482
|
* Can be used to validate dependent plugins.
|
|
468
483
|
*/
|
|
469
484
|
pre?: Array<string>;
|
|
470
485
|
/**
|
|
471
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
486
|
+
* 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.
|
|
472
487
|
*/
|
|
473
488
|
post?: Array<string>;
|
|
474
489
|
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
@@ -486,12 +501,12 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
486
501
|
*/
|
|
487
502
|
key: TOptions['key'];
|
|
488
503
|
/**
|
|
489
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
504
|
+
* 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.
|
|
490
505
|
* Can be used to validate dependent plugins.
|
|
491
506
|
*/
|
|
492
507
|
pre?: Array<string>;
|
|
493
508
|
/**
|
|
494
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
509
|
+
* 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.
|
|
495
510
|
*/
|
|
496
511
|
post?: Array<string>;
|
|
497
512
|
/**
|
|
@@ -541,10 +556,12 @@ type ResolveNameParams = {
|
|
|
541
556
|
name: string;
|
|
542
557
|
pluginKey?: Plugin['key'];
|
|
543
558
|
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
559
|
+
* Specifies the type of entity being named.
|
|
560
|
+
* - 'file' customizes the name of the created file (uses camelCase).
|
|
561
|
+
* - 'function' customizes the exported function names (uses camelCase).
|
|
562
|
+
* - 'type' customizes TypeScript types (uses PascalCase).
|
|
563
|
+
* - 'const' customizes variable names (uses camelCase).
|
|
564
|
+
* @default undefined
|
|
548
565
|
*/
|
|
549
566
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
550
567
|
};
|
|
@@ -599,11 +616,14 @@ type GroupContext = {
|
|
|
599
616
|
};
|
|
600
617
|
type Group = {
|
|
601
618
|
/**
|
|
602
|
-
*
|
|
619
|
+
* Defines the type where to group the files.
|
|
620
|
+
* - 'tag' groups files by OpenAPI tags.
|
|
621
|
+
* - 'path' groups files by OpenAPI paths.
|
|
622
|
+
* @default undefined
|
|
603
623
|
*/
|
|
604
624
|
type: 'tag' | 'path';
|
|
605
625
|
/**
|
|
606
|
-
* Return the name of a group based on the group name, this
|
|
626
|
+
* Return the name of a group based on the group name, this used for the file and name generation
|
|
607
627
|
*/
|
|
608
628
|
name?: (context: GroupContext) => string;
|
|
609
629
|
};
|
|
@@ -675,7 +695,7 @@ declare class PluginManager {
|
|
|
675
695
|
parameters: PluginParameter<H>;
|
|
676
696
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
677
697
|
/**
|
|
678
|
-
*
|
|
698
|
+
* Returns the first non-null result.
|
|
679
699
|
*/
|
|
680
700
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
681
701
|
hookName,
|
|
@@ -687,7 +707,7 @@ declare class PluginManager {
|
|
|
687
707
|
skipped?: ReadonlySet<Plugin> | null;
|
|
688
708
|
}): Promise<SafeParseResult<H>>;
|
|
689
709
|
/**
|
|
690
|
-
*
|
|
710
|
+
* Returns the first non-null result.
|
|
691
711
|
*/
|
|
692
712
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
693
713
|
hookName,
|
|
@@ -699,15 +719,15 @@ declare class PluginManager {
|
|
|
699
719
|
skipped?: ReadonlySet<Plugin> | null;
|
|
700
720
|
}): SafeParseResult<H>;
|
|
701
721
|
/**
|
|
702
|
-
*
|
|
722
|
+
* Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
|
|
703
723
|
*/
|
|
704
|
-
hookParallel<H extends PluginLifecycleHooks,
|
|
724
|
+
hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
|
|
705
725
|
hookName,
|
|
706
726
|
parameters
|
|
707
727
|
}: {
|
|
708
728
|
hookName: H;
|
|
709
729
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
710
|
-
}): Promise<Awaited<
|
|
730
|
+
}): Promise<Awaited<TOutput>[]>;
|
|
711
731
|
/**
|
|
712
732
|
* Chains plugins
|
|
713
733
|
*/
|
|
@@ -976,8 +996,8 @@ type SchemaKeywordMapper = {
|
|
|
976
996
|
*/
|
|
977
997
|
path: KubbFile.Path;
|
|
978
998
|
/**
|
|
979
|
-
* When true `File.Import`
|
|
980
|
-
* When false a reference
|
|
999
|
+
* When true `File.Import` is used.
|
|
1000
|
+
* When false a reference is used inside the current file.
|
|
981
1001
|
*/
|
|
982
1002
|
isImportable: boolean;
|
|
983
1003
|
};
|
|
@@ -1109,7 +1129,7 @@ type SchemaGeneratorOptions = {
|
|
|
1109
1129
|
*/
|
|
1110
1130
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1111
1131
|
/**
|
|
1112
|
-
* Receive schema and name(
|
|
1132
|
+
* Receive schema and name(propertyName) and return FakerMeta array
|
|
1113
1133
|
* TODO TODO add docs
|
|
1114
1134
|
* @beta
|
|
1115
1135
|
*/
|
|
@@ -1188,7 +1208,7 @@ type Options = {
|
|
|
1188
1208
|
output?: Output<Oas>;
|
|
1189
1209
|
/**
|
|
1190
1210
|
* Define which contentType should be used.
|
|
1191
|
-
* By default, the first
|
|
1211
|
+
* By default, uses the first valid JSON media type.
|
|
1192
1212
|
*/
|
|
1193
1213
|
contentType?: contentType;
|
|
1194
1214
|
/**
|
|
@@ -1208,29 +1228,31 @@ type Options = {
|
|
|
1208
1228
|
*/
|
|
1209
1229
|
override?: Array<Override<ResolvedOptions>>;
|
|
1210
1230
|
/**
|
|
1211
|
-
* Choose to use
|
|
1212
|
-
* -
|
|
1213
|
-
* -
|
|
1214
|
-
* -
|
|
1215
|
-
* -
|
|
1216
|
-
* -
|
|
1217
|
-
* -
|
|
1231
|
+
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
1232
|
+
* - 'enum' generates TypeScript enum declarations.
|
|
1233
|
+
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
1234
|
+
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
1235
|
+
* - 'constEnum' generates TypeScript const enum declarations.
|
|
1236
|
+
* - 'literal' generates literal union types.
|
|
1237
|
+
* - 'inlineLiteral' inlines enum values directly into the type (default in v5).
|
|
1218
1238
|
* @default 'asConst'
|
|
1219
|
-
* @note In Kubb v5,
|
|
1239
|
+
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
1220
1240
|
*/
|
|
1221
1241
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
1222
1242
|
/**
|
|
1223
1243
|
* Choose the casing for enum key names.
|
|
1224
|
-
* -
|
|
1225
|
-
* -
|
|
1226
|
-
* -
|
|
1227
|
-
* -
|
|
1228
|
-
* -
|
|
1244
|
+
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
1245
|
+
* - 'snakeCase' generates keys in snake_case format.
|
|
1246
|
+
* - 'pascalCase' generates keys in PascalCase format.
|
|
1247
|
+
* - 'camelCase' generates keys in camelCase format.
|
|
1248
|
+
* - 'none' uses the enum value as-is without transformation.
|
|
1229
1249
|
* @default 'none'
|
|
1230
1250
|
*/
|
|
1231
1251
|
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
1232
1252
|
/**
|
|
1233
|
-
* Switch between type or interface for creating TypeScript types
|
|
1253
|
+
* Switch between type or interface for creating TypeScript types.
|
|
1254
|
+
* - 'type' generates type alias declarations.
|
|
1255
|
+
* - 'interface' generates interface declarations.
|
|
1234
1256
|
* @default 'type'
|
|
1235
1257
|
*/
|
|
1236
1258
|
syntaxType?: 'type' | 'interface';
|
|
@@ -1240,32 +1262,40 @@ type Options = {
|
|
|
1240
1262
|
*/
|
|
1241
1263
|
enumSuffix?: string;
|
|
1242
1264
|
/**
|
|
1243
|
-
* Choose to use
|
|
1265
|
+
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
1266
|
+
* - 'string' represents dates as string values.
|
|
1267
|
+
* - 'date' represents dates as JavaScript Date objects.
|
|
1244
1268
|
* @default 'string'
|
|
1245
1269
|
*/
|
|
1246
1270
|
dateType?: 'string' | 'date';
|
|
1247
1271
|
/**
|
|
1248
1272
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
1273
|
+
* - 'any' allows any value.
|
|
1274
|
+
* - 'unknown' requires type narrowing before use.
|
|
1275
|
+
* - 'void' represents no value.
|
|
1249
1276
|
* @default 'any'
|
|
1250
1277
|
*/
|
|
1251
1278
|
unknownType?: 'any' | 'unknown' | 'void';
|
|
1252
1279
|
/**
|
|
1253
|
-
* Which type to use for empty schema values
|
|
1280
|
+
* Which type to use for empty schema values.
|
|
1281
|
+
* - 'any' allows any value.
|
|
1282
|
+
* - 'unknown' requires type narrowing before use.
|
|
1283
|
+
* - 'void' represents no value.
|
|
1254
1284
|
* @default `unknownType`
|
|
1255
1285
|
*/
|
|
1256
1286
|
emptySchemaType?: 'any' | 'unknown' | 'void';
|
|
1257
1287
|
/**
|
|
1258
1288
|
* Choose what to use as mode for an optional value.
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1289
|
+
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
1290
|
+
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
1291
|
+
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
1262
1292
|
* @default 'questionToken'
|
|
1263
1293
|
*/
|
|
1264
1294
|
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
1265
1295
|
/**
|
|
1266
|
-
* Choose between
|
|
1267
|
-
* -
|
|
1268
|
-
* -
|
|
1296
|
+
* Choose between Array<string> or string[] for array types.
|
|
1297
|
+
* - 'generic' generates Array<Type> syntax.
|
|
1298
|
+
* - 'array' generates Type[] syntax.
|
|
1269
1299
|
* @default 'array'
|
|
1270
1300
|
*/
|
|
1271
1301
|
arrayType?: 'generic' | 'array';
|
|
@@ -1314,4 +1344,4 @@ type ResolvedOptions = {
|
|
|
1314
1344
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1315
1345
|
//#endregion
|
|
1316
1346
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, __name as s, Options as t };
|
|
1317
|
-
//# sourceMappingURL=types-
|
|
1347
|
+
//# sourceMappingURL=types-DQ-FqXlZ.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.0",
|
|
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.
|
|
73
|
-
"@kubb/oas": "4.
|
|
74
|
-
"@kubb/plugin-oas": "4.
|
|
72
|
+
"@kubb/core": "4.19.0",
|
|
73
|
+
"@kubb/oas": "4.19.0",
|
|
74
|
+
"@kubb/plugin-oas": "4.19.0"
|
|
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'
|