swagger-typescript-api 13.2.15 → 13.2.17
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/chunk-DQk6qfdC.mjs +18 -0
- package/dist/cli.cjs +16 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/{cli.js → cli.mjs} +9 -9
- package/dist/cli.mjs.map +1 -0
- package/dist/{src-CsGSW_U0.js → generate-templates-BO-5CKCm.mjs} +365 -483
- package/dist/generate-templates-BO-5CKCm.mjs.map +1 -0
- package/dist/{src-CgtuxwSo.cjs → generate-templates-wjE78AWV.cjs} +403 -503
- package/dist/generate-templates-wjE78AWV.cjs.map +1 -0
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +103 -221
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +103 -221
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +24 -29
- package/templates/default/procedure-call.ejs +1 -1
- package/templates/modular/procedure-call.ejs +1 -1
- package/CHANGELOG.md +0 -1754
- package/dist/chunk-CTAAG5j7.js +0 -13
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/src-CgtuxwSo.cjs.map +0 -1
- package/dist/src-CsGSW_U0.js.map +0 -1
- /package/dist/{cli.d.ts → cli.d.mts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_generate_templates = require('./generate-templates-wjE78AWV.cjs');
|
|
3
|
+
let consola = require("consola");
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
async function generateApi(config) {
|
|
7
|
+
if (config.debug) consola.consola.level = Number.MAX_SAFE_INTEGER;
|
|
8
|
+
if (config.silent) consola.consola.level = 0;
|
|
9
|
+
return await new require_generate_templates.CodeGenProcess(config).start();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.RequestContentKind = require_generate_templates.RequestContentKind;
|
|
14
|
+
exports.SCHEMA_TYPES = require_generate_templates.SCHEMA_TYPES;
|
|
5
15
|
Object.defineProperty(exports, 'constants', {
|
|
6
16
|
enumerable: true,
|
|
7
17
|
get: function () {
|
|
8
|
-
return
|
|
18
|
+
return require_generate_templates.constants_exports;
|
|
9
19
|
}
|
|
10
20
|
});
|
|
11
|
-
exports.generateApi =
|
|
12
|
-
exports.generateTemplates =
|
|
21
|
+
exports.generateApi = generateApi;
|
|
22
|
+
exports.generateTemplates = require_generate_templates.generateTemplates;
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["CodeGenProcess"],"sources":["../src/index.ts"],"sourcesContent":["import { consola } from \"consola\";\nimport type { GenerateApiConfiguration } from \"../types/index.js\";\nimport { CodeGenProcess } from \"./code-gen-process.js\";\n\nexport * from \"../types/index.js\";\n\nexport async function generateApi(\n config: Partial<GenerateApiConfiguration[\"config\"]>,\n) {\n if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;\n if (config.silent) consola.level = 0;\n const codeGenProcess = new CodeGenProcess(config);\n return await codeGenProcess.start();\n}\n\nexport { generateTemplates } from \"./commands/generate-templates/index.js\";\nexport * as constants from \"./constants.js\";\n"],"mappings":";;;;;AAMA,eAAsB,YACpB,QACA;AACA,KAAI,OAAO,MAAO,iBAAQ,QAAQ,OAAO;AACzC,KAAI,OAAO,OAAQ,iBAAQ,QAAQ;AAEnC,QAAO,MADgB,IAAIA,0CAAe,OAAO,CACrB,OAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { OpenAPI } from "openapi-types";
|
|
2
2
|
import * as typescript from "typescript";
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
3
|
+
import * as es_toolkit_compat0 from "es-toolkit/compat";
|
|
4
|
+
import { camelCase } from "es-toolkit/compat";
|
|
5
5
|
import * as swagger_schema_official0 from "swagger-schema-official";
|
|
6
|
-
import * as
|
|
6
|
+
import * as es_toolkit0 from "es-toolkit";
|
|
7
|
+
import * as eta from "eta";
|
|
7
8
|
|
|
8
|
-
//#region
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
9
10
|
//#endregion
|
|
10
11
|
//#region src/schema-components-map.d.ts
|
|
11
12
|
declare class SchemaComponentsMap {
|
|
@@ -182,7 +183,7 @@ declare class SchemaFormatters {
|
|
|
182
183
|
object: (parsedSchema: any) => any;
|
|
183
184
|
};
|
|
184
185
|
formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
|
|
185
|
-
formatDescription: (description:
|
|
186
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
186
187
|
formatObjectContent: (content: any) => string;
|
|
187
188
|
}
|
|
188
189
|
//#endregion
|
|
@@ -246,47 +247,12 @@ declare class SchemaRoutes {
|
|
|
246
247
|
hasQueryRoutes: boolean;
|
|
247
248
|
hasFormDataRoutes: boolean;
|
|
248
249
|
constructor(config: CodeGenConfig, schemaParserFabric: SchemaParserFabric, schemaComponentsMap: SchemaComponentsMap, templatesWorker: TemplatesWorker, typeNameFormatter: TypeNameFormatter);
|
|
249
|
-
createRequestsMap: (
|
|
250
|
-
parseRouteName: (
|
|
251
|
-
originalRoute: string;
|
|
252
|
-
route: string;
|
|
253
|
-
pathParams: {
|
|
254
|
-
$match: string;
|
|
255
|
-
name: string;
|
|
256
|
-
required: boolean;
|
|
257
|
-
type: "string";
|
|
258
|
-
description: string;
|
|
259
|
-
schema: {
|
|
260
|
-
type: string;
|
|
261
|
-
};
|
|
262
|
-
in: "path" | "query";
|
|
263
|
-
}[];
|
|
264
|
-
queryParams: {
|
|
265
|
-
$match: string;
|
|
266
|
-
name: string;
|
|
267
|
-
required: boolean;
|
|
268
|
-
type: "string";
|
|
269
|
-
description: string;
|
|
270
|
-
schema: {
|
|
271
|
-
type: string;
|
|
272
|
-
};
|
|
273
|
-
in: "path" | "query";
|
|
274
|
-
}[];
|
|
275
|
-
} | {
|
|
250
|
+
createRequestsMap: (routesByMethod: any) => {};
|
|
251
|
+
parseRouteName: (rawRoute: any) => {
|
|
276
252
|
originalRoute: any;
|
|
277
253
|
route: any;
|
|
278
|
-
pathParams:
|
|
279
|
-
queryParams:
|
|
280
|
-
$match: unknown;
|
|
281
|
-
name: string;
|
|
282
|
-
required: boolean;
|
|
283
|
-
type: string;
|
|
284
|
-
description: string;
|
|
285
|
-
schema: {
|
|
286
|
-
type: string;
|
|
287
|
-
};
|
|
288
|
-
in: string;
|
|
289
|
-
}[];
|
|
254
|
+
pathParams: any[];
|
|
255
|
+
queryParams: any[];
|
|
290
256
|
};
|
|
291
257
|
getRouteParams: (routeInfo: any, pathParamsFromRouteName: any, queryParamsFromRouteName: any) => {
|
|
292
258
|
path: never[];
|
|
@@ -323,16 +289,16 @@ declare class SchemaRoutes {
|
|
|
323
289
|
parsedSchemas: any;
|
|
324
290
|
operationId: any;
|
|
325
291
|
defaultType: any;
|
|
326
|
-
}) =>
|
|
292
|
+
}) => any[];
|
|
327
293
|
getResponseBodyInfo: (routeInfo: any, parsedSchemas: any) => {
|
|
328
294
|
contentTypes: any[];
|
|
329
|
-
responses:
|
|
295
|
+
responses: any[];
|
|
330
296
|
success: {
|
|
331
|
-
schema:
|
|
297
|
+
schema: any;
|
|
332
298
|
type: any;
|
|
333
299
|
};
|
|
334
300
|
error: {
|
|
335
|
-
schemas:
|
|
301
|
+
schemas: any[];
|
|
336
302
|
type: string;
|
|
337
303
|
};
|
|
338
304
|
full: {
|
|
@@ -385,9 +351,6 @@ declare class JavascriptTranslator extends Translator {
|
|
|
385
351
|
}[]>;
|
|
386
352
|
}
|
|
387
353
|
//#endregion
|
|
388
|
-
//#region src/util/internal-case.d.ts
|
|
389
|
-
declare function internalCase(value: string): string;
|
|
390
|
-
//#endregion
|
|
391
354
|
//#region src/util/name-resolver.d.ts
|
|
392
355
|
type Resolver = (reserved: string[], extras?: string[]) => string;
|
|
393
356
|
declare class NameResolver {
|
|
@@ -499,8 +462,8 @@ declare class CodeGenProcess {
|
|
|
499
462
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
500
463
|
Tuple: (values: unknown[]) => string;
|
|
501
464
|
};
|
|
502
|
-
formatDescription: (description:
|
|
503
|
-
internalCase: typeof
|
|
465
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
466
|
+
internalCase: typeof camelCase;
|
|
504
467
|
classNameCase: typeof pascalCase;
|
|
505
468
|
pascalCase: typeof pascalCase;
|
|
506
469
|
getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
@@ -528,7 +491,7 @@ declare class CodeGenProcess {
|
|
|
528
491
|
eol?: boolean | undefined;
|
|
529
492
|
}) => string;
|
|
530
493
|
NameResolver: typeof NameResolver;
|
|
531
|
-
_:
|
|
494
|
+
_: Record<string, unknown>;
|
|
532
495
|
require: (packageOrPath: string) => any;
|
|
533
496
|
};
|
|
534
497
|
};
|
|
@@ -604,8 +567,8 @@ declare class CodeGenProcess {
|
|
|
604
567
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
605
568
|
Tuple: (values: unknown[]) => string;
|
|
606
569
|
};
|
|
607
|
-
formatDescription: (description:
|
|
608
|
-
internalCase: typeof
|
|
570
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
571
|
+
internalCase: typeof camelCase;
|
|
609
572
|
classNameCase: typeof pascalCase;
|
|
610
573
|
pascalCase: typeof pascalCase;
|
|
611
574
|
getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
@@ -633,7 +596,7 @@ declare class CodeGenProcess {
|
|
|
633
596
|
eol?: boolean | undefined;
|
|
634
597
|
}) => string;
|
|
635
598
|
NameResolver: typeof NameResolver;
|
|
636
|
-
_:
|
|
599
|
+
_: Record<string, unknown>;
|
|
637
600
|
require: (packageOrPath: string) => any;
|
|
638
601
|
};
|
|
639
602
|
config: CodeGenConfig;
|
|
@@ -843,8 +806,7 @@ interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfigurat
|
|
|
843
806
|
}
|
|
844
807
|
type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
|
|
845
808
|
type BuildRouteParam = {
|
|
846
|
-
/** {bar}
|
|
847
|
-
$match: string;
|
|
809
|
+
/** {bar} */$match: string;
|
|
848
810
|
name: string;
|
|
849
811
|
required: boolean;
|
|
850
812
|
type: "string";
|
|
@@ -855,9 +817,7 @@ type BuildRouteParam = {
|
|
|
855
817
|
in: "path" | "query";
|
|
856
818
|
};
|
|
857
819
|
type BuildRoutePath = {
|
|
858
|
-
/** /foo/{bar}/baz */
|
|
859
|
-
originalRoute: string;
|
|
860
|
-
/** /foo/${bar}/baz */
|
|
820
|
+
/** /foo/{bar}/baz */originalRoute: string; /** /foo/${bar}/baz */
|
|
861
821
|
route: string;
|
|
862
822
|
pathParams: BuildRouteParam[];
|
|
863
823
|
queryParams: BuildRouteParam[];
|
|
@@ -965,7 +925,7 @@ declare enum RequestContentKind {
|
|
|
965
925
|
FORM_DATA = "FORM_DATA",
|
|
966
926
|
IMAGE = "IMAGE",
|
|
967
927
|
OTHER = "OTHER",
|
|
968
|
-
TEXT = "TEXT"
|
|
928
|
+
TEXT = "TEXT"
|
|
969
929
|
}
|
|
970
930
|
interface RequestResponseInfo {
|
|
971
931
|
contentTypes: string[];
|
|
@@ -1066,7 +1026,7 @@ declare enum SCHEMA_TYPES {
|
|
|
1066
1026
|
COMPLEX_ANY_OF = "anyOf",
|
|
1067
1027
|
COMPLEX_ALL_OF = "allOf",
|
|
1068
1028
|
COMPLEX_NOT = "not",
|
|
1069
|
-
COMPLEX_UNKNOWN = "__unknown"
|
|
1029
|
+
COMPLEX_UNKNOWN = "__unknown"
|
|
1070
1030
|
}
|
|
1071
1031
|
type MAIN_SCHEMA_TYPES = SCHEMA_TYPES.PRIMITIVE | SCHEMA_TYPES.OBJECT | SCHEMA_TYPES.ENUM;
|
|
1072
1032
|
type ExtractingOptions = {
|
|
@@ -1087,20 +1047,14 @@ type ExtractingOptions = {
|
|
|
1087
1047
|
};
|
|
1088
1048
|
interface GenerateApiConfiguration {
|
|
1089
1049
|
apiConfig: {
|
|
1090
|
-
/** base url from schema */
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
|
|
1094
|
-
/** document version */
|
|
1095
|
-
version: string;
|
|
1096
|
-
/** description split into lines */
|
|
1097
|
-
description: string[];
|
|
1098
|
-
/** flag that description is present */
|
|
1050
|
+
/** base url from schema */baseUrl: string; /** document title */
|
|
1051
|
+
title: string; /** document version */
|
|
1052
|
+
version: string; /** description split into lines */
|
|
1053
|
+
description: string[]; /** flag that description is present */
|
|
1099
1054
|
hasDescription: boolean;
|
|
1100
1055
|
};
|
|
1101
1056
|
config: {
|
|
1102
|
-
/** path to swagger schema */
|
|
1103
|
-
input: string;
|
|
1057
|
+
/** path to swagger schema */input: string;
|
|
1104
1058
|
/**
|
|
1105
1059
|
* generate separated files for http client, data contracts, and routes
|
|
1106
1060
|
* @default false
|
|
@@ -1111,10 +1065,8 @@ interface GenerateApiConfiguration {
|
|
|
1111
1065
|
* may be set to `false` to skip writing content to disk; in this case
|
|
1112
1066
|
* the `files` array on the return value will contain the generated contents.
|
|
1113
1067
|
*/
|
|
1114
|
-
output: string | false;
|
|
1115
|
-
|
|
1116
|
-
url: string;
|
|
1117
|
-
/** swagger schema JSON */
|
|
1068
|
+
output: string | false; /** url to swagger schema */
|
|
1069
|
+
url: string; /** swagger schema JSON */
|
|
1118
1070
|
spec: unknown;
|
|
1119
1071
|
/**
|
|
1120
1072
|
* file name for the generated API module
|
|
@@ -1127,95 +1079,57 @@ interface GenerateApiConfiguration {
|
|
|
1127
1079
|
*/
|
|
1128
1080
|
templates: string;
|
|
1129
1081
|
templatePaths: {
|
|
1130
|
-
/** `templates/base` */
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
|
|
1134
|
-
/** `templates/modular` */
|
|
1135
|
-
modular: string;
|
|
1136
|
-
/** usage path if `--templates` option is not set */
|
|
1137
|
-
original: string;
|
|
1138
|
-
/** custom path to templates (`--templates`) */
|
|
1082
|
+
/** `templates/base` */base: string; /** `templates/default` */
|
|
1083
|
+
default: string; /** `templates/modular` */
|
|
1084
|
+
modular: string; /** usage path if `--templates` option is not set */
|
|
1085
|
+
original: string; /** custom path to templates (`--templates`) */
|
|
1139
1086
|
custom: string | null;
|
|
1140
|
-
};
|
|
1141
|
-
/**
|
|
1142
|
-
authorizationToken?: string;
|
|
1143
|
-
/** generate additional information about request responses and error typings */
|
|
1087
|
+
}; /** authorisation token for private swagger schema access */
|
|
1088
|
+
authorizationToken?: string; /** generate additional information about request responses and error typings */
|
|
1144
1089
|
generateResponses: boolean;
|
|
1145
1090
|
/**
|
|
1146
1091
|
* use "default" response status code as success response.
|
|
1147
1092
|
* some swagger schemas treat "default" as a successful response.
|
|
1148
1093
|
*/
|
|
1149
|
-
defaultResponseAsSuccess: boolean;
|
|
1150
|
-
/** generate
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
originalSchema: object;
|
|
1160
|
-
/** map of schema component references */
|
|
1161
|
-
componentsMap: Record<string, SchemaComponent>;
|
|
1162
|
-
/** flag indicating the schema was converted from Swagger 2.0 */
|
|
1163
|
-
convertedFromSwagger2: boolean;
|
|
1164
|
-
/** determines which path index should be used for routes separation */
|
|
1165
|
-
moduleNameIndex: number;
|
|
1166
|
-
/** use the first tag for the module name */
|
|
1167
|
-
moduleNameFirstTag: boolean;
|
|
1168
|
-
/** extra templates */
|
|
1094
|
+
defaultResponseAsSuccess: boolean; /** generate type definitions for API routes */
|
|
1095
|
+
generateRouteTypes: boolean; /** generate an API client */
|
|
1096
|
+
generateClient: boolean; /** generate all "enum" types as union types (T1 | T2 | TN) */
|
|
1097
|
+
generateUnionEnums: boolean; /** parsed swagger schema */
|
|
1098
|
+
swaggerSchema: object; /** original swagger schema */
|
|
1099
|
+
originalSchema: object; /** map of schema component references */
|
|
1100
|
+
componentsMap: Record<string, SchemaComponent>; /** flag indicating the schema was converted from Swagger 2.0 */
|
|
1101
|
+
convertedFromSwagger2: boolean; /** determines which path index should be used for routes separation */
|
|
1102
|
+
moduleNameIndex: number; /** use the first tag for the module name */
|
|
1103
|
+
moduleNameFirstTag: boolean; /** extra templates */
|
|
1169
1104
|
extraTemplates: {
|
|
1170
1105
|
name: string;
|
|
1171
1106
|
path: string;
|
|
1172
|
-
}[];
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
typePrefix: string;
|
|
1185
|
-
/** suffix string value for type names */
|
|
1186
|
-
typeSuffix: string;
|
|
1187
|
-
/** prefix string value for enum keys */
|
|
1188
|
-
enumKeyPrefix: string;
|
|
1189
|
-
/** suffix string value for enum keys */
|
|
1190
|
-
enumKeySuffix: string;
|
|
1191
|
-
/** fix up small errors in the swagger source definition */
|
|
1192
|
-
patch: boolean;
|
|
1193
|
-
/** remove output directory before generating */
|
|
1194
|
-
cleanOutput: boolean;
|
|
1195
|
-
/** output debug messages */
|
|
1107
|
+
}[]; /** extract request params to data contract */
|
|
1108
|
+
extractRequestParams: boolean; /** unwrap the data item from the response */
|
|
1109
|
+
unwrapResponseData: boolean; /** sort data contracts in alphabetical order */
|
|
1110
|
+
sortTypes: boolean; /** sort routes in alphabetical order */
|
|
1111
|
+
sortRoutes: boolean; /** ability to send HttpClient instance to Api constructor */
|
|
1112
|
+
singleHttpClient: boolean; /** prefix string value for type names */
|
|
1113
|
+
typePrefix: string; /** suffix string value for type names */
|
|
1114
|
+
typeSuffix: string; /** prefix string value for enum keys */
|
|
1115
|
+
enumKeyPrefix: string; /** suffix string value for enum keys */
|
|
1116
|
+
enumKeySuffix: string; /** fix up small errors in the swagger source definition */
|
|
1117
|
+
patch: boolean; /** remove output directory before generating */
|
|
1118
|
+
cleanOutput: boolean; /** output debug messages */
|
|
1196
1119
|
debug: boolean;
|
|
1197
1120
|
/**
|
|
1198
1121
|
* generate array types as Array<Type>
|
|
1199
1122
|
* @default false
|
|
1200
1123
|
*/
|
|
1201
|
-
anotherArrayType: boolean;
|
|
1202
|
-
/**
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
|
|
1206
|
-
/**
|
|
1207
|
-
|
|
1208
|
-
/**
|
|
1209
|
-
|
|
1210
|
-
/** customise code generation constructs */
|
|
1211
|
-
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
|
|
1212
|
-
/** extract response body type to data contract */
|
|
1213
|
-
extractResponseBody: boolean;
|
|
1214
|
-
/** extract response error type to data contract */
|
|
1215
|
-
extractResponseError: boolean;
|
|
1216
|
-
/** extract all enums from nested types/interfaces to `enum` construction */
|
|
1217
|
-
extractEnums: boolean;
|
|
1218
|
-
/** extract all enums from inline interface/type content to typescript enum construction */
|
|
1124
|
+
anotherArrayType: boolean; /** extract request body type to data contract */
|
|
1125
|
+
extractRequestBody: boolean; /** generated http client type */
|
|
1126
|
+
httpClientType: "axios" | "fetch"; /** generate readonly properties */
|
|
1127
|
+
addReadonly: boolean; /** customise primitive type mappings */
|
|
1128
|
+
primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial<PrimitiveTypeStruct>; /** customise code generation constructs */
|
|
1129
|
+
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>; /** extract response body type to data contract */
|
|
1130
|
+
extractResponseBody: boolean; /** extract response error type to data contract */
|
|
1131
|
+
extractResponseError: boolean; /** extract all enums from nested types/interfaces to `enum` construction */
|
|
1132
|
+
extractEnums: boolean; /** extract all enums from inline interface/type content to typescript enum construction */
|
|
1219
1133
|
extractResponses: boolean;
|
|
1220
1134
|
/**
|
|
1221
1135
|
* prefix string value needed to fix invalid type names
|
|
@@ -1236,52 +1150,38 @@ interface GenerateApiConfiguration {
|
|
|
1236
1150
|
* generate js api module with declaration file
|
|
1237
1151
|
* @default false
|
|
1238
1152
|
*/
|
|
1239
|
-
toJS: boolean;
|
|
1240
|
-
/** disable throwing on a non-successful response */
|
|
1153
|
+
toJS: boolean; /** disable throwing on a non-successful response */
|
|
1241
1154
|
disableThrowOnError: boolean;
|
|
1242
1155
|
/**
|
|
1243
1156
|
* output only errors to console
|
|
1244
1157
|
* @default false
|
|
1245
1158
|
*/
|
|
1246
|
-
silent: boolean;
|
|
1247
|
-
/**
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
|
|
1251
|
-
/**
|
|
1252
|
-
|
|
1253
|
-
/** ts compiler configuration object (for --to-js option) */
|
|
1254
|
-
compilerTsConfig: Record<string, unknown>;
|
|
1255
|
-
/** enum key resolver name */
|
|
1256
|
-
enumKeyResolverName: string;
|
|
1257
|
-
/** type name resolver name */
|
|
1258
|
-
typeNameResolverName: string;
|
|
1259
|
-
/** specific argument name resolver name */
|
|
1159
|
+
silent: boolean; /** hooks for customising the generation process */
|
|
1160
|
+
hooks: Partial<Hooks>; /** use enum names as values */
|
|
1161
|
+
enumNamesAsValues: boolean; /** package version */
|
|
1162
|
+
version: string; /** ts compiler configuration object (for --to-js option) */
|
|
1163
|
+
compilerTsConfig: Record<string, unknown>; /** enum key resolver name */
|
|
1164
|
+
enumKeyResolverName: string; /** type name resolver name */
|
|
1165
|
+
typeNameResolverName: string; /** specific argument name resolver name */
|
|
1260
1166
|
specificArgNameResolverName: string;
|
|
1261
1167
|
/**
|
|
1262
1168
|
* custom ts->* translator
|
|
1263
1169
|
* do not use constructor args, just send class reference
|
|
1264
1170
|
*/
|
|
1265
|
-
customTranslator?: new () => Translator;
|
|
1266
|
-
/**
|
|
1267
|
-
constants: typeof constants_d_exports;
|
|
1268
|
-
/** code generation constructs for TypeScript */
|
|
1171
|
+
customTranslator?: new () => Translator; /** internal constants */
|
|
1172
|
+
constants: typeof constants_d_exports; /** code generation constructs for TypeScript */
|
|
1269
1173
|
Ts: CodeGenConstruct;
|
|
1270
1174
|
/**
|
|
1271
1175
|
* swagger schema type -> typescript type
|
|
1272
1176
|
* https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
|
|
1273
1177
|
*/
|
|
1274
|
-
primitiveTypes: PrimitiveTypeStruct;
|
|
1275
|
-
/** built-in template info */
|
|
1178
|
+
primitiveTypes: PrimitiveTypeStruct; /** built-in template info */
|
|
1276
1179
|
templateInfos: {
|
|
1277
1180
|
name: string;
|
|
1278
1181
|
fileName: string;
|
|
1279
|
-
}[];
|
|
1280
|
-
/**
|
|
1281
|
-
|
|
1282
|
-
/** range of HTTP status codes treated as success */
|
|
1283
|
-
successResponseStatusRange: [number, number];
|
|
1284
|
-
/** custom schema parsers */
|
|
1182
|
+
}[]; /** supported template file extensions */
|
|
1183
|
+
templateExtensions: string[]; /** range of HTTP status codes treated as success */
|
|
1184
|
+
successResponseStatusRange: [number, number]; /** custom schema parsers */
|
|
1285
1185
|
schemaParsers?: {
|
|
1286
1186
|
complexOneOf?: MonoSchemaParser;
|
|
1287
1187
|
complexAllOf?: MonoSchemaParser;
|
|
@@ -1293,21 +1193,17 @@ interface GenerateApiConfiguration {
|
|
|
1293
1193
|
primitive?: MonoSchemaParser;
|
|
1294
1194
|
discriminator?: MonoSchemaParser;
|
|
1295
1195
|
array?: MonoSchemaParser;
|
|
1296
|
-
};
|
|
1297
|
-
/** internal options for templates */
|
|
1196
|
+
}; /** internal options for templates */
|
|
1298
1197
|
internalTemplateOptions: {
|
|
1299
1198
|
addUtilRequiredKeysType: boolean;
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1302
|
-
componentTypeNameResolver: ComponentTypeNameResolver;
|
|
1303
|
-
/** generated file names */
|
|
1199
|
+
}; /** resolver for component type names */
|
|
1200
|
+
componentTypeNameResolver: ComponentTypeNameResolver; /** generated file names */
|
|
1304
1201
|
fileNames: {
|
|
1305
1202
|
dataContracts: string;
|
|
1306
1203
|
routeTypes: string;
|
|
1307
1204
|
httpClient: string;
|
|
1308
1205
|
outOfModuleApi: string;
|
|
1309
|
-
};
|
|
1310
|
-
/** Record<templateName, templateContent> */
|
|
1206
|
+
}; /** Record<templateName, templateContent> */
|
|
1311
1207
|
templatesToRender: {
|
|
1312
1208
|
api: string;
|
|
1313
1209
|
dataContracts: string;
|
|
@@ -1319,16 +1215,11 @@ interface GenerateApiConfiguration {
|
|
|
1319
1215
|
typeDataContract: string;
|
|
1320
1216
|
enumDataContract: string;
|
|
1321
1217
|
objectFieldJsDoc: string;
|
|
1322
|
-
};
|
|
1323
|
-
/**
|
|
1324
|
-
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1327
|
-
/** configuration for fetching swagger schema requests */
|
|
1328
|
-
requestOptions?: Partial<RequestInit>;
|
|
1329
|
-
/** extra configuration for extracting type names operations */
|
|
1330
|
-
extractingOptions: Partial<ExtractingOptions>;
|
|
1331
|
-
/** update configuration object during generation */
|
|
1218
|
+
}; /** map of duplicate route names */
|
|
1219
|
+
routeNameDuplicatesMap: Map<string, string>; /** name of the main exported class */
|
|
1220
|
+
apiClassName: string; /** configuration for fetching swagger schema requests */
|
|
1221
|
+
requestOptions?: Partial<RequestInit>; /** extra configuration for extracting type names operations */
|
|
1222
|
+
extractingOptions: Partial<ExtractingOptions>; /** update configuration object during generation */
|
|
1332
1223
|
update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
|
|
1333
1224
|
};
|
|
1334
1225
|
modelTypes: ModelType[];
|
|
@@ -1346,8 +1237,7 @@ interface GenerateApiConfiguration {
|
|
|
1346
1237
|
requestOptions?: Partial<RequestInit>;
|
|
1347
1238
|
utils: {
|
|
1348
1239
|
formatDescription: (description: string, inline?: boolean) => string;
|
|
1349
|
-
internalCase: (value: string) => string;
|
|
1350
|
-
/** @deprecated */
|
|
1240
|
+
internalCase: (value: string) => string; /** @deprecated */
|
|
1351
1241
|
classNameCase: (value: string) => string;
|
|
1352
1242
|
pascalCase: (value: string) => string;
|
|
1353
1243
|
getInlineParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => string;
|
|
@@ -1360,16 +1250,13 @@ interface GenerateApiConfiguration {
|
|
|
1360
1250
|
fmtToJSDocLine: (line: string, params?: {
|
|
1361
1251
|
eol?: boolean;
|
|
1362
1252
|
}) => string;
|
|
1363
|
-
_:
|
|
1253
|
+
_: typeof es_toolkit0 & typeof es_toolkit_compat0;
|
|
1364
1254
|
require: (path: string) => unknown;
|
|
1365
1255
|
};
|
|
1366
1256
|
}
|
|
1367
1257
|
type FileInfo = {
|
|
1368
|
-
/** @example myFilename */
|
|
1369
|
-
|
|
1370
|
-
/** @example .d.ts */
|
|
1371
|
-
fileExtension: string;
|
|
1372
|
-
/** content of the file */
|
|
1258
|
+
/** @example myFilename */fileName: string; /** @example .d.ts */
|
|
1259
|
+
fileExtension: string; /** content of the file */
|
|
1373
1260
|
fileContent: string;
|
|
1374
1261
|
};
|
|
1375
1262
|
interface GenerateApiOutput {
|
|
@@ -1381,7 +1268,7 @@ interface GenerateApiOutput {
|
|
|
1381
1268
|
content: string;
|
|
1382
1269
|
withPrefix: boolean;
|
|
1383
1270
|
}) => void;
|
|
1384
|
-
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<
|
|
1271
|
+
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta.EtaConfig>) => Promise<string> | string;
|
|
1385
1272
|
getTemplate: (params: {
|
|
1386
1273
|
fileName?: string;
|
|
1387
1274
|
name?: string;
|
|
@@ -1453,15 +1340,10 @@ declare class CodeGenConfig {
|
|
|
1453
1340
|
sortTypes: boolean;
|
|
1454
1341
|
sortRoutes: boolean;
|
|
1455
1342
|
templatePaths: {
|
|
1456
|
-
/** `templates/base` */
|
|
1457
|
-
|
|
1458
|
-
/**
|
|
1459
|
-
|
|
1460
|
-
/** `templates/modular` */
|
|
1461
|
-
modular: string;
|
|
1462
|
-
/** usage path if `--templates` option is not set */
|
|
1463
|
-
original: string;
|
|
1464
|
-
/** custom path to templates (`--templates`) */
|
|
1343
|
+
/** `templates/base` */base: string; /** `templates/default` */
|
|
1344
|
+
default: string; /** `templates/modular` */
|
|
1345
|
+
modular: string; /** usage path if `--templates` option is not set */
|
|
1346
|
+
original: string; /** custom path to templates (`--templates`) */
|
|
1465
1347
|
custom: string;
|
|
1466
1348
|
};
|
|
1467
1349
|
/** Record<templateName, templateContent> */
|
|
@@ -1774,8 +1656,8 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1774
1656
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
1775
1657
|
Tuple: (values: unknown[]) => string;
|
|
1776
1658
|
};
|
|
1777
|
-
formatDescription: (description:
|
|
1778
|
-
internalCase: typeof
|
|
1659
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
1660
|
+
internalCase: typeof es_toolkit_compat0.camelCase;
|
|
1779
1661
|
classNameCase: typeof pascalCase;
|
|
1780
1662
|
pascalCase: typeof pascalCase;
|
|
1781
1663
|
getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
@@ -1803,7 +1685,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1803
1685
|
eol?: boolean | undefined;
|
|
1804
1686
|
}) => string;
|
|
1805
1687
|
NameResolver: typeof NameResolver;
|
|
1806
|
-
_:
|
|
1688
|
+
_: Record<string, unknown>;
|
|
1807
1689
|
require: (packageOrPath: string) => any;
|
|
1808
1690
|
};
|
|
1809
1691
|
};
|