generated from stijnvanhulle/template
-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathkubb.config.js
85 lines (84 loc) · 2.26 KB
/
kubb.config.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { defineConfig } from '@kubb/core'
import { pluginClient } from '@kubb/plugin-client'
import { pluginOas, schemaKeywords } from '@kubb/plugin-oas'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginZod } from '@kubb/plugin-zod'
export default defineConfig(async () => {
await setTimeout(() => {
// wait for 1s, async behaviour
return Promise.resolve(true)
}, 1000)
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
},
hooks: {
// done: ['npm run typecheck', 'biome format --write ./', 'biome lint --apply-unsafe ./src'],
},
plugins: [
pluginOas({ generators: [] }),
pluginTs({
output: {
path: './ts',
},
transformers: {
name: (name, type) => {
return `${name}Type`
},
},
}),
pluginZod({
output: {
path: './zod',
},
typed: true,
transformers: {
name: (name, type) => (type === 'file' ? `${name}.gen` : name),
schema: ({ schema, parentName, name }, defaultSchemas) => {
/* override a property with name 'name'
Pet:
required:
- name
type: object
properties:
name:
type: string
example: doggie
*/
if (parentName === 'Pet' && name === 'name') {
// see mapper where we map `productionName` to `faker.commerce.productName`, the original name will be kept.
return [...defaultSchemas, { keyword: schemaKeywords.name, args: 'productName' }]
}
return undefined
},
},
operations: true,
mapper: {
productName: 'z.string().uuid()',
},
importPath: '../../zod.ts',
inferred: true,
}),
pluginClient({
output: {
path: './zodClients.ts',
barrelType: false,
},
include: [
{
type: 'tag',
pattern: 'store',
},
],
parser: 'zod',
dataReturnType: 'data',
pathParamsType: 'object',
}),
],
}
})