Filter which schemas and operations get processed by plugins
Description
I want to be able to filter which schemas the Zod plugin processes so I don't waste time and codesize making validators or things I don't need.
I can't use the global parser filter because I do want to create Types for everything, I just specifically don't want validators for everything.
Hi @JonWolfeDrata! I'm Dosu and I’m helping the openapi-ts team.
The Zod plugin doesn't currently support filtering which schemas or operations get validators generated at a per-schema or per-operation level. You can only enable or disable validator generation for broad categories like requests, responses, or definitions using boolean flags in the plugin config (e.g., requests: true/false), but not for individual schemas or endpoints. The global parser filters apply before plugins and would also exclude type generation, which doesn't fit your use case. There isn't a documented workaround for plugin-level filtering—if you need more granular control, you'd need to handle it post-generation or consider a custom plugin. You can see the available Zod plugin options in the docs: Zod plugin configuration and parser filters.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
I already explored all those avenues and a post-generation fix is possible but annoying, and I could make a custom plugin to do the work if hey-api would expose the zod plugin as it's own export/package so I could wrap around it.
@JonWolfeDrata What's the motivation for generating specific Zod schemas? How are you using them?
Current: We use them as sources for enums the api exposes, and some requests get constructed via .parse.
Eventually: We want to enable validating both sides of the client calls automatically to catch contract violations.
The reason we're trying to do this is because the bundlers aren't tree shaking and dead code eliminating enough of the unused zod validators, so I want to go around the problem and just not generate the validators I'm not using.