-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-typescript-cli.config.example.js
More file actions
58 lines (54 loc) · 1.9 KB
/
openapi-typescript-cli.config.example.js
File metadata and controls
58 lines (54 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
/**
* OpenAPI TypeScript CLI 配置文件
*
* 使用方式:
* 1. 复制此文件为 openapi-typescript-cli.config.js(或 .openapi-typescript-cli.config.js)
* 2. 修改配置项
* 3. 运行:openapi-typescript-cli(会自动查找配置文件)
* 或:openapi-typescript-cli -c ./openapi-typescript-cli.config.js
*
* 优先级:命令行参数 > 配置文件 > 默认值
*
* 支持格式:
* 1. 推荐:{ apis: [ ... ] },根级字段会合并进每一项(可被单项覆盖)
* 每项可用新字段:moduleName(输出基名,同 name)、apijson(本地路径或 http(s) URL)、middleware / midware
* 或沿用:input、url、name、middleware、output
* 2. 兼容:直接 export 数组(多个 API)
* 3. 兼容:单个对象(一个 API)
*/
// ========== 推荐:本地 apis 列表 ==========
module.exports = {
// 可选:所有 API 共用的默认值(单项里可覆盖)
// output: './src/api',
apis: [
{
moduleName: 'userApi',
apijson: 'http://localhost:8080/v3/api-docs',
output: './src/api/user',
// middleware: './middleware.js', // 也可用 midware(拼写别名)
},
{
moduleName: 'orderApi',
apijson: 'http://localhost:8081/v3/api-docs',
output: './src/api/order',
},
{
moduleName: 'paymentApi',
apijson: './openapi/payment.json',
output: './src/api/payment',
},
// 以下为旧字段写法,仍完全支持:
// { input: './openapi/payment.json', name: 'paymentApi', output: './src/api/payment' },
],
};
// ========== 兼容:单个 API ==========
// module.exports = {
// input: './openapi.json',
// name: 'api',
// output: './src/api',
// };
// ========== 兼容:多个 API(数组)==========
// module.exports = [
// { input: './a.json', name: 'a', output: './src/api/a' },
// { input: './b.json', name: 'b', output: './src/api/b' },
// ];