Zod ​
WARNING
Zod plugin is in development. You can follow the updates and provide feedback on GitHub.
Zod is a TypeScript-first schema validation library with static type inference.
Features ​
- seamless integration with
@hey-api/openapi-ts
ecosystem - Zod schemas for requests, responses, and reusable components
Installation ​
WARNING
To use this feature, you must opt in to the experimental parser.
Ensure you have already configured @hey-api/openapi-ts
. Update your configuration to use the Zod plugin.
js
import { defaultPlugins } from '@hey-api/openapi-ts';
export default {
client: '@hey-api/client-fetch',
experimentalParser: true,
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
...defaultPlugins,
'zod',
],
};
You can now generate Zod artifacts. 🎉
SDKs ​
To automatically validate response data in your SDKs, set validator
to true
.
js
import { defaultPlugins } from '@hey-api/openapi-ts';
export default {
client: '@hey-api/client-fetch',
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
...defaultPlugins,
'zod',
{
name: '@hey-api/sdk',
validator: true,
},
],
};
Output ​
The Zod plugin will generate the following artifacts, depending on the input specification.
Schemas ​
More information will be provided as we finalize the plugin.
Examples ​
You can view live examples on StackBlitz.
Sponsoring ​
Love Hey API? Become our sponsor.