-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1430 from hey-api/fix/zod-schema-response
fix: generate response zod schemas
- Loading branch information
Showing
49 changed files
with
1,433 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
'@hey-api/openapi-ts': minor | ||
--- | ||
|
||
fix: require sdk.transformer to use generated transformers | ||
|
||
### Added `sdk.transformer` option | ||
|
||
When generating SDKs, you now have to specify `transformer` in order to modify response data. By default, adding `@hey-api/transformers` to your plugins will only produce additional output. To preserve the previous functionality, set `sdk.transformer` 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, | ||
{ | ||
dates: true, | ||
name: '@hey-api/transformers', | ||
}, | ||
{ | ||
name: '@hey-api/sdk', | ||
transformer: true, // [!code ++] | ||
}, | ||
], | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/docs': patch | ||
--- | ||
|
||
docs: add validators page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@hey-api/client-axios': patch | ||
'@hey-api/client-fetch': patch | ||
--- | ||
|
||
fix: add responseValidator option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
feat: Zod plugin generates response schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
title: Validators | ||
description: Learn about validating data with @hey-api/openapi-ts. | ||
--- | ||
|
||
# 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. | ||
|
||
Hey API clients support validating responses so you can rest assured that you're working with the correct data. | ||
|
||
## Available Validators | ||
|
||
- [Zod](/openapi-ts/validators/zod) | ||
- [Ajv](https://ajv.js.org/) <span class="soon">Soon</span> | ||
- [Joi](https://joi.dev/) <span class="soon">Soon</span> | ||
- [Yup](https://github.com/jquense/yup) <span class="soon">Soon</span> | ||
|
||
If you'd like Hey API to support your validator, let us know by [opening an issue](https://github.com/hey-api/openapi-ts/issues). | ||
|
||
## 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 the validator to your plugins and set `sdk.validator` to `true`. | ||
|
||
::: code-group | ||
|
||
```js [sdk] | ||
export default { | ||
client: '@hey-api/client-fetch', | ||
input: 'path/to/openapi.json', | ||
output: 'src/client', | ||
plugins: [ | ||
{ | ||
name: '@hey-api/sdk', | ||
validator: 'zod', // [!code ++] | ||
}, | ||
], | ||
}; | ||
``` | ||
|
||
```js [validator] | ||
export default { | ||
client: '@hey-api/client-fetch', | ||
input: 'path/to/openapi.json', | ||
output: 'src/client', | ||
plugins: [ | ||
{ | ||
name: '@hey-api/sdk', | ||
validator: true, // [!code ++] | ||
}, | ||
{ | ||
name: 'zod', // [!code ++] | ||
// other options | ||
}, | ||
], | ||
}; | ||
``` | ||
|
||
::: | ||
|
||
<!--@include: ../examples.md--> | ||
<!--@include: ../sponsorship.md--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.