Options
This page is a reference to the different options you can use for configuring your Kubb config. By setting the following options you can override the default behaviour of Kubb and even extend it with your own plugins.
root
Project root directory. Can be an absolute path, or a path relative from the location of the config file itself.
INFO
Type: string
Default: process.cwd()
import { defineConfig } from '@kubb/core'
export default defineConfig({
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
11
input
You can use input.path
or input.data
depending on the needs you have.
path
Define your Swagger/OpenAPI file.
This can be an absolute path or a path relative to the root
.
INFO
Type: string
Required: true
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
data
string
or object
containing your Swagger/OpenAPI
INFO
Type: string | unknown
Required: true
import { defineConfig } from '@kubb/core'
import petStore from './petStore.yaml'
export default defineConfig({
input: {
data: petStore,
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
import petStore from './petStore.yaml'
export default defineConfig({
input: {
data: petStore,
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
11
12
output
path
Path to be used to export all generated files.
This can be an absolute path, or a path relative from the defined root
option.
INFO
Type: string
Required: true
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
clean
Clean output directory before each build.
INFO
Type: boolean
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
},
})
2
3
4
5
6
7
8
9
10
11
write
Write files to the fileSystem.
INFO
Type: boolean
Default: true
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
write: true,
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
write: true,
},
})
2
3
4
5
6
7
8
9
10
11
12
plugins
Array of Kubb plugins to use. The plugin/package can have some extra options defined by the plugin. Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.(see validate)
plugins[index]
TypeScript
INFO
Type: Plugin
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [createSwagger({})],
})
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [createSwagger({})],
})
2
3
4
5
6
7
8
9
10
11
12
JSON
When using JSON, the structure will be a little bit different. Here we are using the same syntax like how Babel makes it possible to use plugins with extra options.
[PLUGIN, {...options}]
[PLUGIN, {...options}]
INFO
{
"$schema": "@kubb/core/schemas/config.json",
"root": ".",
"input": {
"path": "./petStore.yaml"
},
"output": {
"path": "./src/gen"
},
"plugins": [
[
"@kubb/swagger",
{
"output": "schemas",
"validate": true
}
]
]
}
{
"$schema": "@kubb/core/schemas/config.json",
"root": ".",
"input": {
"path": "./petStore.yaml"
},
"output": {
"path": "./src/gen"
},
"plugins": [
[
"@kubb/swagger",
{
"output": "schemas",
"validate": true
}
]
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
hooks
Hooks that will be called when a specific action is triggered in Kubb.
done
Hook that will be triggered at the end of Kubb's generation.
Useful for running Prettier or ESLint to format/lint your code.
INFO
Type: string | string[]
import { defineConfig } from '@kubb/core'
export default defineConfig({
hooks: {
done: ['npx prettier --write .'],
},
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
hooks: {
done: ['npx prettier --write .'],
},
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
11
12
13
import { defineConfig } from '@kubb/core'
export default defineConfig({
hooks: {
done: 'npx prettier --write .',
},
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
import { defineConfig } from '@kubb/core'
export default defineConfig({
hooks: {
done: 'npx prettier --write .',
},
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
2
3
4
5
6
7
8
9
10
11
12
13