-
Thanks for this, cool library! We use // somewhere.ts
import { z } from "zod":
import { createExtendedZod } from ".";
export const oz = createExtendedZod(z);
// elsewhere.ts
import { oz } from "./somewhere"
const schema = oz.string().openapi(/* ... */); Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@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 // 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 Is this what you intended and does this solve it for you? |
Beta Was this translation helpful? Give feedback.
@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:And then we import it as:
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?