Skip to content

@kubb/swagger-zodios 🦙 ​

With the Swagger zodios plugin you can use zodios to validate your schema's based on a Swagger file.

Installation ​

shell
bun add @kubb/swagger-zodios @kubb/swagger-zod @kubb/swagger
shell
pnpm add @kubb/swagger-zodios @kubb/swagger-zod @kubb/swagger
shell
npm install @kubb/swagger-zodios @kubb/swagger-zod @kubb/swagger
shell
yarn add @kubb/swagger-zodios @kubb/swagger-zod @kubb/swagger

Options ​

output ​

output.path ​

Output to save the zodios instance.
Output should be a file(ending with .ts or .js).

INFO

Type: string
Default: 'zodios.ts'

typescript
import { pluginZodios } from '@kubb/swagger-zodios'

const plugin = pluginZodios({
  output: {
    path: './zodios.ts',
  },
})

output.exportAs ​

Name to be used for the export * as from './'

INFO

Type: string

typescript
import { pluginZodios } from '@kubb/swagger-zodios'

const plugin = pluginZodios({
  output: {
    path: './zodios.ts',
    exportAs: 'zodios',
  },
})

output.extName ​

Add an extension to the generated imports and exports, default it will not use an extension

INFO

Type: string

typescript
import { pluginZodios } from '@kubb/swagger-zodios'

const plugin = pluginZodios({
  output: {
    path: './zodios.ts',
    extName: '.js',
  },
})

output.exportType ​

Define what needs to exported, here you can also disable the export of barrel files

INFO

Type: 'barrel' | 'barrelNamed' | false

typescript
import { pluginZodios } from '@kubb/swagger-zodios'

const plugin = pluginZodios({
  output: {
    path: './zodios.ts',
    exportType: 'barrel',
  },
})

Example ​

typescript
import { defineConfig } from '@kubb/core'
import { pluginOas } from '@kubb/plugin-oas'
import { pluginZod } from '@kubb/swagger-zod'
import { pluginZodios } from '@kubb/swagger-zodios'

export default defineConfig({
  input: {
    path: './petStore.yaml',
  },
  output: {
    path: './src/gen',
  },
  plugins: [
    pluginOas(),
    pluginZod(),
    pluginZodios({
      output: {
        path: './zodios.ts',
      },
    }),
  ],
})

Released under the MIT License.