-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathorval.config.ts
68 lines (64 loc) · 1.41 KB
/
orval.config.ts
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
59
60
61
62
63
64
65
66
67
68
/* eslint-disable @typescript-eslint/no-var-requires */
const { camelCase } = require('lodash')
const filterTargetSchema = require('./scripts/transformer/filterTagsSchema.js')
const baseURL = process.env.HOST_URL || 'http://localhost:18083'
const swaggerURL = `${baseURL}/api-docs/swagger.json`
const tagArr = [
'Authentication',
'Metrics',
'MQTT',
'LwM2M Gateways',
'Plugins',
'Bridges',
'Status',
'Topics',
'Authorization',
'Nodes',
'ExHook',
'Monitor',
'Auto Subscribe',
'Gateway Listeners',
'Configs',
'Clients',
'Cluster',
'Gateway Clients',
'Publish',
'Rules',
'Gateways',
'Trace',
'Dashboard',
'Listeners',
'Gateway Authentication',
'CoAP Gateways',
'Retainer',
'Subscriptions',
'API Keys',
'Banned',
'Connectors',
'Actions',
'Sources',
]
const typesFolder = './src/types/schemas/'
const configs = tagArr.reduce((obj: Record<string, any>, tag: string) => {
const key = camelCase(tag)
const filePath = `${typesFolder}${key}.ts`
obj[key] = {
input: {
target: swaggerURL,
override: {
transformer: (json) => filterTargetSchema(json, tag),
},
filters: { tags: [tag] },
},
output: {
mode: 'split',
target: filePath,
override: { header: false },
},
hooks: {
afterAllFilesWrite: ['prettier --write', `yarn remove-orval-client ${filePath}`],
},
}
return obj
}, {})
module.exports = configs