Support zod's infer type
<!--- Provide a general summary of the issue in the Title above --> When using a Zod validator and then passing it to TSOA, it throws this error: ` Error: No matching model found for referenced type infer.` Types File ``` export const MyValidator = z.object({ result: z.object({ price: z.string().nonempty() }), code: z.number(), msg: z.string().nonempty() }) export type MyResponse = z.infer<typeof MyValidator> ``` Then use it in TSO ``` @Get() public async getRequest (): Promise<MyResponse> { ``` ## Sorting - **I'm submitting a ...** - [ ] bug report - [x] feature request - [ ] support request - I confirm that I - [X] used the [search](https://github.com/lukeautry/tsoa/search?type=Issues) to make sure that a similar issue hasn't already been submit ## Expected Behavior When running `yarn tsoa spec-and-routes` I expect TSOA to be able to use the inferred type generated by Zod. ## Current Behavior It crashes with ``` Generate routes error. Error: No matching model found for referenced type infer. at new GenerateMetadataError (/Users/caseygibson/Documents/Github/node_modules/@tsoa/cli/dist/metadataGeneration/exceptions.js:22:28) ``` ## Context (Environment) Version of the library: "^3.14.1" Version of NodeJS: v14.17.4 - Confirm you were using yarn not npm: [X]
Posted by cgibson-swyftx on May 26, 2022, 11:24 PM
Tags
Related issues
- >Beef is already too expensive for most people.
- I gave this a go a couple of years ago.
- I haven't seen any use cases around me, although I'm not that advanced user.
- [BUG] Pro Max 5x Quota Exhausted in 1.5 Hours Despite Moderate Usage
- > Unfortunately it doesn't offer free hosting for hobbyists.
- Still the same HID remapping project from last month (I was hoping to be done by now, but hardware is hard): https://github.co...
Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments
pricing (Software)
>Beef is already too expensive for most people.
I gave this a go a couple of years ago.
I haven't seen any use cases around me, although I'm not that advanced user.
[BUG] Pro Max 5x Quota Exhausted in 1.5 Hours Despite Moderate Usage
> Unfortunately it doesn't offer free hosting for hobbyists.
Still the same HID remapping project from last month (I was hoping to be done by now, but hardware is hard): https://github.co...
This criticism seems like a complete non-sequitur to me.
Bring back the GitHub Copilot in the CLI commands to not break workflows
Support zod's infer type
<!--- Provide a general summary of the issue in the Title above --> When using a Zod validator and then passing it to TSOA, it throws this error: ` Error: No matching model found for referenced type infer.` Types File ``` export const MyValidator = z.object({ result: z.object({ price: z.string().nonempty() }), code: z.number(), msg: z.string().nonempty() }) export type MyResponse = z.infer<typeof MyValidator> ``` Then use it in TSO ``` @Get() public async getRequest (): Promise<MyResponse> { ``` ## Sorting - **I'm submitting a ...** - [ ] bug report - [x] feature request - [ ] support request - I confirm that I - [X] used the [search](https://github.com/lukeautry/tsoa/search?type=Issues) to make sure that a similar issue hasn't already been submit ## Expected Behavior When running `yarn tsoa spec-and-routes` I expect TSOA to be able to use the inferred type generated by Zod. ## Current Behavior It crashes with ``` Generate routes error. Error: No matching model found for referenced type infer. at new GenerateMetadataError (/Users/caseygibson/Documents/Github/node_modules/@tsoa/cli/dist/metadataGeneration/exceptions.js:22:28) ``` ## Context (Environment) Version of the library: "^3.14.1" Version of NodeJS: v14.17.4 - Confirm you were using yarn not npm: [X]
Comments (0)
No comments yet. Start the discussion.