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
The OpenAPI spec allows for portions of the spec to be split out to separate files which are referenced from the main spec. When attempting to run typed-openapi CLI on a project that had this setup I encountered the following error which prevented the typed zod schema from being created.
> npx typed-openapi .\main.yaml -r 'zod'
C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:124
return t.reference(refInfo.normalized);
^
TypeError: Cannot read properties of undefined (reading 'normalized')
at getTs (C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:124:34)
at openApiSchemaToTs (C:\Users\pvjpierson\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:227:16)
at getTs (C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:181:27)
at openApiSchemaToTs (C:\Users\pvjpierson\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:227:16)
at C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:211:26
at Array.map (<anonymous>)
at getTs (C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:210:43)
at openApiSchemaToTs (C:\Users\pvjpierson\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:227:16)
at C:\Users\myuser\AppData\Local\npm-cache\_npx\82013c35a310ca1e\node_modules\typed-openapi\dist\cli.cjs:806:25
at Array.forEach (<anonymous>)
Node.js v18.12.0
After some trial and error I was able to discover that if I just manually merged the spec files together into one file that the schema was able to be generated and the CLI tool ran as expected. It would be great if multi file specs using references could be supported so that this tool could be used directly on these valid spec files without having to manually tinker with them before running this tool.
The text was updated successfully, but these errors were encountered:
Currently I'm using openapi-flattener to preprocess the spec file but it's not quite ideal as it seems to also be flattening the separate schema's themselves which make up the spec. I'll see what I can do as far as contributing a PR.
The OpenAPI spec allows for portions of the spec to be split out to separate files which are referenced from the main spec. When attempting to run
typed-openapi
CLI on a project that had this setup I encountered the following error which prevented the typed zod schema from being created.After some trial and error I was able to discover that if I just manually merged the spec files together into one file that the schema was able to be generated and the CLI tool ran as expected. It would be great if multi file specs using references could be supported so that this tool could be used directly on these valid spec files without having to manually tinker with them before running this tool.
The text was updated successfully, but these errors were encountered: