Skip to content

Extend a distinct zod instance #175

Answered by AGalabov
qw-in asked this question in Q&A
Discussion options

You must be logged in to vote

@qw-in thank you for the kind word. If I understood correctly you just want to do the extending in a single file and reexport it. You do not need createExtendedZod for that. What we've done for a project where we use it is:

// utils/zod.ts
import { z } from 'zod';

extendZodWithOpenApi(z);

export { z }; // If you want to "rename it" you can just use `export { z as oz };`

And then we import it as:

import { z } from '<path-here>/utils/zod'

We've also added an eslint rule not to import from 'zod' directly.

Is this what you intended and does this solve it for you?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@qw-in
Comment options

Answer selected by qw-in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants