Is your issue related to zod or zodios ? Yes, but it can be solved here.
Describe the bug
z.discriminatedUnion does not support lazy zod objects. We need to ensure that zod can extract the discriminator. so my proposed solution is to apply z.lazy() only to the properties that require lazy evaluation, rather than wrapping the entire object.
Edit:
my suggested solution has a type issue that i couldn't solve (discriminatedUnion expects options to be z.ZodObject but instead we are passing z.ZodType), so i have fallen back to use union instead of discriminatedUnion
Is your issue related to zod or zodios ? Yes, but it can be solved here.
Describe the bug z.discriminatedUnion does not support lazy zod objects. We need to ensure that zod can extract the discriminator. so my proposed solution is to apply z.lazy() only to the properties that require lazy evaluation, rather than wrapping the entire object.
Minimal reproduction
Expected behavior
Edit: my suggested solution has a type issue that i couldn't solve (discriminatedUnion expects options to be z.ZodObject but instead we are passing z.ZodType), so i have fallen back to use union instead of discriminatedUnion