Southclaws / supervillain

Converts Go structs to Zod schemas
MIT License
76 stars 6 forks source link

Fix for Deeply Nested Inline Structs #16

Closed m4tty-d closed 2 months ago

m4tty-d commented 2 months ago

I found an edge case during testing that I didn't cover in https://github.com/Southclaws/supervillain/pull/15.

When a struct contains multiple levels of embedded or inline structs, the generated Zod schema didn't accurately represent the flattened structure that Go would produce when marshaling to JSON.

This PR modifies the convertStruct function to recursively process inline and embedded structs. The new convertStructFields function is introduced to handle the recursive traversal of struct fields, including those from inline structs.