open-api-typescript-request-generator 0.0.2 → 0.0.3
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/README.md +7 -7
- package/es/Generator.js +2 -2
- package/es/types.d.ts +157 -157
- package/es/types.js +24 -24
- package/lib/Generator.js +2 -2
- package/lib/types.d.ts +157 -157
- package/lib/types.js +24 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# open-api-typescript-request-generator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Based on the OpenAPI specification, generate request and response type declarations and request method bodies for APIs
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
`npm install open-api-typescript-request-generator`
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Initialize Configuration File
|
|
10
10
|
|
|
11
11
|
`apits-gener init`
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Generate APIs
|
|
15
15
|
|
|
16
16
|
`apits-gener gen`
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Generate Only Specified Name Configuration
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
apits-gener gen --name=test
|
|
@@ -23,5 +23,5 @@ apits-gener gen --name=test
|
|
|
23
23
|
apits-gener gen -n test
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
#
|
|
27
|
-
1.
|
|
26
|
+
# Tips
|
|
27
|
+
1. If you have code formatting requirements, you should ignore the generated code in /api in your configuration
|
package/es/Generator.js
CHANGED
|
@@ -676,9 +676,9 @@ function () {
|
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
code = (0, vtils_1.dedent)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n "], ["\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n "])), genComment(function (title) {
|
|
679
|
-
return "".concat(title, "
|
|
679
|
+
return "".concat(title, " request parameters");
|
|
680
680
|
}), requestDataType.trim(), genComment(function (title) {
|
|
681
|
-
return "".concat(title, "
|
|
681
|
+
return "".concat(title, " response data");
|
|
682
682
|
}), responseDataType.trim(), (0, vtils_1.dedent)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n ", "\n "], ["\n ", "\n ", "\n "])), genComment(function (title) {
|
|
683
683
|
return "".concat(title);
|
|
684
684
|
}), requestFunctionTemplate({
|
package/es/types.d.ts
CHANGED
|
@@ -5,130 +5,130 @@ import { OpenAPIV3 } from 'openapi-types';
|
|
|
5
5
|
import { LiteralUnion, OmitStrict } from 'vtils/types';
|
|
6
6
|
import { ParsedPath } from 'path';
|
|
7
7
|
export declare type requestFunctionTemplateType = (props: RequestFunctionTemplateProps, config?: SyntheticalConfig) => string;
|
|
8
|
-
/**
|
|
9
|
-
/**
|
|
8
|
+
/** Top dependency generation template function */
|
|
9
|
+
/** Generator parameters */
|
|
10
10
|
export declare type topImportTemplateType = () => string;
|
|
11
11
|
export interface GeneratorOptions {
|
|
12
12
|
cwd: string;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** Project information */
|
|
15
15
|
export interface Project {
|
|
16
16
|
/** ID */
|
|
17
17
|
_id: number;
|
|
18
|
-
/**
|
|
18
|
+
/** Name */
|
|
19
19
|
name: string;
|
|
20
|
-
/**
|
|
20
|
+
/** Description */
|
|
21
21
|
desc: string;
|
|
22
|
-
/**
|
|
22
|
+
/** Base path */
|
|
23
23
|
basepath: string;
|
|
24
|
-
/**
|
|
24
|
+
/** Tags */
|
|
25
25
|
tag: string[];
|
|
26
|
-
/**
|
|
26
|
+
/** Environment configuration */
|
|
27
27
|
env: Array<{
|
|
28
|
-
/**
|
|
28
|
+
/** Environment name */
|
|
29
29
|
name: string;
|
|
30
|
-
/**
|
|
30
|
+
/** Environment domain */
|
|
31
31
|
domain: string;
|
|
32
32
|
}>;
|
|
33
|
-
/**
|
|
33
|
+
/** Project token */
|
|
34
34
|
token?: string;
|
|
35
|
-
/**
|
|
35
|
+
/** Category list under the project */
|
|
36
36
|
cat: Category[];
|
|
37
37
|
components?: object[];
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
39
|
+
/** Interface definition */
|
|
40
40
|
export interface Interface {
|
|
41
|
-
/**
|
|
41
|
+
/** Interface ID */
|
|
42
42
|
_id: number;
|
|
43
|
-
/**
|
|
43
|
+
/** Category information (implemented by YTT) */
|
|
44
44
|
_category: OmitStrict<Category, 'list'>;
|
|
45
|
-
/**
|
|
45
|
+
/** Project information (implemented by YTT) */
|
|
46
46
|
_project: Project;
|
|
47
|
-
/**
|
|
47
|
+
/** Interface name */
|
|
48
48
|
title: string;
|
|
49
|
-
/**
|
|
49
|
+
/** Status */
|
|
50
50
|
status: LiteralUnion<'done' | 'undone', string>;
|
|
51
|
-
/**
|
|
51
|
+
/** Interface remarks */
|
|
52
52
|
markdown: string;
|
|
53
|
-
/**
|
|
53
|
+
/** Request path */
|
|
54
54
|
path: string;
|
|
55
|
-
/**
|
|
55
|
+
/** Request method, HEAD and OPTIONS are handled like GET, others like POST */
|
|
56
56
|
method: Method;
|
|
57
|
-
/**
|
|
57
|
+
/** Project ID */
|
|
58
58
|
project_id: number;
|
|
59
|
-
/**
|
|
59
|
+
/** Category ID */
|
|
60
60
|
catid: number;
|
|
61
|
-
/**
|
|
61
|
+
/** Tag list */
|
|
62
62
|
tag: string[];
|
|
63
|
-
/**
|
|
63
|
+
/** Request headers */
|
|
64
64
|
req_headers: Array<{
|
|
65
|
-
/**
|
|
65
|
+
/** Name */
|
|
66
66
|
name: string;
|
|
67
|
-
/**
|
|
67
|
+
/** Value */
|
|
68
68
|
value: string;
|
|
69
|
-
/**
|
|
69
|
+
/** Description */
|
|
70
70
|
desc: string;
|
|
71
|
-
/**
|
|
71
|
+
/** Example */
|
|
72
72
|
example: string;
|
|
73
|
-
/**
|
|
73
|
+
/** Required */
|
|
74
74
|
required: Required;
|
|
75
75
|
}>;
|
|
76
|
-
/**
|
|
76
|
+
/** Path parameters */
|
|
77
77
|
req_params: Array<{
|
|
78
|
-
/**
|
|
78
|
+
/** Name */
|
|
79
79
|
name: string;
|
|
80
|
-
/**
|
|
80
|
+
/** Description */
|
|
81
81
|
desc: string;
|
|
82
|
-
/**
|
|
82
|
+
/** Example */
|
|
83
83
|
example: string;
|
|
84
|
-
/**
|
|
84
|
+
/** Type (YApi-X) */
|
|
85
85
|
type?: RequestParamType;
|
|
86
86
|
}>;
|
|
87
|
-
/**
|
|
87
|
+
/** GET only: query string */
|
|
88
88
|
req_query: Array<{
|
|
89
|
-
/**
|
|
89
|
+
/** Name */
|
|
90
90
|
name: string;
|
|
91
|
-
/**
|
|
91
|
+
/** Description */
|
|
92
92
|
desc: string;
|
|
93
|
-
/**
|
|
93
|
+
/** Example */
|
|
94
94
|
example: string;
|
|
95
|
-
/**
|
|
95
|
+
/** Required */
|
|
96
96
|
required: Required;
|
|
97
|
-
/**
|
|
97
|
+
/** Type (YApi-X) */
|
|
98
98
|
type?: RequestQueryType;
|
|
99
99
|
}>;
|
|
100
|
-
/**
|
|
100
|
+
/** POST only: request content type. No special handling needed for text, file, raw. */
|
|
101
101
|
req_body_type: RequestBodyType;
|
|
102
|
-
/** `req_body_type = json`
|
|
102
|
+
/** Whether it is json schema when `req_body_type = json` */
|
|
103
103
|
req_body_is_json_schema: boolean;
|
|
104
|
-
/** `req_body_type = form`
|
|
104
|
+
/** Request content when `req_body_type = form` */
|
|
105
105
|
req_body_form: Array<{
|
|
106
|
-
/**
|
|
106
|
+
/** Name */
|
|
107
107
|
name: string;
|
|
108
|
-
/**
|
|
108
|
+
/** Type */
|
|
109
109
|
type: RequestFormItemType;
|
|
110
|
-
/**
|
|
110
|
+
/** Description */
|
|
111
111
|
desc: string;
|
|
112
|
-
/**
|
|
112
|
+
/** Example */
|
|
113
113
|
example: string;
|
|
114
|
-
/**
|
|
114
|
+
/** Required */
|
|
115
115
|
required: Required;
|
|
116
116
|
}>;
|
|
117
|
-
/** `req_body_type = json`
|
|
117
|
+
/** Request content when `req_body_type = json` */
|
|
118
118
|
req_body_other: string;
|
|
119
|
-
/**
|
|
119
|
+
/** Response data type */
|
|
120
120
|
res_body_type: ResponseBodyType;
|
|
121
|
-
/** `res_body_type = json`
|
|
121
|
+
/** Whether it is json schema when `res_body_type = json` */
|
|
122
122
|
res_body_is_json_schema: boolean;
|
|
123
|
-
/**
|
|
123
|
+
/** Response data */
|
|
124
124
|
res_body: string;
|
|
125
|
-
/**
|
|
125
|
+
/** Creation time (unix timestamp) */
|
|
126
126
|
add_time: number;
|
|
127
|
-
/**
|
|
127
|
+
/** Update time (unix timestamp) */
|
|
128
128
|
up_time: number;
|
|
129
129
|
[key: string]: any;
|
|
130
130
|
}
|
|
131
|
-
/**
|
|
131
|
+
/** Interface basic information */
|
|
132
132
|
export interface BaseInterfaceInfo {
|
|
133
133
|
edit_uid: number;
|
|
134
134
|
status: string;
|
|
@@ -143,21 +143,21 @@ export interface BaseInterfaceInfo {
|
|
|
143
143
|
uid: number;
|
|
144
144
|
add_time: number;
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
146
|
+
/** Interface list */
|
|
147
147
|
export declare type InterfaceList = Interface[];
|
|
148
|
-
/**
|
|
148
|
+
/** Category information */
|
|
149
149
|
export interface Category {
|
|
150
150
|
/** ID */
|
|
151
151
|
_id: number;
|
|
152
|
-
/**
|
|
152
|
+
/** Category name */
|
|
153
153
|
name: string;
|
|
154
|
-
/**
|
|
154
|
+
/** Category description */
|
|
155
155
|
desc: string;
|
|
156
|
-
/**
|
|
156
|
+
/** Interface list in this category */
|
|
157
157
|
list: InterfaceList;
|
|
158
|
-
/**
|
|
158
|
+
/** Creation time (unix timestamp) */
|
|
159
159
|
add_time: number;
|
|
160
|
-
/**
|
|
160
|
+
/** Update time (unix timestamp) */
|
|
161
161
|
up_time: number;
|
|
162
162
|
}
|
|
163
163
|
export interface ChangeCase {
|
|
@@ -237,7 +237,7 @@ export interface ChangeCase {
|
|
|
237
237
|
*/
|
|
238
238
|
upperCaseFirst: (value: string) => string;
|
|
239
239
|
}
|
|
240
|
-
/**
|
|
240
|
+
/** Request method */
|
|
241
241
|
export declare enum Method {
|
|
242
242
|
GET = "GET",
|
|
243
243
|
POST = "POST",
|
|
@@ -247,201 +247,201 @@ export declare enum Method {
|
|
|
247
247
|
OPTIONS = "OPTIONS",
|
|
248
248
|
PATCH = "PATCH"
|
|
249
249
|
}
|
|
250
|
-
/**
|
|
250
|
+
/** Required */
|
|
251
251
|
export declare enum Required {
|
|
252
|
-
/**
|
|
252
|
+
/** Not required */
|
|
253
253
|
false = "0",
|
|
254
|
-
/**
|
|
254
|
+
/** Required */
|
|
255
255
|
true = "1"
|
|
256
256
|
}
|
|
257
|
-
/**
|
|
257
|
+
/** Request body type */
|
|
258
258
|
export declare enum RequestBodyType {
|
|
259
|
-
/**
|
|
259
|
+
/** Query string */
|
|
260
260
|
query = "query",
|
|
261
|
-
/**
|
|
261
|
+
/** Form */
|
|
262
262
|
form = "form",
|
|
263
263
|
/** JSON */
|
|
264
264
|
json = "json",
|
|
265
|
-
/**
|
|
265
|
+
/** Plain text */
|
|
266
266
|
text = "text",
|
|
267
|
-
/**
|
|
267
|
+
/** File */
|
|
268
268
|
file = "file",
|
|
269
|
-
/**
|
|
269
|
+
/** Raw data */
|
|
270
270
|
raw = "raw",
|
|
271
|
-
/**
|
|
271
|
+
/** No request data */
|
|
272
272
|
none = "none"
|
|
273
273
|
}
|
|
274
|
-
/**
|
|
274
|
+
/** Request path parameter type */
|
|
275
275
|
export declare enum RequestParamType {
|
|
276
|
-
/**
|
|
276
|
+
/** String */
|
|
277
277
|
string = "string",
|
|
278
|
-
/**
|
|
278
|
+
/** Number */
|
|
279
279
|
number = "number"
|
|
280
280
|
}
|
|
281
|
-
/**
|
|
281
|
+
/** Request query parameter type */
|
|
282
282
|
export declare enum RequestQueryType {
|
|
283
|
-
/**
|
|
283
|
+
/** String */
|
|
284
284
|
string = "string",
|
|
285
|
-
/**
|
|
285
|
+
/** Number */
|
|
286
286
|
number = "number"
|
|
287
287
|
}
|
|
288
|
-
/**
|
|
288
|
+
/** Request form item type */
|
|
289
289
|
export declare enum RequestFormItemType {
|
|
290
|
-
/**
|
|
290
|
+
/** Plain text */
|
|
291
291
|
text = "text",
|
|
292
|
-
/**
|
|
292
|
+
/** File */
|
|
293
293
|
file = "file"
|
|
294
294
|
}
|
|
295
|
-
/**
|
|
295
|
+
/** Response body type */
|
|
296
296
|
export declare enum ResponseBodyType {
|
|
297
297
|
/** JSON */
|
|
298
298
|
json = "json",
|
|
299
|
-
/**
|
|
299
|
+
/** Plain text */
|
|
300
300
|
text = "text",
|
|
301
301
|
/** XML */
|
|
302
302
|
xml = "xml",
|
|
303
|
-
/**
|
|
303
|
+
/** Raw data */
|
|
304
304
|
raw = "raw"
|
|
305
305
|
/** JSON Schema */
|
|
306
306
|
}
|
|
307
|
-
/**
|
|
307
|
+
/** Extended interface definition */
|
|
308
308
|
export interface ExtendedInterface extends Interface {
|
|
309
309
|
parsedPath: ParsedPath;
|
|
310
310
|
}
|
|
311
|
-
/**
|
|
311
|
+
/** Category list, corresponding to exported json content */
|
|
312
312
|
export declare type CategoryList = Category[];
|
|
313
|
-
/**
|
|
313
|
+
/** Configuration for generating JSON Schema */
|
|
314
314
|
export interface JsonSchemaConfig {
|
|
315
315
|
/**
|
|
316
|
-
*
|
|
316
|
+
* Whether to enable this feature.
|
|
317
317
|
*/
|
|
318
318
|
enabled: boolean;
|
|
319
319
|
}
|
|
320
|
-
/**
|
|
320
|
+
/** Configuration for generating comments */
|
|
321
321
|
export interface CommentConfig {
|
|
322
322
|
/**
|
|
323
|
-
*
|
|
323
|
+
* Whether to enable this feature.
|
|
324
324
|
*
|
|
325
325
|
* @default true
|
|
326
326
|
*/
|
|
327
327
|
enabled?: boolean;
|
|
328
328
|
/**
|
|
329
|
-
*
|
|
329
|
+
* Whether to include title.
|
|
330
330
|
*
|
|
331
331
|
* @default true
|
|
332
332
|
*/
|
|
333
333
|
title?: boolean;
|
|
334
334
|
/**
|
|
335
|
-
*
|
|
335
|
+
* Whether to include category name.
|
|
336
336
|
*
|
|
337
337
|
* @default true
|
|
338
338
|
*/
|
|
339
339
|
category?: boolean;
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
341
|
+
* Whether to include tags.
|
|
342
342
|
*
|
|
343
343
|
* @default true
|
|
344
344
|
*/
|
|
345
345
|
tag?: boolean;
|
|
346
346
|
/**
|
|
347
|
-
*
|
|
347
|
+
* Whether to include request headers.
|
|
348
348
|
*
|
|
349
349
|
* @default true
|
|
350
350
|
*/
|
|
351
351
|
requestHeader?: boolean;
|
|
352
352
|
/**
|
|
353
|
-
*
|
|
353
|
+
* Whether to include update time.
|
|
354
354
|
*
|
|
355
355
|
* @default true
|
|
356
356
|
*/
|
|
357
357
|
updateTime?: boolean;
|
|
358
358
|
/**
|
|
359
|
-
*
|
|
359
|
+
* Whether to add links to title and category name.
|
|
360
360
|
*
|
|
361
361
|
* @default true
|
|
362
362
|
*/
|
|
363
363
|
link?: boolean;
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
|
-
*
|
|
366
|
+
* Shared configuration.
|
|
367
367
|
*/
|
|
368
368
|
export interface SharedConfig {
|
|
369
369
|
/**
|
|
370
|
-
*
|
|
370
|
+
* Output file path.
|
|
371
371
|
*
|
|
372
|
-
*
|
|
372
|
+
* Can be `relative path` or `absolute path`.
|
|
373
373
|
*
|
|
374
374
|
* @example 'src/api/index.ts'
|
|
375
375
|
*/
|
|
376
376
|
outputFilePath?: string;
|
|
377
377
|
/**
|
|
378
|
-
*
|
|
378
|
+
* Request function file path.
|
|
379
379
|
*
|
|
380
|
-
* @default
|
|
380
|
+
* @default `request.ts` file in the same directory as `outputFilePath`
|
|
381
381
|
* @example 'src/api/request.ts'
|
|
382
382
|
*/
|
|
383
383
|
requestFunctionFilePath?: string;
|
|
384
384
|
/**
|
|
385
|
-
*
|
|
385
|
+
* Configuration for generating JSON Schema.
|
|
386
386
|
*/
|
|
387
387
|
/**
|
|
388
|
-
*
|
|
388
|
+
* Configuration for generating comments.
|
|
389
389
|
*/
|
|
390
390
|
comment?: CommentConfig;
|
|
391
391
|
/**
|
|
392
|
-
*
|
|
392
|
+
* Get the name of the request function.
|
|
393
393
|
*
|
|
394
394
|
* @default changeCase.camelCase(interfaceInfo.parsedPath.name)
|
|
395
|
-
* @param interfaceInfo
|
|
396
|
-
* @param changeCase
|
|
397
|
-
* @returns
|
|
395
|
+
* @param interfaceInfo Interface information
|
|
396
|
+
* @param changeCase Collection of common case conversion functions
|
|
397
|
+
* @returns Name of the request function
|
|
398
398
|
*/
|
|
399
399
|
getRequestFunctionName?(interfaceInfo: ExtendedInterface, changeCase: ChangeCase): string;
|
|
400
400
|
/**
|
|
401
|
-
*
|
|
401
|
+
* Get the name of the request data type.
|
|
402
402
|
*
|
|
403
403
|
* @default changeCase.pascalCase(`${requestFunctionName}Request`)
|
|
404
|
-
* @param interfaceInfo
|
|
405
|
-
* @param changeCase
|
|
406
|
-
* @returns
|
|
404
|
+
* @param interfaceInfo Interface information
|
|
405
|
+
* @param changeCase Collection of common case conversion functions
|
|
406
|
+
* @returns Name of the request data type
|
|
407
407
|
*/
|
|
408
408
|
getRequestDataTypeName?(interfaceInfo: ExtendedInterface, changeCase: ChangeCase): string;
|
|
409
409
|
/**
|
|
410
|
-
*
|
|
410
|
+
* Get the name of the response data type.
|
|
411
411
|
*
|
|
412
412
|
* @default changeCase.pascalCase(`${requestFunctionName}Response`)
|
|
413
|
-
* @param interfaceInfo
|
|
414
|
-
* @param changeCase
|
|
415
|
-
* @returns
|
|
413
|
+
* @param interfaceInfo Interface information
|
|
414
|
+
* @param changeCase Collection of common case conversion functions
|
|
415
|
+
* @returns Name of the response data type
|
|
416
416
|
*/
|
|
417
417
|
getResponseDataTypeName?(interfaceInfo: ExtendedInterface, changeCase: ChangeCase): string;
|
|
418
418
|
}
|
|
419
419
|
/**
|
|
420
|
-
*
|
|
420
|
+
* Server configuration.
|
|
421
421
|
*/
|
|
422
422
|
export interface ApiConfig {
|
|
423
423
|
name: string;
|
|
424
424
|
configIndex?: number;
|
|
425
425
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
426
|
+
* Server URL. Enter the swagger json address here.
|
|
427
|
+
* For example, nestjs projects usually use http://localhost:3041/api-json
|
|
428
428
|
*
|
|
429
429
|
*/
|
|
430
430
|
serverUrl: string;
|
|
431
431
|
/**
|
|
432
|
-
*
|
|
432
|
+
* Output file path.
|
|
433
433
|
*
|
|
434
|
-
*
|
|
434
|
+
* Can be `relative path` or `absolute path`.
|
|
435
435
|
*
|
|
436
436
|
* @example 'src/api/index.ts'
|
|
437
437
|
*/
|
|
438
438
|
outputFilePath?: string;
|
|
439
439
|
/**
|
|
440
|
-
*
|
|
440
|
+
* Set the baseURL for the interface
|
|
441
441
|
*
|
|
442
|
-
* @description
|
|
442
|
+
* @description To configure runtime code, add the `[code]:` prefix
|
|
443
443
|
```
|
|
444
|
-
|
|
444
|
+
Example:
|
|
445
445
|
baseURL: "[code]:process.env.BASE_URL" => baseURL:process.env.BASE_URL
|
|
446
446
|
|
|
447
447
|
baseURL: "http://localhost:3000" => baseURL:"http://localhost:3000"
|
|
@@ -449,82 +449,82 @@ export interface ApiConfig {
|
|
|
449
449
|
*/
|
|
450
450
|
baseURL?: ((path: string) => string | undefined) | string;
|
|
451
451
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
452
|
+
* Define a code snippet at the top of each generated api file
|
|
453
|
+
* For example: import custom request function
|
|
454
454
|
* default: import request from './request'
|
|
455
455
|
*/
|
|
456
456
|
topImportTemplate?: topImportTemplateType;
|
|
457
457
|
/**
|
|
458
|
-
*
|
|
458
|
+
* Whether to use the default request library, request.ts will not be generated after disabling, default: true
|
|
459
459
|
*/
|
|
460
460
|
defaultRequestLib?: boolean;
|
|
461
461
|
}
|
|
462
|
-
/**
|
|
462
|
+
/** Combined configuration. */
|
|
463
463
|
export declare type SyntheticalConfig = Partial<ApiConfig & {
|
|
464
464
|
components: OpenAPIV3.Document['components'];
|
|
465
465
|
}>;
|
|
466
|
-
/**
|
|
466
|
+
/** Configuration. */
|
|
467
467
|
export declare type Config = ApiConfig;
|
|
468
468
|
/**
|
|
469
|
-
*
|
|
469
|
+
* Request configuration.
|
|
470
470
|
*/
|
|
471
471
|
export interface RequestConfig<Path extends string = string, ParamName extends string = string, QueryName extends string = string, RequestDataOptional extends boolean = boolean> {
|
|
472
|
-
/**
|
|
472
|
+
/** Interface path, starting with `/` */
|
|
473
473
|
path: Path;
|
|
474
|
-
/**
|
|
474
|
+
/** Request method */
|
|
475
475
|
method: Method;
|
|
476
|
-
/**
|
|
476
|
+
/** Request headers, all headers except Content-Type */
|
|
477
477
|
requestHeaders: Record<string, string>;
|
|
478
|
-
/**
|
|
478
|
+
/** Request body type */
|
|
479
479
|
requestBodyType: RequestBodyType;
|
|
480
|
-
/**
|
|
480
|
+
/** Response body type */
|
|
481
481
|
responseBodyType: ResponseBodyType;
|
|
482
|
-
/**
|
|
482
|
+
/** List of path parameter names */
|
|
483
483
|
paramNames: ParamName[];
|
|
484
|
-
/**
|
|
484
|
+
/** List of query parameter names */
|
|
485
485
|
queryNames: QueryName[];
|
|
486
|
-
/**
|
|
486
|
+
/** Whether request data is optional */
|
|
487
487
|
requestDataOptional: RequestDataOptional;
|
|
488
|
-
/**
|
|
488
|
+
/** JSON Schema for request data (only effective when JSON Schema generation is enabled) */
|
|
489
489
|
requestDataJsonSchema: JSONSchema4;
|
|
490
|
-
/**
|
|
490
|
+
/** JSON Schema for response data (only effective when JSON Schema generation is enabled) */
|
|
491
491
|
responseDataJsonSchema: JSONSchema4;
|
|
492
|
-
/**
|
|
492
|
+
/** Request function name */
|
|
493
493
|
requestFunctionName: string;
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
|
-
*
|
|
496
|
+
* Request parameters.
|
|
497
497
|
*/
|
|
498
498
|
export interface RequestFunctionParams extends RequestConfig {
|
|
499
|
-
/**
|
|
499
|
+
/** Raw data */
|
|
500
500
|
rawData: Record<string, any>;
|
|
501
|
-
/**
|
|
501
|
+
/** Request data, excluding file data */
|
|
502
502
|
data: Record<string, any>;
|
|
503
|
-
/**
|
|
503
|
+
/** Whether there is file data */
|
|
504
504
|
hasFileData: boolean;
|
|
505
|
-
/**
|
|
505
|
+
/** Request file data */
|
|
506
506
|
fileData: Record<string, any>;
|
|
507
|
-
/**
|
|
507
|
+
/** All request data, including data and fileData */
|
|
508
508
|
allData: Record<string, any>;
|
|
509
|
-
/**
|
|
509
|
+
/** Get FormData instance for all request data (including files) */
|
|
510
510
|
getFormData: () => FormData;
|
|
511
511
|
}
|
|
512
|
-
/**
|
|
512
|
+
/** Additional parameters of the request function */
|
|
513
513
|
export declare type RequestFunctionRestArgs<T extends Function> = T extends (payload: any, ...args: infer R) => any ? R : never;
|
|
514
|
-
/**
|
|
514
|
+
/** Property definition */
|
|
515
515
|
export interface PropDefinition {
|
|
516
|
-
/**
|
|
516
|
+
/** Property name */
|
|
517
517
|
name: string;
|
|
518
|
-
/**
|
|
518
|
+
/** Required */
|
|
519
519
|
required: boolean;
|
|
520
|
-
/**
|
|
520
|
+
/** Type */
|
|
521
521
|
type: JSONSchema4['type'];
|
|
522
|
-
/**
|
|
522
|
+
/** Comment */
|
|
523
523
|
comment: string;
|
|
524
524
|
}
|
|
525
|
-
/**
|
|
525
|
+
/** Property definition list */
|
|
526
526
|
export declare type PropDefinitions = PropDefinition[];
|
|
527
|
-
/**
|
|
527
|
+
/** Request function body generation template function */
|
|
528
528
|
export interface RequestFunctionTemplateProps {
|
|
529
529
|
baseURL?: string;
|
|
530
530
|
requestFunctionName: string;
|