[swagger-zod] readOnly properties are omitted using .and
, creating a intersection of never
and original type #943
Open
Description
What version of kubb
is running?
kubb/2.13.0 darwin-arm64 node-v20.11.1
What platform is your computer?
No response
What version of external packages are you using(@tanstack-query
, MSW
, React
, Vue
, ...)
zod: 3.22.4
What steps can reproduce the bug?
I have some readOnly properties, and the resulting zod schema attempts to omit them by using .and(z.object({ id: z.never() })
. This results in an intersection which means both schemas have to pass. For a never and some other type, that isn't possible so the validation always fails. See https://zod.dev/?id=and for more on .and
zod has an .omit
function that might be a better fit here: https://zod.dev/?id=pickomit
How often does this bug happen?
Every time
What is the expected behavior?
No response
Swagger/OpenAPI file?
No response
Additional information
No response