@paulpugovkin/api-docs-axios-ts-generator 1.1.0 → 1.2.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/README.md +237 -495
- package/dist/index.js +78 -0
- package/package.json +11 -22
- package/bin/cli.js +0 -6
- package/src/clean-generated-folder/cleanGeneratedFolder.js +0 -21
- package/src/collect-genereted-files/collectGeneratedFiles.js +0 -33
- package/src/generate-class/generateClass.js +0 -42
- package/src/generate-index-file-with-public-api/generateIndexFileWithPublicApi.js +0 -45
- package/src/generate-interface/generateInterface.js +0 -81
- package/src/generate-js-doc/generateJSDoc.js +0 -136
- package/src/generate-main-index-file/generateMainIndexFile.js +0 -21
- package/src/generate-method/generateMethod.js +0 -264
- package/src/generators/axiosConfigGenerator.js +0 -79
- package/src/index.js +0 -187
- package/src/map-type/mapType.js +0 -19
- package/src/parse-and-generate/parseAndGenerate.js +0 -190
- package/src/resolve-type/resolveType.js +0 -54
- package/src/update-api-docs-json/updateApiDocsJson.js +0 -33
package/README.md
CHANGED
|
@@ -1,495 +1,237 @@
|
|
|
1
|
-
# API Docs Axios TS Generator
|
|
2
|
-
|
|
3
|
-
Generate TypeScript interfaces and axios classes from OpenAPI (Swagger) specifications.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// Axios configuration settings
|
|
239
|
-
// These settings will be used in the generated axios configuration
|
|
240
|
-
axios: {
|
|
241
|
-
// Base URL for all API requests
|
|
242
|
-
// This will be prepended to all request URLs
|
|
243
|
-
// Example: 'https://api.example.com' or 'https://api.example.com/v1'
|
|
244
|
-
baseURL: 'https://api.example.com',
|
|
245
|
-
|
|
246
|
-
// Request timeout in milliseconds
|
|
247
|
-
// How long to wait for a response before timing out
|
|
248
|
-
// Example: 30000 (30 seconds), 60000 (1 minute)
|
|
249
|
-
timeout: 30000,
|
|
250
|
-
|
|
251
|
-
// Default headers for all requests
|
|
252
|
-
// These headers will be included in every API request
|
|
253
|
-
// You can add authentication headers, content types, etc.
|
|
254
|
-
headers: {
|
|
255
|
-
'Content-Type': 'application/json',
|
|
256
|
-
// 'X-API-Key': 'your-api-key',
|
|
257
|
-
// 'Authorization': 'Bearer your-token',
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
// Send cookies with cross-domain requests
|
|
261
|
-
// Set to true if your API requires cookies for authentication
|
|
262
|
-
// Default: false
|
|
263
|
-
withCredentials: false,
|
|
264
|
-
|
|
265
|
-
// Response type (optional)
|
|
266
|
-
// Expected response type: 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
|
|
267
|
-
// Default: 'json'
|
|
268
|
-
// responseType: 'json',
|
|
269
|
-
|
|
270
|
-
// Transform request data before sending (optional)
|
|
271
|
-
// Function to transform request data before it's sent to the server
|
|
272
|
-
// transformRequest: [(data) => data],
|
|
273
|
-
|
|
274
|
-
// Transform response data after receiving (optional)
|
|
275
|
-
// Function to transform response data after it's received from the server
|
|
276
|
-
// transformResponse: [(data) => data],
|
|
277
|
-
|
|
278
|
-
// Validate status code (optional)
|
|
279
|
-
// Set to false to reject the promise if the status code is not 2xx
|
|
280
|
-
// validateStatus: (status) => status >= 200 && status < 300,
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### 4. Use generated API
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
import { UsersApi, ProductsApi } from './src/api';
|
|
289
|
-
|
|
290
|
-
// Use API
|
|
291
|
-
const usersApi = new UsersApi();
|
|
292
|
-
const productsApi = new ProductsApi();
|
|
293
|
-
|
|
294
|
-
// Get user
|
|
295
|
-
const user = await usersApi.getUserById(123);
|
|
296
|
-
|
|
297
|
-
// With custom axios configuration
|
|
298
|
-
const user = await usersApi.getUserById(123, {
|
|
299
|
-
headers: {
|
|
300
|
-
'X-Custom-Header': 'value',
|
|
301
|
-
},
|
|
302
|
-
timeout: 5000,
|
|
303
|
-
});
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
## Configuration
|
|
307
|
-
|
|
308
|
-
### Main parameters
|
|
309
|
-
|
|
310
|
-
| Parameter | Type | Required | Description |
|
|
311
|
-
|-----------|------|--------------|------------|
|
|
312
|
-
| `apiDocsUrl` | `string` | No* | URL to fetch OpenAPI specification |
|
|
313
|
-
| `apiDocsPath` | `string` | No* | Local path to OpenAPI specification file |
|
|
314
|
-
| `outputDir` | `string` | Yes | Output directory for generated files |
|
|
315
|
-
|
|
316
|
-
*One of `apiDocsUrl` or `apiDocsPath` is required.
|
|
317
|
-
|
|
318
|
-
### Tag filtering
|
|
319
|
-
|
|
320
|
-
```typescript
|
|
321
|
-
tags: {
|
|
322
|
-
include?: string[]; // Tags to include
|
|
323
|
-
exclude?: string[]; // Tags to exclude
|
|
324
|
-
prefix?: string; // Tag prefix (default "api_tag_")
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
### Grouping modes
|
|
329
|
-
|
|
330
|
-
```typescript
|
|
331
|
-
groupBy: 'tag' | 'all' | 'path';
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
- `'tag'` - grouping by tags (multiple classes)
|
|
335
|
-
- `'all'` - all methods in one class
|
|
336
|
-
- `'path'` - grouping by API paths
|
|
337
|
-
|
|
338
|
-
### Class generation modes
|
|
339
|
-
|
|
340
|
-
```typescript
|
|
341
|
-
classMode: 'single' | 'multiple';
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
- `'single'` - one class for all methods
|
|
345
|
-
- `'multiple'` - multiple classes by grouping
|
|
346
|
-
|
|
347
|
-
### Naming options
|
|
348
|
-
|
|
349
|
-
```typescript
|
|
350
|
-
naming: {
|
|
351
|
-
className?: (tag: string) => string;
|
|
352
|
-
interfaceName?: (name: string) => string;
|
|
353
|
-
methodName?: (operationId: string) => string;
|
|
354
|
-
}
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### Import options
|
|
358
|
-
|
|
359
|
-
```typescript
|
|
360
|
-
imports: {
|
|
361
|
-
axiosPath?: string; // Path to import axios (default 'axios')
|
|
362
|
-
baseUrlPath?: string; // Path to import BASE_URL
|
|
363
|
-
}
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Generation options
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
options: {
|
|
370
|
-
generateJSDoc?: boolean; // Generate JSDoc (default true)
|
|
371
|
-
generateIndexFiles?: boolean; // Generate index files (default true)
|
|
372
|
-
cleanOutputDir?: boolean; // Clean output directory (default true)
|
|
373
|
-
generateAxiosConfig?: boolean; // Generate axios configuration (default true)
|
|
374
|
-
allowAxiosConfigSpread?: boolean; // Allow spreading axios configs (default true)
|
|
375
|
-
}
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### Axios settings
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
axios: {
|
|
382
|
-
baseURL?: string;
|
|
383
|
-
timeout?: number;
|
|
384
|
-
headers?: Record<string, string>;
|
|
385
|
-
withCredentials?: boolean;
|
|
386
|
-
}
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
## Spreading user axios configurations
|
|
390
|
-
|
|
391
|
-
When `allowAxiosConfigSpread: true` is enabled, API methods support passing user configurations:
|
|
392
|
-
|
|
393
|
-
```typescript
|
|
394
|
-
// Generated method
|
|
395
|
-
async getUserById(id: number, config?: AxiosRequestConfig): Promise<AxiosResponse<User>>
|
|
396
|
-
|
|
397
|
-
// Usage
|
|
398
|
-
const response = await usersApi.getUserById(123, {
|
|
399
|
-
headers: {
|
|
400
|
-
'X-Custom-Header': 'value',
|
|
401
|
-
},
|
|
402
|
-
timeout: 5000,
|
|
403
|
-
params: {
|
|
404
|
-
fields: 'id,name,email',
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
## Generated files structure
|
|
410
|
-
|
|
411
|
-
```
|
|
412
|
-
outputDir/
|
|
413
|
-
├── config/
|
|
414
|
-
│ └── axios/
|
|
415
|
-
│ └── axios.ts # Axios configuration with interceptors
|
|
416
|
-
├── interfaces/
|
|
417
|
-
│ ├── User.ts
|
|
418
|
-
│ ├── Product.ts
|
|
419
|
-
│ └── index.ts
|
|
420
|
-
├── classes/
|
|
421
|
-
│ ├── UsersApi.ts
|
|
422
|
-
│ ├── ProductsApi.ts
|
|
423
|
-
│ └── index.ts
|
|
424
|
-
└── index.ts
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
## CLI options
|
|
428
|
-
|
|
429
|
-
```
|
|
430
|
-
Usage: api-docs-generator [options]
|
|
431
|
-
|
|
432
|
-
Options:
|
|
433
|
-
-V, --version output the version number
|
|
434
|
-
-c, --config <path> Path to configuration file
|
|
435
|
-
--api-docs-url <url> URL to fetch OpenAPI documentation
|
|
436
|
-
--api-docs-path <path> Local path to OpenAPI documentation file
|
|
437
|
-
--output-dir <dir> Output directory for generated files
|
|
438
|
-
--clean Clean output directory before generation
|
|
439
|
-
-h, --help display help for command
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
## Configuration examples
|
|
443
|
-
|
|
444
|
-
### Generate by tags (multiple classes)
|
|
445
|
-
|
|
446
|
-
```typescript
|
|
447
|
-
{
|
|
448
|
-
tags: {
|
|
449
|
-
include: ['api_tag_users', 'api_tag_products'],
|
|
450
|
-
},
|
|
451
|
-
groupBy: 'tag',
|
|
452
|
-
classMode: 'multiple',
|
|
453
|
-
}
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### Generate single class
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
{
|
|
460
|
-
groupBy: 'all',
|
|
461
|
-
classMode: 'single',
|
|
462
|
-
}
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
### Exclude tags
|
|
466
|
-
|
|
467
|
-
```typescript
|
|
468
|
-
{
|
|
469
|
-
tags: {
|
|
470
|
-
exclude: ['api_tag_internal', 'api_tag_admin'],
|
|
471
|
-
},
|
|
472
|
-
}
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
### Generate with axios configuration
|
|
476
|
-
|
|
477
|
-
```typescript
|
|
478
|
-
{
|
|
479
|
-
options: {
|
|
480
|
-
generateAxiosConfig: true,
|
|
481
|
-
},
|
|
482
|
-
axios: {
|
|
483
|
-
baseURL: 'https://api.example.com',
|
|
484
|
-
timeout: 30000,
|
|
485
|
-
headers: {
|
|
486
|
-
'Content-Type': 'application/json',
|
|
487
|
-
'X-API-Key': 'your-api-key',
|
|
488
|
-
},
|
|
489
|
-
},
|
|
490
|
-
}
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
## License
|
|
494
|
-
|
|
495
|
-
MIT
|
|
1
|
+
# API Docs Axios TS Generator
|
|
2
|
+
|
|
3
|
+
Generate TypeScript interfaces and axios classes from OpenAPI (Swagger) specifications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Generate TypeScript interfaces from OpenAPI schemas
|
|
8
|
+
- Generate axios classes with API methods
|
|
9
|
+
- Flexible configuration via TypeScript file
|
|
10
|
+
- Tag filtering (include/exclude)
|
|
11
|
+
- Generation modes: single class or multiple by tags
|
|
12
|
+
- Automatic axios configuration generation
|
|
13
|
+
- Support for spreading user axios configurations
|
|
14
|
+
- JSDoc comments for methods
|
|
15
|
+
- Backward compatibility with CLI arguments
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install --save-dev @paulpugovkin/api-docs-axios-ts-generator
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add script to your `package.json`:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"scripts": {
|
|
28
|
+
"generate-services": "api-docs-generator --config api-docs-generator.config.js"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Now generate your API client:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run generate-services
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Create configuration file
|
|
42
|
+
|
|
43
|
+
A default configuration file `api-docs-generator.config.js` is automatically created in your project root during installation. You can modify this file to suit your needs.
|
|
44
|
+
|
|
45
|
+
If you need to create it manually, see the template at `src/templates/default.config.template.js` or the [Configuration](#configuration) reference below.
|
|
46
|
+
|
|
47
|
+
## Generated API usage
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { UsersApi, ProductsApi } from './generated';
|
|
51
|
+
|
|
52
|
+
// Use API
|
|
53
|
+
const usersApi = new UsersApi();
|
|
54
|
+
const productsApi = new ProductsApi();
|
|
55
|
+
|
|
56
|
+
// Get user
|
|
57
|
+
const user = await usersApi.getUserById(123);
|
|
58
|
+
|
|
59
|
+
// With custom axios configuration
|
|
60
|
+
const user = await usersApi.getUserById(123, {
|
|
61
|
+
headers: {
|
|
62
|
+
'X-Custom-Header': 'value',
|
|
63
|
+
},
|
|
64
|
+
timeout: 5000,
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
### Main parameters
|
|
71
|
+
|
|
72
|
+
| Parameter | Type | Required | Description |
|
|
73
|
+
|-----------|------|--------------|------------|
|
|
74
|
+
| `apiDocsUrl` | `string` | No* | URL to fetch OpenAPI specification |
|
|
75
|
+
| `apiDocsPath` | `string` | No* | Local path to OpenAPI specification file |
|
|
76
|
+
| `outputDir` | `string` | Yes | Output directory for generated files |
|
|
77
|
+
|
|
78
|
+
*One of `apiDocsUrl` or `apiDocsPath` is required.
|
|
79
|
+
|
|
80
|
+
### Tag filtering
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
tags: {
|
|
84
|
+
include?: string[]; // Tags to include
|
|
85
|
+
exclude?: string[]; // Tags to exclude
|
|
86
|
+
prefix?: string; // Tag prefix (default "api_tag_")
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Grouping modes
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
groupBy: 'tag' | 'all' | 'path';
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- `'tag'` - grouping by tags (multiple classes)
|
|
97
|
+
- `'all'` - all methods in one class
|
|
98
|
+
- `'path'` - grouping by API paths
|
|
99
|
+
|
|
100
|
+
### Class generation modes
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
classMode: 'single' | 'multiple';
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `'single'` - one class for all methods
|
|
107
|
+
- `'multiple'` - multiple classes by grouping
|
|
108
|
+
|
|
109
|
+
### Naming options
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
naming: {
|
|
113
|
+
className?: (tag: string) => string;
|
|
114
|
+
interfaceName?: (name: string) => string;
|
|
115
|
+
methodName?: (operationId: string) => string;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Import options
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
imports: {
|
|
123
|
+
axiosPath?: string; // Path to import axios (default 'axios')
|
|
124
|
+
baseUrlPath?: string; // Path to import BASE_URL
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Generation options
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
options: {
|
|
132
|
+
generateJSDoc?: boolean; // Generate JSDoc (default true)
|
|
133
|
+
generateIndexFiles?: boolean; // Generate index files (default true)
|
|
134
|
+
cleanOutputDir?: boolean; // Clean output directory (default true)
|
|
135
|
+
generateAxiosConfig?: boolean; // Generate axios configuration (default true)
|
|
136
|
+
allowAxiosConfigSpread?: boolean; // Allow spreading axios configs (default true)
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Axios settings
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
axios: {
|
|
144
|
+
baseURL?: string;
|
|
145
|
+
timeout?: number;
|
|
146
|
+
headers?: Record<string, string>;
|
|
147
|
+
withCredentials?: boolean;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Generated files structure
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
outputDir/
|
|
155
|
+
├── config/
|
|
156
|
+
│ └── axios/
|
|
157
|
+
│ └── axios.ts # Axios configuration with interceptors
|
|
158
|
+
├── interfaces/
|
|
159
|
+
│ ├── User.ts
|
|
160
|
+
│ ├── Product.ts
|
|
161
|
+
│ └── index.ts
|
|
162
|
+
├── classes/
|
|
163
|
+
│ ├── UsersApi.ts
|
|
164
|
+
│ ├── ProductsApi.ts
|
|
165
|
+
│ └── index.ts
|
|
166
|
+
└── index.ts
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## CLI options
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
Usage: api-docs-generator [options]
|
|
173
|
+
|
|
174
|
+
Options:
|
|
175
|
+
-V, --version output the version number
|
|
176
|
+
-c, --config <path> Path to configuration file
|
|
177
|
+
--api-docs-url <url> URL to fetch OpenAPI documentation
|
|
178
|
+
--api-docs-path <path> Local path to OpenAPI documentation file
|
|
179
|
+
--output-dir <dir> Output directory for generated files
|
|
180
|
+
--clean Clean output directory before generation
|
|
181
|
+
-h, --help display help for command
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Configuration examples
|
|
185
|
+
|
|
186
|
+
### Generate by tags (multiple classes)
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
{
|
|
190
|
+
tags: {
|
|
191
|
+
include: ['api_tag_users', 'api_tag_products'],
|
|
192
|
+
},
|
|
193
|
+
groupBy: 'tag',
|
|
194
|
+
classMode: 'multiple',
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Generate single class
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
{
|
|
202
|
+
groupBy: 'all',
|
|
203
|
+
classMode: 'single',
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Exclude tags
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
{
|
|
211
|
+
tags: {
|
|
212
|
+
exclude: ['api_tag_internal', 'api_tag_admin'],
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Generate with axios configuration
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
{
|
|
221
|
+
options: {
|
|
222
|
+
generateAxiosConfig: true,
|
|
223
|
+
},
|
|
224
|
+
axios: {
|
|
225
|
+
baseURL: 'https://api.example.com',
|
|
226
|
+
timeout: 30000,
|
|
227
|
+
headers: {
|
|
228
|
+
'Content-Type': 'application/json',
|
|
229
|
+
'X-API-Key': 'your-api-key',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|