fork of hey-api/openapi-ts because I need some additional things

Merge pull request #2227 from hey-api/feat/sdk-validator-request

feat(sdk): add request validators

authored by

Lubos and committed by
GitHub
d387959b acac2979

+4451 -1941
+9
.changeset/clever-jeans-end.md
··· 1 + --- 2 + '@hey-api/openapi-ts': minor 3 + --- 4 + 5 + refactor(plugin): add `DefinePlugin` utility types 6 + 7 + ### Updated Plugin API 8 + 9 + Please refer to the [custom plugin](https://heyapi.dev/openapi-ts/plugins/custom) tutorial for the latest guide.
+26
.changeset/quick-hotels-knock.md
··· 1 + --- 2 + '@hey-api/openapi-ts': minor 3 + --- 4 + 5 + feat(sdk): update `validator` option 6 + 7 + ### Updated `sdk.validator` option 8 + 9 + Clients can now validate both request and response data. As a result, passing a boolean or string to `validator` will control both of these options. To preserve the previous behavior, set `validator.request` to `false` and `validator.response` to your previous configuration. 10 + 11 + ```js 12 + export default { 13 + input: 'https://get.heyapi.dev/hey-api/backend', 14 + output: 'src/client', 15 + plugins: [ 16 + // ...other plugins 17 + { 18 + name: '@hey-api/sdk', 19 + validator: { 20 + request: false, 21 + response: true, 22 + }, 23 + }, 24 + ], 25 + }; 26 + ```
+5
.changeset/real-horses-lay.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix(client): add requestValidator option
+29
docs/openapi-ts/migrating.md
··· 27 27 28 28 This config option is deprecated and will be removed. 29 29 30 + ## v0.77.0 31 + 32 + ### Updated `sdk.validator` option 33 + 34 + Clients can now validate both request and response data. As a result, passing a boolean or string to `validator` will control both of these options. To preserve the previous behavior, set `validator.request` to `false` and `validator.response` to your previous configuration. 35 + 36 + ```js 37 + export default { 38 + input: 'https://get.heyapi.dev/hey-api/backend', 39 + output: 'src/client', 40 + plugins: [ 41 + // ...other plugins 42 + { 43 + name: '@hey-api/sdk', 44 + validator: true, // [!code --] 45 + validator: { 46 + // [!code ++] 47 + request: false, // [!code ++] 48 + response: true, // [!code ++] 49 + }, // [!code ++] 50 + }, 51 + ], 52 + }; 53 + ``` 54 + 55 + ### Updated Plugin API 56 + 57 + Please refer to the [custom plugin](/openapi-ts/plugins/custom) tutorial for the latest guide. 58 + 30 59 ## v0.76.0 31 60 32 61 ### Single Valibot schema per request
+78
docs/openapi-ts/output/sdk.md
··· 146 146 147 147 ::: 148 148 149 + ## Validators 150 + 151 + There are two ways to configure validators. If you only want to add validators to your SDKs, set `sdk.validator` to a validator plugin name. This will implicitly add the selected plugin with default values. 152 + 153 + For a more granular approach, add a validator plugin and set `sdk.validator` to the plugin name or `true` to automatically select a plugin. Until you customize the validator plugin, both approaches will produce the same default output. 154 + 155 + ::: code-group 156 + 157 + ```js [sdk] 158 + export default { 159 + input: 'https://get.heyapi.dev/hey-api/backend', 160 + output: 'src/client', 161 + plugins: [ 162 + { 163 + name: '@hey-api/sdk', 164 + validator: 'zod', // [!code ++] 165 + }, 166 + ], 167 + }; 168 + ``` 169 + 170 + ```js [validator] 171 + export default { 172 + input: 'https://get.heyapi.dev/hey-api/backend', 173 + output: 'src/client', 174 + plugins: [ 175 + { 176 + name: '@hey-api/sdk', 177 + validator: true, // or 'zod' // [!code ++] 178 + }, 179 + { 180 + name: 'zod', // [!code ++] 181 + // other options 182 + }, 183 + ], 184 + }; 185 + ``` 186 + 187 + ::: 188 + 189 + You can choose to validate only requests or responses. 190 + 191 + ::: code-group 192 + 193 + ```js [requests] 194 + export default { 195 + input: 'https://get.heyapi.dev/hey-api/backend', 196 + output: 'src/client', 197 + plugins: [ 198 + { 199 + name: '@hey-api/sdk', 200 + validator: { 201 + request: 'zod', // [!code ++] 202 + }, 203 + }, 204 + ], 205 + }; 206 + ``` 207 + 208 + ```js [responses] 209 + export default { 210 + input: 'https://get.heyapi.dev/hey-api/backend', 211 + output: 'src/client', 212 + plugins: [ 213 + { 214 + name: '@hey-api/sdk', 215 + validator: { 216 + response: 'zod', // [!code ++] 217 + }, 218 + }, 219 + ], 220 + }; 221 + ``` 222 + 223 + ::: 224 + 225 + Learn more about available validators on the [Validators](/openapi-ts/validators) page. 226 + 149 227 <!--@include: ../../examples.md--> 150 228 <!--@include: ../../sponsors.md-->
+16 -22
docs/openapi-ts/plugins/custom.md
··· 19 19 20 20 ```ts [index.ts] 21 21 export { defaultConfig, defineConfig } from './config'; 22 - export type { Config } from './types'; 22 + export type { MyPlugin } from './types'; 23 23 ``` 24 24 25 25 ::: ··· 31 31 ::: code-group 32 32 33 33 ```ts [types.d.ts] 34 - export interface Config { 34 + import type { DefinePlugin } from '@hey-api/openapi-ts'; 35 + 36 + export type Config = { 35 37 /** 36 38 * Plugin name. Must be unique. 37 39 */ ··· 48 50 * @default false 49 51 */ 50 52 myOption?: boolean; 51 - } 53 + }; 54 + 55 + export type MyPlugin = DefinePlugin<Config>; 52 56 ``` 53 57 54 58 ::: 55 59 56 60 ## Configuration 57 61 58 - ::: tip 59 - Reserved fields are prefixed with an underscore and are not exposed to the user. 60 - ::: 61 - 62 - `config.ts` contains the runtime configuration for your plugin. It must implement the `Config` interface we created above and define `handler()` and `handlerLegacy()` functions from the `Plugin.Config` interface. 62 + `config.ts` contains the runtime configuration for your plugin. It must implement the `MyPlugin` interface we created above and define the `handler()` function from the `MyPlugin['Config']` interface. 63 63 64 64 ::: code-group 65 65 66 66 ```ts [config.ts] 67 - import type { Plugin } from '@hey-api/openapi-ts'; 67 + import { definePluginConfig } from '@hey-api/openapi-ts'; 68 68 69 69 import { handler } from './plugin'; 70 - import type { Config } from './types'; 70 + import type { MyPlugin } from './types'; 71 71 72 - export const defaultConfig: Plugin.Config<Config> = { 72 + export const defaultConfig: MyPlugin['Config'] = { 73 73 config: { 74 74 myOption: false, // implements default value from types 75 75 }, 76 76 dependencies: ['@hey-api/typescript'], 77 77 handler, 78 - handlerLegacy: () => {}, 79 78 name: 'my-plugin', 80 79 output: 'my-plugin', 81 80 }; ··· 83 82 /** 84 83 * Type helper for `my-plugin` plugin, returns {@link Plugin.Config} object 85 84 */ 86 - export const defineConfig: Plugin.DefineConfig<Config> = (config) => ({ 87 - ...defaultConfig, 88 - ...config, 89 - }); 85 + export const defineConfig = definePluginConfig(defaultConfig); 90 86 ``` 91 87 92 88 ::: ··· 106 102 ::: code-group 107 103 108 104 ```ts [plugin.ts] 109 - import type { Plugin } from '@hey-api/openapi-ts'; 105 + import type { MyPlugin } from './types'; 110 106 111 - import type { Config } from './types'; 112 - 113 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 107 + export const handler: MyPlugin['Handler'] = ({ plugin }) => { 114 108 // create an output file. it will not be 115 109 // generated until it contains nodes 116 110 const file = plugin.createFile({ ··· 149 143 150 144 ::: 151 145 152 - ### Legacy 146 + ### Legacy Handler 153 147 154 - Notice we defined `handlerLegacy` in our `config.ts` file. This method is responsible for generating the actual output when using the legacy parser. We do not recommend implementing this method unless you must use the legacy parser. You can use one of our [`plugin-legacy.ts`](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/%40hey-api/typescript/plugin-legacy.ts) files as an inspiration for potential implementation. 148 + You can also define an optional `handlerLegacy` function in `config.ts`. This method is responsible for generating the output when using the legacy parser. We do not recommend implementing this method unless you must use the legacy parser. You can use one of our [`plugin-legacy.ts`](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/%40hey-api/typescript/plugin-legacy.ts) files as an inspiration for potential implementation. 155 149 156 150 ## Usage 157 151
+3 -2
docs/openapi-ts/plugins/valibot.md
··· 45 45 46 46 ### SDKs 47 47 48 - To automatically validate response data in your SDKs, set `sdk.validator` to `true`. 48 + To add data validators to your SDKs, set `sdk.validator` to `true`. 49 49 50 50 ```js 51 51 export default { ··· 62 62 }; 63 63 ``` 64 64 65 + Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. 66 + 65 67 ## Output 66 68 67 69 The Valibot plugin will generate the following artifacts, depending on the input specification. ··· 78 80 bar: v.optional(v.union([v.number(), v.null()])), 79 81 }), 80 82 ), 81 - headers: v.optional(v.never()), 82 83 path: v.object({ 83 84 baz: v.string(), 84 85 }),
+3 -2
docs/openapi-ts/plugins/zod.md
··· 45 45 46 46 ### SDKs 47 47 48 - To automatically validate response data in your SDKs, set `sdk.validator` to `true`. 48 + To add data validators to your SDKs, set `sdk.validator` to `true`. 49 49 50 50 ```js 51 51 export default { ··· 62 62 }; 63 63 ``` 64 64 65 + Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. 66 + 65 67 ## Output 66 68 67 69 The Zod plugin will generate the following artifacts, depending on the input specification. ··· 78 80 bar: z.union([z.number(), z.null()]).optional(), 79 81 }) 80 82 .optional(), 81 - headers: z.never().optional(), 82 83 path: z.object({ 83 84 baz: z.string(), 84 85 }),
+5 -38
docs/openapi-ts/validators.md
··· 9 9 10 10 Whatever your reason to use validators might be, you can rest assured that you're working with the correct data. 11 11 12 + ## Features 13 + 14 + - seamless integration with `@hey-api/openapi-ts` ecosystem 15 + - schemas for requests, responses, and reusable definitions 16 + 12 17 ## Options 13 18 14 19 Hey API natively supports the following validators. ··· 22 27 - [Yup](/openapi-ts/plugins/yup) <span data-soon>Soon</span> 23 28 24 29 Don't see your validator? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues). 25 - 26 - ## Installation 27 - 28 - 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`. 29 - 30 - ::: code-group 31 - 32 - ```js [sdk] 33 - export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 35 - output: 'src/client', 36 - plugins: [ 37 - { 38 - name: '@hey-api/sdk', 39 - validator: 'zod', // [!code ++] 40 - }, 41 - ], 42 - }; 43 - ``` 44 - 45 - ```js [validator] 46 - export default { 47 - input: 'https://get.heyapi.dev/hey-api/backend', 48 - output: 'src/client', 49 - plugins: [ 50 - { 51 - name: '@hey-api/sdk', 52 - validator: true, // [!code ++] 53 - }, 54 - { 55 - name: 'zod', // [!code ++] 56 - // other options 57 - }, 58 - ], 59 - }; 60 - ``` 61 - 62 - ::: 63 30 64 31 <!--@include: ../examples.md--> 65 32 <!--@include: ../sponsors.md-->
+20 -8
examples/openapi-ts-fetch/src/client/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 } ··· 103 107 ? getParseAs(response.headers.get('Content-Type')) 104 108 : opts.parseAs) ?? 'json'; 105 109 106 - if (parseAs === 'stream') { 107 - return opts.responseStyle === 'data' 108 - ? response.body 109 - : { 110 - data: response.body, 111 - ...result, 112 - }; 110 + let data: any; 111 + switch (parseAs) { 112 + case 'arrayBuffer': 113 + case 'blob': 114 + case 'formData': 115 + case 'json': 116 + case 'text': 117 + data = await response[parseAs](); 118 + break; 119 + case 'stream': 120 + return opts.responseStyle === 'data' 121 + ? response.body 122 + : { 123 + data: response.body, 124 + ...result, 125 + }; 113 126 } 114 127 115 - let data = await response[parseAs](); 116 128 if (parseAs === 'json') { 117 129 if (opts.responseValidator) { 118 130 await opts.responseValidator(data);
+8 -1
examples/openapi-ts-fetch/src/client/client/types.ts
··· 33 33 * 34 34 * @default 'auto' 35 35 */ 36 - parseAs?: Exclude<keyof Body, 'body' | 'bodyUsed'> | 'auto' | 'stream'; 36 + parseAs?: 37 + | 'arrayBuffer' 38 + | 'auto' 39 + | 'blob' 40 + | 'formData' 41 + | 'json' 42 + | 'stream' 43 + | 'text'; 37 44 /** 38 45 * Should we return only data or multiple fields (data, error, response, etc.)? 39 46 *
+2
examples/openapi-ts-fetch/src/client/client/utils.ts
··· 182 182 if (cleanContent.startsWith('text/')) { 183 183 return 'text'; 184 184 } 185 + 186 + return; 185 187 }; 186 188 187 189 export const setAuthParams = async ({
+1 -1
examples/openapi-ts-fetch/src/client/core/bodySerializer.ts
··· 57 57 58 58 export const jsonBodySerializer = { 59 59 bodySerializer: <T>(body: T) => 60 - JSON.stringify(body, (key, value) => 60 + JSON.stringify(body, (_key, value) => 61 61 typeof value === 'bigint' ? value.toString() : value, 62 62 ), 63 63 };
+6
examples/openapi-ts-fetch/src/client/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
examples/openapi-ts-fetch/src/client/types.gen.ts
··· 560 560 /** 561 561 * successful operation 562 562 */ 563 - 200: Blob | File; 563 + 200: string; 564 564 }; 565 565 566 566 export type LoginUserResponse = LoginUserResponses[keyof LoginUserResponses];
+4 -1
examples/openapi-ts-sample/openapi-ts.config.ts
··· 14 14 runtimeConfigPath: './src/hey-api.ts', 15 15 }, 16 16 '@hey-api/schemas', 17 - '@hey-api/sdk', 17 + { 18 + name: '@hey-api/sdk', 19 + validator: 'zod', 20 + }, 18 21 { 19 22 enums: 'javascript', 20 23 name: '@hey-api/typescript',
+3 -1
examples/openapi-ts-sample/package.json
··· 16 16 "@radix-ui/react-icons": "1.3.2", 17 17 "@radix-ui/themes": "3.1.6", 18 18 "react": "19.0.0", 19 - "react-dom": "19.0.0" 19 + "react-dom": "19.0.0", 20 + "valibot": "1.1.0", 21 + "zod": "3.23.8" 20 22 }, 21 23 "devDependencies": { 22 24 "@config/vite-base": "workspace:*",
+7 -5
examples/openapi-ts-sample/src/App.tsx
··· 9 9 Section, 10 10 } from '@radix-ui/themes'; 11 11 12 - // @ts-expect-error 13 - import { postFoo } from './client/sdk.gen'; 12 + import { getPetById } from './client/sdk.gen'; 14 13 15 14 function App() { 16 15 const onClick = async () => { 17 - postFoo({ 18 - body: { 19 - foo: [[1, 2]], 16 + const response = await getPetById({ 17 + path: { 18 + // @ts-expect-error 19 + foo: 3, 20 + petId: 3, 20 21 }, 21 22 }); 23 + console.log(response); 22 24 }; 23 25 24 26 return (
+20 -8
examples/openapi-ts-sample/src/client/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 } ··· 103 107 ? getParseAs(response.headers.get('Content-Type')) 104 108 : opts.parseAs) ?? 'json'; 105 109 106 - if (parseAs === 'stream') { 107 - return opts.responseStyle === 'data' 108 - ? response.body 109 - : { 110 - data: response.body, 111 - ...result, 112 - }; 110 + let data: any; 111 + switch (parseAs) { 112 + case 'arrayBuffer': 113 + case 'blob': 114 + case 'formData': 115 + case 'json': 116 + case 'text': 117 + data = await response[parseAs](); 118 + break; 119 + case 'stream': 120 + return opts.responseStyle === 'data' 121 + ? response.body 122 + : { 123 + data: response.body, 124 + ...result, 125 + }; 113 126 } 114 127 115 - let data = await response[parseAs](); 116 128 if (parseAs === 'json') { 117 129 if (opts.responseValidator) { 118 130 await opts.responseValidator(data);
+8 -1
examples/openapi-ts-sample/src/client/client/types.ts
··· 33 33 * 34 34 * @default 'auto' 35 35 */ 36 - parseAs?: Exclude<keyof Body, 'body' | 'bodyUsed'> | 'auto' | 'stream'; 36 + parseAs?: 37 + | 'arrayBuffer' 38 + | 'auto' 39 + | 'blob' 40 + | 'formData' 41 + | 'json' 42 + | 'stream' 43 + | 'text'; 37 44 /** 38 45 * Should we return only data or multiple fields (data, error, response, etc.)? 39 46 *
+2
examples/openapi-ts-sample/src/client/client/utils.ts
··· 182 182 if (cleanContent.startsWith('text/')) { 183 183 return 'text'; 184 184 } 185 + 186 + return; 185 187 }; 186 188 187 189 export const setAuthParams = async ({
+1 -1
examples/openapi-ts-sample/src/client/core/bodySerializer.ts
··· 57 57 58 58 export const jsonBodySerializer = { 59 59 bodySerializer: <T>(body: T) => 60 - JSON.stringify(body, (key, value) => 60 + JSON.stringify(body, (_key, value) => 61 61 typeof value === 'bigint' ? value.toString() : value, 62 62 ), 63 63 };
+6
examples/openapi-ts-sample/src/client/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+85
examples/openapi-ts-sample/src/client/sdk.gen.ts
··· 61 61 UploadFileErrors, 62 62 UploadFileResponses, 63 63 } from './types.gen'; 64 + import { 65 + zAddPetData, 66 + zAddPetResponse, 67 + zCreateUserData, 68 + zCreateUserResponse, 69 + zCreateUsersWithListInputData, 70 + zCreateUsersWithListInputResponse, 71 + zDeleteOrderData, 72 + zDeletePetData, 73 + zDeleteUserData, 74 + zFindPetsByStatusData, 75 + zFindPetsByStatusResponse, 76 + zFindPetsByTagsData, 77 + zFindPetsByTagsResponse, 78 + zGetInventoryData, 79 + zGetInventoryResponse, 80 + zGetOrderByIdData, 81 + zGetOrderByIdResponse, 82 + zGetPetByIdData, 83 + zGetPetByIdResponse, 84 + zGetUserByNameData, 85 + zGetUserByNameResponse, 86 + zLoginUserData, 87 + zLoginUserResponse, 88 + zLogoutUserData, 89 + zPlaceOrderData, 90 + zPlaceOrderResponse, 91 + zUpdatePetData, 92 + zUpdatePetResponse, 93 + zUpdatePetWithFormData, 94 + zUpdatePetWithFormResponse, 95 + zUpdateUserData, 96 + zUploadFileData, 97 + zUploadFileResponse, 98 + } from './zod.gen'; 64 99 65 100 export type Options< 66 101 TData extends TDataShape = TDataShape, ··· 91 126 AddPetErrors, 92 127 ThrowOnError 93 128 >({ 129 + requestValidator: async (data) => await zAddPetData.parseAsync(data), 130 + responseValidator: async (data) => await zAddPetResponse.parseAsync(data), 94 131 security: [ 95 132 { 96 133 scheme: 'bearer', ··· 117 154 UpdatePetErrors, 118 155 ThrowOnError 119 156 >({ 157 + requestValidator: async (data) => await zUpdatePetData.parseAsync(data), 158 + responseValidator: async (data) => 159 + await zUpdatePetResponse.parseAsync(data), 120 160 security: [ 121 161 { 122 162 scheme: 'bearer', ··· 143 183 FindPetsByStatusErrors, 144 184 ThrowOnError 145 185 >({ 186 + requestValidator: async (data) => 187 + await zFindPetsByStatusData.parseAsync(data), 188 + responseValidator: async (data) => 189 + await zFindPetsByStatusResponse.parseAsync(data), 146 190 security: [ 147 191 { 148 192 scheme: 'bearer', ··· 165 209 FindPetsByTagsErrors, 166 210 ThrowOnError 167 211 >({ 212 + requestValidator: async (data) => 213 + await zFindPetsByTagsData.parseAsync(data), 214 + responseValidator: async (data) => 215 + await zFindPetsByTagsResponse.parseAsync(data), 168 216 security: [ 169 217 { 170 218 scheme: 'bearer', ··· 187 235 DeletePetErrors, 188 236 ThrowOnError 189 237 >({ 238 + requestValidator: async (data) => await zDeletePetData.parseAsync(data), 190 239 security: [ 191 240 { 192 241 scheme: 'bearer', ··· 209 258 GetPetByIdErrors, 210 259 ThrowOnError 211 260 >({ 261 + requestValidator: async (data) => await zGetPetByIdData.parseAsync(data), 262 + responseValidator: async (data) => 263 + await zGetPetByIdResponse.parseAsync(data), 212 264 security: [ 213 265 { 214 266 name: 'api_key', ··· 235 287 UpdatePetWithFormErrors, 236 288 ThrowOnError 237 289 >({ 290 + requestValidator: async (data) => 291 + await zUpdatePetWithFormData.parseAsync(data), 292 + responseValidator: async (data) => 293 + await zUpdatePetWithFormResponse.parseAsync(data), 238 294 security: [ 239 295 { 240 296 scheme: 'bearer', ··· 258 314 ThrowOnError 259 315 >({ 260 316 bodySerializer: null, 317 + requestValidator: async (data) => await zUploadFileData.parseAsync(data), 318 + responseValidator: async (data) => 319 + await zUploadFileResponse.parseAsync(data), 261 320 security: [ 262 321 { 263 322 scheme: 'bearer', ··· 284 343 GetInventoryErrors, 285 344 ThrowOnError 286 345 >({ 346 + requestValidator: async (data) => await zGetInventoryData.parseAsync(data), 347 + responseValidator: async (data) => 348 + await zGetInventoryResponse.parseAsync(data), 287 349 security: [ 288 350 { 289 351 name: 'api_key', ··· 306 368 PlaceOrderErrors, 307 369 ThrowOnError 308 370 >({ 371 + requestValidator: async (data) => await zPlaceOrderData.parseAsync(data), 372 + responseValidator: async (data) => 373 + await zPlaceOrderResponse.parseAsync(data), 309 374 url: '/store/order', 310 375 ...options, 311 376 headers: { ··· 326 391 DeleteOrderErrors, 327 392 ThrowOnError 328 393 >({ 394 + requestValidator: async (data) => await zDeleteOrderData.parseAsync(data), 329 395 url: '/store/order/{orderId}', 330 396 ...options, 331 397 }); ··· 342 408 GetOrderByIdErrors, 343 409 ThrowOnError 344 410 >({ 411 + requestValidator: async (data) => await zGetOrderByIdData.parseAsync(data), 412 + responseValidator: async (data) => 413 + await zGetOrderByIdResponse.parseAsync(data), 345 414 url: '/store/order/{orderId}', 346 415 ...options, 347 416 }); ··· 358 427 CreateUserErrors, 359 428 ThrowOnError 360 429 >({ 430 + requestValidator: async (data) => await zCreateUserData.parseAsync(data), 431 + responseValidator: async (data) => 432 + await zCreateUserResponse.parseAsync(data), 361 433 url: '/user', 362 434 ...options, 363 435 headers: { ··· 378 450 CreateUsersWithListInputErrors, 379 451 ThrowOnError 380 452 >({ 453 + requestValidator: async (data) => 454 + await zCreateUsersWithListInputData.parseAsync(data), 455 + responseValidator: async (data) => 456 + await zCreateUsersWithListInputResponse.parseAsync(data), 381 457 url: '/user/createWithList', 382 458 ...options, 383 459 headers: { ··· 398 474 LoginUserErrors, 399 475 ThrowOnError 400 476 >({ 477 + requestValidator: async (data) => await zLoginUserData.parseAsync(data), 478 + responseValidator: async (data) => 479 + await zLoginUserResponse.parseAsync(data), 401 480 url: '/user/login', 402 481 ...options, 403 482 }); ··· 414 493 LogoutUserErrors, 415 494 ThrowOnError 416 495 >({ 496 + requestValidator: async (data) => await zLogoutUserData.parseAsync(data), 417 497 url: '/user/logout', 418 498 ...options, 419 499 }); ··· 430 510 DeleteUserErrors, 431 511 ThrowOnError 432 512 >({ 513 + requestValidator: async (data) => await zDeleteUserData.parseAsync(data), 433 514 url: '/user/{username}', 434 515 ...options, 435 516 }); ··· 446 527 GetUserByNameErrors, 447 528 ThrowOnError 448 529 >({ 530 + requestValidator: async (data) => await zGetUserByNameData.parseAsync(data), 531 + responseValidator: async (data) => 532 + await zGetUserByNameResponse.parseAsync(data), 449 533 url: '/user/{username}', 450 534 ...options, 451 535 }); ··· 462 546 UpdateUserErrors, 463 547 ThrowOnError 464 548 >({ 549 + requestValidator: async (data) => await zUpdateUserData.parseAsync(data), 465 550 url: '/user/{username}', 466 551 ...options, 467 552 headers: {
+1 -1
examples/openapi-ts-sample/src/client/types.gen.ts
··· 560 560 /** 561 561 * successful operation 562 562 */ 563 - 200: Blob | File; 563 + 200: string; 564 564 }; 565 565 566 566 export type LoginUserResponse = LoginUserResponses[keyof LoginUserResponses];
+284
examples/openapi-ts-sample/src/client/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zOrder = z.object({ 6 + complete: z.boolean().optional(), 7 + id: z.coerce.bigint().optional(), 8 + petId: z.coerce.bigint().optional(), 9 + quantity: z.number().int().optional(), 10 + shipDate: z.string().datetime().optional(), 11 + status: z.enum(['placed', 'approved', 'delivered']).optional(), 12 + }); 13 + 14 + export const zCategory = z.object({ 15 + id: z.coerce.bigint().optional(), 16 + name: z.string().optional(), 17 + }); 18 + 19 + export const zUser = z.object({ 20 + email: z.string().optional(), 21 + firstName: z.string().optional(), 22 + id: z.coerce.bigint().optional(), 23 + lastName: z.string().optional(), 24 + password: z.string().optional(), 25 + phone: z.string().optional(), 26 + userStatus: z.number().int().optional(), 27 + username: z.string().optional(), 28 + }); 29 + 30 + export const zTag = z.object({ 31 + id: z.coerce.bigint().optional(), 32 + name: z.string().optional(), 33 + }); 34 + 35 + export const zPet = z.object({ 36 + category: zCategory.optional(), 37 + id: z.coerce.bigint().optional(), 38 + name: z.string(), 39 + photoUrls: z.array(z.string()), 40 + status: z.enum(['available', 'pending', 'sold']).optional(), 41 + tags: z.array(zTag).optional(), 42 + }); 43 + 44 + export const zApiResponse = z.object({ 45 + code: z.number().int().optional(), 46 + message: z.string().optional(), 47 + type: z.string().optional(), 48 + }); 49 + 50 + export const zPet2 = zPet; 51 + 52 + /** 53 + * List of user object 54 + */ 55 + export const zUserArray = z.array(zUser); 56 + 57 + export const zAddPetData = z.object({ 58 + body: zPet, 59 + path: z.never().optional(), 60 + query: z.never().optional(), 61 + }); 62 + 63 + /** 64 + * Successful operation 65 + */ 66 + export const zAddPetResponse = zPet; 67 + 68 + export const zUpdatePetData = z.object({ 69 + body: zPet, 70 + path: z.never().optional(), 71 + query: z.never().optional(), 72 + }); 73 + 74 + /** 75 + * Successful operation 76 + */ 77 + export const zUpdatePetResponse = zPet; 78 + 79 + export const zFindPetsByStatusData = z.object({ 80 + body: z.never().optional(), 81 + path: z.never().optional(), 82 + query: z 83 + .object({ 84 + status: z.enum(['available', 'pending', 'sold']).optional(), 85 + }) 86 + .optional(), 87 + }); 88 + 89 + /** 90 + * successful operation 91 + */ 92 + export const zFindPetsByStatusResponse = z.array(zPet); 93 + 94 + export const zFindPetsByTagsData = z.object({ 95 + body: z.never().optional(), 96 + path: z.never().optional(), 97 + query: z 98 + .object({ 99 + tags: z.array(z.string()).optional(), 100 + }) 101 + .optional(), 102 + }); 103 + 104 + /** 105 + * successful operation 106 + */ 107 + export const zFindPetsByTagsResponse = z.array(zPet); 108 + 109 + export const zDeletePetData = z.object({ 110 + body: z.never().optional(), 111 + headers: z 112 + .object({ 113 + api_key: z.string().optional(), 114 + }) 115 + .optional(), 116 + path: z.object({ 117 + petId: z.coerce.bigint(), 118 + }), 119 + query: z.never().optional(), 120 + }); 121 + 122 + export const zGetPetByIdData = z.object({ 123 + body: z.never().optional(), 124 + path: z.object({ 125 + petId: z.coerce.bigint(), 126 + }), 127 + query: z.never().optional(), 128 + }); 129 + 130 + /** 131 + * successful operation 132 + */ 133 + export const zGetPetByIdResponse = zPet; 134 + 135 + export const zUpdatePetWithFormData = z.object({ 136 + body: z.never().optional(), 137 + path: z.object({ 138 + petId: z.coerce.bigint(), 139 + }), 140 + query: z 141 + .object({ 142 + name: z.string().optional(), 143 + status: z.string().optional(), 144 + }) 145 + .optional(), 146 + }); 147 + 148 + /** 149 + * successful operation 150 + */ 151 + export const zUpdatePetWithFormResponse = zPet; 152 + 153 + export const zUploadFileData = z.object({ 154 + body: z.string().optional(), 155 + path: z.object({ 156 + petId: z.coerce.bigint(), 157 + }), 158 + query: z 159 + .object({ 160 + additionalMetadata: z.string().optional(), 161 + }) 162 + .optional(), 163 + }); 164 + 165 + /** 166 + * successful operation 167 + */ 168 + export const zUploadFileResponse = zApiResponse; 169 + 170 + export const zGetInventoryData = z.object({ 171 + body: z.never().optional(), 172 + path: z.never().optional(), 173 + query: z.never().optional(), 174 + }); 175 + 176 + /** 177 + * successful operation 178 + */ 179 + export const zGetInventoryResponse = z.object({}); 180 + 181 + export const zPlaceOrderData = z.object({ 182 + body: zOrder.optional(), 183 + path: z.never().optional(), 184 + query: z.never().optional(), 185 + }); 186 + 187 + /** 188 + * successful operation 189 + */ 190 + export const zPlaceOrderResponse = zOrder; 191 + 192 + export const zDeleteOrderData = z.object({ 193 + body: z.never().optional(), 194 + path: z.object({ 195 + orderId: z.coerce.bigint(), 196 + }), 197 + query: z.never().optional(), 198 + }); 199 + 200 + export const zGetOrderByIdData = z.object({ 201 + body: z.never().optional(), 202 + path: z.object({ 203 + orderId: z.coerce.bigint(), 204 + }), 205 + query: z.never().optional(), 206 + }); 207 + 208 + /** 209 + * successful operation 210 + */ 211 + export const zGetOrderByIdResponse = zOrder; 212 + 213 + export const zCreateUserData = z.object({ 214 + body: zUser.optional(), 215 + path: z.never().optional(), 216 + query: z.never().optional(), 217 + }); 218 + 219 + /** 220 + * successful operation 221 + */ 222 + export const zCreateUserResponse = zUser; 223 + 224 + export const zCreateUsersWithListInputData = z.object({ 225 + body: z.array(zUser).optional(), 226 + path: z.never().optional(), 227 + query: z.never().optional(), 228 + }); 229 + 230 + /** 231 + * Successful operation 232 + */ 233 + export const zCreateUsersWithListInputResponse = zUser; 234 + 235 + export const zLoginUserData = z.object({ 236 + body: z.never().optional(), 237 + path: z.never().optional(), 238 + query: z 239 + .object({ 240 + password: z.string().optional(), 241 + username: z.string().optional(), 242 + }) 243 + .optional(), 244 + }); 245 + 246 + /** 247 + * successful operation 248 + */ 249 + export const zLoginUserResponse = z.string(); 250 + 251 + export const zLogoutUserData = z.object({ 252 + body: z.never().optional(), 253 + path: z.never().optional(), 254 + query: z.never().optional(), 255 + }); 256 + 257 + export const zDeleteUserData = z.object({ 258 + body: z.never().optional(), 259 + path: z.object({ 260 + username: z.string(), 261 + }), 262 + query: z.never().optional(), 263 + }); 264 + 265 + export const zGetUserByNameData = z.object({ 266 + body: z.never().optional(), 267 + path: z.object({ 268 + username: z.string(), 269 + }), 270 + query: z.never().optional(), 271 + }); 272 + 273 + /** 274 + * successful operation 275 + */ 276 + export const zGetUserByNameResponse = zUser; 277 + 278 + export const zUpdateUserData = z.object({ 279 + body: zUser.optional(), 280 + path: z.object({ 281 + username: z.string(), 282 + }), 283 + query: z.never().optional(), 284 + });
+4
packages/custom-client/src/client.ts
··· 47 47 }); 48 48 } 49 49 50 + if (opts.requestValidator) { 51 + await opts.requestValidator(opts); 52 + } 53 + 50 54 if (opts.body && opts.bodySerializer) { 51 55 opts.body = opts.bodySerializer(opts.body); 52 56 }
+6
packages/custom-client/src/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+7 -6
packages/custom-client/src/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + export type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: '@hey-api/custom-client'; 15 - } 15 + }; 16 + 17 + export type CustomClientPlugin = DefinePlugin<Config>; 16 18 17 - export const defaultConfig: Plugin.Config<Config> = { 19 + export const defaultConfig: CustomClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: { 20 22 ...clientDefaultConfig, 21 23 bundle: false, 22 24 }, 23 - handler: clientPluginHandler, 24 - handlerLegacy: () => {}, 25 + handler: clientPluginHandler as unknown as CustomClientPlugin['Handler'], 25 26 name: '@hey-api/custom-client', 26 27 }; 27 28
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/body-response-text-plain/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/body-response-text-plain/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/form-data/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/form-data/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
-1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
··· 14 14 15 15 export const vPostFooData = v.object({ 16 16 body: v.optional(v.never()), 17 - headers: v.optional(v.never()), 18 17 path: v.optional(v.never()), 19 18 query: v.optional(v.never()) 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts
··· 2 2 3 3 import type { Options as ClientOptions, TDataShape, Client } from './client'; 4 4 import type { PostFooData, PostFooResponses } from './types.gen'; 5 + import { zPostFooData, zPostFooResponse } from './zod.gen'; 5 6 import { postFooResponseTransformer } from './transformers.gen'; 6 - import { zPostFooResponse } from './zod.gen'; 7 7 import { client as _heyApiClient } from './client.gen'; 8 8 9 9 export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { ··· 22 22 23 23 export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => { 24 24 return (options?.client ?? _heyApiClient).post<PostFooResponses, unknown, ThrowOnError>({ 25 + requestValidator: async (data) => { 26 + return await zPostFooData.parseAsync(data); 27 + }, 25 28 responseTransformer: postFooResponseTransformer, 26 29 responseValidator: async (data) => { 27 30 return await zPostFooResponse.parseAsync(data);
-1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
··· 14 14 15 15 export const zPostFooData = z.object({ 16 16 body: z.never().optional(), 17 - headers: z.never().optional(), 18 17 path: z.never().optional(), 19 18 query: z.never().optional() 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-ignore/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-ignore/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts
··· 228 228 229 229 export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 230 230 return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 231 - responseType: 'json', 232 231 querySerializer: { 233 232 array: { 234 233 explode: false, 235 234 style: 'form' 236 235 } 237 236 }, 237 + responseType: 'json', 238 238 url: '/api/v{api-version}/types', 239 239 ...options 240 240 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts
··· 228 228 229 229 export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 230 230 return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 231 - responseType: 'json', 232 231 querySerializer: { 233 232 array: { 234 233 explode: false, 235 234 style: 'form' 236 235 } 237 236 }, 237 + responseType: 'json', 238 238 url: '/api/v{api-version}/types', 239 239 ...options 240 240 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts
··· 228 228 229 229 export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 230 230 return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 231 - responseType: 'json', 232 231 querySerializer: { 233 232 array: { 234 233 explode: false, 235 234 style: 'form' 236 235 } 237 236 }, 237 + responseType: 'json', 238 238 url: '/api/v{api-version}/types', 239 239 ...options 240 240 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts
··· 228 228 229 229 export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 230 230 return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 231 - responseType: 'json', 232 231 querySerializer: { 233 232 array: { 234 233 explode: false, 235 234 style: 'form' 236 235 } 237 236 }, 237 + responseType: 'json', 238 238 url: '/api/v{api-version}/types', 239 239 ...options 240 240 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts
··· 228 228 229 229 export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 230 230 return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 231 - responseType: 'json', 232 231 querySerializer: { 233 232 array: { 234 233 explode: false, 235 234 style: 'form' 236 235 } 237 236 }, 237 + responseType: 'json', 238 238 url: '/api/v{api-version}/types', 239 239 ...options 240 240 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+6 -38
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts
··· 400 400 401 401 export const vServiceWithEmptyTagData = v.object({ 402 402 body: v.optional(v.never()), 403 - headers: v.optional(v.never()), 404 403 path: v.optional(v.never()), 405 404 query: v.optional(v.never()) 406 405 }); 407 406 408 407 export const vPatchApiVbyApiVersionNoTagData = v.object({ 409 408 body: v.optional(v.never()), 410 - headers: v.optional(v.never()), 411 409 path: v.optional(v.never()), 412 410 query: v.optional(v.never()) 413 411 }); 414 412 415 413 export const vFooWowData = v.object({ 416 414 body: v.optional(v.never()), 417 - headers: v.optional(v.never()), 418 415 path: v.optional(v.never()), 419 416 query: v.optional(v.never()) 420 417 }); 421 418 422 419 export const vDeleteCallWithoutParametersAndResponseData = v.object({ 423 420 body: v.optional(v.never()), 424 - headers: v.optional(v.never()), 425 421 path: v.optional(v.never()), 426 422 query: v.optional(v.never()) 427 423 }); 428 424 429 425 export const vGetCallWithoutParametersAndResponseData = v.object({ 430 426 body: v.optional(v.never()), 431 - headers: v.optional(v.never()), 432 427 path: v.optional(v.never()), 433 428 query: v.optional(v.never()) 434 429 }); 435 430 436 431 export const vHeadCallWithoutParametersAndResponseData = v.object({ 437 432 body: v.optional(v.never()), 438 - headers: v.optional(v.never()), 439 433 path: v.optional(v.never()), 440 434 query: v.optional(v.never()) 441 435 }); 442 436 443 437 export const vOptionsCallWithoutParametersAndResponseData = v.object({ 444 438 body: v.optional(v.never()), 445 - headers: v.optional(v.never()), 446 439 path: v.optional(v.never()), 447 440 query: v.optional(v.never()) 448 441 }); 449 442 450 443 export const vPatchCallWithoutParametersAndResponseData = v.object({ 451 444 body: v.optional(v.never()), 452 - headers: v.optional(v.never()), 453 445 path: v.optional(v.never()), 454 446 query: v.optional(v.never()) 455 447 }); 456 448 457 449 export const vPostCallWithoutParametersAndResponseData = v.object({ 458 450 body: v.optional(v.never()), 459 - headers: v.optional(v.never()), 460 451 path: v.optional(v.never()), 461 452 query: v.optional(v.never()) 462 453 }); 463 454 464 455 export const vPutCallWithoutParametersAndResponseData = v.object({ 465 456 body: v.optional(v.never()), 466 - headers: v.optional(v.never()), 467 457 path: v.optional(v.never()), 468 458 query: v.optional(v.never()) 469 459 }); 470 460 471 461 export const vCallWithDescriptionsData = v.object({ 472 462 body: v.optional(v.never()), 473 - headers: v.optional(v.never()), 474 463 path: v.optional(v.never()), 475 464 query: v.optional(v.object({ 476 465 parameterWithBreaks: v.optional(v.string()), ··· 484 473 485 474 export const vCallWithParametersData = v.object({ 486 475 body: v.optional(v.never()), 487 - headers: v.object({ 488 - parameterHeader: v.string() 489 - }), 490 476 path: v.object({ 491 477 parameterPath: v.string(), 492 478 'api-version': v.string() 493 479 }), 494 480 query: v.object({ 495 481 parameterQuery: v.string() 482 + }), 483 + headers: v.object({ 484 + parameterHeader: v.string() 496 485 }) 497 486 }); 498 487 499 488 export const vCallWithWeirdParameterNamesData = v.object({ 500 489 body: v.optional(v.never()), 501 - headers: v.object({ 502 - 'parameter.header': v.string() 503 - }), 504 490 path: v.object({ 505 491 'parameter.path.1': v.optional(v.string()), 506 492 'parameter-path-2': v.optional(v.string()), ··· 510 496 query: v.object({ 511 497 default: v.optional(v.string()), 512 498 'parameter-query': v.string() 499 + }), 500 + headers: v.object({ 501 + 'parameter.header': v.string() 513 502 }) 514 503 }); 515 504 516 505 export const vCallWithDefaultParametersData = v.object({ 517 506 body: v.optional(v.never()), 518 - headers: v.optional(v.never()), 519 507 path: v.optional(v.never()), 520 508 query: v.object({ 521 509 parameterString: v.optional(v.string(), 'Hello World!'), ··· 536 524 537 525 export const vCallWithDefaultOptionalParametersData = v.object({ 538 526 body: v.optional(v.never()), 539 - headers: v.optional(v.never()), 540 527 path: v.optional(v.never()), 541 528 query: v.optional(v.object({ 542 529 parameterString: v.optional(v.string(), 'Hello World!'), ··· 552 539 553 540 export const vCallToTestOrderOfParamsData = v.object({ 554 541 body: v.optional(v.never()), 555 - headers: v.optional(v.never()), 556 542 path: v.optional(v.never()), 557 543 query: v.object({ 558 544 parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), ··· 574 560 575 561 export const vDuplicateNameData = v.object({ 576 562 body: v.optional(v.never()), 577 - headers: v.optional(v.never()), 578 563 path: v.optional(v.never()), 579 564 query: v.optional(v.never()) 580 565 }); 581 566 582 567 export const vDuplicateName2Data = v.object({ 583 568 body: v.optional(v.never()), 584 - headers: v.optional(v.never()), 585 569 path: v.optional(v.never()), 586 570 query: v.optional(v.never()) 587 571 }); 588 572 589 573 export const vDuplicateName3Data = v.object({ 590 574 body: v.optional(v.never()), 591 - headers: v.optional(v.never()), 592 575 path: v.optional(v.never()), 593 576 query: v.optional(v.never()) 594 577 }); 595 578 596 579 export const vDuplicateName4Data = v.object({ 597 580 body: v.optional(v.never()), 598 - headers: v.optional(v.never()), 599 581 path: v.optional(v.never()), 600 582 query: v.optional(v.never()) 601 583 }); 602 584 603 585 export const vCallWithNoContentResponseData = v.object({ 604 586 body: v.optional(v.never()), 605 - headers: v.optional(v.never()), 606 587 path: v.optional(v.never()), 607 588 query: v.optional(v.never()) 608 589 }); 609 590 610 591 export const vCallWithResponseAndNoContentResponseData = v.object({ 611 592 body: v.optional(v.never()), 612 - headers: v.optional(v.never()), 613 593 path: v.optional(v.never()), 614 594 query: v.optional(v.never()) 615 595 }); ··· 621 601 622 602 export const vDummyAData = v.object({ 623 603 body: v.optional(v.never()), 624 - headers: v.optional(v.never()), 625 604 path: v.optional(v.never()), 626 605 query: v.optional(v.never()) 627 606 }); 628 607 629 608 export const vDummyBData = v.object({ 630 609 body: v.optional(v.never()), 631 - headers: v.optional(v.never()), 632 610 path: v.optional(v.never()), 633 611 query: v.optional(v.never()) 634 612 }); 635 613 636 614 export const vCallWithResponseData = v.object({ 637 615 body: v.optional(v.never()), 638 - headers: v.optional(v.never()), 639 616 path: v.optional(v.never()), 640 617 query: v.optional(v.never()) 641 618 }); ··· 647 624 648 625 export const vCallWithDuplicateResponsesData = v.object({ 649 626 body: v.optional(v.never()), 650 - headers: v.optional(v.never()), 651 627 path: v.optional(v.never()), 652 628 query: v.optional(v.never()) 653 629 }); ··· 659 635 660 636 export const vCallWithResponsesData = v.object({ 661 637 body: v.optional(v.never()), 662 - headers: v.optional(v.never()), 663 638 path: v.optional(v.never()), 664 639 query: v.optional(v.never()) 665 640 }); ··· 676 651 677 652 export const vCollectionFormatData = v.object({ 678 653 body: v.optional(v.never()), 679 - headers: v.optional(v.never()), 680 654 path: v.optional(v.never()), 681 655 query: v.object({ 682 656 parameterArrayCSV: v.array(v.string()), ··· 689 663 690 664 export const vTypesData = v.object({ 691 665 body: v.optional(v.never()), 692 - headers: v.optional(v.never()), 693 666 path: v.optional(v.object({ 694 667 id: v.optional(v.pipe(v.number(), v.integer())) 695 668 })), ··· 716 689 717 690 export const vComplexTypesData = v.object({ 718 691 body: v.optional(v.never()), 719 - headers: v.optional(v.never()), 720 692 path: v.optional(v.never()), 721 693 query: v.object({ 722 694 parameterObject: v.object({ ··· 739 711 740 712 export const vCallWithResultFromHeaderData = v.object({ 741 713 body: v.optional(v.never()), 742 - headers: v.optional(v.never()), 743 714 path: v.optional(v.never()), 744 715 query: v.optional(v.never()) 745 716 }); 746 717 747 718 export const vTestErrorCodeData = v.object({ 748 719 body: v.optional(v.never()), 749 - headers: v.optional(v.never()), 750 720 path: v.optional(v.never()), 751 721 query: v.object({ 752 722 status: v.string() ··· 755 725 756 726 export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 757 727 body: v.optional(v.never()), 758 - headers: v.optional(v.never()), 759 728 path: v.optional(v.never()), 760 729 query: v.object({ 761 730 'nonAsciiParamæøåÆØÅöôêÊ': v.pipe(v.number(), v.integer()) ··· 769 738 770 739 export const vPostApiVbyApiVersionBodyData = v.object({ 771 740 body: vParameterActivityParams, 772 - headers: v.optional(v.never()), 773 741 path: v.optional(v.never()), 774 742 query: v.optional(v.never()) 775 743 });
+6 -38
packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/zod/default/zod.gen.ts
··· 393 393 394 394 export const zServiceWithEmptyTagData = z.object({ 395 395 body: z.never().optional(), 396 - headers: z.never().optional(), 397 396 path: z.never().optional(), 398 397 query: z.never().optional() 399 398 }); 400 399 401 400 export const zPatchApiVbyApiVersionNoTagData = z.object({ 402 401 body: z.never().optional(), 403 - headers: z.never().optional(), 404 402 path: z.never().optional(), 405 403 query: z.never().optional() 406 404 }); 407 405 408 406 export const zFooWowData = z.object({ 409 407 body: z.never().optional(), 410 - headers: z.never().optional(), 411 408 path: z.never().optional(), 412 409 query: z.never().optional() 413 410 }); 414 411 415 412 export const zDeleteCallWithoutParametersAndResponseData = z.object({ 416 413 body: z.never().optional(), 417 - headers: z.never().optional(), 418 414 path: z.never().optional(), 419 415 query: z.never().optional() 420 416 }); 421 417 422 418 export const zGetCallWithoutParametersAndResponseData = z.object({ 423 419 body: z.never().optional(), 424 - headers: z.never().optional(), 425 420 path: z.never().optional(), 426 421 query: z.never().optional() 427 422 }); 428 423 429 424 export const zHeadCallWithoutParametersAndResponseData = z.object({ 430 425 body: z.never().optional(), 431 - headers: z.never().optional(), 432 426 path: z.never().optional(), 433 427 query: z.never().optional() 434 428 }); 435 429 436 430 export const zOptionsCallWithoutParametersAndResponseData = z.object({ 437 431 body: z.never().optional(), 438 - headers: z.never().optional(), 439 432 path: z.never().optional(), 440 433 query: z.never().optional() 441 434 }); 442 435 443 436 export const zPatchCallWithoutParametersAndResponseData = z.object({ 444 437 body: z.never().optional(), 445 - headers: z.never().optional(), 446 438 path: z.never().optional(), 447 439 query: z.never().optional() 448 440 }); 449 441 450 442 export const zPostCallWithoutParametersAndResponseData = z.object({ 451 443 body: z.never().optional(), 452 - headers: z.never().optional(), 453 444 path: z.never().optional(), 454 445 query: z.never().optional() 455 446 }); 456 447 457 448 export const zPutCallWithoutParametersAndResponseData = z.object({ 458 449 body: z.never().optional(), 459 - headers: z.never().optional(), 460 450 path: z.never().optional(), 461 451 query: z.never().optional() 462 452 }); 463 453 464 454 export const zCallWithDescriptionsData = z.object({ 465 455 body: z.never().optional(), 466 - headers: z.never().optional(), 467 456 path: z.never().optional(), 468 457 query: z.object({ 469 458 parameterWithBreaks: z.string().optional(), ··· 477 466 478 467 export const zCallWithParametersData = z.object({ 479 468 body: z.never().optional(), 480 - headers: z.object({ 481 - parameterHeader: z.string() 482 - }), 483 469 path: z.object({ 484 470 parameterPath: z.string(), 485 471 'api-version': z.string() 486 472 }), 487 473 query: z.object({ 488 474 parameterQuery: z.string() 475 + }), 476 + headers: z.object({ 477 + parameterHeader: z.string() 489 478 }) 490 479 }); 491 480 492 481 export const zCallWithWeirdParameterNamesData = z.object({ 493 482 body: z.never().optional(), 494 - headers: z.object({ 495 - 'parameter.header': z.string() 496 - }), 497 483 path: z.object({ 498 484 'parameter.path.1': z.string().optional(), 499 485 'parameter-path-2': z.string().optional(), ··· 503 489 query: z.object({ 504 490 default: z.string().optional(), 505 491 'parameter-query': z.string() 492 + }), 493 + headers: z.object({ 494 + 'parameter.header': z.string() 506 495 }) 507 496 }); 508 497 509 498 export const zCallWithDefaultParametersData = z.object({ 510 499 body: z.never().optional(), 511 - headers: z.never().optional(), 512 500 path: z.never().optional(), 513 501 query: z.object({ 514 502 parameterString: z.string().default('Hello World!'), ··· 529 517 530 518 export const zCallWithDefaultOptionalParametersData = z.object({ 531 519 body: z.never().optional(), 532 - headers: z.never().optional(), 533 520 path: z.never().optional(), 534 521 query: z.object({ 535 522 parameterString: z.string().optional().default('Hello World!'), ··· 545 532 546 533 export const zCallToTestOrderOfParamsData = z.object({ 547 534 body: z.never().optional(), 548 - headers: z.never().optional(), 549 535 path: z.never().optional(), 550 536 query: z.object({ 551 537 parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), ··· 567 553 568 554 export const zDuplicateNameData = z.object({ 569 555 body: z.never().optional(), 570 - headers: z.never().optional(), 571 556 path: z.never().optional(), 572 557 query: z.never().optional() 573 558 }); 574 559 575 560 export const zDuplicateName2Data = z.object({ 576 561 body: z.never().optional(), 577 - headers: z.never().optional(), 578 562 path: z.never().optional(), 579 563 query: z.never().optional() 580 564 }); 581 565 582 566 export const zDuplicateName3Data = z.object({ 583 567 body: z.never().optional(), 584 - headers: z.never().optional(), 585 568 path: z.never().optional(), 586 569 query: z.never().optional() 587 570 }); 588 571 589 572 export const zDuplicateName4Data = z.object({ 590 573 body: z.never().optional(), 591 - headers: z.never().optional(), 592 574 path: z.never().optional(), 593 575 query: z.never().optional() 594 576 }); 595 577 596 578 export const zCallWithNoContentResponseData = z.object({ 597 579 body: z.never().optional(), 598 - headers: z.never().optional(), 599 580 path: z.never().optional(), 600 581 query: z.never().optional() 601 582 }); 602 583 603 584 export const zCallWithResponseAndNoContentResponseData = z.object({ 604 585 body: z.never().optional(), 605 - headers: z.never().optional(), 606 586 path: z.never().optional(), 607 587 query: z.never().optional() 608 588 }); ··· 614 594 615 595 export const zDummyAData = z.object({ 616 596 body: z.never().optional(), 617 - headers: z.never().optional(), 618 597 path: z.never().optional(), 619 598 query: z.never().optional() 620 599 }); 621 600 622 601 export const zDummyBData = z.object({ 623 602 body: z.never().optional(), 624 - headers: z.never().optional(), 625 603 path: z.never().optional(), 626 604 query: z.never().optional() 627 605 }); 628 606 629 607 export const zCallWithResponseData = z.object({ 630 608 body: z.never().optional(), 631 - headers: z.never().optional(), 632 609 path: z.never().optional(), 633 610 query: z.never().optional() 634 611 }); ··· 640 617 641 618 export const zCallWithDuplicateResponsesData = z.object({ 642 619 body: z.never().optional(), 643 - headers: z.never().optional(), 644 620 path: z.never().optional(), 645 621 query: z.never().optional() 646 622 }); ··· 652 628 653 629 export const zCallWithResponsesData = z.object({ 654 630 body: z.never().optional(), 655 - headers: z.never().optional(), 656 631 path: z.never().optional(), 657 632 query: z.never().optional() 658 633 }); ··· 669 644 670 645 export const zCollectionFormatData = z.object({ 671 646 body: z.never().optional(), 672 - headers: z.never().optional(), 673 647 path: z.never().optional(), 674 648 query: z.object({ 675 649 parameterArrayCSV: z.array(z.string()), ··· 682 656 683 657 export const zTypesData = z.object({ 684 658 body: z.never().optional(), 685 - headers: z.never().optional(), 686 659 path: z.object({ 687 660 id: z.number().int().optional() 688 661 }).optional(), ··· 709 682 710 683 export const zComplexTypesData = z.object({ 711 684 body: z.never().optional(), 712 - headers: z.never().optional(), 713 685 path: z.never().optional(), 714 686 query: z.object({ 715 687 parameterObject: z.object({ ··· 732 704 733 705 export const zCallWithResultFromHeaderData = z.object({ 734 706 body: z.never().optional(), 735 - headers: z.never().optional(), 736 707 path: z.never().optional(), 737 708 query: z.never().optional() 738 709 }); 739 710 740 711 export const zTestErrorCodeData = z.object({ 741 712 body: z.never().optional(), 742 - headers: z.never().optional(), 743 713 path: z.never().optional(), 744 714 query: z.object({ 745 715 status: z.string() ··· 748 718 749 719 export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 750 720 body: z.never().optional(), 751 - headers: z.never().optional(), 752 721 path: z.never().optional(), 753 722 query: z.object({ 754 723 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() ··· 762 731 763 732 export const zPostApiVbyApiVersionBodyData = z.object({ 764 733 body: zParameterActivityParams, 765 - headers: z.never().optional(), 766 734 path: z.never().optional(), 767 735 query: z.never().optional() 768 736 });
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/read-write-only/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/read-write-only/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/schema-unknown/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/schema-unknown/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-api-key/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-api-key/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-basic/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-basic/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-oauth2/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/security-oauth2/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers-base-path/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers-base-path/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers-host/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers-host/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/2.0.x/servers/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/body-response-text-plain/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/body-response-text-plain/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/content-types/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/content-types/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/internal-name-conflict/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/internal-name-conflict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/parameter-explode-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/parameter-explode-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
-1
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
··· 14 14 15 15 export const vPostFooData = v.object({ 16 16 body: v.optional(v.never()), 17 - headers: v.optional(v.never()), 18 17 path: v.optional(v.never()), 19 18 query: v.optional(v.never()) 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4 -1
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts
··· 2 2 3 3 import type { Options as ClientOptions, TDataShape, Client } from './client'; 4 4 import type { PostFooData, PostFooResponses } from './types.gen'; 5 + import { zPostFooData, zPostFooResponse } from './zod.gen'; 5 6 import { postFooResponseTransformer } from './transformers.gen'; 6 - import { zPostFooResponse } from './zod.gen'; 7 7 import { client as _heyApiClient } from './client.gen'; 8 8 9 9 export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { ··· 22 22 23 23 export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => { 24 24 return (options?.client ?? _heyApiClient).post<PostFooResponses, unknown, ThrowOnError>({ 25 + requestValidator: async (data) => { 26 + return await zPostFooData.parseAsync(data); 27 + }, 25 28 responseTransformer: postFooResponseTransformer, 26 29 responseValidator: async (data) => { 27 30 return await zPostFooResponse.parseAsync(data);
-1
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
··· 14 14 15 15 export const zPostFooData = z.object({ 16 16 body: z.never().optional(), 17 - headers: z.never().optional(), 18 17 path: z.never().optional(), 19 18 query: z.never().optional() 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-ignore/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-ignore/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+20 -64
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts
··· 1072 1072 1073 1073 export const vExportData = v.object({ 1074 1074 body: v.optional(v.never()), 1075 - headers: v.optional(v.never()), 1076 1075 path: v.optional(v.never()), 1077 1076 query: v.optional(v.never()) 1078 1077 }); 1079 1078 1080 1079 export const vPatchApiVbyApiVersionNoTagData = v.object({ 1081 1080 body: v.optional(v.never()), 1082 - headers: v.optional(v.never()), 1083 1081 path: v.optional(v.never()), 1084 1082 query: v.optional(v.never()) 1085 1083 }); ··· 1089 1087 vModelWithReadOnlyAndWriteOnly, 1090 1088 vModelWithArrayReadOnlyAndWriteOnly 1091 1089 ]), 1092 - headers: v.optional(v.never()), 1093 1090 path: v.optional(v.never()), 1094 1091 query: v.optional(v.never()) 1095 1092 }); ··· 1101 1098 1102 1099 export const vFooWowData = v.object({ 1103 1100 body: v.optional(v.never()), 1104 - headers: v.optional(v.never()), 1105 1101 path: v.optional(v.never()), 1106 1102 query: v.optional(v.never()) 1107 1103 }); 1108 1104 1109 1105 export const vApiVVersionODataControllerCountData = v.object({ 1110 1106 body: v.optional(v.never()), 1111 - headers: v.optional(v.never()), 1112 1107 path: v.optional(v.never()), 1113 1108 query: v.optional(v.never()) 1114 1109 }); ··· 1120 1115 1121 1116 export const vGetApiVbyApiVersionSimpleOperationData = v.object({ 1122 1117 body: v.optional(v.never()), 1123 - headers: v.optional(v.never()), 1124 1118 path: v.object({ 1125 1119 foo_param: v.string() 1126 1120 }), ··· 1134 1128 1135 1129 export const vDeleteCallWithoutParametersAndResponseData = v.object({ 1136 1130 body: v.optional(v.never()), 1137 - headers: v.optional(v.never()), 1138 1131 path: v.optional(v.never()), 1139 1132 query: v.optional(v.never()) 1140 1133 }); 1141 1134 1142 1135 export const vGetCallWithoutParametersAndResponseData = v.object({ 1143 1136 body: v.optional(v.never()), 1144 - headers: v.optional(v.never()), 1145 1137 path: v.optional(v.never()), 1146 1138 query: v.optional(v.never()) 1147 1139 }); 1148 1140 1149 1141 export const vHeadCallWithoutParametersAndResponseData = v.object({ 1150 1142 body: v.optional(v.never()), 1151 - headers: v.optional(v.never()), 1152 1143 path: v.optional(v.never()), 1153 1144 query: v.optional(v.never()) 1154 1145 }); 1155 1146 1156 1147 export const vOptionsCallWithoutParametersAndResponseData = v.object({ 1157 1148 body: v.optional(v.never()), 1158 - headers: v.optional(v.never()), 1159 1149 path: v.optional(v.never()), 1160 1150 query: v.optional(v.never()) 1161 1151 }); 1162 1152 1163 1153 export const vPatchCallWithoutParametersAndResponseData = v.object({ 1164 1154 body: v.optional(v.never()), 1165 - headers: v.optional(v.never()), 1166 1155 path: v.optional(v.never()), 1167 1156 query: v.optional(v.never()) 1168 1157 }); 1169 1158 1170 1159 export const vPostCallWithoutParametersAndResponseData = v.object({ 1171 1160 body: v.optional(v.never()), 1172 - headers: v.optional(v.never()), 1173 1161 path: v.optional(v.never()), 1174 1162 query: v.optional(v.never()) 1175 1163 }); 1176 1164 1177 1165 export const vPutCallWithoutParametersAndResponseData = v.object({ 1178 1166 body: v.optional(v.never()), 1179 - headers: v.optional(v.never()), 1180 1167 path: v.optional(v.never()), 1181 1168 query: v.optional(v.never()) 1182 1169 }); 1183 1170 1184 1171 export const vDeleteFooData3 = v.object({ 1185 1172 body: v.optional(v.never()), 1186 - headers: v.object({ 1187 - 'x-Foo-Bar': vModelWithString 1188 - }), 1189 1173 path: v.object({ 1190 1174 foo_param: v.string(), 1191 1175 BarParam: v.string() 1192 1176 }), 1193 - query: v.optional(v.never()) 1177 + query: v.optional(v.never()), 1178 + headers: v.object({ 1179 + 'x-Foo-Bar': vModelWithString 1180 + }) 1194 1181 }); 1195 1182 1196 1183 export const vCallWithDescriptionsData = v.object({ 1197 1184 body: v.optional(v.never()), 1198 - headers: v.optional(v.never()), 1199 1185 path: v.optional(v.never()), 1200 1186 query: v.optional(v.object({ 1201 1187 parameterWithBreaks: v.optional(v.string()), ··· 1209 1195 1210 1196 export const vDeprecatedCallData = v.object({ 1211 1197 body: v.optional(v.never()), 1212 - headers: v.optional(v.object({ 1198 + path: v.optional(v.never()), 1199 + query: v.optional(v.never()), 1200 + headers: v.object({ 1213 1201 parameter: v.union([ 1214 1202 vDeprecatedModel, 1215 1203 v.null() 1216 1204 ]) 1217 - })), 1218 - path: v.optional(v.never()), 1219 - query: v.optional(v.never()) 1205 + }) 1220 1206 }); 1221 1207 1222 1208 export const vCallWithParametersData = v.object({ ··· 1224 1210 v.object({}), 1225 1211 v.null() 1226 1212 ]), 1227 - headers: v.object({ 1228 - parameterHeader: v.union([ 1229 - v.string(), 1230 - v.null() 1231 - ]) 1232 - }), 1233 1213 path: v.object({ 1234 1214 parameterPath: v.union([ 1235 1215 v.string(), ··· 1244 1224 foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), 1245 1225 foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, 1246 1226 cursor: v.union([ 1227 + v.string(), 1228 + v.null() 1229 + ]) 1230 + }), 1231 + headers: v.object({ 1232 + parameterHeader: v.union([ 1247 1233 v.string(), 1248 1234 v.null() 1249 1235 ]) ··· 1255 1241 vModelWithString, 1256 1242 v.null() 1257 1243 ]), 1258 - headers: v.object({ 1259 - 'parameter.header': v.union([ 1260 - v.string(), 1261 - v.null() 1262 - ]) 1263 - }), 1264 1244 path: v.object({ 1265 1245 'parameter.path.1': v.optional(v.string()), 1266 1246 'parameter-path-2': v.optional(v.string()), ··· 1276 1256 v.string(), 1277 1257 v.null() 1278 1258 ]) 1259 + }), 1260 + headers: v.object({ 1261 + 'parameter.header': v.union([ 1262 + v.string(), 1263 + v.null() 1264 + ]) 1279 1265 }) 1280 1266 }); 1281 1267 1282 1268 export const vGetCallWithOptionalParamData = v.object({ 1283 1269 body: vModelWithOneOfEnum, 1284 - headers: v.optional(v.never()), 1285 1270 path: v.optional(v.never()), 1286 1271 query: v.optional(v.object({ 1287 1272 page: v.optional(v.number()) ··· 1295 1280 v.null() 1296 1281 ])) 1297 1282 })), 1298 - headers: v.optional(v.never()), 1299 1283 path: v.optional(v.never()), 1300 1284 query: v.object({ 1301 1285 parameter: vPageable ··· 1309 1293 1310 1294 export const vPostApiVbyApiVersionRequestBodyData = v.object({ 1311 1295 body: v.optional(vSimpleRequestBody), 1312 - headers: v.optional(v.never()), 1313 1296 path: v.optional(v.never()), 1314 1297 query: v.optional(v.object({ 1315 1298 parameter: v.optional(v.string()) ··· 1318 1301 1319 1302 export const vPostApiVbyApiVersionFormDataData = v.object({ 1320 1303 body: v.optional(vSimpleFormData), 1321 - headers: v.optional(v.never()), 1322 1304 path: v.optional(v.never()), 1323 1305 query: v.optional(v.object({ 1324 1306 parameter: v.optional(v.string()) ··· 1327 1309 1328 1310 export const vCallWithDefaultParametersData = v.object({ 1329 1311 body: v.optional(v.never()), 1330 - headers: v.optional(v.never()), 1331 1312 path: v.optional(v.never()), 1332 1313 query: v.optional(v.object({ 1333 1314 parameterString: v.optional(v.union([ ··· 1356 1337 1357 1338 export const vCallWithDefaultOptionalParametersData = v.object({ 1358 1339 body: v.optional(v.never()), 1359 - headers: v.optional(v.never()), 1360 1340 path: v.optional(v.never()), 1361 1341 query: v.optional(v.object({ 1362 1342 parameterString: v.optional(v.string(), 'Hello World!'), ··· 1373 1353 1374 1354 export const vCallToTestOrderOfParamsData = v.object({ 1375 1355 body: v.optional(v.never()), 1376 - headers: v.optional(v.never()), 1377 1356 path: v.optional(v.never()), 1378 1357 query: v.object({ 1379 1358 parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), ··· 1395 1374 1396 1375 export const vDuplicateNameData = v.object({ 1397 1376 body: v.optional(v.never()), 1398 - headers: v.optional(v.never()), 1399 1377 path: v.optional(v.never()), 1400 1378 query: v.optional(v.never()) 1401 1379 }); 1402 1380 1403 1381 export const vDuplicateName2Data = v.object({ 1404 1382 body: v.optional(v.never()), 1405 - headers: v.optional(v.never()), 1406 1383 path: v.optional(v.never()), 1407 1384 query: v.optional(v.never()) 1408 1385 }); 1409 1386 1410 1387 export const vDuplicateName3Data = v.object({ 1411 1388 body: v.optional(v.never()), 1412 - headers: v.optional(v.never()), 1413 1389 path: v.optional(v.never()), 1414 1390 query: v.optional(v.never()) 1415 1391 }); 1416 1392 1417 1393 export const vDuplicateName4Data = v.object({ 1418 1394 body: v.optional(v.never()), 1419 - headers: v.optional(v.never()), 1420 1395 path: v.optional(v.never()), 1421 1396 query: v.optional(v.never()) 1422 1397 }); 1423 1398 1424 1399 export const vCallWithNoContentResponseData = v.object({ 1425 1400 body: v.optional(v.never()), 1426 - headers: v.optional(v.never()), 1427 1401 path: v.optional(v.never()), 1428 1402 query: v.optional(v.never()) 1429 1403 }); ··· 1435 1409 1436 1410 export const vCallWithResponseAndNoContentResponseData = v.object({ 1437 1411 body: v.optional(v.never()), 1438 - headers: v.optional(v.never()), 1439 1412 path: v.optional(v.never()), 1440 1413 query: v.optional(v.never()) 1441 1414 }); ··· 1447 1420 1448 1421 export const vDummyAData = v.object({ 1449 1422 body: v.optional(v.never()), 1450 - headers: v.optional(v.never()), 1451 1423 path: v.optional(v.never()), 1452 1424 query: v.optional(v.never()) 1453 1425 }); ··· 1456 1428 1457 1429 export const vDummyBData = v.object({ 1458 1430 body: v.optional(v.never()), 1459 - headers: v.optional(v.never()), 1460 1431 path: v.optional(v.never()), 1461 1432 query: v.optional(v.never()) 1462 1433 }); ··· 1468 1439 1469 1440 export const vCallWithResponseData = v.object({ 1470 1441 body: v.optional(v.never()), 1471 - headers: v.optional(v.never()), 1472 1442 path: v.optional(v.never()), 1473 1443 query: v.optional(v.never()) 1474 1444 }); ··· 1477 1447 1478 1448 export const vCallWithDuplicateResponsesData = v.object({ 1479 1449 body: v.optional(v.never()), 1480 - headers: v.optional(v.never()), 1481 1450 path: v.optional(v.never()), 1482 1451 query: v.optional(v.never()) 1483 1452 }); ··· 1492 1461 1493 1462 export const vCallWithResponsesData = v.object({ 1494 1463 body: v.optional(v.never()), 1495 - headers: v.optional(v.never()), 1496 1464 path: v.optional(v.never()), 1497 1465 query: v.optional(v.never()) 1498 1466 }); ··· 1509 1477 1510 1478 export const vCollectionFormatData = v.object({ 1511 1479 body: v.optional(v.never()), 1512 - headers: v.optional(v.never()), 1513 1480 path: v.optional(v.never()), 1514 1481 query: v.object({ 1515 1482 parameterArrayCSV: v.union([ ··· 1537 1504 1538 1505 export const vTypesData = v.object({ 1539 1506 body: v.optional(v.never()), 1540 - headers: v.optional(v.never()), 1541 1507 path: v.optional(v.object({ 1542 1508 id: v.optional(v.pipe(v.number(), v.integer())) 1543 1509 })), ··· 1580 1546 1581 1547 export const vUploadFileData = v.object({ 1582 1548 body: v.string(), 1583 - headers: v.optional(v.never()), 1584 1549 path: v.object({ 1585 1550 'api-version': v.union([ 1586 1551 v.string(), ··· 1594 1559 1595 1560 export const vFileResponseData = v.object({ 1596 1561 body: v.optional(v.never()), 1597 - headers: v.optional(v.never()), 1598 1562 path: v.object({ 1599 1563 id: v.string(), 1600 1564 'api-version': v.string() ··· 1609 1573 1610 1574 export const vComplexTypesData = v.object({ 1611 1575 body: v.optional(v.never()), 1612 - headers: v.optional(v.never()), 1613 1576 path: v.optional(v.never()), 1614 1577 query: v.object({ 1615 1578 parameterObject: v.object({ ··· 1630 1593 1631 1594 export const vMultipartResponseData = v.object({ 1632 1595 body: v.optional(v.never()), 1633 - headers: v.optional(v.never()), 1634 1596 path: v.optional(v.never()), 1635 1597 query: v.optional(v.never()) 1636 1598 }); ··· 1654 1616 v.null() 1655 1617 ])) 1656 1618 })), 1657 - headers: v.optional(v.never()), 1658 1619 path: v.optional(v.never()), 1659 1620 query: v.optional(v.never()) 1660 1621 }); ··· 1697 1658 ]), v.readonly())) 1698 1659 }), v.readonly())) 1699 1660 })), 1700 - headers: v.optional(v.never()), 1701 1661 path: v.object({ 1702 1662 id: v.pipe(v.number(), v.integer()), 1703 1663 'api-version': v.string() ··· 1712 1672 1713 1673 export const vCallWithResultFromHeaderData = v.object({ 1714 1674 body: v.optional(v.never()), 1715 - headers: v.optional(v.never()), 1716 1675 path: v.optional(v.never()), 1717 1676 query: v.optional(v.never()) 1718 1677 }); 1719 1678 1720 1679 export const vTestErrorCodeData = v.object({ 1721 1680 body: v.optional(v.never()), 1722 - headers: v.optional(v.never()), 1723 1681 path: v.optional(v.never()), 1724 1682 query: v.object({ 1725 1683 status: v.pipe(v.number(), v.integer()) ··· 1728 1686 1729 1687 export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 1730 1688 body: v.optional(v.never()), 1731 - headers: v.optional(v.never()), 1732 1689 path: v.optional(v.never()), 1733 1690 query: v.object({ 1734 1691 'nonAsciiParamæøåÆØÅöôêÊ': v.pipe(v.number(), v.integer()) ··· 1742 1699 1743 1700 export const vPutWithFormUrlEncodedData = v.object({ 1744 1701 body: vArrayWithStrings, 1745 - headers: v.optional(v.never()), 1746 1702 path: v.optional(v.never()), 1747 1703 query: v.optional(v.never()) 1748 1704 });
+19 -63
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/zod/default/zod.gen.ts
··· 1057 1057 1058 1058 export const zExportData = z.object({ 1059 1059 body: z.never().optional(), 1060 - headers: z.never().optional(), 1061 1060 path: z.never().optional(), 1062 1061 query: z.never().optional() 1063 1062 }); 1064 1063 1065 1064 export const zPatchApiVbyApiVersionNoTagData = z.object({ 1066 1065 body: z.never().optional(), 1067 - headers: z.never().optional(), 1068 1066 path: z.never().optional(), 1069 1067 query: z.never().optional() 1070 1068 }); ··· 1074 1072 zModelWithReadOnlyAndWriteOnly, 1075 1073 zModelWithArrayReadOnlyAndWriteOnly 1076 1074 ]), 1077 - headers: z.never().optional(), 1078 1075 path: z.never().optional(), 1079 1076 query: z.never().optional() 1080 1077 }); ··· 1086 1083 1087 1084 export const zFooWowData = z.object({ 1088 1085 body: z.never().optional(), 1089 - headers: z.never().optional(), 1090 1086 path: z.never().optional(), 1091 1087 query: z.never().optional() 1092 1088 }); 1093 1089 1094 1090 export const zApiVVersionODataControllerCountData = z.object({ 1095 1091 body: z.never().optional(), 1096 - headers: z.never().optional(), 1097 1092 path: z.never().optional(), 1098 1093 query: z.never().optional() 1099 1094 }); ··· 1105 1100 1106 1101 export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1107 1102 body: z.never().optional(), 1108 - headers: z.never().optional(), 1109 1103 path: z.object({ 1110 1104 foo_param: z.string() 1111 1105 }), ··· 1119 1113 1120 1114 export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1121 1115 body: z.never().optional(), 1122 - headers: z.never().optional(), 1123 1116 path: z.never().optional(), 1124 1117 query: z.never().optional() 1125 1118 }); 1126 1119 1127 1120 export const zGetCallWithoutParametersAndResponseData = z.object({ 1128 1121 body: z.never().optional(), 1129 - headers: z.never().optional(), 1130 1122 path: z.never().optional(), 1131 1123 query: z.never().optional() 1132 1124 }); 1133 1125 1134 1126 export const zHeadCallWithoutParametersAndResponseData = z.object({ 1135 1127 body: z.never().optional(), 1136 - headers: z.never().optional(), 1137 1128 path: z.never().optional(), 1138 1129 query: z.never().optional() 1139 1130 }); 1140 1131 1141 1132 export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1142 1133 body: z.never().optional(), 1143 - headers: z.never().optional(), 1144 1134 path: z.never().optional(), 1145 1135 query: z.never().optional() 1146 1136 }); 1147 1137 1148 1138 export const zPatchCallWithoutParametersAndResponseData = z.object({ 1149 1139 body: z.never().optional(), 1150 - headers: z.never().optional(), 1151 1140 path: z.never().optional(), 1152 1141 query: z.never().optional() 1153 1142 }); 1154 1143 1155 1144 export const zPostCallWithoutParametersAndResponseData = z.object({ 1156 1145 body: z.never().optional(), 1157 - headers: z.never().optional(), 1158 1146 path: z.never().optional(), 1159 1147 query: z.never().optional() 1160 1148 }); 1161 1149 1162 1150 export const zPutCallWithoutParametersAndResponseData = z.object({ 1163 1151 body: z.never().optional(), 1164 - headers: z.never().optional(), 1165 1152 path: z.never().optional(), 1166 1153 query: z.never().optional() 1167 1154 }); 1168 1155 1169 1156 export const zDeleteFooData3 = z.object({ 1170 1157 body: z.never().optional(), 1171 - headers: z.object({ 1172 - 'x-Foo-Bar': zModelWithString 1173 - }), 1174 1158 path: z.object({ 1175 1159 foo_param: z.string(), 1176 1160 BarParam: z.string() 1177 1161 }), 1178 - query: z.never().optional() 1162 + query: z.never().optional(), 1163 + headers: z.object({ 1164 + 'x-Foo-Bar': zModelWithString 1165 + }) 1179 1166 }); 1180 1167 1181 1168 export const zCallWithDescriptionsData = z.object({ 1182 1169 body: z.never().optional(), 1183 - headers: z.never().optional(), 1184 1170 path: z.never().optional(), 1185 1171 query: z.object({ 1186 1172 parameterWithBreaks: z.string().optional(), ··· 1194 1180 1195 1181 export const zDeprecatedCallData = z.object({ 1196 1182 body: z.never().optional(), 1183 + path: z.never().optional(), 1184 + query: z.never().optional(), 1197 1185 headers: z.object({ 1198 1186 parameter: z.union([ 1199 1187 zDeprecatedModel, 1200 1188 z.null() 1201 1189 ]) 1202 - }).optional(), 1203 - path: z.never().optional(), 1204 - query: z.never().optional() 1190 + }) 1205 1191 }); 1206 1192 1207 1193 export const zCallWithParametersData = z.object({ ··· 1209 1195 z.object({}), 1210 1196 z.null() 1211 1197 ]), 1212 - headers: z.object({ 1213 - parameterHeader: z.union([ 1214 - z.string(), 1215 - z.null() 1216 - ]) 1217 - }), 1218 1198 path: z.object({ 1219 1199 parameterPath: z.union([ 1220 1200 z.string(), ··· 1232 1212 z.string(), 1233 1213 z.null() 1234 1214 ]) 1215 + }), 1216 + headers: z.object({ 1217 + parameterHeader: z.union([ 1218 + z.string(), 1219 + z.null() 1220 + ]) 1235 1221 }) 1236 1222 }); 1237 1223 ··· 1240 1226 zModelWithString, 1241 1227 z.null() 1242 1228 ]), 1243 - headers: z.object({ 1244 - 'parameter.header': z.union([ 1245 - z.string(), 1246 - z.null() 1247 - ]) 1248 - }), 1249 1229 path: z.object({ 1250 1230 'parameter.path.1': z.string().optional(), 1251 1231 'parameter-path-2': z.string().optional(), ··· 1258 1238 query: z.object({ 1259 1239 default: z.string().optional(), 1260 1240 'parameter-query': z.union([ 1241 + z.string(), 1242 + z.null() 1243 + ]) 1244 + }), 1245 + headers: z.object({ 1246 + 'parameter.header': z.union([ 1261 1247 z.string(), 1262 1248 z.null() 1263 1249 ]) ··· 1266 1252 1267 1253 export const zGetCallWithOptionalParamData = z.object({ 1268 1254 body: zModelWithOneOfEnum, 1269 - headers: z.never().optional(), 1270 1255 path: z.never().optional(), 1271 1256 query: z.object({ 1272 1257 page: z.number().optional() ··· 1280 1265 z.null() 1281 1266 ]).optional() 1282 1267 }).optional(), 1283 - headers: z.never().optional(), 1284 1268 path: z.never().optional(), 1285 1269 query: z.object({ 1286 1270 parameter: zPageable ··· 1294 1278 1295 1279 export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1296 1280 body: zSimpleRequestBody.optional(), 1297 - headers: z.never().optional(), 1298 1281 path: z.never().optional(), 1299 1282 query: z.object({ 1300 1283 parameter: z.string().optional() ··· 1303 1286 1304 1287 export const zPostApiVbyApiVersionFormDataData = z.object({ 1305 1288 body: zSimpleFormData.optional(), 1306 - headers: z.never().optional(), 1307 1289 path: z.never().optional(), 1308 1290 query: z.object({ 1309 1291 parameter: z.string().optional() ··· 1312 1294 1313 1295 export const zCallWithDefaultParametersData = z.object({ 1314 1296 body: z.never().optional(), 1315 - headers: z.never().optional(), 1316 1297 path: z.never().optional(), 1317 1298 query: z.object({ 1318 1299 parameterString: z.union([ ··· 1341 1322 1342 1323 export const zCallWithDefaultOptionalParametersData = z.object({ 1343 1324 body: z.never().optional(), 1344 - headers: z.never().optional(), 1345 1325 path: z.never().optional(), 1346 1326 query: z.object({ 1347 1327 parameterString: z.string().optional().default('Hello World!'), ··· 1358 1338 1359 1339 export const zCallToTestOrderOfParamsData = z.object({ 1360 1340 body: z.never().optional(), 1361 - headers: z.never().optional(), 1362 1341 path: z.never().optional(), 1363 1342 query: z.object({ 1364 1343 parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), ··· 1380 1359 1381 1360 export const zDuplicateNameData = z.object({ 1382 1361 body: z.never().optional(), 1383 - headers: z.never().optional(), 1384 1362 path: z.never().optional(), 1385 1363 query: z.never().optional() 1386 1364 }); 1387 1365 1388 1366 export const zDuplicateName2Data = z.object({ 1389 1367 body: z.never().optional(), 1390 - headers: z.never().optional(), 1391 1368 path: z.never().optional(), 1392 1369 query: z.never().optional() 1393 1370 }); 1394 1371 1395 1372 export const zDuplicateName3Data = z.object({ 1396 1373 body: z.never().optional(), 1397 - headers: z.never().optional(), 1398 1374 path: z.never().optional(), 1399 1375 query: z.never().optional() 1400 1376 }); 1401 1377 1402 1378 export const zDuplicateName4Data = z.object({ 1403 1379 body: z.never().optional(), 1404 - headers: z.never().optional(), 1405 1380 path: z.never().optional(), 1406 1381 query: z.never().optional() 1407 1382 }); 1408 1383 1409 1384 export const zCallWithNoContentResponseData = z.object({ 1410 1385 body: z.never().optional(), 1411 - headers: z.never().optional(), 1412 1386 path: z.never().optional(), 1413 1387 query: z.never().optional() 1414 1388 }); ··· 1420 1394 1421 1395 export const zCallWithResponseAndNoContentResponseData = z.object({ 1422 1396 body: z.never().optional(), 1423 - headers: z.never().optional(), 1424 1397 path: z.never().optional(), 1425 1398 query: z.never().optional() 1426 1399 }); ··· 1432 1405 1433 1406 export const zDummyAData = z.object({ 1434 1407 body: z.never().optional(), 1435 - headers: z.never().optional(), 1436 1408 path: z.never().optional(), 1437 1409 query: z.never().optional() 1438 1410 }); ··· 1441 1413 1442 1414 export const zDummyBData = z.object({ 1443 1415 body: z.never().optional(), 1444 - headers: z.never().optional(), 1445 1416 path: z.never().optional(), 1446 1417 query: z.never().optional() 1447 1418 }); ··· 1453 1424 1454 1425 export const zCallWithResponseData = z.object({ 1455 1426 body: z.never().optional(), 1456 - headers: z.never().optional(), 1457 1427 path: z.never().optional(), 1458 1428 query: z.never().optional() 1459 1429 }); ··· 1462 1432 1463 1433 export const zCallWithDuplicateResponsesData = z.object({ 1464 1434 body: z.never().optional(), 1465 - headers: z.never().optional(), 1466 1435 path: z.never().optional(), 1467 1436 query: z.never().optional() 1468 1437 }); ··· 1474 1443 1475 1444 export const zCallWithResponsesData = z.object({ 1476 1445 body: z.never().optional(), 1477 - headers: z.never().optional(), 1478 1446 path: z.never().optional(), 1479 1447 query: z.never().optional() 1480 1448 }); ··· 1491 1459 1492 1460 export const zCollectionFormatData = z.object({ 1493 1461 body: z.never().optional(), 1494 - headers: z.never().optional(), 1495 1462 path: z.never().optional(), 1496 1463 query: z.object({ 1497 1464 parameterArrayCSV: z.union([ ··· 1519 1486 1520 1487 export const zTypesData = z.object({ 1521 1488 body: z.never().optional(), 1522 - headers: z.never().optional(), 1523 1489 path: z.object({ 1524 1490 id: z.number().int().optional() 1525 1491 }).optional(), ··· 1562 1528 1563 1529 export const zUploadFileData = z.object({ 1564 1530 body: z.string(), 1565 - headers: z.never().optional(), 1566 1531 path: z.object({ 1567 1532 'api-version': z.union([ 1568 1533 z.string(), ··· 1576 1541 1577 1542 export const zFileResponseData = z.object({ 1578 1543 body: z.never().optional(), 1579 - headers: z.never().optional(), 1580 1544 path: z.object({ 1581 1545 id: z.string(), 1582 1546 'api-version': z.string() ··· 1591 1555 1592 1556 export const zComplexTypesData = z.object({ 1593 1557 body: z.never().optional(), 1594 - headers: z.never().optional(), 1595 1558 path: z.never().optional(), 1596 1559 query: z.object({ 1597 1560 parameterObject: z.object({ ··· 1612 1575 1613 1576 export const zMultipartResponseData = z.object({ 1614 1577 body: z.never().optional(), 1615 - headers: z.never().optional(), 1616 1578 path: z.never().optional(), 1617 1579 query: z.never().optional() 1618 1580 }); ··· 1636 1598 z.null() 1637 1599 ]).optional() 1638 1600 }).optional(), 1639 - headers: z.never().optional(), 1640 1601 path: z.never().optional(), 1641 1602 query: z.never().optional() 1642 1603 }); ··· 1679 1640 ]).readonly().optional() 1680 1641 }).readonly().optional() 1681 1642 }).optional(), 1682 - headers: z.never().optional(), 1683 1643 path: z.object({ 1684 1644 id: z.number().int(), 1685 1645 'api-version': z.string() ··· 1694 1654 1695 1655 export const zCallWithResultFromHeaderData = z.object({ 1696 1656 body: z.never().optional(), 1697 - headers: z.never().optional(), 1698 1657 path: z.never().optional(), 1699 1658 query: z.never().optional() 1700 1659 }); 1701 1660 1702 1661 export const zTestErrorCodeData = z.object({ 1703 1662 body: z.never().optional(), 1704 - headers: z.never().optional(), 1705 1663 path: z.never().optional(), 1706 1664 query: z.object({ 1707 1665 status: z.number().int() ··· 1710 1668 1711 1669 export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1712 1670 body: z.never().optional(), 1713 - headers: z.never().optional(), 1714 1671 path: z.never().optional(), 1715 1672 query: z.object({ 1716 1673 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() ··· 1724 1681 1725 1682 export const zPutWithFormUrlEncodedData = z.object({ 1726 1683 body: zArrayWithStrings, 1727 - headers: z.never().optional(), 1728 1684 path: z.never().optional(), 1729 1685 query: z.never().optional() 1730 1686 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/read-write-only/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/read-write-only/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-api-key/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-api-key/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-http-bearer/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-http-bearer/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-oauth2/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-oauth2/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-open-id-connect/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/security-open-id-connect/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/servers/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/servers/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-all-of/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-all-of/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-array/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.0.x/transformers-array/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/body-response-text-plain/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/body-response-text-plain/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+19 -8
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+1 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs
··· 1 - 'use strict';var C=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e};var w=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},P=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},_={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>w(r,e,s)):w(r,e,o));}),r}},x={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},U={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>P(r,e,s)):P(r,e,o));}),r.toString()}};var D=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},M=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},B=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:t,explode:r,name:e,style:o,value:s})=>{if(!r){let n=(t?s:s.map(c=>encodeURIComponent(c))).join(M(o));switch(o){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let a=D(o),i=s.map(n=>o==="label"||o==="simple"?t?n:encodeURIComponent(n):h({allowReserved:t,name:e,value:n})).join(a);return o==="label"||o==="matrix"?a+i:i},h=({allowReserved:t,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${t?e:encodeURIComponent(e)}`},R=({allowReserved:t,explode:r,name:e,style:o,value:s,valueOnly:a})=>{if(s instanceof Date)return a?s.toISOString():`${e}=${s.toISOString()}`;if(o!=="deepObject"&&!r){let c=[];Object.entries(s).forEach(([f,d])=>{c=[...c,f,t?d:encodeURIComponent(d)];});let p=c.join(",");switch(o){case "form":return `${e}=${p}`;case "label":return `.${p}`;case "matrix":return `;${e}=${p}`;default:return p}}let i=B(o),n=Object.entries(s).map(([c,p])=>h({allowReserved:t,name:o==="deepObject"?`${e}[${c}]`:c,value:p})).join(i);return o==="label"||o==="matrix"?i+n:n};var F=/\{[^{}]+\}/g,H=({path:t,url:r})=>{let e=r,o=r.match(F);if(o)for(let s of o){let a=false,i=s.substring(1,s.length-1),n="simple";i.endsWith("*")&&(a=true,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),n="label"):i.startsWith(";")&&(i=i.substring(1),n="matrix");let c=t[i];if(c==null)continue;if(Array.isArray(c)){e=e.replace(s,O({explode:a,name:i,style:n,value:c}));continue}if(typeof c=="object"){e=e.replace(s,R({explode:a,name:i,style:n,value:c,valueOnly:true}));continue}if(n==="matrix"){e=e.replace(s,`;${h({name:i,value:c})}`);continue}let p=encodeURIComponent(n==="label"?`.${c}`:c);e=e.replace(s,p);}return e},k=({allowReserved:t,array:r,object:e}={})=>s=>{let a=[];if(s&&typeof s=="object")for(let i in s){let n=s[i];if(n!=null)if(Array.isArray(n)){let c=O({allowReserved:t,explode:true,name:i,style:"form",value:n,...r});c&&a.push(c);}else if(typeof n=="object"){let c=R({allowReserved:t,explode:true,name:i,style:"deepObject",value:n,...e});c&&a.push(c);}else {let c=h({allowReserved:t,name:i,value:n});c&&a.push(c);}}return a.join("&")},I=t=>{if(!t)return "stream";let r=t.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},T=async({security:t,...r})=>{for(let e of t){let o=await C(e,r.auth);if(!o)continue;let s=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[s]=o;break;case "cookie":r.headers.append("Cookie",`${s}=${o}`);break;case "header":default:r.headers.set(s,o);break}return}},q=t=>W({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:k(t.querySerializer),url:t.url}),W=({baseUrl:t,path:r,query:e,querySerializer:o,url:s})=>{let a=s.startsWith("/")?s:`/${s}`,i=(t??"")+a;r&&(i=H({path:r,url:i}));let n=e?o(e):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(i+=`?${n}`),i},z=(t,r)=>{let e={...t,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=j(t.headers,r.headers),e},j=(...t)=>{let r=new Headers;for(let e of t){if(!e||typeof e!="object")continue;let o=e instanceof Headers?e.entries():Object.entries(e);for(let[s,a]of o)if(a===null)r.delete(s);else if(Array.isArray(a))for(let i of a)r.append(s,i);else a!==void 0&&r.set(s,typeof a=="object"?JSON.stringify(a):a);}return r},g=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let o=this.getInterceptorIndex(r);return this._fns[o]?(this._fns[o]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},E=()=>({error:new g,request:new g,response:new g}),N=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Q={"Content-Type":"application/json"},A=(t={})=>({...x,headers:Q,parseAs:"auto",querySerializer:N,...t});var V=(t={})=>{let r=z(A(),t),e=()=>({...r}),o=i=>(r=z(r,i),e()),s=E(),a=async i=>{let n={...r,...i,fetch:i.fetch??r.fetch??globalThis.fetch,headers:j(r.headers,i.headers)};n.security&&await T({...n,security:n.security}),n.body&&n.bodySerializer&&(n.body=n.bodySerializer(n.body)),(n.body===void 0||n.body==="")&&n.headers.delete("Content-Type");let c=q(n),p={redirect:"follow",...n},f=new Request(c,p);for(let u of s.request._fns)u&&(f=await u(f,n));let d=n.fetch,l=await d(f);for(let u of s.response._fns)u&&(l=await u(l,f,n));let b={request:f,response:l};if(l.ok){if(l.status===204||l.headers.get("Content-Length")==="0")return {data:{},...b};let u=(n.parseAs==="auto"?I(l.headers.get("Content-Type")):n.parseAs)??"json",m;switch(u){case "arrayBuffer":case "blob":case "formData":case "json":case "text":m=await l[u]();break;case "stream":return {data:l.body,...b}}return u==="json"&&(n.responseValidator&&await n.responseValidator(m),n.responseTransformer&&(m=await n.responseTransformer(m))),{data:m,...b}}let S=await l.text();try{S=JSON.parse(S);}catch{}let y=S;for(let u of s.error._fns)u&&(y=await u(S,l,f,n));if(y=y||{},n.throwOnError)throw y;return {error:y,...b}};return {buildUrl:q,connect:i=>a({...i,method:"CONNECT"}),delete:i=>a({...i,method:"DELETE"}),get:i=>a({...i,method:"GET"}),getConfig:e,head:i=>a({...i,method:"HEAD"}),interceptors:s,options:i=>a({...i,method:"OPTIONS"}),patch:i=>a({...i,method:"PATCH"}),post:i=>a({...i,method:"POST"}),put:i=>a({...i,method:"PUT"}),request:a,setConfig:o,trace:i=>a({...i,method:"TRACE"})}};var J={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},K=Object.entries(J),$=(t,r)=>{r||(r=new Map);for(let e of t)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&$(e.args,r);return r},L=t=>{for(let[r,e]of Object.entries(t))e&&typeof e=="object"&&!Object.keys(e).length&&delete t[r];},G=(t,r)=>{let e={body:{},headers:{},path:{},query:{}},o=$(r),s;for(let[a,i]of t.entries())if(r[a]&&(s=r[a]),!!s)if("in"in s)if(s.key){let n=o.get(s.key),c=n.map||s.key;e[n.in][c]=i;}else e.body=i;else for(let[n,c]of Object.entries(i??{})){let p=o.get(n);if(p){let f=p.map||n;e[p.in][f]=c;}else {let f=K.find(([d])=>n.startsWith(d));if(f){let[d,l]=f;e[l][n.slice(d.length)]=c;}else for(let[d,l]of Object.entries(s.allowExtra??{}))if(l){e[d][n]=c;break}}}return L(e),e};exports.buildClientParams=G;exports.createClient=V;exports.createConfig=A;exports.formDataBodySerializer=_;exports.jsonBodySerializer=x;exports.urlSearchParamsBodySerializer=U;//# sourceMappingURL=index.cjs.map 1 + 'use strict';var C=async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e};var w=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},P=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},_={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>w(r,e,s)):w(r,e,o));}),r}},x={bodySerializer:n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e)},U={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>P(r,e,s)):P(r,e,o));}),r.toString()}};var D=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},M=n=>{switch(n){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},B=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:n,explode:r,name:e,style:o,value:s})=>{if(!r){let t=(n?s:s.map(c=>encodeURIComponent(c))).join(M(o));switch(o){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let a=D(o),i=s.map(t=>o==="label"||o==="simple"?n?t:encodeURIComponent(t):h({allowReserved:n,name:e,value:t})).join(a);return o==="label"||o==="matrix"?a+i:i},h=({allowReserved:n,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${n?e:encodeURIComponent(e)}`},R=({allowReserved:n,explode:r,name:e,style:o,value:s,valueOnly:a})=>{if(s instanceof Date)return a?s.toISOString():`${e}=${s.toISOString()}`;if(o!=="deepObject"&&!r){let c=[];Object.entries(s).forEach(([f,d])=>{c=[...c,f,n?d:encodeURIComponent(d)];});let p=c.join(",");switch(o){case "form":return `${e}=${p}`;case "label":return `.${p}`;case "matrix":return `;${e}=${p}`;default:return p}}let i=B(o),t=Object.entries(s).map(([c,p])=>h({allowReserved:n,name:o==="deepObject"?`${e}[${c}]`:c,value:p})).join(i);return o==="label"||o==="matrix"?i+t:t};var F=/\{[^{}]+\}/g,H=({path:n,url:r})=>{let e=r,o=r.match(F);if(o)for(let s of o){let a=false,i=s.substring(1,s.length-1),t="simple";i.endsWith("*")&&(a=true,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),t="label"):i.startsWith(";")&&(i=i.substring(1),t="matrix");let c=n[i];if(c==null)continue;if(Array.isArray(c)){e=e.replace(s,O({explode:a,name:i,style:t,value:c}));continue}if(typeof c=="object"){e=e.replace(s,R({explode:a,name:i,style:t,value:c,valueOnly:true}));continue}if(t==="matrix"){e=e.replace(s,`;${h({name:i,value:c})}`);continue}let p=encodeURIComponent(t==="label"?`.${c}`:c);e=e.replace(s,p);}return e},k=({allowReserved:n,array:r,object:e}={})=>s=>{let a=[];if(s&&typeof s=="object")for(let i in s){let t=s[i];if(t!=null)if(Array.isArray(t)){let c=O({allowReserved:n,explode:true,name:i,style:"form",value:t,...r});c&&a.push(c);}else if(typeof t=="object"){let c=R({allowReserved:n,explode:true,name:i,style:"deepObject",value:t,...e});c&&a.push(c);}else {let c=h({allowReserved:n,name:i,value:t});c&&a.push(c);}}return a.join("&")},I=n=>{if(!n)return "stream";let r=n.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},T=async({security:n,...r})=>{for(let e of n){let o=await C(e,r.auth);if(!o)continue;let s=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[s]=o;break;case "cookie":r.headers.append("Cookie",`${s}=${o}`);break;case "header":default:r.headers.set(s,o);break}return}},q=n=>W({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:k(n.querySerializer),url:n.url}),W=({baseUrl:n,path:r,query:e,querySerializer:o,url:s})=>{let a=s.startsWith("/")?s:`/${s}`,i=(n??"")+a;r&&(i=H({path:r,url:i}));let t=e?o(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(i+=`?${t}`),i},z=(n,r)=>{let e={...n,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=j(n.headers,r.headers),e},j=(...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let o=e instanceof Headers?e.entries():Object.entries(e);for(let[s,a]of o)if(a===null)r.delete(s);else if(Array.isArray(a))for(let i of a)r.append(s,i);else a!==void 0&&r.set(s,typeof a=="object"?JSON.stringify(a):a);}return r},g=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let o=this.getInterceptorIndex(r);return this._fns[o]?(this._fns[o]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},E=()=>({error:new g,request:new g,response:new g}),N=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Q={"Content-Type":"application/json"},A=(n={})=>({...x,headers:Q,parseAs:"auto",querySerializer:N,...n});var V=(n={})=>{let r=z(A(),n),e=()=>({...r}),o=i=>(r=z(r,i),e()),s=E(),a=async i=>{let t={...r,...i,fetch:i.fetch??r.fetch??globalThis.fetch,headers:j(r.headers,i.headers)};t.security&&await T({...t,security:t.security}),t.requestValidator&&await t.requestValidator(t),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");let c=q(t),p={redirect:"follow",...t},f=new Request(c,p);for(let u of s.request._fns)u&&(f=await u(f,t));let d=t.fetch,l=await d(f);for(let u of s.response._fns)u&&(l=await u(l,f,t));let b={request:f,response:l};if(l.ok){if(l.status===204||l.headers.get("Content-Length")==="0")return {data:{},...b};let u=(t.parseAs==="auto"?I(l.headers.get("Content-Type")):t.parseAs)??"json",m;switch(u){case "arrayBuffer":case "blob":case "formData":case "json":case "text":m=await l[u]();break;case "stream":return {data:l.body,...b}}return u==="json"&&(t.responseValidator&&await t.responseValidator(m),t.responseTransformer&&(m=await t.responseTransformer(m))),{data:m,...b}}let S=await l.text();try{S=JSON.parse(S);}catch{}let y=S;for(let u of s.error._fns)u&&(y=await u(S,l,f,t));if(y=y||{},t.throwOnError)throw y;return {error:y,...b}};return {buildUrl:q,connect:i=>a({...i,method:"CONNECT"}),delete:i=>a({...i,method:"DELETE"}),get:i=>a({...i,method:"GET"}),getConfig:e,head:i=>a({...i,method:"HEAD"}),interceptors:s,options:i=>a({...i,method:"OPTIONS"}),patch:i=>a({...i,method:"PATCH"}),post:i=>a({...i,method:"POST"}),put:i=>a({...i,method:"PUT"}),request:a,setConfig:o,trace:i=>a({...i,method:"TRACE"})}};var J={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},K=Object.entries(J),$=(n,r)=>{r||(r=new Map);for(let e of n)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&$(e.args,r);return r},L=n=>{for(let[r,e]of Object.entries(n))e&&typeof e=="object"&&!Object.keys(e).length&&delete n[r];},G=(n,r)=>{let e={body:{},headers:{},path:{},query:{}},o=$(r),s;for(let[a,i]of n.entries())if(r[a]&&(s=r[a]),!!s)if("in"in s)if(s.key){let t=o.get(s.key),c=t.map||s.key;e[t.in][c]=i;}else e.body=i;else for(let[t,c]of Object.entries(i??{})){let p=o.get(t);if(p){let f=p.map||t;e[p.in][f]=c;}else {let f=K.find(([d])=>t.startsWith(d));if(f){let[d,l]=f;e[l][t.slice(d.length)]=c;}else for(let[d,l]of Object.entries(s.allowExtra??{}))if(l){e[d][t]=c;break}}}return L(e),e};exports.buildClientParams=G;exports.createClient=V;exports.createConfig=A;exports.formDataBodySerializer=_;exports.jsonBodySerializer=x;exports.urlSearchParamsBodySerializer=U;//# sourceMappingURL=index.cjs.map 2 2 //# sourceMappingURL=index.cjs.map
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts
··· 97 97 */ 98 98 querySerializer?: QuerySerializer | QuerySerializerOptions; 99 99 /** 100 + * A function validating request data. This is useful if you want to ensure 101 + * the request conforms to the desired shape, so it can be safely sent to 102 + * the server. 103 + */ 104 + requestValidator?: (data: unknown) => Promise<unknown>; 105 + /** 100 106 * A function transforming response data before it's returned. This is useful 101 107 * for post-processing data, e.g. converting ISO strings into Date objects. 102 108 */
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts
··· 97 97 */ 98 98 querySerializer?: QuerySerializer | QuerySerializerOptions; 99 99 /** 100 + * A function validating request data. This is useful if you want to ensure 101 + * the request conforms to the desired shape, so it can be safely sent to 102 + * the server. 103 + */ 104 + requestValidator?: (data: unknown) => Promise<unknown>; 105 + /** 100 106 * A function transforming response data before it's returned. This is useful 101 107 * for post-processing data, e.g. converting ISO strings into Date objects. 102 108 */
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+7 -5
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/content-types/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/content-types/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/headers/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/headers/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/internal-name-conflict/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/internal-name-conflict/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/pagination-ref/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/pagination-ref/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/parameter-explode-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/parameter-explode-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
-1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
··· 14 14 15 15 export const vPostFooData = v.object({ 16 16 body: v.optional(v.never()), 17 - headers: v.optional(v.never()), 18 17 path: v.optional(v.never()), 19 18 query: v.optional(v.never()) 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts
··· 2 2 3 3 import type { Options as ClientOptions, TDataShape, Client } from './client'; 4 4 import type { PostFooData, PostFooResponses } from './types.gen'; 5 + import { zPostFooData, zPostFooResponse } from './zod.gen'; 5 6 import { postFooResponseTransformer } from './transformers.gen'; 6 - import { zPostFooResponse } from './zod.gen'; 7 7 import { client as _heyApiClient } from './client.gen'; 8 8 9 9 export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { ··· 22 22 23 23 export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => { 24 24 return (options?.client ?? _heyApiClient).post<PostFooResponses, unknown, ThrowOnError>({ 25 + requestValidator: async (data) => { 26 + return await zPostFooData.parseAsync(data); 27 + }, 25 28 responseTransformer: postFooResponseTransformer, 26 29 responseValidator: async (data) => { 27 30 return await zPostFooResponse.parseAsync(data);
-1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
··· 14 14 15 15 export const zPostFooData = z.object({ 16 16 body: z.never().optional(), 17 - headers: z.never().optional(), 18 17 path: z.never().optional(), 19 18 query: z.never().optional() 20 19 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-custom-name/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-custom-name/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-ignore/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-ignore/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+20 -64
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts
··· 1076 1076 1077 1077 export const vExportData = v.object({ 1078 1078 body: v.optional(v.never()), 1079 - headers: v.optional(v.never()), 1080 1079 path: v.optional(v.never()), 1081 1080 query: v.optional(v.never()) 1082 1081 }); 1083 1082 1084 1083 export const vPatchApiVbyApiVersionNoTagData = v.object({ 1085 1084 body: v.optional(v.never()), 1086 - headers: v.optional(v.never()), 1087 1085 path: v.optional(v.never()), 1088 1086 query: v.optional(v.never()) 1089 1087 }); ··· 1093 1091 vModelWithReadOnlyAndWriteOnly, 1094 1092 vModelWithArrayReadOnlyAndWriteOnly 1095 1093 ]), 1096 - headers: v.optional(v.never()), 1097 1094 path: v.optional(v.never()), 1098 1095 query: v.optional(v.never()) 1099 1096 }); ··· 1105 1102 1106 1103 export const vFooWowData = v.object({ 1107 1104 body: v.optional(v.never()), 1108 - headers: v.optional(v.never()), 1109 1105 path: v.optional(v.never()), 1110 1106 query: v.optional(v.never()) 1111 1107 }); 1112 1108 1113 1109 export const vApiVVersionODataControllerCountData = v.object({ 1114 1110 body: v.optional(v.never()), 1115 - headers: v.optional(v.never()), 1116 1111 path: v.optional(v.never()), 1117 1112 query: v.optional(v.never()) 1118 1113 }); ··· 1124 1119 1125 1120 export const vGetApiVbyApiVersionSimpleOperationData = v.object({ 1126 1121 body: v.optional(v.never()), 1127 - headers: v.optional(v.never()), 1128 1122 path: v.object({ 1129 1123 foo_param: v.union([ 1130 1124 v.string(), ··· 1141 1135 1142 1136 export const vDeleteCallWithoutParametersAndResponseData = v.object({ 1143 1137 body: v.optional(v.never()), 1144 - headers: v.optional(v.never()), 1145 1138 path: v.optional(v.never()), 1146 1139 query: v.optional(v.never()) 1147 1140 }); 1148 1141 1149 1142 export const vGetCallWithoutParametersAndResponseData = v.object({ 1150 1143 body: v.optional(v.never()), 1151 - headers: v.optional(v.never()), 1152 1144 path: v.optional(v.never()), 1153 1145 query: v.optional(v.never()) 1154 1146 }); 1155 1147 1156 1148 export const vHeadCallWithoutParametersAndResponseData = v.object({ 1157 1149 body: v.optional(v.never()), 1158 - headers: v.optional(v.never()), 1159 1150 path: v.optional(v.never()), 1160 1151 query: v.optional(v.never()) 1161 1152 }); 1162 1153 1163 1154 export const vOptionsCallWithoutParametersAndResponseData = v.object({ 1164 1155 body: v.optional(v.never()), 1165 - headers: v.optional(v.never()), 1166 1156 path: v.optional(v.never()), 1167 1157 query: v.optional(v.never()) 1168 1158 }); 1169 1159 1170 1160 export const vPatchCallWithoutParametersAndResponseData = v.object({ 1171 1161 body: v.optional(v.never()), 1172 - headers: v.optional(v.never()), 1173 1162 path: v.optional(v.never()), 1174 1163 query: v.optional(v.never()) 1175 1164 }); 1176 1165 1177 1166 export const vPostCallWithoutParametersAndResponseData = v.object({ 1178 1167 body: v.optional(v.never()), 1179 - headers: v.optional(v.never()), 1180 1168 path: v.optional(v.never()), 1181 1169 query: v.optional(v.never()) 1182 1170 }); 1183 1171 1184 1172 export const vPutCallWithoutParametersAndResponseData = v.object({ 1185 1173 body: v.optional(v.never()), 1186 - headers: v.optional(v.never()), 1187 1174 path: v.optional(v.never()), 1188 1175 query: v.optional(v.never()) 1189 1176 }); 1190 1177 1191 1178 export const vDeleteFooData3 = v.object({ 1192 1179 body: v.optional(v.never()), 1193 - headers: v.object({ 1194 - 'x-Foo-Bar': vModelWithString 1195 - }), 1196 1180 path: v.object({ 1197 1181 foo_param: v.string(), 1198 1182 BarParam: v.string() 1199 1183 }), 1200 - query: v.optional(v.never()) 1184 + query: v.optional(v.never()), 1185 + headers: v.object({ 1186 + 'x-Foo-Bar': vModelWithString 1187 + }) 1201 1188 }); 1202 1189 1203 1190 export const vCallWithDescriptionsData = v.object({ 1204 1191 body: v.optional(v.never()), 1205 - headers: v.optional(v.never()), 1206 1192 path: v.optional(v.never()), 1207 1193 query: v.optional(v.object({ 1208 1194 parameterWithBreaks: v.optional(v.string()), ··· 1216 1202 1217 1203 export const vDeprecatedCallData = v.object({ 1218 1204 body: v.optional(v.never()), 1219 - headers: v.optional(v.object({ 1205 + path: v.optional(v.never()), 1206 + query: v.optional(v.never()), 1207 + headers: v.object({ 1220 1208 parameter: v.union([ 1221 1209 vDeprecatedModel, 1222 1210 v.null() 1223 1211 ]) 1224 - })), 1225 - path: v.optional(v.never()), 1226 - query: v.optional(v.never()) 1212 + }) 1227 1213 }); 1228 1214 1229 1215 export const vCallWithParametersData = v.object({ ··· 1231 1217 v.object({}), 1232 1218 v.null() 1233 1219 ]), 1234 - headers: v.object({ 1235 - parameterHeader: v.union([ 1236 - v.string(), 1237 - v.null() 1238 - ]) 1239 - }), 1240 1220 path: v.object({ 1241 1221 parameterPath: v.union([ 1242 1222 v.string(), ··· 1251 1231 foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), 1252 1232 foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, 1253 1233 cursor: v.union([ 1234 + v.string(), 1235 + v.null() 1236 + ]) 1237 + }), 1238 + headers: v.object({ 1239 + parameterHeader: v.union([ 1254 1240 v.string(), 1255 1241 v.null() 1256 1242 ]) ··· 1262 1248 vModelWithString, 1263 1249 v.null() 1264 1250 ]), 1265 - headers: v.object({ 1266 - 'parameter.header': v.union([ 1267 - v.string(), 1268 - v.null() 1269 - ]) 1270 - }), 1271 1251 path: v.object({ 1272 1252 'parameter.path.1': v.optional(v.string()), 1273 1253 'parameter-path-2': v.optional(v.string()), ··· 1283 1263 v.string(), 1284 1264 v.null() 1285 1265 ]) 1266 + }), 1267 + headers: v.object({ 1268 + 'parameter.header': v.union([ 1269 + v.string(), 1270 + v.null() 1271 + ]) 1286 1272 }) 1287 1273 }); 1288 1274 1289 1275 export const vGetCallWithOptionalParamData = v.object({ 1290 1276 body: vModelWithOneOfEnum, 1291 - headers: v.optional(v.never()), 1292 1277 path: v.optional(v.never()), 1293 1278 query: v.optional(v.object({ 1294 1279 page: v.optional(v.number()) ··· 1302 1287 v.null() 1303 1288 ])) 1304 1289 })), 1305 - headers: v.optional(v.never()), 1306 1290 path: v.optional(v.never()), 1307 1291 query: v.object({ 1308 1292 parameter: vPageable ··· 1316 1300 1317 1301 export const vPostApiVbyApiVersionRequestBodyData = v.object({ 1318 1302 body: v.optional(vSimpleRequestBody), 1319 - headers: v.optional(v.never()), 1320 1303 path: v.optional(v.never()), 1321 1304 query: v.optional(v.object({ 1322 1305 parameter: v.optional(v.string()) ··· 1325 1308 1326 1309 export const vPostApiVbyApiVersionFormDataData = v.object({ 1327 1310 body: v.optional(vSimpleFormData), 1328 - headers: v.optional(v.never()), 1329 1311 path: v.optional(v.never()), 1330 1312 query: v.optional(v.object({ 1331 1313 parameter: v.optional(v.string()) ··· 1334 1316 1335 1317 export const vCallWithDefaultParametersData = v.object({ 1336 1318 body: v.optional(v.never()), 1337 - headers: v.optional(v.never()), 1338 1319 path: v.optional(v.never()), 1339 1320 query: v.optional(v.object({ 1340 1321 parameterString: v.optional(v.union([ ··· 1363 1344 1364 1345 export const vCallWithDefaultOptionalParametersData = v.object({ 1365 1346 body: v.optional(v.never()), 1366 - headers: v.optional(v.never()), 1367 1347 path: v.optional(v.never()), 1368 1348 query: v.optional(v.object({ 1369 1349 parameterString: v.optional(v.string(), 'Hello World!'), ··· 1380 1360 1381 1361 export const vCallToTestOrderOfParamsData = v.object({ 1382 1362 body: v.optional(v.never()), 1383 - headers: v.optional(v.never()), 1384 1363 path: v.optional(v.never()), 1385 1364 query: v.object({ 1386 1365 parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), ··· 1402 1381 1403 1382 export const vDuplicateNameData = v.object({ 1404 1383 body: v.optional(v.never()), 1405 - headers: v.optional(v.never()), 1406 1384 path: v.optional(v.never()), 1407 1385 query: v.optional(v.never()) 1408 1386 }); 1409 1387 1410 1388 export const vDuplicateName2Data = v.object({ 1411 1389 body: v.optional(v.never()), 1412 - headers: v.optional(v.never()), 1413 1390 path: v.optional(v.never()), 1414 1391 query: v.optional(v.never()) 1415 1392 }); 1416 1393 1417 1394 export const vDuplicateName3Data = v.object({ 1418 1395 body: v.optional(v.never()), 1419 - headers: v.optional(v.never()), 1420 1396 path: v.optional(v.never()), 1421 1397 query: v.optional(v.never()) 1422 1398 }); 1423 1399 1424 1400 export const vDuplicateName4Data = v.object({ 1425 1401 body: v.optional(v.never()), 1426 - headers: v.optional(v.never()), 1427 1402 path: v.optional(v.never()), 1428 1403 query: v.optional(v.never()) 1429 1404 }); 1430 1405 1431 1406 export const vCallWithNoContentResponseData = v.object({ 1432 1407 body: v.optional(v.never()), 1433 - headers: v.optional(v.never()), 1434 1408 path: v.optional(v.never()), 1435 1409 query: v.optional(v.never()) 1436 1410 }); ··· 1442 1416 1443 1417 export const vCallWithResponseAndNoContentResponseData = v.object({ 1444 1418 body: v.optional(v.never()), 1445 - headers: v.optional(v.never()), 1446 1419 path: v.optional(v.never()), 1447 1420 query: v.optional(v.never()) 1448 1421 }); ··· 1454 1427 1455 1428 export const vDummyAData = v.object({ 1456 1429 body: v.optional(v.never()), 1457 - headers: v.optional(v.never()), 1458 1430 path: v.optional(v.never()), 1459 1431 query: v.optional(v.never()) 1460 1432 }); ··· 1463 1435 1464 1436 export const vDummyBData = v.object({ 1465 1437 body: v.optional(v.never()), 1466 - headers: v.optional(v.never()), 1467 1438 path: v.optional(v.never()), 1468 1439 query: v.optional(v.never()) 1469 1440 }); ··· 1475 1446 1476 1447 export const vCallWithResponseData = v.object({ 1477 1448 body: v.optional(v.never()), 1478 - headers: v.optional(v.never()), 1479 1449 path: v.optional(v.never()), 1480 1450 query: v.optional(v.never()) 1481 1451 }); ··· 1484 1454 1485 1455 export const vCallWithDuplicateResponsesData = v.object({ 1486 1456 body: v.optional(v.never()), 1487 - headers: v.optional(v.never()), 1488 1457 path: v.optional(v.never()), 1489 1458 query: v.optional(v.never()) 1490 1459 }); ··· 1499 1468 1500 1469 export const vCallWithResponsesData = v.object({ 1501 1470 body: v.optional(v.never()), 1502 - headers: v.optional(v.never()), 1503 1471 path: v.optional(v.never()), 1504 1472 query: v.optional(v.never()) 1505 1473 }); ··· 1516 1484 1517 1485 export const vCollectionFormatData = v.object({ 1518 1486 body: v.optional(v.never()), 1519 - headers: v.optional(v.never()), 1520 1487 path: v.optional(v.never()), 1521 1488 query: v.object({ 1522 1489 parameterArrayCSV: v.union([ ··· 1544 1511 1545 1512 export const vTypesData = v.object({ 1546 1513 body: v.optional(v.never()), 1547 - headers: v.optional(v.never()), 1548 1514 path: v.optional(v.object({ 1549 1515 id: v.optional(v.pipe(v.number(), v.integer())) 1550 1516 })), ··· 1588 1554 1589 1555 export const vUploadFileData = v.object({ 1590 1556 body: v.string(), 1591 - headers: v.optional(v.never()), 1592 1557 path: v.object({ 1593 1558 'api-version': v.union([ 1594 1559 v.string(), ··· 1602 1567 1603 1568 export const vFileResponseData = v.object({ 1604 1569 body: v.optional(v.never()), 1605 - headers: v.optional(v.never()), 1606 1570 path: v.object({ 1607 1571 id: v.string(), 1608 1572 'api-version': v.string() ··· 1617 1581 1618 1582 export const vComplexTypesData = v.object({ 1619 1583 body: v.optional(v.never()), 1620 - headers: v.optional(v.never()), 1621 1584 path: v.optional(v.never()), 1622 1585 query: v.object({ 1623 1586 parameterObject: v.object({ ··· 1638 1601 1639 1602 export const vMultipartResponseData = v.object({ 1640 1603 body: v.optional(v.never()), 1641 - headers: v.optional(v.never()), 1642 1604 path: v.optional(v.never()), 1643 1605 query: v.optional(v.never()) 1644 1606 }); ··· 1662 1624 v.null() 1663 1625 ])) 1664 1626 })), 1665 - headers: v.optional(v.never()), 1666 1627 path: v.optional(v.never()), 1667 1628 query: v.optional(v.never()) 1668 1629 }); ··· 1705 1666 ]), v.readonly())) 1706 1667 }), v.readonly())) 1707 1668 })), 1708 - headers: v.optional(v.never()), 1709 1669 path: v.object({ 1710 1670 id: v.pipe(v.number(), v.integer()), 1711 1671 'api-version': v.string() ··· 1720 1680 1721 1681 export const vCallWithResultFromHeaderData = v.object({ 1722 1682 body: v.optional(v.never()), 1723 - headers: v.optional(v.never()), 1724 1683 path: v.optional(v.never()), 1725 1684 query: v.optional(v.never()) 1726 1685 }); 1727 1686 1728 1687 export const vTestErrorCodeData = v.object({ 1729 1688 body: v.optional(v.never()), 1730 - headers: v.optional(v.never()), 1731 1689 path: v.optional(v.never()), 1732 1690 query: v.object({ 1733 1691 status: v.pipe(v.number(), v.integer()) ··· 1736 1694 1737 1695 export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 1738 1696 body: v.optional(v.never()), 1739 - headers: v.optional(v.never()), 1740 1697 path: v.optional(v.never()), 1741 1698 query: v.object({ 1742 1699 'nonAsciiParamæøåÆØÅöôêÊ': v.pipe(v.number(), v.integer()) ··· 1750 1707 1751 1708 export const vPutWithFormUrlEncodedData = v.object({ 1752 1709 body: vArrayWithStrings, 1753 - headers: v.optional(v.never()), 1754 1710 path: v.optional(v.never()), 1755 1711 query: v.optional(v.never()) 1756 1712 });
+19 -63
packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/zod/default/zod.gen.ts
··· 1063 1063 1064 1064 export const zExportData = z.object({ 1065 1065 body: z.never().optional(), 1066 - headers: z.never().optional(), 1067 1066 path: z.never().optional(), 1068 1067 query: z.never().optional() 1069 1068 }); 1070 1069 1071 1070 export const zPatchApiVbyApiVersionNoTagData = z.object({ 1072 1071 body: z.never().optional(), 1073 - headers: z.never().optional(), 1074 1072 path: z.never().optional(), 1075 1073 query: z.never().optional() 1076 1074 }); ··· 1080 1078 zModelWithReadOnlyAndWriteOnly, 1081 1079 zModelWithArrayReadOnlyAndWriteOnly 1082 1080 ]), 1083 - headers: z.never().optional(), 1084 1081 path: z.never().optional(), 1085 1082 query: z.never().optional() 1086 1083 }); ··· 1092 1089 1093 1090 export const zFooWowData = z.object({ 1094 1091 body: z.never().optional(), 1095 - headers: z.never().optional(), 1096 1092 path: z.never().optional(), 1097 1093 query: z.never().optional() 1098 1094 }); 1099 1095 1100 1096 export const zApiVVersionODataControllerCountData = z.object({ 1101 1097 body: z.never().optional(), 1102 - headers: z.never().optional(), 1103 1098 path: z.never().optional(), 1104 1099 query: z.never().optional() 1105 1100 }); ··· 1111 1106 1112 1107 export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1113 1108 body: z.never().optional(), 1114 - headers: z.never().optional(), 1115 1109 path: z.object({ 1116 1110 foo_param: z.union([ 1117 1111 z.string(), ··· 1128 1122 1129 1123 export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1130 1124 body: z.never().optional(), 1131 - headers: z.never().optional(), 1132 1125 path: z.never().optional(), 1133 1126 query: z.never().optional() 1134 1127 }); 1135 1128 1136 1129 export const zGetCallWithoutParametersAndResponseData = z.object({ 1137 1130 body: z.never().optional(), 1138 - headers: z.never().optional(), 1139 1131 path: z.never().optional(), 1140 1132 query: z.never().optional() 1141 1133 }); 1142 1134 1143 1135 export const zHeadCallWithoutParametersAndResponseData = z.object({ 1144 1136 body: z.never().optional(), 1145 - headers: z.never().optional(), 1146 1137 path: z.never().optional(), 1147 1138 query: z.never().optional() 1148 1139 }); 1149 1140 1150 1141 export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1151 1142 body: z.never().optional(), 1152 - headers: z.never().optional(), 1153 1143 path: z.never().optional(), 1154 1144 query: z.never().optional() 1155 1145 }); 1156 1146 1157 1147 export const zPatchCallWithoutParametersAndResponseData = z.object({ 1158 1148 body: z.never().optional(), 1159 - headers: z.never().optional(), 1160 1149 path: z.never().optional(), 1161 1150 query: z.never().optional() 1162 1151 }); 1163 1152 1164 1153 export const zPostCallWithoutParametersAndResponseData = z.object({ 1165 1154 body: z.never().optional(), 1166 - headers: z.never().optional(), 1167 1155 path: z.never().optional(), 1168 1156 query: z.never().optional() 1169 1157 }); 1170 1158 1171 1159 export const zPutCallWithoutParametersAndResponseData = z.object({ 1172 1160 body: z.never().optional(), 1173 - headers: z.never().optional(), 1174 1161 path: z.never().optional(), 1175 1162 query: z.never().optional() 1176 1163 }); 1177 1164 1178 1165 export const zDeleteFooData3 = z.object({ 1179 1166 body: z.never().optional(), 1180 - headers: z.object({ 1181 - 'x-Foo-Bar': zModelWithString 1182 - }), 1183 1167 path: z.object({ 1184 1168 foo_param: z.string(), 1185 1169 BarParam: z.string() 1186 1170 }), 1187 - query: z.never().optional() 1171 + query: z.never().optional(), 1172 + headers: z.object({ 1173 + 'x-Foo-Bar': zModelWithString 1174 + }) 1188 1175 }); 1189 1176 1190 1177 export const zCallWithDescriptionsData = z.object({ 1191 1178 body: z.never().optional(), 1192 - headers: z.never().optional(), 1193 1179 path: z.never().optional(), 1194 1180 query: z.object({ 1195 1181 parameterWithBreaks: z.string().optional(), ··· 1203 1189 1204 1190 export const zDeprecatedCallData = z.object({ 1205 1191 body: z.never().optional(), 1192 + path: z.never().optional(), 1193 + query: z.never().optional(), 1206 1194 headers: z.object({ 1207 1195 parameter: z.union([ 1208 1196 zDeprecatedModel, 1209 1197 z.null() 1210 1198 ]) 1211 - }).optional(), 1212 - path: z.never().optional(), 1213 - query: z.never().optional() 1199 + }) 1214 1200 }); 1215 1201 1216 1202 export const zCallWithParametersData = z.object({ ··· 1218 1204 z.object({}), 1219 1205 z.null() 1220 1206 ]), 1221 - headers: z.object({ 1222 - parameterHeader: z.union([ 1223 - z.string(), 1224 - z.null() 1225 - ]) 1226 - }), 1227 1207 path: z.object({ 1228 1208 parameterPath: z.union([ 1229 1209 z.string(), ··· 1241 1221 z.string(), 1242 1222 z.null() 1243 1223 ]) 1224 + }), 1225 + headers: z.object({ 1226 + parameterHeader: z.union([ 1227 + z.string(), 1228 + z.null() 1229 + ]) 1244 1230 }) 1245 1231 }); 1246 1232 ··· 1249 1235 zModelWithString, 1250 1236 z.null() 1251 1237 ]), 1252 - headers: z.object({ 1253 - 'parameter.header': z.union([ 1254 - z.string(), 1255 - z.null() 1256 - ]) 1257 - }), 1258 1238 path: z.object({ 1259 1239 'parameter.path.1': z.string().optional(), 1260 1240 'parameter-path-2': z.string().optional(), ··· 1267 1247 query: z.object({ 1268 1248 default: z.string().optional(), 1269 1249 'parameter-query': z.union([ 1250 + z.string(), 1251 + z.null() 1252 + ]) 1253 + }), 1254 + headers: z.object({ 1255 + 'parameter.header': z.union([ 1270 1256 z.string(), 1271 1257 z.null() 1272 1258 ]) ··· 1275 1261 1276 1262 export const zGetCallWithOptionalParamData = z.object({ 1277 1263 body: zModelWithOneOfEnum, 1278 - headers: z.never().optional(), 1279 1264 path: z.never().optional(), 1280 1265 query: z.object({ 1281 1266 page: z.number().optional() ··· 1289 1274 z.null() 1290 1275 ]).optional() 1291 1276 }).optional(), 1292 - headers: z.never().optional(), 1293 1277 path: z.never().optional(), 1294 1278 query: z.object({ 1295 1279 parameter: zPageable ··· 1303 1287 1304 1288 export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1305 1289 body: zSimpleRequestBody.optional(), 1306 - headers: z.never().optional(), 1307 1290 path: z.never().optional(), 1308 1291 query: z.object({ 1309 1292 parameter: z.string().optional() ··· 1312 1295 1313 1296 export const zPostApiVbyApiVersionFormDataData = z.object({ 1314 1297 body: zSimpleFormData.optional(), 1315 - headers: z.never().optional(), 1316 1298 path: z.never().optional(), 1317 1299 query: z.object({ 1318 1300 parameter: z.string().optional() ··· 1321 1303 1322 1304 export const zCallWithDefaultParametersData = z.object({ 1323 1305 body: z.never().optional(), 1324 - headers: z.never().optional(), 1325 1306 path: z.never().optional(), 1326 1307 query: z.object({ 1327 1308 parameterString: z.union([ ··· 1350 1331 1351 1332 export const zCallWithDefaultOptionalParametersData = z.object({ 1352 1333 body: z.never().optional(), 1353 - headers: z.never().optional(), 1354 1334 path: z.never().optional(), 1355 1335 query: z.object({ 1356 1336 parameterString: z.string().optional().default('Hello World!'), ··· 1367 1347 1368 1348 export const zCallToTestOrderOfParamsData = z.object({ 1369 1349 body: z.never().optional(), 1370 - headers: z.never().optional(), 1371 1350 path: z.never().optional(), 1372 1351 query: z.object({ 1373 1352 parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), ··· 1389 1368 1390 1369 export const zDuplicateNameData = z.object({ 1391 1370 body: z.never().optional(), 1392 - headers: z.never().optional(), 1393 1371 path: z.never().optional(), 1394 1372 query: z.never().optional() 1395 1373 }); 1396 1374 1397 1375 export const zDuplicateName2Data = z.object({ 1398 1376 body: z.never().optional(), 1399 - headers: z.never().optional(), 1400 1377 path: z.never().optional(), 1401 1378 query: z.never().optional() 1402 1379 }); 1403 1380 1404 1381 export const zDuplicateName3Data = z.object({ 1405 1382 body: z.never().optional(), 1406 - headers: z.never().optional(), 1407 1383 path: z.never().optional(), 1408 1384 query: z.never().optional() 1409 1385 }); 1410 1386 1411 1387 export const zDuplicateName4Data = z.object({ 1412 1388 body: z.never().optional(), 1413 - headers: z.never().optional(), 1414 1389 path: z.never().optional(), 1415 1390 query: z.never().optional() 1416 1391 }); 1417 1392 1418 1393 export const zCallWithNoContentResponseData = z.object({ 1419 1394 body: z.never().optional(), 1420 - headers: z.never().optional(), 1421 1395 path: z.never().optional(), 1422 1396 query: z.never().optional() 1423 1397 }); ··· 1429 1403 1430 1404 export const zCallWithResponseAndNoContentResponseData = z.object({ 1431 1405 body: z.never().optional(), 1432 - headers: z.never().optional(), 1433 1406 path: z.never().optional(), 1434 1407 query: z.never().optional() 1435 1408 }); ··· 1441 1414 1442 1415 export const zDummyAData = z.object({ 1443 1416 body: z.never().optional(), 1444 - headers: z.never().optional(), 1445 1417 path: z.never().optional(), 1446 1418 query: z.never().optional() 1447 1419 }); ··· 1450 1422 1451 1423 export const zDummyBData = z.object({ 1452 1424 body: z.never().optional(), 1453 - headers: z.never().optional(), 1454 1425 path: z.never().optional(), 1455 1426 query: z.never().optional() 1456 1427 }); ··· 1462 1433 1463 1434 export const zCallWithResponseData = z.object({ 1464 1435 body: z.never().optional(), 1465 - headers: z.never().optional(), 1466 1436 path: z.never().optional(), 1467 1437 query: z.never().optional() 1468 1438 }); ··· 1471 1441 1472 1442 export const zCallWithDuplicateResponsesData = z.object({ 1473 1443 body: z.never().optional(), 1474 - headers: z.never().optional(), 1475 1444 path: z.never().optional(), 1476 1445 query: z.never().optional() 1477 1446 }); ··· 1483 1452 1484 1453 export const zCallWithResponsesData = z.object({ 1485 1454 body: z.never().optional(), 1486 - headers: z.never().optional(), 1487 1455 path: z.never().optional(), 1488 1456 query: z.never().optional() 1489 1457 }); ··· 1500 1468 1501 1469 export const zCollectionFormatData = z.object({ 1502 1470 body: z.never().optional(), 1503 - headers: z.never().optional(), 1504 1471 path: z.never().optional(), 1505 1472 query: z.object({ 1506 1473 parameterArrayCSV: z.union([ ··· 1528 1495 1529 1496 export const zTypesData = z.object({ 1530 1497 body: z.never().optional(), 1531 - headers: z.never().optional(), 1532 1498 path: z.object({ 1533 1499 id: z.number().int().optional() 1534 1500 }).optional(), ··· 1572 1538 1573 1539 export const zUploadFileData = z.object({ 1574 1540 body: z.string(), 1575 - headers: z.never().optional(), 1576 1541 path: z.object({ 1577 1542 'api-version': z.union([ 1578 1543 z.string(), ··· 1586 1551 1587 1552 export const zFileResponseData = z.object({ 1588 1553 body: z.never().optional(), 1589 - headers: z.never().optional(), 1590 1554 path: z.object({ 1591 1555 id: z.string(), 1592 1556 'api-version': z.string() ··· 1601 1565 1602 1566 export const zComplexTypesData = z.object({ 1603 1567 body: z.never().optional(), 1604 - headers: z.never().optional(), 1605 1568 path: z.never().optional(), 1606 1569 query: z.object({ 1607 1570 parameterObject: z.object({ ··· 1622 1585 1623 1586 export const zMultipartResponseData = z.object({ 1624 1587 body: z.never().optional(), 1625 - headers: z.never().optional(), 1626 1588 path: z.never().optional(), 1627 1589 query: z.never().optional() 1628 1590 }); ··· 1646 1608 z.null() 1647 1609 ]).optional() 1648 1610 }).optional(), 1649 - headers: z.never().optional(), 1650 1611 path: z.never().optional(), 1651 1612 query: z.never().optional() 1652 1613 }); ··· 1689 1650 ]).readonly().optional() 1690 1651 }).readonly().optional() 1691 1652 }).optional(), 1692 - headers: z.never().optional(), 1693 1653 path: z.object({ 1694 1654 id: z.number().int(), 1695 1655 'api-version': z.string() ··· 1704 1664 1705 1665 export const zCallWithResultFromHeaderData = z.object({ 1706 1666 body: z.never().optional(), 1707 - headers: z.never().optional(), 1708 1667 path: z.never().optional(), 1709 1668 query: z.never().optional() 1710 1669 }); 1711 1670 1712 1671 export const zTestErrorCodeData = z.object({ 1713 1672 body: z.never().optional(), 1714 - headers: z.never().optional(), 1715 1673 path: z.never().optional(), 1716 1674 query: z.object({ 1717 1675 status: z.number().int() ··· 1720 1678 1721 1679 export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1722 1680 body: z.never().optional(), 1723 - headers: z.never().optional(), 1724 1681 path: z.never().optional(), 1725 1682 query: z.object({ 1726 1683 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() ··· 1734 1691 1735 1692 export const zPutWithFormUrlEncodedData = z.object({ 1736 1693 body: zArrayWithStrings, 1737 - headers: z.never().optional(), 1738 1694 path: z.never().optional(), 1739 1695 query: z.never().optional() 1740 1696 });
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/read-write-only/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/read-write-only/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-api-key/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-api-key/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-false/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-false/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-http-bearer/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-http-bearer/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-oauth2/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-oauth2/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-open-id-connect/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/security-open-id-connect/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/servers/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/servers/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-all-of/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-all-of/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+4
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-array/client/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/3.1.x/transformers-array/core/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
-2
packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts
··· 55 55 body: v.object({ 56 56 foo: v.optional(v.string()) 57 57 }), 58 - headers: v.optional(v.never()), 59 58 path: v.optional(v.never()), 60 59 query: v.optional(v.object({ 61 60 foo: v.optional(v.pipe(v.string(), v.metadata({ ··· 72 71 73 72 export const vPostFooData = v.object({ 74 73 body: vFoo3, 75 - headers: v.optional(v.never()), 76 74 path: v.optional(v.never()), 77 75 query: v.optional(v.never()) 78 76 });
-2
packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/zod.gen.ts
··· 45 45 body: z.object({ 46 46 foo: z.string().optional() 47 47 }), 48 - headers: z.never().optional(), 49 48 path: z.never().optional(), 50 49 query: z.object({ 51 50 foo: z.string().describe('This is Foo parameter.').optional(), ··· 60 59 61 60 export const zPostFooData = z.object({ 62 61 body: zFoo3, 63 - headers: z.never().optional(), 64 62 path: z.never().optional(), 65 63 query: z.never().optional() 66 64 });
-2
packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/valibot.gen.ts
··· 45 45 body: v.object({ 46 46 foo: v.optional(v.string()) 47 47 }), 48 - headers: v.optional(v.never()), 49 48 path: v.optional(v.never()), 50 49 query: v.optional(v.object({ 51 50 foo: v.optional(v.string()), ··· 60 59 61 60 export const vPostFooData = v.object({ 62 61 body: vFoo3, 63 - headers: v.optional(v.never()), 64 62 path: v.optional(v.never()), 65 63 query: v.optional(v.never()) 66 64 });
-2
packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/zod.gen.ts
··· 45 45 body: z.object({ 46 46 foo: z.string().optional() 47 47 }), 48 - headers: z.never().optional(), 49 48 path: z.never().optional(), 50 49 query: z.object({ 51 50 foo: z.string().optional(), ··· 60 59 61 60 export const zPostFooData = z.object({ 62 61 body: zFoo3, 63 - headers: z.never().optional(), 64 62 path: z.never().optional(), 65 63 query: z.never().optional() 66 64 });
+4
packages/openapi-ts-tests/test/__snapshots__/test/generated/v3_no_index/client/client.ts.snap
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+6
packages/openapi-ts-tests/test/__snapshots__/test/generated/v3_no_index/core/types.ts.snap
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+7 -5
packages/openapi-ts-tests/test/custom/client/plugin.ts
··· 3 3 clientDefaultConfig, 4 4 clientDefaultMeta, 5 5 clientPluginHandler, 6 + type DefinePlugin, 6 7 definePluginConfig, 7 - type Plugin, 8 8 } from '@hey-api/openapi-ts'; 9 9 10 - export interface Config extends Client.Config { 10 + type Config = Client.Config & { 11 11 /** 12 12 * Plugin name. Must be unique. 13 13 */ 14 14 name: string; 15 - } 15 + }; 16 16 17 - export const defaultConfig: Plugin.Config<Config> = { 17 + export type MyClientPlugin = DefinePlugin<Config>; 18 + 19 + export const defaultConfig: MyClientPlugin['Config'] = { 18 20 ...clientDefaultMeta, 19 21 config: clientDefaultConfig, 20 - handler: clientPluginHandler, 22 + handler: clientPluginHandler as MyClientPlugin['Handler'], 21 23 name: __filename, 22 24 }; 23 25
+5 -2
packages/openapi-ts-tests/test/openapi-ts.config.ts
··· 103 103 { 104 104 // baseUrl: false, 105 105 // exportFromIndex: true, 106 - name: '@hey-api/client-axios', 106 + // name: '@hey-api/client-axios', 107 107 // name: 'legacy/angular', 108 108 // strictBaseUrl: true, 109 109 // throwOnError: true, ··· 127 127 // throwOnError: true, 128 128 // transformer: '@hey-api/transformers', 129 129 transformer: true, 130 - validator: 'valibot', 130 + validator: { 131 + request: 'zod', 132 + response: 'valibot', 133 + }, 131 134 }, 132 135 { 133 136 // bigInt: true,
+7 -5
packages/openapi-ts-tests/test/plugins.test.ts
··· 4 4 5 5 import { 6 6 createClient, 7 - type Plugin, 7 + type DefinePlugin, 8 8 type UserConfig, 9 9 } from '@hey-api/openapi-ts'; 10 10 import { describe, expect, it, vi } from 'vitest'; ··· 518 518 519 519 describe('custom plugin', () => { 520 520 it('handles a custom plugin', async () => { 521 - const myPlugin: Plugin.Config<{ 521 + const myPlugin: DefinePlugin<{ 522 522 customOption: boolean; 523 523 name: any; 524 524 output: string; 525 - }> = { 525 + }>['Config'] = { 526 + api: undefined, 526 527 config: { 527 528 customOption: true, 528 529 }, ··· 547 548 }); 548 549 549 550 it('throws on invalid dependency', async () => { 550 - const myPlugin: Plugin.Config<{ 551 + const myPlugin: DefinePlugin<{ 551 552 name: any; 552 553 output: string; 553 - }> = { 554 + }>['Config'] = { 555 + api: undefined, 554 556 config: {}, 555 557 dependencies: ['@hey-api/oops'], 556 558 handler: vi.fn(),
+14 -7
packages/openapi-ts/src/generate/__tests__/class.test.ts
··· 42 42 ], 43 43 plugins: { 44 44 '@hey-api/schemas': { 45 - config: {}, 45 + config: { 46 + name: '@hey-api/schemas', 47 + }, 46 48 handler: () => {}, 47 - handlerLegacy: () => {}, 48 49 name: '@hey-api/schemas', 50 + output: '', 49 51 }, 50 52 '@hey-api/sdk': { 51 - config: {}, 53 + config: { 54 + name: '@hey-api/sdk', 55 + }, 52 56 handler: () => {}, 53 - handlerLegacy: () => {}, 54 57 name: '@hey-api/sdk', 58 + output: '', 55 59 }, 56 60 '@hey-api/typescript': { 57 61 config: { 58 62 enums: 'javascript', 63 + name: '@hey-api/typescript', 59 64 }, 60 65 handler: () => {}, 61 - handlerLegacy: () => {}, 62 66 name: '@hey-api/typescript', 67 + output: '', 63 68 }, 64 69 'legacy/fetch': { 65 - config: {}, 70 + config: { 71 + name: 'legacy/fetch', 72 + }, 66 73 handler: () => {}, 67 - handlerLegacy: () => {}, 68 74 name: 'legacy/fetch', 75 + output: '', 69 76 tags: ['client'], 70 77 }, 71 78 },
+42 -21
packages/openapi-ts/src/generate/__tests__/core.test.ts
··· 57 57 ], 58 58 plugins: { 59 59 '@hey-api/schemas': { 60 - config: {}, 60 + config: { 61 + name: '@hey-api/schemas', 62 + }, 61 63 handler: () => {}, 62 - handlerLegacy: () => {}, 63 64 name: '@hey-api/schemas', 65 + output: '', 64 66 }, 65 67 '@hey-api/sdk': { 66 - config: {}, 68 + config: { 69 + name: '@hey-api/sdk', 70 + }, 67 71 handler: () => {}, 68 - handlerLegacy: () => {}, 69 72 name: '@hey-api/sdk', 73 + output: '', 70 74 }, 71 75 '@hey-api/typescript': { 72 76 config: { 73 77 enums: 'javascript', 78 + name: '@hey-api/typescript', 74 79 }, 75 80 handler: () => {}, 76 - handlerLegacy: () => {}, 77 81 name: '@hey-api/typescript', 82 + output: '', 78 83 }, 79 84 'legacy/fetch': { 80 - config: {}, 85 + config: { 86 + name: 'legacy/fetch', 87 + }, 81 88 handler: () => {}, 82 - handlerLegacy: () => {}, 83 89 name: 'legacy/fetch', 90 + output: '', 84 91 tags: ['client'], 85 92 }, 86 93 }, ··· 156 163 ], 157 164 plugins: { 158 165 '@hey-api/schemas': { 159 - config: {}, 166 + config: { 167 + name: '@hey-api/schemas', 168 + }, 160 169 handler: () => {}, 161 - handlerLegacy: () => {}, 162 170 name: '@hey-api/schemas', 171 + output: '', 163 172 }, 164 173 '@hey-api/sdk': { 165 - config: {}, 174 + config: { 175 + name: '@hey-api/sdk', 176 + }, 166 177 handler: () => {}, 167 - handlerLegacy: () => {}, 168 178 name: '@hey-api/sdk', 179 + output: '', 169 180 }, 170 181 '@hey-api/typescript': { 171 182 config: { 172 183 enums: 'javascript', 184 + name: '@hey-api/typescript', 173 185 }, 174 186 handler: () => {}, 175 - handlerLegacy: () => {}, 176 187 name: '@hey-api/typescript', 188 + output: '', 177 189 }, 178 190 'legacy/fetch': { 179 - config: {}, 191 + config: { 192 + name: 'legacy/fetch', 193 + }, 180 194 handler: () => {}, 181 - handlerLegacy: () => {}, 182 195 name: 'legacy/fetch', 196 + output: '', 183 197 tags: ['client'], 184 198 }, 185 199 }, ··· 238 252 ], 239 253 plugins: { 240 254 '@hey-api/schemas': { 241 - config: {}, 255 + config: { 256 + name: '@hey-api/schemas', 257 + }, 242 258 handler: () => {}, 243 - handlerLegacy: () => {}, 244 259 name: '@hey-api/schemas', 260 + output: '', 245 261 }, 246 262 '@hey-api/sdk': { 247 - config: {}, 263 + config: { 264 + name: '@hey-api/sdk', 265 + }, 248 266 handler: () => {}, 249 - handlerLegacy: () => {}, 250 267 name: '@hey-api/sdk', 268 + output: '', 251 269 }, 252 270 '@hey-api/typescript': { 253 271 config: { 254 272 enums: 'javascript', 273 + name: '@hey-api/typescript', 255 274 }, 256 275 handler: () => {}, 257 - handlerLegacy: () => {}, 258 276 name: '@hey-api/typescript', 277 + output: '', 259 278 }, 260 279 'legacy/fetch': { 261 - config: {}, 280 + config: { 281 + name: 'legacy/fetch', 282 + }, 262 283 handler: () => {}, 263 - handlerLegacy: () => {}, 264 284 name: 'legacy/fetch', 285 + output: '', 265 286 tags: ['client'], 266 287 }, 267 288 },
+2 -2
packages/openapi-ts/src/generate/client.ts
··· 7 7 import type { ImportExportItemObject } from '../compiler/utils'; 8 8 import type { Client } from '../plugins/@hey-api/client-core/types'; 9 9 import { getClientPlugin } from '../plugins/@hey-api/client-core/utils'; 10 - import type { Plugin } from '../plugins/types'; 10 + import type { DefinePlugin } from '../plugins/types'; 11 11 import type { Config } from '../types/config'; 12 12 import { ensureDirSync, relativeModulePath } from './utils'; 13 13 ··· 95 95 tsConfig, 96 96 }: { 97 97 outputPath: string; 98 - plugin: Plugin.Config<Client.Config & { name: any }>; 98 + plugin: DefinePlugin<Client.Config & { name: string }>['Config']; 99 99 tsConfig: ts.ParsedCommandLine | null; 100 100 }): void => { 101 101 // copy Hey API clients to output
+1 -1
packages/openapi-ts/src/generate/files.ts
··· 7 7 import { type ImportExportItemObject, tsNodeToString } from '../compiler/utils'; 8 8 import type { IR } from '../ir/types'; 9 9 import { ensureValidIdentifier } from '../openApi/shared/utils/identifier'; 10 - import type { StringCase } from '../types/config'; 10 + import type { StringCase } from '../types/case'; 11 11 import { stringCase } from '../utils/stringCase'; 12 12 import { ensureDirSync } from './utils'; 13 13
+14 -7
packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts
··· 41 41 ], 42 42 plugins: { 43 43 '@hey-api/schemas': { 44 - config: {}, 44 + config: { 45 + name: '@hey-api/schemas', 46 + }, 45 47 handler: () => {}, 46 - handlerLegacy: () => {}, 47 48 name: '@hey-api/schemas', 49 + output: '', 48 50 }, 49 51 '@hey-api/sdk': { 50 - config: {}, 52 + config: { 53 + name: '@hey-api/sdk', 54 + }, 51 55 handler: () => {}, 52 - handlerLegacy: () => {}, 53 56 name: '@hey-api/sdk', 57 + output: '', 54 58 }, 55 59 '@hey-api/typescript': { 56 60 config: { 57 61 enums: 'javascript', 62 + name: '@hey-api/typescript', 58 63 }, 59 64 handler: () => {}, 60 - handlerLegacy: () => {}, 61 65 name: '@hey-api/typescript', 66 + output: '', 62 67 }, 63 68 'legacy/fetch': { 64 - config: {}, 69 + config: { 70 + name: 'legacy/fetch', 71 + }, 65 72 handler: () => {}, 66 - handlerLegacy: () => {}, 67 73 name: 'legacy/fetch', 74 + output: '', 68 75 tags: ['client'], 69 76 }, 70 77 },
+14 -7
packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts
··· 55 55 ], 56 56 plugins: { 57 57 '@hey-api/schemas': { 58 - config: {}, 58 + config: { 59 + name: '@hey-api/schemas', 60 + }, 59 61 handler: () => {}, 60 - handlerLegacy: () => {}, 61 62 name: '@hey-api/schemas', 63 + output: '', 62 64 }, 63 65 '@hey-api/sdk': { 64 - config: {}, 66 + config: { 67 + name: '@hey-api/sdk', 68 + }, 65 69 handler: () => {}, 66 - handlerLegacy: () => {}, 67 70 name: '@hey-api/sdk', 71 + output: '', 68 72 }, 69 73 '@hey-api/typescript': { 70 74 config: { 71 75 enums: 'javascript', 76 + name: '@hey-api/typescript', 72 77 }, 73 78 handler: () => {}, 74 - handlerLegacy: () => {}, 75 79 name: '@hey-api/typescript', 80 + output: '', 76 81 }, 77 82 'legacy/fetch': { 78 - config: {}, 83 + config: { 84 + name: 'legacy/fetch', 85 + }, 79 86 handler: () => {}, 80 - handlerLegacy: () => {}, 81 87 name: 'legacy/fetch', 88 + output: '', 82 89 tags: ['client'], 83 90 }, 84 91 },
+2 -1
packages/openapi-ts/src/generate/legacy/output.ts
··· 69 69 ) { 70 70 generateClientBundle({ 71 71 outputPath, 72 + // @ts-expect-error 72 73 plugin: clientPlugin, 73 74 tsConfig, 74 75 }); ··· 96 97 id: `legacy-unused-${plugin.name}`, 97 98 name: `${outputParts[outputParts.length - 1]}.ts`, 98 99 }); 99 - plugin.handlerLegacy({ 100 + plugin.handlerLegacy?.({ 100 101 client, 101 102 files, 102 103 openApi: spec,
+1
packages/openapi-ts/src/generate/output.ts
··· 26 26 if ('bundle' in client.config && client.config.bundle) { 27 27 generateClientBundle({ 28 28 outputPath, 29 + // @ts-expect-error 29 30 plugin: client, 30 31 tsConfig, 31 32 });
+1 -1
packages/openapi-ts/src/index.ts
··· 116 116 export { clientPluginHandler } from './plugins/@hey-api/client-core/plugin'; 117 117 export type { Client } from './plugins/@hey-api/client-core/types'; 118 118 export { definePluginConfig } from './plugins/shared/utils/config'; 119 - export type { Plugin } from './plugins/types'; 119 + export type { DefinePlugin, Plugin } from './plugins/types'; 120 120 export type { UserConfig } from './types/config'; 121 121 export type { LegacyIR } from './types/types'; 122 122 export { utils } from './utils/exports';
+3 -3
packages/openapi-ts/src/initConfigs.ts
··· 3 3 import { loadConfig } from 'c12'; 4 4 5 5 import { getLogs } from './getLogs'; 6 - import type { UserPlugins } from './plugins'; 7 - import { defaultPluginConfigs } from './plugins'; 6 + import { defaultPluginConfigs } from './plugins/config'; 8 7 import type { 9 8 AnyPluginName, 10 9 PluginContext, ··· 19 18 export const defaultPlugins = [ 20 19 '@hey-api/typescript', 21 20 '@hey-api/sdk', 22 - ] as const satisfies ReadonlyArray<UserPlugins['name']>; 21 + ] as const satisfies ReadonlyArray<PluginNames>; 23 22 24 23 const defaultWatch: Config['input']['watch'] = { 25 24 enabled: false, ··· 194 193 return result; 195 194 }, 196 195 }; 196 + // @ts-expect-error 197 197 plugin.resolveConfig(plugin, context); 198 198 } 199 199
+12 -16
packages/openapi-ts/src/ir/context.ts
··· 1 1 import path from 'node:path'; 2 2 3 3 import { TypeScriptFile } from '../generate/files'; 4 + import type { PluginConfigMap } from '../plugins/config'; 4 5 import { PluginInstance } from '../plugins/shared/utils/instance'; 5 - import type { Config, StringCase } from '../types/config'; 6 + import type { PluginNames } from '../plugins/types'; 7 + import type { StringCase } from '../types/case'; 8 + import type { Config } from '../types/config'; 6 9 import type { Files } from '../types/utils'; 7 10 import { resolveRef } from '../utils/ref'; 8 11 import type { IR } from './types'; 9 12 10 - // Helper type to extract the original config type from Plugin.Config and ensure it satisfies BaseConfig 11 - type ExtractConfig<T> = T extends { config: infer C } 12 - ? C & { name: string } 13 - : never; 14 - 15 - // Helper type to map plugin names to their specific PluginInstance types 16 - type PluginInstanceMap = { 17 - [K in keyof Config['plugins']]?: PluginInstance< 18 - ExtractConfig<Config['plugins'][K]> 19 - >; 20 - }; 21 - 22 13 export interface ContextFile { 23 14 /** 24 15 * Should the exports from this file be re-exported in the index barrel file? ··· 60 51 * registered through the `registerPlugin` method and can be accessed by 61 52 * their configured name from the config. 62 53 */ 63 - public plugins: PluginInstanceMap = {}; 54 + public plugins: Partial< 55 + Record<PluginNames, PluginInstance<PluginConfigMap[keyof PluginConfigMap]>> 56 + > = {}; 64 57 /** 65 58 * Resolved specification from `input`. 66 59 */ ··· 120 113 * @param name Plugin name. 121 114 * @returns Registered plugin instance. 122 115 */ 123 - private registerPlugin(name: keyof Config['plugins']): PluginInstance { 116 + private registerPlugin<T extends PluginNames>( 117 + name: T, 118 + ): PluginInstance<PluginConfigMap[T]> { 124 119 const plugin = this.config.plugins[name]!; 125 120 const instance = new PluginInstance({ 126 - config: plugin.config, 121 + api: plugin.api, 122 + config: plugin.config as any, 127 123 context: this as any, 128 124 dependencies: plugin.dependencies ?? [], 129 125 handler: plugin.handler,
+4 -2
packages/openapi-ts/src/openApi/common/parser/__tests__/type.test.ts
··· 7 7 const config: Partial<Config> = { 8 8 plugins: { 9 9 '@hey-api/typescript': { 10 - config: {}, 10 + config: { 11 + name: '@hey-api/typescript', 12 + }, 11 13 handler: () => {}, 12 - handlerLegacy: () => {}, 13 14 name: '@hey-api/typescript', 15 + output: '', 14 16 }, 15 17 }, 16 18 };
+1
packages/openapi-ts/src/openApi/shared/utils/__tests__/operation.test.ts
··· 42 42 // @ts-expect-error 43 43 '@hey-api/sdk': { 44 44 config: { 45 + name: '@hey-api/sdk', 45 46 operationId: true, 46 47 }, 47 48 },
+4 -2
packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.test.ts
··· 9 9 const config: Partial<Config> = { 10 10 plugins: { 11 11 '@hey-api/typescript': { 12 - config: {}, 12 + config: { 13 + name: '@hey-api/typescript', 14 + }, 13 15 handler: () => {}, 14 - handlerLegacy: () => {}, 15 16 name: '@hey-api/typescript', 17 + output: '', 16 18 }, 17 19 }, 18 20 };
+4
packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+3 -4
packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; 4 3 import { clientPluginHandler } from '../client-core/plugin'; 5 - import type { Config } from './types'; 4 + import type { HeyApiClientAxiosPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiClientAxiosPlugin['Config'] = { 8 7 ...clientDefaultMeta, 9 8 config: { 10 9 ...clientDefaultConfig, 11 10 throwOnError: false, 12 11 }, 13 - handler: clientPluginHandler, 12 + handler: clientPluginHandler as HeyApiClientAxiosPlugin['Handler'], 14 13 name: '@hey-api/client-axios', 15 14 }; 16 15
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-axios/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientAxiosPlugin } from './types';
+12 -11
packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'@hey-api/client-axios'>, 6 - Client.Config { 7 - /** 8 - * Throw an error instead of returning it in the response? 9 - * 10 - * @default false 11 - */ 12 - throwOnError?: boolean; 13 - } 4 + export type Config = Plugin.Name<'@hey-api/client-axios'> & 5 + Client.Config & { 6 + /** 7 + * Throw an error instead of returning it in the response? 8 + * 9 + * @default false 10 + */ 11 + throwOnError?: boolean; 12 + }; 13 + 14 + export type HeyApiClientAxiosPlugin = DefinePlugin<Config>;
+6
packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts
··· 85 85 */ 86 86 querySerializer?: QuerySerializer | QuerySerializerOptions; 87 87 /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 88 94 * A function transforming response data before it's returned. This is useful 89 95 * for post-processing data, e.g. converting ISO strings into Date objects. 90 96 */
+6 -4
packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts
··· 5 5 import type { PluginHandler } from './types'; 6 6 import { clientId, getClientBaseUrlKey } from './utils'; 7 7 8 - const resolveBaseUrlString: PluginHandler<string | undefined> = ({ 8 + const resolveBaseUrlString = ({ 9 9 plugin, 10 - }) => { 10 + }: Parameters<PluginHandler>[0]): string | undefined => { 11 11 const { baseUrl } = plugin.config; 12 12 13 13 if (baseUrl === false) { ··· 27 27 return servers[typeof baseUrl === 'number' ? baseUrl : 0]?.url; 28 28 }; 29 29 30 - export const createClient: PluginHandler = ({ plugin }) => { 30 + export const createClient = ({ plugin }: Parameters<PluginHandler>[0]) => { 31 31 const file = plugin.context.file({ id: clientId })!; 32 32 33 33 const clientModule = clientModulePath({ ··· 60 60 61 61 const defaultValues: Array<unknown> = []; 62 62 63 - const resolvedBaseUrl = resolveBaseUrlString({ plugin }); 63 + const resolvedBaseUrl = resolveBaseUrlString({ 64 + plugin: plugin as any, 65 + }); 64 66 if (resolvedBaseUrl) { 65 67 const url = parseUrl(resolvedBaseUrl); 66 68 if (url.protocol && url.host && !resolvedBaseUrl.includes('{')) {
-1
packages/openapi-ts/src/plugins/@hey-api/client-core/config.ts
··· 6 6 7 7 export const clientDefaultMeta = { 8 8 dependencies: ['@hey-api/typescript'], 9 - handlerLegacy: () => {}, 10 9 output: 'client', 11 10 tags: ['client'], 12 11 } as const;
+3 -1
packages/openapi-ts/src/plugins/@hey-api/client-core/createClientConfig.ts
··· 4 4 import { typesId } from '../typescript/ref'; 5 5 import type { PluginHandler } from './types'; 6 6 7 - export const createClientConfigType: PluginHandler = ({ plugin }) => { 7 + export const createClientConfigType = ({ 8 + plugin, 9 + }: Parameters<PluginHandler>[0]) => { 8 10 const file = plugin.context.file({ id: clientId })!; 9 11 10 12 const clientModule = clientModulePath({
+9 -3
packages/openapi-ts/src/plugins/@hey-api/client-core/plugin.ts
··· 3 3 import { createClientConfigType } from './createClientConfig'; 4 4 import type { PluginHandler } from './types'; 5 5 6 - export const clientPluginHandler: PluginHandler = ({ plugin }) => { 6 + export const clientPluginHandler = ({ 7 + plugin, 8 + }: Parameters<PluginHandler>[0]) => { 7 9 plugin.createFile({ 8 10 id: clientId, 9 11 path: plugin.output, 10 12 }); 11 13 12 - createClientConfigType({ plugin }); 13 - createClient({ plugin }); 14 + createClientConfigType({ 15 + plugin: plugin as any, 16 + }); 17 + createClient({ 18 + plugin: plugin as any, 19 + }); 14 20 };
+9 -13
packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 2 - import type { Config as ClientAxiosConfig } from '../client-axios'; 3 - import type { Config as ClientFetchConfig } from '../client-fetch'; 4 - import type { Config as ClientNextConfig } from '../client-next'; 5 - import type { Config as ClientNuxtConfig } from '../client-nuxt'; 6 - 7 - export type PluginHandler<ReturnType = void> = Plugin.Handler< 8 - ClientAxiosConfig | ClientFetchConfig | ClientNextConfig | ClientNuxtConfig, 9 - ReturnType 10 - >; 1 + import type { HeyApiClientAxiosPlugin } from '../client-axios'; 2 + import type { HeyApiClientFetchPlugin } from '../client-fetch'; 3 + import type { HeyApiClientNextPlugin } from '../client-next'; 4 + import type { HeyApiClientNuxtPlugin } from '../client-nuxt'; 11 5 12 - export type PluginInstance = Plugin.Instance< 13 - ClientAxiosConfig | ClientFetchConfig | ClientNextConfig | ClientNuxtConfig 14 - >; 6 + export type PluginHandler = 7 + | HeyApiClientAxiosPlugin['Handler'] 8 + | HeyApiClientFetchPlugin['Handler'] 9 + | HeyApiClientNextPlugin['Handler'] 10 + | HeyApiClientNuxtPlugin['Handler']; 15 11 16 12 /** 17 13 * Public Client API.
+8 -5
packages/openapi-ts/src/plugins/@hey-api/client-core/utils.ts
··· 3 3 4 4 export const clientId = 'client'; 5 5 6 - type Plugins = Required<Config>['plugins']; 7 - 8 6 export const getClientBaseUrlKey = (config: Config) => { 9 7 const client = getClientPlugin(config); 10 8 if ( ··· 18 16 19 17 export const getClientPlugin = ( 20 18 config: Config, 21 - ): Required<Plugins>[PluginClientNames] => { 19 + ): Config['plugins'][PluginClientNames] & { name: PluginClientNames } => { 22 20 for (const name of config.pluginOrder) { 23 21 const plugin = config.plugins[name]; 24 22 if (plugin?.tags?.includes('client')) { 25 - return plugin as Required<Plugins>[PluginClientNames]; 23 + return plugin as Config['plugins'][PluginClientNames] & { 24 + name: PluginClientNames; 25 + }; 26 26 } 27 27 } 28 28 29 29 return { 30 - config: {}, 30 + config: { 31 + // @ts-expect-error 32 + name: '', 33 + }, 31 34 // @ts-expect-error 32 35 name: '', 33 36 };
+4
packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts
··· 46 46 }); 47 47 } 48 48 49 + if (opts.requestValidator) { 50 + await opts.requestValidator(opts); 51 + } 52 + 49 53 if (opts.body && opts.bodySerializer) { 50 54 opts.body = opts.bodySerializer(opts.body); 51 55 }
+3 -4
packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; 4 3 import { clientPluginHandler } from '../client-core/plugin'; 5 - import type { Config } from './types'; 4 + import type { HeyApiClientFetchPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiClientFetchPlugin['Config'] = { 8 7 ...clientDefaultMeta, 9 8 config: { 10 9 ...clientDefaultConfig, 11 10 throwOnError: false, 12 11 }, 13 - handler: clientPluginHandler, 12 + handler: clientPluginHandler as HeyApiClientFetchPlugin['Handler'], 14 13 name: '@hey-api/client-fetch', 15 14 }; 16 15
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-fetch/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientFetchPlugin } from './types';
+12 -11
packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'@hey-api/client-fetch'>, 6 - Client.Config { 7 - /** 8 - * Throw an error instead of returning it in the response? 9 - * 10 - * @default false 11 - */ 12 - throwOnError?: boolean; 13 - } 4 + export type Config = Plugin.Name<'@hey-api/client-fetch'> & 5 + Client.Config & { 6 + /** 7 + * Throw an error instead of returning it in the response? 8 + * 9 + * @default false 10 + */ 11 + throwOnError?: boolean; 12 + }; 13 + 14 + export type HeyApiClientFetchPlugin = DefinePlugin<Config>;
+4
packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts
··· 42 42 }); 43 43 } 44 44 45 + if (opts.requestValidator) { 46 + await opts.requestValidator(opts); 47 + } 48 + 45 49 if (opts.body && opts.bodySerializer) { 46 50 opts.body = opts.bodySerializer(opts.body); 47 51 }
+3 -4
packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; 4 3 import { clientPluginHandler } from '../client-core/plugin'; 5 - import type { Config } from './types'; 4 + import type { HeyApiClientNextPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiClientNextPlugin['Config'] = { 8 7 ...clientDefaultMeta, 9 8 config: { 10 9 ...clientDefaultConfig, 11 10 throwOnError: false, 12 11 }, 13 - handler: clientPluginHandler, 12 + handler: clientPluginHandler as HeyApiClientNextPlugin['Handler'], 14 13 name: '@hey-api/client-next', 15 14 }; 16 15
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-next/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientNextPlugin } from './types';
+12 -11
packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'@hey-api/client-next'>, 6 - Client.Config { 7 - /** 8 - * Throw an error instead of returning it in the response? 9 - * 10 - * @default false 11 - */ 12 - throwOnError?: boolean; 13 - } 4 + export type Config = Plugin.Name<'@hey-api/client-next'> & 5 + Client.Config & { 6 + /** 7 + * Throw an error instead of returning it in the response? 8 + * 9 + * @default false 10 + */ 11 + throwOnError?: boolean; 12 + }; 13 + 14 + export type HeyApiClientNextPlugin = DefinePlugin<Config>;
+19 -8
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts
··· 43 43 onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 44 }; 45 45 46 - const { responseTransformer, responseValidator, security } = opts; 47 - if (security) { 46 + const { 47 + requestValidator, 48 + responseTransformer, 49 + responseValidator, 50 + security, 51 + } = opts; 52 + if (requestValidator || security) { 48 53 // auth must happen in interceptors otherwise we'd need to require 49 54 // asyncContext enabled 50 55 // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 51 56 opts.onRequest = [ 52 57 async ({ options }) => { 53 - await setAuthParams({ 54 - auth: opts.auth, 55 - headers: options.headers, 56 - query: options.query, 57 - security, 58 - }); 58 + if (security) { 59 + await setAuthParams({ 60 + auth: opts.auth, 61 + headers: options.headers, 62 + query: options.query, 63 + security, 64 + }); 65 + } 66 + 67 + if (requestValidator) { 68 + await requestValidator(options); 69 + } 59 70 }, 60 71 ...opts.onRequest, 61 72 ];
+3 -4
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; 4 3 import { clientPluginHandler } from '../client-core/plugin'; 5 - import type { Config } from './types'; 4 + import type { HeyApiClientNuxtPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiClientNuxtPlugin['Config'] = { 8 7 ...clientDefaultMeta, 9 8 config: clientDefaultConfig, 10 - handler: clientPluginHandler, 9 + handler: clientPluginHandler as HeyApiClientNuxtPlugin['Handler'], 11 10 name: '@hey-api/client-nuxt', 12 11 }; 13 12
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientNuxtPlugin } from './types';
+4 -4
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'@hey-api/client-nuxt'>, 6 - Client.Config {} 4 + export type Config = Plugin.Name<'@hey-api/client-nuxt'> & Client.Config; 5 + 6 + export type HeyApiClientNuxtPlugin = DefinePlugin<Config>;
+2 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-angular/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 - import type { Config } from './types'; 2 + import type { HeyApiClientLegacyAngularPlugin } from './types'; 4 3 5 - export const defaultConfig: Plugin.Config<Config> = { 4 + export const defaultConfig: HeyApiClientLegacyAngularPlugin['Config'] = { 6 5 config: {}, 7 6 handler: () => {}, 8 - handlerLegacy: () => {}, 9 7 name: 'legacy/angular', 10 8 output: 'client', 11 9 tags: ['client'],
+1 -1
packages/openapi-ts/src/plugins/@hey-api/legacy-angular/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientLegacyAngularPlugin } from './types';
+5 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-angular/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'legacy/angular'>, 6 - Pick<Client.Config, 'output'> {} 4 + export type Config = Plugin.Name<'legacy/angular'> & 5 + Pick<Client.Config, 'output'>; 6 + 7 + export type HeyApiClientLegacyAngularPlugin = DefinePlugin<Config>;
+2 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-axios/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 - import type { Config } from './types'; 2 + import type { HeyApiClientLegacyAxiosPlugin } from './types'; 4 3 5 - export const defaultConfig: Plugin.Config<Config> = { 4 + export const defaultConfig: HeyApiClientLegacyAxiosPlugin['Config'] = { 6 5 config: {}, 7 6 handler: () => {}, 8 - handlerLegacy: () => {}, 9 7 name: 'legacy/axios', 10 8 output: 'client', 11 9 tags: ['client'],
+1 -1
packages/openapi-ts/src/plugins/@hey-api/legacy-axios/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientLegacyAxiosPlugin } from './types';
+5 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-axios/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'legacy/axios'>, 6 - Pick<Client.Config, 'output'> {} 4 + export type Config = Plugin.Name<'legacy/axios'> & 5 + Pick<Client.Config, 'output'>; 6 + 7 + export type HeyApiClientLegacyAxiosPlugin = DefinePlugin<Config>;
+2 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-fetch/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 - import type { Config } from './types'; 2 + import type { HeyApiClientLegacyFetchPlugin } from './types'; 4 3 5 - export const defaultConfig: Plugin.Config<Config> = { 4 + export const defaultConfig: HeyApiClientLegacyFetchPlugin['Config'] = { 6 5 config: {}, 7 6 handler: () => {}, 8 - handlerLegacy: () => {}, 9 7 name: 'legacy/fetch', 10 8 output: 'client', 11 9 tags: ['client'],
+1 -1
packages/openapi-ts/src/plugins/@hey-api/legacy-fetch/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientLegacyFetchPlugin } from './types';
+5 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-fetch/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'legacy/fetch'>, 6 - Pick<Client.Config, 'output'> {} 4 + export type Config = Plugin.Name<'legacy/fetch'> & 5 + Pick<Client.Config, 'output'>; 6 + 7 + export type HeyApiClientLegacyFetchPlugin = DefinePlugin<Config>;
+2 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-node/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 - import type { Config } from './types'; 2 + import type { HeyApiClientLegacyNodePlugin } from './types'; 4 3 5 - export const defaultConfig: Plugin.Config<Config> = { 4 + export const defaultConfig: HeyApiClientLegacyNodePlugin['Config'] = { 6 5 config: {}, 7 6 handler: () => {}, 8 - handlerLegacy: () => {}, 9 7 name: 'legacy/node', 10 8 output: 'client', 11 9 tags: ['client'],
+1 -1
packages/openapi-ts/src/plugins/@hey-api/legacy-node/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientLegacyNodePlugin } from './types';
+4 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-node/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'legacy/node'>, 6 - Pick<Client.Config, 'output'> {} 4 + export type Config = Plugin.Name<'legacy/node'> & Pick<Client.Config, 'output'>; 5 + 6 + export type HeyApiClientLegacyNodePlugin = DefinePlugin<Config>;
+2 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-xhr/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 - import type { Config } from './types'; 2 + import type { HeyApiClientLegacyXhrPlugin } from './types'; 4 3 5 - export const defaultConfig: Plugin.Config<Config> = { 4 + export const defaultConfig: HeyApiClientLegacyXhrPlugin['Config'] = { 6 5 config: {}, 7 6 handler: () => {}, 8 - handlerLegacy: () => {}, 9 7 name: 'legacy/xhr', 10 8 output: 'client', 11 9 tags: ['client'],
+1 -1
packages/openapi-ts/src/plugins/@hey-api/legacy-xhr/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiClientLegacyXhrPlugin } from './types';
+4 -4
packages/openapi-ts/src/plugins/@hey-api/legacy-xhr/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 import type { Client } from '../client-core/types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'legacy/xhr'>, 6 - Pick<Client.Config, 'output'> {} 4 + export type Config = Plugin.Name<'legacy/xhr'> & Pick<Client.Config, 'output'>; 5 + 6 + export type HeyApiClientLegacyXhrPlugin = DefinePlugin<Config>;
+26 -13
packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts
··· 44 44 ], 45 45 plugins: { 46 46 '@hey-api/schemas': { 47 - config: {}, 47 + config: { 48 + name: '@hey-api/schemas', 49 + }, 48 50 handler: () => {}, 49 - handlerLegacy: () => {}, 50 51 name: '@hey-api/schemas', 52 + output: '', 51 53 }, 52 54 '@hey-api/sdk': { 53 - config: {}, 55 + config: { 56 + name: '@hey-api/sdk', 57 + }, 54 58 handler: () => {}, 55 - handlerLegacy: () => {}, 56 59 name: '@hey-api/sdk', 60 + output: '', 57 61 }, 58 62 '@hey-api/typescript': { 59 63 config: { 60 64 enums: 'javascript', 65 + name: '@hey-api/typescript', 61 66 }, 62 67 handler: () => {}, 63 - handlerLegacy: () => {}, 64 68 name: '@hey-api/typescript', 69 + output: '', 65 70 }, 66 71 'legacy/fetch': { 67 - config: {}, 72 + config: { 73 + name: 'legacy/fetch', 74 + }, 68 75 handler: () => {}, 69 - handlerLegacy: () => {}, 70 76 name: 'legacy/fetch', 77 + output: '', 71 78 tags: ['client'], 72 79 }, 73 80 }, ··· 145 152 plugins: { 146 153 '@hey-api/schemas': { 147 154 config: { 155 + name: '@hey-api/schemas', 148 156 nameBuilder: nameFn, 149 157 }, 150 158 handler: () => {}, 151 - handlerLegacy: () => {}, 152 159 name: '@hey-api/schemas', 160 + output: '', 153 161 }, 154 162 '@hey-api/sdk': { 155 - config: {}, 163 + config: { 164 + name: '@hey-api/sdk', 165 + }, 156 166 handler: () => {}, 157 - handlerLegacy: () => {}, 158 167 name: '@hey-api/sdk', 168 + output: '', 159 169 }, 160 170 '@hey-api/typescript': { 161 171 config: { 162 172 enums: 'javascript', 173 + name: '@hey-api/typescript', 163 174 }, 164 175 handler: () => {}, 165 - handlerLegacy: () => {}, 166 176 name: '@hey-api/typescript', 177 + output: '', 167 178 }, 168 179 'legacy/fetch': { 169 - config: {}, 180 + config: { 181 + name: 'legacy/fetch', 182 + }, 170 183 handler: () => {}, 171 - handlerLegacy: () => {}, 172 184 name: 'legacy/fetch', 185 + output: '', 173 186 tags: ['client'], 174 187 }, 175 188 },
+2 -3
packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from './plugin'; 4 3 import { handlerLegacy } from './plugin-legacy'; 5 - import type { Config } from './types'; 4 + import type { HeyApiSchemasPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiSchemasPlugin['Config'] = { 8 7 config: { 9 8 exportFromIndex: false, 10 9 nameBuilder: (name) => `${name}Schema`,
+1 -1
packages/openapi-ts/src/plugins/@hey-api/schemas/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiSchemasPlugin } from './types';
+2 -3
packages/openapi-ts/src/plugins/@hey-api/schemas/plugin-legacy.ts
··· 3 3 import type { OpenApiV2Schema, OpenApiV3Schema } from '../../../openApi'; 4 4 import { ensureValidTypeScriptJavaScriptIdentifier } from '../../../openApi'; 5 5 import { getConfig } from '../../../utils/config'; 6 - import type { Plugin } from '../../types'; 7 - import type { Config } from './types'; 6 + import type { HeyApiSchemasPlugin } from './types'; 8 7 9 8 const ensureValidSchemaOutput = ( 10 9 schema: unknown, ··· 75 74 return `${validName}Schema`; 76 75 }; 77 76 78 - export const handlerLegacy: Plugin.LegacyHandler<Config> = ({ 77 + export const handlerLegacy: HeyApiSchemasPlugin['LegacyHandler'] = ({ 79 78 files, 80 79 openApi, 81 80 plugin,
+10 -11
packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts
··· 5 5 import type { OpenApiV3_1_XTypes } from '../../../openApi/3.1.x'; 6 6 import { ensureValidIdentifier } from '../../../openApi/shared/utils/identifier'; 7 7 import type { OpenApi } from '../../../openApi/types'; 8 - import type { Plugin } from '../../types'; 9 - import type { Config } from './types'; 8 + import type { HeyApiSchemasPlugin } from './types'; 10 9 11 10 const schemasId = 'schemas'; 12 11 ··· 14 13 plugin, 15 14 schema, 16 15 }: { 17 - plugin: Plugin.Instance<Config>; 16 + plugin: HeyApiSchemasPlugin['Instance']; 18 17 schema: 19 18 | OpenApiV2_0_XTypes['SchemaObject'] 20 19 | OpenApiV3_0_XTypes['SchemaObject'] ··· 49 48 schema: _schema, 50 49 }: { 51 50 context: IR.Context; 52 - plugin: Plugin.Instance<Config>; 51 + plugin: HeyApiSchemasPlugin['Instance']; 53 52 schema: OpenApiV2_0_XTypes['SchemaObject']; 54 53 }): OpenApiV2_0_XTypes['SchemaObject'] => { 55 54 if (Array.isArray(_schema)) { ··· 125 124 schema: _schema, 126 125 }: { 127 126 context: IR.Context; 128 - plugin: Plugin.Instance<Config>; 127 + plugin: HeyApiSchemasPlugin['Instance']; 129 128 schema: 130 129 | OpenApiV3_0_XTypes['SchemaObject'] 131 130 | OpenApiV3_0_XTypes['ReferenceObject']; ··· 227 226 schema: _schema, 228 227 }: { 229 228 context: IR.Context; 230 - plugin: Plugin.Instance<Config>; 229 + plugin: HeyApiSchemasPlugin['Instance']; 231 230 schema: OpenApiV3_1_XTypes['SchemaObject']; 232 231 }): OpenApiV3_1_XTypes['SchemaObject'] => { 233 232 if (Array.isArray(_schema)) { ··· 332 331 schema, 333 332 }: { 334 333 name: string; 335 - plugin: Plugin.Instance<Config>; 334 + plugin: HeyApiSchemasPlugin['Instance']; 336 335 schema: 337 336 | OpenApiV2_0_XTypes['SchemaObject'] 338 337 | OpenApiV3_0_XTypes['ReferenceObject'] ··· 361 360 plugin, 362 361 }: { 363 362 context: IR.Context<OpenApi.V2_0_X>; 364 - plugin: Plugin.Instance<Config>; 363 + plugin: HeyApiSchemasPlugin['Instance']; 365 364 }) => { 366 365 if (!context.spec.definitions) { 367 366 return; ··· 389 388 plugin, 390 389 }: { 391 390 context: IR.Context<OpenApi.V3_0_X>; 392 - plugin: Plugin.Instance<Config>; 391 + plugin: HeyApiSchemasPlugin['Instance']; 393 392 }) => { 394 393 if (!context.spec.components) { 395 394 return; ··· 417 416 plugin, 418 417 }: { 419 418 context: IR.Context<OpenApi.V3_1_X>; 420 - plugin: Plugin.Instance<Config>; 419 + plugin: HeyApiSchemasPlugin['Instance']; 421 420 }) => { 422 421 if (!context.spec.components) { 423 422 return; ··· 440 439 } 441 440 }; 442 441 443 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 442 + export const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => { 444 443 plugin.createFile({ 445 444 id: schemasId, 446 445 path: plugin.output,
+5 -3
packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts
··· 2 2 import type { OpenApiV2_0_XTypes } from '../../../openApi/2.0.x'; 3 3 import type { OpenApiV3_0_XTypes } from '../../../openApi/3.0.x'; 4 4 import type { OpenApiV3_1_XTypes } from '../../../openApi/3.1.x'; 5 - import type { Plugin } from '../../types'; 5 + import type { DefinePlugin, Plugin } from '../../types'; 6 6 7 - export interface Config extends Plugin.Name<'@hey-api/schemas'> { 7 + export type Config = Plugin.Name<'@hey-api/schemas'> & { 8 8 /** 9 9 * Should the exports from the generated files be re-exported in the index 10 10 * barrel file? ··· 45 45 * @default 'json' 46 46 */ 47 47 type?: 'form' | 'json'; 48 - } 48 + }; 49 + 50 + export type HeyApiSchemasPlugin = DefinePlugin<Config>;
+56 -28
packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts
··· 46 46 ], 47 47 plugins: { 48 48 '@hey-api/schemas': { 49 - config: {}, 49 + config: { 50 + name: '@hey-api/schemas', 51 + }, 50 52 handler: () => {}, 51 - handlerLegacy: () => {}, 52 53 name: '@hey-api/schemas', 54 + output: '', 53 55 }, 54 56 '@hey-api/sdk': { 55 57 config: { 56 58 asClass: true, 59 + name: '@hey-api/sdk', 57 60 }, 58 61 handler: () => {}, 59 - handlerLegacy: () => {}, 60 62 name: '@hey-api/sdk', 63 + output: '', 61 64 }, 62 65 '@hey-api/typescript': { 63 - config: {}, 66 + config: { 67 + name: '@hey-api/typescript', 68 + }, 64 69 handler: () => {}, 65 - handlerLegacy: () => {}, 66 70 name: '@hey-api/typescript', 71 + output: '', 67 72 }, 68 73 'legacy/fetch': { 69 - config: {}, 74 + config: { 75 + name: 'legacy/fetch', 76 + }, 70 77 handler: () => {}, 71 - handlerLegacy: () => {}, 72 78 name: 'legacy/fetch', 79 + output: '', 73 80 tags: ['client'], 74 81 }, 75 82 }, ··· 219 226 ], 220 227 plugins: { 221 228 '@hey-api/schemas': { 222 - config: {}, 229 + config: { 230 + name: '@hey-api/schemas', 231 + }, 223 232 handler: () => {}, 224 - handlerLegacy: () => {}, 225 233 name: '@hey-api/schemas', 234 + output: '', 226 235 }, 227 236 '@hey-api/sdk': { 228 237 config: { 229 238 asClass: true, 239 + name: '@hey-api/sdk', 230 240 }, 231 241 handler: () => {}, 232 - handlerLegacy: () => {}, 233 242 name: '@hey-api/sdk', 243 + output: '', 234 244 }, 235 245 '@hey-api/typescript': { 236 - config: {}, 246 + config: { 247 + name: '@hey-api/typescript', 248 + }, 237 249 handler: () => {}, 238 - handlerLegacy: () => {}, 239 250 name: '@hey-api/typescript', 251 + output: '', 240 252 }, 241 253 'legacy/fetch': { 242 - config: {}, 254 + config: { 255 + name: 'legacy/fetch', 256 + }, 243 257 handler: () => {}, 244 - handlerLegacy: () => {}, 245 258 name: 'legacy/fetch', 259 + output: '', 246 260 tags: ['client'], 247 261 }, 248 262 }, ··· 314 328 ], 315 329 plugins: { 316 330 '@hey-api/schemas': { 317 - config: {}, 331 + config: { 332 + name: '@hey-api/schemas', 333 + }, 318 334 handler: () => {}, 319 - handlerLegacy: () => {}, 320 335 name: '@hey-api/schemas', 336 + output: '', 321 337 }, 322 338 '@hey-api/sdk': { 323 339 config: { 324 340 asClass: true, 325 341 methodNameBuilder, 342 + name: '@hey-api/sdk', 326 343 }, 327 344 handler: () => {}, 328 - handlerLegacy: () => {}, 329 345 name: '@hey-api/sdk', 346 + output: '', 330 347 }, 331 348 '@hey-api/typescript': { 332 - config: {}, 349 + config: { 350 + name: '@hey-api/typescript', 351 + }, 333 352 handler: () => {}, 334 - handlerLegacy: () => {}, 335 353 name: '@hey-api/typescript', 354 + output: '', 336 355 }, 337 356 'legacy/fetch': { 338 - config: {}, 357 + config: { 358 + name: 'legacy/fetch', 359 + }, 339 360 handler: () => {}, 340 - handlerLegacy: () => {}, 341 361 name: 'legacy/fetch', 362 + output: '', 342 363 tags: ['client'], 343 364 }, 344 365 }, ··· 412 433 ], 413 434 plugins: { 414 435 '@hey-api/schemas': { 415 - config: {}, 436 + config: { 437 + name: '@hey-api/schemas', 438 + }, 416 439 handler: () => {}, 417 - handlerLegacy: () => {}, 418 440 name: '@hey-api/schemas', 441 + output: '', 419 442 }, 420 443 '@hey-api/sdk': { 421 444 config: { 422 445 asClass: false, 423 446 methodNameBuilder, 447 + name: '@hey-api/sdk', 424 448 }, 425 449 handler: () => {}, 426 - handlerLegacy: () => {}, 427 450 name: '@hey-api/sdk', 451 + output: '', 428 452 }, 429 453 '@hey-api/typescript': { 430 - config: {}, 454 + config: { 455 + name: '@hey-api/typescript', 456 + }, 431 457 handler: () => {}, 432 - handlerLegacy: () => {}, 433 458 name: '@hey-api/typescript', 459 + output: '', 434 460 }, 435 461 'legacy/fetch': { 436 - config: {}, 462 + config: { 463 + name: 'legacy/fetch', 464 + }, 437 465 handler: () => {}, 438 - handlerLegacy: () => {}, 439 466 name: 'legacy/fetch', 467 + output: '', 440 468 tags: ['client'], 441 469 }, 442 470 },
+2 -3
packages/openapi-ts/src/plugins/@hey-api/sdk/auth.ts
··· 1 1 import type { IR } from '../../../ir/types'; 2 - import type { Plugin } from '../../types'; 3 2 import type { Auth } from '../client-core/bundle/auth'; 4 - import type { Config } from './types'; 3 + import type { HeyApiSdkPlugin } from './types'; 5 4 6 5 // TODO: parser - handle more security types 7 6 const securitySchemeObjectToAuthObject = ({ ··· 75 74 }: { 76 75 context: IR.Context; 77 76 operation: IR.OperationObject; 78 - plugin: Plugin.Instance<Config>; 77 + plugin: HeyApiSdkPlugin['Instance']; 79 78 }): Array<Auth> => { 80 79 if (!operation.security || !plugin.config.auth) { 81 80 return [];
+33 -12
packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from './plugin'; 4 3 import { handlerLegacy } from './plugin-legacy'; 5 - import type { Config } from './types'; 4 + import type { HeyApiSdkPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiSdkPlugin['Config'] = { 8 7 config: { 9 8 asClass: false, 10 9 auth: true, ··· 15 14 operationId: true, 16 15 response: 'body', 17 16 responseStyle: 'fields', 17 + transformer: false, 18 + validator: false, 18 19 }, 19 20 dependencies: ['@hey-api/typescript'], 20 21 handler, ··· 30 31 } 31 32 32 33 plugin.dependencies.add(plugin.config.client!); 34 + } else { 35 + plugin.config.client = false; 33 36 } 34 37 35 38 if (plugin.config.transformer) { ··· 38 41 } 39 42 40 43 plugin.dependencies.add(plugin.config.transformer!); 44 + } else { 45 + plugin.config.transformer = false; 41 46 } 42 47 43 - if (plugin.config.validator) { 44 - if (typeof plugin.config.validator === 'boolean') { 45 - plugin.config.validator = context.pluginByTag('validator'); 48 + if (typeof plugin.config.validator !== 'object') { 49 + plugin.config.validator = { 50 + request: plugin.config.validator, 51 + response: plugin.config.validator, 52 + }; 53 + } 54 + 55 + if (plugin.config.validator.request) { 56 + if (typeof plugin.config.validator.request === 'boolean') { 57 + plugin.config.validator.request = context.pluginByTag('validator'); 58 + } 59 + 60 + plugin.dependencies.add(plugin.config.validator.request!); 61 + } else { 62 + plugin.config.validator.request = false; 63 + } 64 + 65 + if (plugin.config.validator.response) { 66 + if (typeof plugin.config.validator.response === 'boolean') { 67 + plugin.config.validator.response = context.pluginByTag('validator'); 46 68 } 47 69 48 - plugin.dependencies.add(plugin.config.validator!); 70 + plugin.dependencies.add(plugin.config.validator.response!); 71 + } else { 72 + plugin.config.validator.response = false; 49 73 } 50 74 51 75 if (plugin.config.instance) { ··· 54 78 } 55 79 56 80 plugin.config.asClass = true; 57 - } 58 - 59 - // TODO: add responseStyle field to all clients 60 - if (plugin.config.client !== '@hey-api/client-fetch') { 61 - plugin.config.responseStyle = 'fields'; 81 + } else { 82 + plugin.config.instance = false; 62 83 } 63 84 }, 64 85 };
+1 -1
packages/openapi-ts/src/plugins/@hey-api/sdk/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiSdkPlugin } from './types';
+41 -34
packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts
··· 10 10 import { reservedJavaScriptKeywordsRegExp } from '../../../utils/regexp'; 11 11 import { stringCase } from '../../../utils/stringCase'; 12 12 import { transformClassName } from '../../../utils/transform'; 13 - import type { Plugin } from '../../types'; 14 13 import { clientId, getClientPlugin } from '../client-core/utils'; 15 14 import { 16 15 operationTransformerIrRef, ··· 19 18 import { importIdentifier } from '../typescript/ref'; 20 19 import { operationAuth } from './auth'; 21 20 import { nuxtTypeComposable, nuxtTypeDefault, sdkId } from './constants'; 22 - import type { Config } from './types'; 23 - import { createResponseValidator } from './validator'; 21 + import type { HeyApiSdkPlugin } from './types'; 22 + import { createRequestValidator, createResponseValidator } from './validator'; 24 23 25 24 interface ClassNameEntry { 26 25 /** ··· 61 60 operation: IR.OperationObject; 62 61 plugin: { 63 62 config: Pick< 64 - Plugin.Instance<Config>['config'], 63 + HeyApiSdkPlugin['Instance']['config'], 65 64 'asClass' | 'methodNameBuilder' 66 65 >; 67 66 }; ··· 90 89 operation: IR.OperationObject; 91 90 plugin: { 92 91 config: Pick< 93 - Plugin.Instance<Config>['config'], 92 + HeyApiSdkPlugin['Instance']['config'], 94 93 'asClass' | 'classStructure' | 'instance' 95 94 >; 96 95 }; ··· 247 246 context: IR.Context; 248 247 isRequiredOptions: boolean; 249 248 operation: IR.OperationObject; 250 - plugin: Plugin.Instance<Config>; 249 + plugin: HeyApiSdkPlugin['Instance']; 251 250 }): Array<ts.Statement> => { 252 251 const file = context.file({ id: sdkId })!; 253 252 const sdkOutput = file.nameWithoutExtension(); ··· 322 321 } 323 322 } 324 323 325 - if (client.name === '@hey-api/client-axios') { 326 - // try to infer `responseType` option for Axios. We don't need this in 327 - // Fetch API client because it automatically detects the correct response 328 - // during runtime. 329 - for (const statusCode in operation.responses) { 330 - // this doesn't handle default status code for now 331 - if (statusCodeToGroup({ statusCode }) === '2XX') { 332 - const response = operation.responses[statusCode]; 333 - const responseType = getResponseType(response?.mediaType); 334 - if (responseType) { 335 - requestOptions.push({ 336 - key: 'responseType', 337 - value: responseType, 338 - }); 339 - break; 340 - } 341 - } 342 - } 343 - } 344 - 345 324 // TODO: parser - set parseAs to skip inference if every response has the same 346 325 // content type. currently impossible because successes do not contain 347 326 // header information 348 327 349 - const auth = operationAuth({ context, operation, plugin }); 350 - if (auth.length) { 351 - requestOptions.push({ 352 - key: 'security', 353 - value: compiler.arrayLiteralExpression({ elements: auth }), 354 - }); 355 - } 356 - 357 328 for (const name in operation.parameters?.query) { 358 329 const parameter = operation.parameters.query[name]!; 359 330 if ( ··· 384 355 } 385 356 } 386 357 358 + const requestValidator = createRequestValidator({ operation, plugin }); 359 + if (requestValidator) { 360 + requestOptions.push({ 361 + key: 'requestValidator', 362 + value: requestValidator, 363 + }); 364 + } 365 + 387 366 if (plugin.config.transformer === '@hey-api/transformers') { 388 367 const identifierTransformer = context 389 368 .file({ id: transformersId })! ··· 408 387 } 409 388 } 410 389 390 + if (client.name === '@hey-api/client-axios') { 391 + // try to infer `responseType` option for Axios. We don't need this in 392 + // Fetch API client because it automatically detects the correct response 393 + // during runtime. 394 + for (const statusCode in operation.responses) { 395 + // this doesn't handle default status code for now 396 + if (statusCodeToGroup({ statusCode }) === '2XX') { 397 + const response = operation.responses[statusCode]; 398 + const responseType = getResponseType(response?.mediaType); 399 + if (responseType) { 400 + requestOptions.push({ 401 + key: 'responseType', 402 + value: responseType, 403 + }); 404 + break; 405 + } 406 + } 407 + } 408 + } 409 + 411 410 const responseValidator = createResponseValidator({ operation, plugin }); 412 411 if (responseValidator) { 413 412 requestOptions.push({ ··· 420 419 requestOptions.push({ 421 420 key: 'responseStyle', 422 421 value: plugin.config.responseStyle, 422 + }); 423 + } 424 + 425 + const auth = operationAuth({ context, operation, plugin }); 426 + if (auth.length) { 427 + requestOptions.push({ 428 + key: 'security', 429 + value: compiler.arrayLiteralExpression({ elements: auth }), 423 430 }); 424 431 } 425 432
+2 -3
packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts
··· 29 29 import { transformClassName } from '../../../utils/transform'; 30 30 import { setUniqueTypeName } from '../../../utils/type'; 31 31 import { unique } from '../../../utils/unique'; 32 - import type { Plugin } from '../../types'; 33 32 import { getClientPlugin } from '../client-core/utils'; 34 - import type { Config } from './types'; 33 + import type { HeyApiSdkPlugin } from './types'; 35 34 36 35 type OnNode = (node: ts.Node) => void; 37 36 type OnImport = (name: string) => void; ··· 800 799 onNode(statement); 801 800 }; 802 801 803 - export const handlerLegacy: Plugin.LegacyHandler<Config> = ({ 802 + export const handlerLegacy: HeyApiSdkPlugin['LegacyHandler'] = ({ 804 803 client, 805 804 files, 806 805 plugin,
+13 -6
packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts
··· 7 7 createOperationComment, 8 8 isOperationOptionsRequired, 9 9 } from '../../shared/utils/operation'; 10 - import type { Plugin } from '../../types'; 11 10 import { getClientPlugin } from '../client-core/utils'; 12 11 import { importIdentifier } from '../typescript/ref'; 13 12 import { nuxtTypeComposable, nuxtTypeDefault, sdkId } from './constants'; ··· 18 17 } from './operation'; 19 18 import { serviceFunctionIdentifier } from './plugin-legacy'; 20 19 import { createTypeOptions } from './typeOptions'; 21 - import type { Config } from './types'; 20 + import type { HeyApiSdkPlugin } from './types'; 22 21 23 22 const createClientClassNodes = ({ 24 23 plugin, 25 24 }: { 26 - plugin: Plugin.Instance<Config>; 25 + plugin: HeyApiSdkPlugin['Instance']; 27 26 }): ReadonlyArray<ts.ClassElement> => { 28 27 const clientAssignmentStatement = compiler.expressionToStatement({ 29 28 expression: compiler.binaryExpression({ ··· 109 108 root: boolean; 110 109 } 111 110 112 - const generateClassSdk = ({ plugin }: { plugin: Plugin.Instance<Config> }) => { 111 + const generateClassSdk = ({ 112 + plugin, 113 + }: { 114 + plugin: HeyApiSdkPlugin['Instance']; 115 + }) => { 113 116 const client = getClientPlugin(plugin.context.config); 114 117 const isNuxtClient = client.name === '@hey-api/client-nuxt'; 115 118 const file = plugin.context.file({ id: sdkId })!; ··· 316 319 } 317 320 }; 318 321 319 - const generateFlatSdk = ({ plugin }: { plugin: Plugin.Instance<Config> }) => { 322 + const generateFlatSdk = ({ 323 + plugin, 324 + }: { 325 + plugin: HeyApiSdkPlugin['Instance']; 326 + }) => { 320 327 const client = getClientPlugin(plugin.context.config); 321 328 const isNuxtClient = client.name === '@hey-api/client-nuxt'; 322 329 const file = plugin.context.file({ id: sdkId })!; ··· 398 405 }); 399 406 }; 400 407 401 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 408 + export const handler: HeyApiSdkPlugin['Handler'] = ({ plugin }) => { 402 409 const file = plugin.createFile({ 403 410 id: sdkId, 404 411 path: plugin.output,
+2 -3
packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts
··· 2 2 import { clientModulePath } from '../../../generate/client'; 3 3 import type { FileImportResult } from '../../../generate/files'; 4 4 import type { IR } from '../../../ir/types'; 5 - import type { Plugin } from '../../types'; 6 5 import { getClientPlugin } from '../client-core/utils'; 7 6 import { nuxtTypeDefault, nuxtTypeResponse, sdkId } from './constants'; 8 - import type { Config } from './types'; 7 + import type { HeyApiSdkPlugin } from './types'; 9 8 10 9 export const createTypeOptions = ({ 11 10 clientOptions, ··· 14 13 }: { 15 14 clientOptions: FileImportResult; 16 15 context: IR.Context; 17 - plugin: Plugin.Instance<Config>; 16 + plugin: HeyApiSdkPlugin['Instance']; 18 17 }) => { 19 18 const file = context.file({ id: sdkId })!; 20 19 const client = getClientPlugin(context.config);
+192 -10
packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts
··· 1 1 import type { IR } from '../../../ir/types'; 2 2 import type { Operation } from '../../../types/client'; 3 3 import type { 4 + DefinePlugin, 4 5 Plugin, 5 6 PluginClientNames, 6 7 PluginValidatorNames, 7 8 } from '../../types'; 8 9 9 - export interface Config extends Plugin.Name<'@hey-api/sdk'> { 10 + export type Config = Plugin.Name<'@hey-api/sdk'> & { 10 11 /** 11 12 * Group operation methods into classes? When enabled, you can select which 12 13 * classes to export with `sdk.include` and/or transform their names with ··· 114 115 */ 115 116 transformer?: '@hey-api/transformers' | boolean; 116 117 /** 117 - * Validate response data against schema before returning. This is useful 118 - * if you want to ensure the response conforms to a desired shape. However, 119 - * validation adds runtime overhead, so it's not recommended to use unless 120 - * absolutely necessary. 118 + * Validate request and/or response data against schema before returning. 119 + * This is useful if you want to ensure the request and/or response conforms 120 + * to a desired shape. However, validation adds runtime overhead, so it's 121 + * not recommended to use unless absolutely necessary. 122 + * 123 + * You can customize the validator output through its plugin. You can also 124 + * set `validator` to `true` to automatically choose the validator from your 125 + * defined plugins. 126 + * 127 + * You can enable/disable validation for requests and responses separately 128 + * by setting `validator` to an object `{ request, response }`. 121 129 * 122 130 * Ensure you have declared the selected library as a dependency to avoid 123 - * errors. You can customize the selected validator output through its 124 - * plugin. You can also set `validator` to `true` to automatically choose 125 - * the validator from your defined plugins. 131 + * errors. 126 132 * 127 133 * @default false 128 134 */ 129 - validator?: PluginValidatorNames | boolean; 135 + validator?: 136 + | PluginValidatorNames 137 + | boolean 138 + | { 139 + /** 140 + * Validate request data against schema before sending. 141 + * 142 + * Can be a validator plugin name or boolean (true to auto-select, false 143 + * to disable). 144 + * 145 + * @default false 146 + */ 147 + request?: PluginValidatorNames | boolean; 148 + /** 149 + * Validate response data against schema before returning. 150 + * 151 + * Can be a validator plugin name or boolean (true to auto-select, false 152 + * to disable). 153 + * 154 + * @default false 155 + */ 156 + response?: PluginValidatorNames | boolean; 157 + }; 130 158 131 159 // DEPRECATED OPTIONS BELOW 132 160 ··· 150 178 * @default 'body' 151 179 */ 152 180 response?: 'body' | 'response'; 153 - } 181 + }; 182 + 183 + export type ResolvedConfig = Plugin.Name<'@hey-api/sdk'> & { 184 + /** 185 + * Group operation methods into classes? When enabled, you can select which 186 + * classes to export with `sdk.include` and/or transform their names with 187 + * `sdk.classNameBuilder`. 188 + * 189 + * Note that by enabling this option, your SDKs will **NOT** 190 + * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. 191 + * For this reason, it is disabled by default. 192 + * 193 + * @default false 194 + */ 195 + asClass: boolean; 196 + /** 197 + * Should the generated functions contain auth mechanisms? You may want to 198 + * disable this option if you're handling auth yourself or defining it 199 + * globally on the client and want to reduce the size of generated code. 200 + * 201 + * @default true 202 + */ 203 + auth: boolean; 204 + /** 205 + * Customize the generated class names. The name variable is obtained from 206 + * your OpenAPI specification tags or `instance` value. 207 + * 208 + * This option has no effect if `sdk.asClass` is `false`. 209 + */ 210 + classNameBuilder: string | ((name: string) => string); 211 + /** 212 + * How should we structure your SDK? By default, we try to infer the ideal 213 + * structure using `operationId` keywords. If you prefer a flatter structure, 214 + * you can set `classStructure` to `off` to disable this behavior. 215 + * 216 + * @default 'auto' 217 + */ 218 + classStructure: 'auto' | 'off'; 219 + /** 220 + * Use an internal client instance to send HTTP requests? This is useful if 221 + * you don't want to manually pass the client to each SDK function. 222 + * 223 + * You can customize the selected client output through its plugin. You can 224 + * also set `client` to `true` to automatically choose the client from your 225 + * defined plugins. If we can't detect a client plugin when using `true`, we 226 + * will default to `@hey-api/client-fetch`. 227 + * 228 + * @default true 229 + */ 230 + client: PluginClientNames | false; 231 + /** 232 + * Should the exports from the generated files be re-exported in the index 233 + * barrel file? 234 + * 235 + * @default true 236 + */ 237 + exportFromIndex: boolean; 238 + /** 239 + * Include only service classes with names matching regular expression 240 + * 241 + * This option has no effect if `sdk.asClass` is `false`. 242 + */ 243 + include: string | undefined; 244 + /** 245 + * Set `instance` to create an instantiable SDK. Using `true` will use the 246 + * default instance name; in practice, you want to define your own by passing 247 + * a string value. 248 + * 249 + * @default false 250 + */ 251 + instance: string | boolean; 252 + /** 253 + * Customise the name of methods within the service. By default, 254 + * {@link IR.OperationObject.id} or {@link Operation.name} is used. 255 + */ 256 + methodNameBuilder?: (operation: IR.OperationObject | Operation) => string; 257 + // TODO: parser - rename operationId option to something like inferId?: boolean 258 + /** 259 + * Use operation ID to generate operation names? 260 + * 261 + * @default true 262 + */ 263 + operationId: boolean; 264 + /** 265 + * Name of the generated file. 266 + * 267 + * @default 'sdk' 268 + */ 269 + output: string; 270 + /** 271 + * **This feature works only with the Fetch client** 272 + * 273 + * Should we return only data or multiple fields (data, error, response, etc.)? 274 + * 275 + * @default 'fields' 276 + */ 277 + responseStyle: 'data' | 'fields'; 278 + /** 279 + * Transform response data before returning. This is useful if you want to 280 + * convert for example ISO strings into Date objects. However, transformation 281 + * adds runtime overhead, so it's not recommended to use unless necessary. 282 + * 283 + * You can customize the selected transformer output through its plugin. You 284 + * can also set `transformer` to `true` to automatically choose the 285 + * transformer from your defined plugins. 286 + * 287 + * @default false 288 + */ 289 + transformer: '@hey-api/transformers' | false; 290 + /** 291 + * Validate request and/or response data against schema before returning. 292 + * This is useful if you want to ensure the request and/or response conforms 293 + * to a desired shape. However, validation adds runtime overhead, so it's 294 + * not recommended to use unless absolutely necessary. 295 + */ 296 + validator: { 297 + /** 298 + * The validator plugin to use for request validation, or false to disable. 299 + * 300 + * @default false 301 + */ 302 + request: PluginValidatorNames | false; 303 + /** 304 + * The validator plugin to use for response validation, or false to disable. 305 + * 306 + * @default false 307 + */ 308 + response: PluginValidatorNames | false; 309 + }; 310 + 311 + // DEPRECATED OPTIONS BELOW 312 + 313 + /** 314 + * **This feature works only with the legacy parser** 315 + * 316 + * Filter endpoints to be included in the generated SDK. The provided 317 + * string should be a regular expression where matched results will be 318 + * included in the output. The input pattern this string will be tested 319 + * against is `{method} {path}`. For example, you can match 320 + * `POST /api/v1/foo` with `^POST /api/v1/foo$`. 321 + * 322 + * @deprecated 323 + */ 324 + // eslint-disable-next-line typescript-sort-keys/interface 325 + filter?: string; 326 + /** 327 + * Define shape of returned value from service calls 328 + * 329 + * @deprecated 330 + * @default 'body' 331 + */ 332 + response: 'body' | 'response'; 333 + }; 334 + 335 + export type HeyApiSdkPlugin = DefinePlugin<Config, ResolvedConfig>;
+25 -119
packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts
··· 1 - import { compiler } from '../../../compiler'; 2 1 import type { IR } from '../../../ir/types'; 3 - import type { Plugin } from '../../types'; 4 - import { valibotId } from '../../valibot/constants'; 5 - import { zodId } from '../../zod/plugin'; 6 2 import { sdkId } from './constants'; 7 - import type { Config } from './types'; 8 - 9 - const identifiers = { 10 - data: compiler.identifier({ text: 'data' }), 11 - parseAsync: compiler.identifier({ text: 'parseAsync' }), 12 - v: compiler.identifier({ text: 'v' }), 13 - }; 3 + import type { HeyApiSdkPlugin } from './types'; 14 4 15 - const valibotResponseValidator = ({ 5 + export const createRequestValidator = ({ 16 6 operation, 17 7 plugin, 18 8 }: { 19 9 operation: IR.OperationObject; 20 - plugin: Plugin.Instance<Config>; 10 + plugin: HeyApiSdkPlugin['Instance']; 21 11 }) => { 22 - const file = plugin.context.file({ id: sdkId })!; 23 - 24 - const responses = plugin.getPlugin('valibot')?.config.responses; 25 - const identifierSchema = plugin.context.file({ id: valibotId })!.identifier({ 26 - // TODO: refactor for better cross-plugin compatibility 27 - $ref: `#/valibot-response/${operation.id}`, 28 - // TODO: refactor to not have to define nameTransformer 29 - nameTransformer: typeof responses === 'object' ? responses.name : undefined, 30 - namespace: 'value', 31 - }); 32 - 33 - if (!identifierSchema.name) { 12 + if (!plugin.config.validator.request) { 34 13 return; 35 14 } 36 15 37 - file.import({ 38 - module: file.relativePathToFile({ 39 - context: plugin.context, 40 - id: valibotId, 41 - }), 42 - name: identifierSchema.name, 43 - }); 44 - 45 - file.import({ 46 - alias: identifiers.v.text, 47 - module: 'valibot', 48 - name: '*', 49 - }); 16 + const pluginValidator = plugin.getPlugin(plugin.config.validator.request); 17 + if (!pluginValidator || !pluginValidator.api.createRequestValidator) { 18 + return; 19 + } 50 20 51 - return compiler.arrowFunction({ 52 - async: true, 53 - parameters: [ 54 - { 55 - name: 'data', 56 - }, 57 - ], 58 - statements: [ 59 - compiler.returnStatement({ 60 - expression: compiler.awaitExpression({ 61 - expression: compiler.callExpression({ 62 - functionName: compiler.propertyAccessExpression({ 63 - expression: identifiers.v, 64 - name: identifiers.parseAsync, 65 - }), 66 - parameters: [ 67 - compiler.identifier({ text: identifierSchema.name }), 68 - identifiers.data, 69 - ], 70 - }), 71 - }), 72 - }), 73 - ], 21 + return pluginValidator.api.createRequestValidator({ 22 + file: plugin.context.file({ id: sdkId })!, 23 + operation, 24 + // @ts-expect-error 25 + plugin: pluginValidator, 74 26 }); 75 27 }; 76 28 77 - const zodResponseValidator = ({ 29 + export const createResponseValidator = ({ 78 30 operation, 79 31 plugin, 80 32 }: { 81 33 operation: IR.OperationObject; 82 - plugin: Plugin.Instance<Config>; 34 + plugin: HeyApiSdkPlugin['Instance']; 83 35 }) => { 84 - const file = plugin.context.file({ id: sdkId })!; 85 - 86 - const responses = plugin.getPlugin('zod')?.config.responses; 87 - const identifierSchema = plugin.context.file({ id: zodId })!.identifier({ 88 - // TODO: refactor for better cross-plugin compatibility 89 - $ref: `#/zod-response/${operation.id}`, 90 - // TODO: refactor to not have to define nameTransformer 91 - nameTransformer: typeof responses === 'object' ? responses.name : undefined, 92 - namespace: 'value', 93 - }); 94 - 95 - if (!identifierSchema.name) { 36 + if (!plugin.config.validator.response) { 96 37 return; 97 38 } 98 39 99 - file.import({ 100 - module: file.relativePathToFile({ 101 - context: plugin.context, 102 - id: zodId, 103 - }), 104 - name: identifierSchema.name, 105 - }); 40 + const pluginValidator = plugin.getPlugin(plugin.config.validator.response); 41 + if (!pluginValidator || !pluginValidator.api.createResponseValidator) { 42 + return; 43 + } 106 44 107 - return compiler.arrowFunction({ 108 - async: true, 109 - parameters: [ 110 - { 111 - name: 'data', 112 - }, 113 - ], 114 - statements: [ 115 - compiler.returnStatement({ 116 - expression: compiler.awaitExpression({ 117 - expression: compiler.callExpression({ 118 - functionName: compiler.propertyAccessExpression({ 119 - expression: compiler.identifier({ text: identifierSchema.name }), 120 - name: identifiers.parseAsync, 121 - }), 122 - parameters: [identifiers.data], 123 - }), 124 - }), 125 - }), 126 - ], 45 + return pluginValidator.api.createResponseValidator({ 46 + file: plugin.context.file({ id: sdkId })!, 47 + operation, 48 + // @ts-expect-error 49 + plugin: pluginValidator, 127 50 }); 128 51 }; 129 - 130 - export const createResponseValidator = ({ 131 - operation, 132 - plugin, 133 - }: { 134 - operation: IR.OperationObject; 135 - plugin: Plugin.Instance<Config>; 136 - }) => { 137 - switch (plugin.config.validator) { 138 - case 'valibot': 139 - return valibotResponseValidator({ operation, plugin }); 140 - case 'zod': 141 - return zodResponseValidator({ operation, plugin }); 142 - default: 143 - return; 144 - } 145 - };
+2 -3
packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from './plugin'; 4 3 import { handlerLegacy } from './plugin-legacy'; 5 - import type { Config } from './types'; 4 + import type { HeyApiTransformersPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiTransformersPlugin['Config'] = { 8 7 config: { 9 8 bigInt: true, 10 9 dates: true,
+1 -1
packages/openapi-ts/src/plugins/@hey-api/transformers/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiTransformersPlugin } from './types';
+2 -3
packages/openapi-ts/src/plugins/@hey-api/transformers/plugin-legacy.ts
··· 5 5 import type { ModelMeta, OperationResponse } from '../../../types/client'; 6 6 import { getConfig } from '../../../utils/config'; 7 7 import { isModelDate, unsetUniqueTypeName } from '../../../utils/type'; 8 - import type { Plugin } from '../../types'; 9 8 import { 10 9 modelResponseTransformerTypeName, 11 10 operationResponseTransformerTypeName, 12 11 operationResponseTypeName, 13 12 } from '../sdk/plugin-legacy'; 14 13 import { generateType, type TypesProps } from '../typescript/plugin-legacy'; 15 - import type { Config } from './types'; 14 + import type { HeyApiTransformersPlugin } from './types'; 16 15 17 16 interface ModelProps extends TypesProps { 18 17 meta?: ModelMeta; ··· 249 248 }; 250 249 251 250 // handles only response transformers for now 252 - export const handlerLegacy: Plugin.LegacyHandler<Config> = ({ 251 + export const handlerLegacy: HeyApiTransformersPlugin['LegacyHandler'] = ({ 253 252 client, 254 253 files, 255 254 }) => {
+4 -5
packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts
··· 9 9 import { irRef } from '../../../utils/ref'; 10 10 import { stringCase } from '../../../utils/stringCase'; 11 11 import { operationIrRef } from '../../shared/utils/ref'; 12 - import type { Plugin } from '../../types'; 13 12 import { typesId } from '../typescript/ref'; 14 - import type { Config } from './types'; 13 + import type { HeyApiTransformersPlugin } from './types'; 15 14 16 15 interface OperationIRRef { 17 16 /** ··· 162 161 plugin, 163 162 schema, 164 163 }: { 165 - plugin: Plugin.Instance<Config>; 164 + plugin: HeyApiTransformersPlugin['Instance']; 166 165 schema: IR.SchemaObject; 167 166 }): Array<ts.Expression | ts.Statement> => { 168 167 const identifierData = compiler.identifier({ text: dataVariableName }); ··· 187 186 schema, 188 187 }: { 189 188 dataExpression?: ts.Expression | string; 190 - plugin: Plugin.Instance<Config>; 189 + plugin: HeyApiTransformersPlugin['Instance']; 191 190 schema: IR.SchemaObject; 192 191 }): Array<ts.Expression | ts.Statement> => { 193 192 const file = plugin.context.file({ id: transformersId })!; ··· 454 453 }; 455 454 456 455 // handles only response transformers for now 457 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 456 + export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { 458 457 const file = plugin.createFile({ 459 458 id: transformersId, 460 459 path: plugin.output,
+5 -3
packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts
··· 1 - import type { Plugin } from '../../types'; 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 2 3 - export interface Config extends Plugin.Name<'@hey-api/transformers'> { 3 + export type Config = Plugin.Name<'@hey-api/transformers'> & { 4 4 /** 5 5 * Convert long integers into BigInt values? 6 6 * ··· 26 26 * @default 'transformers' 27 27 */ 28 28 output?: string; 29 - } 29 + }; 30 + 31 + export type HeyApiTransformersPlugin = DefinePlugin<Config>;
+14 -7
packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts
··· 44 44 ], 45 45 plugins: { 46 46 '@hey-api/schemas': { 47 - config: {}, 47 + config: { 48 + name: '@hey-api/schemas', 49 + }, 48 50 handler: () => {}, 49 - handlerLegacy: () => {}, 50 51 name: '@hey-api/schemas', 52 + output: '', 51 53 }, 52 54 '@hey-api/sdk': { 53 - config: {}, 55 + config: { 56 + name: '@hey-api/sdk', 57 + }, 54 58 handler: () => {}, 55 - handlerLegacy: () => {}, 56 59 name: '@hey-api/sdk', 60 + output: '', 57 61 }, 58 62 '@hey-api/typescript': { 59 63 config: { 60 64 enums: 'javascript', 65 + name: '@hey-api/typescript', 61 66 }, 62 67 handler: () => {}, 63 - handlerLegacy: () => {}, 64 68 name: '@hey-api/typescript', 69 + output: '', 65 70 }, 66 71 'legacy/fetch': { 67 - config: {}, 72 + config: { 73 + name: 'legacy/fetch', 74 + }, 68 75 handler: () => {}, 69 - handlerLegacy: () => {}, 70 76 name: 'legacy/fetch', 77 + output: '', 71 78 tags: ['client'], 72 79 }, 73 80 },
+2 -3
packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts
··· 4 4 import type { Identifier } from '../../../generate/files'; 5 5 import type { IR } from '../../../ir/types'; 6 6 import { parseUrl } from '../../../utils/url'; 7 - import type { Plugin } from '../../types'; 8 7 import { getClientBaseUrlKey, getClientPlugin } from '../client-core/utils'; 9 8 import { typesId } from './ref'; 10 - import type { Config } from './types'; 9 + import type { HeyApiTypeScriptPlugin } from './types'; 11 10 12 11 const stringType = compiler.keywordTypeNode({ keyword: 'string' }); 13 12 ··· 37 36 servers, 38 37 }: { 39 38 identifier: Identifier; 40 - plugin: Plugin.Instance<Config>; 39 + plugin: HeyApiTypeScriptPlugin['Instance']; 41 40 servers: ReadonlyArray<IR.ServerObject>; 42 41 }) => { 43 42 const file = plugin.context.file({ id: typesId })!;
+2 -3
packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from './plugin'; 4 3 import { handlerLegacy } from './plugin-legacy'; 5 - import type { Config } from './types'; 4 + import type { HeyApiTypeScriptPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config> = { 6 + export const defaultConfig: HeyApiTypeScriptPlugin['Config'] = { 8 7 config: { 9 8 enums: false, 10 9 enumsCase: 'SCREAMING_SNAKE_CASE',
+1 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { HeyApiTypeScriptPlugin } from './types';
+2 -3
packages/openapi-ts/src/plugins/@hey-api/typescript/plugin-legacy.ts
··· 18 18 type SetUniqueTypeNameResult, 19 19 toType, 20 20 } from '../../../utils/type'; 21 - import type { Plugin } from '../../types'; 22 21 import { 23 22 operationDataTypeName, 24 23 operationErrorTypeName, 25 24 operationResponseTypeName, 26 25 } from '../sdk/plugin-legacy'; 27 - import type { Config } from './types'; 26 + import type { HeyApiTypeScriptPlugin } from './types'; 28 27 29 28 export interface TypesProps { 30 29 client: Client; ··· 610 609 } 611 610 }; 612 611 613 - export const handlerLegacy: Plugin.LegacyHandler<Config> = ({ 612 + export const handlerLegacy: HeyApiTypeScriptPlugin['LegacyHandler'] = ({ 614 613 client, 615 614 files, 616 615 plugin,
+18 -19
packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts
··· 11 11 import { fieldName } from '../../shared/utils/case'; 12 12 import { operationIrRef } from '../../shared/utils/ref'; 13 13 import { createSchemaComment } from '../../shared/utils/schema'; 14 - import type { Plugin } from '../../types'; 15 14 import { createClientOptions } from './clientOptions'; 16 15 import { typesId } from './ref'; 17 - import type { Config } from './types'; 16 + import type { HeyApiTypeScriptPlugin } from './types'; 18 17 19 18 interface SchemaWithType<T extends Required<IR.SchemaObject>['type']> 20 19 extends Omit<IR.SchemaObject, 'type'> { ··· 42 41 }: { 43 42 $ref: string; 44 43 accessScope?: 'both' | 'read' | 'write'; 45 - plugin: Plugin.Instance<Config>; 44 + plugin: HeyApiTypeScriptPlugin['Instance']; 46 45 }) => { 47 46 if (!accessScope || accessScope === 'both') { 48 47 return $ref; ··· 121 120 schema, 122 121 }: { 123 122 $ref: string; 124 - plugin: Plugin.Instance<Config>; 123 + plugin: HeyApiTypeScriptPlugin['Instance']; 125 124 schema: SchemaWithType<'enum'>; 126 125 }) => { 127 126 const file = plugin.context.file({ id: typesId })!; ··· 168 167 plugin, 169 168 schema, 170 169 }: { 171 - plugin: Plugin.Instance<Config>; 170 + plugin: HeyApiTypeScriptPlugin['Instance']; 172 171 schema: IR.SchemaObject; 173 172 }) => { 174 173 const typeofItems: Array< ··· 242 241 state, 243 242 }: { 244 243 $ref: string; 245 - plugin: Plugin.Instance<Config>; 244 + plugin: HeyApiTypeScriptPlugin['Instance']; 246 245 schema: SchemaWithType<'enum'>; 247 246 state: State | undefined; 248 247 }): ts.TypeAliasDeclaration | undefined => { ··· 292 291 plugin, 293 292 schema, 294 293 }: { 295 - plugin: Plugin.Instance<Config>; 294 + plugin: HeyApiTypeScriptPlugin['Instance']; 296 295 schema: SchemaWithType<'enum'>; 297 296 }) => { 298 297 const enumObject = schemaToEnumObject({ plugin, schema }); ··· 309 308 state, 310 309 }: { 311 310 $ref: string; 312 - plugin: Plugin.Instance<Config>; 311 + plugin: HeyApiTypeScriptPlugin['Instance']; 313 312 schema: SchemaWithType<'enum'>; 314 313 state: State | undefined; 315 314 }) => { ··· 347 346 state, 348 347 }: { 349 348 namespace: Array<ts.Statement>; 350 - plugin: Plugin.Instance<Config>; 349 + plugin: HeyApiTypeScriptPlugin['Instance']; 351 350 schema: SchemaWithType<'array'>; 352 351 state: State | undefined; 353 352 }): ts.TypeNode | undefined => { ··· 419 418 }: { 420 419 $ref?: string; 421 420 namespace: Array<ts.Statement>; 422 - plugin: Plugin.Instance<Config>; 421 + plugin: HeyApiTypeScriptPlugin['Instance']; 423 422 schema: SchemaWithType<'enum'>; 424 423 state: State | undefined; 425 424 }): ts.TypeNode | undefined => { ··· 510 509 schema, 511 510 }: { 512 511 namespace: Array<ts.Statement>; 513 - plugin: Plugin.Instance<Config>; 512 + plugin: HeyApiTypeScriptPlugin['Instance']; 514 513 schema: SchemaWithType<'integer' | 'number'>; 515 514 }): ts.TypeNode => { 516 515 if (schema.const !== undefined) { ··· 538 537 state, 539 538 }: { 540 539 namespace: Array<ts.Statement>; 541 - plugin: Plugin.Instance<Config>; 540 + plugin: HeyApiTypeScriptPlugin['Instance']; 542 541 schema: SchemaWithType<'object'>; 543 542 state: State | undefined; 544 543 }): ts.TypeNode | undefined => { ··· 648 647 schema, 649 648 }: { 650 649 namespace: Array<ts.Statement>; 651 - plugin: Plugin.Instance<Config>; 650 + plugin: HeyApiTypeScriptPlugin['Instance']; 652 651 schema: SchemaWithType<'string'>; 653 652 }): ts.TypeNode => { 654 653 if (schema.const !== undefined) { ··· 691 690 state, 692 691 }: { 693 692 namespace: Array<ts.Statement>; 694 - plugin: Plugin.Instance<Config>; 693 + plugin: HeyApiTypeScriptPlugin['Instance']; 695 694 schema: SchemaWithType<'tuple'>; 696 695 state: State | undefined; 697 696 }): ts.TypeNode | undefined => { ··· 735 734 }: { 736 735 $ref?: string; 737 736 namespace: Array<ts.Statement>; 738 - plugin: Plugin.Instance<Config>; 737 + plugin: HeyApiTypeScriptPlugin['Instance']; 739 738 schema: IR.SchemaObject; 740 739 state: State | undefined; 741 740 }): ts.TypeNode | undefined => { ··· 851 850 plugin, 852 851 }: { 853 852 operation: IR.OperationObject; 854 - plugin: Plugin.Instance<Config>; 853 + plugin: HeyApiTypeScriptPlugin['Instance']; 855 854 }) => { 856 855 const file = plugin.context.file({ id: typesId })!; 857 856 const data: IR.SchemaObject = { ··· 962 961 plugin, 963 962 }: { 964 963 operation: IR.OperationObject; 965 - plugin: Plugin.Instance<Config>; 964 + plugin: HeyApiTypeScriptPlugin['Instance']; 966 965 }) => { 967 966 operationToDataType({ operation, plugin }); 968 967 ··· 1139 1138 }: { 1140 1139 $ref?: string; 1141 1140 namespace?: Array<ts.Statement>; 1142 - plugin: Plugin.Instance<Config>; 1141 + plugin: HeyApiTypeScriptPlugin['Instance']; 1143 1142 schema: IR.SchemaObject; 1144 1143 state: State | undefined; 1145 1144 }): ts.TypeNode | undefined => { ··· 1266 1265 return type; 1267 1266 }; 1268 1267 1269 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 1268 + export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { 1270 1269 const file = plugin.createFile({ 1271 1270 id: typesId, 1272 1271 identifierCase: plugin.config.identifierCase,
+6 -4
packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config extends Plugin.Name<'@hey-api/typescript'> { 4 + export type Config = Plugin.Name<'@hey-api/typescript'> & { 5 5 /** 6 6 * By default, enums are generated as TypeScript types. In addition to that, 7 7 * you can choose to generate them as JavaScript objects, TypeScript enums, ··· 107 107 * @default false 108 108 */ 109 109 tree?: boolean; 110 - } 110 + }; 111 + 112 + export type HeyApiTypeScriptPlugin = DefinePlugin<Config>;
+4 -5
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from '../query-core/plugin'; 4 3 import { handlerLegacy } from '../query-core/plugin-legacy'; 5 - import type { Config, ResolvedConfig } from './types'; 4 + import type { TanStackAngularQueryPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: TanStackAngularQueryPlugin['Config'] = { 8 7 config: { 9 8 case: 'camelCase', 10 9 comments: true, 11 10 exportFromIndex: false, 12 11 }, 13 12 dependencies: ['@hey-api/sdk', '@hey-api/typescript'], 14 - handler, 15 - handlerLegacy, 13 + handler: handler as TanStackAngularQueryPlugin['Handler'], 14 + handlerLegacy: handlerLegacy as TanStackAngularQueryPlugin['LegacyHandler'], 16 15 name: '@tanstack/angular-query-experimental', 17 16 output: '@tanstack/angular-query-experimental', 18 17 resolveConfig: (plugin, context) => {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { TanStackAngularQueryPlugin } from './types';
+81 -80
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config 5 - extends Plugin.Name<'@tanstack/angular-query-experimental'> { 4 + export type Config = Plugin.Name<'@tanstack/angular-query-experimental'> & { 6 5 /** 7 6 * The casing convention to use for generated names. 8 7 * ··· 92 91 enabled?: boolean; 93 92 name?: string | ((name: string) => string); 94 93 }; 95 - } 94 + }; 96 95 97 - export interface ResolvedConfig 98 - extends Plugin.Name<'@tanstack/angular-query-experimental'> { 99 - /** 100 - * The casing convention to use for generated names. 101 - * 102 - * @default 'camelCase' 103 - */ 104 - case: StringCase; 105 - /** 106 - * Add comments from SDK functions to the generated TanStack Query code? 107 - * 108 - * @default true 109 - */ 110 - comments: boolean; 111 - /** 112 - * Should the exports from the generated files be re-exported in the index barrel file? 113 - * 114 - * @default false 115 - */ 116 - exportFromIndex: boolean; 117 - /** 118 - * Resolved configuration for generated infinite query key helpers. 119 - * 120 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 121 - */ 122 - infiniteQueryKeys: { 123 - case: StringCase; 124 - enabled: boolean; 125 - name: string | ((name: string) => string); 126 - }; 127 - /** 128 - * Resolved configuration for generated infinite query options helpers. 129 - * 130 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 131 - */ 132 - infiniteQueryOptions: { 133 - case: StringCase; 134 - enabled: boolean; 135 - name: string | ((name: string) => string); 136 - }; 137 - /** 138 - * Resolved configuration for generated mutation options helpers. 139 - * 140 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation 141 - */ 142 - mutationOptions: { 143 - case: StringCase; 144 - enabled: boolean; 145 - name: string | ((name: string) => string); 146 - }; 147 - /** 148 - * Name of the generated file. 149 - * 150 - * @default '@tanstack/angular-query-experimental' 151 - */ 152 - output: string; 153 - /** 154 - * Resolved configuration for generated query keys. 155 - * 156 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryKey 157 - */ 158 - queryKeys: { 159 - case: StringCase; 160 - enabled: boolean; 161 - name: string | ((name: string) => string); 162 - }; 163 - /** 164 - * Resolved configuration for generated query options helpers. 165 - * 166 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions 167 - */ 168 - queryOptions: { 96 + export type ResolvedConfig = 97 + Plugin.Name<'@tanstack/angular-query-experimental'> & { 98 + /** 99 + * The casing convention to use for generated names. 100 + * 101 + * @default 'camelCase' 102 + */ 169 103 case: StringCase; 170 - enabled: boolean; 171 - name: string | ((name: string) => string); 104 + /** 105 + * Add comments from SDK functions to the generated TanStack Query code? 106 + * 107 + * @default true 108 + */ 109 + comments: boolean; 110 + /** 111 + * Should the exports from the generated files be re-exported in the index barrel file? 112 + * 113 + * @default false 114 + */ 115 + exportFromIndex: boolean; 116 + /** 117 + * Resolved configuration for generated infinite query key helpers. 118 + * 119 + * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 120 + */ 121 + infiniteQueryKeys: { 122 + case: StringCase; 123 + enabled: boolean; 124 + name: string | ((name: string) => string); 125 + }; 126 + /** 127 + * Resolved configuration for generated infinite query options helpers. 128 + * 129 + * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 130 + */ 131 + infiniteQueryOptions: { 132 + case: StringCase; 133 + enabled: boolean; 134 + name: string | ((name: string) => string); 135 + }; 136 + /** 137 + * Resolved configuration for generated mutation options helpers. 138 + * 139 + * @see https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation 140 + */ 141 + mutationOptions: { 142 + case: StringCase; 143 + enabled: boolean; 144 + name: string | ((name: string) => string); 145 + }; 146 + /** 147 + * Name of the generated file. 148 + * 149 + * @default '@tanstack/angular-query-experimental' 150 + */ 151 + output: string; 152 + /** 153 + * Resolved configuration for generated query keys. 154 + * 155 + * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryKey 156 + */ 157 + queryKeys: { 158 + case: StringCase; 159 + enabled: boolean; 160 + name: string | ((name: string) => string); 161 + }; 162 + /** 163 + * Resolved configuration for generated query options helpers. 164 + * 165 + * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions 166 + */ 167 + queryOptions: { 168 + case: StringCase; 169 + enabled: boolean; 170 + name: string | ((name: string) => string); 171 + }; 172 172 }; 173 - } 173 + 174 + export type TanStackAngularQueryPlugin = DefinePlugin<Config, ResolvedConfig>;
+16 -13
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin-legacy.ts
··· 32 32 operationResponseTypeName, 33 33 serviceFunctionIdentifier, 34 34 } from '../../@hey-api/sdk/plugin-legacy'; 35 - import type { Plugin } from '../../types'; 36 - import type { Config as AngularQueryConfig } from '../angular-query-experimental'; 37 - import type { Config as ReactQueryConfig } from '../react-query'; 38 - import type { Config as SolidQueryConfig } from '../solid-query'; 39 - import type { Config as SvelteQueryConfig } from '../svelte-query'; 40 - import type { Config as VueQueryConfig } from '../vue-query'; 35 + import type { TanStackAngularQueryPlugin } from '../angular-query-experimental'; 36 + import type { TanStackReactQueryPlugin } from '../react-query'; 37 + import type { TanStackSolidQueryPlugin } from '../solid-query'; 38 + import type { TanStackSvelteQueryPlugin } from '../svelte-query'; 39 + import type { TanStackVueQueryPlugin } from '../vue-query'; 41 40 42 41 const toInfiniteQueryOptionsName = (operation: Operation) => 43 42 `${serviceFunctionIdentifier({ ··· 668 667 return queryKeyLiteral; 669 668 }; 670 669 671 - export const handlerLegacy: Plugin.LegacyHandler< 672 - | ReactQueryConfig 673 - | AngularQueryConfig 674 - | SolidQueryConfig 675 - | SvelteQueryConfig 676 - | VueQueryConfig 677 - > = ({ client, files, plugin }) => { 670 + export const handlerLegacy = ({ 671 + client, 672 + files, 673 + plugin, 674 + }: Parameters< 675 + | TanStackAngularQueryPlugin['LegacyHandler'] 676 + | TanStackReactQueryPlugin['LegacyHandler'] 677 + | TanStackSolidQueryPlugin['LegacyHandler'] 678 + | TanStackSvelteQueryPlugin['LegacyHandler'] 679 + | TanStackVueQueryPlugin['LegacyHandler'] 680 + >[0]) => { 678 681 const config = getConfig(); 679 682 680 683 if (isLegacyClient(config)) {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
··· 9 9 import { createQueryOptions } from './queryOptions'; 10 10 import type { PluginHandler, PluginState } from './types'; 11 11 12 - export const handler: PluginHandler = ({ plugin }) => { 12 + export const handler = ({ plugin }: Parameters<PluginHandler>[0]) => { 13 13 const file = plugin.createFile({ 14 14 id: plugin.name, 15 15 identifierCase: plugin.config.case,
+17 -20
packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts
··· 1 1 import type { ImportExportItem } from '../../../compiler/module'; 2 - import type { Plugin } from '../../types'; 3 - import type { ResolvedConfig as AngularQueryResolvedConfig } from '../angular-query-experimental/types'; 4 - import type { ResolvedConfig as ReactQueryResolvedConfig } from '../react-query/types'; 5 - import type { ResolvedConfig as SolidQueryResolvedConfig } from '../solid-query/types'; 6 - import type { ResolvedConfig as SvelteQueryResolvedConfig } from '../svelte-query/types'; 7 - import type { ResolvedConfig as VueQueryResolvedConfig } from '../vue-query/types'; 2 + import type { TanStackAngularQueryPlugin } from '../angular-query-experimental/types'; 3 + import type { TanStackReactQueryPlugin } from '../react-query/types'; 4 + import type { TanStackSolidQueryPlugin } from '../solid-query/types'; 5 + import type { TanStackSvelteQueryPlugin } from '../svelte-query/types'; 6 + import type { TanStackVueQueryPlugin } from '../vue-query/types'; 8 7 9 - export type PluginHandler = Plugin.Handler< 10 - | AngularQueryResolvedConfig 11 - | ReactQueryResolvedConfig 12 - | SolidQueryResolvedConfig 13 - | SvelteQueryResolvedConfig 14 - | VueQueryResolvedConfig 15 - >; 8 + export type PluginHandler = 9 + | TanStackAngularQueryPlugin['Handler'] 10 + | TanStackReactQueryPlugin['Handler'] 11 + | TanStackSolidQueryPlugin['Handler'] 12 + | TanStackSvelteQueryPlugin['Handler'] 13 + | TanStackVueQueryPlugin['Handler']; 16 14 17 - export type PluginInstance = Plugin.Instance< 18 - | AngularQueryResolvedConfig 19 - | ReactQueryResolvedConfig 20 - | SolidQueryResolvedConfig 21 - | SvelteQueryResolvedConfig 22 - | VueQueryResolvedConfig 23 - >; 15 + export type PluginInstance = 16 + | TanStackAngularQueryPlugin['Instance'] 17 + | TanStackReactQueryPlugin['Instance'] 18 + | TanStackSolidQueryPlugin['Instance'] 19 + | TanStackSvelteQueryPlugin['Instance'] 20 + | TanStackVueQueryPlugin['Instance']; 24 21 25 22 export interface PluginState { 26 23 hasCreateInfiniteParamsFunction: boolean;
+4 -5
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from '../query-core/plugin'; 4 3 import { handlerLegacy } from '../query-core/plugin-legacy'; 5 - import type { Config, ResolvedConfig } from './types'; 4 + import type { TanStackReactQueryPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: TanStackReactQueryPlugin['Config'] = { 8 7 config: { 9 8 case: 'camelCase', 10 9 comments: true, 11 10 exportFromIndex: false, 12 11 }, 13 12 dependencies: ['@hey-api/sdk', '@hey-api/typescript'], 14 - handler, 15 - handlerLegacy, 13 + handler: handler as TanStackReactQueryPlugin['Handler'], 14 + handlerLegacy: handlerLegacy as TanStackReactQueryPlugin['LegacyHandler'], 16 15 name: '@tanstack/react-query', 17 16 output: '@tanstack/react-query', 18 17 resolveConfig: (plugin, context) => {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { TanStackReactQueryPlugin } from './types';
+8 -6
packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config extends Plugin.Name<'@tanstack/react-query'> { 4 + export type Config = Plugin.Name<'@tanstack/react-query'> & { 5 5 /** 6 6 * The casing convention to use for generated names. 7 7 * ··· 206 206 */ 207 207 name?: string | ((name: string) => string); 208 208 }; 209 - } 209 + }; 210 210 211 - export interface ResolvedConfig extends Plugin.Name<'@tanstack/react-query'> { 211 + export type ResolvedConfig = Plugin.Name<'@tanstack/react-query'> & { 212 212 /** 213 213 * The casing convention to use for generated names. 214 214 * ··· 363 363 */ 364 364 name: string | ((name: string) => string); 365 365 }; 366 - } 366 + }; 367 + 368 + export type TanStackReactQueryPlugin = DefinePlugin<Config, ResolvedConfig>;
+4 -5
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from '../query-core/plugin'; 4 3 import { handlerLegacy } from '../query-core/plugin-legacy'; 5 - import type { Config, ResolvedConfig } from './types'; 4 + import type { TanStackSolidQueryPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: TanStackSolidQueryPlugin['Config'] = { 8 7 config: { 9 8 case: 'camelCase', 10 9 comments: true, 11 10 exportFromIndex: false, 12 11 }, 13 12 dependencies: ['@hey-api/sdk', '@hey-api/typescript'], 14 - handler, 15 - handlerLegacy, 13 + handler: handler as TanStackSolidQueryPlugin['Handler'], 14 + handlerLegacy: handlerLegacy as TanStackSolidQueryPlugin['LegacyHandler'], 16 15 name: '@tanstack/solid-query', 17 16 output: '@tanstack/solid-query', 18 17 resolveConfig: (plugin, context) => {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/solid-query/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { TanStackSolidQueryPlugin } from './types';
+8 -6
packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config extends Plugin.Name<'@tanstack/solid-query'> { 4 + export type Config = Plugin.Name<'@tanstack/solid-query'> & { 5 5 /** 6 6 * The casing convention to use for generated names. 7 7 * ··· 91 91 enabled?: boolean; 92 92 name?: string | ((name: string) => string); 93 93 }; 94 - } 94 + }; 95 95 96 - export interface ResolvedConfig extends Plugin.Name<'@tanstack/solid-query'> { 96 + export type ResolvedConfig = Plugin.Name<'@tanstack/solid-query'> & { 97 97 /** 98 98 * The casing convention to use for generated names. 99 99 * ··· 168 168 enabled: boolean; 169 169 name: string | ((name: string) => string); 170 170 }; 171 - } 171 + }; 172 + 173 + export type TanStackSolidQueryPlugin = DefinePlugin<Config, ResolvedConfig>;
+4 -5
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from '../query-core/plugin'; 4 3 import { handlerLegacy } from '../query-core/plugin-legacy'; 5 - import type { Config, ResolvedConfig } from './types'; 4 + import type { TanStackSvelteQueryPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: TanStackSvelteQueryPlugin['Config'] = { 8 7 config: { 9 8 case: 'camelCase', 10 9 comments: true, 11 10 exportFromIndex: false, 12 11 }, 13 12 dependencies: ['@hey-api/sdk', '@hey-api/typescript'], 14 - handler, 15 - handlerLegacy, 13 + handler: handler as TanStackSvelteQueryPlugin['Handler'], 14 + handlerLegacy: handlerLegacy as TanStackSvelteQueryPlugin['LegacyHandler'], 16 15 name: '@tanstack/svelte-query', 17 16 output: '@tanstack/svelte-query', 18 17 resolveConfig: (plugin, context) => {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { TanStackSvelteQueryPlugin } from './types';
+8 -6
packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config extends Plugin.Name<'@tanstack/svelte-query'> { 4 + export type Config = Plugin.Name<'@tanstack/svelte-query'> & { 5 5 /** 6 6 * The casing convention to use for generated names. 7 7 * ··· 91 91 enabled?: boolean; 92 92 name?: string | ((name: string) => string); 93 93 }; 94 - } 94 + }; 95 95 96 - export interface ResolvedConfig extends Plugin.Name<'@tanstack/svelte-query'> { 96 + export type ResolvedConfig = Plugin.Name<'@tanstack/svelte-query'> & { 97 97 /** 98 98 * The casing convention to use for generated names. 99 99 * ··· 168 168 enabled: boolean; 169 169 name: string | ((name: string) => string); 170 170 }; 171 - } 171 + }; 172 + 173 + export type TanStackSvelteQueryPlugin = DefinePlugin<Config, ResolvedConfig>;
+4 -5
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 - import type { Plugin } from '../../types'; 3 2 import { handler } from '../query-core/plugin'; 4 3 import { handlerLegacy } from '../query-core/plugin-legacy'; 5 - import type { Config, ResolvedConfig } from './types'; 4 + import type { TanStackVueQueryPlugin } from './types'; 6 5 7 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: TanStackVueQueryPlugin['Config'] = { 8 7 config: { 9 8 case: 'camelCase', 10 9 comments: true, 11 10 exportFromIndex: false, 12 11 }, 13 12 dependencies: ['@hey-api/sdk', '@hey-api/typescript'], 14 - handler, 15 - handlerLegacy, 13 + handler: handler as TanStackVueQueryPlugin['Handler'], 14 + handlerLegacy: handlerLegacy as TanStackVueQueryPlugin['LegacyHandler'], 16 15 name: '@tanstack/vue-query', 17 16 output: '@tanstack/vue-query', 18 17 resolveConfig: (plugin, context) => {
+1 -1
packages/openapi-ts/src/plugins/@tanstack/vue-query/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { TanStackVueQueryPlugin } from './types';
+8 -6
packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts
··· 1 - import type { StringCase } from '../../../types/config'; 2 - import type { Plugin } from '../../types'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../../types'; 3 3 4 - export interface Config extends Plugin.Name<'@tanstack/vue-query'> { 4 + export type Config = Plugin.Name<'@tanstack/vue-query'> & { 5 5 /** 6 6 * The casing convention to use for generated names. 7 7 * ··· 91 91 enabled?: boolean; 92 92 name?: string | ((name: string) => string); 93 93 }; 94 - } 94 + }; 95 95 96 - export interface ResolvedConfig extends Plugin.Name<'@tanstack/vue-query'> { 96 + export type ResolvedConfig = Plugin.Name<'@tanstack/vue-query'> & { 97 97 /** 98 98 * The casing convention to use for generated names. 99 99 * ··· 168 168 enabled: boolean; 169 169 name: string | ((name: string) => string); 170 170 }; 171 - } 171 + }; 172 + 173 + export type TanStackVueQueryPlugin = DefinePlugin<Config, ResolvedConfig>;
+93
packages/openapi-ts/src/plugins/config.ts
··· 1 + import type { HeyApiClientAxiosPlugin } from './@hey-api/client-axios'; 2 + import { defaultConfig as heyApiClientAxios } from './@hey-api/client-axios'; 3 + import type { HeyApiClientFetchPlugin } from './@hey-api/client-fetch'; 4 + import { defaultConfig as heyApiClientFetch } from './@hey-api/client-fetch'; 5 + import type { HeyApiClientNextPlugin } from './@hey-api/client-next'; 6 + import { defaultConfig as heyApiClientNext } from './@hey-api/client-next'; 7 + import type { HeyApiClientNuxtPlugin } from './@hey-api/client-nuxt'; 8 + import { defaultConfig as heyApiClientNuxt } from './@hey-api/client-nuxt'; 9 + import type { HeyApiClientLegacyAngularPlugin } from './@hey-api/legacy-angular'; 10 + import { defaultConfig as heyApiLegacyAngular } from './@hey-api/legacy-angular'; 11 + import type { HeyApiClientLegacyAxiosPlugin } from './@hey-api/legacy-axios'; 12 + import { defaultConfig as heyApiLegacyAxios } from './@hey-api/legacy-axios'; 13 + import type { HeyApiClientLegacyFetchPlugin } from './@hey-api/legacy-fetch'; 14 + import { defaultConfig as heyApiLegacyFetch } from './@hey-api/legacy-fetch'; 15 + import type { HeyApiClientLegacyNodePlugin } from './@hey-api/legacy-node'; 16 + import { defaultConfig as heyApiLegacyNode } from './@hey-api/legacy-node'; 17 + import type { HeyApiClientLegacyXhrPlugin } from './@hey-api/legacy-xhr'; 18 + import { defaultConfig as heyApiLegacyXhr } from './@hey-api/legacy-xhr'; 19 + import type { HeyApiSchemasPlugin } from './@hey-api/schemas'; 20 + import { defaultConfig as heyApiSchemas } from './@hey-api/schemas'; 21 + import type { HeyApiSdkPlugin } from './@hey-api/sdk'; 22 + import { defaultConfig as heyApiSdk } from './@hey-api/sdk'; 23 + import type { HeyApiTransformersPlugin } from './@hey-api/transformers'; 24 + import { defaultConfig as heyApiTransformers } from './@hey-api/transformers'; 25 + import type { HeyApiTypeScriptPlugin } from './@hey-api/typescript'; 26 + import { defaultConfig as heyApiTypeScript } from './@hey-api/typescript'; 27 + import type { TanStackAngularQueryPlugin } from './@tanstack/angular-query-experimental'; 28 + import { defaultConfig as tanStackAngularQuery } from './@tanstack/angular-query-experimental'; 29 + import type { TanStackReactQueryPlugin } from './@tanstack/react-query'; 30 + import { defaultConfig as tanStackReactQuery } from './@tanstack/react-query'; 31 + import type { TanStackSolidQueryPlugin } from './@tanstack/solid-query'; 32 + import { defaultConfig as tanStackSolidQuery } from './@tanstack/solid-query'; 33 + import type { TanStackSvelteQueryPlugin } from './@tanstack/svelte-query'; 34 + import { defaultConfig as tanStackSvelteQuery } from './@tanstack/svelte-query'; 35 + import type { TanStackVueQueryPlugin } from './@tanstack/vue-query'; 36 + import { defaultConfig as tanStackVueQuery } from './@tanstack/vue-query'; 37 + import type { FastifyPlugin } from './fastify'; 38 + import { defaultConfig as fastify } from './fastify'; 39 + import type { Plugin, PluginNames } from './types'; 40 + import type { ValibotPlugin } from './valibot'; 41 + import { defaultConfig as valibot } from './valibot'; 42 + import type { ZodPlugin } from './zod'; 43 + import { defaultConfig as zod } from './zod'; 44 + 45 + export interface PluginConfigMap { 46 + '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types']; 47 + '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types']; 48 + '@hey-api/client-next': HeyApiClientNextPlugin['Types']; 49 + '@hey-api/client-nuxt': HeyApiClientNuxtPlugin['Types']; 50 + '@hey-api/schemas': HeyApiSchemasPlugin['Types']; 51 + '@hey-api/sdk': HeyApiSdkPlugin['Types']; 52 + '@hey-api/transformers': HeyApiTransformersPlugin['Types']; 53 + '@hey-api/typescript': HeyApiTypeScriptPlugin['Types']; 54 + '@tanstack/angular-query-experimental': TanStackAngularQueryPlugin['Types']; 55 + '@tanstack/react-query': TanStackReactQueryPlugin['Types']; 56 + '@tanstack/solid-query': TanStackSolidQueryPlugin['Types']; 57 + '@tanstack/svelte-query': TanStackSvelteQueryPlugin['Types']; 58 + '@tanstack/vue-query': TanStackVueQueryPlugin['Types']; 59 + fastify: FastifyPlugin['Types']; 60 + 'legacy/angular': HeyApiClientLegacyAngularPlugin['Types']; 61 + 'legacy/axios': HeyApiClientLegacyAxiosPlugin['Types']; 62 + 'legacy/fetch': HeyApiClientLegacyFetchPlugin['Types']; 63 + 'legacy/node': HeyApiClientLegacyNodePlugin['Types']; 64 + 'legacy/xhr': HeyApiClientLegacyXhrPlugin['Types']; 65 + valibot: ValibotPlugin['Types']; 66 + zod: ZodPlugin['Types']; 67 + } 68 + 69 + export const defaultPluginConfigs: { 70 + [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>; 71 + } = { 72 + '@hey-api/client-axios': heyApiClientAxios, 73 + '@hey-api/client-fetch': heyApiClientFetch, 74 + '@hey-api/client-next': heyApiClientNext, 75 + '@hey-api/client-nuxt': heyApiClientNuxt, 76 + '@hey-api/schemas': heyApiSchemas, 77 + '@hey-api/sdk': heyApiSdk, 78 + '@hey-api/transformers': heyApiTransformers, 79 + '@hey-api/typescript': heyApiTypeScript, 80 + '@tanstack/angular-query-experimental': tanStackAngularQuery, 81 + '@tanstack/react-query': tanStackReactQuery, 82 + '@tanstack/solid-query': tanStackSolidQuery, 83 + '@tanstack/svelte-query': tanStackSvelteQuery, 84 + '@tanstack/vue-query': tanStackVueQuery, 85 + fastify, 86 + 'legacy/angular': heyApiLegacyAngular, 87 + 'legacy/axios': heyApiLegacyAxios, 88 + 'legacy/fetch': heyApiLegacyFetch, 89 + 'legacy/node': heyApiLegacyNode, 90 + 'legacy/xhr': heyApiLegacyXhr, 91 + valibot, 92 + zod, 93 + };
+2 -4
packages/openapi-ts/src/plugins/fastify/config.ts
··· 1 1 import { definePluginConfig } from '../shared/utils/config'; 2 - import type { Plugin } from '../types'; 3 2 import { handler } from './plugin'; 4 - import type { Config } from './types'; 3 + import type { FastifyPlugin } from './types'; 5 4 6 - export const defaultConfig: Plugin.Config<Config> = { 5 + export const defaultConfig: FastifyPlugin['Config'] = { 7 6 config: { 8 7 exportFromIndex: false, 9 8 }, 10 9 dependencies: ['@hey-api/typescript'], 11 10 handler, 12 - handlerLegacy: () => {}, 13 11 name: 'fastify', 14 12 output: 'fastify', 15 13 };
+1 -1
packages/openapi-ts/src/plugins/fastify/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { FastifyPlugin } from './types';
+2 -3
packages/openapi-ts/src/plugins/fastify/plugin.ts
··· 6 6 import type { IR } from '../../ir/types'; 7 7 import { typesId } from '../@hey-api/typescript/ref'; 8 8 import { operationIrRef } from '../shared/utils/ref'; 9 - import type { Plugin } from '../types'; 10 - import type { Config } from './types'; 9 + import type { FastifyPlugin } from './types'; 11 10 12 11 const fastifyId = 'fastify'; 13 12 ··· 207 206 return routeHandler; 208 207 }; 209 208 210 - export const handler: Plugin.Handler<Config> = ({ plugin }) => { 209 + export const handler: FastifyPlugin['Handler'] = ({ plugin }) => { 211 210 const file = plugin.createFile({ 212 211 id: fastifyId, 213 212 path: plugin.output,
+5 -3
packages/openapi-ts/src/plugins/fastify/types.d.ts
··· 1 - import type { Plugin } from '../types'; 1 + import type { DefinePlugin, Plugin } from '../types'; 2 2 3 - export interface Config extends Plugin.Name<'fastify'> { 3 + export type Config = Plugin.Name<'fastify'> & { 4 4 /** 5 5 * Should the exports from the generated files be re-exported in the index 6 6 * barrel file? ··· 14 14 * @default 'fastify' 15 15 */ 16 16 output?: string; 17 - } 17 + }; 18 + 19 + export type FastifyPlugin = DefinePlugin<Config>;
-154
packages/openapi-ts/src/plugins/index.ts
··· 1 - import { 2 - type Config as HeyApiClientAxios, 3 - defaultConfig as heyApiClientAxios, 4 - } from './@hey-api/client-axios'; 5 - import { 6 - type Config as HeyApiClientFetch, 7 - defaultConfig as heyApiClientFetch, 8 - } from './@hey-api/client-fetch'; 9 - import { 10 - type Config as HeyApiClientNext, 11 - defaultConfig as heyApiClientNext, 12 - } from './@hey-api/client-next'; 13 - import { 14 - type Config as HeyApiClientNuxt, 15 - defaultConfig as heyApiClientNuxt, 16 - } from './@hey-api/client-nuxt'; 17 - import { 18 - type Config as HeyApiLegacyAngular, 19 - defaultConfig as heyApiLegacyAngular, 20 - } from './@hey-api/legacy-angular'; 21 - import { 22 - type Config as HeyApiLegacyAxios, 23 - defaultConfig as heyApiLegacyAxios, 24 - } from './@hey-api/legacy-axios'; 25 - import { 26 - type Config as HeyApiLegacyFetch, 27 - defaultConfig as heyApiLegacyFetch, 28 - } from './@hey-api/legacy-fetch'; 29 - import { 30 - type Config as HeyApiLegacyNode, 31 - defaultConfig as heyApiLegacyNode, 32 - } from './@hey-api/legacy-node'; 33 - import { 34 - type Config as HeyApiLegacyXhr, 35 - defaultConfig as heyApiLegacyXhr, 36 - } from './@hey-api/legacy-xhr'; 37 - import { 38 - type Config as HeyApiSchemas, 39 - defaultConfig as heyApiSchemas, 40 - } from './@hey-api/schemas'; 41 - import { 42 - type Config as HeyApiSdk, 43 - defaultConfig as heyApiSdk, 44 - } from './@hey-api/sdk'; 45 - import { 46 - type Config as HeyApiTransformers, 47 - defaultConfig as heyApiTransformers, 48 - } from './@hey-api/transformers'; 49 - import { 50 - type Config as HeyApiTypeScript, 51 - defaultConfig as heyApiTypeScript, 52 - } from './@hey-api/typescript'; 53 - import { 54 - type Config as TanStackAngularQueryExperimental, 55 - defaultConfig as tanStackAngularQueryExperimental, 56 - } from './@tanstack/angular-query-experimental'; 57 - import { 58 - type Config as TanStackReactQuery, 59 - defaultConfig as tanStackReactQuery, 60 - } from './@tanstack/react-query'; 61 - import { 62 - type Config as TanStackSolidQuery, 63 - defaultConfig as tanStackSolidQuery, 64 - } from './@tanstack/solid-query'; 65 - import { 66 - type Config as TanStackSvelteQuery, 67 - defaultConfig as tanStackSvelteQuery, 68 - } from './@tanstack/svelte-query'; 69 - import { 70 - type Config as TanStackVueQuery, 71 - defaultConfig as tanStackVueQuery, 72 - } from './@tanstack/vue-query'; 73 - import { type Config as Fastify, defaultConfig as fastify } from './fastify'; 74 - import type { Plugin, PluginNames } from './types'; 75 - import { type Config as Valibot, defaultConfig as valibot } from './valibot'; 76 - import { type Config as Zod, defaultConfig as zod } from './zod'; 77 - 78 - /** 79 - * User-facing plugin types. 80 - */ 81 - export type UserPlugins = 82 - | Plugin.UserConfig<HeyApiClientAxios> 83 - | Plugin.UserConfig<HeyApiClientFetch> 84 - | Plugin.UserConfig<HeyApiClientNext> 85 - | Plugin.UserConfig<HeyApiClientNuxt> 86 - | Plugin.UserConfig<HeyApiLegacyAngular> 87 - | Plugin.UserConfig<HeyApiLegacyAxios> 88 - | Plugin.UserConfig<HeyApiLegacyFetch> 89 - | Plugin.UserConfig<HeyApiLegacyNode> 90 - | Plugin.UserConfig<HeyApiLegacyXhr> 91 - | Plugin.UserConfig<HeyApiSchemas> 92 - | Plugin.UserConfig<HeyApiSdk> 93 - | Plugin.UserConfig<HeyApiTransformers> 94 - | Plugin.UserConfig<HeyApiTypeScript> 95 - | Plugin.UserConfig<TanStackAngularQueryExperimental> 96 - | Plugin.UserConfig<TanStackReactQuery> 97 - | Plugin.UserConfig<TanStackSolidQuery> 98 - | Plugin.UserConfig<TanStackSvelteQuery> 99 - | Plugin.UserConfig<TanStackVueQuery> 100 - | Plugin.UserConfig<Fastify> 101 - | Plugin.UserConfig<Valibot> 102 - | Plugin.UserConfig<Zod>; 103 - 104 - /** 105 - * Internal plugin types. 106 - */ 107 - export type ClientPlugins = 108 - | Plugin.Config<HeyApiClientAxios> 109 - | Plugin.Config<HeyApiClientFetch> 110 - | Plugin.Config<HeyApiClientNext> 111 - | Plugin.Config<HeyApiClientNuxt> 112 - | Plugin.Config<HeyApiLegacyAngular> 113 - | Plugin.Config<HeyApiLegacyAxios> 114 - | Plugin.Config<HeyApiLegacyFetch> 115 - | Plugin.Config<HeyApiLegacyNode> 116 - | Plugin.Config<HeyApiLegacyXhr> 117 - | Plugin.Config<HeyApiSchemas> 118 - | Plugin.Config<HeyApiSdk> 119 - | Plugin.Config<HeyApiTransformers> 120 - | Plugin.Config<HeyApiTypeScript> 121 - | Plugin.Config<TanStackAngularQueryExperimental> 122 - | Plugin.Config<TanStackReactQuery> 123 - | Plugin.Config<TanStackSolidQuery> 124 - | Plugin.Config<TanStackSvelteQuery> 125 - | Plugin.Config<TanStackVueQuery> 126 - | Plugin.Config<Fastify> 127 - | Plugin.Config<Valibot> 128 - | Plugin.Config<Zod>; 129 - 130 - export const defaultPluginConfigs: { 131 - [K in PluginNames]: any; 132 - } = { 133 - '@hey-api/client-axios': heyApiClientAxios, 134 - '@hey-api/client-fetch': heyApiClientFetch, 135 - '@hey-api/client-next': heyApiClientNext, 136 - '@hey-api/client-nuxt': heyApiClientNuxt, 137 - '@hey-api/schemas': heyApiSchemas, 138 - '@hey-api/sdk': heyApiSdk, 139 - '@hey-api/transformers': heyApiTransformers, 140 - '@hey-api/typescript': heyApiTypeScript, 141 - '@tanstack/angular-query-experimental': tanStackAngularQueryExperimental, 142 - '@tanstack/react-query': tanStackReactQuery, 143 - '@tanstack/solid-query': tanStackSolidQuery, 144 - '@tanstack/svelte-query': tanStackSvelteQuery, 145 - '@tanstack/vue-query': tanStackVueQuery, 146 - fastify, 147 - 'legacy/angular': heyApiLegacyAngular, 148 - 'legacy/axios': heyApiLegacyAxios, 149 - 'legacy/fetch': heyApiLegacyFetch, 150 - 'legacy/node': heyApiLegacyNode, 151 - 'legacy/xhr': heyApiLegacyXhr, 152 - valibot, 153 - zod, 154 - };
+4 -6
packages/openapi-ts/src/plugins/shared/utils/config.ts
··· 1 - import type { BaseConfig, Plugin } from '../../types'; 1 + import type { Plugin } from '../../types'; 2 2 3 3 export const definePluginConfig = 4 - <Config extends BaseConfig, ResolvedConfig extends BaseConfig = Config>( 5 - defaultConfig: Plugin.Config<Config, ResolvedConfig>, 6 - ) => 4 + <T extends Plugin.Types>(defaultConfig: Plugin.Config<T>) => 7 5 ( 8 - userConfig?: Omit<Plugin.UserConfig<Config>, 'name'>, 9 - ): Omit<Plugin.Config<Config, ResolvedConfig>, 'name'> & { 6 + userConfig?: Omit<Plugin.UserConfig<T['config']>, 'name'>, 7 + ): Omit<Plugin.Config<T>, 'name'> & { 10 8 /** 11 9 * Cast name to `any` so it doesn't throw type error in `plugins` array. 12 10 * We could allow any `string` as plugin `name` in the object syntax, but
+20 -18
packages/openapi-ts/src/plugins/shared/utils/instance.ts
··· 1 1 import { HeyApiError } from '../../../error'; 2 2 import type { IR } from '../../../ir/types'; 3 3 import type { OpenApi } from '../../../openApi/types'; 4 - import type { Config } from '../../../types/config'; 5 - import type { BaseConfig, Plugin } from '../../types'; 4 + import type { PluginConfigMap } from '../../config'; 5 + import type { Plugin } from '../../types'; 6 6 import type { WalkEvent, WalkEventType } from '../types/instance'; 7 7 8 - export class PluginInstance<PluginConfig extends BaseConfig = BaseConfig> { 9 - public config: Plugin.Config<PluginConfig>['config']; 8 + export class PluginInstance<T extends Plugin.Types = Plugin.Types> { 9 + public api: T['api']; 10 + public config: Omit<T['resolvedConfig'], 'name' | 'output'>; 10 11 public context: IR.Context; 11 - public dependencies: Required<Plugin.Config<PluginConfig>>['dependencies'] = 12 - []; 13 - private handler: Plugin.Config<PluginConfig>['handler']; 14 - public name: Plugin.Config<PluginConfig>['name']; 15 - public output: Required<PluginConfig>['output']; 12 + public dependencies: Required<Plugin.Config<T>>['dependencies'] = []; 13 + private handler: Plugin.Config<T>['handler']; 14 + public name: T['resolvedConfig']['name']; 15 + public output: Required<T['config']>['output']; 16 16 17 17 public constructor( 18 18 props: Pick< 19 - Required<Plugin.Config<PluginConfig>>, 19 + Required<Plugin.Config<T>>, 20 20 'config' | 'dependencies' | 'handler' 21 - > & 22 - Pick<Required<PluginConfig>, 'output'> & { 23 - context: IR.Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>; 24 - name: string; 25 - }, 21 + > & { 22 + api?: T['api']; 23 + context: IR.Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>; 24 + name: string; 25 + output: string; 26 + }, 26 27 ) { 28 + this.api = props.api ?? {}; 27 29 this.config = props.config; 28 30 this.context = props.context; 29 31 this.dependencies = props.dependencies; ··· 185 187 * @param name Plugin name as defined in the configuration. 186 188 * @returns The plugin instance if found, undefined otherwise. 187 189 */ 188 - public getPlugin<T extends keyof Config['plugins']>( 190 + public getPlugin<T extends keyof PluginConfigMap>( 189 191 name: T, 190 - ): IR.Context['plugins'][T] { 191 - return this.context.plugins[name]; 192 + ): T extends any ? PluginInstance<PluginConfigMap[T]> | undefined : never { 193 + return this.context.plugins[name] as any; 192 194 } 193 195 194 196 /**
+2 -1
packages/openapi-ts/src/plugins/shared/utils/ref.ts
··· 1 - import type { Config, StringCase } from '../../../types/config'; 1 + import type { StringCase } from '../../../types/case'; 2 + import type { Config } from '../../../types/config'; 2 3 import { irRef } from '../../../utils/ref'; 3 4 import { stringCase } from '../../../utils/stringCase'; 4 5
+67 -65
packages/openapi-ts/src/plugins/types.d.ts
··· 68 68 }) => ObjectType<T>; 69 69 } 70 70 71 - export interface BaseConfig { 71 + type BaseApi = Record<string, unknown>; 72 + 73 + type BaseConfig = { 72 74 /** 73 75 * Should the exports from the plugin's file be re-exported in the index 74 76 * barrel file? ··· 76 78 exportFromIndex?: boolean; 77 79 name: AnyPluginName; 78 80 output?: string; 79 - } 80 - 81 - interface Meta< 82 - Config extends BaseConfig, 83 - ResolvedConfig extends BaseConfig = Config, 84 - > { 85 - /** 86 - * Dependency plugins will be always processed, regardless of whether user 87 - * explicitly defines them in their `plugins` config. 88 - */ 89 - dependencies?: ReadonlyArray<AnyPluginName>; 90 - /** 91 - * Resolves static configuration values into their runtime equivalents. For 92 - * example, when `validator` is set to `true`, it figures out which plugin 93 - * should be used for validation. 94 - */ 95 - resolveConfig?: ( 96 - plugin: Omit<Plugin.Config<Config, ResolvedConfig>, 'dependencies'> & { 97 - dependencies: Set<AnyPluginName>; 98 - }, 99 - context: PluginContext, 100 - ) => void; 101 - /** 102 - * Optional tags can be used to help with deciding plugin order and resolving 103 - * plugin configuration options. 104 - */ 105 - tags?: ReadonlyArray<PluginTag>; 106 - } 81 + }; 107 82 108 83 /** 109 84 * Public Plugin API. 110 85 */ 111 86 export namespace Plugin { 112 - export type Config< 113 - Config extends BaseConfig, 114 - ResolvedConfig extends BaseConfig = Config, 115 - > = Pick<Config, 'name' | 'output'> & 116 - Meta<Config, ResolvedConfig> & { 117 - config: Omit<Config, 'name' | 'output'>; 118 - handler: Plugin.Handler< 119 - Omit<ResolvedConfig, 'name'> & { 120 - name: any; 121 - } 122 - >; 123 - handlerLegacy: Plugin.LegacyHandler< 124 - Omit<ResolvedConfig, 'name'> & { 125 - name: any; 126 - } 127 - >; 128 - }; 87 + export type Config<T extends Types> = Pick<T, 'api'> & { 88 + config: Omit<T['config'], 'name' | 'output'>; 89 + /** 90 + * Dependency plugins will be always processed, regardless of whether user 91 + * explicitly defines them in their `plugins` config. 92 + */ 93 + dependencies?: ReadonlyArray<AnyPluginName>; 94 + handler: Handler<T>; 95 + handlerLegacy?: LegacyHandler<T>; 96 + name: T['config']['name']; 97 + output: NonNullable<T['config']['output']>; 98 + /** 99 + * Resolves static configuration values into their runtime equivalents. For 100 + * example, when `validator` is set to `true`, it figures out which plugin 101 + * should be used for validation. 102 + */ 103 + resolveConfig?: ( 104 + plugin: Omit<Plugin.Config<T>, 'dependencies'> & { 105 + dependencies: Set<AnyPluginName>; 106 + }, 107 + context: PluginContext, 108 + ) => void; 109 + /** 110 + * Optional tags can be used to help with deciding plugin order and resolving 111 + * plugin configuration options. 112 + */ 113 + tags?: ReadonlyArray<PluginTag>; 114 + }; 115 + 116 + export type ConfigWithName<T extends Types> = Omit<Config<T>, 'config'> & { 117 + config: Omit<T['config'], 'output'>; 118 + }; 129 119 130 120 /** @deprecated - use `definePluginConfig()` instead */ 131 121 export type DefineConfig< 132 122 Config extends BaseConfig, 133 123 ResolvedConfig extends BaseConfig = Config, 134 - > = (config?: Plugin.UserConfig<Omit<Config, 'name'>>) => Omit< 124 + > = (config?: UserConfig<Omit<Config, 'name'>>) => Omit< 135 125 Plugin.Config<Config, ResolvedConfig>, 136 126 'name' 137 127 > & { ··· 144 134 name: any; 145 135 }; 146 136 137 + export interface Name<Name extends PluginNames> { 138 + name: Name; 139 + } 140 + 141 + export type Types< 142 + Config extends BaseConfig = BaseConfig, 143 + ResolvedConfig extends BaseConfig = Config, 144 + Api extends BaseApi = never, 145 + > = ([Api] extends [never] ? { api?: BaseApi } : { api: Api }) & { 146 + config: Config; 147 + resolvedConfig: ResolvedConfig; 148 + }; 149 + 147 150 /** 148 - * Plugin implementation for experimental parser. 151 + * Users cannot modify output file path to avoid risk of conflicts. 149 152 */ 150 - export type Handler<Config extends BaseConfig, ReturnType = void> = (args: { 151 - plugin: Plugin.Instance<Config>; 152 - }) => ReturnType; 153 + export type UserConfig<Config extends BaseConfig> = Omit<Config, 'output'>; 154 + } 153 155 154 - export type Instance<Config extends BaseConfig> = PluginInstance<Config>; 155 - 156 + export type DefinePlugin< 157 + Config extends BaseConfig = BaseConfig, 158 + ResolvedConfig extends BaseConfig = Config, 159 + Api extends BaseApi = never, 160 + > = { 161 + Config: Plugin.Config<Plugin.Types<Config, ResolvedConfig, Api>>; 162 + Handler: (args: { 163 + plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>; 164 + }) => void; 165 + Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>; 156 166 /** 157 167 * Plugin implementation for legacy parser. 158 168 * 159 169 * @deprecated 160 170 */ 161 - export type LegacyHandler<Config extends BaseConfig> = (args: { 171 + LegacyHandler: (args: { 162 172 client: LegacyClient; 163 173 files: Files; 164 174 openApi: LegacyOpenApi; 165 - plugin: Plugin.Instance<Config>; 175 + plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>; 166 176 }) => void; 167 - 168 - export interface Name<Name extends PluginNames> { 169 - name: Name; 170 - } 171 - 172 - /** 173 - * Users cannot modify output file path to avoid risk of conflicts. 174 - */ 175 - export type UserConfig<Config extends BaseConfig> = Omit<Config, 'output'>; 176 - } 177 + Types: Plugin.Types<Config, ResolvedConfig, Api>; 178 + };
+153
packages/openapi-ts/src/plugins/valibot/api.ts
··· 1 + import type ts from 'typescript'; 2 + 3 + import { compiler } from '../../compiler'; 4 + import type { TypeScriptFile } from '../../generate/files'; 5 + import type { IR } from '../../ir/types'; 6 + import { identifiers, valibotId } from './constants'; 7 + import type { ValibotPlugin } from './types'; 8 + 9 + const createRequestValidator = ({ 10 + file, 11 + operation, 12 + plugin, 13 + }: { 14 + file: TypeScriptFile; 15 + operation: IR.OperationObject; 16 + plugin: ValibotPlugin['Instance']; 17 + }): ts.ArrowFunction | undefined => { 18 + const { requests } = plugin.config; 19 + const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ 20 + // TODO: refactor for better cross-plugin compatibility 21 + $ref: `#/valibot-response/${operation.id}`, 22 + // TODO: refactor to not have to define nameTransformer 23 + nameTransformer: typeof requests === 'object' ? requests.name : undefined, 24 + namespace: 'value', 25 + }); 26 + 27 + if (!schemaIdentifier.name) { 28 + return; 29 + } 30 + 31 + file.import({ 32 + module: file.relativePathToFile({ 33 + context: plugin.context, 34 + id: valibotId, 35 + }), 36 + name: schemaIdentifier.name, 37 + }); 38 + 39 + file.import({ 40 + alias: identifiers.v.text, 41 + module: 'valibot', 42 + name: '*', 43 + }); 44 + 45 + const dataParameterName = 'data'; 46 + 47 + return compiler.arrowFunction({ 48 + async: true, 49 + parameters: [ 50 + { 51 + name: dataParameterName, 52 + }, 53 + ], 54 + statements: [ 55 + compiler.returnStatement({ 56 + expression: compiler.awaitExpression({ 57 + expression: compiler.callExpression({ 58 + functionName: compiler.propertyAccessExpression({ 59 + expression: identifiers.v, 60 + name: identifiers.async.parseAsync, 61 + }), 62 + parameters: [ 63 + compiler.identifier({ text: schemaIdentifier.name }), 64 + compiler.identifier({ text: dataParameterName }), 65 + ], 66 + }), 67 + }), 68 + }), 69 + ], 70 + }); 71 + }; 72 + 73 + const createResponseValidator = ({ 74 + file, 75 + operation, 76 + plugin, 77 + }: { 78 + file: TypeScriptFile; 79 + operation: IR.OperationObject; 80 + plugin: ValibotPlugin['Instance']; 81 + }): ts.ArrowFunction | undefined => { 82 + const { responses } = plugin.config; 83 + const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ 84 + // TODO: refactor for better cross-plugin compatibility 85 + $ref: `#/valibot-response/${operation.id}`, 86 + // TODO: refactor to not have to define nameTransformer 87 + nameTransformer: typeof responses === 'object' ? responses.name : undefined, 88 + namespace: 'value', 89 + }); 90 + 91 + if (!schemaIdentifier.name) { 92 + return; 93 + } 94 + 95 + file.import({ 96 + module: file.relativePathToFile({ 97 + context: plugin.context, 98 + id: valibotId, 99 + }), 100 + name: schemaIdentifier.name, 101 + }); 102 + 103 + file.import({ 104 + alias: identifiers.v.text, 105 + module: 'valibot', 106 + name: '*', 107 + }); 108 + 109 + const dataParameterName = 'data'; 110 + 111 + return compiler.arrowFunction({ 112 + async: true, 113 + parameters: [ 114 + { 115 + name: dataParameterName, 116 + }, 117 + ], 118 + statements: [ 119 + compiler.returnStatement({ 120 + expression: compiler.awaitExpression({ 121 + expression: compiler.callExpression({ 122 + functionName: compiler.propertyAccessExpression({ 123 + expression: identifiers.v, 124 + name: identifiers.async.parseAsync, 125 + }), 126 + parameters: [ 127 + compiler.identifier({ text: schemaIdentifier.name }), 128 + compiler.identifier({ text: dataParameterName }), 129 + ], 130 + }), 131 + }), 132 + }), 133 + ], 134 + }); 135 + }; 136 + 137 + export type Api = { 138 + createRequestValidator: (args: { 139 + file: TypeScriptFile; 140 + operation: IR.OperationObject; 141 + plugin: ValibotPlugin['Instance']; 142 + }) => ts.ArrowFunction | undefined; 143 + createResponseValidator: (args: { 144 + file: TypeScriptFile; 145 + operation: IR.OperationObject; 146 + plugin: ValibotPlugin['Instance']; 147 + }) => ts.ArrowFunction | undefined; 148 + }; 149 + 150 + export const api: Api = { 151 + createRequestValidator, 152 + createResponseValidator, 153 + };
+4 -4
packages/openapi-ts/src/plugins/valibot/config.ts
··· 1 1 import { definePluginConfig } from '../shared/utils/config'; 2 - import type { Plugin } from '../types'; 2 + import { api } from './api'; 3 3 import { handler } from './plugin'; 4 - import type { Config, ResolvedConfig } from './types'; 4 + import type { ValibotPlugin } from './types'; 5 5 6 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: ValibotPlugin['Config'] = { 7 + api, 7 8 config: { 8 9 case: 'camelCase', 9 10 comments: true, ··· 11 12 metadata: false, 12 13 }, 13 14 handler, 14 - handlerLegacy: () => {}, 15 15 name: 'valibot', 16 16 output: 'valibot', 17 17 resolveConfig: (plugin, context) => {
+45 -1
packages/openapi-ts/src/plugins/valibot/constants.ts
··· 116 116 * {@link https://valibot.dev/api/#async Async} 117 117 */ 118 118 async: { 119 - // TODO: implement if necessary 119 + argsAsync: compiler.identifier({ text: 'argsAsync' }), 120 + arrayAsync: compiler.identifier({ text: 'arrayAsync' }), 121 + awaitAsync: compiler.identifier({ text: 'awaitAsync' }), 122 + checkAsync: compiler.identifier({ text: 'checkAsync' }), 123 + checkItemsAsync: compiler.identifier({ text: 'checkItemsAsync' }), 124 + customAsync: compiler.identifier({ text: 'customAsync' }), 125 + exactOptionalAsync: compiler.identifier({ text: 'exactOptionalAsync' }), 126 + fallbackAsync: compiler.identifier({ text: 'fallbackAsync' }), 127 + forwardAsync: compiler.identifier({ text: 'forwardAsync' }), 128 + getDefaultsAsync: compiler.identifier({ text: 'getDefaultsAsync' }), 129 + getFallbacksAsync: compiler.identifier({ text: 'getFallbacksAsync' }), 130 + intersectAsync: compiler.identifier({ text: 'intersectAsync' }), 131 + lazyAsync: compiler.identifier({ text: 'lazyAsync' }), 132 + looseObjectAsync: compiler.identifier({ text: 'looseObjectAsync' }), 133 + looseTupleAsync: compiler.identifier({ text: 'looseTupleAsync' }), 134 + mapAsync: compiler.identifier({ text: 'mapAsync' }), 135 + nonNullableAsync: compiler.identifier({ text: 'nonNullableAsync' }), 136 + nonNullishAsync: compiler.identifier({ text: 'nonNullishAsync' }), 137 + nonOptionalAsync: compiler.identifier({ text: 'nonOptionalAsync' }), 138 + nullableAsync: compiler.identifier({ text: 'nullableAsync' }), 139 + nullishAsync: compiler.identifier({ text: 'nullishAsync' }), 140 + objectAsync: compiler.identifier({ text: 'objectAsync' }), 141 + objectWithRestAsync: compiler.identifier({ text: 'objectWithRestAsync' }), 142 + optionalAsync: compiler.identifier({ text: 'optionalAsync' }), 143 + parseAsync: compiler.identifier({ text: 'parseAsync' }), 144 + parserAsync: compiler.identifier({ text: 'parserAsync' }), 145 + partialAsync: compiler.identifier({ text: 'partialAsync' }), 146 + partialCheckAsync: compiler.identifier({ text: 'partialCheckAsync' }), 147 + pipeAsync: compiler.identifier({ text: 'pipeAsync' }), 148 + rawCheckAsync: compiler.identifier({ text: 'rawCheckAsync' }), 149 + rawTransformAsync: compiler.identifier({ text: 'rawTransformAsync' }), 150 + recordAsync: compiler.identifier({ text: 'recordAsync' }), 151 + requiredAsync: compiler.identifier({ text: 'requiredAsync' }), 152 + returnsAsync: compiler.identifier({ text: 'returnsAsync' }), 153 + safeParseAsync: compiler.identifier({ text: 'safeParseAsync' }), 154 + safeParserAsync: compiler.identifier({ text: 'safeParserAsync' }), 155 + setAsync: compiler.identifier({ text: 'setAsync' }), 156 + strictObjectAsync: compiler.identifier({ text: 'strictObjectAsync' }), 157 + strictTupleAsync: compiler.identifier({ text: 'strictTupleAsync' }), 158 + transformAsync: compiler.identifier({ text: 'transformAsync' }), 159 + tupleAsync: compiler.identifier({ text: 'tupleAsync' }), 160 + tupleWithRestAsync: compiler.identifier({ text: 'tupleWithRestAsync' }), 161 + undefinedableAsync: compiler.identifier({ text: 'undefinedableAsync' }), 162 + unionAsync: compiler.identifier({ text: 'unionAsync' }), 163 + variantAsync: compiler.identifier({ text: 'variantAsync' }), 120 164 }, 121 165 /** 122 166 * {@link https://valibot.dev/api/#methods Methods}
+1 -1
packages/openapi-ts/src/plugins/valibot/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { ValibotPlugin } from './types';
+158
packages/openapi-ts/src/plugins/valibot/operation.ts
··· 1 + import { operationResponsesMap } from '../../ir/operation'; 2 + import type { IR } from '../../ir/types'; 3 + import { valibotId } from './constants'; 4 + import { schemaToValibotSchema, type State } from './plugin'; 5 + import type { ValibotPlugin } from './types'; 6 + 7 + export const operationToValibotSchema = ({ 8 + operation, 9 + plugin, 10 + state, 11 + }: { 12 + operation: IR.OperationObject; 13 + plugin: ValibotPlugin['Instance']; 14 + state: State; 15 + }) => { 16 + const file = plugin.context.file({ id: valibotId })!; 17 + 18 + if (plugin.config.requests.enabled) { 19 + const requiredProperties = new Set<string>(); 20 + 21 + const schemaData: IR.SchemaObject = { 22 + properties: { 23 + body: { 24 + type: 'never', 25 + }, 26 + path: { 27 + type: 'never', 28 + }, 29 + query: { 30 + type: 'never', 31 + }, 32 + }, 33 + type: 'object', 34 + }; 35 + 36 + if (operation.parameters) { 37 + // TODO: add support for cookies 38 + 39 + if (operation.parameters.header) { 40 + const properties: Record<string, IR.SchemaObject> = {}; 41 + const required: Array<string> = []; 42 + 43 + for (const key in operation.parameters.header) { 44 + const parameter = operation.parameters.header[key]!; 45 + properties[parameter.name] = parameter.schema; 46 + if (parameter.required) { 47 + required.push(parameter.name); 48 + requiredProperties.add('headers'); 49 + } 50 + } 51 + 52 + if (Object.keys(properties).length) { 53 + schemaData.properties!.headers = { 54 + properties, 55 + required, 56 + type: 'object', 57 + }; 58 + } 59 + } 60 + 61 + if (operation.parameters.path) { 62 + const properties: Record<string, IR.SchemaObject> = {}; 63 + const required: Array<string> = []; 64 + 65 + for (const key in operation.parameters.path) { 66 + const parameter = operation.parameters.path[key]!; 67 + properties[parameter.name] = parameter.schema; 68 + if (parameter.required) { 69 + required.push(parameter.name); 70 + requiredProperties.add('path'); 71 + } 72 + } 73 + 74 + if (Object.keys(properties).length) { 75 + schemaData.properties!.path = { 76 + properties, 77 + required, 78 + type: 'object', 79 + }; 80 + } 81 + } 82 + 83 + if (operation.parameters.query) { 84 + const properties: Record<string, IR.SchemaObject> = {}; 85 + const required: Array<string> = []; 86 + 87 + for (const key in operation.parameters.query) { 88 + const parameter = operation.parameters.query[key]!; 89 + properties[parameter.name] = parameter.schema; 90 + if (parameter.required) { 91 + required.push(parameter.name); 92 + requiredProperties.add('query'); 93 + } 94 + } 95 + 96 + if (Object.keys(properties).length) { 97 + schemaData.properties!.query = { 98 + properties, 99 + required, 100 + type: 'object', 101 + }; 102 + } 103 + } 104 + } 105 + 106 + if (operation.body) { 107 + schemaData.properties!.body = operation.body.schema; 108 + 109 + if (operation.body.required) { 110 + requiredProperties.add('body'); 111 + } 112 + } 113 + 114 + schemaData.required = [...requiredProperties]; 115 + 116 + const identifierData = file.identifier({ 117 + // TODO: refactor for better cross-plugin compatibility 118 + $ref: `#/valibot-data/${operation.id}`, 119 + case: plugin.config.requests.case, 120 + create: true, 121 + nameTransformer: plugin.config.requests.name, 122 + namespace: 'value', 123 + }); 124 + schemaToValibotSchema({ 125 + // TODO: refactor for better cross-plugin compatibility 126 + $ref: `#/valibot-data/${operation.id}`, 127 + identifier: identifierData, 128 + plugin, 129 + schema: schemaData, 130 + state, 131 + }); 132 + } 133 + 134 + if (plugin.config.responses.enabled) { 135 + if (operation.responses) { 136 + const { response } = operationResponsesMap(operation); 137 + 138 + if (response) { 139 + const identifierResponse = file.identifier({ 140 + // TODO: refactor for better cross-plugin compatibility 141 + $ref: `#/valibot-response/${operation.id}`, 142 + case: plugin.config.responses.case, 143 + create: true, 144 + nameTransformer: plugin.config.responses.name, 145 + namespace: 'value', 146 + }); 147 + schemaToValibotSchema({ 148 + // TODO: refactor for better cross-plugin compatibility 149 + $ref: `#/valibot-response/${operation.id}`, 150 + identifier: identifierResponse, 151 + plugin, 152 + schema: response, 153 + state, 154 + }); 155 + } 156 + } 157 + } 158 + };
+11 -164
packages/openapi-ts/src/plugins/valibot/plugin.ts
··· 2 2 3 3 import { compiler } from '../../compiler'; 4 4 import type { Identifier } from '../../generate/files'; 5 - import { operationResponsesMap } from '../../ir/operation'; 6 - import { hasParameterGroupObjectRequired } from '../../ir/parameter'; 7 5 import { deduplicateSchema } from '../../ir/schema'; 8 6 import type { IR } from '../../ir/types'; 9 - import type { StringCase } from '../../types/config'; 7 + import type { StringCase } from '../../types/case'; 10 8 import { numberRegExp } from '../../utils/regexp'; 11 9 import { createSchemaComment } from '../shared/utils/schema'; 12 - import type { Plugin } from '../types'; 13 10 import { identifiers, valibotId } from './constants'; 14 - import type { ResolvedConfig } from './types'; 11 + import { operationToValibotSchema } from './operation'; 12 + import type { ValibotPlugin } from './types'; 15 13 16 14 interface SchemaWithType<T extends Required<IR.SchemaObject>['type']> 17 15 extends Omit<IR.SchemaObject, 'type'> { 18 16 type: Extract<Required<IR.SchemaObject>['type'], T>; 19 17 } 20 18 21 - interface State { 19 + export interface State { 22 20 circularReferenceTracker: Set<string>; 23 21 hasCircularReference: boolean; 24 22 nameCase: StringCase; ··· 45 43 schema, 46 44 state, 47 45 }: { 48 - plugin: Plugin.Instance<ResolvedConfig>; 46 + plugin: ValibotPlugin['Instance']; 49 47 schema: SchemaWithType<'array'>; 50 48 state: State; 51 49 }): ts.CallExpression => { ··· 371 369 schema, 372 370 state, 373 371 }: { 374 - plugin: Plugin.Instance<ResolvedConfig>; 372 + plugin: ValibotPlugin['Instance']; 375 373 schema: SchemaWithType<'object'>; 376 374 state: State; 377 375 }): { ··· 603 601 schema, 604 602 state, 605 603 }: { 606 - plugin: Plugin.Instance<ResolvedConfig>; 604 + plugin: ValibotPlugin['Instance']; 607 605 schema: SchemaWithType<'tuple'>; 608 606 state: State; 609 607 }) => { ··· 705 703 schema, 706 704 state, 707 705 }: { 708 - plugin: Plugin.Instance<ResolvedConfig>; 706 + plugin: ValibotPlugin['Instance']; 709 707 schema: IR.SchemaObject; 710 708 state: State; 711 709 }): { ··· 793 791 } 794 792 }; 795 793 796 - const operationToValibotSchema = ({ 797 - operation, 798 - plugin, 799 - state, 800 - }: { 801 - operation: IR.OperationObject; 802 - plugin: Plugin.Instance<ResolvedConfig>; 803 - state: State; 804 - }) => { 805 - const file = plugin.context.file({ id: valibotId })!; 806 - 807 - if (plugin.config.requests.enabled) { 808 - const requiredProperties: Array<string> = []; 809 - if (operation.body?.required) { 810 - requiredProperties.push('body'); 811 - } 812 - 813 - const headersPropertyProperties: Record<string, IR.SchemaObject> = {}; 814 - const headersPropertyRequired: Array<string> = []; 815 - const pathPropertyProperties: Record<string, IR.SchemaObject> = {}; 816 - const pathPropertyRequired: Array<string> = []; 817 - const queryPropertyProperties: Record<string, IR.SchemaObject> = {}; 818 - const queryPropertyRequired: Array<string> = []; 819 - 820 - if (operation.parameters) { 821 - // TODO: add support for cookies 822 - 823 - if (operation.parameters.header) { 824 - if (hasParameterGroupObjectRequired(operation.parameters.path)) { 825 - requiredProperties.push('headers'); 826 - } 827 - 828 - for (const key in operation.parameters.header) { 829 - const parameter = operation.parameters.header[key]!; 830 - headersPropertyProperties[parameter.name] = parameter.schema; 831 - if (parameter.required) { 832 - headersPropertyRequired.push(parameter.name); 833 - } 834 - } 835 - } 836 - 837 - if (operation.parameters.path) { 838 - if (hasParameterGroupObjectRequired(operation.parameters.path)) { 839 - requiredProperties.push('path'); 840 - } 841 - 842 - for (const key in operation.parameters.path) { 843 - const parameter = operation.parameters.path[key]!; 844 - pathPropertyProperties[parameter.name] = parameter.schema; 845 - if (parameter.required) { 846 - pathPropertyRequired.push(parameter.name); 847 - } 848 - } 849 - } 850 - 851 - if (operation.parameters.query) { 852 - if (hasParameterGroupObjectRequired(operation.parameters.query)) { 853 - requiredProperties.push('query'); 854 - } 855 - 856 - for (const key in operation.parameters.query) { 857 - const parameter = operation.parameters.query[key]!; 858 - queryPropertyProperties[parameter.name] = parameter.schema; 859 - if (parameter.required) { 860 - queryPropertyRequired.push(parameter.name); 861 - } 862 - } 863 - } 864 - } 865 - 866 - const identifierData = file.identifier({ 867 - // TODO: refactor for better cross-plugin compatibility 868 - $ref: `#/valibot-data/${operation.id}`, 869 - case: plugin.config.requests.case, 870 - create: true, 871 - nameTransformer: plugin.config.requests.name, 872 - namespace: 'value', 873 - }); 874 - schemaToValibotSchema({ 875 - // TODO: refactor for better cross-plugin compatibility 876 - $ref: `#/valibot-data/${operation.id}`, 877 - identifier: identifierData, 878 - plugin, 879 - schema: { 880 - properties: { 881 - body: operation.body 882 - ? operation.body.schema 883 - : { 884 - type: 'never', 885 - }, 886 - headers: Object.keys(headersPropertyProperties).length 887 - ? { 888 - properties: headersPropertyProperties, 889 - required: headersPropertyRequired, 890 - type: 'object', 891 - } 892 - : { 893 - type: 'never', 894 - }, 895 - path: Object.keys(pathPropertyProperties).length 896 - ? { 897 - properties: pathPropertyProperties, 898 - required: pathPropertyRequired, 899 - type: 'object', 900 - } 901 - : { 902 - type: 'never', 903 - }, 904 - query: Object.keys(queryPropertyProperties).length 905 - ? { 906 - properties: queryPropertyProperties, 907 - required: queryPropertyRequired, 908 - type: 'object', 909 - } 910 - : { 911 - type: 'never', 912 - }, 913 - }, 914 - required: requiredProperties, 915 - type: 'object', 916 - }, 917 - state, 918 - }); 919 - } 920 - 921 - if (plugin.config.responses.enabled) { 922 - if (operation.responses) { 923 - const { response } = operationResponsesMap(operation); 924 - 925 - if (response) { 926 - const identifierResponse = file.identifier({ 927 - // TODO: refactor for better cross-plugin compatibility 928 - $ref: `#/valibot-response/${operation.id}`, 929 - case: plugin.config.responses.case, 930 - create: true, 931 - nameTransformer: plugin.config.responses.name, 932 - namespace: 'value', 933 - }); 934 - schemaToValibotSchema({ 935 - // TODO: refactor for better cross-plugin compatibility 936 - $ref: `#/valibot-response/${operation.id}`, 937 - identifier: identifierResponse, 938 - plugin, 939 - schema: response, 940 - state, 941 - }); 942 - } 943 - } 944 - } 945 - }; 946 - 947 - const schemaToValibotSchema = ({ 794 + export const schemaToValibotSchema = ({ 948 795 $ref, 949 796 identifier: _identifier, 950 797 optional, ··· 963 810 * `.default()` which is handled in this function. 964 811 */ 965 812 optional?: boolean; 966 - plugin: Plugin.Instance<ResolvedConfig>; 813 + plugin: ValibotPlugin['Instance']; 967 814 schema: IR.SchemaObject; 968 815 state: State; 969 816 }): Array<ts.Expression> => { ··· 1200 1047 return pipes; 1201 1048 }; 1202 1049 1203 - export const handler: Plugin.Handler<ResolvedConfig> = ({ plugin }) => { 1050 + export const handler: ValibotPlugin['Handler'] = ({ plugin }) => { 1204 1051 const file = plugin.createFile({ 1205 1052 id: valibotId, 1206 1053 identifierCase: plugin.config.case,
+9 -6
packages/openapi-ts/src/plugins/valibot/types.d.ts
··· 1 - import type { StringCase } from '../../types/config'; 2 - import type { Plugin } from '../types'; 1 + import type { StringCase } from '../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../types'; 3 + import type { Api } from './api'; 3 4 4 - export interface Config extends Plugin.Name<'valibot'> { 5 + export type Config = Plugin.Name<'valibot'> & { 5 6 /** 6 7 * The casing convention to use for generated names. 7 8 * ··· 137 138 */ 138 139 name?: string | ((name: string) => string); 139 140 }; 140 - } 141 + }; 141 142 142 - export interface ResolvedConfig extends Plugin.Name<'valibot'> { 143 + export type ResolvedConfig = Plugin.Name<'valibot'> & { 143 144 /** 144 145 * The casing convention to use for generated names. 145 146 * ··· 251 252 */ 252 253 name: string | ((name: string) => string); 253 254 }; 254 - } 255 + }; 256 + 257 + export type ValibotPlugin = DefinePlugin<Config, ResolvedConfig, Api>;
+135
packages/openapi-ts/src/plugins/zod/api.ts
··· 1 + import type ts from 'typescript'; 2 + 3 + import { compiler } from '../../compiler'; 4 + import type { TypeScriptFile } from '../../generate/files'; 5 + import type { IR } from '../../ir/types'; 6 + import { identifiers, zodId } from './constants'; 7 + import type { ZodPlugin } from './types'; 8 + 9 + const createRequestValidator = ({ 10 + file, 11 + operation, 12 + plugin, 13 + }: { 14 + file: TypeScriptFile; 15 + operation: IR.OperationObject; 16 + plugin: ZodPlugin['Instance']; 17 + }): ts.ArrowFunction | undefined => { 18 + const { requests } = plugin.config; 19 + const schemaIdentifier = plugin.context.file({ id: zodId })!.identifier({ 20 + // TODO: refactor for better cross-plugin compatibility 21 + $ref: `#/zod-data/${operation.id}`, 22 + // TODO: refactor to not have to define nameTransformer 23 + nameTransformer: typeof requests === 'object' ? requests.name : undefined, 24 + namespace: 'value', 25 + }); 26 + 27 + if (!schemaIdentifier.name) { 28 + return; 29 + } 30 + 31 + file.import({ 32 + module: file.relativePathToFile({ 33 + context: plugin.context, 34 + id: zodId, 35 + }), 36 + name: schemaIdentifier.name, 37 + }); 38 + 39 + const dataParameterName = 'data'; 40 + 41 + return compiler.arrowFunction({ 42 + async: true, 43 + parameters: [ 44 + { 45 + name: dataParameterName, 46 + }, 47 + ], 48 + statements: [ 49 + compiler.returnStatement({ 50 + expression: compiler.awaitExpression({ 51 + expression: compiler.callExpression({ 52 + functionName: compiler.propertyAccessExpression({ 53 + expression: compiler.identifier({ text: schemaIdentifier.name }), 54 + name: identifiers.parseAsync, 55 + }), 56 + parameters: [compiler.identifier({ text: dataParameterName })], 57 + }), 58 + }), 59 + }), 60 + ], 61 + }); 62 + }; 63 + 64 + const createResponseValidator = ({ 65 + file, 66 + operation, 67 + plugin, 68 + }: { 69 + file: TypeScriptFile; 70 + operation: IR.OperationObject; 71 + plugin: ZodPlugin['Instance']; 72 + }): ts.ArrowFunction | undefined => { 73 + const { responses } = plugin.config; 74 + const schemaIdentifier = plugin.context.file({ id: zodId })!.identifier({ 75 + // TODO: refactor for better cross-plugin compatibility 76 + $ref: `#/zod-response/${operation.id}`, 77 + // TODO: refactor to not have to define nameTransformer 78 + nameTransformer: typeof responses === 'object' ? responses.name : undefined, 79 + namespace: 'value', 80 + }); 81 + 82 + if (!schemaIdentifier.name) { 83 + return; 84 + } 85 + 86 + file.import({ 87 + module: file.relativePathToFile({ 88 + context: plugin.context, 89 + id: zodId, 90 + }), 91 + name: schemaIdentifier.name, 92 + }); 93 + 94 + const dataParameterName = 'data'; 95 + 96 + return compiler.arrowFunction({ 97 + async: true, 98 + parameters: [ 99 + { 100 + name: dataParameterName, 101 + }, 102 + ], 103 + statements: [ 104 + compiler.returnStatement({ 105 + expression: compiler.awaitExpression({ 106 + expression: compiler.callExpression({ 107 + functionName: compiler.propertyAccessExpression({ 108 + expression: compiler.identifier({ text: schemaIdentifier.name }), 109 + name: identifiers.parseAsync, 110 + }), 111 + parameters: [compiler.identifier({ text: dataParameterName })], 112 + }), 113 + }), 114 + }), 115 + ], 116 + }); 117 + }; 118 + 119 + export type Api = { 120 + createRequestValidator: (args: { 121 + file: TypeScriptFile; 122 + operation: IR.OperationObject; 123 + plugin: ZodPlugin['Instance']; 124 + }) => ts.ArrowFunction | undefined; 125 + createResponseValidator: (args: { 126 + file: TypeScriptFile; 127 + operation: IR.OperationObject; 128 + plugin: ZodPlugin['Instance']; 129 + }) => ts.ArrowFunction | undefined; 130 + }; 131 + 132 + export const api: Api = { 133 + createRequestValidator, 134 + createResponseValidator, 135 + };
+4 -4
packages/openapi-ts/src/plugins/zod/config.ts
··· 1 1 import { definePluginConfig } from '../shared/utils/config'; 2 - import type { Plugin } from '../types'; 2 + import { api } from './api'; 3 3 import { handler } from './plugin'; 4 - import type { Config, ResolvedConfig } from './types'; 4 + import type { ZodPlugin } from './types'; 5 5 6 - export const defaultConfig: Plugin.Config<Config, ResolvedConfig> = { 6 + export const defaultConfig: ZodPlugin['Config'] = { 7 + api, 7 8 config: { 8 9 case: 'camelCase', 9 10 comments: true, ··· 11 12 metadata: false, 12 13 }, 13 14 handler, 14 - handlerLegacy: () => {}, 15 15 name: 'zod', 16 16 output: 'zod', 17 17 resolveConfig: (plugin, context) => {
+7
packages/openapi-ts/src/plugins/zod/constants.ts
··· 1 + import { compiler } from '../../compiler'; 2 + 3 + export const identifiers = { 4 + parseAsync: compiler.identifier({ text: 'parseAsync' }), 5 + }; 6 + 7 + export const zodId = 'zod';
+1 -1
packages/openapi-ts/src/plugins/zod/index.ts
··· 1 1 export { defaultConfig, defineConfig } from './config'; 2 - export type { Config } from './types'; 2 + export type { ZodPlugin } from './types';
+159
packages/openapi-ts/src/plugins/zod/operation.ts
··· 1 + import { operationResponsesMap } from '../../ir/operation'; 2 + import type { IR } from '../../ir/types'; 3 + import { zodId } from './constants'; 4 + import type { State } from './plugin'; 5 + import { schemaToZodSchema } from './plugin'; 6 + import type { ZodPlugin } from './types'; 7 + 8 + export const operationToZodSchema = ({ 9 + operation, 10 + plugin, 11 + state, 12 + }: { 13 + operation: IR.OperationObject; 14 + plugin: ZodPlugin['Instance']; 15 + state: State; 16 + }) => { 17 + const file = plugin.context.file({ id: zodId })!; 18 + 19 + if (plugin.config.requests.enabled) { 20 + const requiredProperties = new Set<string>(); 21 + 22 + const schemaData: IR.SchemaObject = { 23 + properties: { 24 + body: { 25 + type: 'never', 26 + }, 27 + path: { 28 + type: 'never', 29 + }, 30 + query: { 31 + type: 'never', 32 + }, 33 + }, 34 + type: 'object', 35 + }; 36 + 37 + if (operation.parameters) { 38 + // TODO: add support for cookies 39 + 40 + if (operation.parameters.header) { 41 + const properties: Record<string, IR.SchemaObject> = {}; 42 + const required: Array<string> = []; 43 + 44 + for (const key in operation.parameters.header) { 45 + const parameter = operation.parameters.header[key]!; 46 + properties[parameter.name] = parameter.schema; 47 + if (parameter.required) { 48 + required.push(parameter.name); 49 + requiredProperties.add('headers'); 50 + } 51 + } 52 + 53 + if (Object.keys(properties).length) { 54 + schemaData.properties!.headers = { 55 + properties, 56 + required, 57 + type: 'object', 58 + }; 59 + } 60 + } 61 + 62 + if (operation.parameters.path) { 63 + const properties: Record<string, IR.SchemaObject> = {}; 64 + const required: Array<string> = []; 65 + 66 + for (const key in operation.parameters.path) { 67 + const parameter = operation.parameters.path[key]!; 68 + properties[parameter.name] = parameter.schema; 69 + if (parameter.required) { 70 + required.push(parameter.name); 71 + requiredProperties.add('path'); 72 + } 73 + } 74 + 75 + if (Object.keys(properties).length) { 76 + schemaData.properties!.path = { 77 + properties, 78 + required, 79 + type: 'object', 80 + }; 81 + } 82 + } 83 + 84 + if (operation.parameters.query) { 85 + const properties: Record<string, IR.SchemaObject> = {}; 86 + const required: Array<string> = []; 87 + 88 + for (const key in operation.parameters.query) { 89 + const parameter = operation.parameters.query[key]!; 90 + properties[parameter.name] = parameter.schema; 91 + if (parameter.required) { 92 + required.push(parameter.name); 93 + requiredProperties.add('query'); 94 + } 95 + } 96 + 97 + if (Object.keys(properties).length) { 98 + schemaData.properties!.query = { 99 + properties, 100 + required, 101 + type: 'object', 102 + }; 103 + } 104 + } 105 + } 106 + 107 + if (operation.body) { 108 + schemaData.properties!.body = operation.body.schema; 109 + 110 + if (operation.body.required) { 111 + requiredProperties.add('body'); 112 + } 113 + } 114 + 115 + schemaData.required = [...requiredProperties]; 116 + 117 + const identifierData = file.identifier({ 118 + // TODO: refactor for better cross-plugin compatibility 119 + $ref: `#/zod-data/${operation.id}`, 120 + case: plugin.config.requests.case, 121 + create: true, 122 + nameTransformer: plugin.config.requests.name, 123 + namespace: 'value', 124 + }); 125 + schemaToZodSchema({ 126 + // TODO: refactor for better cross-plugin compatibility 127 + $ref: `#/zod-data/${operation.id}`, 128 + identifier: identifierData, 129 + plugin, 130 + schema: schemaData, 131 + state, 132 + }); 133 + } 134 + 135 + if (plugin.config.responses.enabled) { 136 + if (operation.responses) { 137 + const { response } = operationResponsesMap(operation); 138 + 139 + if (response) { 140 + const identifierResponse = file.identifier({ 141 + // TODO: refactor for better cross-plugin compatibility 142 + $ref: `#/zod-response/${operation.id}`, 143 + case: plugin.config.responses.case, 144 + create: true, 145 + nameTransformer: plugin.config.responses.name, 146 + namespace: 'value', 147 + }); 148 + schemaToZodSchema({ 149 + // TODO: refactor for better cross-plugin compatibility 150 + $ref: `#/zod-response/${operation.id}`, 151 + identifier: identifierResponse, 152 + plugin, 153 + schema: response, 154 + state, 155 + }); 156 + } 157 + } 158 + } 159 + };
+12 -166
packages/openapi-ts/src/plugins/zod/plugin.ts
··· 2 2 3 3 import { compiler } from '../../compiler'; 4 4 import type { Identifier } from '../../generate/files'; 5 - import { operationResponsesMap } from '../../ir/operation'; 6 - import { hasParameterGroupObjectRequired } from '../../ir/parameter'; 7 5 import { deduplicateSchema } from '../../ir/schema'; 8 6 import type { IR } from '../../ir/types'; 9 - import type { StringCase } from '../../types/config'; 7 + import type { StringCase } from '../../types/case'; 10 8 import { numberRegExp } from '../../utils/regexp'; 11 9 import { createSchemaComment } from '../shared/utils/schema'; 12 - import type { Plugin } from '../types'; 13 - import type { ResolvedConfig } from './types'; 10 + import { zodId } from './constants'; 11 + import { operationToZodSchema } from './operation'; 12 + import type { ZodPlugin } from './types'; 14 13 15 14 interface SchemaWithType<T extends Required<IR.SchemaObject>['type']> 16 15 extends Omit<IR.SchemaObject, 'type'> { 17 16 type: Extract<Required<IR.SchemaObject>['type'], T>; 18 17 } 19 18 20 - interface State { 19 + export interface State { 21 20 circularReferenceTracker: Set<string>; 22 21 hasCircularReference: boolean; 23 22 nameCase: StringCase; 24 23 nameTransformer: string | ((name: string) => string); 25 24 } 26 25 27 - export const zodId = 'zod'; 28 - 29 26 // frequently used identifiers 30 27 const andIdentifier = compiler.identifier({ text: 'and' }); 31 28 const arrayIdentifier = compiler.identifier({ text: 'array' }); ··· 51 48 schema, 52 49 state, 53 50 }: { 54 - plugin: Plugin.Instance<ResolvedConfig>; 51 + plugin: ZodPlugin['Instance']; 55 52 schema: SchemaWithType<'array'>; 56 53 state: State; 57 54 }): ts.CallExpression => { ··· 371 368 schema, 372 369 state, 373 370 }: { 374 - plugin: Plugin.Instance<ResolvedConfig>; 371 + plugin: ZodPlugin['Instance']; 375 372 schema: SchemaWithType<'object'>; 376 373 state: State; 377 374 }): { ··· 569 566 schema, 570 567 state, 571 568 }: { 572 - plugin: Plugin.Instance<ResolvedConfig>; 569 + plugin: ZodPlugin['Instance']; 573 570 schema: SchemaWithType<'tuple'>; 574 571 state: State; 575 572 }) => { ··· 665 662 schema, 666 663 state, 667 664 }: { 668 - plugin: Plugin.Instance<ResolvedConfig>; 665 + plugin: ZodPlugin['Instance']; 669 666 schema: IR.SchemaObject; 670 667 state: State; 671 668 }): { ··· 753 750 } 754 751 }; 755 752 756 - const operationToZodSchema = ({ 757 - operation, 758 - plugin, 759 - state, 760 - }: { 761 - operation: IR.OperationObject; 762 - plugin: Plugin.Instance<ResolvedConfig>; 763 - state: State; 764 - }) => { 765 - const file = plugin.context.file({ id: zodId })!; 766 - 767 - if (plugin.config.requests.enabled) { 768 - const requiredProperties: Array<string> = []; 769 - if (operation.body?.required) { 770 - requiredProperties.push('body'); 771 - } 772 - 773 - const headersPropertyProperties: Record<string, IR.SchemaObject> = {}; 774 - const headersPropertyRequired: Array<string> = []; 775 - const pathPropertyProperties: Record<string, IR.SchemaObject> = {}; 776 - const pathPropertyRequired: Array<string> = []; 777 - const queryPropertyProperties: Record<string, IR.SchemaObject> = {}; 778 - const queryPropertyRequired: Array<string> = []; 779 - 780 - if (operation.parameters) { 781 - // TODO: add support for cookies 782 - 783 - if (operation.parameters.header) { 784 - if (hasParameterGroupObjectRequired(operation.parameters.path)) { 785 - requiredProperties.push('headers'); 786 - } 787 - 788 - for (const key in operation.parameters.header) { 789 - const parameter = operation.parameters.header[key]!; 790 - headersPropertyProperties[parameter.name] = parameter.schema; 791 - if (parameter.required) { 792 - headersPropertyRequired.push(parameter.name); 793 - } 794 - } 795 - } 796 - 797 - if (operation.parameters.path) { 798 - if (hasParameterGroupObjectRequired(operation.parameters.path)) { 799 - requiredProperties.push('path'); 800 - } 801 - 802 - for (const key in operation.parameters.path) { 803 - const parameter = operation.parameters.path[key]!; 804 - pathPropertyProperties[parameter.name] = parameter.schema; 805 - if (parameter.required) { 806 - pathPropertyRequired.push(parameter.name); 807 - } 808 - } 809 - } 810 - 811 - if (operation.parameters.query) { 812 - if (hasParameterGroupObjectRequired(operation.parameters.query)) { 813 - requiredProperties.push('query'); 814 - } 815 - 816 - for (const key in operation.parameters.query) { 817 - const parameter = operation.parameters.query[key]!; 818 - queryPropertyProperties[parameter.name] = parameter.schema; 819 - if (parameter.required) { 820 - queryPropertyRequired.push(parameter.name); 821 - } 822 - } 823 - } 824 - } 825 - 826 - const identifierData = file.identifier({ 827 - // TODO: refactor for better cross-plugin compatibility 828 - $ref: `#/zod-data/${operation.id}`, 829 - case: plugin.config.requests.case, 830 - create: true, 831 - nameTransformer: plugin.config.requests.name, 832 - namespace: 'value', 833 - }); 834 - schemaToZodSchema({ 835 - // TODO: refactor for better cross-plugin compatibility 836 - $ref: `#/zod-data/${operation.id}`, 837 - identifier: identifierData, 838 - plugin, 839 - schema: { 840 - properties: { 841 - body: operation.body 842 - ? operation.body.schema 843 - : { 844 - type: 'never', 845 - }, 846 - headers: Object.keys(headersPropertyProperties).length 847 - ? { 848 - properties: headersPropertyProperties, 849 - required: headersPropertyRequired, 850 - type: 'object', 851 - } 852 - : { 853 - type: 'never', 854 - }, 855 - path: Object.keys(pathPropertyProperties).length 856 - ? { 857 - properties: pathPropertyProperties, 858 - required: pathPropertyRequired, 859 - type: 'object', 860 - } 861 - : { 862 - type: 'never', 863 - }, 864 - query: Object.keys(queryPropertyProperties).length 865 - ? { 866 - properties: queryPropertyProperties, 867 - required: queryPropertyRequired, 868 - type: 'object', 869 - } 870 - : { 871 - type: 'never', 872 - }, 873 - }, 874 - required: requiredProperties, 875 - type: 'object', 876 - }, 877 - state, 878 - }); 879 - } 880 - 881 - if (plugin.config.responses.enabled) { 882 - if (operation.responses) { 883 - const { response } = operationResponsesMap(operation); 884 - 885 - if (response) { 886 - const identifierResponse = file.identifier({ 887 - // TODO: refactor for better cross-plugin compatibility 888 - $ref: `#/zod-response/${operation.id}`, 889 - case: plugin.config.responses.case, 890 - create: true, 891 - nameTransformer: plugin.config.responses.name, 892 - namespace: 'value', 893 - }); 894 - schemaToZodSchema({ 895 - // TODO: refactor for better cross-plugin compatibility 896 - $ref: `#/zod-response/${operation.id}`, 897 - identifier: identifierResponse, 898 - plugin, 899 - schema: response, 900 - state, 901 - }); 902 - } 903 - } 904 - } 905 - }; 906 - 907 - const schemaToZodSchema = ({ 753 + export const schemaToZodSchema = ({ 908 754 $ref, 909 755 identifier: _identifier, 910 756 optional, ··· 923 769 * `.default()` which is handled in this function. 924 770 */ 925 771 optional?: boolean; 926 - plugin: Plugin.Instance<ResolvedConfig>; 772 + plugin: ZodPlugin['Instance']; 927 773 schema: IR.SchemaObject; 928 774 state: State; 929 775 }): ts.Expression => { ··· 1151 997 return expression!; 1152 998 }; 1153 999 1154 - export const handler: Plugin.Handler<ResolvedConfig> = ({ plugin }) => { 1000 + export const handler: ZodPlugin['Handler'] = ({ plugin }) => { 1155 1001 const file = plugin.createFile({ 1156 1002 id: zodId, 1157 1003 identifierCase: plugin.config.case,
+9 -6
packages/openapi-ts/src/plugins/zod/types.d.ts
··· 1 - import type { StringCase } from '../../types/config'; 2 - import type { Plugin } from '../types'; 1 + import type { StringCase } from '../../types/case'; 2 + import type { DefinePlugin, Plugin } from '../types'; 3 + import type { Api } from './api'; 3 4 4 - export interface Config extends Plugin.Name<'zod'> { 5 + export type Config = Plugin.Name<'zod'> & { 5 6 /** 6 7 * The casing convention to use for generated names. 7 8 * ··· 134 135 */ 135 136 name?: string | ((name: string) => string); 136 137 }; 137 - } 138 + }; 138 139 139 - export interface ResolvedConfig extends Plugin.Name<'zod'> { 140 + export type ResolvedConfig = Plugin.Name<'zod'> & { 140 141 /** 141 142 * The casing convention to use for generated names. 142 143 * ··· 245 246 */ 246 247 name: string | ((name: string) => string); 247 248 }; 248 - } 249 + }; 250 + 251 + export type ZodPlugin = DefinePlugin<Config, ResolvedConfig, Api>;
+6
packages/openapi-ts/src/types/case.d.ts
··· 1 + export type StringCase = 2 + | 'camelCase' 3 + | 'PascalCase' 4 + | 'preserve' 5 + | 'snake_case' 6 + | 'SCREAMING_SNAKE_CASE';
+15 -15
packages/openapi-ts/src/types/config.d.ts
··· 1 - import type { ClientPlugins, UserPlugins } from '../plugins'; 1 + import type { PluginConfigMap } from '../plugins/config'; 2 + import type { Plugin, PluginNames } from '../plugins/types'; 3 + import type { StringCase } from './case'; 2 4 import type { Input, Watch } from './input'; 3 - import type { ArrayOfObjectsToObjectMap, ExtractArrayOfObjects } from './utils'; 4 5 5 6 export type Formatters = 'biome' | 'prettier'; 6 7 7 8 export type Linters = 'biome' | 'eslint' | 'oxlint'; 8 - 9 - export type StringCase = 10 - | 'camelCase' 11 - | 'PascalCase' 12 - | 'preserve' 13 - | 'snake_case' 14 - | 'SCREAMING_SNAKE_CASE'; 15 9 16 10 export interface UserConfig { 17 11 /** ··· 145 139 * 146 140 * @default ['@hey-api/typescript', '@hey-api/sdk'] 147 141 */ 148 - plugins?: ReadonlyArray<UserPlugins['name'] | UserPlugins>; 142 + plugins?: ReadonlyArray< 143 + | PluginNames 144 + | { 145 + [K in PluginNames]: Plugin.UserConfig<PluginConfigMap[K]['config']> & { 146 + name: K; 147 + }; 148 + }[PluginNames] 149 + >; 149 150 150 151 // DEPRECATED OPTIONS BELOW 151 152 ··· 219 220 }; 220 221 logs: Extract<Required<UserConfig['logs']>, object>; 221 222 output: Extract<UserConfig['output'], object>; 222 - pluginOrder: ReadonlyArray<ClientPlugins['name']>; 223 - plugins: ArrayOfObjectsToObjectMap< 224 - ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, { name: string }>, 225 - 'name' 226 - >; 223 + pluginOrder: ReadonlyArray<keyof PluginConfigMap>; 224 + plugins: { 225 + [K in PluginNames]?: Plugin.ConfigWithName<PluginConfigMap[K]>; 226 + }; 227 227 };
-28
packages/openapi-ts/src/types/utils.d.ts
··· 1 1 import type { TypeScriptFile } from '../generate/files'; 2 2 3 - export type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator 4 - ? T 5 - : never; 6 - 7 - /** 8 - * Accepts an array of elements union and attempts to extract only objects. 9 - * For example, Array<string | number | { id: string }> would result in 10 - * Array<{ id: string }>. 11 - */ 12 - export type ExtractArrayOfObjects<T, Discriminator> = 13 - T extends Array<infer U> 14 - ? Array<ExtractWithDiscriminator<U, Discriminator>> 15 - : T extends ReadonlyArray<infer U> 16 - ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>> 17 - : never; 18 - 19 3 export type Files = Record<string, TypeScriptFile>; 20 - 21 - /** 22 - * Transforms an array of objects into an optional object map. 23 - * For example, Array<{ id: string }> would result in 24 - * { [key: string]?: { id: string } } 25 - */ 26 - export type ArrayOfObjectsToObjectMap< 27 - T extends ReadonlyArray<Record<string, any>>, 28 - D extends keyof T[number], 29 - > = { 30 - [K in T[number][D]]?: Extract<T[number], Record<D, K>>; 31 - };
+28 -14
packages/openapi-ts/src/utils/__tests__/handlebars.test.ts
··· 40 40 ], 41 41 plugins: { 42 42 '@hey-api/schemas': { 43 - config: {}, 43 + config: { 44 + name: '@hey-api/schemas', 45 + }, 44 46 handler: () => {}, 45 - handlerLegacy: () => {}, 46 47 name: '@hey-api/schemas', 48 + output: '', 47 49 }, 48 50 '@hey-api/sdk': { 49 - config: {}, 51 + config: { 52 + name: '@hey-api/sdk', 53 + }, 50 54 handler: () => {}, 51 - handlerLegacy: () => {}, 52 55 name: '@hey-api/sdk', 56 + output: '', 53 57 }, 54 58 '@hey-api/typescript': { 55 59 config: { 56 60 enums: 'javascript', 61 + name: '@hey-api/typescript', 57 62 }, 58 63 handler: () => {}, 59 - handlerLegacy: () => {}, 60 64 name: '@hey-api/typescript', 65 + output: '', 61 66 }, 62 67 'legacy/fetch': { 63 - config: {}, 68 + config: { 69 + name: 'legacy/fetch', 70 + }, 64 71 handler: () => {}, 65 - handlerLegacy: () => {}, 66 72 name: 'legacy/fetch', 73 + output: '', 67 74 tags: ['client'], 68 75 }, 69 76 }, ··· 113 120 ], 114 121 plugins: { 115 122 '@hey-api/schemas': { 116 - config: {}, 123 + config: { 124 + name: '@hey-api/schemas', 125 + }, 117 126 handler: () => {}, 118 - handlerLegacy: () => {}, 119 127 name: '@hey-api/schemas', 128 + output: '', 120 129 }, 121 130 '@hey-api/sdk': { 122 - config: {}, 131 + config: { 132 + name: '@hey-api/sdk', 133 + }, 123 134 handler: () => {}, 124 - handlerLegacy: () => {}, 125 135 name: '@hey-api/sdk', 136 + output: '', 126 137 }, 127 138 '@hey-api/typescript': { 128 139 config: { 129 140 enums: 'javascript', 141 + name: '@hey-api/typescript', 130 142 }, 131 143 handler: () => {}, 132 - handlerLegacy: () => {}, 133 144 name: '@hey-api/typescript', 145 + output: '', 134 146 }, 135 147 'legacy/fetch': { 136 - config: {}, 148 + config: { 149 + name: 'legacy/fetch', 150 + }, 137 151 handler: () => {}, 138 - handlerLegacy: () => {}, 139 152 name: 'legacy/fetch', 153 + output: '', 140 154 tags: ['client'], 141 155 }, 142 156 },
+22 -11
packages/openapi-ts/src/utils/__tests__/parse.test.ts
··· 30 30 plugins: { 31 31 '@hey-api/sdk': { 32 32 config: { 33 + name: '@hey-api/sdk', 33 34 operationId: true, 34 35 response: 'body', 35 36 }, 36 37 handler: () => {}, 37 - handlerLegacy: () => {}, 38 38 name: '@hey-api/sdk', 39 + output: '', 39 40 }, 40 41 'legacy/fetch': { 41 - config: {}, 42 + config: { 43 + name: 'legacy/fetch', 44 + }, 42 45 handler: () => {}, 43 - handlerLegacy: () => {}, 44 46 name: 'legacy/fetch', 47 + output: '', 45 48 tags: ['client'], 46 49 }, 47 50 }, ··· 54 57 ...optionsCommon.plugins, 55 58 '@hey-api/sdk': { 56 59 config: { 60 + name: '@hey-api/sdk', 57 61 operationId: true, 58 62 response: 'body', 59 63 }, 60 64 handler: () => {}, 61 - handlerLegacy: () => {}, 62 65 name: '@hey-api/sdk', 66 + output: '', 63 67 }, 64 68 }, 65 69 }; ··· 70 74 ...optionsCommon.plugins, 71 75 '@hey-api/sdk': { 72 76 config: { 77 + name: '@hey-api/sdk', 73 78 operationId: false, 74 79 response: 'body', 75 80 }, 76 81 handler: () => {}, 77 - handlerLegacy: () => {}, 78 82 name: '@hey-api/sdk', 83 + output: '', 79 84 }, 80 85 }, 81 86 }; ··· 85 90 pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], 86 91 plugins: { 87 92 '@hey-api/client-fetch': { 88 - config: {}, 93 + config: { 94 + name: '@hey-api/client-fetch', 95 + }, 89 96 handler: () => {}, 90 - handlerLegacy: () => {}, 91 97 name: '@hey-api/client-fetch', 98 + output: '', 92 99 tags: ['client'], 93 100 }, 94 101 '@hey-api/sdk': { 95 102 config: { 103 + name: '@hey-api/sdk', 96 104 operationId: true, 97 105 response: 'body', 98 106 }, 99 107 handler: () => {}, 100 - handlerLegacy: () => {}, 101 108 name: '@hey-api/sdk', 109 + output: '', 102 110 }, 103 111 }, 104 112 }; ··· 108 116 pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], 109 117 plugins: { 110 118 '@hey-api/client-fetch': { 111 - config: {}, 119 + config: { 120 + name: '@hey-api/client-fetch', 121 + }, 112 122 handler: () => {}, 113 - handlerLegacy: () => {}, 114 123 name: '@hey-api/client-fetch', 124 + output: '', 115 125 tags: ['client'], 116 126 }, 117 127 '@hey-api/sdk': { 118 128 config: { 129 + name: '@hey-api/sdk', 119 130 operationId: false, 120 131 response: 'body', 121 132 }, 122 133 handler: () => {}, 123 - handlerLegacy: () => {}, 124 134 name: '@hey-api/sdk', 135 + output: '', 125 136 }, 126 137 }, 127 138 };
+1 -1
packages/openapi-ts/src/utils/__tests__/stringCase.test.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { StringCase } from '../../types/config'; 3 + import type { StringCase } from '../../types/case'; 4 4 import { stringCase } from '../stringCase'; 5 5 6 6 const cases: ReadonlyArray<StringCase> = [
+1 -1
packages/openapi-ts/src/utils/stringCase.ts
··· 1 - import type { StringCase } from '../types/config'; 1 + import type { StringCase } from '../types/case'; 2 2 3 3 const uppercaseRegExp = /[\p{Lu}]/u; 4 4 const lowercaseRegExp = /[\p{Ll}]/u;
+14 -12
pnpm-lock.yaml
··· 350 350 react-dom: 351 351 specifier: 19.0.0 352 352 version: 19.0.0(react@19.0.0) 353 + valibot: 354 + specifier: 1.1.0 355 + version: 1.1.0(typescript@5.8.3) 356 + zod: 357 + specifier: 3.23.8 358 + version: 3.23.8 353 359 devDependencies: 354 360 '@config/vite-base': 355 361 specifier: workspace:* ··· 12548 12554 '@babel/traverse': 7.26.10 12549 12555 '@babel/types': 7.26.10 12550 12556 convert-source-map: 2.0.0 12551 - debug: 4.4.0 12557 + debug: 4.4.0(supports-color@9.4.0) 12552 12558 gensync: 1.0.0-beta.2 12553 12559 json5: 2.2.3 12554 12560 semver: 6.3.1 ··· 13292 13298 '@babel/parser': 7.26.10 13293 13299 '@babel/template': 7.26.9 13294 13300 '@babel/types': 7.26.10 13295 - debug: 4.4.0 13301 + debug: 4.4.0(supports-color@9.4.0) 13296 13302 globals: 11.12.0 13297 13303 transitivePeerDependencies: 13298 13304 - supports-color ··· 13957 13963 '@eslint/config-array@0.19.2': 13958 13964 dependencies: 13959 13965 '@eslint/object-schema': 2.1.6 13960 - debug: 4.4.0 13966 + debug: 4.4.0(supports-color@9.4.0) 13961 13967 minimatch: 3.1.2 13962 13968 transitivePeerDependencies: 13963 13969 - supports-color ··· 13973 13979 '@eslint/eslintrc@3.3.0': 13974 13980 dependencies: 13975 13981 ajv: 6.12.6 13976 - debug: 4.4.0 13982 + debug: 4.4.0(supports-color@9.4.0) 13977 13983 espree: 10.3.0 13978 13984 globals: 14.0.0 13979 13985 ignore: 5.3.2 ··· 16703 16709 '@typescript-eslint/types': 8.29.1 16704 16710 '@typescript-eslint/typescript-estree': 8.29.1(typescript@5.8.3) 16705 16711 '@typescript-eslint/visitor-keys': 8.29.1 16706 - debug: 4.4.0 16712 + debug: 4.4.0(supports-color@9.4.0) 16707 16713 eslint: 9.17.0(jiti@2.4.2) 16708 16714 typescript: 5.8.3 16709 16715 transitivePeerDependencies: ··· 16723 16729 dependencies: 16724 16730 '@typescript-eslint/typescript-estree': 8.29.1(typescript@5.8.3) 16725 16731 '@typescript-eslint/utils': 8.29.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.8.3) 16726 - debug: 4.4.0 16732 + debug: 4.4.0(supports-color@9.4.0) 16727 16733 eslint: 9.17.0(jiti@2.4.2) 16728 16734 ts-api-utils: 2.0.1(typescript@5.8.3) 16729 16735 typescript: 5.8.3 ··· 16752 16758 dependencies: 16753 16759 '@typescript-eslint/types': 8.29.1 16754 16760 '@typescript-eslint/visitor-keys': 8.29.1 16755 - debug: 4.4.0 16761 + debug: 4.4.0(supports-color@9.4.0) 16756 16762 fast-glob: 3.3.3 16757 16763 is-glob: 4.0.3 16758 16764 minimatch: 9.0.5 ··· 18358 18364 dependencies: 18359 18365 ms: 2.1.3 18360 18366 18361 - debug@4.4.0: 18362 - dependencies: 18363 - ms: 2.1.3 18364 - 18365 18367 debug@4.4.0(supports-color@9.4.0): 18366 18368 dependencies: 18367 18369 ms: 2.1.3 ··· 19135 19137 ajv: 6.12.6 19136 19138 chalk: 4.1.2 19137 19139 cross-spawn: 7.0.6 19138 - debug: 4.4.0 19140 + debug: 4.4.0(supports-color@9.4.0) 19139 19141 escape-string-regexp: 4.0.0 19140 19142 eslint-scope: 8.3.0 19141 19143 eslint-visitor-keys: 4.2.0