swagger-typescript-api 13.0.11 → 13.0.13
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-R4CYI34W.js → chunk-O6K2HOIW.js} +2 -2
- package/dist/chunk-O6K2HOIW.js.map +1 -0
- package/dist/{chunk-3OGOYA5P.cjs → chunk-T7GDAZLY.cjs} +2 -2
- package/dist/chunk-T7GDAZLY.cjs.map +1 -0
- package/dist/cli.cjs +9 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +9 -9
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +4 -4
- package/dist/lib.js +1 -1
- package/dist/types.d.cts +1818 -0
- package/dist/types.d.ts +1818 -0
- package/package.json +9 -10
- package/cli/index.d.ts +0 -35
- package/dist/chunk-3OGOYA5P.cjs.map +0 -1
- package/dist/chunk-R4CYI34W.js.map +0 -1
- package/index.d.ts +0 -784
package/index.d.ts
DELETED
|
@@ -1,784 +0,0 @@
|
|
|
1
|
-
import type { MonoSchemaParser } from "./src/schema-parser/mono-schema-parser";
|
|
2
|
-
|
|
3
|
-
type HttpClientType = "axios" | "fetch";
|
|
4
|
-
|
|
5
|
-
interface GenerateApiParamsBase {
|
|
6
|
-
/**
|
|
7
|
-
* default 'api.ts'
|
|
8
|
-
*/
|
|
9
|
-
name?: string;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* name of the main exported class
|
|
13
|
-
*/
|
|
14
|
-
apiClassName?: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* path to folder where will be located the created api module.
|
|
18
|
-
*
|
|
19
|
-
* may set to `false` to skip writing content to disk. in this case,
|
|
20
|
-
* you may access the `files` on the return value.
|
|
21
|
-
*/
|
|
22
|
-
output?: string | false;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* path to folder containing templates (default: ./src/templates)
|
|
26
|
-
*/
|
|
27
|
-
templates?: string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* generate all "enum" types as union types (T1 | T2 | TN) (default: false)
|
|
31
|
-
*/
|
|
32
|
-
generateUnionEnums?: boolean;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* generate type definitions for API routes (default: false)
|
|
36
|
-
*/
|
|
37
|
-
generateRouteTypes?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* do not generate an API class
|
|
41
|
-
*/
|
|
42
|
-
generateClient?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* generated http client type
|
|
45
|
-
*/
|
|
46
|
-
httpClientType?: HttpClientType;
|
|
47
|
-
/**
|
|
48
|
-
* use "default" response status code as success response too.
|
|
49
|
-
* some swagger schemas use "default" response status code as success response type by default.
|
|
50
|
-
*/
|
|
51
|
-
defaultResponseAsSuccess?: boolean;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* generate additional information about request responses
|
|
55
|
-
* also add typings for bad responses
|
|
56
|
-
*/
|
|
57
|
-
generateResponses?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* unwrap the data item from the response
|
|
61
|
-
*/
|
|
62
|
-
unwrapResponseData?: boolean;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* sort data contracts in alphabetical order
|
|
66
|
-
*/
|
|
67
|
-
sortTypes?: boolean;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* sort routes in alphabetical order
|
|
71
|
-
*/
|
|
72
|
-
sortRoutes?: boolean;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* generate js api module with declaration file (default: false)
|
|
76
|
-
*/
|
|
77
|
-
toJS?: boolean;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* determines which path index should be used for routes separation
|
|
81
|
-
*/
|
|
82
|
-
moduleNameIndex?: number;
|
|
83
|
-
/**
|
|
84
|
-
* users operation's first tag for route separation
|
|
85
|
-
*/
|
|
86
|
-
moduleNameFirstTag?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* disabled SSL check
|
|
89
|
-
*/
|
|
90
|
-
disableStrictSSL?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* disabled Proxy
|
|
93
|
-
*/
|
|
94
|
-
disableProxy?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* generate separated files for http client, data contracts, and routes (default: false)
|
|
97
|
-
*/
|
|
98
|
-
modular?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* extract request params to data contract (Also combine path params and query params into one object)
|
|
101
|
-
*/
|
|
102
|
-
extractRequestParams?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* extract request body type to data contract
|
|
105
|
-
*/
|
|
106
|
-
extractRequestBody?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* extract response body type to data contract
|
|
109
|
-
*/
|
|
110
|
-
extractResponseBody?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* extract response error type to data contract
|
|
113
|
-
*/
|
|
114
|
-
extractResponseError?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* prettier configuration
|
|
117
|
-
*/
|
|
118
|
-
prettier?: object;
|
|
119
|
-
/**
|
|
120
|
-
* Output only errors to console (default: false)
|
|
121
|
-
*/
|
|
122
|
-
silent?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* default type for empty response schema (default: "void")
|
|
125
|
-
*/
|
|
126
|
-
defaultResponseType?: string;
|
|
127
|
-
/**
|
|
128
|
-
* Ability to send HttpClient instance to Api constructor
|
|
129
|
-
*/
|
|
130
|
-
singleHttpClient?: boolean;
|
|
131
|
-
cleanOutput?: boolean;
|
|
132
|
-
enumNamesAsValues?: boolean;
|
|
133
|
-
|
|
134
|
-
hooks?: Partial<Hooks>;
|
|
135
|
-
/**
|
|
136
|
-
* extra templates
|
|
137
|
-
*/
|
|
138
|
-
extraTemplates?: { name: string; path: string }[];
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* fix up small errors in the swagger source definition
|
|
142
|
-
*/
|
|
143
|
-
patch?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* authorization token
|
|
146
|
-
*/
|
|
147
|
-
authorizationToken?: string;
|
|
148
|
-
/**
|
|
149
|
-
* generate readonly properties (default: false)
|
|
150
|
-
*/
|
|
151
|
-
addReadonly?: boolean;
|
|
152
|
-
|
|
153
|
-
primitiveTypeConstructs?: (
|
|
154
|
-
struct: PrimitiveTypeStruct,
|
|
155
|
-
) => Partial<PrimitiveTypeStruct>;
|
|
156
|
-
|
|
157
|
-
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
|
|
158
|
-
|
|
159
|
-
/** extract all enums from nested types\interfaces to `enum` construction */
|
|
160
|
-
extractEnums?: boolean;
|
|
161
|
-
|
|
162
|
-
/** prefix string value needed to fix invalid type names (default: 'Type') */
|
|
163
|
-
fixInvalidTypeNamePrefix?: string;
|
|
164
|
-
|
|
165
|
-
/** prefix string value needed to fix invalid enum keys (default: 'Value') */
|
|
166
|
-
fixInvalidEnumKeyPrefix?: string;
|
|
167
|
-
|
|
168
|
-
/** prefix string value for enum keys */
|
|
169
|
-
enumKeyPrefix?: string;
|
|
170
|
-
|
|
171
|
-
/** suffix string value for enum keys */
|
|
172
|
-
enumKeySuffix?: string;
|
|
173
|
-
|
|
174
|
-
/** prefix string value for type names */
|
|
175
|
-
typePrefix?: string;
|
|
176
|
-
|
|
177
|
-
/** suffix string value for type names */
|
|
178
|
-
typeSuffix?: string;
|
|
179
|
-
|
|
180
|
-
/** extra configuration for extracting type names operations */
|
|
181
|
-
extractingOptions?: Partial<ExtractingOptions>;
|
|
182
|
-
|
|
183
|
-
/** configuration for fetching swagger schema requests */
|
|
184
|
-
requestOptions?: null | Partial<RequestInit>;
|
|
185
|
-
|
|
186
|
-
/** ts compiler configuration object (for --to-js option) */
|
|
187
|
-
compilerTsConfig?: Record<string, any>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* custom ts->* translator
|
|
191
|
-
* do not use constructor args, it can break functionality of this property, just send class reference
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* import { Translator } from "swagger-typescript-api/src/translators/translator";
|
|
196
|
-
*
|
|
197
|
-
* class MyTranslator extends Translator {
|
|
198
|
-
*
|
|
199
|
-
* translate({ fileName, fileExtension, fileContent }) {
|
|
200
|
-
* this.codeFormatter.format()
|
|
201
|
-
* this.config.
|
|
202
|
-
* this.logger.
|
|
203
|
-
*
|
|
204
|
-
* return [
|
|
205
|
-
* {
|
|
206
|
-
* fileName,
|
|
207
|
-
* fileExtension,
|
|
208
|
-
* fileContent,
|
|
209
|
-
* }
|
|
210
|
-
* ]
|
|
211
|
-
* }
|
|
212
|
-
* }
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
customTranslator?: new () => typeof import("./src/translators/translator").Translator;
|
|
216
|
-
/** fallback name for enum key resolver */
|
|
217
|
-
enumKeyResolverName?: string;
|
|
218
|
-
/** fallback name for type name resolver */
|
|
219
|
-
typeNameResolverName?: string;
|
|
220
|
-
/** fallback name for specific arg name resolver */
|
|
221
|
-
specificArgNameResolverName?: string;
|
|
222
|
-
schemaParsers?: {
|
|
223
|
-
complexOneOf?: MonoSchemaParser;
|
|
224
|
-
complexAllOf?: MonoSchemaParser;
|
|
225
|
-
complexAnyOf?: MonoSchemaParser;
|
|
226
|
-
complexNot?: MonoSchemaParser;
|
|
227
|
-
enum?: MonoSchemaParser;
|
|
228
|
-
object?: MonoSchemaParser;
|
|
229
|
-
complex?: MonoSchemaParser;
|
|
230
|
-
primitive?: MonoSchemaParser;
|
|
231
|
-
discriminator?: MonoSchemaParser;
|
|
232
|
-
array?: MonoSchemaParser;
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
type CodeGenConstruct = {
|
|
237
|
-
Keyword: {
|
|
238
|
-
Number: string;
|
|
239
|
-
String: string;
|
|
240
|
-
Boolean: string;
|
|
241
|
-
Any: string;
|
|
242
|
-
Void: string;
|
|
243
|
-
Unknown: string;
|
|
244
|
-
Null: string;
|
|
245
|
-
Undefined: string;
|
|
246
|
-
Object: string;
|
|
247
|
-
File: string;
|
|
248
|
-
Date: string;
|
|
249
|
-
Type: string;
|
|
250
|
-
Enum: string;
|
|
251
|
-
Interface: string;
|
|
252
|
-
Array: string;
|
|
253
|
-
Record: string;
|
|
254
|
-
Intersection: string;
|
|
255
|
-
Union: string;
|
|
256
|
-
};
|
|
257
|
-
CodeGenKeyword: {
|
|
258
|
-
UtilRequiredKeys: string;
|
|
259
|
-
};
|
|
260
|
-
ArrayType: (content: any) => string;
|
|
261
|
-
StringValue: (content: any) => string;
|
|
262
|
-
BooleanValue: (content: any) => string;
|
|
263
|
-
NumberValue: (content: any) => string;
|
|
264
|
-
NullValue: (content: any) => string;
|
|
265
|
-
UnionType: (content: any) => string;
|
|
266
|
-
ExpressionGroup: (content: any) => string;
|
|
267
|
-
IntersectionType: (content: any) => string;
|
|
268
|
-
RecordType: (content: any) => string;
|
|
269
|
-
TypeField: (content: any) => string;
|
|
270
|
-
InterfaceDynamicField: (content: any) => string;
|
|
271
|
-
EnumField: (content: any) => string;
|
|
272
|
-
EnumFieldsWrapper: (content: any) => string;
|
|
273
|
-
ObjectWrapper: (content: any) => string;
|
|
274
|
-
MultilineComment: (content: any) => string;
|
|
275
|
-
TypeWithGeneric: (content: any) => string;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
type PrimitiveTypeStructValue =
|
|
279
|
-
| string
|
|
280
|
-
| ((
|
|
281
|
-
schema: Record<string, any>,
|
|
282
|
-
parser: import("./src/schema-parser/schema-parser").SchemaParser,
|
|
283
|
-
) => string);
|
|
284
|
-
|
|
285
|
-
type PrimitiveTypeStruct = Record<
|
|
286
|
-
"integer" | "number" | "boolean" | "object" | "file" | "string" | "array",
|
|
287
|
-
| string
|
|
288
|
-
| ({ $default: PrimitiveTypeStructValue } & Record<
|
|
289
|
-
string,
|
|
290
|
-
PrimitiveTypeStructValue
|
|
291
|
-
>)
|
|
292
|
-
>;
|
|
293
|
-
|
|
294
|
-
interface GenerateApiParamsFromPath extends GenerateApiParamsBase {
|
|
295
|
-
/**
|
|
296
|
-
* path to swagger schema
|
|
297
|
-
*/
|
|
298
|
-
input: string;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
interface GenerateApiParamsFromUrl extends GenerateApiParamsBase {
|
|
302
|
-
/**
|
|
303
|
-
* url to swagger schema
|
|
304
|
-
*/
|
|
305
|
-
url: string;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
interface GenerateApiParamsFromSpecLiteral extends GenerateApiParamsBase {
|
|
309
|
-
/**
|
|
310
|
-
* swagger schema JSON
|
|
311
|
-
*/
|
|
312
|
-
spec: import("swagger-schema-official").Spec;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export type GenerateApiParams =
|
|
316
|
-
| GenerateApiParamsFromPath
|
|
317
|
-
| GenerateApiParamsFromUrl
|
|
318
|
-
| GenerateApiParamsFromSpecLiteral;
|
|
319
|
-
|
|
320
|
-
type BuildRouteParam = {
|
|
321
|
-
/** {bar} */
|
|
322
|
-
$match: string;
|
|
323
|
-
name: string;
|
|
324
|
-
required: boolean;
|
|
325
|
-
type: "string";
|
|
326
|
-
description: string;
|
|
327
|
-
schema: {
|
|
328
|
-
type: string;
|
|
329
|
-
};
|
|
330
|
-
in: "path" | "query";
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
type BuildRoutePath = {
|
|
334
|
-
/** /foo/{bar}/baz */
|
|
335
|
-
originalRoute: string;
|
|
336
|
-
/** /foo/${bar}/baz */
|
|
337
|
-
route: string;
|
|
338
|
-
pathParams: BuildRouteParam[];
|
|
339
|
-
queryParams: BuildRouteParam[];
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
export interface Hooks {
|
|
343
|
-
/** calls before parse\process route path */
|
|
344
|
-
onPreBuildRoutePath: (routePath: string) => string | void;
|
|
345
|
-
/** calls after parse\process route path */
|
|
346
|
-
onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void;
|
|
347
|
-
/** calls before insert path param name into string path interpolation */
|
|
348
|
-
onInsertPathParam: (
|
|
349
|
-
paramName: string,
|
|
350
|
-
index: number,
|
|
351
|
-
arr: BuildRouteParam[],
|
|
352
|
-
resultRoute: string,
|
|
353
|
-
) => string | void;
|
|
354
|
-
/** calls after parse schema component */
|
|
355
|
-
onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
|
|
356
|
-
/** calls before parse any kind of schema */
|
|
357
|
-
onPreParseSchema: (
|
|
358
|
-
originalSchema: any,
|
|
359
|
-
typeName: string,
|
|
360
|
-
schemaType: string,
|
|
361
|
-
) => any;
|
|
362
|
-
/** calls after parse any kind of schema */
|
|
363
|
-
onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
|
|
364
|
-
/** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */
|
|
365
|
-
onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void | false;
|
|
366
|
-
/** Start point of work this tool (after fetching schema) */
|
|
367
|
-
onInit?: <C extends GenerateApiConfiguration["config"]>(
|
|
368
|
-
configuration: C,
|
|
369
|
-
codeGenProcess: import("./src/code-gen-process").CodeGenProcess,
|
|
370
|
-
) => C | void;
|
|
371
|
-
/** customize configuration object before sending it to ETA templates */
|
|
372
|
-
onPrepareConfig?: <C extends GenerateApiConfiguration>(
|
|
373
|
-
currentConfiguration: C,
|
|
374
|
-
) => C | void;
|
|
375
|
-
/** customize route name as you need */
|
|
376
|
-
onCreateRouteName?: (
|
|
377
|
-
routeNameInfo: RouteNameInfo,
|
|
378
|
-
rawRouteInfo: RawRouteInfo,
|
|
379
|
-
) => RouteNameInfo | void;
|
|
380
|
-
/** customize request params (path params, query params) */
|
|
381
|
-
onCreateRequestParams?: (
|
|
382
|
-
rawType: SchemaComponent["rawTypeData"],
|
|
383
|
-
) => SchemaComponent["rawTypeData"] | void;
|
|
384
|
-
/** customize name of model type */
|
|
385
|
-
onFormatTypeName?: (
|
|
386
|
-
typeName: string,
|
|
387
|
-
rawTypeName?: string,
|
|
388
|
-
schemaType?: "type-name" | "enum-key",
|
|
389
|
-
) => string | void;
|
|
390
|
-
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
|
|
391
|
-
onFormatRouteName?: (
|
|
392
|
-
routeInfo: RawRouteInfo,
|
|
393
|
-
templateRouteName: string,
|
|
394
|
-
) => string | void;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
export type RouteNameRouteInfo = {};
|
|
398
|
-
|
|
399
|
-
export type RouteNameInfo = {
|
|
400
|
-
usage: string;
|
|
401
|
-
original: string;
|
|
402
|
-
duplicate: boolean;
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
export type SchemaTypePrimitiveContent = {
|
|
406
|
-
$parsedSchema: boolean;
|
|
407
|
-
schemaType: string;
|
|
408
|
-
type: string;
|
|
409
|
-
typeIdentifier: string;
|
|
410
|
-
name?: any;
|
|
411
|
-
description: string;
|
|
412
|
-
content: string;
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
export type SchemaTypeObjectContent = {
|
|
416
|
-
$$raw: {
|
|
417
|
-
type: string;
|
|
418
|
-
required: boolean;
|
|
419
|
-
$parsed: SchemaTypePrimitiveContent;
|
|
420
|
-
};
|
|
421
|
-
isRequired: boolean;
|
|
422
|
-
field: string;
|
|
423
|
-
}[];
|
|
424
|
-
|
|
425
|
-
export type SchemaTypeEnumContent = {
|
|
426
|
-
key: string;
|
|
427
|
-
type: string;
|
|
428
|
-
value: string;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export interface ParsedSchema<C> {
|
|
432
|
-
$parsedSchema: boolean;
|
|
433
|
-
schemaType: string;
|
|
434
|
-
type: string;
|
|
435
|
-
typeIdentifier: string;
|
|
436
|
-
name: string;
|
|
437
|
-
description?: string;
|
|
438
|
-
allFieldsAreOptional?: boolean;
|
|
439
|
-
content: C;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
export interface PathArgInfo {
|
|
443
|
-
name: string;
|
|
444
|
-
optional: boolean;
|
|
445
|
-
type: string;
|
|
446
|
-
description?: string;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
export interface SchemaComponent {
|
|
450
|
-
$ref: string;
|
|
451
|
-
typeName: string;
|
|
452
|
-
rawTypeData?: {
|
|
453
|
-
type: string;
|
|
454
|
-
required?: string[];
|
|
455
|
-
properties?: Record<
|
|
456
|
-
string,
|
|
457
|
-
{
|
|
458
|
-
name?: string;
|
|
459
|
-
type: string;
|
|
460
|
-
required: boolean;
|
|
461
|
-
$parsed?: SchemaTypePrimitiveContent;
|
|
462
|
-
}
|
|
463
|
-
>;
|
|
464
|
-
discriminator?: {
|
|
465
|
-
propertyName?: string;
|
|
466
|
-
};
|
|
467
|
-
$parsed: ParsedSchema<
|
|
468
|
-
| SchemaTypeObjectContent
|
|
469
|
-
| SchemaTypeEnumContent
|
|
470
|
-
| SchemaTypePrimitiveContent
|
|
471
|
-
>;
|
|
472
|
-
};
|
|
473
|
-
componentName: "schemas" | "paths";
|
|
474
|
-
typeData: ParsedSchema<
|
|
475
|
-
SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent
|
|
476
|
-
> | null;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export enum RequestContentKind {
|
|
480
|
-
JSON = "JSON",
|
|
481
|
-
URL_ENCODED = "URL_ENCODED",
|
|
482
|
-
FORM_DATA = "FORM_DATA",
|
|
483
|
-
IMAGE = "IMAGE",
|
|
484
|
-
OTHER = "OTHER",
|
|
485
|
-
TEXT = "TEXT",
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
export interface RequestResponseInfo {
|
|
489
|
-
contentTypes: string[];
|
|
490
|
-
contentKind: RequestContentKind;
|
|
491
|
-
type: string;
|
|
492
|
-
description: string;
|
|
493
|
-
status: string | number;
|
|
494
|
-
isSuccess: boolean;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
export type RawRouteInfo = {
|
|
498
|
-
operationId: string;
|
|
499
|
-
method: string;
|
|
500
|
-
route: string;
|
|
501
|
-
moduleName: string;
|
|
502
|
-
responsesTypes: RequestResponseInfo[];
|
|
503
|
-
description?: string;
|
|
504
|
-
tags?: string[];
|
|
505
|
-
summary?: string;
|
|
506
|
-
responses?: import("swagger-schema-official").Spec["responses"];
|
|
507
|
-
produces?: string[];
|
|
508
|
-
requestBody?: object;
|
|
509
|
-
consumes?: string[];
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
export interface ParsedRoute {
|
|
513
|
-
id: string;
|
|
514
|
-
jsDocLines: string;
|
|
515
|
-
namespace: string;
|
|
516
|
-
request: Request;
|
|
517
|
-
response: Response;
|
|
518
|
-
routeName: RouteNameInfo;
|
|
519
|
-
raw: RawRouteInfo;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export type ModelType = {
|
|
523
|
-
typeIdentifier: string;
|
|
524
|
-
name: string;
|
|
525
|
-
rawContent: string;
|
|
526
|
-
description: string;
|
|
527
|
-
content: string;
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
export enum SCHEMA_TYPES {
|
|
531
|
-
ARRAY = "array",
|
|
532
|
-
OBJECT = "object",
|
|
533
|
-
ENUM = "enum",
|
|
534
|
-
REF = "$ref",
|
|
535
|
-
PRIMITIVE = "primitive",
|
|
536
|
-
COMPLEX = "complex",
|
|
537
|
-
COMPLEX_ONE_OF = "oneOf",
|
|
538
|
-
COMPLEX_ANY_OF = "anyOf",
|
|
539
|
-
COMPLEX_ALL_OF = "allOf",
|
|
540
|
-
COMPLEX_NOT = "not",
|
|
541
|
-
COMPLEX_UNKNOWN = "__unknown",
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
type MAIN_SCHEMA_TYPES =
|
|
545
|
-
| SCHEMA_TYPES.PRIMITIVE
|
|
546
|
-
| SCHEMA_TYPES.OBJECT
|
|
547
|
-
| SCHEMA_TYPES.ENUM;
|
|
548
|
-
|
|
549
|
-
type ExtractingOptions = {
|
|
550
|
-
requestBodySuffix: string[];
|
|
551
|
-
responseBodySuffix: string[];
|
|
552
|
-
responseErrorSuffix: string[];
|
|
553
|
-
requestParamsSuffix: string[];
|
|
554
|
-
enumSuffix: string[];
|
|
555
|
-
discriminatorMappingSuffix: string[];
|
|
556
|
-
discriminatorAbstractPrefix: string[];
|
|
557
|
-
requestBodyNameResolver: (
|
|
558
|
-
name: string,
|
|
559
|
-
reservedNames: string,
|
|
560
|
-
) => string | undefined;
|
|
561
|
-
responseBodyNameResolver: (
|
|
562
|
-
name: string,
|
|
563
|
-
reservedNames: string,
|
|
564
|
-
) => string | undefined;
|
|
565
|
-
responseErrorNameResolver: (
|
|
566
|
-
name: string,
|
|
567
|
-
reservedNames: string,
|
|
568
|
-
) => string | undefined;
|
|
569
|
-
requestParamsNameResolver: (
|
|
570
|
-
name: string,
|
|
571
|
-
reservedNames: string,
|
|
572
|
-
) => string | undefined;
|
|
573
|
-
enumNameResolver: (name: string, reservedNames: string) => string | undefined;
|
|
574
|
-
discriminatorMappingNameResolver: (
|
|
575
|
-
name: string,
|
|
576
|
-
reservedNames: string,
|
|
577
|
-
) => string | undefined;
|
|
578
|
-
discriminatorAbstractResolver: (
|
|
579
|
-
name: string,
|
|
580
|
-
reservedNames: string,
|
|
581
|
-
) => string | undefined;
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
export interface GenerateApiConfiguration {
|
|
585
|
-
apiConfig: {
|
|
586
|
-
baseUrl: string;
|
|
587
|
-
title: string;
|
|
588
|
-
version: string;
|
|
589
|
-
description: string[];
|
|
590
|
-
hasDescription: boolean;
|
|
591
|
-
};
|
|
592
|
-
config: {
|
|
593
|
-
input: string;
|
|
594
|
-
output: string;
|
|
595
|
-
url: string;
|
|
596
|
-
spec: any;
|
|
597
|
-
fileName: string;
|
|
598
|
-
templatePaths: {
|
|
599
|
-
/** `templates/base` */
|
|
600
|
-
base: string;
|
|
601
|
-
/** `templates/default` */
|
|
602
|
-
default: string;
|
|
603
|
-
/** `templates/modular` */
|
|
604
|
-
modular: string;
|
|
605
|
-
/** usage path if `--templates` option is not set */
|
|
606
|
-
original: string;
|
|
607
|
-
/** custom path to templates (`--templates`) */
|
|
608
|
-
custom: string | null;
|
|
609
|
-
};
|
|
610
|
-
authorizationToken?: string;
|
|
611
|
-
generateResponses: boolean;
|
|
612
|
-
defaultResponseAsSuccess: boolean;
|
|
613
|
-
generateRouteTypes: boolean;
|
|
614
|
-
generateClient: boolean;
|
|
615
|
-
generateUnionEnums: boolean;
|
|
616
|
-
swaggerSchema: object;
|
|
617
|
-
originalSchema: object;
|
|
618
|
-
componentsMap: Record<string, SchemaComponent>;
|
|
619
|
-
convertedFromSwagger2: boolean;
|
|
620
|
-
moduleNameIndex: number;
|
|
621
|
-
moduleNameFirstTag: boolean;
|
|
622
|
-
extraTemplates: { name: string; path: string }[];
|
|
623
|
-
disableStrictSSL: boolean;
|
|
624
|
-
disableProxy: boolean;
|
|
625
|
-
extractRequestParams: boolean;
|
|
626
|
-
unwrapResponseData: boolean;
|
|
627
|
-
sortTypes: boolean;
|
|
628
|
-
sortRoutes: boolean;
|
|
629
|
-
singleHttpClient: boolean;
|
|
630
|
-
typePrefix: string;
|
|
631
|
-
typeSuffix: string;
|
|
632
|
-
enumKeyPrefix: string;
|
|
633
|
-
enumKeySuffix: string;
|
|
634
|
-
patch: boolean;
|
|
635
|
-
cleanOutput: boolean;
|
|
636
|
-
debug: boolean;
|
|
637
|
-
anotherArrayType: boolean;
|
|
638
|
-
extractRequestBody: boolean;
|
|
639
|
-
httpClientType: "axios" | "fetch";
|
|
640
|
-
addReadonly: boolean;
|
|
641
|
-
extractResponseBody: boolean;
|
|
642
|
-
extractResponseError: boolean;
|
|
643
|
-
extractEnums: boolean;
|
|
644
|
-
fixInvalidTypeNamePrefix: string;
|
|
645
|
-
fixInvalidEnumKeyPrefix: string;
|
|
646
|
-
defaultResponseType: string;
|
|
647
|
-
toJS: boolean;
|
|
648
|
-
disableThrowOnError: boolean;
|
|
649
|
-
silent: boolean;
|
|
650
|
-
hooks: Hooks;
|
|
651
|
-
enumNamesAsValues: boolean;
|
|
652
|
-
version: string;
|
|
653
|
-
compilerTsConfig: Record<string, any>;
|
|
654
|
-
enumKeyResolverName: string;
|
|
655
|
-
typeNameResolverName: string;
|
|
656
|
-
specificArgNameResolverName: string;
|
|
657
|
-
/** do not use constructor args, it can break functionality of this property, just send class reference */
|
|
658
|
-
customTranslator?: new (
|
|
659
|
-
...args: never[]
|
|
660
|
-
) => typeof import("./src/translators/translator").Translator;
|
|
661
|
-
internalTemplateOptions: {
|
|
662
|
-
addUtilRequiredKeysType: boolean;
|
|
663
|
-
};
|
|
664
|
-
componentTypeNameResolver: typeof import("./src/component-type-name-resolver").ComponentTypeNameResolver;
|
|
665
|
-
fileNames: {
|
|
666
|
-
dataContracts: string;
|
|
667
|
-
routeTypes: string;
|
|
668
|
-
httpClient: string;
|
|
669
|
-
outOfModuleApi: string;
|
|
670
|
-
};
|
|
671
|
-
templatesToRender: {
|
|
672
|
-
api: string;
|
|
673
|
-
dataContracts: string;
|
|
674
|
-
httpClient: string;
|
|
675
|
-
routeTypes: string;
|
|
676
|
-
routeName: string;
|
|
677
|
-
dataContractJsDoc: string;
|
|
678
|
-
interfaceDataContract: string;
|
|
679
|
-
typeDataContract: string;
|
|
680
|
-
enumDataContract: string;
|
|
681
|
-
objectFieldJsDoc: string;
|
|
682
|
-
};
|
|
683
|
-
routeNameDuplicatesMap: Map<string, string>;
|
|
684
|
-
apiClassName: string;
|
|
685
|
-
requestOptions?: RequestInit;
|
|
686
|
-
extractingOptions: ExtractingOptions;
|
|
687
|
-
};
|
|
688
|
-
modelTypes: ModelType[];
|
|
689
|
-
hasFormDataRoutes: boolean;
|
|
690
|
-
hasSecurityRoutes: boolean;
|
|
691
|
-
hasQueryRoutes: boolean;
|
|
692
|
-
generateResponses: boolean;
|
|
693
|
-
routes: {
|
|
694
|
-
outOfModule: ParsedRoute[];
|
|
695
|
-
combined?: {
|
|
696
|
-
moduleName: string;
|
|
697
|
-
routes: ParsedRoute[];
|
|
698
|
-
}[];
|
|
699
|
-
};
|
|
700
|
-
requestOptions?: null | Partial<RequestInit>;
|
|
701
|
-
utils: {
|
|
702
|
-
formatDescription: (description: string, inline?: boolean) => string;
|
|
703
|
-
internalCase: (value: string) => string;
|
|
704
|
-
/** @deprecated */
|
|
705
|
-
classNameCase: (value: string) => string;
|
|
706
|
-
pascalCase: (value: string) => string;
|
|
707
|
-
getInlineParseContent: (
|
|
708
|
-
rawTypeData: SchemaComponent["rawTypeData"],
|
|
709
|
-
typeName?: string,
|
|
710
|
-
) => string;
|
|
711
|
-
getParseContent: (
|
|
712
|
-
rawTypeData: SchemaComponent["rawTypeData"],
|
|
713
|
-
typeName?: string,
|
|
714
|
-
) => ModelType;
|
|
715
|
-
getComponentByRef: (ref: string) => SchemaComponent;
|
|
716
|
-
parseSchema: (
|
|
717
|
-
rawSchema: string | SchemaComponent["rawTypeData"],
|
|
718
|
-
typeName?: string,
|
|
719
|
-
formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,
|
|
720
|
-
) => ModelType;
|
|
721
|
-
formatters: Record<
|
|
722
|
-
MAIN_SCHEMA_TYPES,
|
|
723
|
-
(content: string | object | string[] | object[]) => string
|
|
724
|
-
>;
|
|
725
|
-
inlineExtraFormatters: Record<
|
|
726
|
-
Exclude<MAIN_SCHEMA_TYPES, SCHEMA_TYPES.PRIMITIVE>,
|
|
727
|
-
(schema: ModelType) => string
|
|
728
|
-
>;
|
|
729
|
-
formatModelName: (name: string) => string;
|
|
730
|
-
fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string;
|
|
731
|
-
_: import("lodash").LoDashStatic;
|
|
732
|
-
require: (path: string) => unknown;
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
type FileInfo = {
|
|
737
|
-
/** @example myFilename */
|
|
738
|
-
fileName: string;
|
|
739
|
-
/** @example .d.ts */
|
|
740
|
-
fileExtension: string;
|
|
741
|
-
/** content of the file */
|
|
742
|
-
fileContent: string;
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
export interface GenerateApiOutput {
|
|
746
|
-
configuration: GenerateApiConfiguration;
|
|
747
|
-
files: FileInfo[];
|
|
748
|
-
createFile: (params: {
|
|
749
|
-
path: string;
|
|
750
|
-
fileName: string;
|
|
751
|
-
content: string;
|
|
752
|
-
withPrefix?: boolean;
|
|
753
|
-
}) => void;
|
|
754
|
-
renderTemplate: (
|
|
755
|
-
templateContent: string,
|
|
756
|
-
data: Record<string, unknown>,
|
|
757
|
-
etaOptions?: import("eta/dist/types/config").PartialConfig,
|
|
758
|
-
) => string;
|
|
759
|
-
getTemplate: (params: {
|
|
760
|
-
fileName?: string;
|
|
761
|
-
name?: string;
|
|
762
|
-
path?: string;
|
|
763
|
-
}) => string;
|
|
764
|
-
formatTSContent: (content: string) => Promise<string>;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
export declare function generateApi(
|
|
768
|
-
params: GenerateApiParams,
|
|
769
|
-
): Promise<GenerateApiOutput>;
|
|
770
|
-
|
|
771
|
-
export interface GenerateTemplatesParams {
|
|
772
|
-
cleanOutput?: boolean;
|
|
773
|
-
output?: string;
|
|
774
|
-
httpClientType?: HttpClientType;
|
|
775
|
-
modular?: boolean;
|
|
776
|
-
silent?: boolean;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
export interface GenerateTemplatesOutput
|
|
780
|
-
extends Pick<GenerateApiOutput, "files" | "createFile"> {}
|
|
781
|
-
|
|
782
|
-
export declare function generateTemplates(
|
|
783
|
-
params: GenerateTemplatesParams,
|
|
784
|
-
): Promise<GenerateTemplatesOutput>;
|