Adapted from this recommendation by @jandockx
Despite supporting recursive schemas, passing cyclical data into Zod will cause an infinite loop in some cases.
You can protect against cyclical objects starting an infinite loop (at a performance cost) with the following approach
(using the above jsonSchema
as an example):