Quick start
Intro
The easiest way to get started with Kubb is just run the following in your cli. Kubb will search based on the configuration order which file/config it needs to use.
bash
kubb
kubb
Simple example
bash
kubb --config kubb.config.js
kubb --config kubb.config.js
typescript
import { defineConfig } from '@kubb/core'
export default defineConfig(async () => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [],
}
})
import { defineConfig } from '@kubb/core'
export default defineConfig(async () => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [],
}
})
Examples with plugins
bash
kubb --config kubb.config.js
kubb --config kubb.config.js
typescript
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'
export default defineConfig(async () => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [createSwagger({}), createSwaggerTS({}), createSwaggerTanstackQuery({})],
}
})
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'
export default defineConfig(async () => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [createSwagger({}), createSwaggerTS({}), createSwaggerTanstackQuery({})],
}
})
Example with plugins in JSON format
bash
kubb --config kubb.config.js
kubb --config kubb.config.js
typescript
import { defineConfig } from '@kubb/core'
export default defineConfig(() => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [
['@kubb/swagger', { output: false }],
['@kubb/swagger-ts', { output: 'models/ts' }],
['@kubb/swagger-tanstack-query', { output: './reactQuery' } }],
],
}
})
import { defineConfig } from '@kubb/core'
export default defineConfig(() => {
return {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [
['@kubb/swagger', { output: false }],
['@kubb/swagger-ts', { output: 'models/ts' }],
['@kubb/swagger-tanstack-query', { output: './reactQuery' } }],
],
}
})
If you're looking for a fully functioning example, please have a look at our simple codesandbox example.