Validators ​
There are times when you cannot blindly trust the server to return the correct data. You might be working on a critical application where any mistakes would be costly, or you're simply dealing with a legacy or undocumented system.
Whatever your reason to use validators might be, you can rest assured that you're working with the correct data.
Options ​
Hey API natively supports the following validators.
Don't see your validator? Let us know your interest by opening an issue.
Installation ​
There are two ways to generate validators. If you only need response validation in your SDKs, set sdk.validator
to the desired value. For a more granular approach, add your validator to plugins and set sdk.validator
to true
.
export default {
client: '@hey-api/client-fetch',
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
{
name: '@hey-api/sdk',
validator: 'zod',
},
],
};
export default {
client: '@hey-api/client-fetch',
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
{
name: '@hey-api/sdk',
validator: true,
},
{
name: 'zod',
// other options
},
],
};
Examples ​
You can view live examples on StackBlitz.
Sponsors ​
Love Hey API? Become our sponsor.