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 am working with a recursive schema in an OpenAPI specification file (openapi.json) and generating TypeScript types using this library. The generated types include a Zod schema for the recursive object. However, I'm facing an issue when I attempt to use the exported type in my code.
This manual fix seems to resolve the error but there might be an underlying problem that needs addressing. I tried to use something like --export-schemas but it didn't had an effect.
Any assistance or suggestions to rectify this error would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
not sure what the solution could be, it seems more like a zod/zodios/typescript issue.
I feel like exporting everything kinda pollutes the global imports across the app.
still, you can use a custom template -t, --template <path> Template path for the handlebars template that will be used to generate the output
also, if you don't need runtime validation you can use typed-openapi instead
We need runtime validation.
Actually I don't want to use the Item type here, but for some reason it must be exported. Otherwise the compiler can't resolve the types even if I only use the Zod schema.
But thanks for the input. I will look into the template method and consider to look into zodios.
Description:
I am working with a recursive schema in an OpenAPI specification file (openapi.json) and generating TypeScript types using this library. The generated types include a Zod schema for the recursive object. However, I'm facing an issue when I attempt to use the exported type in my code.
Steps to reproduce:
OpenAPI Specification (openapi.json):
Generated Code:
I generated the code using the following command:
This produces the following TypeScript code:
For reference, I export it like this in my index.ts:
Error Encountered:
When I use the Item type, I encounter the following compiler error:
Temporary Fix
I can work around this issue by manually adding an export statement to the
Item
type as follows:This manual fix seems to resolve the error but there might be an underlying problem that needs addressing. I tried to use something like
--export-schemas
but it didn't had an effect.Any assistance or suggestions to rectify this error would be greatly appreciated!
The text was updated successfully, but these errors were encountered: