Skip to content

Zod V4 uses the wrong import #1773

Closed
Closed
@mheob

Description

@mheob

What version of kubb is running?

3.12.0

What kind of platform do you use?

MacOS

Your kubb.config.ts config file?

import { defineConfig } from '@kubb/core';
import { pluginOas } from '@kubb/plugin-oas';
import { pluginZod } from '@kubb/plugin-zod';

export default defineConfig(() => {
	return {
		input: {
			path: './api/swagger.yaml',
		},
		output: {
			clean: true,
			extension: { '.ts': '' },
			path: './src/DataSources/Trainings/__generated__',
		},
		plugins: [
			pluginOas(),
			pluginZod({
				dateType: 'stringOffset',
				group: { type: 'tag' },
				inferred: true,
				output: { barrelType: 'propagate', path: './zod' },
				unknownType: 'unknown',
				version: '4',
			}),
		],
	};
});

Swagger/OpenAPI file?

not needed here

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

not needed here

What steps can reproduce the bug?

Set up the Zod plugin with using version 4 and run the generation by pnpm dlx kubb@latest generate --config kubb.config.ts.

How often does this bug happen?

Every time

What is the expected behaviour?

Current behavior:

Image

Expected behavior:

Image

Additional information

Thanks for implementing Zod v4.

Currently, incorrect imports are being used when generating with Zod v4. Instead of

import { z } from 'zod';

it should be

import { z } from 'zod/v4';

This issues have caused errors in the created schemas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions