[zod-openapi] How to generate a separate requestBody component?
I have several routes that get media files from user requests, and I want to separate them into a separate component to reuse them. But, I also have an array of allowed types to upload. So, I want to make the schema autogenerate itself when I add a new mime type to the array.
I wrote this abomination and it doesn't work. I should have stopped when typescript stopped showing the appropriate type for
mediaRequestBody
.
Here is how I'm using it:
What am I doing wrong?1 Reply
am not sure is it help for you but have you try
.merge
or .extend
?
https://zod.dev/?id=merge
https://zod.dev/?id=extendGitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference
GitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference