You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to let you know that this issue still persists and I noticed that it also occurs when two schemas reference each other.
It works in the ZodGenerator test case due to the resolvePath mock.
I can offer to work on a fix for this issue. It would require to check for self references or circular dependencies between two or more schemas. Let me know if removing .schema from the zod schemas is an option you would consider or if you prefer another approach.
What version of
kubb
is running?kubb/2.0.1 linux-x64 node-v20.10.0
What platform is your computer?
Linux
What version of external packages are you using(
@tanstack-query
,MSW
,React
,Vue
, ...)No response
What steps can reproduce the bug?
Use
@kubb/swagger-zod
in combination with an OpenAPI schema that includes a component with self-referencing property (see example schema).The schema that is generated by
swagger-zod
causes the following error:ReferenceError: Cannot access 'exampleSchema' before initialization
Zod Schema:
Playground URL:
https://play.kubb.dev/?version=2.0.0&tanstack_version=4&msw_version=1&config=H4sIAAAAAAAAA12LMQ6EIBQF7%2FJq1N7KO2xpKDD%2BZY3IJ%2FDJZpdwd7Ux0W4ymSmIzIIeLRQWH%2FLBBcHI53RdIHkJR2p%2FZnOoCpzl3ljypw8u28Un9OOIYc3T1KWvsZYiVLmmt3GJqlaPpPnzDK3rDmTfWUCMAAAA&code=H4sIAAAAAAAAA51SsU7EMAzd%2BxVVYESXAtvtNzMwIoaQ89EcaWLFBoFO%2FXectFxLi25giez3%2FGznJaeqrlVECAad2tbqftNsbtVNRl04RIFOEkvGjj3kit2n6dBD%2FWhb6IwSti%2FlBOkDEknJU1EMOiHek8%2B6lhm3WvtojW8jsValoJfzuTRAwy1NAzUMg86IYK%2FAs1SABIQxENAvWIi7pllAAu6BbHLILoa80cNbueiswMbAEHilFMogemdN1uojlQbLmmzCYMpfnLDXCQ558JW2sZO9ZRTpQUJ69FWthH11KZ9nU%2FwT9WePh0ea5k5GjwvMfd6trM8%2F4AvLB4gvR7A8s05hkh%2BU2K2fIQAx7Md2S%2FYfjly8YdV%2FAypZNrbOAgAA
How often does this bug happen?
None
What is the expected behavior?
The zod schema can be used / imported without causing a reference error
Swagger/OpenAPI file?
Additional information
It looks like the schema works as expected if
.schema
is removed e.g.The text was updated successfully, but these errors were encountered: