Zod ​
WARNING
This feature is in development! 🎉 Try it out 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.
Assuming you have already created a configuration file, simply add zod
to your plugins and you'll be ready to generate Zod artifacts. 🎉
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',
],
};
SDKs ​
To automatically validate response data in your SDKs, set sdk.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.
Sponsors ​
Love Hey API? Become our sponsor.