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

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3432 from nmokkenstorm/feat/use-mutation-hooks

feat: generate useMutation hooks for TanStack React Query plugin

authored by

Lubos and committed by
GitHub
262798eb 35c82337

+14123 -2
+5
.changeset/grumpy-mice-ask.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + **plugin(@tanstack/react-query)**: support generating `useMutation` hooks
+550
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/@tanstack/react-query.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type DefaultError, queryOptions, useMutation, type UseMutationOptions } from '@tanstack/react-query'; 4 + 5 + import { client } from '../client.gen'; 6 + import { callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexTypes, deleteCallWithoutParametersAndResponse, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, fooWow, getCallWithoutParametersAndResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionBody, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, serviceWithEmptyTag, testErrorCode, types } from '../sdk.gen'; 7 + import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DummyAData, DummyBData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, FooWowData, GetCallWithoutParametersAndResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, ServiceWithEmptyTagData, TestErrorCodeData, TypesData, TypesResponse } from '../types.gen'; 8 + 9 + export type QueryKey<TOptions extends Options> = [ 10 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 12 + _infinite?: boolean; 13 + tags?: ReadonlyArray<string>; 14 + } 15 + ]; 16 + 17 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 + QueryKey<TOptions>[0] 19 + ] => { 20 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 + if (infinite) { 22 + params._infinite = infinite; 23 + } 24 + if (tags) { 25 + params.tags = tags; 26 + } 27 + if (options?.body) { 28 + params.body = options.body; 29 + } 30 + if (options?.headers) { 31 + params.headers = options.headers; 32 + } 33 + if (options?.path) { 34 + params.path = options.path; 35 + } 36 + if (options?.query) { 37 + params.query = options.query; 38 + } 39 + return [params]; 40 + }; 41 + 42 + export const serviceWithEmptyTagQueryKey = (options?: Options<ServiceWithEmptyTagData>) => createQueryKey('serviceWithEmptyTag', options); 43 + 44 + export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTagData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof serviceWithEmptyTagQueryKey>>({ 45 + queryFn: async ({ queryKey, signal }) => { 46 + const { data } = await serviceWithEmptyTag({ 47 + ...options, 48 + ...queryKey[0], 49 + signal, 50 + throwOnError: true 51 + }); 52 + return data; 53 + }, 54 + queryKey: serviceWithEmptyTagQueryKey(options) 55 + }); 56 + 57 + export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => { 58 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> = { 59 + mutationFn: async (fnOptions) => { 60 + const { data } = await patchApiVbyApiVersionNoTag({ 61 + ...options, 62 + ...fnOptions, 63 + throwOnError: true 64 + }); 65 + return data; 66 + } 67 + }; 68 + return mutationOptions; 69 + }; 70 + 71 + export const usePatchApiVbyApiVersionNoTagMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>>, 'mutationFn'>>) => useMutation({ ...patchApiVbyApiVersionNoTagMutation(), ...mutationOptions }); 72 + 73 + export const fooWowMutation = (options?: Partial<Options<FooWowData>>): UseMutationOptions<unknown, DefaultError, Options<FooWowData>> => { 74 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<FooWowData>> = { 75 + mutationFn: async (fnOptions) => { 76 + const { data } = await fooWow({ 77 + ...options, 78 + ...fnOptions, 79 + throwOnError: true 80 + }); 81 + return data; 82 + } 83 + }; 84 + return mutationOptions; 85 + }; 86 + 87 + export const useFooWowMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<FooWowData>>, 'mutationFn'>>) => useMutation({ ...fooWowMutation(), ...mutationOptions }); 88 + 89 + export const deleteCallWithoutParametersAndResponseMutation = (options?: Partial<Options<DeleteCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> => { 90 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> = { 91 + mutationFn: async (fnOptions) => { 92 + const { data } = await deleteCallWithoutParametersAndResponse({ 93 + ...options, 94 + ...fnOptions, 95 + throwOnError: true 96 + }); 97 + return data; 98 + } 99 + }; 100 + return mutationOptions; 101 + }; 102 + 103 + export const useDeleteCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...deleteCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 104 + 105 + export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 106 + 107 + export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getCallWithoutParametersAndResponseQueryKey>>({ 108 + queryFn: async ({ queryKey, signal }) => { 109 + const { data } = await getCallWithoutParametersAndResponse({ 110 + ...options, 111 + ...queryKey[0], 112 + signal, 113 + throwOnError: true 114 + }); 115 + return data; 116 + }, 117 + queryKey: getCallWithoutParametersAndResponseQueryKey(options) 118 + }); 119 + 120 + export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => { 121 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> = { 122 + mutationFn: async (fnOptions) => { 123 + const { data } = await patchCallWithoutParametersAndResponse({ 124 + ...options, 125 + ...fnOptions, 126 + throwOnError: true 127 + }); 128 + return data; 129 + } 130 + }; 131 + return mutationOptions; 132 + }; 133 + 134 + export const usePatchCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...patchCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 135 + 136 + export const postCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PostCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> => { 137 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> = { 138 + mutationFn: async (fnOptions) => { 139 + const { data } = await postCallWithoutParametersAndResponse({ 140 + ...options, 141 + ...fnOptions, 142 + throwOnError: true 143 + }); 144 + return data; 145 + } 146 + }; 147 + return mutationOptions; 148 + }; 149 + 150 + export const usePostCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...postCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 151 + 152 + export const putCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PutCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> => { 153 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> = { 154 + mutationFn: async (fnOptions) => { 155 + const { data } = await putCallWithoutParametersAndResponse({ 156 + ...options, 157 + ...fnOptions, 158 + throwOnError: true 159 + }); 160 + return data; 161 + } 162 + }; 163 + return mutationOptions; 164 + }; 165 + 166 + export const usePutCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...putCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 167 + 168 + export const callWithDescriptionsMutation = (options?: Partial<Options<CallWithDescriptionsData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> => { 169 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> = { 170 + mutationFn: async (fnOptions) => { 171 + const { data } = await callWithDescriptions({ 172 + ...options, 173 + ...fnOptions, 174 + throwOnError: true 175 + }); 176 + return data; 177 + } 178 + }; 179 + return mutationOptions; 180 + }; 181 + 182 + export const useCallWithDescriptionsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>>, 'mutationFn'>>) => useMutation({ ...callWithDescriptionsMutation(), ...mutationOptions }); 183 + 184 + export const callWithParametersMutation = (options?: Partial<Options<CallWithParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> => { 185 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> = { 186 + mutationFn: async (fnOptions) => { 187 + const { data } = await callWithParameters({ 188 + ...options, 189 + ...fnOptions, 190 + throwOnError: true 191 + }); 192 + return data; 193 + } 194 + }; 195 + return mutationOptions; 196 + }; 197 + 198 + export const useCallWithParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithParametersMutation(), ...mutationOptions }); 199 + 200 + export const callWithWeirdParameterNamesMutation = (options?: Partial<Options<CallWithWeirdParameterNamesData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> => { 201 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 202 + mutationFn: async (fnOptions) => { 203 + const { data } = await callWithWeirdParameterNames({ 204 + ...options, 205 + ...fnOptions, 206 + throwOnError: true 207 + }); 208 + return data; 209 + } 210 + }; 211 + return mutationOptions; 212 + }; 213 + 214 + export const useCallWithWeirdParameterNamesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>>, 'mutationFn'>>) => useMutation({ ...callWithWeirdParameterNamesMutation(), ...mutationOptions }); 215 + 216 + export const callWithDefaultParametersQueryKey = (options: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 217 + 218 + export const callWithDefaultParametersOptions = (options: Options<CallWithDefaultParametersData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof callWithDefaultParametersQueryKey>>({ 219 + queryFn: async ({ queryKey, signal }) => { 220 + const { data } = await callWithDefaultParameters({ 221 + ...options, 222 + ...queryKey[0], 223 + signal, 224 + throwOnError: true 225 + }); 226 + return data; 227 + }, 228 + queryKey: callWithDefaultParametersQueryKey(options) 229 + }); 230 + 231 + export const callWithDefaultOptionalParametersMutation = (options?: Partial<Options<CallWithDefaultOptionalParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> => { 232 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 233 + mutationFn: async (fnOptions) => { 234 + const { data } = await callWithDefaultOptionalParameters({ 235 + ...options, 236 + ...fnOptions, 237 + throwOnError: true 238 + }); 239 + return data; 240 + } 241 + }; 242 + return mutationOptions; 243 + }; 244 + 245 + export const useCallWithDefaultOptionalParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithDefaultOptionalParametersMutation(), ...mutationOptions }); 246 + 247 + export const callToTestOrderOfParamsMutation = (options?: Partial<Options<CallToTestOrderOfParamsData>>): UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> => { 248 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> = { 249 + mutationFn: async (fnOptions) => { 250 + const { data } = await callToTestOrderOfParams({ 251 + ...options, 252 + ...fnOptions, 253 + throwOnError: true 254 + }); 255 + return data; 256 + } 257 + }; 258 + return mutationOptions; 259 + }; 260 + 261 + export const useCallToTestOrderOfParamsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>>, 'mutationFn'>>) => useMutation({ ...callToTestOrderOfParamsMutation(), ...mutationOptions }); 262 + 263 + export const duplicateNameMutation = (options?: Partial<Options<DuplicateNameData>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> => { 264 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> = { 265 + mutationFn: async (fnOptions) => { 266 + const { data } = await duplicateName({ 267 + ...options, 268 + ...fnOptions, 269 + throwOnError: true 270 + }); 271 + return data; 272 + } 273 + }; 274 + return mutationOptions; 275 + }; 276 + 277 + export const useDuplicateNameMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>>, 'mutationFn'>>) => useMutation({ ...duplicateNameMutation(), ...mutationOptions }); 278 + 279 + export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 280 + 281 + export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof duplicateName2QueryKey>>({ 282 + queryFn: async ({ queryKey, signal }) => { 283 + const { data } = await duplicateName2({ 284 + ...options, 285 + ...queryKey[0], 286 + signal, 287 + throwOnError: true 288 + }); 289 + return data; 290 + }, 291 + queryKey: duplicateName2QueryKey(options) 292 + }); 293 + 294 + export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => { 295 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> = { 296 + mutationFn: async (fnOptions) => { 297 + const { data } = await duplicateName3({ 298 + ...options, 299 + ...fnOptions, 300 + throwOnError: true 301 + }); 302 + return data; 303 + } 304 + }; 305 + return mutationOptions; 306 + }; 307 + 308 + export const useDuplicateName3Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName3Mutation(), ...mutationOptions }); 309 + 310 + export const duplicateName4Mutation = (options?: Partial<Options<DuplicateName4Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> => { 311 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> = { 312 + mutationFn: async (fnOptions) => { 313 + const { data } = await duplicateName4({ 314 + ...options, 315 + ...fnOptions, 316 + throwOnError: true 317 + }); 318 + return data; 319 + } 320 + }; 321 + return mutationOptions; 322 + }; 323 + 324 + export const useDuplicateName4Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName4Mutation(), ...mutationOptions }); 325 + 326 + export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 327 + 328 + export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof callWithNoContentResponseQueryKey>>({ 329 + queryFn: async ({ queryKey, signal }) => { 330 + const { data } = await callWithNoContentResponse({ 331 + ...options, 332 + ...queryKey[0], 333 + signal, 334 + throwOnError: true 335 + }); 336 + return data; 337 + }, 338 + queryKey: callWithNoContentResponseQueryKey(options) 339 + }); 340 + 341 + export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 342 + 343 + export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => queryOptions<CallWithResponseAndNoContentResponseResponse, DefaultError, CallWithResponseAndNoContentResponseResponse, ReturnType<typeof callWithResponseAndNoContentResponseQueryKey>>({ 344 + queryFn: async ({ queryKey, signal }) => { 345 + const { data } = await callWithResponseAndNoContentResponse({ 346 + ...options, 347 + ...queryKey[0], 348 + signal, 349 + throwOnError: true 350 + }); 351 + return data; 352 + }, 353 + queryKey: callWithResponseAndNoContentResponseQueryKey(options) 354 + }); 355 + 356 + export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 357 + 358 + export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof dummyAQueryKey>>({ 359 + queryFn: async ({ queryKey, signal }) => { 360 + const { data } = await dummyA({ 361 + ...options, 362 + ...queryKey[0], 363 + signal, 364 + throwOnError: true 365 + }); 366 + return data; 367 + }, 368 + queryKey: dummyAQueryKey(options) 369 + }); 370 + 371 + export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 372 + 373 + export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof dummyBQueryKey>>({ 374 + queryFn: async ({ queryKey, signal }) => { 375 + const { data } = await dummyB({ 376 + ...options, 377 + ...queryKey[0], 378 + signal, 379 + throwOnError: true 380 + }); 381 + return data; 382 + }, 383 + queryKey: dummyBQueryKey(options) 384 + }); 385 + 386 + export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 387 + 388 + export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => queryOptions<CallWithResponseResponse, DefaultError, CallWithResponseResponse, ReturnType<typeof callWithResponseQueryKey>>({ 389 + queryFn: async ({ queryKey, signal }) => { 390 + const { data } = await callWithResponse({ 391 + ...options, 392 + ...queryKey[0], 393 + signal, 394 + throwOnError: true 395 + }); 396 + return data; 397 + }, 398 + queryKey: callWithResponseQueryKey(options) 399 + }); 400 + 401 + export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => { 402 + const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> = { 403 + mutationFn: async (fnOptions) => { 404 + const { data } = await callWithDuplicateResponses({ 405 + ...options, 406 + ...fnOptions, 407 + throwOnError: true 408 + }); 409 + return data; 410 + } 411 + }; 412 + return mutationOptions; 413 + }; 414 + 415 + export const useCallWithDuplicateResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithDuplicateResponsesMutation(), ...mutationOptions }); 416 + 417 + export const callWithResponsesMutation = (options?: Partial<Options<CallWithResponsesData>>): UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> => { 418 + const mutationOptions: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> = { 419 + mutationFn: async (fnOptions) => { 420 + const { data } = await callWithResponses({ 421 + ...options, 422 + ...fnOptions, 423 + throwOnError: true 424 + }); 425 + return data; 426 + } 427 + }; 428 + return mutationOptions; 429 + }; 430 + 431 + export const useCallWithResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithResponsesMutation(), ...mutationOptions }); 432 + 433 + export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 434 + 435 + export const collectionFormatOptions = (options: Options<CollectionFormatData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof collectionFormatQueryKey>>({ 436 + queryFn: async ({ queryKey, signal }) => { 437 + const { data } = await collectionFormat({ 438 + ...options, 439 + ...queryKey[0], 440 + signal, 441 + throwOnError: true 442 + }); 443 + return data; 444 + }, 445 + queryKey: collectionFormatQueryKey(options) 446 + }); 447 + 448 + export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 449 + 450 + export const typesOptions = (options: Options<TypesData>) => queryOptions<TypesResponse, DefaultError, TypesResponse, ReturnType<typeof typesQueryKey>>({ 451 + queryFn: async ({ queryKey, signal }) => { 452 + const { data } = await types({ 453 + ...options, 454 + ...queryKey[0], 455 + signal, 456 + throwOnError: true 457 + }); 458 + return data; 459 + }, 460 + queryKey: typesQueryKey(options) 461 + }); 462 + 463 + export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 464 + 465 + export const complexTypesOptions = (options: Options<ComplexTypesData>) => queryOptions<ComplexTypesResponse, DefaultError, ComplexTypesResponse, ReturnType<typeof complexTypesQueryKey>>({ 466 + queryFn: async ({ queryKey, signal }) => { 467 + const { data } = await complexTypes({ 468 + ...options, 469 + ...queryKey[0], 470 + signal, 471 + throwOnError: true 472 + }); 473 + return data; 474 + }, 475 + queryKey: complexTypesQueryKey(options) 476 + }); 477 + 478 + export const callWithResultFromHeaderMutation = (options?: Partial<Options<CallWithResultFromHeaderData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> => { 479 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> = { 480 + mutationFn: async (fnOptions) => { 481 + const { data } = await callWithResultFromHeader({ 482 + ...options, 483 + ...fnOptions, 484 + throwOnError: true 485 + }); 486 + return data; 487 + } 488 + }; 489 + return mutationOptions; 490 + }; 491 + 492 + export const useCallWithResultFromHeaderMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>>, 'mutationFn'>>) => useMutation({ ...callWithResultFromHeaderMutation(), ...mutationOptions }); 493 + 494 + export const testErrorCodeMutation = (options?: Partial<Options<TestErrorCodeData>>): UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> => { 495 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> = { 496 + mutationFn: async (fnOptions) => { 497 + const { data } = await testErrorCode({ 498 + ...options, 499 + ...fnOptions, 500 + throwOnError: true 501 + }); 502 + return data; 503 + } 504 + }; 505 + return mutationOptions; 506 + }; 507 + 508 + export const useTestErrorCodeMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>>, 'mutationFn'>>) => useMutation({ ...testErrorCodeMutation(), ...mutationOptions }); 509 + 510 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options?: Partial<Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>): UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> => { 511 + const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 512 + mutationFn: async (fnOptions) => { 513 + const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 514 + ...options, 515 + ...fnOptions, 516 + throwOnError: true 517 + }); 518 + return data; 519 + } 520 + }; 521 + return mutationOptions; 522 + }; 523 + 524 + export const useNonAsciiæøåÆøÅöôêÊ字符串Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>, 'mutationFn'>>) => useMutation({ ...nonAsciiæøåÆøÅöôêÊ字符串Mutation(), ...mutationOptions }); 525 + 526 + /** 527 + * Body should not be unknown 528 + * 529 + * Body should not be unknown 530 + */ 531 + export const postApiVbyApiVersionBodyMutation = (options?: Partial<Options<PostApiVbyApiVersionBodyData>>): UseMutationOptions<PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError, Options<PostApiVbyApiVersionBodyData>> => { 532 + const mutationOptions: UseMutationOptions<PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError, Options<PostApiVbyApiVersionBodyData>> = { 533 + mutationFn: async (fnOptions) => { 534 + const { data } = await postApiVbyApiVersionBody({ 535 + ...options, 536 + ...fnOptions, 537 + throwOnError: true 538 + }); 539 + return data; 540 + } 541 + }; 542 + return mutationOptions; 543 + }; 544 + 545 + /** 546 + * Body should not be unknown 547 + * 548 + * Body should not be unknown 549 + */ 550 + export const usePostApiVbyApiVersionBodyMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError, Options<PostApiVbyApiVersionBodyData>>, 'mutationFn'>>) => useMutation({ ...postApiVbyApiVersionBodyMutation(), ...mutationOptions });
+16
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 + import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:3000/base' }));
+288
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createSseClient } from '../core/serverSentEvents.gen'; 4 + import type { HttpMethod } from '../core/types.gen'; 5 + import { getValidRequestBody } from '../core/utils.gen'; 6 + import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen'; 7 + import { 8 + buildUrl, 9 + createConfig, 10 + createInterceptors, 11 + getParseAs, 12 + mergeConfigs, 13 + mergeHeaders, 14 + setAuthParams, 15 + } from './utils.gen'; 16 + 17 + type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 18 + body?: any; 19 + headers: ReturnType<typeof mergeHeaders>; 20 + }; 21 + 22 + export const createClient = (config: Config = {}): Client => { 23 + let _config = mergeConfigs(createConfig(), config); 24 + 25 + const getConfig = (): Config => ({ ..._config }); 26 + 27 + const setConfig = (config: Config): Config => { 28 + _config = mergeConfigs(_config, config); 29 + return getConfig(); 30 + }; 31 + 32 + const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 33 + 34 + const beforeRequest = async (options: RequestOptions) => { 35 + const opts = { 36 + ..._config, 37 + ...options, 38 + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 39 + headers: mergeHeaders(_config.headers, options.headers), 40 + serializedBody: undefined as string | undefined, 41 + }; 42 + 43 + if (opts.security) { 44 + await setAuthParams({ 45 + ...opts, 46 + security: opts.security, 47 + }); 48 + } 49 + 50 + if (opts.requestValidator) { 51 + await opts.requestValidator(opts); 52 + } 53 + 54 + if (opts.body !== undefined && opts.bodySerializer) { 55 + opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 56 + } 57 + 58 + // remove Content-Type header if body is empty to avoid sending invalid requests 59 + if (opts.body === undefined || opts.serializedBody === '') { 60 + opts.headers.delete('Content-Type'); 61 + } 62 + 63 + const url = buildUrl(opts); 64 + 65 + return { opts, url }; 66 + }; 67 + 68 + const request: Client['request'] = async (options) => { 69 + // @ts-expect-error 70 + const { opts, url } = await beforeRequest(options); 71 + const requestInit: ReqInit = { 72 + redirect: 'follow', 73 + ...opts, 74 + body: getValidRequestBody(opts), 75 + }; 76 + 77 + let request = new Request(url, requestInit); 78 + 79 + for (const fn of interceptors.request.fns) { 80 + if (fn) { 81 + request = await fn(request, opts); 82 + } 83 + } 84 + 85 + // fetch must be assigned here, otherwise it would throw the error: 86 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 + const _fetch = opts.fetch!; 88 + let response: Response; 89 + 90 + try { 91 + response = await _fetch(request); 92 + } catch (error) { 93 + // Handle fetch exceptions (AbortError, network errors, etc.) 94 + let finalError = error; 95 + 96 + for (const fn of interceptors.error.fns) { 97 + if (fn) { 98 + finalError = (await fn(error, undefined as any, request, opts)) as unknown; 99 + } 100 + } 101 + 102 + finalError = finalError || ({} as unknown); 103 + 104 + if (opts.throwOnError) { 105 + throw finalError; 106 + } 107 + 108 + // Return error response 109 + return opts.responseStyle === 'data' 110 + ? undefined 111 + : { 112 + error: finalError, 113 + request, 114 + response: undefined as any, 115 + }; 116 + } 117 + 118 + for (const fn of interceptors.response.fns) { 119 + if (fn) { 120 + response = await fn(response, request, opts); 121 + } 122 + } 123 + 124 + const result = { 125 + request, 126 + response, 127 + }; 128 + 129 + if (response.ok) { 130 + const parseAs = 131 + (opts.parseAs === 'auto' 132 + ? getParseAs(response.headers.get('Content-Type')) 133 + : opts.parseAs) ?? 'json'; 134 + 135 + if (response.status === 204 || response.headers.get('Content-Length') === '0') { 136 + let emptyData: any; 137 + switch (parseAs) { 138 + case 'arrayBuffer': 139 + case 'blob': 140 + case 'text': 141 + emptyData = await response[parseAs](); 142 + break; 143 + case 'formData': 144 + emptyData = new FormData(); 145 + break; 146 + case 'stream': 147 + emptyData = response.body; 148 + break; 149 + case 'json': 150 + default: 151 + emptyData = {}; 152 + break; 153 + } 154 + return opts.responseStyle === 'data' 155 + ? emptyData 156 + : { 157 + data: emptyData, 158 + ...result, 159 + }; 160 + } 161 + 162 + let data: any; 163 + switch (parseAs) { 164 + case 'arrayBuffer': 165 + case 'blob': 166 + case 'formData': 167 + case 'text': 168 + data = await response[parseAs](); 169 + break; 170 + case 'json': { 171 + // Some servers return 200 with no Content-Length and empty body. 172 + // response.json() would throw; read as text and parse if non-empty. 173 + const text = await response.text(); 174 + data = text ? JSON.parse(text) : {}; 175 + break; 176 + } 177 + case 'stream': 178 + return opts.responseStyle === 'data' 179 + ? response.body 180 + : { 181 + data: response.body, 182 + ...result, 183 + }; 184 + } 185 + 186 + if (parseAs === 'json') { 187 + if (opts.responseValidator) { 188 + await opts.responseValidator(data); 189 + } 190 + 191 + if (opts.responseTransformer) { 192 + data = await opts.responseTransformer(data); 193 + } 194 + } 195 + 196 + return opts.responseStyle === 'data' 197 + ? data 198 + : { 199 + data, 200 + ...result, 201 + }; 202 + } 203 + 204 + const textError = await response.text(); 205 + let jsonError: unknown; 206 + 207 + try { 208 + jsonError = JSON.parse(textError); 209 + } catch { 210 + // noop 211 + } 212 + 213 + const error = jsonError ?? textError; 214 + let finalError = error; 215 + 216 + for (const fn of interceptors.error.fns) { 217 + if (fn) { 218 + finalError = (await fn(error, response, request, opts)) as string; 219 + } 220 + } 221 + 222 + finalError = finalError || ({} as string); 223 + 224 + if (opts.throwOnError) { 225 + throw finalError; 226 + } 227 + 228 + // TODO: we probably want to return error and improve types 229 + return opts.responseStyle === 'data' 230 + ? undefined 231 + : { 232 + error: finalError, 233 + ...result, 234 + }; 235 + }; 236 + 237 + const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 238 + request({ ...options, method }); 239 + 240 + const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 241 + const { opts, url } = await beforeRequest(options); 242 + return createSseClient({ 243 + ...opts, 244 + body: opts.body as BodyInit | null | undefined, 245 + headers: opts.headers as unknown as Record<string, string>, 246 + method, 247 + onRequest: async (url, init) => { 248 + let request = new Request(url, init); 249 + for (const fn of interceptors.request.fns) { 250 + if (fn) { 251 + request = await fn(request, opts); 252 + } 253 + } 254 + return request; 255 + }, 256 + serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined, 257 + url, 258 + }); 259 + }; 260 + 261 + return { 262 + buildUrl, 263 + connect: makeMethodFn('CONNECT'), 264 + delete: makeMethodFn('DELETE'), 265 + get: makeMethodFn('GET'), 266 + getConfig, 267 + head: makeMethodFn('HEAD'), 268 + interceptors, 269 + options: makeMethodFn('OPTIONS'), 270 + patch: makeMethodFn('PATCH'), 271 + post: makeMethodFn('POST'), 272 + put: makeMethodFn('PUT'), 273 + request, 274 + setConfig, 275 + sse: { 276 + connect: makeSseFn('CONNECT'), 277 + delete: makeSseFn('DELETE'), 278 + get: makeSseFn('GET'), 279 + head: makeSseFn('HEAD'), 280 + options: makeSseFn('OPTIONS'), 281 + patch: makeSseFn('PATCH'), 282 + post: makeSseFn('POST'), 283 + put: makeSseFn('PUT'), 284 + trace: makeSseFn('TRACE'), 285 + }, 286 + trace: makeMethodFn('TRACE'), 287 + } as Client; 288 + };
+25
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 + export { createClient } from './client.gen'; 13 + export type { 14 + Client, 15 + ClientOptions, 16 + Config, 17 + CreateClientConfig, 18 + Options, 19 + RequestOptions, 20 + RequestResult, 21 + ResolvedRequestOptions, 22 + ResponseStyle, 23 + TDataShape, 24 + } from './types.gen'; 25 + export { createConfig, mergeHeaders } from './utils.gen';
+214
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth } from '../core/auth.gen'; 4 + import type { 5 + ServerSentEventsOptions, 6 + ServerSentEventsResult, 7 + } from '../core/serverSentEvents.gen'; 8 + import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen'; 9 + import type { Middleware } from './utils.gen'; 10 + 11 + export type ResponseStyle = 'data' | 'fields'; 12 + 13 + export interface Config<T extends ClientOptions = ClientOptions> 14 + extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig { 15 + /** 16 + * Base URL for all requests made by this client. 17 + */ 18 + baseUrl?: T['baseUrl']; 19 + /** 20 + * Fetch API implementation. You can use this option to provide a custom 21 + * fetch instance. 22 + * 23 + * @default globalThis.fetch 24 + */ 25 + fetch?: typeof fetch; 26 + /** 27 + * Please don't use the Fetch client for Next.js applications. The `next` 28 + * options won't have any effect. 29 + * 30 + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 31 + */ 32 + next?: never; 33 + /** 34 + * Return the response data parsed in a specified format. By default, `auto` 35 + * will infer the appropriate method from the `Content-Type` response header. 36 + * You can override this behavior with any of the {@link Body} methods. 37 + * Select `stream` if you don't want to parse response data at all. 38 + * 39 + * @default 'auto' 40 + */ 41 + parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 42 + /** 43 + * Should we return only data or multiple fields (data, error, response, etc.)? 44 + * 45 + * @default 'fields' 46 + */ 47 + responseStyle?: ResponseStyle; 48 + /** 49 + * Throw an error instead of returning it in the response? 50 + * 51 + * @default false 52 + */ 53 + throwOnError?: T['throwOnError']; 54 + } 55 + 56 + export interface RequestOptions< 57 + TData = unknown, 58 + TResponseStyle extends ResponseStyle = 'fields', 59 + ThrowOnError extends boolean = boolean, 60 + Url extends string = string, 61 + > 62 + extends 63 + Config<{ 64 + responseStyle: TResponseStyle; 65 + throwOnError: ThrowOnError; 66 + }>, 67 + Pick< 68 + ServerSentEventsOptions<TData>, 69 + | 'onRequest' 70 + | 'onSseError' 71 + | 'onSseEvent' 72 + | 'sseDefaultRetryDelay' 73 + | 'sseMaxRetryAttempts' 74 + | 'sseMaxRetryDelay' 75 + > { 76 + /** 77 + * Any body that you want to add to your request. 78 + * 79 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 80 + */ 81 + body?: unknown; 82 + path?: Record<string, unknown>; 83 + query?: Record<string, unknown>; 84 + /** 85 + * Security mechanism(s) to use for the request. 86 + */ 87 + security?: ReadonlyArray<Auth>; 88 + url: Url; 89 + } 90 + 91 + export interface ResolvedRequestOptions< 92 + TResponseStyle extends ResponseStyle = 'fields', 93 + ThrowOnError extends boolean = boolean, 94 + Url extends string = string, 95 + > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 96 + serializedBody?: string; 97 + } 98 + 99 + export type RequestResult< 100 + TData = unknown, 101 + TError = unknown, 102 + ThrowOnError extends boolean = boolean, 103 + TResponseStyle extends ResponseStyle = 'fields', 104 + > = ThrowOnError extends true 105 + ? Promise< 106 + TResponseStyle extends 'data' 107 + ? TData extends Record<string, unknown> 108 + ? TData[keyof TData] 109 + : TData 110 + : { 111 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 112 + request: Request; 113 + response: Response; 114 + } 115 + > 116 + : Promise< 117 + TResponseStyle extends 'data' 118 + ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined 119 + : ( 120 + | { 121 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 122 + error: undefined; 123 + } 124 + | { 125 + data: undefined; 126 + error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; 127 + } 128 + ) & { 129 + request: Request; 130 + response: Response; 131 + } 132 + >; 133 + 134 + export interface ClientOptions { 135 + baseUrl?: string; 136 + responseStyle?: ResponseStyle; 137 + throwOnError?: boolean; 138 + } 139 + 140 + type MethodFn = < 141 + TData = unknown, 142 + TError = unknown, 143 + ThrowOnError extends boolean = false, 144 + TResponseStyle extends ResponseStyle = 'fields', 145 + >( 146 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 147 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 148 + 149 + type SseFn = < 150 + TData = unknown, 151 + TError = unknown, 152 + ThrowOnError extends boolean = false, 153 + TResponseStyle extends ResponseStyle = 'fields', 154 + >( 155 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 156 + ) => Promise<ServerSentEventsResult<TData, TError>>; 157 + 158 + type RequestFn = < 159 + TData = unknown, 160 + TError = unknown, 161 + ThrowOnError extends boolean = false, 162 + TResponseStyle extends ResponseStyle = 'fields', 163 + >( 164 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 165 + Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>, 166 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 + 168 + type BuildUrlFn = < 169 + TData extends { 170 + body?: unknown; 171 + path?: Record<string, unknown>; 172 + query?: Record<string, unknown>; 173 + url: string; 174 + }, 175 + >( 176 + options: TData & Options<TData>, 177 + ) => string; 178 + 179 + export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { 180 + interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 181 + }; 182 + 183 + /** 184 + * The `createClientConfig()` function will be called on client initialization 185 + * and the returned object will become the client's initial configuration. 186 + * 187 + * You may want to initialize your client this way instead of calling 188 + * `setConfig()`. This is useful for example if you're using Next.js 189 + * to ensure your client always has the correct values. 190 + */ 191 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 192 + override?: Config<ClientOptions & T>, 193 + ) => Config<Required<ClientOptions> & T>; 194 + 195 + export interface TDataShape { 196 + body?: unknown; 197 + headers?: unknown; 198 + path?: unknown; 199 + query?: unknown; 200 + url: string; 201 + } 202 + 203 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 204 + 205 + export type Options< 206 + TData extends TDataShape = TDataShape, 207 + ThrowOnError extends boolean = boolean, 208 + TResponse = unknown, 209 + TResponseStyle extends ResponseStyle = 'fields', 210 + > = OmitKeys< 211 + RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 212 + 'body' | 'path' | 'query' | 'url' 213 + > & 214 + ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
+316
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 + import { 7 + serializeArrayParam, 8 + serializeObjectParam, 9 + serializePrimitiveParam, 10 + } from '../core/pathSerializer.gen'; 11 + import { getUrl } from '../core/utils.gen'; 12 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 + 14 + export const createQuerySerializer = <T = unknown>({ 15 + parameters = {}, 16 + ...args 17 + }: QuerySerializerOptions = {}) => { 18 + const querySerializer = (queryParams: T) => { 19 + const search: string[] = []; 20 + if (queryParams && typeof queryParams === 'object') { 21 + for (const name in queryParams) { 22 + const value = queryParams[name]; 23 + 24 + if (value === undefined || value === null) { 25 + continue; 26 + } 27 + 28 + const options = parameters[name] || args; 29 + 30 + if (Array.isArray(value)) { 31 + const serializedArray = serializeArrayParam({ 32 + allowReserved: options.allowReserved, 33 + explode: true, 34 + name, 35 + style: 'form', 36 + value, 37 + ...options.array, 38 + }); 39 + if (serializedArray) search.push(serializedArray); 40 + } else if (typeof value === 'object') { 41 + const serializedObject = serializeObjectParam({ 42 + allowReserved: options.allowReserved, 43 + explode: true, 44 + name, 45 + style: 'deepObject', 46 + value: value as Record<string, unknown>, 47 + ...options.object, 48 + }); 49 + if (serializedObject) search.push(serializedObject); 50 + } else { 51 + const serializedPrimitive = serializePrimitiveParam({ 52 + allowReserved: options.allowReserved, 53 + name, 54 + value: value as string, 55 + }); 56 + if (serializedPrimitive) search.push(serializedPrimitive); 57 + } 58 + } 59 + } 60 + return search.join('&'); 61 + }; 62 + return querySerializer; 63 + }; 64 + 65 + /** 66 + * Infers parseAs value from provided Content-Type header. 67 + */ 68 + export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => { 69 + if (!contentType) { 70 + // If no Content-Type header is provided, the best we can do is return the raw response body, 71 + // which is effectively the same as the 'stream' option. 72 + return 'stream'; 73 + } 74 + 75 + const cleanContent = contentType.split(';')[0]?.trim(); 76 + 77 + if (!cleanContent) { 78 + return; 79 + } 80 + 81 + if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) { 82 + return 'json'; 83 + } 84 + 85 + if (cleanContent === 'multipart/form-data') { 86 + return 'formData'; 87 + } 88 + 89 + if ( 90 + ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type)) 91 + ) { 92 + return 'blob'; 93 + } 94 + 95 + if (cleanContent.startsWith('text/')) { 96 + return 'text'; 97 + } 98 + 99 + return; 100 + }; 101 + 102 + const checkForExistence = ( 103 + options: Pick<RequestOptions, 'auth' | 'query'> & { 104 + headers: Headers; 105 + }, 106 + name?: string, 107 + ): boolean => { 108 + if (!name) { 109 + return false; 110 + } 111 + if ( 112 + options.headers.has(name) || 113 + options.query?.[name] || 114 + options.headers.get('Cookie')?.includes(`${name}=`) 115 + ) { 116 + return true; 117 + } 118 + return false; 119 + }; 120 + 121 + export const setAuthParams = async ({ 122 + security, 123 + ...options 124 + }: Pick<Required<RequestOptions>, 'security'> & 125 + Pick<RequestOptions, 'auth' | 'query'> & { 126 + headers: Headers; 127 + }) => { 128 + for (const auth of security) { 129 + if (checkForExistence(options, auth.name)) { 130 + continue; 131 + } 132 + 133 + const token = await getAuthToken(auth, options.auth); 134 + 135 + if (!token) { 136 + continue; 137 + } 138 + 139 + const name = auth.name ?? 'Authorization'; 140 + 141 + switch (auth.in) { 142 + case 'query': 143 + if (!options.query) { 144 + options.query = {}; 145 + } 146 + options.query[name] = token; 147 + break; 148 + case 'cookie': 149 + options.headers.append('Cookie', `${name}=${token}`); 150 + break; 151 + case 'header': 152 + default: 153 + options.headers.set(name, token); 154 + break; 155 + } 156 + } 157 + }; 158 + 159 + export const buildUrl: Client['buildUrl'] = (options) => 160 + getUrl({ 161 + baseUrl: options.baseUrl as string, 162 + path: options.path, 163 + query: options.query, 164 + querySerializer: 165 + typeof options.querySerializer === 'function' 166 + ? options.querySerializer 167 + : createQuerySerializer(options.querySerializer), 168 + url: options.url, 169 + }); 170 + 171 + export const mergeConfigs = (a: Config, b: Config): Config => { 172 + const config = { ...a, ...b }; 173 + if (config.baseUrl?.endsWith('/')) { 174 + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 175 + } 176 + config.headers = mergeHeaders(a.headers, b.headers); 177 + return config; 178 + }; 179 + 180 + const headersEntries = (headers: Headers): Array<[string, string]> => { 181 + const entries: Array<[string, string]> = []; 182 + headers.forEach((value, key) => { 183 + entries.push([key, value]); 184 + }); 185 + return entries; 186 + }; 187 + 188 + export const mergeHeaders = ( 189 + ...headers: Array<Required<Config>['headers'] | undefined> 190 + ): Headers => { 191 + const mergedHeaders = new Headers(); 192 + for (const header of headers) { 193 + if (!header) { 194 + continue; 195 + } 196 + 197 + const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header); 198 + 199 + for (const [key, value] of iterator) { 200 + if (value === null) { 201 + mergedHeaders.delete(key); 202 + } else if (Array.isArray(value)) { 203 + for (const v of value) { 204 + mergedHeaders.append(key, v as string); 205 + } 206 + } else if (value !== undefined) { 207 + // assume object headers are meant to be JSON stringified, i.e. their 208 + // content value in OpenAPI specification is 'application/json' 209 + mergedHeaders.set( 210 + key, 211 + typeof value === 'object' ? JSON.stringify(value) : (value as string), 212 + ); 213 + } 214 + } 215 + } 216 + return mergedHeaders; 217 + }; 218 + 219 + type ErrInterceptor<Err, Res, Req, Options> = ( 220 + error: Err, 221 + response: Res, 222 + request: Req, 223 + options: Options, 224 + ) => Err | Promise<Err>; 225 + 226 + type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; 227 + 228 + type ResInterceptor<Res, Req, Options> = ( 229 + response: Res, 230 + request: Req, 231 + options: Options, 232 + ) => Res | Promise<Res>; 233 + 234 + class Interceptors<Interceptor> { 235 + fns: Array<Interceptor | null> = []; 236 + 237 + clear(): void { 238 + this.fns = []; 239 + } 240 + 241 + eject(id: number | Interceptor): void { 242 + const index = this.getInterceptorIndex(id); 243 + if (this.fns[index]) { 244 + this.fns[index] = null; 245 + } 246 + } 247 + 248 + exists(id: number | Interceptor): boolean { 249 + const index = this.getInterceptorIndex(id); 250 + return Boolean(this.fns[index]); 251 + } 252 + 253 + getInterceptorIndex(id: number | Interceptor): number { 254 + if (typeof id === 'number') { 255 + return this.fns[id] ? id : -1; 256 + } 257 + return this.fns.indexOf(id); 258 + } 259 + 260 + update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false { 261 + const index = this.getInterceptorIndex(id); 262 + if (this.fns[index]) { 263 + this.fns[index] = fn; 264 + return id; 265 + } 266 + return false; 267 + } 268 + 269 + use(fn: Interceptor): number { 270 + this.fns.push(fn); 271 + return this.fns.length - 1; 272 + } 273 + } 274 + 275 + export interface Middleware<Req, Res, Err, Options> { 276 + error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 277 + request: Interceptors<ReqInterceptor<Req, Options>>; 278 + response: Interceptors<ResInterceptor<Res, Req, Options>>; 279 + } 280 + 281 + export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 282 + Req, 283 + Res, 284 + Err, 285 + Options 286 + > => ({ 287 + error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 288 + request: new Interceptors<ReqInterceptor<Req, Options>>(), 289 + response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 290 + }); 291 + 292 + const defaultQuerySerializer = createQuerySerializer({ 293 + allowReserved: false, 294 + array: { 295 + explode: true, 296 + style: 'form', 297 + }, 298 + object: { 299 + explode: true, 300 + style: 'deepObject', 301 + }, 302 + }); 303 + 304 + const defaultHeaders = { 305 + 'Content-Type': 'application/json', 306 + }; 307 + 308 + export const createConfig = <T extends ClientOptions = ClientOptions>( 309 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 310 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 311 + ...jsonBodySerializer, 312 + headers: defaultHeaders, 313 + parseAs: 'auto', 314 + querySerializer: defaultQuerySerializer, 315 + ...override, 316 + });
+41
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = typeof callback === 'function' ? await callback(auth) : callback; 27 + 28 + if (!token) { 29 + return; 30 + } 31 + 32 + if (auth.scheme === 'bearer') { 33 + return `Bearer ${token}`; 34 + } 35 + 36 + if (auth.scheme === 'basic') { 37 + return `Basic ${btoa(token)}`; 38 + } 39 + 40 + return token; 41 + };
+82
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen'; 4 + 5 + export type QuerySerializer = (query: Record<string, unknown>) => string; 6 + 7 + export type BodySerializer = (body: unknown) => unknown; 8 + 9 + type QuerySerializerOptionsObject = { 10 + allowReserved?: boolean; 11 + array?: Partial<SerializerOptions<ArrayStyle>>; 12 + object?: Partial<SerializerOptions<ObjectStyle>>; 13 + }; 14 + 15 + export type QuerySerializerOptions = QuerySerializerOptionsObject & { 16 + /** 17 + * Per-parameter serialization overrides. When provided, these settings 18 + * override the global array/object settings for specific parameter names. 19 + */ 20 + parameters?: Record<string, QuerySerializerOptionsObject>; 21 + }; 22 + 23 + const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => { 34 + if (typeof value === 'string') { 35 + data.append(key, value); 36 + } else { 37 + data.append(key, JSON.stringify(value)); 38 + } 39 + }; 40 + 41 + export const formDataBodySerializer = { 42 + bodySerializer: (body: unknown): FormData => { 43 + const data = new FormData(); 44 + 45 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 46 + if (value === undefined || value === null) { 47 + return; 48 + } 49 + if (Array.isArray(value)) { 50 + value.forEach((v) => serializeFormDataPair(data, key, v)); 51 + } else { 52 + serializeFormDataPair(data, key, value); 53 + } 54 + }); 55 + 56 + return data; 57 + }, 58 + }; 59 + 60 + export const jsonBodySerializer = { 61 + bodySerializer: (body: unknown): string => 62 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 63 + }; 64 + 65 + export const urlSearchParamsBodySerializer = { 66 + bodySerializer: (body: unknown): string => { 67 + const data = new URLSearchParams(); 68 + 69 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 70 + if (value === undefined || value === null) { 71 + return; 72 + } 73 + if (Array.isArray(value)) { 74 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 75 + } else { 76 + serializeUrlSearchParamsPair(data, key, value); 77 + } 78 + }); 79 + 80 + return data.toString(); 81 + }, 82 + };
+169
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + } 26 + | { 27 + /** 28 + * Field name. This is the name we want the user to see and use. 29 + */ 30 + key: string; 31 + /** 32 + * Field mapped name. This is the name we want to use in the request. 33 + * If `in` is omitted, `map` aliases `key` to the transport layer. 34 + */ 35 + map: Slot; 36 + }; 37 + 38 + export interface Fields { 39 + allowExtra?: Partial<Record<Slot, boolean>>; 40 + args?: ReadonlyArray<Field>; 41 + } 42 + 43 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 + 45 + const extraPrefixesMap: Record<string, Slot> = { 46 + $body_: 'body', 47 + $headers_: 'headers', 48 + $path_: 'path', 49 + $query_: 'query', 50 + }; 51 + const extraPrefixes = Object.entries(extraPrefixesMap); 52 + 53 + type KeyMap = Map< 54 + string, 55 + | { 56 + in: Slot; 57 + map?: string; 58 + } 59 + | { 60 + in?: never; 61 + map: Slot; 62 + } 63 + >; 64 + 65 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 + if (!map) { 67 + map = new Map(); 68 + } 69 + 70 + for (const config of fields) { 71 + if ('in' in config) { 72 + if (config.key) { 73 + map.set(config.key, { 74 + in: config.in, 75 + map: config.map, 76 + }); 77 + } 78 + } else if ('key' in config) { 79 + map.set(config.key, { 80 + map: config.map, 81 + }); 82 + } else if (config.args) { 83 + buildKeyMap(config.args, map); 84 + } 85 + } 86 + 87 + return map; 88 + }; 89 + 90 + interface Params { 91 + body: unknown; 92 + headers: Record<string, unknown>; 93 + path: Record<string, unknown>; 94 + query: Record<string, unknown>; 95 + } 96 + 97 + const stripEmptySlots = (params: Params) => { 98 + for (const [slot, value] of Object.entries(params)) { 99 + if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) { 100 + delete params[slot as Slot]; 101 + } 102 + } 103 + }; 104 + 105 + export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => { 106 + const params: Params = { 107 + body: {}, 108 + headers: {}, 109 + path: {}, 110 + query: {}, 111 + }; 112 + 113 + const map = buildKeyMap(fields); 114 + 115 + let config: FieldsConfig[number] | undefined; 116 + 117 + for (const [index, arg] of args.entries()) { 118 + if (fields[index]) { 119 + config = fields[index]; 120 + } 121 + 122 + if (!config) { 123 + continue; 124 + } 125 + 126 + if ('in' in config) { 127 + if (config.key) { 128 + const field = map.get(config.key)!; 129 + const name = field.map || config.key; 130 + if (field.in) { 131 + (params[field.in] as Record<string, unknown>)[name] = arg; 132 + } 133 + } else { 134 + params.body = arg; 135 + } 136 + } else { 137 + for (const [key, value] of Object.entries(arg ?? {})) { 138 + const field = map.get(key); 139 + 140 + if (field) { 141 + if (field.in) { 142 + const name = field.map || key; 143 + (params[field.in] as Record<string, unknown>)[name] = value; 144 + } else { 145 + params[field.map] = value; 146 + } 147 + } else { 148 + const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 149 + 150 + if (extra) { 151 + const [prefix, slot] = extra; 152 + (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value; 153 + } else if ('allowExtra' in config && config.allowExtra) { 154 + for (const [slot, allowed] of Object.entries(config.allowExtra)) { 155 + if (allowed) { 156 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 157 + break; 158 + } 159 + } 160 + } 161 + } 162 + } 163 + } 164 + } 165 + 166 + stripEmptySlots(params); 167 + 168 + return params; 169 + };
+171
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {} 4 + 5 + interface SerializePrimitiveOptions { 6 + allowReserved?: boolean; 7 + name: string; 8 + } 9 + 10 + export interface SerializerOptions<T> { 11 + /** 12 + * @default true 13 + */ 14 + explode: boolean; 15 + style: T; 16 + } 17 + 18 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 19 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 20 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 21 + export type ObjectStyle = 'form' | 'deepObject'; 22 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 23 + 24 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 25 + value: string; 26 + } 27 + 28 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 29 + switch (style) { 30 + case 'label': 31 + return '.'; 32 + case 'matrix': 33 + return ';'; 34 + case 'simple': 35 + return ','; 36 + default: 37 + return '&'; 38 + } 39 + }; 40 + 41 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 42 + switch (style) { 43 + case 'form': 44 + return ','; 45 + case 'pipeDelimited': 46 + return '|'; 47 + case 'spaceDelimited': 48 + return '%20'; 49 + default: 50 + return ','; 51 + } 52 + }; 53 + 54 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 55 + switch (style) { 56 + case 'label': 57 + return '.'; 58 + case 'matrix': 59 + return ';'; 60 + case 'simple': 61 + return ','; 62 + default: 63 + return '&'; 64 + } 65 + }; 66 + 67 + export const serializeArrayParam = ({ 68 + allowReserved, 69 + explode, 70 + name, 71 + style, 72 + value, 73 + }: SerializeOptions<ArraySeparatorStyle> & { 74 + value: unknown[]; 75 + }) => { 76 + if (!explode) { 77 + const joinedValues = ( 78 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 79 + ).join(separatorArrayNoExplode(style)); 80 + switch (style) { 81 + case 'label': 82 + return `.${joinedValues}`; 83 + case 'matrix': 84 + return `;${name}=${joinedValues}`; 85 + case 'simple': 86 + return joinedValues; 87 + default: 88 + return `${name}=${joinedValues}`; 89 + } 90 + } 91 + 92 + const separator = separatorArrayExplode(style); 93 + const joinedValues = value 94 + .map((v) => { 95 + if (style === 'label' || style === 'simple') { 96 + return allowReserved ? v : encodeURIComponent(v as string); 97 + } 98 + 99 + return serializePrimitiveParam({ 100 + allowReserved, 101 + name, 102 + value: v as string, 103 + }); 104 + }) 105 + .join(separator); 106 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 107 + }; 108 + 109 + export const serializePrimitiveParam = ({ 110 + allowReserved, 111 + name, 112 + value, 113 + }: SerializePrimitiveParam) => { 114 + if (value === undefined || value === null) { 115 + return ''; 116 + } 117 + 118 + if (typeof value === 'object') { 119 + throw new Error( 120 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 121 + ); 122 + } 123 + 124 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 125 + }; 126 + 127 + export const serializeObjectParam = ({ 128 + allowReserved, 129 + explode, 130 + name, 131 + style, 132 + value, 133 + valueOnly, 134 + }: SerializeOptions<ObjectSeparatorStyle> & { 135 + value: Record<string, unknown> | Date; 136 + valueOnly?: boolean; 137 + }) => { 138 + if (value instanceof Date) { 139 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 140 + } 141 + 142 + if (style !== 'deepObject' && !explode) { 143 + let values: string[] = []; 144 + Object.entries(value).forEach(([key, v]) => { 145 + values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]; 146 + }); 147 + const joinedValues = values.join(','); 148 + switch (style) { 149 + case 'form': 150 + return `${name}=${joinedValues}`; 151 + case 'label': 152 + return `.${joinedValues}`; 153 + case 'matrix': 154 + return `;${name}=${joinedValues}`; 155 + default: 156 + return joinedValues; 157 + } 158 + } 159 + 160 + const separator = separatorObjectExplode(style); 161 + const joinedValues = Object.entries(value) 162 + .map(([key, v]) => 163 + serializePrimitiveParam({ 164 + allowReserved, 165 + name: style === 'deepObject' ? `${name}[${key}]` : key, 166 + value: v as string, 167 + }), 168 + ) 169 + .join(separator); 170 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 171 + };
+117
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/queryKeySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * JSON-friendly union that mirrors what Pinia Colada can hash. 5 + */ 6 + export type JsonValue = 7 + | null 8 + | string 9 + | number 10 + | boolean 11 + | JsonValue[] 12 + | { [key: string]: JsonValue }; 13 + 14 + /** 15 + * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 + */ 17 + export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 19 + return undefined; 20 + } 21 + if (typeof value === 'bigint') { 22 + return value.toString(); 23 + } 24 + if (value instanceof Date) { 25 + return value.toISOString(); 26 + } 27 + return value; 28 + }; 29 + 30 + /** 31 + * Safely stringifies a value and parses it back into a JsonValue. 32 + */ 33 + export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 34 + try { 35 + const json = JSON.stringify(input, queryKeyJsonReplacer); 36 + if (json === undefined) { 37 + return undefined; 38 + } 39 + return JSON.parse(json) as JsonValue; 40 + } catch { 41 + return undefined; 42 + } 43 + }; 44 + 45 + /** 46 + * Detects plain objects (including objects with a null prototype). 47 + */ 48 + const isPlainObject = (value: unknown): value is Record<string, unknown> => { 49 + if (value === null || typeof value !== 'object') { 50 + return false; 51 + } 52 + const prototype = Object.getPrototypeOf(value as object); 53 + return prototype === Object.prototype || prototype === null; 54 + }; 55 + 56 + /** 57 + * Turns URLSearchParams into a sorted JSON object for deterministic keys. 58 + */ 59 + const serializeSearchParams = (params: URLSearchParams): JsonValue => { 60 + const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b)); 61 + const result: Record<string, JsonValue> = {}; 62 + 63 + for (const [key, value] of entries) { 64 + const existing = result[key]; 65 + if (existing === undefined) { 66 + result[key] = value; 67 + continue; 68 + } 69 + 70 + if (Array.isArray(existing)) { 71 + (existing as string[]).push(value); 72 + } else { 73 + result[key] = [existing, value]; 74 + } 75 + } 76 + 77 + return result; 78 + }; 79 + 80 + /** 81 + * Normalizes any accepted value into a JSON-friendly shape for query keys. 82 + */ 83 + export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => { 84 + if (value === null) { 85 + return null; 86 + } 87 + 88 + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 89 + return value; 90 + } 91 + 92 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 93 + return undefined; 94 + } 95 + 96 + if (typeof value === 'bigint') { 97 + return value.toString(); 98 + } 99 + 100 + if (value instanceof Date) { 101 + return value.toISOString(); 102 + } 103 + 104 + if (Array.isArray(value)) { 105 + return stringifyToJsonValue(value); 106 + } 107 + 108 + if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) { 109 + return serializeSearchParams(value); 110 + } 111 + 112 + if (isPlainObject(value)) { 113 + return stringifyToJsonValue(value); 114 + } 115 + 116 + return undefined; 117 + };
+243
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & 6 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 7 + /** 8 + * Fetch API implementation. You can use this option to provide a custom 9 + * fetch instance. 10 + * 11 + * @default globalThis.fetch 12 + */ 13 + fetch?: typeof fetch; 14 + /** 15 + * Implementing clients can call request interceptors inside this hook. 16 + */ 17 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 18 + /** 19 + * Callback invoked when a network or parsing error occurs during streaming. 20 + * 21 + * This option applies only if the endpoint returns a stream of events. 22 + * 23 + * @param error The error that occurred. 24 + */ 25 + onSseError?: (error: unknown) => void; 26 + /** 27 + * Callback invoked when an event is streamed from the server. 28 + * 29 + * This option applies only if the endpoint returns a stream of events. 30 + * 31 + * @param event Event streamed from the server. 32 + * @returns Nothing (void). 33 + */ 34 + onSseEvent?: (event: StreamEvent<TData>) => void; 35 + serializedBody?: RequestInit['body']; 36 + /** 37 + * Default retry delay in milliseconds. 38 + * 39 + * This option applies only if the endpoint returns a stream of events. 40 + * 41 + * @default 3000 42 + */ 43 + sseDefaultRetryDelay?: number; 44 + /** 45 + * Maximum number of retry attempts before giving up. 46 + */ 47 + sseMaxRetryAttempts?: number; 48 + /** 49 + * Maximum retry delay in milliseconds. 50 + * 51 + * Applies only when exponential backoff is used. 52 + * 53 + * This option applies only if the endpoint returns a stream of events. 54 + * 55 + * @default 30000 56 + */ 57 + sseMaxRetryDelay?: number; 58 + /** 59 + * Optional sleep function for retry backoff. 60 + * 61 + * Defaults to using `setTimeout`. 62 + */ 63 + sseSleepFn?: (ms: number) => Promise<void>; 64 + url: string; 65 + }; 66 + 67 + export interface StreamEvent<TData = unknown> { 68 + data: TData; 69 + event?: string; 70 + id?: string; 71 + retry?: number; 72 + } 73 + 74 + export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { 75 + stream: AsyncGenerator< 76 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 77 + TReturn, 78 + TNext 79 + >; 80 + }; 81 + 82 + export const createSseClient = <TData = unknown>({ 83 + onRequest, 84 + onSseError, 85 + onSseEvent, 86 + responseTransformer, 87 + responseValidator, 88 + sseDefaultRetryDelay, 89 + sseMaxRetryAttempts, 90 + sseMaxRetryDelay, 91 + sseSleepFn, 92 + url, 93 + ...options 94 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 95 + let lastEventId: string | undefined; 96 + 97 + const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 98 + 99 + const createStream = async function* () { 100 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 101 + let attempt = 0; 102 + const signal = options.signal ?? new AbortController().signal; 103 + 104 + while (true) { 105 + if (signal.aborted) break; 106 + 107 + attempt++; 108 + 109 + const headers = 110 + options.headers instanceof Headers 111 + ? options.headers 112 + : new Headers(options.headers as Record<string, string> | undefined); 113 + 114 + if (lastEventId !== undefined) { 115 + headers.set('Last-Event-ID', lastEventId); 116 + } 117 + 118 + try { 119 + const requestInit: RequestInit = { 120 + redirect: 'follow', 121 + ...options, 122 + body: options.serializedBody, 123 + headers, 124 + signal, 125 + }; 126 + let request = new Request(url, requestInit); 127 + if (onRequest) { 128 + request = await onRequest(url, requestInit); 129 + } 130 + // fetch must be assigned here, otherwise it would throw the error: 131 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 132 + const _fetch = options.fetch ?? globalThis.fetch; 133 + const response = await _fetch(request); 134 + 135 + if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`); 136 + 137 + if (!response.body) throw new Error('No body in SSE response'); 138 + 139 + const reader = response.body.pipeThrough(new TextDecoderStream()).getReader(); 140 + 141 + let buffer = ''; 142 + 143 + const abortHandler = () => { 144 + try { 145 + reader.cancel(); 146 + } catch { 147 + // noop 148 + } 149 + }; 150 + 151 + signal.addEventListener('abort', abortHandler); 152 + 153 + try { 154 + while (true) { 155 + const { done, value } = await reader.read(); 156 + if (done) break; 157 + buffer += value; 158 + // Normalize line endings: CRLF -> LF, then CR -> LF 159 + buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 160 + 161 + const chunks = buffer.split('\n\n'); 162 + buffer = chunks.pop() ?? ''; 163 + 164 + for (const chunk of chunks) { 165 + const lines = chunk.split('\n'); 166 + const dataLines: Array<string> = []; 167 + let eventName: string | undefined; 168 + 169 + for (const line of lines) { 170 + if (line.startsWith('data:')) { 171 + dataLines.push(line.replace(/^data:\s*/, '')); 172 + } else if (line.startsWith('event:')) { 173 + eventName = line.replace(/^event:\s*/, ''); 174 + } else if (line.startsWith('id:')) { 175 + lastEventId = line.replace(/^id:\s*/, ''); 176 + } else if (line.startsWith('retry:')) { 177 + const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10); 178 + if (!Number.isNaN(parsed)) { 179 + retryDelay = parsed; 180 + } 181 + } 182 + } 183 + 184 + let data: unknown; 185 + let parsedJson = false; 186 + 187 + if (dataLines.length) { 188 + const rawData = dataLines.join('\n'); 189 + try { 190 + data = JSON.parse(rawData); 191 + parsedJson = true; 192 + } catch { 193 + data = rawData; 194 + } 195 + } 196 + 197 + if (parsedJson) { 198 + if (responseValidator) { 199 + await responseValidator(data); 200 + } 201 + 202 + if (responseTransformer) { 203 + data = await responseTransformer(data); 204 + } 205 + } 206 + 207 + onSseEvent?.({ 208 + data, 209 + event: eventName, 210 + id: lastEventId, 211 + retry: retryDelay, 212 + }); 213 + 214 + if (dataLines.length) { 215 + yield data as any; 216 + } 217 + } 218 + } 219 + } finally { 220 + signal.removeEventListener('abort', abortHandler); 221 + reader.releaseLock(); 222 + } 223 + 224 + break; // exit loop on normal completion 225 + } catch (error) { 226 + // connection failed or aborted; retry after delay 227 + onSseError?.(error); 228 + 229 + if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) { 230 + break; // stop after firing error 231 + } 232 + 233 + // exponential backoff: double retry each attempt, cap at 30s 234 + const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000); 235 + await sleep(backoff); 236 + } 237 + } 238 + }; 239 + 240 + const stream = createStream(); 241 + 242 + return { stream }; 243 + };
+104
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen'; 5 + 6 + export type HttpMethod = 7 + | 'connect' 8 + | 'delete' 9 + | 'get' 10 + | 'head' 11 + | 'options' 12 + | 'patch' 13 + | 'post' 14 + | 'put' 15 + | 'trace'; 16 + 17 + export type Client< 18 + RequestFn = never, 19 + Config = unknown, 20 + MethodFn = never, 21 + BuildUrlFn = never, 22 + SseFn = never, 23 + > = { 24 + /** 25 + * Returns the final request URL. 26 + */ 27 + buildUrl: BuildUrlFn; 28 + getConfig: () => Config; 29 + request: RequestFn; 30 + setConfig: (config: Config) => Config; 31 + } & { 32 + [K in HttpMethod]: MethodFn; 33 + } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } }); 34 + 35 + export interface Config { 36 + /** 37 + * Auth token or a function returning auth token. The resolved value will be 38 + * added to the request payload as defined by its `security` array. 39 + */ 40 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 41 + /** 42 + * A function for serializing request body parameter. By default, 43 + * {@link JSON.stringify()} will be used. 44 + */ 45 + bodySerializer?: BodySerializer | null; 46 + /** 47 + * An object containing any HTTP headers that you want to pre-populate your 48 + * `Headers` object with. 49 + * 50 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 51 + */ 52 + headers?: 53 + | RequestInit['headers'] 54 + | Record< 55 + string, 56 + string | number | boolean | (string | number | boolean)[] | null | undefined | unknown 57 + >; 58 + /** 59 + * The request method. 60 + * 61 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 62 + */ 63 + method?: Uppercase<HttpMethod>; 64 + /** 65 + * A function for serializing request query parameters. By default, arrays 66 + * will be exploded in form style, objects will be exploded in deepObject 67 + * style, and reserved characters are percent-encoded. 68 + * 69 + * This method will have no effect if the native `paramsSerializer()` Axios 70 + * API function is used. 71 + * 72 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 73 + */ 74 + querySerializer?: QuerySerializer | QuerySerializerOptions; 75 + /** 76 + * A function validating request data. This is useful if you want to ensure 77 + * the request conforms to the desired shape, so it can be safely sent to 78 + * the server. 79 + */ 80 + requestValidator?: (data: unknown) => Promise<unknown>; 81 + /** 82 + * A function transforming response data before it's returned. This is useful 83 + * for post-processing data, e.g. converting ISO strings into Date objects. 84 + */ 85 + responseTransformer?: (data: unknown) => Promise<unknown>; 86 + /** 87 + * A function validating response data. This is useful if you want to ensure 88 + * the response conforms to the desired shape, so it can be safely passed to 89 + * the transformers and returned to the user. 90 + */ 91 + responseValidator?: (data: unknown) => Promise<unknown>; 92 + } 93 + 94 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 95 + ? true 96 + : [T] extends [never | undefined] 97 + ? [undefined] extends [T] 98 + ? false 99 + : true 100 + : false; 101 + 102 + export type OmitNever<T extends Record<string, unknown>> = { 103 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]; 104 + };
+140
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace(match, serializeArrayParam({ explode, name, style, value })); 48 + continue; 49 + } 50 + 51 + if (typeof value === 'object') { 52 + url = url.replace( 53 + match, 54 + serializeObjectParam({ 55 + explode, 56 + name, 57 + style, 58 + value: value as Record<string, unknown>, 59 + valueOnly: true, 60 + }), 61 + ); 62 + continue; 63 + } 64 + 65 + if (style === 'matrix') { 66 + url = url.replace( 67 + match, 68 + `;${serializePrimitiveParam({ 69 + name, 70 + value: value as string, 71 + })}`, 72 + ); 73 + continue; 74 + } 75 + 76 + const replaceValue = encodeURIComponent( 77 + style === 'label' ? `.${value as string}` : (value as string), 78 + ); 79 + url = url.replace(match, replaceValue); 80 + } 81 + } 82 + return url; 83 + }; 84 + 85 + export const getUrl = ({ 86 + baseUrl, 87 + path, 88 + query, 89 + querySerializer, 90 + url: _url, 91 + }: { 92 + baseUrl?: string; 93 + path?: Record<string, unknown>; 94 + query?: Record<string, unknown>; 95 + querySerializer: QuerySerializer; 96 + url: string; 97 + }) => { 98 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 99 + let url = (baseUrl ?? '') + pathUrl; 100 + if (path) { 101 + url = defaultPathSerializer({ path, url }); 102 + } 103 + let search = query ? querySerializer(query) : ''; 104 + if (search.startsWith('?')) { 105 + search = search.substring(1); 106 + } 107 + if (search) { 108 + url += `?${search}`; 109 + } 110 + return url; 111 + }; 112 + 113 + export function getValidRequestBody(options: { 114 + body?: unknown; 115 + bodySerializer?: BodySerializer | null; 116 + serializedBody?: unknown; 117 + }) { 118 + const hasBody = options.body !== undefined; 119 + const isSerializedBody = hasBody && options.bodySerializer; 120 + 121 + if (isSerializedBody) { 122 + if ('serializedBody' in options) { 123 + const hasSerializedBody = 124 + options.serializedBody !== undefined && options.serializedBody !== ''; 125 + 126 + return hasSerializedBody ? options.serializedBody : null; 127 + } 128 + 129 + // not all clients implement a serializedBody property (i.e. client-axios) 130 + return options.body !== '' ? options.body : null; 131 + } 132 + 133 + // plain/text body 134 + if (hasBody) { 135 + return options.body; 136 + } 137 + 138 + // no body was provided 139 + return undefined; 140 + }
+4
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export { callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexTypes, deleteCallWithoutParametersAndResponse, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, fooWow, getCallWithoutParametersAndResponse, headCallWithoutParametersAndResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, optionsCallWithoutParametersAndResponse, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionBody, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, serviceWithEmptyTag, testErrorCode, types } from './sdk.gen'; 4 + export type { ArrayWithArray, ArrayWithBooleans, ArrayWithNumbers, ArrayWithProperties, ArrayWithReferences, ArrayWithStrings, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponse, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesError, CallWithResponsesErrors, CallWithResponsesResponse, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, ClientOptions, CollectionFormatData, CommentWithBackticks, CommentWithBackticksAndQuotes, CommentWithBreaks, CommentWithExpressionPlaceholders, CommentWithQuotes, CommentWithReservedCharacters, CommentWithSlashes, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponse, ComplexTypesResponses, Date, Default, DeleteCallWithoutParametersAndResponseData, DictionaryWithArray, DictionaryWithDictionary, DictionaryWithProperties, DictionaryWithReference, DictionaryWithString, DummyAData, DummyAResponses, DummyBData, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, EnumFromDescription, EnumWithExtensions, EnumWithNumbers, EnumWithStrings, ExternalRefA, ExternalRefB, ExternalSharedModel, FailureFailure, FooWowData, FooWowResponses, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ModelThatExtends, ModelThatExtendsExtends, ModelWithArray, ModelWithBoolean, ModelWithCircularReference, ModelWithDictionary, ModelWithDuplicateImports, ModelWithDuplicateProperties, ModelWithEnum, ModelWithEnumFromDescription, ModelWithInteger, ModelWithNestedEnums, ModelWithNestedProperties, ModelWithNullableString, ModelWithOrderedProperties, ModelWithPattern, ModelWithPatternWritable, ModelWithProperties, ModelWithPropertiesWritable, ModelWithReference, ModelWithReferenceWritable, ModelWithString, ModelWithStringError, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Responses, NonAsciiStringæøåÆøÅöôêÊ字符串, OptionsCallWithoutParametersAndResponseData, ParameterActivityParams, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyResponses, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, ResponsePostActivityResponse, ServiceWithEmptyTagData, SimpleBoolean, SimpleFile, SimpleInteger, SimpleReference, SimpleString, SimpleStringWithPattern, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponse, TypesResponses } from './types.gen';
+127
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Client, Options as Options2, TDataShape } from './client'; 4 + import { client } from './client.gen'; 5 + import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, DeleteCallWithoutParametersAndResponseData, DummyAData, DummyAResponses, DummyBData, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, FooWowData, FooWowResponses, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponses, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, ServiceWithEmptyTagData, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponses } from './types.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const serviceWithEmptyTag = <ThrowOnError extends boolean = false>(options?: Options<ServiceWithEmptyTagData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 22 + 23 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => (options?.client ?? client).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 24 + 25 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => (options?.client ?? client).put<FooWowResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 26 + 27 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 28 + 29 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 30 + 31 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).head<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 32 + 33 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).options<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 34 + 35 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).patch<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 36 + 37 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 38 + 39 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 40 + 41 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/descriptions/', ...options }); 42 + 43 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); 44 + 45 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 46 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 47 + ...options, 48 + headers: { 49 + 'Content-Type': 'application/json', 50 + ...options.headers 51 + } 52 + }); 53 + 54 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithDefaultParametersData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ 55 + querySerializer: { parameters: { parameterModel: { object: { explode: false, style: 'form' } } } }, 56 + url: '/api/v{api-version}/defaults', 57 + ...options 58 + }); 59 + 60 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 61 + 62 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 63 + 64 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 65 + 66 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 67 + 68 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 69 + 70 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 71 + 72 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no-content', ...options }); 73 + 74 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); 75 + 76 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => (options?.client ?? client).get<DummyAResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/a', ...options }); 77 + 78 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => (options?.client ?? client).get<DummyBResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/b', ...options }); 79 + 80 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 81 + 82 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => (options?.client ?? client).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 83 + 84 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => (options?.client ?? client).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 85 + 86 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ 87 + querySerializer: { parameters: { 88 + parameterArrayCSV: { array: { explode: false } }, 89 + parameterArraySSV: { array: { explode: false } }, 90 + parameterArrayTSV: { array: { explode: false } }, 91 + parameterArrayPipes: { array: { explode: false } } 92 + } }, 93 + url: '/api/v{api-version}/collectionFormat', 94 + ...options 95 + }); 96 + 97 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => (options.client ?? client).get<TypesResponses, unknown, ThrowOnError>({ 98 + querySerializer: { parameters: { parameterArray: { array: { explode: false } }, parameterDictionary: { object: { explode: false, style: 'form' } } } }, 99 + url: '/api/v{api-version}/types', 100 + ...options 101 + }); 102 + 103 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => (options.client ?? client).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 104 + querySerializer: { parameters: { parameterObject: { object: { explode: false, style: 'form' } }, parameterReference: { object: { explode: false, style: 'form' } } } }, 105 + url: '/api/v{api-version}/complex', 106 + ...options 107 + }); 108 + 109 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => (options?.client ?? client).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ url: '/api/v{api-version}/header', ...options }); 110 + 111 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => (options.client ?? client).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ url: '/api/v{api-version}/error', ...options }); 112 + 113 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => (options.client ?? client).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); 114 + 115 + /** 116 + * Body should not be unknown 117 + * 118 + * Body should not be unknown 119 + */ 120 + export const postApiVbyApiVersionBody = <ThrowOnError extends boolean = false>(options: Options<PostApiVbyApiVersionBodyData, ThrowOnError>) => (options.client ?? client).post<PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors, ThrowOnError>({ 121 + url: '/api/v{api-version}/body', 122 + ...options, 123 + headers: { 124 + 'Content-Type': 'application/json', 125 + ...options.headers 126 + } 127 + });
+1190
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useMutation/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type ClientOptions = { 4 + baseUrl: 'http://localhost:3000/base' | (string & {}); 5 + }; 6 + 7 + export type ExternalRefA = ExternalSharedModel; 8 + 9 + export type ExternalRefB = ExternalSharedModel; 10 + 11 + /** 12 + * Testing multiline comments in string: First line 13 + * Second line 14 + * 15 + * Fourth line 16 + */ 17 + export type CommentWithBreaks = number; 18 + 19 + /** 20 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 21 + */ 22 + export type CommentWithBackticks = number; 23 + 24 + /** 25 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 26 + */ 27 + export type CommentWithBackticksAndQuotes = number; 28 + 29 + /** 30 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 31 + */ 32 + export type CommentWithSlashes = number; 33 + 34 + /** 35 + * Testing expression placeholders in string: ${expression} should work 36 + */ 37 + export type CommentWithExpressionPlaceholders = number; 38 + 39 + /** 40 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 41 + */ 42 + export type CommentWithQuotes = number; 43 + 44 + /** 45 + * Testing reserved characters in string: * inline * and ** inline ** should work 46 + */ 47 + export type CommentWithReservedCharacters = number; 48 + 49 + /** 50 + * This is a simple number 51 + */ 52 + export type SimpleInteger = number; 53 + 54 + /** 55 + * This is a simple boolean 56 + */ 57 + export type SimpleBoolean = boolean; 58 + 59 + /** 60 + * This is a simple string 61 + */ 62 + export type SimpleString = string; 63 + 64 + /** 65 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 66 + */ 67 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 68 + 69 + /** 70 + * This is a simple file 71 + */ 72 + export type SimpleFile = Blob | File; 73 + 74 + export type SimpleReference = ModelWithString; 75 + 76 + /** 77 + * This is a simple string 78 + */ 79 + export type SimpleStringWithPattern = string; 80 + 81 + /** 82 + * This is a simple enum with strings 83 + */ 84 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | '\'Single Quote\'' | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 85 + 86 + /** 87 + * This is a simple enum with numbers 88 + */ 89 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 90 + 91 + /** 92 + * Success=1,Warning=2,Error=3 93 + */ 94 + export type EnumFromDescription = number; 95 + 96 + /** 97 + * This is a simple enum with numbers 98 + */ 99 + export type EnumWithExtensions = 200 | 400 | 500; 100 + 101 + /** 102 + * This is a simple array with numbers 103 + */ 104 + export type ArrayWithNumbers = Array<number>; 105 + 106 + /** 107 + * This is a simple array with booleans 108 + */ 109 + export type ArrayWithBooleans = Array<boolean>; 110 + 111 + /** 112 + * This is a simple array with strings 113 + */ 114 + export type ArrayWithStrings = Array<string>; 115 + 116 + /** 117 + * This is a simple array with references 118 + */ 119 + export type ArrayWithReferences = Array<ModelWithString>; 120 + 121 + /** 122 + * This is a simple array containing an array 123 + */ 124 + export type ArrayWithArray = Array<Array<ModelWithString>>; 125 + 126 + /** 127 + * This is a simple array with properties 128 + */ 129 + export type ArrayWithProperties = Array<{ 130 + foo?: string; 131 + bar?: string; 132 + }>; 133 + 134 + /** 135 + * This is a string dictionary 136 + */ 137 + export type DictionaryWithString = { 138 + [key: string]: string; 139 + }; 140 + 141 + /** 142 + * This is a string reference 143 + */ 144 + export type DictionaryWithReference = { 145 + [key: string]: ModelWithString; 146 + }; 147 + 148 + /** 149 + * This is a complex dictionary 150 + */ 151 + export type DictionaryWithArray = { 152 + [key: string]: Array<ModelWithString>; 153 + }; 154 + 155 + /** 156 + * This is a string dictionary 157 + */ 158 + export type DictionaryWithDictionary = { 159 + [key: string]: { 160 + [key: string]: string; 161 + }; 162 + }; 163 + 164 + /** 165 + * This is a complex dictionary 166 + */ 167 + export type DictionaryWithProperties = { 168 + [key: string]: { 169 + foo?: string; 170 + bar?: string; 171 + }; 172 + }; 173 + 174 + /** 175 + * This is a type-only model that defines Date as a string 176 + */ 177 + export type Date = string; 178 + 179 + /** 180 + * This is a model with one number property 181 + */ 182 + export type ModelWithInteger = { 183 + /** 184 + * This is a simple number property 185 + */ 186 + prop?: number; 187 + }; 188 + 189 + /** 190 + * This is a model with one boolean property 191 + */ 192 + export type ModelWithBoolean = { 193 + /** 194 + * This is a simple boolean property 195 + */ 196 + prop?: boolean; 197 + }; 198 + 199 + /** 200 + * This is a model with one string property 201 + */ 202 + export type ModelWithString = { 203 + /** 204 + * This is a simple string property 205 + */ 206 + prop?: string; 207 + }; 208 + 209 + /** 210 + * This is a model with one string property 211 + */ 212 + export type ModelWithStringError = { 213 + /** 214 + * This is a simple string property 215 + */ 216 + prop?: string; 217 + }; 218 + 219 + /** 220 + * This is a model with one string property 221 + */ 222 + export type ModelWithNullableString = { 223 + /** 224 + * This is a simple string property 225 + */ 226 + nullableProp?: string | null; 227 + /** 228 + * This is a simple string property 229 + */ 230 + nullableRequiredProp: string | null; 231 + }; 232 + 233 + /** 234 + * This is a model with one enum 235 + */ 236 + export type ModelWithEnum = { 237 + /** 238 + * This is a simple enum with strings 239 + */ 240 + test?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 241 + /** 242 + * These are the HTTP error code enums 243 + */ 244 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 245 + /** 246 + * Simple boolean enum 247 + */ 248 + bool?: true; 249 + }; 250 + 251 + /** 252 + * This is a model with one enum 253 + */ 254 + export type ModelWithEnumFromDescription = { 255 + /** 256 + * Success=1,Warning=2,Error=3 257 + */ 258 + test?: number; 259 + }; 260 + 261 + /** 262 + * This is a model with nested enums 263 + */ 264 + export type ModelWithNestedEnums = { 265 + dictionaryWithEnum?: { 266 + [key: string]: 'Success' | 'Warning' | 'Error'; 267 + }; 268 + dictionaryWithEnumFromDescription?: { 269 + [key: string]: number; 270 + }; 271 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 272 + arrayWithDescription?: Array<number>; 273 + }; 274 + 275 + /** 276 + * This is a model with one property containing a reference 277 + */ 278 + export type ModelWithReference = { 279 + prop?: ModelWithProperties; 280 + }; 281 + 282 + /** 283 + * This is a model with one property containing an array 284 + */ 285 + export type ModelWithArray = { 286 + prop?: Array<ModelWithString>; 287 + propWithFile?: Array<Blob | File>; 288 + propWithNumber?: Array<number>; 289 + }; 290 + 291 + /** 292 + * This is a model with one property containing a dictionary 293 + */ 294 + export type ModelWithDictionary = { 295 + prop?: { 296 + [key: string]: string; 297 + }; 298 + }; 299 + 300 + /** 301 + * This is a model with one property containing a circular reference 302 + */ 303 + export type ModelWithCircularReference = { 304 + prop?: ModelWithCircularReference; 305 + }; 306 + 307 + /** 308 + * This is a model with one nested property 309 + */ 310 + export type ModelWithProperties = { 311 + required: string; 312 + readonly requiredAndReadOnly: string; 313 + string?: string; 314 + number?: number; 315 + boolean?: boolean; 316 + reference?: ModelWithString; 317 + 'property with space'?: string; 318 + default?: string; 319 + try?: string; 320 + readonly '@namespace.string'?: string; 321 + readonly '@namespace.integer'?: number; 322 + }; 323 + 324 + /** 325 + * This is a model with one nested property 326 + */ 327 + export type ModelWithNestedProperties = { 328 + readonly first: { 329 + readonly second: { 330 + readonly third: string; 331 + }; 332 + }; 333 + }; 334 + 335 + /** 336 + * This is a model with duplicated properties 337 + */ 338 + export type ModelWithDuplicateProperties = { 339 + prop?: ModelWithString; 340 + }; 341 + 342 + /** 343 + * This is a model with ordered properties 344 + */ 345 + export type ModelWithOrderedProperties = { 346 + zebra?: string; 347 + apple?: string; 348 + hawaii?: string; 349 + }; 350 + 351 + /** 352 + * This is a model with duplicated imports 353 + */ 354 + export type ModelWithDuplicateImports = { 355 + propA?: ModelWithString; 356 + propB?: ModelWithString; 357 + propC?: ModelWithString; 358 + }; 359 + 360 + /** 361 + * This is a model that extends another model 362 + */ 363 + export type ModelThatExtends = ModelWithString & { 364 + propExtendsA?: string; 365 + propExtendsB?: ModelWithString; 366 + }; 367 + 368 + /** 369 + * This is a model that extends another model 370 + */ 371 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 372 + propExtendsC?: string; 373 + propExtendsD?: ModelWithString; 374 + }; 375 + 376 + export type Default = { 377 + name?: string; 378 + }; 379 + 380 + /** 381 + * This is a model that contains a some patterns 382 + */ 383 + export type ModelWithPattern = { 384 + key: string; 385 + name: string; 386 + readonly enabled?: boolean; 387 + readonly modified?: string; 388 + id?: string; 389 + text?: string; 390 + patternWithSingleQuotes?: string; 391 + patternWithNewline?: string; 392 + patternWithBacktick?: string; 393 + patternWithUnicode?: string; 394 + }; 395 + 396 + export type ParameterActivityParams = { 397 + description?: string; 398 + graduate_id?: number; 399 + organization_id?: number; 400 + parent_activity?: number; 401 + post_id?: number; 402 + }; 403 + 404 + export type ResponsePostActivityResponse = { 405 + description?: string; 406 + graduate_id?: number; 407 + organization_id?: number; 408 + parent_activity_id?: number; 409 + post_id?: number; 410 + }; 411 + 412 + export type FailureFailure = { 413 + error?: string; 414 + message?: string; 415 + reference_code?: string; 416 + }; 417 + 418 + export type ExternalSharedModel = { 419 + id: string; 420 + name?: string; 421 + }; 422 + 423 + /** 424 + * This is a model with one property containing a reference 425 + */ 426 + export type ModelWithReferenceWritable = { 427 + prop?: ModelWithPropertiesWritable; 428 + }; 429 + 430 + /** 431 + * This is a model with one nested property 432 + */ 433 + export type ModelWithPropertiesWritable = { 434 + required: string; 435 + string?: string; 436 + number?: number; 437 + boolean?: boolean; 438 + reference?: ModelWithString; 439 + 'property with space'?: string; 440 + default?: string; 441 + try?: string; 442 + }; 443 + 444 + /** 445 + * This is a model that contains a some patterns 446 + */ 447 + export type ModelWithPatternWritable = { 448 + key: string; 449 + name: string; 450 + id?: string; 451 + text?: string; 452 + patternWithSingleQuotes?: string; 453 + patternWithNewline?: string; 454 + patternWithBacktick?: string; 455 + patternWithUnicode?: string; 456 + }; 457 + 458 + export type ServiceWithEmptyTagData = { 459 + body?: never; 460 + path?: never; 461 + query?: never; 462 + url: '/api/v{api-version}/no+tag'; 463 + }; 464 + 465 + export type PatchApiVbyApiVersionNoTagData = { 466 + body?: never; 467 + path?: never; 468 + query?: never; 469 + url: '/api/v{api-version}/no+tag'; 470 + }; 471 + 472 + export type PatchApiVbyApiVersionNoTagResponses = { 473 + /** 474 + * OK 475 + */ 476 + default: unknown; 477 + }; 478 + 479 + export type FooWowData = { 480 + body?: never; 481 + path?: never; 482 + query?: never; 483 + url: '/api/v{api-version}/no+tag'; 484 + }; 485 + 486 + export type FooWowResponses = { 487 + /** 488 + * OK 489 + */ 490 + default: unknown; 491 + }; 492 + 493 + export type DeleteCallWithoutParametersAndResponseData = { 494 + body?: never; 495 + path?: never; 496 + query?: never; 497 + url: '/api/v{api-version}/simple'; 498 + }; 499 + 500 + export type GetCallWithoutParametersAndResponseData = { 501 + body?: never; 502 + path?: never; 503 + query?: never; 504 + url: '/api/v{api-version}/simple'; 505 + }; 506 + 507 + export type HeadCallWithoutParametersAndResponseData = { 508 + body?: never; 509 + path?: never; 510 + query?: never; 511 + url: '/api/v{api-version}/simple'; 512 + }; 513 + 514 + export type OptionsCallWithoutParametersAndResponseData = { 515 + body?: never; 516 + path?: never; 517 + query?: never; 518 + url: '/api/v{api-version}/simple'; 519 + }; 520 + 521 + export type PatchCallWithoutParametersAndResponseData = { 522 + body?: never; 523 + path?: never; 524 + query?: never; 525 + url: '/api/v{api-version}/simple'; 526 + }; 527 + 528 + export type PostCallWithoutParametersAndResponseData = { 529 + body?: never; 530 + path?: never; 531 + query?: never; 532 + url: '/api/v{api-version}/simple'; 533 + }; 534 + 535 + export type PutCallWithoutParametersAndResponseData = { 536 + body?: never; 537 + path?: never; 538 + query?: never; 539 + url: '/api/v{api-version}/simple'; 540 + }; 541 + 542 + export type CallWithDescriptionsData = { 543 + body?: never; 544 + path?: never; 545 + query?: { 546 + /** 547 + * Testing multiline comments in string: First line 548 + * Second line 549 + * 550 + * Fourth line 551 + */ 552 + parameterWithBreaks?: string; 553 + /** 554 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 555 + */ 556 + parameterWithBackticks?: string; 557 + /** 558 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 559 + */ 560 + parameterWithSlashes?: string; 561 + /** 562 + * Testing expression placeholders in string: ${expression} should work 563 + */ 564 + parameterWithExpressionPlaceholders?: string; 565 + /** 566 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 567 + */ 568 + parameterWithQuotes?: string; 569 + /** 570 + * Testing reserved characters in string: * inline * and ** inline ** should work 571 + */ 572 + parameterWithReservedCharacters?: string; 573 + }; 574 + url: '/api/v{api-version}/descriptions/'; 575 + }; 576 + 577 + export type CallWithParametersData = { 578 + body?: never; 579 + headers: { 580 + /** 581 + * This is the parameter that goes into the header 582 + */ 583 + parameterHeader: string; 584 + }; 585 + path: { 586 + /** 587 + * This is the parameter that goes into the path 588 + */ 589 + parameterPath: string; 590 + /** 591 + * api-version should be required in standalone clients 592 + */ 593 + 'api-version': string; 594 + }; 595 + query: { 596 + /** 597 + * This is the parameter that goes into the query params 598 + */ 599 + parameterQuery: string; 600 + }; 601 + url: '/api/v{api-version}/parameters/{parameterPath}'; 602 + }; 603 + 604 + export type CallWithWeirdParameterNamesData = { 605 + /** 606 + * This is the parameter that is sent as request body 607 + */ 608 + body: string; 609 + headers: { 610 + /** 611 + * This is the parameter that goes into the request header 612 + */ 613 + 'parameter.header': string; 614 + }; 615 + path: { 616 + /** 617 + * This is the parameter that goes into the path 618 + */ 619 + 'parameter.path.1'?: string; 620 + /** 621 + * This is the parameter that goes into the path 622 + */ 623 + 'parameter-path-2'?: string; 624 + /** 625 + * This is the parameter that goes into the path 626 + */ 627 + 'PARAMETER-PATH-3'?: string; 628 + /** 629 + * api-version should be required in standalone clients 630 + */ 631 + 'api-version': string; 632 + }; 633 + query: { 634 + /** 635 + * This is the parameter with a reserved keyword 636 + */ 637 + default?: string; 638 + /** 639 + * This is the parameter that goes into the request query params 640 + */ 641 + 'parameter-query': string; 642 + }; 643 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 644 + }; 645 + 646 + export type CallWithDefaultParametersData = { 647 + body?: never; 648 + path?: never; 649 + query: { 650 + /** 651 + * This is a simple string with default value 652 + */ 653 + parameterString: string; 654 + /** 655 + * This is a simple number with default value 656 + */ 657 + parameterNumber: number; 658 + /** 659 + * This is a simple boolean with default value 660 + */ 661 + parameterBoolean: boolean; 662 + /** 663 + * This is a simple enum with default value 664 + */ 665 + parameterEnum: 'Success' | 'Warning' | 'Error'; 666 + /** 667 + * This is a model with one string property 668 + */ 669 + parameterModel: { 670 + /** 671 + * This is a simple string property 672 + */ 673 + prop?: string; 674 + }; 675 + }; 676 + url: '/api/v{api-version}/defaults'; 677 + }; 678 + 679 + export type CallWithDefaultOptionalParametersData = { 680 + body?: never; 681 + path?: never; 682 + query?: { 683 + /** 684 + * This is a simple string that is optional with default value 685 + */ 686 + parameterString?: string; 687 + /** 688 + * This is a simple number that is optional with default value 689 + */ 690 + parameterNumber?: number; 691 + /** 692 + * This is a simple boolean that is optional with default value 693 + */ 694 + parameterBoolean?: boolean; 695 + /** 696 + * This is a simple enum that is optional with default value 697 + */ 698 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 699 + }; 700 + url: '/api/v{api-version}/defaults'; 701 + }; 702 + 703 + export type CallToTestOrderOfParamsData = { 704 + body?: never; 705 + path?: never; 706 + query: { 707 + /** 708 + * This is a optional string with default 709 + */ 710 + parameterOptionalStringWithDefault?: string; 711 + /** 712 + * This is a optional string with empty default 713 + */ 714 + parameterOptionalStringWithEmptyDefault?: string; 715 + /** 716 + * This is a optional string with no default 717 + */ 718 + parameterOptionalStringWithNoDefault?: string; 719 + /** 720 + * This is a string with default 721 + */ 722 + parameterStringWithDefault: string; 723 + /** 724 + * This is a string with empty default 725 + */ 726 + parameterStringWithEmptyDefault: string; 727 + /** 728 + * This is a string with no default 729 + */ 730 + parameterStringWithNoDefault: string; 731 + /** 732 + * This is a string that can be null with no default 733 + */ 734 + parameterStringNullableWithNoDefault?: string | null; 735 + /** 736 + * This is a string that can be null with default 737 + */ 738 + parameterStringNullableWithDefault?: string | null; 739 + }; 740 + url: '/api/v{api-version}/defaults'; 741 + }; 742 + 743 + export type DuplicateNameData = { 744 + body?: never; 745 + path?: never; 746 + query?: never; 747 + url: '/api/v{api-version}/duplicate'; 748 + }; 749 + 750 + export type DuplicateName2Data = { 751 + body?: never; 752 + path?: never; 753 + query?: never; 754 + url: '/api/v{api-version}/duplicate'; 755 + }; 756 + 757 + export type DuplicateName3Data = { 758 + body?: never; 759 + path?: never; 760 + query?: never; 761 + url: '/api/v{api-version}/duplicate'; 762 + }; 763 + 764 + export type DuplicateName4Data = { 765 + body?: never; 766 + path?: never; 767 + query?: never; 768 + url: '/api/v{api-version}/duplicate'; 769 + }; 770 + 771 + export type CallWithNoContentResponseData = { 772 + body?: never; 773 + path?: never; 774 + query?: never; 775 + url: '/api/v{api-version}/no-content'; 776 + }; 777 + 778 + export type CallWithNoContentResponseResponses = { 779 + /** 780 + * Success 781 + */ 782 + 204: unknown; 783 + }; 784 + 785 + export type CallWithResponseAndNoContentResponseData = { 786 + body?: never; 787 + path?: never; 788 + query?: never; 789 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 790 + }; 791 + 792 + export type CallWithResponseAndNoContentResponseResponses = { 793 + /** 794 + * Response is a simple number 795 + */ 796 + 200: number; 797 + /** 798 + * Success 799 + */ 800 + 204: unknown; 801 + }; 802 + 803 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 804 + 805 + export type DummyAData = { 806 + body?: never; 807 + path?: never; 808 + query?: never; 809 + url: '/api/v{api-version}/multiple-tags/a'; 810 + }; 811 + 812 + export type DummyAResponses = { 813 + /** 814 + * Success 815 + */ 816 + 204: unknown; 817 + }; 818 + 819 + export type DummyBData = { 820 + body?: never; 821 + path?: never; 822 + query?: never; 823 + url: '/api/v{api-version}/multiple-tags/b'; 824 + }; 825 + 826 + export type DummyBResponses = { 827 + /** 828 + * Success 829 + */ 830 + 204: unknown; 831 + }; 832 + 833 + export type CallWithResponseData = { 834 + body?: never; 835 + path?: never; 836 + query?: never; 837 + url: '/api/v{api-version}/response'; 838 + }; 839 + 840 + export type CallWithResponseResponses = { 841 + /** 842 + * Message for default response 843 + */ 844 + default: ModelWithString; 845 + }; 846 + 847 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 848 + 849 + export type CallWithDuplicateResponsesData = { 850 + body?: never; 851 + path?: never; 852 + query?: never; 853 + url: '/api/v{api-version}/response'; 854 + }; 855 + 856 + export type CallWithDuplicateResponsesErrors = { 857 + /** 858 + * Message for 500 error 859 + */ 860 + 500: ModelWithStringError; 861 + /** 862 + * Message for 501 error 863 + */ 864 + 501: ModelWithStringError; 865 + /** 866 + * Message for 502 error 867 + */ 868 + 502: ModelWithStringError; 869 + /** 870 + * Message for default response 871 + */ 872 + default: ModelWithString; 873 + }; 874 + 875 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 876 + 877 + export type CallWithDuplicateResponsesResponses = { 878 + /** 879 + * Message for 201 response 880 + */ 881 + 201: ModelWithString; 882 + /** 883 + * Message for 202 response 884 + */ 885 + 202: ModelWithString; 886 + }; 887 + 888 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 889 + 890 + export type CallWithResponsesData = { 891 + body?: never; 892 + path?: never; 893 + query?: never; 894 + url: '/api/v{api-version}/response'; 895 + }; 896 + 897 + export type CallWithResponsesErrors = { 898 + /** 899 + * Message for 500 error 900 + */ 901 + 500: ModelWithStringError; 902 + /** 903 + * Message for 501 error 904 + */ 905 + 501: ModelWithStringError; 906 + /** 907 + * Message for 502 error 908 + */ 909 + 502: ModelWithStringError; 910 + /** 911 + * Message for default response 912 + */ 913 + default: ModelWithString; 914 + }; 915 + 916 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 917 + 918 + export type CallWithResponsesResponses = { 919 + /** 920 + * Message for 200 response 921 + */ 922 + 200: { 923 + readonly '@namespace.string'?: string; 924 + readonly '@namespace.integer'?: number; 925 + readonly value?: Array<ModelWithString>; 926 + }; 927 + /** 928 + * Message for 201 response 929 + */ 930 + 201: ModelThatExtends; 931 + /** 932 + * Message for 202 response 933 + */ 934 + 202: ModelThatExtendsExtends; 935 + }; 936 + 937 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 938 + 939 + export type CollectionFormatData = { 940 + body?: never; 941 + path?: never; 942 + query: { 943 + /** 944 + * This is an array parameter that is sent as csv format (comma-separated values) 945 + */ 946 + parameterArrayCSV: Array<string>; 947 + /** 948 + * This is an array parameter that is sent as ssv format (space-separated values) 949 + */ 950 + parameterArraySSV: Array<string>; 951 + /** 952 + * This is an array parameter that is sent as tsv format (tab-separated values) 953 + */ 954 + parameterArrayTSV: Array<string>; 955 + /** 956 + * This is an array parameter that is sent as pipes format (pipe-separated values) 957 + */ 958 + parameterArrayPipes: Array<string>; 959 + /** 960 + * This is an array parameter that is sent as multi format (multiple parameter instances) 961 + */ 962 + parameterArrayMulti: Array<string>; 963 + }; 964 + url: '/api/v{api-version}/collectionFormat'; 965 + }; 966 + 967 + export type TypesData = { 968 + body?: never; 969 + path?: { 970 + /** 971 + * This is a number parameter 972 + */ 973 + id?: number; 974 + }; 975 + query: { 976 + /** 977 + * This is a number parameter 978 + */ 979 + parameterNumber: number; 980 + /** 981 + * This is a string parameter 982 + */ 983 + parameterString: string; 984 + /** 985 + * This is a boolean parameter 986 + */ 987 + parameterBoolean: boolean; 988 + /** 989 + * This is an array parameter 990 + */ 991 + parameterArray: Array<string>; 992 + /** 993 + * This is a dictionary parameter 994 + */ 995 + parameterDictionary: { 996 + [key: string]: unknown; 997 + }; 998 + /** 999 + * This is an enum parameter 1000 + */ 1001 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1002 + }; 1003 + url: '/api/v{api-version}/types'; 1004 + }; 1005 + 1006 + export type TypesResponses = { 1007 + /** 1008 + * Response is a simple number 1009 + */ 1010 + 200: number; 1011 + /** 1012 + * Response is a simple string 1013 + */ 1014 + 201: string; 1015 + /** 1016 + * Response is a simple boolean 1017 + */ 1018 + 202: boolean; 1019 + /** 1020 + * Response is a simple object 1021 + */ 1022 + 203: { 1023 + [key: string]: unknown; 1024 + }; 1025 + }; 1026 + 1027 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1028 + 1029 + export type ComplexTypesData = { 1030 + body?: never; 1031 + path?: never; 1032 + query: { 1033 + /** 1034 + * Parameter containing object 1035 + */ 1036 + parameterObject: { 1037 + first?: { 1038 + second?: { 1039 + third?: string; 1040 + }; 1041 + }; 1042 + }; 1043 + /** 1044 + * This is a model with one string property 1045 + */ 1046 + parameterReference: { 1047 + /** 1048 + * This is a simple string property 1049 + */ 1050 + prop?: string; 1051 + }; 1052 + }; 1053 + url: '/api/v{api-version}/complex'; 1054 + }; 1055 + 1056 + export type ComplexTypesErrors = { 1057 + /** 1058 + * 400 server error 1059 + */ 1060 + 400: unknown; 1061 + /** 1062 + * 500 server error 1063 + */ 1064 + 500: unknown; 1065 + }; 1066 + 1067 + export type ComplexTypesResponses = { 1068 + /** 1069 + * Successful response 1070 + */ 1071 + 200: Array<ModelWithString>; 1072 + }; 1073 + 1074 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1075 + 1076 + export type CallWithResultFromHeaderData = { 1077 + body?: never; 1078 + path?: never; 1079 + query?: never; 1080 + url: '/api/v{api-version}/header'; 1081 + }; 1082 + 1083 + export type CallWithResultFromHeaderErrors = { 1084 + /** 1085 + * 400 server error 1086 + */ 1087 + 400: unknown; 1088 + /** 1089 + * 500 server error 1090 + */ 1091 + 500: unknown; 1092 + }; 1093 + 1094 + export type CallWithResultFromHeaderResponses = { 1095 + /** 1096 + * Successful response 1097 + */ 1098 + 200: unknown; 1099 + }; 1100 + 1101 + export type TestErrorCodeData = { 1102 + body?: never; 1103 + path?: never; 1104 + query: { 1105 + /** 1106 + * Status code to return 1107 + */ 1108 + status: string; 1109 + }; 1110 + url: '/api/v{api-version}/error'; 1111 + }; 1112 + 1113 + export type TestErrorCodeErrors = { 1114 + /** 1115 + * Custom message: Internal Server Error 1116 + */ 1117 + 500: unknown; 1118 + /** 1119 + * Custom message: Not Implemented 1120 + */ 1121 + 501: unknown; 1122 + /** 1123 + * Custom message: Bad Gateway 1124 + */ 1125 + 502: unknown; 1126 + /** 1127 + * Custom message: Service Unavailable 1128 + */ 1129 + 503: unknown; 1130 + }; 1131 + 1132 + export type TestErrorCodeResponses = { 1133 + /** 1134 + * Custom message: Successful response 1135 + */ 1136 + 200: unknown; 1137 + }; 1138 + 1139 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 1140 + body?: never; 1141 + path?: never; 1142 + query: { 1143 + /** 1144 + * Dummy input param 1145 + */ 1146 + nonAsciiParamæøåÆØÅöôêÊ: number; 1147 + }; 1148 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 1149 + }; 1150 + 1151 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 1152 + /** 1153 + * Successful response 1154 + */ 1155 + 200: NonAsciiStringæøåÆøÅöôêÊ字符串; 1156 + }; 1157 + 1158 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 1159 + 1160 + export type PostApiVbyApiVersionBodyData = { 1161 + /** 1162 + * Body should not be unknown 1163 + */ 1164 + body: ParameterActivityParams; 1165 + path?: never; 1166 + query?: never; 1167 + url: '/api/v{api-version}/body'; 1168 + }; 1169 + 1170 + export type PostApiVbyApiVersionBodyErrors = { 1171 + /** 1172 + * Bad Request 1173 + */ 1174 + 400: FailureFailure; 1175 + /** 1176 + * Internal Server Error 1177 + */ 1178 + 500: FailureFailure; 1179 + }; 1180 + 1181 + export type PostApiVbyApiVersionBodyError = PostApiVbyApiVersionBodyErrors[keyof PostApiVbyApiVersionBodyErrors]; 1182 + 1183 + export type PostApiVbyApiVersionBodyResponses = { 1184 + /** 1185 + * OK 1186 + */ 1187 + 200: ResponsePostActivityResponse; 1188 + }; 1189 + 1190 + export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses[keyof PostApiVbyApiVersionBodyResponses];
+824
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/@tanstack/react-query.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, useMutation, type UseMutationOptions } from '@tanstack/react-query'; 4 + 5 + import { client } from '../client.gen'; 6 + import { apiVVersionODataControllerCount, callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexParams, complexTypes, deleteCallWithoutParametersAndResponse, deleteFoo, deprecatedCall, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, export_, fileResponse, fooWow, getApiVbyApiVersionSimpleOperation, getCallWithOptionalParam, getCallWithoutParametersAndResponse, import_, multipartRequest, multipartResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionFormData, postApiVbyApiVersionRequestBody, postCallWithOptionalParam, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, putWithFormUrlEncoded, testErrorCode, types, uploadFile } from '../sdk.gen'; 7 + import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponse, DummyBData, DummyBResponse, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, TypesResponse, UploadFileData, UploadFileResponse } from '../types.gen'; 8 + 9 + export type QueryKey<TOptions extends Options> = [ 10 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 12 + _infinite?: boolean; 13 + tags?: ReadonlyArray<string>; 14 + } 15 + ]; 16 + 17 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 + QueryKey<TOptions>[0] 19 + ] => { 20 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 + if (infinite) { 22 + params._infinite = infinite; 23 + } 24 + if (tags) { 25 + params.tags = tags; 26 + } 27 + if (options?.body) { 28 + params.body = options.body; 29 + } 30 + if (options?.headers) { 31 + params.headers = options.headers; 32 + } 33 + if (options?.path) { 34 + params.path = options.path; 35 + } 36 + if (options?.query) { 37 + params.query = options.query; 38 + } 39 + return [params]; 40 + }; 41 + 42 + export const exportQueryKey = (options?: Options<ExportData>) => createQueryKey('export', options); 43 + 44 + export const exportOptions = (options?: Options<ExportData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof exportQueryKey>>({ 45 + queryFn: async ({ queryKey, signal }) => { 46 + const { data } = await export_({ 47 + ...options, 48 + ...queryKey[0], 49 + signal, 50 + throwOnError: true 51 + }); 52 + return data; 53 + }, 54 + queryKey: exportQueryKey(options) 55 + }); 56 + 57 + export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => { 58 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> = { 59 + mutationFn: async (fnOptions) => { 60 + const { data } = await patchApiVbyApiVersionNoTag({ 61 + ...options, 62 + ...fnOptions, 63 + throwOnError: true 64 + }); 65 + return data; 66 + } 67 + }; 68 + return mutationOptions; 69 + }; 70 + 71 + export const usePatchApiVbyApiVersionNoTagMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>>, 'mutationFn'>>) => useMutation({ ...patchApiVbyApiVersionNoTagMutation(), ...mutationOptions }); 72 + 73 + export const importMutation = (options?: Partial<Options<ImportData>>): UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>> => { 74 + const mutationOptions: UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>> = { 75 + mutationFn: async (fnOptions) => { 76 + const { data } = await import_({ 77 + ...options, 78 + ...fnOptions, 79 + throwOnError: true 80 + }); 81 + return data; 82 + } 83 + }; 84 + return mutationOptions; 85 + }; 86 + 87 + export const useImportMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>>, 'mutationFn'>>) => useMutation({ ...importMutation(), ...mutationOptions }); 88 + 89 + export const fooWowMutation = (options?: Partial<Options<FooWowData>>): UseMutationOptions<unknown, DefaultError, Options<FooWowData>> => { 90 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<FooWowData>> = { 91 + mutationFn: async (fnOptions) => { 92 + const { data } = await fooWow({ 93 + ...options, 94 + ...fnOptions, 95 + throwOnError: true 96 + }); 97 + return data; 98 + } 99 + }; 100 + return mutationOptions; 101 + }; 102 + 103 + export const useFooWowMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<FooWowData>>, 'mutationFn'>>) => useMutation({ ...fooWowMutation(), ...mutationOptions }); 104 + 105 + export const apiVVersionODataControllerCountQueryKey = (options?: Options<ApiVVersionODataControllerCountData>) => createQueryKey('apiVVersionODataControllerCount', options); 106 + 107 + export const apiVVersionODataControllerCountOptions = (options?: Options<ApiVVersionODataControllerCountData>) => queryOptions<ApiVVersionODataControllerCountResponse, DefaultError, ApiVVersionODataControllerCountResponse, ReturnType<typeof apiVVersionODataControllerCountQueryKey>>({ 108 + queryFn: async ({ queryKey, signal }) => { 109 + const { data } = await apiVVersionODataControllerCount({ 110 + ...options, 111 + ...queryKey[0], 112 + signal, 113 + throwOnError: true 114 + }); 115 + return data; 116 + }, 117 + queryKey: apiVVersionODataControllerCountQueryKey(options) 118 + }); 119 + 120 + export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); 121 + 122 + export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => queryOptions<GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, ReturnType<typeof getApiVbyApiVersionSimpleOperationQueryKey>>({ 123 + queryFn: async ({ queryKey, signal }) => { 124 + const { data } = await getApiVbyApiVersionSimpleOperation({ 125 + ...options, 126 + ...queryKey[0], 127 + signal, 128 + throwOnError: true 129 + }); 130 + return data; 131 + }, 132 + queryKey: getApiVbyApiVersionSimpleOperationQueryKey(options) 133 + }); 134 + 135 + export const deleteCallWithoutParametersAndResponseMutation = (options?: Partial<Options<DeleteCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> => { 136 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> = { 137 + mutationFn: async (fnOptions) => { 138 + const { data } = await deleteCallWithoutParametersAndResponse({ 139 + ...options, 140 + ...fnOptions, 141 + throwOnError: true 142 + }); 143 + return data; 144 + } 145 + }; 146 + return mutationOptions; 147 + }; 148 + 149 + export const useDeleteCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...deleteCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 150 + 151 + export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 152 + 153 + export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getCallWithoutParametersAndResponseQueryKey>>({ 154 + queryFn: async ({ queryKey, signal }) => { 155 + const { data } = await getCallWithoutParametersAndResponse({ 156 + ...options, 157 + ...queryKey[0], 158 + signal, 159 + throwOnError: true 160 + }); 161 + return data; 162 + }, 163 + queryKey: getCallWithoutParametersAndResponseQueryKey(options) 164 + }); 165 + 166 + export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => { 167 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> = { 168 + mutationFn: async (fnOptions) => { 169 + const { data } = await patchCallWithoutParametersAndResponse({ 170 + ...options, 171 + ...fnOptions, 172 + throwOnError: true 173 + }); 174 + return data; 175 + } 176 + }; 177 + return mutationOptions; 178 + }; 179 + 180 + export const usePatchCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...patchCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 181 + 182 + export const postCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PostCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> => { 183 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> = { 184 + mutationFn: async (fnOptions) => { 185 + const { data } = await postCallWithoutParametersAndResponse({ 186 + ...options, 187 + ...fnOptions, 188 + throwOnError: true 189 + }); 190 + return data; 191 + } 192 + }; 193 + return mutationOptions; 194 + }; 195 + 196 + export const usePostCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...postCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 197 + 198 + export const putCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PutCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> => { 199 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> = { 200 + mutationFn: async (fnOptions) => { 201 + const { data } = await putCallWithoutParametersAndResponse({ 202 + ...options, 203 + ...fnOptions, 204 + throwOnError: true 205 + }); 206 + return data; 207 + } 208 + }; 209 + return mutationOptions; 210 + }; 211 + 212 + export const usePutCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...putCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 213 + 214 + export const deleteFooMutation = (options?: Partial<Options<DeleteFooData3>>): UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>> => { 215 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>> = { 216 + mutationFn: async (fnOptions) => { 217 + const { data } = await deleteFoo({ 218 + ...options, 219 + ...fnOptions, 220 + throwOnError: true 221 + }); 222 + return data; 223 + } 224 + }; 225 + return mutationOptions; 226 + }; 227 + 228 + export const useDeleteFooMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>>, 'mutationFn'>>) => useMutation({ ...deleteFooMutation(), ...mutationOptions }); 229 + 230 + export const callWithDescriptionsMutation = (options?: Partial<Options<CallWithDescriptionsData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> => { 231 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> = { 232 + mutationFn: async (fnOptions) => { 233 + const { data } = await callWithDescriptions({ 234 + ...options, 235 + ...fnOptions, 236 + throwOnError: true 237 + }); 238 + return data; 239 + } 240 + }; 241 + return mutationOptions; 242 + }; 243 + 244 + export const useCallWithDescriptionsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>>, 'mutationFn'>>) => useMutation({ ...callWithDescriptionsMutation(), ...mutationOptions }); 245 + 246 + /** 247 + * @deprecated 248 + */ 249 + export const deprecatedCallMutation = (options?: Partial<Options<DeprecatedCallData>>): UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>> => { 250 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>> = { 251 + mutationFn: async (fnOptions) => { 252 + const { data } = await deprecatedCall({ 253 + ...options, 254 + ...fnOptions, 255 + throwOnError: true 256 + }); 257 + return data; 258 + } 259 + }; 260 + return mutationOptions; 261 + }; 262 + 263 + /** 264 + * @deprecated 265 + */ 266 + export const useDeprecatedCallMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>>, 'mutationFn'>>) => useMutation({ ...deprecatedCallMutation(), ...mutationOptions }); 267 + 268 + export const callWithParametersMutation = (options?: Partial<Options<CallWithParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> => { 269 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> = { 270 + mutationFn: async (fnOptions) => { 271 + const { data } = await callWithParameters({ 272 + ...options, 273 + ...fnOptions, 274 + throwOnError: true 275 + }); 276 + return data; 277 + } 278 + }; 279 + return mutationOptions; 280 + }; 281 + 282 + export const useCallWithParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithParametersMutation(), ...mutationOptions }); 283 + 284 + export const callWithWeirdParameterNamesMutation = (options?: Partial<Options<CallWithWeirdParameterNamesData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> => { 285 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 286 + mutationFn: async (fnOptions) => { 287 + const { data } = await callWithWeirdParameterNames({ 288 + ...options, 289 + ...fnOptions, 290 + throwOnError: true 291 + }); 292 + return data; 293 + } 294 + }; 295 + return mutationOptions; 296 + }; 297 + 298 + export const useCallWithWeirdParameterNamesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>>, 'mutationFn'>>) => useMutation({ ...callWithWeirdParameterNamesMutation(), ...mutationOptions }); 299 + 300 + export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => createQueryKey('getCallWithOptionalParam', options); 301 + 302 + export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getCallWithOptionalParamQueryKey>>({ 303 + queryFn: async ({ queryKey, signal }) => { 304 + const { data } = await getCallWithOptionalParam({ 305 + ...options, 306 + ...queryKey[0], 307 + signal, 308 + throwOnError: true 309 + }); 310 + return data; 311 + }, 312 + queryKey: getCallWithOptionalParamQueryKey(options) 313 + }); 314 + 315 + const createInfiniteParams = <K extends Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>>(queryKey: QueryKey<Options>, page: K) => { 316 + const params = { ...queryKey[0] }; 317 + if (page.body) { 318 + params.body = { 319 + ...queryKey[0].body as any, 320 + ...page.body as any 321 + }; 322 + } 323 + if (page.headers) { 324 + params.headers = { 325 + ...queryKey[0].headers, 326 + ...page.headers 327 + }; 328 + } 329 + if (page.path) { 330 + params.path = { 331 + ...queryKey[0].path as any, 332 + ...page.path as any 333 + }; 334 + } 335 + if (page.query) { 336 + params.query = { 337 + ...queryKey[0].query as any, 338 + ...page.query as any 339 + }; 340 + } 341 + return params as unknown as typeof page; 342 + }; 343 + 344 + export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => createQueryKey('getCallWithOptionalParam', options, true); 345 + 346 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => infiniteQueryOptions<unknown, DefaultError, InfiniteData<unknown>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( 347 + // @ts-ignore 348 + { 349 + queryFn: async ({ pageParam, queryKey, signal }) => { 350 + // @ts-ignore 351 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 352 + query: { 353 + page: pageParam 354 + } 355 + }; 356 + const params = createInfiniteParams(queryKey, page); 357 + const { data } = await getCallWithOptionalParam({ 358 + ...options, 359 + ...params, 360 + signal, 361 + throwOnError: true 362 + }); 363 + return data; 364 + }, 365 + queryKey: getCallWithOptionalParamInfiniteQueryKey(options) 366 + }); 367 + 368 + export const postCallWithOptionalParamMutation = (options?: Partial<Options<PostCallWithOptionalParamData>>): UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>> => { 369 + const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>> = { 370 + mutationFn: async (fnOptions) => { 371 + const { data } = await postCallWithOptionalParam({ 372 + ...options, 373 + ...fnOptions, 374 + throwOnError: true 375 + }); 376 + return data; 377 + } 378 + }; 379 + return mutationOptions; 380 + }; 381 + 382 + export const usePostCallWithOptionalParamMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>>, 'mutationFn'>>) => useMutation({ ...postCallWithOptionalParamMutation(), ...mutationOptions }); 383 + 384 + export const postApiVbyApiVersionRequestBodyMutation = (options?: Partial<Options<PostApiVbyApiVersionRequestBodyData>>): UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> => { 385 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 386 + mutationFn: async (fnOptions) => { 387 + const { data } = await postApiVbyApiVersionRequestBody({ 388 + ...options, 389 + ...fnOptions, 390 + throwOnError: true 391 + }); 392 + return data; 393 + } 394 + }; 395 + return mutationOptions; 396 + }; 397 + 398 + export const usePostApiVbyApiVersionRequestBodyMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>>, 'mutationFn'>>) => useMutation({ ...postApiVbyApiVersionRequestBodyMutation(), ...mutationOptions }); 399 + 400 + export const postApiVbyApiVersionFormDataMutation = (options?: Partial<Options<PostApiVbyApiVersionFormDataData>>): UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>> => { 401 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 402 + mutationFn: async (fnOptions) => { 403 + const { data } = await postApiVbyApiVersionFormData({ 404 + ...options, 405 + ...fnOptions, 406 + throwOnError: true 407 + }); 408 + return data; 409 + } 410 + }; 411 + return mutationOptions; 412 + }; 413 + 414 + export const usePostApiVbyApiVersionFormDataMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>>, 'mutationFn'>>) => useMutation({ ...postApiVbyApiVersionFormDataMutation(), ...mutationOptions }); 415 + 416 + export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 417 + 418 + export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof callWithDefaultParametersQueryKey>>({ 419 + queryFn: async ({ queryKey, signal }) => { 420 + const { data } = await callWithDefaultParameters({ 421 + ...options, 422 + ...queryKey[0], 423 + signal, 424 + throwOnError: true 425 + }); 426 + return data; 427 + }, 428 + queryKey: callWithDefaultParametersQueryKey(options) 429 + }); 430 + 431 + export const callWithDefaultOptionalParametersMutation = (options?: Partial<Options<CallWithDefaultOptionalParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> => { 432 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 433 + mutationFn: async (fnOptions) => { 434 + const { data } = await callWithDefaultOptionalParameters({ 435 + ...options, 436 + ...fnOptions, 437 + throwOnError: true 438 + }); 439 + return data; 440 + } 441 + }; 442 + return mutationOptions; 443 + }; 444 + 445 + export const useCallWithDefaultOptionalParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithDefaultOptionalParametersMutation(), ...mutationOptions }); 446 + 447 + export const callToTestOrderOfParamsMutation = (options?: Partial<Options<CallToTestOrderOfParamsData>>): UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> => { 448 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> = { 449 + mutationFn: async (fnOptions) => { 450 + const { data } = await callToTestOrderOfParams({ 451 + ...options, 452 + ...fnOptions, 453 + throwOnError: true 454 + }); 455 + return data; 456 + } 457 + }; 458 + return mutationOptions; 459 + }; 460 + 461 + export const useCallToTestOrderOfParamsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>>, 'mutationFn'>>) => useMutation({ ...callToTestOrderOfParamsMutation(), ...mutationOptions }); 462 + 463 + export const duplicateNameMutation = (options?: Partial<Options<DuplicateNameData>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> => { 464 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> = { 465 + mutationFn: async (fnOptions) => { 466 + const { data } = await duplicateName({ 467 + ...options, 468 + ...fnOptions, 469 + throwOnError: true 470 + }); 471 + return data; 472 + } 473 + }; 474 + return mutationOptions; 475 + }; 476 + 477 + export const useDuplicateNameMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>>, 'mutationFn'>>) => useMutation({ ...duplicateNameMutation(), ...mutationOptions }); 478 + 479 + export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 480 + 481 + export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof duplicateName2QueryKey>>({ 482 + queryFn: async ({ queryKey, signal }) => { 483 + const { data } = await duplicateName2({ 484 + ...options, 485 + ...queryKey[0], 486 + signal, 487 + throwOnError: true 488 + }); 489 + return data; 490 + }, 491 + queryKey: duplicateName2QueryKey(options) 492 + }); 493 + 494 + export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => { 495 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> = { 496 + mutationFn: async (fnOptions) => { 497 + const { data } = await duplicateName3({ 498 + ...options, 499 + ...fnOptions, 500 + throwOnError: true 501 + }); 502 + return data; 503 + } 504 + }; 505 + return mutationOptions; 506 + }; 507 + 508 + export const useDuplicateName3Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName3Mutation(), ...mutationOptions }); 509 + 510 + export const duplicateName4Mutation = (options?: Partial<Options<DuplicateName4Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> => { 511 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> = { 512 + mutationFn: async (fnOptions) => { 513 + const { data } = await duplicateName4({ 514 + ...options, 515 + ...fnOptions, 516 + throwOnError: true 517 + }); 518 + return data; 519 + } 520 + }; 521 + return mutationOptions; 522 + }; 523 + 524 + export const useDuplicateName4Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName4Mutation(), ...mutationOptions }); 525 + 526 + export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 527 + 528 + export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => queryOptions<CallWithNoContentResponseResponse, DefaultError, CallWithNoContentResponseResponse, ReturnType<typeof callWithNoContentResponseQueryKey>>({ 529 + queryFn: async ({ queryKey, signal }) => { 530 + const { data } = await callWithNoContentResponse({ 531 + ...options, 532 + ...queryKey[0], 533 + signal, 534 + throwOnError: true 535 + }); 536 + return data; 537 + }, 538 + queryKey: callWithNoContentResponseQueryKey(options) 539 + }); 540 + 541 + export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 542 + 543 + export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => queryOptions<CallWithResponseAndNoContentResponseResponse, DefaultError, CallWithResponseAndNoContentResponseResponse, ReturnType<typeof callWithResponseAndNoContentResponseQueryKey>>({ 544 + queryFn: async ({ queryKey, signal }) => { 545 + const { data } = await callWithResponseAndNoContentResponse({ 546 + ...options, 547 + ...queryKey[0], 548 + signal, 549 + throwOnError: true 550 + }); 551 + return data; 552 + }, 553 + queryKey: callWithResponseAndNoContentResponseQueryKey(options) 554 + }); 555 + 556 + export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 557 + 558 + export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<DummyAResponse, DefaultError, DummyAResponse, ReturnType<typeof dummyAQueryKey>>({ 559 + queryFn: async ({ queryKey, signal }) => { 560 + const { data } = await dummyA({ 561 + ...options, 562 + ...queryKey[0], 563 + signal, 564 + throwOnError: true 565 + }); 566 + return data; 567 + }, 568 + queryKey: dummyAQueryKey(options) 569 + }); 570 + 571 + export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 572 + 573 + export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<DummyBResponse, DefaultError, DummyBResponse, ReturnType<typeof dummyBQueryKey>>({ 574 + queryFn: async ({ queryKey, signal }) => { 575 + const { data } = await dummyB({ 576 + ...options, 577 + ...queryKey[0], 578 + signal, 579 + throwOnError: true 580 + }); 581 + return data; 582 + }, 583 + queryKey: dummyBQueryKey(options) 584 + }); 585 + 586 + export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 587 + 588 + export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => queryOptions<CallWithResponseResponse, DefaultError, CallWithResponseResponse, ReturnType<typeof callWithResponseQueryKey>>({ 589 + queryFn: async ({ queryKey, signal }) => { 590 + const { data } = await callWithResponse({ 591 + ...options, 592 + ...queryKey[0], 593 + signal, 594 + throwOnError: true 595 + }); 596 + return data; 597 + }, 598 + queryKey: callWithResponseQueryKey(options) 599 + }); 600 + 601 + export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => { 602 + const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> = { 603 + mutationFn: async (fnOptions) => { 604 + const { data } = await callWithDuplicateResponses({ 605 + ...options, 606 + ...fnOptions, 607 + throwOnError: true 608 + }); 609 + return data; 610 + } 611 + }; 612 + return mutationOptions; 613 + }; 614 + 615 + export const useCallWithDuplicateResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithDuplicateResponsesMutation(), ...mutationOptions }); 616 + 617 + export const callWithResponsesMutation = (options?: Partial<Options<CallWithResponsesData>>): UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> => { 618 + const mutationOptions: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> = { 619 + mutationFn: async (fnOptions) => { 620 + const { data } = await callWithResponses({ 621 + ...options, 622 + ...fnOptions, 623 + throwOnError: true 624 + }); 625 + return data; 626 + } 627 + }; 628 + return mutationOptions; 629 + }; 630 + 631 + export const useCallWithResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithResponsesMutation(), ...mutationOptions }); 632 + 633 + export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 634 + 635 + export const collectionFormatOptions = (options: Options<CollectionFormatData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof collectionFormatQueryKey>>({ 636 + queryFn: async ({ queryKey, signal }) => { 637 + const { data } = await collectionFormat({ 638 + ...options, 639 + ...queryKey[0], 640 + signal, 641 + throwOnError: true 642 + }); 643 + return data; 644 + }, 645 + queryKey: collectionFormatQueryKey(options) 646 + }); 647 + 648 + export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 649 + 650 + export const typesOptions = (options: Options<TypesData>) => queryOptions<TypesResponse, DefaultError, TypesResponse, ReturnType<typeof typesQueryKey>>({ 651 + queryFn: async ({ queryKey, signal }) => { 652 + const { data } = await types({ 653 + ...options, 654 + ...queryKey[0], 655 + signal, 656 + throwOnError: true 657 + }); 658 + return data; 659 + }, 660 + queryKey: typesQueryKey(options) 661 + }); 662 + 663 + export const uploadFileMutation = (options?: Partial<Options<UploadFileData>>): UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>> => { 664 + const mutationOptions: UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>> = { 665 + mutationFn: async (fnOptions) => { 666 + const { data } = await uploadFile({ 667 + ...options, 668 + ...fnOptions, 669 + throwOnError: true 670 + }); 671 + return data; 672 + } 673 + }; 674 + return mutationOptions; 675 + }; 676 + 677 + export const useUploadFileMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>>, 'mutationFn'>>) => useMutation({ ...uploadFileMutation(), ...mutationOptions }); 678 + 679 + export const fileResponseQueryKey = (options: Options<FileResponseData>) => createQueryKey('fileResponse', options); 680 + 681 + export const fileResponseOptions = (options: Options<FileResponseData>) => queryOptions<FileResponseResponse, DefaultError, FileResponseResponse, ReturnType<typeof fileResponseQueryKey>>({ 682 + queryFn: async ({ queryKey, signal }) => { 683 + const { data } = await fileResponse({ 684 + ...options, 685 + ...queryKey[0], 686 + signal, 687 + throwOnError: true 688 + }); 689 + return data; 690 + }, 691 + queryKey: fileResponseQueryKey(options) 692 + }); 693 + 694 + export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 695 + 696 + export const complexTypesOptions = (options: Options<ComplexTypesData>) => queryOptions<ComplexTypesResponse, DefaultError, ComplexTypesResponse, ReturnType<typeof complexTypesQueryKey>>({ 697 + queryFn: async ({ queryKey, signal }) => { 698 + const { data } = await complexTypes({ 699 + ...options, 700 + ...queryKey[0], 701 + signal, 702 + throwOnError: true 703 + }); 704 + return data; 705 + }, 706 + queryKey: complexTypesQueryKey(options) 707 + }); 708 + 709 + export const multipartResponseQueryKey = (options?: Options<MultipartResponseData>) => createQueryKey('multipartResponse', options); 710 + 711 + export const multipartResponseOptions = (options?: Options<MultipartResponseData>) => queryOptions<MultipartResponseResponse, DefaultError, MultipartResponseResponse, ReturnType<typeof multipartResponseQueryKey>>({ 712 + queryFn: async ({ queryKey, signal }) => { 713 + const { data } = await multipartResponse({ 714 + ...options, 715 + ...queryKey[0], 716 + signal, 717 + throwOnError: true 718 + }); 719 + return data; 720 + }, 721 + queryKey: multipartResponseQueryKey(options) 722 + }); 723 + 724 + export const multipartRequestMutation = (options?: Partial<Options<MultipartRequestData>>): UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>> => { 725 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>> = { 726 + mutationFn: async (fnOptions) => { 727 + const { data } = await multipartRequest({ 728 + ...options, 729 + ...fnOptions, 730 + throwOnError: true 731 + }); 732 + return data; 733 + } 734 + }; 735 + return mutationOptions; 736 + }; 737 + 738 + export const useMultipartRequestMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>>, 'mutationFn'>>) => useMutation({ ...multipartRequestMutation(), ...mutationOptions }); 739 + 740 + export const complexParamsMutation = (options?: Partial<Options<ComplexParamsData>>): UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>> => { 741 + const mutationOptions: UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>> = { 742 + mutationFn: async (fnOptions) => { 743 + const { data } = await complexParams({ 744 + ...options, 745 + ...fnOptions, 746 + throwOnError: true 747 + }); 748 + return data; 749 + } 750 + }; 751 + return mutationOptions; 752 + }; 753 + 754 + export const useComplexParamsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>>, 'mutationFn'>>) => useMutation({ ...complexParamsMutation(), ...mutationOptions }); 755 + 756 + export const callWithResultFromHeaderMutation = (options?: Partial<Options<CallWithResultFromHeaderData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> => { 757 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> = { 758 + mutationFn: async (fnOptions) => { 759 + const { data } = await callWithResultFromHeader({ 760 + ...options, 761 + ...fnOptions, 762 + throwOnError: true 763 + }); 764 + return data; 765 + } 766 + }; 767 + return mutationOptions; 768 + }; 769 + 770 + export const useCallWithResultFromHeaderMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>>, 'mutationFn'>>) => useMutation({ ...callWithResultFromHeaderMutation(), ...mutationOptions }); 771 + 772 + export const testErrorCodeMutation = (options?: Partial<Options<TestErrorCodeData>>): UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> => { 773 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> = { 774 + mutationFn: async (fnOptions) => { 775 + const { data } = await testErrorCode({ 776 + ...options, 777 + ...fnOptions, 778 + throwOnError: true 779 + }); 780 + return data; 781 + } 782 + }; 783 + return mutationOptions; 784 + }; 785 + 786 + export const useTestErrorCodeMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>>, 'mutationFn'>>) => useMutation({ ...testErrorCodeMutation(), ...mutationOptions }); 787 + 788 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options?: Partial<Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>): UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> => { 789 + const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 790 + mutationFn: async (fnOptions) => { 791 + const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 792 + ...options, 793 + ...fnOptions, 794 + throwOnError: true 795 + }); 796 + return data; 797 + } 798 + }; 799 + return mutationOptions; 800 + }; 801 + 802 + export const useNonAsciiæøåÆøÅöôêÊ字符串Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>, 'mutationFn'>>) => useMutation({ ...nonAsciiæøåÆøÅöôêÊ字符串Mutation(), ...mutationOptions }); 803 + 804 + /** 805 + * Login User 806 + */ 807 + export const putWithFormUrlEncodedMutation = (options?: Partial<Options<PutWithFormUrlEncodedData>>): UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>> => { 808 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>> = { 809 + mutationFn: async (fnOptions) => { 810 + const { data } = await putWithFormUrlEncoded({ 811 + ...options, 812 + ...fnOptions, 813 + throwOnError: true 814 + }); 815 + return data; 816 + } 817 + }; 818 + return mutationOptions; 819 + }; 820 + 821 + /** 822 + * Login User 823 + */ 824 + export const usePutWithFormUrlEncodedMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>>, 'mutationFn'>>) => useMutation({ ...putWithFormUrlEncodedMutation(), ...mutationOptions });
+16
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 + import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:3000/base' }));
+288
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createSseClient } from '../core/serverSentEvents.gen'; 4 + import type { HttpMethod } from '../core/types.gen'; 5 + import { getValidRequestBody } from '../core/utils.gen'; 6 + import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen'; 7 + import { 8 + buildUrl, 9 + createConfig, 10 + createInterceptors, 11 + getParseAs, 12 + mergeConfigs, 13 + mergeHeaders, 14 + setAuthParams, 15 + } from './utils.gen'; 16 + 17 + type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 18 + body?: any; 19 + headers: ReturnType<typeof mergeHeaders>; 20 + }; 21 + 22 + export const createClient = (config: Config = {}): Client => { 23 + let _config = mergeConfigs(createConfig(), config); 24 + 25 + const getConfig = (): Config => ({ ..._config }); 26 + 27 + const setConfig = (config: Config): Config => { 28 + _config = mergeConfigs(_config, config); 29 + return getConfig(); 30 + }; 31 + 32 + const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 33 + 34 + const beforeRequest = async (options: RequestOptions) => { 35 + const opts = { 36 + ..._config, 37 + ...options, 38 + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 39 + headers: mergeHeaders(_config.headers, options.headers), 40 + serializedBody: undefined as string | undefined, 41 + }; 42 + 43 + if (opts.security) { 44 + await setAuthParams({ 45 + ...opts, 46 + security: opts.security, 47 + }); 48 + } 49 + 50 + if (opts.requestValidator) { 51 + await opts.requestValidator(opts); 52 + } 53 + 54 + if (opts.body !== undefined && opts.bodySerializer) { 55 + opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 56 + } 57 + 58 + // remove Content-Type header if body is empty to avoid sending invalid requests 59 + if (opts.body === undefined || opts.serializedBody === '') { 60 + opts.headers.delete('Content-Type'); 61 + } 62 + 63 + const url = buildUrl(opts); 64 + 65 + return { opts, url }; 66 + }; 67 + 68 + const request: Client['request'] = async (options) => { 69 + // @ts-expect-error 70 + const { opts, url } = await beforeRequest(options); 71 + const requestInit: ReqInit = { 72 + redirect: 'follow', 73 + ...opts, 74 + body: getValidRequestBody(opts), 75 + }; 76 + 77 + let request = new Request(url, requestInit); 78 + 79 + for (const fn of interceptors.request.fns) { 80 + if (fn) { 81 + request = await fn(request, opts); 82 + } 83 + } 84 + 85 + // fetch must be assigned here, otherwise it would throw the error: 86 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 + const _fetch = opts.fetch!; 88 + let response: Response; 89 + 90 + try { 91 + response = await _fetch(request); 92 + } catch (error) { 93 + // Handle fetch exceptions (AbortError, network errors, etc.) 94 + let finalError = error; 95 + 96 + for (const fn of interceptors.error.fns) { 97 + if (fn) { 98 + finalError = (await fn(error, undefined as any, request, opts)) as unknown; 99 + } 100 + } 101 + 102 + finalError = finalError || ({} as unknown); 103 + 104 + if (opts.throwOnError) { 105 + throw finalError; 106 + } 107 + 108 + // Return error response 109 + return opts.responseStyle === 'data' 110 + ? undefined 111 + : { 112 + error: finalError, 113 + request, 114 + response: undefined as any, 115 + }; 116 + } 117 + 118 + for (const fn of interceptors.response.fns) { 119 + if (fn) { 120 + response = await fn(response, request, opts); 121 + } 122 + } 123 + 124 + const result = { 125 + request, 126 + response, 127 + }; 128 + 129 + if (response.ok) { 130 + const parseAs = 131 + (opts.parseAs === 'auto' 132 + ? getParseAs(response.headers.get('Content-Type')) 133 + : opts.parseAs) ?? 'json'; 134 + 135 + if (response.status === 204 || response.headers.get('Content-Length') === '0') { 136 + let emptyData: any; 137 + switch (parseAs) { 138 + case 'arrayBuffer': 139 + case 'blob': 140 + case 'text': 141 + emptyData = await response[parseAs](); 142 + break; 143 + case 'formData': 144 + emptyData = new FormData(); 145 + break; 146 + case 'stream': 147 + emptyData = response.body; 148 + break; 149 + case 'json': 150 + default: 151 + emptyData = {}; 152 + break; 153 + } 154 + return opts.responseStyle === 'data' 155 + ? emptyData 156 + : { 157 + data: emptyData, 158 + ...result, 159 + }; 160 + } 161 + 162 + let data: any; 163 + switch (parseAs) { 164 + case 'arrayBuffer': 165 + case 'blob': 166 + case 'formData': 167 + case 'text': 168 + data = await response[parseAs](); 169 + break; 170 + case 'json': { 171 + // Some servers return 200 with no Content-Length and empty body. 172 + // response.json() would throw; read as text and parse if non-empty. 173 + const text = await response.text(); 174 + data = text ? JSON.parse(text) : {}; 175 + break; 176 + } 177 + case 'stream': 178 + return opts.responseStyle === 'data' 179 + ? response.body 180 + : { 181 + data: response.body, 182 + ...result, 183 + }; 184 + } 185 + 186 + if (parseAs === 'json') { 187 + if (opts.responseValidator) { 188 + await opts.responseValidator(data); 189 + } 190 + 191 + if (opts.responseTransformer) { 192 + data = await opts.responseTransformer(data); 193 + } 194 + } 195 + 196 + return opts.responseStyle === 'data' 197 + ? data 198 + : { 199 + data, 200 + ...result, 201 + }; 202 + } 203 + 204 + const textError = await response.text(); 205 + let jsonError: unknown; 206 + 207 + try { 208 + jsonError = JSON.parse(textError); 209 + } catch { 210 + // noop 211 + } 212 + 213 + const error = jsonError ?? textError; 214 + let finalError = error; 215 + 216 + for (const fn of interceptors.error.fns) { 217 + if (fn) { 218 + finalError = (await fn(error, response, request, opts)) as string; 219 + } 220 + } 221 + 222 + finalError = finalError || ({} as string); 223 + 224 + if (opts.throwOnError) { 225 + throw finalError; 226 + } 227 + 228 + // TODO: we probably want to return error and improve types 229 + return opts.responseStyle === 'data' 230 + ? undefined 231 + : { 232 + error: finalError, 233 + ...result, 234 + }; 235 + }; 236 + 237 + const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 238 + request({ ...options, method }); 239 + 240 + const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 241 + const { opts, url } = await beforeRequest(options); 242 + return createSseClient({ 243 + ...opts, 244 + body: opts.body as BodyInit | null | undefined, 245 + headers: opts.headers as unknown as Record<string, string>, 246 + method, 247 + onRequest: async (url, init) => { 248 + let request = new Request(url, init); 249 + for (const fn of interceptors.request.fns) { 250 + if (fn) { 251 + request = await fn(request, opts); 252 + } 253 + } 254 + return request; 255 + }, 256 + serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined, 257 + url, 258 + }); 259 + }; 260 + 261 + return { 262 + buildUrl, 263 + connect: makeMethodFn('CONNECT'), 264 + delete: makeMethodFn('DELETE'), 265 + get: makeMethodFn('GET'), 266 + getConfig, 267 + head: makeMethodFn('HEAD'), 268 + interceptors, 269 + options: makeMethodFn('OPTIONS'), 270 + patch: makeMethodFn('PATCH'), 271 + post: makeMethodFn('POST'), 272 + put: makeMethodFn('PUT'), 273 + request, 274 + setConfig, 275 + sse: { 276 + connect: makeSseFn('CONNECT'), 277 + delete: makeSseFn('DELETE'), 278 + get: makeSseFn('GET'), 279 + head: makeSseFn('HEAD'), 280 + options: makeSseFn('OPTIONS'), 281 + patch: makeSseFn('PATCH'), 282 + post: makeSseFn('POST'), 283 + put: makeSseFn('PUT'), 284 + trace: makeSseFn('TRACE'), 285 + }, 286 + trace: makeMethodFn('TRACE'), 287 + } as Client; 288 + };
+25
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 + export { createClient } from './client.gen'; 13 + export type { 14 + Client, 15 + ClientOptions, 16 + Config, 17 + CreateClientConfig, 18 + Options, 19 + RequestOptions, 20 + RequestResult, 21 + ResolvedRequestOptions, 22 + ResponseStyle, 23 + TDataShape, 24 + } from './types.gen'; 25 + export { createConfig, mergeHeaders } from './utils.gen';
+214
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth } from '../core/auth.gen'; 4 + import type { 5 + ServerSentEventsOptions, 6 + ServerSentEventsResult, 7 + } from '../core/serverSentEvents.gen'; 8 + import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen'; 9 + import type { Middleware } from './utils.gen'; 10 + 11 + export type ResponseStyle = 'data' | 'fields'; 12 + 13 + export interface Config<T extends ClientOptions = ClientOptions> 14 + extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig { 15 + /** 16 + * Base URL for all requests made by this client. 17 + */ 18 + baseUrl?: T['baseUrl']; 19 + /** 20 + * Fetch API implementation. You can use this option to provide a custom 21 + * fetch instance. 22 + * 23 + * @default globalThis.fetch 24 + */ 25 + fetch?: typeof fetch; 26 + /** 27 + * Please don't use the Fetch client for Next.js applications. The `next` 28 + * options won't have any effect. 29 + * 30 + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 31 + */ 32 + next?: never; 33 + /** 34 + * Return the response data parsed in a specified format. By default, `auto` 35 + * will infer the appropriate method from the `Content-Type` response header. 36 + * You can override this behavior with any of the {@link Body} methods. 37 + * Select `stream` if you don't want to parse response data at all. 38 + * 39 + * @default 'auto' 40 + */ 41 + parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 42 + /** 43 + * Should we return only data or multiple fields (data, error, response, etc.)? 44 + * 45 + * @default 'fields' 46 + */ 47 + responseStyle?: ResponseStyle; 48 + /** 49 + * Throw an error instead of returning it in the response? 50 + * 51 + * @default false 52 + */ 53 + throwOnError?: T['throwOnError']; 54 + } 55 + 56 + export interface RequestOptions< 57 + TData = unknown, 58 + TResponseStyle extends ResponseStyle = 'fields', 59 + ThrowOnError extends boolean = boolean, 60 + Url extends string = string, 61 + > 62 + extends 63 + Config<{ 64 + responseStyle: TResponseStyle; 65 + throwOnError: ThrowOnError; 66 + }>, 67 + Pick< 68 + ServerSentEventsOptions<TData>, 69 + | 'onRequest' 70 + | 'onSseError' 71 + | 'onSseEvent' 72 + | 'sseDefaultRetryDelay' 73 + | 'sseMaxRetryAttempts' 74 + | 'sseMaxRetryDelay' 75 + > { 76 + /** 77 + * Any body that you want to add to your request. 78 + * 79 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 80 + */ 81 + body?: unknown; 82 + path?: Record<string, unknown>; 83 + query?: Record<string, unknown>; 84 + /** 85 + * Security mechanism(s) to use for the request. 86 + */ 87 + security?: ReadonlyArray<Auth>; 88 + url: Url; 89 + } 90 + 91 + export interface ResolvedRequestOptions< 92 + TResponseStyle extends ResponseStyle = 'fields', 93 + ThrowOnError extends boolean = boolean, 94 + Url extends string = string, 95 + > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 96 + serializedBody?: string; 97 + } 98 + 99 + export type RequestResult< 100 + TData = unknown, 101 + TError = unknown, 102 + ThrowOnError extends boolean = boolean, 103 + TResponseStyle extends ResponseStyle = 'fields', 104 + > = ThrowOnError extends true 105 + ? Promise< 106 + TResponseStyle extends 'data' 107 + ? TData extends Record<string, unknown> 108 + ? TData[keyof TData] 109 + : TData 110 + : { 111 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 112 + request: Request; 113 + response: Response; 114 + } 115 + > 116 + : Promise< 117 + TResponseStyle extends 'data' 118 + ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined 119 + : ( 120 + | { 121 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 122 + error: undefined; 123 + } 124 + | { 125 + data: undefined; 126 + error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; 127 + } 128 + ) & { 129 + request: Request; 130 + response: Response; 131 + } 132 + >; 133 + 134 + export interface ClientOptions { 135 + baseUrl?: string; 136 + responseStyle?: ResponseStyle; 137 + throwOnError?: boolean; 138 + } 139 + 140 + type MethodFn = < 141 + TData = unknown, 142 + TError = unknown, 143 + ThrowOnError extends boolean = false, 144 + TResponseStyle extends ResponseStyle = 'fields', 145 + >( 146 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 147 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 148 + 149 + type SseFn = < 150 + TData = unknown, 151 + TError = unknown, 152 + ThrowOnError extends boolean = false, 153 + TResponseStyle extends ResponseStyle = 'fields', 154 + >( 155 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 156 + ) => Promise<ServerSentEventsResult<TData, TError>>; 157 + 158 + type RequestFn = < 159 + TData = unknown, 160 + TError = unknown, 161 + ThrowOnError extends boolean = false, 162 + TResponseStyle extends ResponseStyle = 'fields', 163 + >( 164 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 165 + Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>, 166 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 + 168 + type BuildUrlFn = < 169 + TData extends { 170 + body?: unknown; 171 + path?: Record<string, unknown>; 172 + query?: Record<string, unknown>; 173 + url: string; 174 + }, 175 + >( 176 + options: TData & Options<TData>, 177 + ) => string; 178 + 179 + export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { 180 + interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 181 + }; 182 + 183 + /** 184 + * The `createClientConfig()` function will be called on client initialization 185 + * and the returned object will become the client's initial configuration. 186 + * 187 + * You may want to initialize your client this way instead of calling 188 + * `setConfig()`. This is useful for example if you're using Next.js 189 + * to ensure your client always has the correct values. 190 + */ 191 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 192 + override?: Config<ClientOptions & T>, 193 + ) => Config<Required<ClientOptions> & T>; 194 + 195 + export interface TDataShape { 196 + body?: unknown; 197 + headers?: unknown; 198 + path?: unknown; 199 + query?: unknown; 200 + url: string; 201 + } 202 + 203 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 204 + 205 + export type Options< 206 + TData extends TDataShape = TDataShape, 207 + ThrowOnError extends boolean = boolean, 208 + TResponse = unknown, 209 + TResponseStyle extends ResponseStyle = 'fields', 210 + > = OmitKeys< 211 + RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 212 + 'body' | 'path' | 'query' | 'url' 213 + > & 214 + ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
+316
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 + import { 7 + serializeArrayParam, 8 + serializeObjectParam, 9 + serializePrimitiveParam, 10 + } from '../core/pathSerializer.gen'; 11 + import { getUrl } from '../core/utils.gen'; 12 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 + 14 + export const createQuerySerializer = <T = unknown>({ 15 + parameters = {}, 16 + ...args 17 + }: QuerySerializerOptions = {}) => { 18 + const querySerializer = (queryParams: T) => { 19 + const search: string[] = []; 20 + if (queryParams && typeof queryParams === 'object') { 21 + for (const name in queryParams) { 22 + const value = queryParams[name]; 23 + 24 + if (value === undefined || value === null) { 25 + continue; 26 + } 27 + 28 + const options = parameters[name] || args; 29 + 30 + if (Array.isArray(value)) { 31 + const serializedArray = serializeArrayParam({ 32 + allowReserved: options.allowReserved, 33 + explode: true, 34 + name, 35 + style: 'form', 36 + value, 37 + ...options.array, 38 + }); 39 + if (serializedArray) search.push(serializedArray); 40 + } else if (typeof value === 'object') { 41 + const serializedObject = serializeObjectParam({ 42 + allowReserved: options.allowReserved, 43 + explode: true, 44 + name, 45 + style: 'deepObject', 46 + value: value as Record<string, unknown>, 47 + ...options.object, 48 + }); 49 + if (serializedObject) search.push(serializedObject); 50 + } else { 51 + const serializedPrimitive = serializePrimitiveParam({ 52 + allowReserved: options.allowReserved, 53 + name, 54 + value: value as string, 55 + }); 56 + if (serializedPrimitive) search.push(serializedPrimitive); 57 + } 58 + } 59 + } 60 + return search.join('&'); 61 + }; 62 + return querySerializer; 63 + }; 64 + 65 + /** 66 + * Infers parseAs value from provided Content-Type header. 67 + */ 68 + export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => { 69 + if (!contentType) { 70 + // If no Content-Type header is provided, the best we can do is return the raw response body, 71 + // which is effectively the same as the 'stream' option. 72 + return 'stream'; 73 + } 74 + 75 + const cleanContent = contentType.split(';')[0]?.trim(); 76 + 77 + if (!cleanContent) { 78 + return; 79 + } 80 + 81 + if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) { 82 + return 'json'; 83 + } 84 + 85 + if (cleanContent === 'multipart/form-data') { 86 + return 'formData'; 87 + } 88 + 89 + if ( 90 + ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type)) 91 + ) { 92 + return 'blob'; 93 + } 94 + 95 + if (cleanContent.startsWith('text/')) { 96 + return 'text'; 97 + } 98 + 99 + return; 100 + }; 101 + 102 + const checkForExistence = ( 103 + options: Pick<RequestOptions, 'auth' | 'query'> & { 104 + headers: Headers; 105 + }, 106 + name?: string, 107 + ): boolean => { 108 + if (!name) { 109 + return false; 110 + } 111 + if ( 112 + options.headers.has(name) || 113 + options.query?.[name] || 114 + options.headers.get('Cookie')?.includes(`${name}=`) 115 + ) { 116 + return true; 117 + } 118 + return false; 119 + }; 120 + 121 + export const setAuthParams = async ({ 122 + security, 123 + ...options 124 + }: Pick<Required<RequestOptions>, 'security'> & 125 + Pick<RequestOptions, 'auth' | 'query'> & { 126 + headers: Headers; 127 + }) => { 128 + for (const auth of security) { 129 + if (checkForExistence(options, auth.name)) { 130 + continue; 131 + } 132 + 133 + const token = await getAuthToken(auth, options.auth); 134 + 135 + if (!token) { 136 + continue; 137 + } 138 + 139 + const name = auth.name ?? 'Authorization'; 140 + 141 + switch (auth.in) { 142 + case 'query': 143 + if (!options.query) { 144 + options.query = {}; 145 + } 146 + options.query[name] = token; 147 + break; 148 + case 'cookie': 149 + options.headers.append('Cookie', `${name}=${token}`); 150 + break; 151 + case 'header': 152 + default: 153 + options.headers.set(name, token); 154 + break; 155 + } 156 + } 157 + }; 158 + 159 + export const buildUrl: Client['buildUrl'] = (options) => 160 + getUrl({ 161 + baseUrl: options.baseUrl as string, 162 + path: options.path, 163 + query: options.query, 164 + querySerializer: 165 + typeof options.querySerializer === 'function' 166 + ? options.querySerializer 167 + : createQuerySerializer(options.querySerializer), 168 + url: options.url, 169 + }); 170 + 171 + export const mergeConfigs = (a: Config, b: Config): Config => { 172 + const config = { ...a, ...b }; 173 + if (config.baseUrl?.endsWith('/')) { 174 + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 175 + } 176 + config.headers = mergeHeaders(a.headers, b.headers); 177 + return config; 178 + }; 179 + 180 + const headersEntries = (headers: Headers): Array<[string, string]> => { 181 + const entries: Array<[string, string]> = []; 182 + headers.forEach((value, key) => { 183 + entries.push([key, value]); 184 + }); 185 + return entries; 186 + }; 187 + 188 + export const mergeHeaders = ( 189 + ...headers: Array<Required<Config>['headers'] | undefined> 190 + ): Headers => { 191 + const mergedHeaders = new Headers(); 192 + for (const header of headers) { 193 + if (!header) { 194 + continue; 195 + } 196 + 197 + const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header); 198 + 199 + for (const [key, value] of iterator) { 200 + if (value === null) { 201 + mergedHeaders.delete(key); 202 + } else if (Array.isArray(value)) { 203 + for (const v of value) { 204 + mergedHeaders.append(key, v as string); 205 + } 206 + } else if (value !== undefined) { 207 + // assume object headers are meant to be JSON stringified, i.e. their 208 + // content value in OpenAPI specification is 'application/json' 209 + mergedHeaders.set( 210 + key, 211 + typeof value === 'object' ? JSON.stringify(value) : (value as string), 212 + ); 213 + } 214 + } 215 + } 216 + return mergedHeaders; 217 + }; 218 + 219 + type ErrInterceptor<Err, Res, Req, Options> = ( 220 + error: Err, 221 + response: Res, 222 + request: Req, 223 + options: Options, 224 + ) => Err | Promise<Err>; 225 + 226 + type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; 227 + 228 + type ResInterceptor<Res, Req, Options> = ( 229 + response: Res, 230 + request: Req, 231 + options: Options, 232 + ) => Res | Promise<Res>; 233 + 234 + class Interceptors<Interceptor> { 235 + fns: Array<Interceptor | null> = []; 236 + 237 + clear(): void { 238 + this.fns = []; 239 + } 240 + 241 + eject(id: number | Interceptor): void { 242 + const index = this.getInterceptorIndex(id); 243 + if (this.fns[index]) { 244 + this.fns[index] = null; 245 + } 246 + } 247 + 248 + exists(id: number | Interceptor): boolean { 249 + const index = this.getInterceptorIndex(id); 250 + return Boolean(this.fns[index]); 251 + } 252 + 253 + getInterceptorIndex(id: number | Interceptor): number { 254 + if (typeof id === 'number') { 255 + return this.fns[id] ? id : -1; 256 + } 257 + return this.fns.indexOf(id); 258 + } 259 + 260 + update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false { 261 + const index = this.getInterceptorIndex(id); 262 + if (this.fns[index]) { 263 + this.fns[index] = fn; 264 + return id; 265 + } 266 + return false; 267 + } 268 + 269 + use(fn: Interceptor): number { 270 + this.fns.push(fn); 271 + return this.fns.length - 1; 272 + } 273 + } 274 + 275 + export interface Middleware<Req, Res, Err, Options> { 276 + error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 277 + request: Interceptors<ReqInterceptor<Req, Options>>; 278 + response: Interceptors<ResInterceptor<Res, Req, Options>>; 279 + } 280 + 281 + export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 282 + Req, 283 + Res, 284 + Err, 285 + Options 286 + > => ({ 287 + error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 288 + request: new Interceptors<ReqInterceptor<Req, Options>>(), 289 + response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 290 + }); 291 + 292 + const defaultQuerySerializer = createQuerySerializer({ 293 + allowReserved: false, 294 + array: { 295 + explode: true, 296 + style: 'form', 297 + }, 298 + object: { 299 + explode: true, 300 + style: 'deepObject', 301 + }, 302 + }); 303 + 304 + const defaultHeaders = { 305 + 'Content-Type': 'application/json', 306 + }; 307 + 308 + export const createConfig = <T extends ClientOptions = ClientOptions>( 309 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 310 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 311 + ...jsonBodySerializer, 312 + headers: defaultHeaders, 313 + parseAs: 'auto', 314 + querySerializer: defaultQuerySerializer, 315 + ...override, 316 + });
+41
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = typeof callback === 'function' ? await callback(auth) : callback; 27 + 28 + if (!token) { 29 + return; 30 + } 31 + 32 + if (auth.scheme === 'bearer') { 33 + return `Bearer ${token}`; 34 + } 35 + 36 + if (auth.scheme === 'basic') { 37 + return `Basic ${btoa(token)}`; 38 + } 39 + 40 + return token; 41 + };
+82
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen'; 4 + 5 + export type QuerySerializer = (query: Record<string, unknown>) => string; 6 + 7 + export type BodySerializer = (body: unknown) => unknown; 8 + 9 + type QuerySerializerOptionsObject = { 10 + allowReserved?: boolean; 11 + array?: Partial<SerializerOptions<ArrayStyle>>; 12 + object?: Partial<SerializerOptions<ObjectStyle>>; 13 + }; 14 + 15 + export type QuerySerializerOptions = QuerySerializerOptionsObject & { 16 + /** 17 + * Per-parameter serialization overrides. When provided, these settings 18 + * override the global array/object settings for specific parameter names. 19 + */ 20 + parameters?: Record<string, QuerySerializerOptionsObject>; 21 + }; 22 + 23 + const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => { 34 + if (typeof value === 'string') { 35 + data.append(key, value); 36 + } else { 37 + data.append(key, JSON.stringify(value)); 38 + } 39 + }; 40 + 41 + export const formDataBodySerializer = { 42 + bodySerializer: (body: unknown): FormData => { 43 + const data = new FormData(); 44 + 45 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 46 + if (value === undefined || value === null) { 47 + return; 48 + } 49 + if (Array.isArray(value)) { 50 + value.forEach((v) => serializeFormDataPair(data, key, v)); 51 + } else { 52 + serializeFormDataPair(data, key, value); 53 + } 54 + }); 55 + 56 + return data; 57 + }, 58 + }; 59 + 60 + export const jsonBodySerializer = { 61 + bodySerializer: (body: unknown): string => 62 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 63 + }; 64 + 65 + export const urlSearchParamsBodySerializer = { 66 + bodySerializer: (body: unknown): string => { 67 + const data = new URLSearchParams(); 68 + 69 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 70 + if (value === undefined || value === null) { 71 + return; 72 + } 73 + if (Array.isArray(value)) { 74 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 75 + } else { 76 + serializeUrlSearchParamsPair(data, key, value); 77 + } 78 + }); 79 + 80 + return data.toString(); 81 + }, 82 + };
+169
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + } 26 + | { 27 + /** 28 + * Field name. This is the name we want the user to see and use. 29 + */ 30 + key: string; 31 + /** 32 + * Field mapped name. This is the name we want to use in the request. 33 + * If `in` is omitted, `map` aliases `key` to the transport layer. 34 + */ 35 + map: Slot; 36 + }; 37 + 38 + export interface Fields { 39 + allowExtra?: Partial<Record<Slot, boolean>>; 40 + args?: ReadonlyArray<Field>; 41 + } 42 + 43 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 + 45 + const extraPrefixesMap: Record<string, Slot> = { 46 + $body_: 'body', 47 + $headers_: 'headers', 48 + $path_: 'path', 49 + $query_: 'query', 50 + }; 51 + const extraPrefixes = Object.entries(extraPrefixesMap); 52 + 53 + type KeyMap = Map< 54 + string, 55 + | { 56 + in: Slot; 57 + map?: string; 58 + } 59 + | { 60 + in?: never; 61 + map: Slot; 62 + } 63 + >; 64 + 65 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 + if (!map) { 67 + map = new Map(); 68 + } 69 + 70 + for (const config of fields) { 71 + if ('in' in config) { 72 + if (config.key) { 73 + map.set(config.key, { 74 + in: config.in, 75 + map: config.map, 76 + }); 77 + } 78 + } else if ('key' in config) { 79 + map.set(config.key, { 80 + map: config.map, 81 + }); 82 + } else if (config.args) { 83 + buildKeyMap(config.args, map); 84 + } 85 + } 86 + 87 + return map; 88 + }; 89 + 90 + interface Params { 91 + body: unknown; 92 + headers: Record<string, unknown>; 93 + path: Record<string, unknown>; 94 + query: Record<string, unknown>; 95 + } 96 + 97 + const stripEmptySlots = (params: Params) => { 98 + for (const [slot, value] of Object.entries(params)) { 99 + if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) { 100 + delete params[slot as Slot]; 101 + } 102 + } 103 + }; 104 + 105 + export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => { 106 + const params: Params = { 107 + body: {}, 108 + headers: {}, 109 + path: {}, 110 + query: {}, 111 + }; 112 + 113 + const map = buildKeyMap(fields); 114 + 115 + let config: FieldsConfig[number] | undefined; 116 + 117 + for (const [index, arg] of args.entries()) { 118 + if (fields[index]) { 119 + config = fields[index]; 120 + } 121 + 122 + if (!config) { 123 + continue; 124 + } 125 + 126 + if ('in' in config) { 127 + if (config.key) { 128 + const field = map.get(config.key)!; 129 + const name = field.map || config.key; 130 + if (field.in) { 131 + (params[field.in] as Record<string, unknown>)[name] = arg; 132 + } 133 + } else { 134 + params.body = arg; 135 + } 136 + } else { 137 + for (const [key, value] of Object.entries(arg ?? {})) { 138 + const field = map.get(key); 139 + 140 + if (field) { 141 + if (field.in) { 142 + const name = field.map || key; 143 + (params[field.in] as Record<string, unknown>)[name] = value; 144 + } else { 145 + params[field.map] = value; 146 + } 147 + } else { 148 + const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 149 + 150 + if (extra) { 151 + const [prefix, slot] = extra; 152 + (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value; 153 + } else if ('allowExtra' in config && config.allowExtra) { 154 + for (const [slot, allowed] of Object.entries(config.allowExtra)) { 155 + if (allowed) { 156 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 157 + break; 158 + } 159 + } 160 + } 161 + } 162 + } 163 + } 164 + } 165 + 166 + stripEmptySlots(params); 167 + 168 + return params; 169 + };
+171
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {} 4 + 5 + interface SerializePrimitiveOptions { 6 + allowReserved?: boolean; 7 + name: string; 8 + } 9 + 10 + export interface SerializerOptions<T> { 11 + /** 12 + * @default true 13 + */ 14 + explode: boolean; 15 + style: T; 16 + } 17 + 18 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 19 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 20 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 21 + export type ObjectStyle = 'form' | 'deepObject'; 22 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 23 + 24 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 25 + value: string; 26 + } 27 + 28 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 29 + switch (style) { 30 + case 'label': 31 + return '.'; 32 + case 'matrix': 33 + return ';'; 34 + case 'simple': 35 + return ','; 36 + default: 37 + return '&'; 38 + } 39 + }; 40 + 41 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 42 + switch (style) { 43 + case 'form': 44 + return ','; 45 + case 'pipeDelimited': 46 + return '|'; 47 + case 'spaceDelimited': 48 + return '%20'; 49 + default: 50 + return ','; 51 + } 52 + }; 53 + 54 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 55 + switch (style) { 56 + case 'label': 57 + return '.'; 58 + case 'matrix': 59 + return ';'; 60 + case 'simple': 61 + return ','; 62 + default: 63 + return '&'; 64 + } 65 + }; 66 + 67 + export const serializeArrayParam = ({ 68 + allowReserved, 69 + explode, 70 + name, 71 + style, 72 + value, 73 + }: SerializeOptions<ArraySeparatorStyle> & { 74 + value: unknown[]; 75 + }) => { 76 + if (!explode) { 77 + const joinedValues = ( 78 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 79 + ).join(separatorArrayNoExplode(style)); 80 + switch (style) { 81 + case 'label': 82 + return `.${joinedValues}`; 83 + case 'matrix': 84 + return `;${name}=${joinedValues}`; 85 + case 'simple': 86 + return joinedValues; 87 + default: 88 + return `${name}=${joinedValues}`; 89 + } 90 + } 91 + 92 + const separator = separatorArrayExplode(style); 93 + const joinedValues = value 94 + .map((v) => { 95 + if (style === 'label' || style === 'simple') { 96 + return allowReserved ? v : encodeURIComponent(v as string); 97 + } 98 + 99 + return serializePrimitiveParam({ 100 + allowReserved, 101 + name, 102 + value: v as string, 103 + }); 104 + }) 105 + .join(separator); 106 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 107 + }; 108 + 109 + export const serializePrimitiveParam = ({ 110 + allowReserved, 111 + name, 112 + value, 113 + }: SerializePrimitiveParam) => { 114 + if (value === undefined || value === null) { 115 + return ''; 116 + } 117 + 118 + if (typeof value === 'object') { 119 + throw new Error( 120 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 121 + ); 122 + } 123 + 124 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 125 + }; 126 + 127 + export const serializeObjectParam = ({ 128 + allowReserved, 129 + explode, 130 + name, 131 + style, 132 + value, 133 + valueOnly, 134 + }: SerializeOptions<ObjectSeparatorStyle> & { 135 + value: Record<string, unknown> | Date; 136 + valueOnly?: boolean; 137 + }) => { 138 + if (value instanceof Date) { 139 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 140 + } 141 + 142 + if (style !== 'deepObject' && !explode) { 143 + let values: string[] = []; 144 + Object.entries(value).forEach(([key, v]) => { 145 + values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]; 146 + }); 147 + const joinedValues = values.join(','); 148 + switch (style) { 149 + case 'form': 150 + return `${name}=${joinedValues}`; 151 + case 'label': 152 + return `.${joinedValues}`; 153 + case 'matrix': 154 + return `;${name}=${joinedValues}`; 155 + default: 156 + return joinedValues; 157 + } 158 + } 159 + 160 + const separator = separatorObjectExplode(style); 161 + const joinedValues = Object.entries(value) 162 + .map(([key, v]) => 163 + serializePrimitiveParam({ 164 + allowReserved, 165 + name: style === 'deepObject' ? `${name}[${key}]` : key, 166 + value: v as string, 167 + }), 168 + ) 169 + .join(separator); 170 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 171 + };
+117
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/queryKeySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * JSON-friendly union that mirrors what Pinia Colada can hash. 5 + */ 6 + export type JsonValue = 7 + | null 8 + | string 9 + | number 10 + | boolean 11 + | JsonValue[] 12 + | { [key: string]: JsonValue }; 13 + 14 + /** 15 + * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 + */ 17 + export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 19 + return undefined; 20 + } 21 + if (typeof value === 'bigint') { 22 + return value.toString(); 23 + } 24 + if (value instanceof Date) { 25 + return value.toISOString(); 26 + } 27 + return value; 28 + }; 29 + 30 + /** 31 + * Safely stringifies a value and parses it back into a JsonValue. 32 + */ 33 + export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 34 + try { 35 + const json = JSON.stringify(input, queryKeyJsonReplacer); 36 + if (json === undefined) { 37 + return undefined; 38 + } 39 + return JSON.parse(json) as JsonValue; 40 + } catch { 41 + return undefined; 42 + } 43 + }; 44 + 45 + /** 46 + * Detects plain objects (including objects with a null prototype). 47 + */ 48 + const isPlainObject = (value: unknown): value is Record<string, unknown> => { 49 + if (value === null || typeof value !== 'object') { 50 + return false; 51 + } 52 + const prototype = Object.getPrototypeOf(value as object); 53 + return prototype === Object.prototype || prototype === null; 54 + }; 55 + 56 + /** 57 + * Turns URLSearchParams into a sorted JSON object for deterministic keys. 58 + */ 59 + const serializeSearchParams = (params: URLSearchParams): JsonValue => { 60 + const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b)); 61 + const result: Record<string, JsonValue> = {}; 62 + 63 + for (const [key, value] of entries) { 64 + const existing = result[key]; 65 + if (existing === undefined) { 66 + result[key] = value; 67 + continue; 68 + } 69 + 70 + if (Array.isArray(existing)) { 71 + (existing as string[]).push(value); 72 + } else { 73 + result[key] = [existing, value]; 74 + } 75 + } 76 + 77 + return result; 78 + }; 79 + 80 + /** 81 + * Normalizes any accepted value into a JSON-friendly shape for query keys. 82 + */ 83 + export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => { 84 + if (value === null) { 85 + return null; 86 + } 87 + 88 + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 89 + return value; 90 + } 91 + 92 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 93 + return undefined; 94 + } 95 + 96 + if (typeof value === 'bigint') { 97 + return value.toString(); 98 + } 99 + 100 + if (value instanceof Date) { 101 + return value.toISOString(); 102 + } 103 + 104 + if (Array.isArray(value)) { 105 + return stringifyToJsonValue(value); 106 + } 107 + 108 + if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) { 109 + return serializeSearchParams(value); 110 + } 111 + 112 + if (isPlainObject(value)) { 113 + return stringifyToJsonValue(value); 114 + } 115 + 116 + return undefined; 117 + };
+243
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & 6 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 7 + /** 8 + * Fetch API implementation. You can use this option to provide a custom 9 + * fetch instance. 10 + * 11 + * @default globalThis.fetch 12 + */ 13 + fetch?: typeof fetch; 14 + /** 15 + * Implementing clients can call request interceptors inside this hook. 16 + */ 17 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 18 + /** 19 + * Callback invoked when a network or parsing error occurs during streaming. 20 + * 21 + * This option applies only if the endpoint returns a stream of events. 22 + * 23 + * @param error The error that occurred. 24 + */ 25 + onSseError?: (error: unknown) => void; 26 + /** 27 + * Callback invoked when an event is streamed from the server. 28 + * 29 + * This option applies only if the endpoint returns a stream of events. 30 + * 31 + * @param event Event streamed from the server. 32 + * @returns Nothing (void). 33 + */ 34 + onSseEvent?: (event: StreamEvent<TData>) => void; 35 + serializedBody?: RequestInit['body']; 36 + /** 37 + * Default retry delay in milliseconds. 38 + * 39 + * This option applies only if the endpoint returns a stream of events. 40 + * 41 + * @default 3000 42 + */ 43 + sseDefaultRetryDelay?: number; 44 + /** 45 + * Maximum number of retry attempts before giving up. 46 + */ 47 + sseMaxRetryAttempts?: number; 48 + /** 49 + * Maximum retry delay in milliseconds. 50 + * 51 + * Applies only when exponential backoff is used. 52 + * 53 + * This option applies only if the endpoint returns a stream of events. 54 + * 55 + * @default 30000 56 + */ 57 + sseMaxRetryDelay?: number; 58 + /** 59 + * Optional sleep function for retry backoff. 60 + * 61 + * Defaults to using `setTimeout`. 62 + */ 63 + sseSleepFn?: (ms: number) => Promise<void>; 64 + url: string; 65 + }; 66 + 67 + export interface StreamEvent<TData = unknown> { 68 + data: TData; 69 + event?: string; 70 + id?: string; 71 + retry?: number; 72 + } 73 + 74 + export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { 75 + stream: AsyncGenerator< 76 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 77 + TReturn, 78 + TNext 79 + >; 80 + }; 81 + 82 + export const createSseClient = <TData = unknown>({ 83 + onRequest, 84 + onSseError, 85 + onSseEvent, 86 + responseTransformer, 87 + responseValidator, 88 + sseDefaultRetryDelay, 89 + sseMaxRetryAttempts, 90 + sseMaxRetryDelay, 91 + sseSleepFn, 92 + url, 93 + ...options 94 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 95 + let lastEventId: string | undefined; 96 + 97 + const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 98 + 99 + const createStream = async function* () { 100 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 101 + let attempt = 0; 102 + const signal = options.signal ?? new AbortController().signal; 103 + 104 + while (true) { 105 + if (signal.aborted) break; 106 + 107 + attempt++; 108 + 109 + const headers = 110 + options.headers instanceof Headers 111 + ? options.headers 112 + : new Headers(options.headers as Record<string, string> | undefined); 113 + 114 + if (lastEventId !== undefined) { 115 + headers.set('Last-Event-ID', lastEventId); 116 + } 117 + 118 + try { 119 + const requestInit: RequestInit = { 120 + redirect: 'follow', 121 + ...options, 122 + body: options.serializedBody, 123 + headers, 124 + signal, 125 + }; 126 + let request = new Request(url, requestInit); 127 + if (onRequest) { 128 + request = await onRequest(url, requestInit); 129 + } 130 + // fetch must be assigned here, otherwise it would throw the error: 131 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 132 + const _fetch = options.fetch ?? globalThis.fetch; 133 + const response = await _fetch(request); 134 + 135 + if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`); 136 + 137 + if (!response.body) throw new Error('No body in SSE response'); 138 + 139 + const reader = response.body.pipeThrough(new TextDecoderStream()).getReader(); 140 + 141 + let buffer = ''; 142 + 143 + const abortHandler = () => { 144 + try { 145 + reader.cancel(); 146 + } catch { 147 + // noop 148 + } 149 + }; 150 + 151 + signal.addEventListener('abort', abortHandler); 152 + 153 + try { 154 + while (true) { 155 + const { done, value } = await reader.read(); 156 + if (done) break; 157 + buffer += value; 158 + // Normalize line endings: CRLF -> LF, then CR -> LF 159 + buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 160 + 161 + const chunks = buffer.split('\n\n'); 162 + buffer = chunks.pop() ?? ''; 163 + 164 + for (const chunk of chunks) { 165 + const lines = chunk.split('\n'); 166 + const dataLines: Array<string> = []; 167 + let eventName: string | undefined; 168 + 169 + for (const line of lines) { 170 + if (line.startsWith('data:')) { 171 + dataLines.push(line.replace(/^data:\s*/, '')); 172 + } else if (line.startsWith('event:')) { 173 + eventName = line.replace(/^event:\s*/, ''); 174 + } else if (line.startsWith('id:')) { 175 + lastEventId = line.replace(/^id:\s*/, ''); 176 + } else if (line.startsWith('retry:')) { 177 + const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10); 178 + if (!Number.isNaN(parsed)) { 179 + retryDelay = parsed; 180 + } 181 + } 182 + } 183 + 184 + let data: unknown; 185 + let parsedJson = false; 186 + 187 + if (dataLines.length) { 188 + const rawData = dataLines.join('\n'); 189 + try { 190 + data = JSON.parse(rawData); 191 + parsedJson = true; 192 + } catch { 193 + data = rawData; 194 + } 195 + } 196 + 197 + if (parsedJson) { 198 + if (responseValidator) { 199 + await responseValidator(data); 200 + } 201 + 202 + if (responseTransformer) { 203 + data = await responseTransformer(data); 204 + } 205 + } 206 + 207 + onSseEvent?.({ 208 + data, 209 + event: eventName, 210 + id: lastEventId, 211 + retry: retryDelay, 212 + }); 213 + 214 + if (dataLines.length) { 215 + yield data as any; 216 + } 217 + } 218 + } 219 + } finally { 220 + signal.removeEventListener('abort', abortHandler); 221 + reader.releaseLock(); 222 + } 223 + 224 + break; // exit loop on normal completion 225 + } catch (error) { 226 + // connection failed or aborted; retry after delay 227 + onSseError?.(error); 228 + 229 + if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) { 230 + break; // stop after firing error 231 + } 232 + 233 + // exponential backoff: double retry each attempt, cap at 30s 234 + const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000); 235 + await sleep(backoff); 236 + } 237 + } 238 + }; 239 + 240 + const stream = createStream(); 241 + 242 + return { stream }; 243 + };
+104
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen'; 5 + 6 + export type HttpMethod = 7 + | 'connect' 8 + | 'delete' 9 + | 'get' 10 + | 'head' 11 + | 'options' 12 + | 'patch' 13 + | 'post' 14 + | 'put' 15 + | 'trace'; 16 + 17 + export type Client< 18 + RequestFn = never, 19 + Config = unknown, 20 + MethodFn = never, 21 + BuildUrlFn = never, 22 + SseFn = never, 23 + > = { 24 + /** 25 + * Returns the final request URL. 26 + */ 27 + buildUrl: BuildUrlFn; 28 + getConfig: () => Config; 29 + request: RequestFn; 30 + setConfig: (config: Config) => Config; 31 + } & { 32 + [K in HttpMethod]: MethodFn; 33 + } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } }); 34 + 35 + export interface Config { 36 + /** 37 + * Auth token or a function returning auth token. The resolved value will be 38 + * added to the request payload as defined by its `security` array. 39 + */ 40 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 41 + /** 42 + * A function for serializing request body parameter. By default, 43 + * {@link JSON.stringify()} will be used. 44 + */ 45 + bodySerializer?: BodySerializer | null; 46 + /** 47 + * An object containing any HTTP headers that you want to pre-populate your 48 + * `Headers` object with. 49 + * 50 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 51 + */ 52 + headers?: 53 + | RequestInit['headers'] 54 + | Record< 55 + string, 56 + string | number | boolean | (string | number | boolean)[] | null | undefined | unknown 57 + >; 58 + /** 59 + * The request method. 60 + * 61 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 62 + */ 63 + method?: Uppercase<HttpMethod>; 64 + /** 65 + * A function for serializing request query parameters. By default, arrays 66 + * will be exploded in form style, objects will be exploded in deepObject 67 + * style, and reserved characters are percent-encoded. 68 + * 69 + * This method will have no effect if the native `paramsSerializer()` Axios 70 + * API function is used. 71 + * 72 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 73 + */ 74 + querySerializer?: QuerySerializer | QuerySerializerOptions; 75 + /** 76 + * A function validating request data. This is useful if you want to ensure 77 + * the request conforms to the desired shape, so it can be safely sent to 78 + * the server. 79 + */ 80 + requestValidator?: (data: unknown) => Promise<unknown>; 81 + /** 82 + * A function transforming response data before it's returned. This is useful 83 + * for post-processing data, e.g. converting ISO strings into Date objects. 84 + */ 85 + responseTransformer?: (data: unknown) => Promise<unknown>; 86 + /** 87 + * A function validating response data. This is useful if you want to ensure 88 + * the response conforms to the desired shape, so it can be safely passed to 89 + * the transformers and returned to the user. 90 + */ 91 + responseValidator?: (data: unknown) => Promise<unknown>; 92 + } 93 + 94 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 95 + ? true 96 + : [T] extends [never | undefined] 97 + ? [undefined] extends [T] 98 + ? false 99 + : true 100 + : false; 101 + 102 + export type OmitNever<T extends Record<string, unknown>> = { 103 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]; 104 + };
+140
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace(match, serializeArrayParam({ explode, name, style, value })); 48 + continue; 49 + } 50 + 51 + if (typeof value === 'object') { 52 + url = url.replace( 53 + match, 54 + serializeObjectParam({ 55 + explode, 56 + name, 57 + style, 58 + value: value as Record<string, unknown>, 59 + valueOnly: true, 60 + }), 61 + ); 62 + continue; 63 + } 64 + 65 + if (style === 'matrix') { 66 + url = url.replace( 67 + match, 68 + `;${serializePrimitiveParam({ 69 + name, 70 + value: value as string, 71 + })}`, 72 + ); 73 + continue; 74 + } 75 + 76 + const replaceValue = encodeURIComponent( 77 + style === 'label' ? `.${value as string}` : (value as string), 78 + ); 79 + url = url.replace(match, replaceValue); 80 + } 81 + } 82 + return url; 83 + }; 84 + 85 + export const getUrl = ({ 86 + baseUrl, 87 + path, 88 + query, 89 + querySerializer, 90 + url: _url, 91 + }: { 92 + baseUrl?: string; 93 + path?: Record<string, unknown>; 94 + query?: Record<string, unknown>; 95 + querySerializer: QuerySerializer; 96 + url: string; 97 + }) => { 98 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 99 + let url = (baseUrl ?? '') + pathUrl; 100 + if (path) { 101 + url = defaultPathSerializer({ path, url }); 102 + } 103 + let search = query ? querySerializer(query) : ''; 104 + if (search.startsWith('?')) { 105 + search = search.substring(1); 106 + } 107 + if (search) { 108 + url += `?${search}`; 109 + } 110 + return url; 111 + }; 112 + 113 + export function getValidRequestBody(options: { 114 + body?: unknown; 115 + bodySerializer?: BodySerializer | null; 116 + serializedBody?: unknown; 117 + }) { 118 + const hasBody = options.body !== undefined; 119 + const isSerializedBody = hasBody && options.bodySerializer; 120 + 121 + if (isSerializedBody) { 122 + if ('serializedBody' in options) { 123 + const hasSerializedBody = 124 + options.serializedBody !== undefined && options.serializedBody !== ''; 125 + 126 + return hasSerializedBody ? options.serializedBody : null; 127 + } 128 + 129 + // not all clients implement a serializedBody property (i.e. client-axios) 130 + return options.body !== '' ? options.body : null; 131 + } 132 + 133 + // plain/text body 134 + if (hasBody) { 135 + return options.body; 136 + } 137 + 138 + // no body was provided 139 + return undefined; 140 + }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export { apiVVersionODataControllerCount, callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexParams, complexTypes, deleteCallWithoutParametersAndResponse, deleteFoo, deprecatedCall, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, export_, fileResponse, fooWow, getApiVbyApiVersionSimpleOperation, getCallWithOptionalParam, getCallWithoutParametersAndResponse, headCallWithoutParametersAndResponse, import_, multipartRequest, multipartResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, optionsCallWithoutParametersAndResponse, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionFormData, postApiVbyApiVersionRequestBody, postCallWithOptionalParam, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, putWithFormUrlEncoded, testErrorCode, types, uploadFile } from './sdk.gen'; 4 + export type { _3eNum1Период, _400, AdditionalPropertiesIntegerIssue, AdditionalPropertiesUnknownIssue, AdditionalPropertiesUnknownIssue2, AdditionalPropertiesUnknownIssue3, AdditionalPropertiesUnknownIssueWritable, AnyOfAnyAndNull, AnyOfArrays, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountResponses, ArrayWithAnyOfProperties, ArrayWithArray, ArrayWithBooleans, ArrayWithNumbers, ArrayWithProperties, ArrayWithReferences, ArrayWithStrings, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponse, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesError, CallWithResponsesErrors, CallWithResponsesResponse, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CamelCaseCommentWithBreaks, CharactersInDescription, ClientOptions, CollectionFormatData, CommentWithBackticks, CommentWithBackticksAndQuotes, CommentWithBreaks, CommentWithExpressionPlaceholders, CommentWithQuotes, CommentWithReservedCharacters, CommentWithSlashes, ComplexParamsData, ComplexParamsResponse, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponse, ComplexTypesResponses, CompositionBaseModel, CompositionExtendedModel, CompositionWithAllOfAndNullable, CompositionWithAnyOf, CompositionWithAnyOfAndNullable, CompositionWithAnyOfAnonymous, CompositionWithNestedAnyAndTypeNull, CompositionWithNestedAnyOfAndNull, CompositionWithOneOf, CompositionWithOneOfAndComplexArrayDictionary, CompositionWithOneOfAndNullable, CompositionWithOneOfAndProperties, CompositionWithOneOfAndSimpleArrayDictionary, CompositionWithOneOfAndSimpleDictionary, CompositionWithOneOfAnonymous, CompositionWithOneOfDiscriminator, ConstValue, Default, DeleteCallWithoutParametersAndResponseData, DeleteFooData, DeleteFooData2, DeleteFooData3, DeprecatedCallData, DeprecatedModel, DictionaryWithArray, DictionaryWithDictionary, DictionaryWithProperties, DictionaryWithPropertiesAndAdditionalProperties, DictionaryWithReference, DictionaryWithString, DummyAData, DummyAResponse, DummyAResponses, DummyBData, DummyBResponse, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, EnumFromDescription, EnumWithExtensions, EnumWithNumbers, EnumWithReplacedCharacters, EnumWithStrings, EnumWithXEnumNames, ExportData, ExternalRefA, ExternalRefB, ExternalSharedModel, File, FileResponseData, FileResponseResponse, FileResponseResponses, FileWritable, FooWowData, FooWowResponses, FreeFormObjectWithAdditionalPropertiesEqEmptyObject, FreeFormObjectWithAdditionalPropertiesEqTrue, FreeFormObjectWithoutAdditionalProperties, GenericSchemaDuplicateIssue1SystemBoolean, GenericSchemaDuplicateIssue1SystemBooleanWritable, GenericSchemaDuplicateIssue1SystemString, GenericSchemaDuplicateIssue1SystemStringWritable, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, Import, ImportData, ImportResponse, ImportResponses, IoK8sApimachineryPkgApisMetaV1DeleteOptions, IoK8sApimachineryPkgApisMetaV1Preconditions, ModelCircle, ModelFromZendesk, ModelSquare, ModelThatExtends, ModelThatExtendsExtends, ModelWithAdditionalPropertiesEqTrue, ModelWithAdditionalPropertiesRef, ModelWithAnyOfConstantSizeArray, ModelWithAnyOfConstantSizeArrayAndIntersect, ModelWithAnyOfConstantSizeArrayNullable, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable, ModelWithArray, ModelWithArrayReadOnlyAndWriteOnly, ModelWithArrayReadOnlyAndWriteOnlyWritable, ModelWithBackticksInDescription, ModelWithBoolean, ModelWithCircularReference, ModelWithConst, ModelWithConstantSizeArray, ModelWithDictionary, ModelWithDuplicateImports, ModelWithDuplicateProperties, ModelWithEnum, ModelWithEnumFromDescription, ModelWithEnumWithHyphen, ModelWithInteger, ModelWithNestedArrayEnums, ModelWithNestedArrayEnumsData, ModelWithNestedArrayEnumsDataBar, ModelWithNestedArrayEnumsDataFoo, ModelWithNestedCompositionEnums, ModelWithNestedEnums, ModelWithNestedProperties, ModelWithNullableObject, ModelWithNullableString, ModelWithNumericEnumUnion, ModelWithOneOfAndProperties, ModelWithOneOfEnum, ModelWithOrderedProperties, ModelWithPattern, ModelWithPatternWritable, ModelWithPrefixItemsConstantSizeArray, ModelWithProperties, ModelWithPropertiesWritable, ModelWithReadOnlyAndWriteOnly, ModelWithReadOnlyAndWriteOnlyWritable, ModelWithReference, ModelWithReferenceWritable, ModelWithString, ModelWithStringError, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, MultipartResponseResponses, NestedAnyOfArraysNullable, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Responses, NonAsciiStringæøåÆøÅöôêÊ字符串, NullableObject, OneOfAllOfIssue, OneOfAllOfIssueWritable, OptionsCallWithoutParametersAndResponseData, Pageable, ParameterSimpleParameterUnused, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PostServiceWithEmptyTagResponse, PostServiceWithEmptyTagResponse2, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, SchemaWithFormRestrictedKeys, SimpleBoolean, SimpleFile, SimpleFormData, SimpleInteger, SimpleParameter, SimpleReference, SimpleRequestBody, SimpleString, SimpleStringWithPattern, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponse, TypesResponses, UploadFileData, UploadFileResponse, UploadFileResponses, XFooBar } from './types.gen';
+206
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Client, formDataBodySerializer, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client'; 4 + import { client } from './client.gen'; 5 + import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponses, DummyBData, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ImportData, ImportResponses, MultipartRequestData, MultipartResponseData, MultipartResponseResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponses, UploadFileData, UploadFileResponses } from './types.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 22 + 23 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => (options?.client ?? client).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 24 + 25 + export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => (options.client ?? client).post<ImportResponses, unknown, ThrowOnError>({ 26 + url: '/api/v{api-version}/no+tag', 27 + ...options, 28 + headers: { 29 + 'Content-Type': 'application/json', 30 + ...options.headers 31 + } 32 + }); 33 + 34 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => (options?.client ?? client).put<FooWowResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 35 + 36 + export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => (options?.client ?? client).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple/$count', ...options }); 37 + 38 + export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => (options.client ?? client).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ url: '/api/v{api-version}/simple:operation', ...options }); 39 + 40 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 41 + 42 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 43 + 44 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).head<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 45 + 46 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).options<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 47 + 48 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).patch<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 49 + 50 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 51 + 52 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 53 + 54 + export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => (options.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); 55 + 56 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/descriptions', ...options }); 57 + 58 + /** 59 + * @deprecated 60 + */ 61 + export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/parameters/deprecated', ...options }); 62 + 63 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 64 + url: '/api/v{api-version}/parameters/{parameterPath}', 65 + ...options, 66 + headers: { 67 + 'Content-Type': 'application/json', 68 + ...options.headers 69 + } 70 + }); 71 + 72 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 73 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 74 + ...options, 75 + headers: { 76 + 'Content-Type': 'application/json', 77 + ...options.headers 78 + } 79 + }); 80 + 81 + export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ 82 + url: '/api/v{api-version}/parameters', 83 + ...options, 84 + headers: { 85 + 'Content-Type': 'application/json', 86 + ...options.headers 87 + } 88 + }); 89 + 90 + export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 91 + url: '/api/v{api-version}/parameters', 92 + ...options, 93 + headers: { 94 + 'Content-Type': 'application/json', 95 + ...options.headers 96 + } 97 + }); 98 + 99 + export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 100 + url: '/api/v{api-version}/requestBody', 101 + ...options, 102 + headers: { 103 + 'Content-Type': 'application/json', 104 + ...options?.headers 105 + } 106 + }); 107 + 108 + export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 109 + ...formDataBodySerializer, 110 + url: '/api/v{api-version}/formData', 111 + ...options, 112 + headers: { 113 + 'Content-Type': null, 114 + ...options?.headers 115 + } 116 + }); 117 + 118 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 119 + 120 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 121 + 122 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 123 + 124 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 125 + 126 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 127 + 128 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 129 + 130 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 131 + 132 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no-content', ...options }); 133 + 134 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); 135 + 136 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => (options?.client ?? client).get<DummyAResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/a', ...options }); 137 + 138 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => (options?.client ?? client).get<DummyBResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/b', ...options }); 139 + 140 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 141 + 142 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => (options?.client ?? client).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 143 + 144 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => (options?.client ?? client).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 145 + 146 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/collectionFormat', ...options }); 147 + 148 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => (options.client ?? client).get<TypesResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/types', ...options }); 149 + 150 + export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => (options.client ?? client).post<UploadFileResponses, unknown, ThrowOnError>({ 151 + ...urlSearchParamsBodySerializer, 152 + url: '/api/v{api-version}/upload', 153 + ...options, 154 + headers: { 155 + 'Content-Type': 'application/x-www-form-urlencoded', 156 + ...options.headers 157 + } 158 + }); 159 + 160 + export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => (options.client ?? client).get<FileResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/file/{id}', ...options }); 161 + 162 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => (options.client ?? client).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 163 + querySerializer: { parameters: { parameterObject: { object: { style: 'form' } } } }, 164 + url: '/api/v{api-version}/complex', 165 + ...options 166 + }); 167 + 168 + export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => (options?.client ?? client).get<MultipartResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multipart', ...options }); 169 + 170 + export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 171 + ...formDataBodySerializer, 172 + url: '/api/v{api-version}/multipart', 173 + ...options, 174 + headers: { 175 + 'Content-Type': null, 176 + ...options?.headers 177 + } 178 + }); 179 + 180 + export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => (options.client ?? client).put<ComplexParamsResponses, unknown, ThrowOnError>({ 181 + url: '/api/v{api-version}/complex/{id}', 182 + ...options, 183 + headers: { 184 + 'Content-Type': 'application/json-patch+json', 185 + ...options.headers 186 + } 187 + }); 188 + 189 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => (options?.client ?? client).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ url: '/api/v{api-version}/header', ...options }); 190 + 191 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => (options.client ?? client).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ url: '/api/v{api-version}/error', ...options }); 192 + 193 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => (options.client ?? client).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); 194 + 195 + /** 196 + * Login User 197 + */ 198 + export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ 199 + ...urlSearchParamsBodySerializer, 200 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 201 + ...options, 202 + headers: { 203 + 'Content-Type': 'application/x-www-form-urlencoded', 204 + ...options.headers 205 + } 206 + });
+2081
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/useMutation/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type ClientOptions = { 4 + baseUrl: 'http://localhost:3000/base' | (string & {}); 5 + }; 6 + 7 + /** 8 + * Model with number-only name 9 + */ 10 + export type _400 = string; 11 + 12 + export type ExternalRefA = ExternalSharedModel; 13 + 14 + export type ExternalRefB = ExternalSharedModel; 15 + 16 + /** 17 + * Testing multiline comments in string: First line 18 + * Second line 19 + * 20 + * Fourth line 21 + */ 22 + export type CamelCaseCommentWithBreaks = number; 23 + 24 + /** 25 + * Testing multiline comments in string: First line 26 + * Second line 27 + * 28 + * Fourth line 29 + */ 30 + export type CommentWithBreaks = number; 31 + 32 + /** 33 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 34 + */ 35 + export type CommentWithBackticks = number; 36 + 37 + /** 38 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 39 + */ 40 + export type CommentWithBackticksAndQuotes = number; 41 + 42 + /** 43 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 44 + */ 45 + export type CommentWithSlashes = number; 46 + 47 + /** 48 + * Testing expression placeholders in string: ${expression} should work 49 + */ 50 + export type CommentWithExpressionPlaceholders = number; 51 + 52 + /** 53 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 54 + */ 55 + export type CommentWithQuotes = number; 56 + 57 + /** 58 + * Testing reserved characters in string: * inline * and ** inline ** should work 59 + */ 60 + export type CommentWithReservedCharacters = number; 61 + 62 + /** 63 + * This is a simple number 64 + */ 65 + export type SimpleInteger = number; 66 + 67 + /** 68 + * This is a simple boolean 69 + */ 70 + export type SimpleBoolean = boolean; 71 + 72 + /** 73 + * This is a simple string 74 + */ 75 + export type SimpleString = string; 76 + 77 + /** 78 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 79 + */ 80 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 81 + 82 + /** 83 + * This is a simple file 84 + */ 85 + export type SimpleFile = Blob | File; 86 + 87 + /** 88 + * This is a simple reference 89 + */ 90 + export type SimpleReference = ModelWithString; 91 + 92 + /** 93 + * This is a simple string 94 + */ 95 + export type SimpleStringWithPattern = string | null; 96 + 97 + /** 98 + * This is a simple enum with strings 99 + */ 100 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | '\'Single Quote\'' | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 101 + 102 + export type EnumWithReplacedCharacters = '\'Single Quote\'' | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 103 + 104 + /** 105 + * This is a simple enum with numbers 106 + */ 107 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 108 + 109 + /** 110 + * Success=1,Warning=2,Error=3 111 + */ 112 + export type EnumFromDescription = number; 113 + 114 + /** 115 + * This is a simple enum with numbers 116 + */ 117 + export type EnumWithExtensions = 200 | 400 | 500; 118 + 119 + export type EnumWithXEnumNames = 0 | 1 | 2; 120 + 121 + /** 122 + * This is a simple array with numbers 123 + */ 124 + export type ArrayWithNumbers = Array<number>; 125 + 126 + /** 127 + * This is a simple array with booleans 128 + */ 129 + export type ArrayWithBooleans = Array<boolean>; 130 + 131 + /** 132 + * This is a simple array with strings 133 + */ 134 + export type ArrayWithStrings = Array<string>; 135 + 136 + /** 137 + * This is a simple array with references 138 + */ 139 + export type ArrayWithReferences = Array<ModelWithString>; 140 + 141 + /** 142 + * This is a simple array containing an array 143 + */ 144 + export type ArrayWithArray = Array<Array<ModelWithString>>; 145 + 146 + /** 147 + * This is a simple array with properties 148 + */ 149 + export type ArrayWithProperties = Array<{ 150 + '16x16'?: CamelCaseCommentWithBreaks; 151 + bar?: string; 152 + }>; 153 + 154 + /** 155 + * This is a simple array with any of properties 156 + */ 157 + export type ArrayWithAnyOfProperties = Array<{ 158 + foo?: string; 159 + } | { 160 + bar?: string; 161 + }>; 162 + 163 + export type AnyOfAnyAndNull = { 164 + data?: unknown; 165 + }; 166 + 167 + /** 168 + * This is a simple array with any of properties 169 + */ 170 + export type AnyOfArrays = { 171 + results?: Array<{ 172 + foo?: string; 173 + } | { 174 + bar?: string; 175 + }>; 176 + }; 177 + 178 + /** 179 + * This is a string dictionary 180 + */ 181 + export type DictionaryWithString = { 182 + [key: string]: string; 183 + }; 184 + 185 + export type DictionaryWithPropertiesAndAdditionalProperties = { 186 + foo?: number; 187 + bar?: boolean; 188 + [key: string]: string | number | boolean | undefined; 189 + }; 190 + 191 + /** 192 + * This is a string reference 193 + */ 194 + export type DictionaryWithReference = { 195 + [key: string]: ModelWithString; 196 + }; 197 + 198 + /** 199 + * This is a complex dictionary 200 + */ 201 + export type DictionaryWithArray = { 202 + [key: string]: Array<ModelWithString>; 203 + }; 204 + 205 + /** 206 + * This is a string dictionary 207 + */ 208 + export type DictionaryWithDictionary = { 209 + [key: string]: { 210 + [key: string]: string; 211 + }; 212 + }; 213 + 214 + /** 215 + * This is a complex dictionary 216 + */ 217 + export type DictionaryWithProperties = { 218 + [key: string]: { 219 + foo?: string; 220 + bar?: string; 221 + }; 222 + }; 223 + 224 + /** 225 + * This is a model with one number property 226 + */ 227 + export type ModelWithInteger = { 228 + /** 229 + * This is a simple number property 230 + */ 231 + prop?: number; 232 + }; 233 + 234 + /** 235 + * This is a model with one boolean property 236 + */ 237 + export type ModelWithBoolean = { 238 + /** 239 + * This is a simple boolean property 240 + */ 241 + prop?: boolean; 242 + }; 243 + 244 + /** 245 + * This is a model with one string property 246 + */ 247 + export type ModelWithString = { 248 + /** 249 + * This is a simple string property 250 + */ 251 + prop?: string; 252 + }; 253 + 254 + /** 255 + * This is a model with one string property 256 + */ 257 + export type ModelWithStringError = { 258 + /** 259 + * This is a simple string property 260 + */ 261 + prop?: string; 262 + }; 263 + 264 + /** 265 + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) 266 + */ 267 + export type ModelFromZendesk = string; 268 + 269 + /** 270 + * This is a model with one string property 271 + */ 272 + export type ModelWithNullableString = { 273 + /** 274 + * This is a simple string property 275 + */ 276 + nullableProp1?: string | null; 277 + /** 278 + * This is a simple string property 279 + */ 280 + nullableRequiredProp1: string | null; 281 + /** 282 + * This is a simple string property 283 + */ 284 + nullableProp2?: string | null; 285 + /** 286 + * This is a simple string property 287 + */ 288 + nullableRequiredProp2: string | null; 289 + /** 290 + * This is a simple enum with strings 291 + */ 292 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 293 + }; 294 + 295 + /** 296 + * This is a model with one enum 297 + */ 298 + export type ModelWithEnum = { 299 + /** 300 + * This is a simple enum with strings 301 + */ 302 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 303 + /** 304 + * These are the HTTP error code enums 305 + */ 306 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 307 + /** 308 + * Simple boolean enum 309 + */ 310 + bool?: true; 311 + }; 312 + 313 + /** 314 + * This is a model with one enum with escaped name 315 + */ 316 + export type ModelWithEnumWithHyphen = { 317 + /** 318 + * Foo-Bar-Baz-Qux 319 + */ 320 + 'foo-bar-baz-qux'?: '3.0'; 321 + }; 322 + 323 + /** 324 + * This is a model with one enum 325 + */ 326 + export type ModelWithEnumFromDescription = { 327 + /** 328 + * Success=1,Warning=2,Error=3 329 + */ 330 + test?: number; 331 + }; 332 + 333 + /** 334 + * This is a model with nested enums 335 + */ 336 + export type ModelWithNestedEnums = { 337 + dictionaryWithEnum?: { 338 + [key: string]: 'Success' | 'Warning' | 'Error'; 339 + }; 340 + dictionaryWithEnumFromDescription?: { 341 + [key: string]: number; 342 + }; 343 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 344 + arrayWithDescription?: Array<number>; 345 + /** 346 + * This is a simple enum with strings 347 + */ 348 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 349 + }; 350 + 351 + /** 352 + * This is a model with one property containing a reference 353 + */ 354 + export type ModelWithReference = { 355 + prop?: ModelWithProperties; 356 + }; 357 + 358 + /** 359 + * This is a model with one property containing an array 360 + */ 361 + export type ModelWithArrayReadOnlyAndWriteOnly = { 362 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 363 + propWithFile?: Array<Blob | File>; 364 + propWithNumber?: Array<number>; 365 + }; 366 + 367 + /** 368 + * This is a model with one property containing an array 369 + */ 370 + export type ModelWithArray = { 371 + prop?: Array<ModelWithString>; 372 + propWithFile?: Array<Blob | File>; 373 + propWithNumber?: Array<number>; 374 + }; 375 + 376 + /** 377 + * This is a model with one property containing a dictionary 378 + */ 379 + export type ModelWithDictionary = { 380 + prop?: { 381 + [key: string]: string; 382 + }; 383 + }; 384 + 385 + /** 386 + * This is a deprecated model with a deprecated property 387 + * 388 + * @deprecated 389 + */ 390 + export type DeprecatedModel = { 391 + /** 392 + * This is a deprecated property 393 + * 394 + * @deprecated 395 + */ 396 + prop?: string; 397 + }; 398 + 399 + /** 400 + * This is a model with one property containing a circular reference 401 + */ 402 + export type ModelWithCircularReference = { 403 + prop?: ModelWithCircularReference; 404 + }; 405 + 406 + /** 407 + * This is a model with one property with a 'one of' relationship 408 + */ 409 + export type CompositionWithOneOf = { 410 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 411 + }; 412 + 413 + /** 414 + * This is a model with one property with a 'one of' relationship where the options are not $ref 415 + */ 416 + export type CompositionWithOneOfAnonymous = { 417 + propA?: { 418 + propA?: string; 419 + } | string | number; 420 + }; 421 + 422 + /** 423 + * Circle 424 + */ 425 + export type ModelCircle = { 426 + kind: string; 427 + radius?: number; 428 + }; 429 + 430 + /** 431 + * Square 432 + */ 433 + export type ModelSquare = { 434 + kind: string; 435 + sideLength?: number; 436 + }; 437 + 438 + /** 439 + * This is a model with one property with a 'one of' relationship where the options are not $ref 440 + */ 441 + export type CompositionWithOneOfDiscriminator = ({ 442 + kind: 'circle'; 443 + } & ModelCircle) | ({ 444 + kind: 'square'; 445 + } & ModelSquare); 446 + 447 + /** 448 + * This is a model with one property with a 'any of' relationship 449 + */ 450 + export type CompositionWithAnyOf = { 451 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 452 + }; 453 + 454 + /** 455 + * This is a model with one property with a 'any of' relationship where the options are not $ref 456 + */ 457 + export type CompositionWithAnyOfAnonymous = { 458 + propA?: { 459 + propA?: string; 460 + } | string | number; 461 + }; 462 + 463 + /** 464 + * This is a model with nested 'any of' property with a type null 465 + */ 466 + export type CompositionWithNestedAnyAndTypeNull = { 467 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 468 + }; 469 + 470 + export type _3eNum1Период = 'Bird' | 'Dog'; 471 + 472 + export type ConstValue = 'ConstValue'; 473 + 474 + /** 475 + * This is a model with one property with a 'any of' relationship where the options are not $ref 476 + */ 477 + export type CompositionWithNestedAnyOfAndNull = { 478 + propA?: Array<_3eNum1Период | ConstValue> | null; 479 + }; 480 + 481 + /** 482 + * This is a model with one property with a 'one of' relationship 483 + */ 484 + export type CompositionWithOneOfAndNullable = { 485 + propA?: { 486 + boolean?: boolean; 487 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 488 + }; 489 + 490 + /** 491 + * This is a model that contains a simple dictionary within composition 492 + */ 493 + export type CompositionWithOneOfAndSimpleDictionary = { 494 + propA?: boolean | { 495 + [key: string]: number; 496 + }; 497 + }; 498 + 499 + /** 500 + * This is a model that contains a dictionary of simple arrays within composition 501 + */ 502 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 503 + propA?: boolean | { 504 + [key: string]: Array<boolean>; 505 + }; 506 + }; 507 + 508 + /** 509 + * This is a model that contains a dictionary of complex arrays (composited) within composition 510 + */ 511 + export type CompositionWithOneOfAndComplexArrayDictionary = { 512 + propA?: boolean | { 513 + [key: string]: Array<number | string>; 514 + }; 515 + }; 516 + 517 + /** 518 + * This is a model with one property with a 'all of' relationship 519 + */ 520 + export type CompositionWithAllOfAndNullable = { 521 + propA?: ({ 522 + boolean?: boolean; 523 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 524 + }; 525 + 526 + /** 527 + * This is a model with one property with a 'any of' relationship 528 + */ 529 + export type CompositionWithAnyOfAndNullable = { 530 + propA?: { 531 + boolean?: boolean; 532 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 533 + }; 534 + 535 + /** 536 + * This is a base model with two simple optional properties 537 + */ 538 + export type CompositionBaseModel = { 539 + firstName?: string; 540 + lastname?: string; 541 + }; 542 + 543 + /** 544 + * This is a model that extends the base model 545 + */ 546 + export type CompositionExtendedModel = CompositionBaseModel & { 547 + age: number; 548 + firstName: string; 549 + lastname: string; 550 + }; 551 + 552 + /** 553 + * This is a model with one nested property 554 + */ 555 + export type ModelWithProperties = { 556 + required: string; 557 + readonly requiredAndReadOnly: string; 558 + requiredAndNullable: string | null; 559 + string?: string; 560 + number?: number; 561 + boolean?: boolean; 562 + reference?: ModelWithString; 563 + 'property with space'?: string; 564 + default?: string; 565 + try?: string; 566 + readonly '@namespace.string'?: string; 567 + readonly '@namespace.integer'?: number; 568 + }; 569 + 570 + /** 571 + * This is a model with one nested property 572 + */ 573 + export type ModelWithNestedProperties = { 574 + readonly first: { 575 + readonly second: { 576 + readonly third: string | null; 577 + } | null; 578 + } | null; 579 + }; 580 + 581 + /** 582 + * This is a model with duplicated properties 583 + */ 584 + export type ModelWithDuplicateProperties = { 585 + prop?: ModelWithString; 586 + }; 587 + 588 + /** 589 + * This is a model with ordered properties 590 + */ 591 + export type ModelWithOrderedProperties = { 592 + zebra?: string; 593 + apple?: string; 594 + hawaii?: string; 595 + }; 596 + 597 + /** 598 + * This is a model with duplicated imports 599 + */ 600 + export type ModelWithDuplicateImports = { 601 + propA?: ModelWithString; 602 + propB?: ModelWithString; 603 + propC?: ModelWithString; 604 + }; 605 + 606 + /** 607 + * This is a model that extends another model 608 + */ 609 + export type ModelThatExtends = ModelWithString & { 610 + propExtendsA?: string; 611 + propExtendsB?: ModelWithString; 612 + }; 613 + 614 + /** 615 + * This is a model that extends another model 616 + */ 617 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 618 + propExtendsC?: string; 619 + propExtendsD?: ModelWithString; 620 + }; 621 + 622 + /** 623 + * This is a model that contains a some patterns 624 + */ 625 + export type ModelWithPattern = { 626 + key: string; 627 + name: string; 628 + readonly enabled?: boolean; 629 + readonly modified?: string; 630 + id?: string; 631 + text?: string; 632 + patternWithSingleQuotes?: string; 633 + patternWithNewline?: string; 634 + patternWithBacktick?: string; 635 + patternWithUnicode?: string; 636 + }; 637 + 638 + export type File = { 639 + /** 640 + * Id 641 + */ 642 + readonly id?: string; 643 + /** 644 + * Updated at 645 + */ 646 + readonly updated_at?: string; 647 + /** 648 + * Created at 649 + */ 650 + readonly created_at?: string; 651 + /** 652 + * Mime 653 + */ 654 + mime: string; 655 + /** 656 + * File 657 + */ 658 + readonly file?: string; 659 + }; 660 + 661 + export type Default = { 662 + name?: string; 663 + }; 664 + 665 + export type Pageable = { 666 + page?: number; 667 + size?: number; 668 + sort?: Array<string>; 669 + }; 670 + 671 + /** 672 + * This is a free-form object without additionalProperties. 673 + */ 674 + export type FreeFormObjectWithoutAdditionalProperties = { 675 + [key: string]: unknown; 676 + }; 677 + 678 + /** 679 + * This is a free-form object with additionalProperties: true. 680 + */ 681 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 682 + [key: string]: unknown; 683 + }; 684 + 685 + /** 686 + * This is a free-form object with additionalProperties: {}. 687 + */ 688 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 689 + [key: string]: unknown; 690 + }; 691 + 692 + export type ModelWithConst = { 693 + String?: 'String'; 694 + number?: 0; 695 + null?: unknown; 696 + withType?: 'Some string'; 697 + }; 698 + 699 + /** 700 + * This is a model with one property and additionalProperties: true 701 + */ 702 + export type ModelWithAdditionalPropertiesEqTrue = { 703 + /** 704 + * This is a simple string property 705 + */ 706 + prop?: string; 707 + [key: string]: unknown; 708 + }; 709 + 710 + export type NestedAnyOfArraysNullable = { 711 + nullableArray?: Array<string | boolean> | null; 712 + }; 713 + 714 + export type CompositionWithOneOfAndProperties = ({ 715 + foo: SimpleParameter; 716 + } | { 717 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 718 + }) & { 719 + baz: number | null; 720 + qux: number; 721 + }; 722 + 723 + /** 724 + * An object that can be null 725 + */ 726 + export type NullableObject = { 727 + foo?: string; 728 + } | null; 729 + 730 + /** 731 + * Some % character 732 + */ 733 + export type CharactersInDescription = string; 734 + 735 + export type ModelWithNullableObject = { 736 + data?: NullableObject; 737 + }; 738 + 739 + /** 740 + * An object with additional properties that can be null 741 + */ 742 + export type ModelWithAdditionalPropertiesRef = { 743 + [key: string]: NullableObject | null; 744 + }; 745 + 746 + export type ModelWithOneOfEnum = { 747 + foo: 'Bar'; 748 + } | { 749 + foo: 'Baz'; 750 + } | { 751 + foo: 'Qux'; 752 + } | { 753 + content: string; 754 + foo: 'Quux'; 755 + } | { 756 + content: [ 757 + string, 758 + string 759 + ]; 760 + foo: 'Corge'; 761 + }; 762 + 763 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 764 + 765 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 766 + 767 + export type ModelWithNestedArrayEnumsData = { 768 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 769 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 770 + }; 771 + 772 + export type ModelWithNestedArrayEnums = { 773 + array_strings?: Array<string>; 774 + data?: ModelWithNestedArrayEnumsData; 775 + }; 776 + 777 + export type ModelWithNestedCompositionEnums = { 778 + foo?: ModelWithNestedArrayEnumsDataFoo; 779 + }; 780 + 781 + export type ModelWithReadOnlyAndWriteOnly = { 782 + foo: string; 783 + readonly bar: string; 784 + }; 785 + 786 + export type ModelWithConstantSizeArray = [ 787 + number, 788 + number 789 + ]; 790 + 791 + export type ModelWithAnyOfConstantSizeArray = [ 792 + number | string, 793 + number | string, 794 + number | string 795 + ]; 796 + 797 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 798 + 799 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 800 + number | null | string, 801 + number | null | string, 802 + number | null | string 803 + ]; 804 + 805 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 806 + number | Import, 807 + number | Import 808 + ]; 809 + 810 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 811 + number & string, 812 + number & string 813 + ]; 814 + 815 + export type ModelWithNumericEnumUnion = { 816 + /** 817 + * Период 818 + */ 819 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 820 + }; 821 + 822 + /** 823 + * Some description with `back ticks` 824 + */ 825 + export type ModelWithBackticksInDescription = { 826 + /** 827 + * The template `that` should be used for parsing and importing the contents of the CSV file. 828 + * 829 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 830 + * <pre> 831 + * [ 832 + * { 833 + * "resourceType": "Asset", 834 + * "identifier": { 835 + * "name": "${1}", 836 + * "domain": { 837 + * "name": "${2}", 838 + * "community": { 839 + * "name": "Some Community" 840 + * } 841 + * } 842 + * }, 843 + * "attributes" : { 844 + * "00000000-0000-0000-0000-000000003115" : [ { 845 + * "value" : "${3}" 846 + * } ], 847 + * "00000000-0000-0000-0000-000000000222" : [ { 848 + * "value" : "${4}" 849 + * } ] 850 + * } 851 + * } 852 + * ] 853 + * </pre> 854 + */ 855 + template?: string; 856 + }; 857 + 858 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 859 + baz: number | null; 860 + qux: number; 861 + }; 862 + 863 + /** 864 + * Model used to test deduplication strategy (unused) 865 + */ 866 + export type ParameterSimpleParameterUnused = string; 867 + 868 + /** 869 + * Model used to test deduplication strategy 870 + */ 871 + export type PostServiceWithEmptyTagResponse = string; 872 + 873 + /** 874 + * Model used to test deduplication strategy 875 + */ 876 + export type PostServiceWithEmptyTagResponse2 = string; 877 + 878 + /** 879 + * Model used to test deduplication strategy 880 + */ 881 + export type DeleteFooData = string; 882 + 883 + /** 884 + * Model used to test deduplication strategy 885 + */ 886 + export type DeleteFooData2 = string; 887 + 888 + /** 889 + * Model with restricted keyword name 890 + */ 891 + export type Import = string; 892 + 893 + export type SchemaWithFormRestrictedKeys = { 894 + description?: string; 895 + 'x-enum-descriptions'?: string; 896 + 'x-enum-varnames'?: string; 897 + 'x-enumNames'?: string; 898 + title?: string; 899 + object?: { 900 + description?: string; 901 + 'x-enum-descriptions'?: string; 902 + 'x-enum-varnames'?: string; 903 + 'x-enumNames'?: string; 904 + title?: string; 905 + }; 906 + array?: Array<{ 907 + description?: string; 908 + 'x-enum-descriptions'?: string; 909 + 'x-enum-varnames'?: string; 910 + 'x-enumNames'?: string; 911 + title?: string; 912 + }>; 913 + }; 914 + 915 + /** 916 + * This schema was giving PascalCase transformations a hard time 917 + */ 918 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 919 + /** 920 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 921 + */ 922 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 923 + }; 924 + 925 + /** 926 + * This schema was giving PascalCase transformations a hard time 927 + */ 928 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 929 + /** 930 + * Specifies the target ResourceVersion 931 + */ 932 + resourceVersion?: string; 933 + /** 934 + * Specifies the target UID. 935 + */ 936 + uid?: string; 937 + }; 938 + 939 + export type AdditionalPropertiesUnknownIssue = { 940 + [key: string]: string | number; 941 + }; 942 + 943 + export type AdditionalPropertiesUnknownIssue2 = { 944 + [key: string]: string | number; 945 + }; 946 + 947 + export type AdditionalPropertiesUnknownIssue3 = string & { 948 + entries: { 949 + [key: string]: AdditionalPropertiesUnknownIssue; 950 + }; 951 + }; 952 + 953 + export type AdditionalPropertiesIntegerIssue = { 954 + value: number; 955 + [key: string]: number; 956 + }; 957 + 958 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 959 + 960 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 961 + item?: boolean; 962 + error?: string | null; 963 + readonly hasError?: boolean; 964 + data?: { 965 + [key: string]: never; 966 + }; 967 + }; 968 + 969 + export type GenericSchemaDuplicateIssue1SystemString = { 970 + item?: string | null; 971 + error?: string | null; 972 + readonly hasError?: boolean; 973 + }; 974 + 975 + export type ExternalSharedModel = { 976 + id: string; 977 + name?: string; 978 + }; 979 + 980 + /** 981 + * This is a model with one property containing a reference 982 + */ 983 + export type ModelWithReferenceWritable = { 984 + prop?: ModelWithPropertiesWritable; 985 + }; 986 + 987 + /** 988 + * This is a model with one property containing an array 989 + */ 990 + export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { 991 + prop?: Array<ModelWithReadOnlyAndWriteOnlyWritable>; 992 + propWithFile?: Array<Blob | File>; 993 + propWithNumber?: Array<number>; 994 + }; 995 + 996 + /** 997 + * This is a model with one nested property 998 + */ 999 + export type ModelWithPropertiesWritable = { 1000 + required: string; 1001 + requiredAndNullable: string | null; 1002 + string?: string; 1003 + number?: number; 1004 + boolean?: boolean; 1005 + reference?: ModelWithString; 1006 + 'property with space'?: string; 1007 + default?: string; 1008 + try?: string; 1009 + }; 1010 + 1011 + /** 1012 + * This is a model that contains a some patterns 1013 + */ 1014 + export type ModelWithPatternWritable = { 1015 + key: string; 1016 + name: string; 1017 + id?: string; 1018 + text?: string; 1019 + patternWithSingleQuotes?: string; 1020 + patternWithNewline?: string; 1021 + patternWithBacktick?: string; 1022 + patternWithUnicode?: string; 1023 + }; 1024 + 1025 + export type FileWritable = { 1026 + /** 1027 + * Mime 1028 + */ 1029 + mime: string; 1030 + }; 1031 + 1032 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1033 + foo: string; 1034 + baz: string; 1035 + }; 1036 + 1037 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ 1038 + number | Import, 1039 + number | Import 1040 + ]; 1041 + 1042 + export type AdditionalPropertiesUnknownIssueWritable = { 1043 + [key: string]: string | number; 1044 + }; 1045 + 1046 + export type OneOfAllOfIssueWritable = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 1047 + 1048 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1049 + item?: boolean; 1050 + error?: string | null; 1051 + data?: { 1052 + [key: string]: never; 1053 + }; 1054 + }; 1055 + 1056 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1057 + item?: string | null; 1058 + error?: string | null; 1059 + }; 1060 + 1061 + /** 1062 + * This is a reusable parameter 1063 + */ 1064 + export type SimpleParameter = string; 1065 + 1066 + /** 1067 + * Parameter with illegal characters 1068 + */ 1069 + export type XFooBar = ModelWithString; 1070 + 1071 + export type SimpleRequestBody = ModelWithString; 1072 + 1073 + export type SimpleFormData = ModelWithString; 1074 + 1075 + export type ExportData = { 1076 + body?: never; 1077 + path?: never; 1078 + query?: never; 1079 + url: '/api/v{api-version}/no+tag'; 1080 + }; 1081 + 1082 + export type PatchApiVbyApiVersionNoTagData = { 1083 + body?: never; 1084 + path?: never; 1085 + query?: never; 1086 + url: '/api/v{api-version}/no+tag'; 1087 + }; 1088 + 1089 + export type PatchApiVbyApiVersionNoTagResponses = { 1090 + /** 1091 + * OK 1092 + */ 1093 + default: unknown; 1094 + }; 1095 + 1096 + export type ImportData = { 1097 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; 1098 + path?: never; 1099 + query?: never; 1100 + url: '/api/v{api-version}/no+tag'; 1101 + }; 1102 + 1103 + export type ImportResponses = { 1104 + /** 1105 + * Success 1106 + */ 1107 + 200: ModelFromZendesk; 1108 + /** 1109 + * Default success response 1110 + */ 1111 + default: ModelWithReadOnlyAndWriteOnly; 1112 + }; 1113 + 1114 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1115 + 1116 + export type FooWowData = { 1117 + body?: never; 1118 + path?: never; 1119 + query?: never; 1120 + url: '/api/v{api-version}/no+tag'; 1121 + }; 1122 + 1123 + export type FooWowResponses = { 1124 + /** 1125 + * OK 1126 + */ 1127 + default: unknown; 1128 + }; 1129 + 1130 + export type ApiVVersionODataControllerCountData = { 1131 + body?: never; 1132 + path?: never; 1133 + query?: never; 1134 + url: '/api/v{api-version}/simple/$count'; 1135 + }; 1136 + 1137 + export type ApiVVersionODataControllerCountResponses = { 1138 + /** 1139 + * Success 1140 + */ 1141 + 200: ModelFromZendesk; 1142 + }; 1143 + 1144 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1145 + 1146 + export type GetApiVbyApiVersionSimpleOperationData = { 1147 + body?: never; 1148 + path: { 1149 + /** 1150 + * foo in method 1151 + */ 1152 + foo_param: string; 1153 + }; 1154 + query?: never; 1155 + url: '/api/v{api-version}/simple:operation'; 1156 + }; 1157 + 1158 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1159 + /** 1160 + * Default error response 1161 + */ 1162 + default: ModelWithBoolean; 1163 + }; 1164 + 1165 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1166 + 1167 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1168 + /** 1169 + * Response is a simple number 1170 + */ 1171 + 200: number; 1172 + }; 1173 + 1174 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1175 + 1176 + export type DeleteCallWithoutParametersAndResponseData = { 1177 + body?: never; 1178 + path?: never; 1179 + query?: never; 1180 + url: '/api/v{api-version}/simple'; 1181 + }; 1182 + 1183 + export type GetCallWithoutParametersAndResponseData = { 1184 + body?: never; 1185 + path?: never; 1186 + query?: never; 1187 + url: '/api/v{api-version}/simple'; 1188 + }; 1189 + 1190 + export type HeadCallWithoutParametersAndResponseData = { 1191 + body?: never; 1192 + path?: never; 1193 + query?: never; 1194 + url: '/api/v{api-version}/simple'; 1195 + }; 1196 + 1197 + export type OptionsCallWithoutParametersAndResponseData = { 1198 + body?: never; 1199 + path?: never; 1200 + query?: never; 1201 + url: '/api/v{api-version}/simple'; 1202 + }; 1203 + 1204 + export type PatchCallWithoutParametersAndResponseData = { 1205 + body?: never; 1206 + path?: never; 1207 + query?: never; 1208 + url: '/api/v{api-version}/simple'; 1209 + }; 1210 + 1211 + export type PostCallWithoutParametersAndResponseData = { 1212 + body?: never; 1213 + path?: never; 1214 + query?: never; 1215 + url: '/api/v{api-version}/simple'; 1216 + }; 1217 + 1218 + export type PutCallWithoutParametersAndResponseData = { 1219 + body?: never; 1220 + path?: never; 1221 + query?: never; 1222 + url: '/api/v{api-version}/simple'; 1223 + }; 1224 + 1225 + export type DeleteFooData3 = { 1226 + body?: never; 1227 + headers: { 1228 + /** 1229 + * Parameter with illegal characters 1230 + */ 1231 + 'x-Foo-Bar': ModelWithString; 1232 + }; 1233 + path: { 1234 + /** 1235 + * foo in method 1236 + */ 1237 + foo_param: string; 1238 + /** 1239 + * bar in method 1240 + */ 1241 + BarParam: string; 1242 + }; 1243 + query?: never; 1244 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1245 + }; 1246 + 1247 + export type CallWithDescriptionsData = { 1248 + body?: never; 1249 + path?: never; 1250 + query?: { 1251 + /** 1252 + * Testing multiline comments in string: First line 1253 + * Second line 1254 + * 1255 + * Fourth line 1256 + */ 1257 + parameterWithBreaks?: string; 1258 + /** 1259 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1260 + */ 1261 + parameterWithBackticks?: string; 1262 + /** 1263 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1264 + */ 1265 + parameterWithSlashes?: string; 1266 + /** 1267 + * Testing expression placeholders in string: ${expression} should work 1268 + */ 1269 + parameterWithExpressionPlaceholders?: string; 1270 + /** 1271 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1272 + */ 1273 + parameterWithQuotes?: string; 1274 + /** 1275 + * Testing reserved characters in string: * inline * and ** inline ** should work 1276 + */ 1277 + parameterWithReservedCharacters?: string; 1278 + }; 1279 + url: '/api/v{api-version}/descriptions'; 1280 + }; 1281 + 1282 + export type DeprecatedCallData = { 1283 + body?: never; 1284 + headers: { 1285 + /** 1286 + * This parameter is deprecated 1287 + * 1288 + * @deprecated 1289 + */ 1290 + parameter: DeprecatedModel | null; 1291 + }; 1292 + path?: never; 1293 + query?: never; 1294 + url: '/api/v{api-version}/parameters/deprecated'; 1295 + }; 1296 + 1297 + export type CallWithParametersData = { 1298 + /** 1299 + * This is the parameter that goes into the body 1300 + */ 1301 + body: { 1302 + [key: string]: unknown; 1303 + } | null; 1304 + headers: { 1305 + /** 1306 + * This is the parameter that goes into the header 1307 + */ 1308 + parameterHeader: string | null; 1309 + }; 1310 + path: { 1311 + /** 1312 + * This is the parameter that goes into the path 1313 + */ 1314 + parameterPath: string | null; 1315 + /** 1316 + * api-version should be required in standalone clients 1317 + */ 1318 + 'api-version': string | null; 1319 + }; 1320 + query: { 1321 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1322 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1323 + /** 1324 + * This is the parameter that goes into the query params 1325 + */ 1326 + cursor: string | null; 1327 + }; 1328 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1329 + }; 1330 + 1331 + export type CallWithWeirdParameterNamesData = { 1332 + /** 1333 + * This is the parameter that goes into the body 1334 + */ 1335 + body: ModelWithString | null; 1336 + headers: { 1337 + /** 1338 + * This is the parameter that goes into the request header 1339 + */ 1340 + 'parameter.header': string | null; 1341 + }; 1342 + path: { 1343 + /** 1344 + * This is the parameter that goes into the path 1345 + */ 1346 + 'parameter.path.1'?: string; 1347 + /** 1348 + * This is the parameter that goes into the path 1349 + */ 1350 + 'parameter-path-2'?: string; 1351 + /** 1352 + * This is the parameter that goes into the path 1353 + */ 1354 + 'PARAMETER-PATH-3'?: string; 1355 + /** 1356 + * api-version should be required in standalone clients 1357 + */ 1358 + 'api-version': string | null; 1359 + }; 1360 + query: { 1361 + /** 1362 + * This is the parameter with a reserved keyword 1363 + */ 1364 + default?: string; 1365 + /** 1366 + * This is the parameter that goes into the request query params 1367 + */ 1368 + 'parameter-query': string | null; 1369 + }; 1370 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1371 + }; 1372 + 1373 + export type GetCallWithOptionalParamData = { 1374 + /** 1375 + * This is a required parameter 1376 + */ 1377 + body: ModelWithOneOfEnum; 1378 + path?: never; 1379 + query?: { 1380 + /** 1381 + * This is an optional parameter 1382 + */ 1383 + page?: number; 1384 + }; 1385 + url: '/api/v{api-version}/parameters'; 1386 + }; 1387 + 1388 + export type PostCallWithOptionalParamData = { 1389 + /** 1390 + * This is an optional parameter 1391 + */ 1392 + body?: { 1393 + offset?: number | null; 1394 + }; 1395 + path?: never; 1396 + query: { 1397 + /** 1398 + * This is a required parameter 1399 + */ 1400 + parameter: Pageable; 1401 + }; 1402 + url: '/api/v{api-version}/parameters'; 1403 + }; 1404 + 1405 + export type PostCallWithOptionalParamResponses = { 1406 + /** 1407 + * Response is a simple number 1408 + */ 1409 + 200: number; 1410 + /** 1411 + * Success 1412 + */ 1413 + 204: void; 1414 + }; 1415 + 1416 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1417 + 1418 + export type PostApiVbyApiVersionRequestBodyData = { 1419 + /** 1420 + * A reusable request body 1421 + */ 1422 + body?: SimpleRequestBody; 1423 + path?: never; 1424 + query?: { 1425 + /** 1426 + * This is a reusable parameter 1427 + */ 1428 + parameter?: string; 1429 + }; 1430 + url: '/api/v{api-version}/requestBody'; 1431 + }; 1432 + 1433 + export type PostApiVbyApiVersionFormDataData = { 1434 + /** 1435 + * A reusable request body 1436 + */ 1437 + body?: SimpleFormData; 1438 + path?: never; 1439 + query?: { 1440 + /** 1441 + * This is a reusable parameter 1442 + */ 1443 + parameter?: string; 1444 + }; 1445 + url: '/api/v{api-version}/formData'; 1446 + }; 1447 + 1448 + export type CallWithDefaultParametersData = { 1449 + body?: never; 1450 + path?: never; 1451 + query?: { 1452 + /** 1453 + * This is a simple string with default value 1454 + */ 1455 + parameterString?: string | null; 1456 + /** 1457 + * This is a simple number with default value 1458 + */ 1459 + parameterNumber?: number | null; 1460 + /** 1461 + * This is a simple boolean with default value 1462 + */ 1463 + parameterBoolean?: boolean | null; 1464 + /** 1465 + * This is a simple enum with default value 1466 + */ 1467 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1468 + /** 1469 + * This is a simple model with default value 1470 + */ 1471 + parameterModel?: ModelWithString | null; 1472 + }; 1473 + url: '/api/v{api-version}/defaults'; 1474 + }; 1475 + 1476 + export type CallWithDefaultOptionalParametersData = { 1477 + body?: never; 1478 + path?: never; 1479 + query?: { 1480 + /** 1481 + * This is a simple string that is optional with default value 1482 + */ 1483 + parameterString?: string; 1484 + /** 1485 + * This is a simple number that is optional with default value 1486 + */ 1487 + parameterNumber?: number; 1488 + /** 1489 + * This is a simple boolean that is optional with default value 1490 + */ 1491 + parameterBoolean?: boolean; 1492 + /** 1493 + * This is a simple enum that is optional with default value 1494 + */ 1495 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1496 + /** 1497 + * This is a simple model that is optional with default value 1498 + */ 1499 + parameterModel?: ModelWithString; 1500 + }; 1501 + url: '/api/v{api-version}/defaults'; 1502 + }; 1503 + 1504 + export type CallToTestOrderOfParamsData = { 1505 + body?: never; 1506 + path?: never; 1507 + query: { 1508 + /** 1509 + * This is a optional string with default 1510 + */ 1511 + parameterOptionalStringWithDefault?: string; 1512 + /** 1513 + * This is a optional string with empty default 1514 + */ 1515 + parameterOptionalStringWithEmptyDefault?: string; 1516 + /** 1517 + * This is a optional string with no default 1518 + */ 1519 + parameterOptionalStringWithNoDefault?: string; 1520 + /** 1521 + * This is a string with default 1522 + */ 1523 + parameterStringWithDefault: string; 1524 + /** 1525 + * This is a string with empty default 1526 + */ 1527 + parameterStringWithEmptyDefault: string; 1528 + /** 1529 + * This is a string with no default 1530 + */ 1531 + parameterStringWithNoDefault: string; 1532 + /** 1533 + * This is a string that can be null with no default 1534 + */ 1535 + parameterStringNullableWithNoDefault?: string | null; 1536 + /** 1537 + * This is a string that can be null with default 1538 + */ 1539 + parameterStringNullableWithDefault?: string | null; 1540 + }; 1541 + url: '/api/v{api-version}/defaults'; 1542 + }; 1543 + 1544 + export type DuplicateNameData = { 1545 + body?: never; 1546 + path?: never; 1547 + query?: never; 1548 + url: '/api/v{api-version}/duplicate'; 1549 + }; 1550 + 1551 + export type DuplicateName2Data = { 1552 + body?: never; 1553 + path?: never; 1554 + query?: never; 1555 + url: '/api/v{api-version}/duplicate'; 1556 + }; 1557 + 1558 + export type DuplicateName3Data = { 1559 + body?: never; 1560 + path?: never; 1561 + query?: never; 1562 + url: '/api/v{api-version}/duplicate'; 1563 + }; 1564 + 1565 + export type DuplicateName4Data = { 1566 + body?: never; 1567 + path?: never; 1568 + query?: never; 1569 + url: '/api/v{api-version}/duplicate'; 1570 + }; 1571 + 1572 + export type CallWithNoContentResponseData = { 1573 + body?: never; 1574 + path?: never; 1575 + query?: never; 1576 + url: '/api/v{api-version}/no-content'; 1577 + }; 1578 + 1579 + export type CallWithNoContentResponseResponses = { 1580 + /** 1581 + * Success 1582 + */ 1583 + 204: void; 1584 + }; 1585 + 1586 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1587 + 1588 + export type CallWithResponseAndNoContentResponseData = { 1589 + body?: never; 1590 + path?: never; 1591 + query?: never; 1592 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1593 + }; 1594 + 1595 + export type CallWithResponseAndNoContentResponseResponses = { 1596 + /** 1597 + * Response is a simple number 1598 + */ 1599 + 200: number; 1600 + /** 1601 + * Success 1602 + */ 1603 + 204: void; 1604 + }; 1605 + 1606 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1607 + 1608 + export type DummyAData = { 1609 + body?: never; 1610 + path?: never; 1611 + query?: never; 1612 + url: '/api/v{api-version}/multiple-tags/a'; 1613 + }; 1614 + 1615 + export type DummyAResponses = { 1616 + 200: _400; 1617 + }; 1618 + 1619 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1620 + 1621 + export type DummyBData = { 1622 + body?: never; 1623 + path?: never; 1624 + query?: never; 1625 + url: '/api/v{api-version}/multiple-tags/b'; 1626 + }; 1627 + 1628 + export type DummyBResponses = { 1629 + /** 1630 + * Success 1631 + */ 1632 + 204: void; 1633 + }; 1634 + 1635 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1636 + 1637 + export type CallWithResponseData = { 1638 + body?: never; 1639 + path?: never; 1640 + query?: never; 1641 + url: '/api/v{api-version}/response'; 1642 + }; 1643 + 1644 + export type CallWithResponseResponses = { 1645 + default: Import; 1646 + }; 1647 + 1648 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1649 + 1650 + export type CallWithDuplicateResponsesData = { 1651 + body?: never; 1652 + path?: never; 1653 + query?: never; 1654 + url: '/api/v{api-version}/response'; 1655 + }; 1656 + 1657 + export type CallWithDuplicateResponsesErrors = { 1658 + /** 1659 + * Message for 500 error 1660 + */ 1661 + 500: ModelWithStringError; 1662 + /** 1663 + * Message for 501 error 1664 + */ 1665 + 501: ModelWithStringError; 1666 + /** 1667 + * Message for 502 error 1668 + */ 1669 + 502: ModelWithStringError; 1670 + /** 1671 + * Message for 4XX errors 1672 + */ 1673 + '4XX': DictionaryWithArray; 1674 + /** 1675 + * Default error response 1676 + */ 1677 + default: ModelWithBoolean; 1678 + }; 1679 + 1680 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1681 + 1682 + export type CallWithDuplicateResponsesResponses = { 1683 + /** 1684 + * Message for 200 response 1685 + */ 1686 + 200: ModelWithBoolean & ModelWithInteger; 1687 + /** 1688 + * Message for 201 response 1689 + */ 1690 + 201: ModelWithString; 1691 + /** 1692 + * Message for 202 response 1693 + */ 1694 + 202: ModelWithString; 1695 + }; 1696 + 1697 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1698 + 1699 + export type CallWithResponsesData = { 1700 + body?: never; 1701 + path?: never; 1702 + query?: never; 1703 + url: '/api/v{api-version}/response'; 1704 + }; 1705 + 1706 + export type CallWithResponsesErrors = { 1707 + /** 1708 + * Message for 500 error 1709 + */ 1710 + 500: ModelWithStringError; 1711 + /** 1712 + * Message for 501 error 1713 + */ 1714 + 501: ModelWithStringError; 1715 + /** 1716 + * Message for 502 error 1717 + */ 1718 + 502: ModelWithStringError; 1719 + /** 1720 + * Message for default response 1721 + */ 1722 + default: ModelWithStringError; 1723 + }; 1724 + 1725 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1726 + 1727 + export type CallWithResponsesResponses = { 1728 + /** 1729 + * Message for 200 response 1730 + */ 1731 + 200: { 1732 + readonly '@namespace.string'?: string; 1733 + readonly '@namespace.integer'?: number; 1734 + readonly value?: Array<ModelWithString>; 1735 + }; 1736 + /** 1737 + * Message for 201 response 1738 + */ 1739 + 201: ModelThatExtends; 1740 + /** 1741 + * Message for 202 response 1742 + */ 1743 + 202: ModelThatExtendsExtends; 1744 + }; 1745 + 1746 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1747 + 1748 + export type CollectionFormatData = { 1749 + body?: never; 1750 + path?: never; 1751 + query: { 1752 + /** 1753 + * This is an array parameter that is sent as csv format (comma-separated values) 1754 + */ 1755 + parameterArrayCSV: Array<string> | null; 1756 + /** 1757 + * This is an array parameter that is sent as ssv format (space-separated values) 1758 + */ 1759 + parameterArraySSV: Array<string> | null; 1760 + /** 1761 + * This is an array parameter that is sent as tsv format (tab-separated values) 1762 + */ 1763 + parameterArrayTSV: Array<string> | null; 1764 + /** 1765 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1766 + */ 1767 + parameterArrayPipes: Array<string> | null; 1768 + /** 1769 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1770 + */ 1771 + parameterArrayMulti: Array<string> | null; 1772 + }; 1773 + url: '/api/v{api-version}/collectionFormat'; 1774 + }; 1775 + 1776 + export type TypesData = { 1777 + body?: never; 1778 + path?: { 1779 + /** 1780 + * This is a number parameter 1781 + */ 1782 + id?: number; 1783 + }; 1784 + query: { 1785 + /** 1786 + * This is a number parameter 1787 + */ 1788 + parameterNumber: number; 1789 + /** 1790 + * This is a string parameter 1791 + */ 1792 + parameterString: string | null; 1793 + /** 1794 + * This is a boolean parameter 1795 + */ 1796 + parameterBoolean: boolean | null; 1797 + /** 1798 + * This is an object parameter 1799 + */ 1800 + parameterObject: { 1801 + [key: string]: unknown; 1802 + } | null; 1803 + /** 1804 + * This is an array parameter 1805 + */ 1806 + parameterArray: Array<string> | null; 1807 + /** 1808 + * This is a dictionary parameter 1809 + */ 1810 + parameterDictionary: { 1811 + [key: string]: unknown; 1812 + } | null; 1813 + /** 1814 + * This is an enum parameter 1815 + */ 1816 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1817 + }; 1818 + url: '/api/v{api-version}/types'; 1819 + }; 1820 + 1821 + export type TypesResponses = { 1822 + /** 1823 + * Response is a simple number 1824 + */ 1825 + 200: number; 1826 + /** 1827 + * Response is a simple string 1828 + */ 1829 + 201: string; 1830 + /** 1831 + * Response is a simple boolean 1832 + */ 1833 + 202: boolean; 1834 + /** 1835 + * Response is a simple object 1836 + */ 1837 + 203: { 1838 + [key: string]: unknown; 1839 + }; 1840 + }; 1841 + 1842 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1843 + 1844 + export type UploadFileData = { 1845 + body: Blob | File; 1846 + path: { 1847 + /** 1848 + * api-version should be required in standalone clients 1849 + */ 1850 + 'api-version': string | null; 1851 + }; 1852 + query?: never; 1853 + url: '/api/v{api-version}/upload'; 1854 + }; 1855 + 1856 + export type UploadFileResponses = { 1857 + 200: boolean; 1858 + }; 1859 + 1860 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1861 + 1862 + export type FileResponseData = { 1863 + body?: never; 1864 + path: { 1865 + id: string; 1866 + /** 1867 + * api-version should be required in standalone clients 1868 + */ 1869 + 'api-version': string; 1870 + }; 1871 + query?: never; 1872 + url: '/api/v{api-version}/file/{id}'; 1873 + }; 1874 + 1875 + export type FileResponseResponses = { 1876 + /** 1877 + * Success 1878 + */ 1879 + 200: Blob | File; 1880 + }; 1881 + 1882 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1883 + 1884 + export type ComplexTypesData = { 1885 + body?: never; 1886 + path?: never; 1887 + query: { 1888 + /** 1889 + * Parameter containing object 1890 + */ 1891 + parameterObject: { 1892 + first?: { 1893 + second?: { 1894 + third?: string; 1895 + }; 1896 + }; 1897 + }; 1898 + /** 1899 + * Parameter containing reference 1900 + */ 1901 + parameterReference: ModelWithString; 1902 + }; 1903 + url: '/api/v{api-version}/complex'; 1904 + }; 1905 + 1906 + export type ComplexTypesErrors = { 1907 + /** 1908 + * 400 `server` error 1909 + */ 1910 + 400: unknown; 1911 + /** 1912 + * 500 server error 1913 + */ 1914 + 500: unknown; 1915 + }; 1916 + 1917 + export type ComplexTypesResponses = { 1918 + /** 1919 + * Successful response 1920 + */ 1921 + 200: Array<ModelWithString>; 1922 + }; 1923 + 1924 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1925 + 1926 + export type MultipartResponseData = { 1927 + body?: never; 1928 + path?: never; 1929 + query?: never; 1930 + url: '/api/v{api-version}/multipart'; 1931 + }; 1932 + 1933 + export type MultipartResponseResponses = { 1934 + /** 1935 + * OK 1936 + */ 1937 + 200: { 1938 + file?: Blob | File; 1939 + metadata?: { 1940 + foo?: string; 1941 + bar?: string; 1942 + }; 1943 + }; 1944 + }; 1945 + 1946 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1947 + 1948 + export type MultipartRequestData = { 1949 + body?: { 1950 + content?: Blob | File; 1951 + data?: ModelWithString | null; 1952 + }; 1953 + path?: never; 1954 + query?: never; 1955 + url: '/api/v{api-version}/multipart'; 1956 + }; 1957 + 1958 + export type ComplexParamsData = { 1959 + body?: { 1960 + readonly key: string | null; 1961 + name: string | null; 1962 + enabled?: boolean; 1963 + type: 'Monkey' | 'Horse' | 'Bird'; 1964 + listOfModels?: Array<ModelWithString> | null; 1965 + listOfStrings?: Array<string> | null; 1966 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1967 + readonly user?: { 1968 + readonly id?: number; 1969 + readonly name?: string | null; 1970 + }; 1971 + }; 1972 + path: { 1973 + id: number; 1974 + /** 1975 + * api-version should be required in standalone clients 1976 + */ 1977 + 'api-version': string; 1978 + }; 1979 + query?: never; 1980 + url: '/api/v{api-version}/complex/{id}'; 1981 + }; 1982 + 1983 + export type ComplexParamsResponses = { 1984 + /** 1985 + * Success 1986 + */ 1987 + 200: ModelWithString; 1988 + }; 1989 + 1990 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1991 + 1992 + export type CallWithResultFromHeaderData = { 1993 + body?: never; 1994 + path?: never; 1995 + query?: never; 1996 + url: '/api/v{api-version}/header'; 1997 + }; 1998 + 1999 + export type CallWithResultFromHeaderErrors = { 2000 + /** 2001 + * 400 server error 2002 + */ 2003 + 400: unknown; 2004 + /** 2005 + * 500 server error 2006 + */ 2007 + 500: unknown; 2008 + }; 2009 + 2010 + export type CallWithResultFromHeaderResponses = { 2011 + /** 2012 + * Successful response 2013 + */ 2014 + 200: unknown; 2015 + }; 2016 + 2017 + export type TestErrorCodeData = { 2018 + body?: never; 2019 + path?: never; 2020 + query: { 2021 + /** 2022 + * Status code to return 2023 + */ 2024 + status: number; 2025 + }; 2026 + url: '/api/v{api-version}/error'; 2027 + }; 2028 + 2029 + export type TestErrorCodeErrors = { 2030 + /** 2031 + * Custom message: Internal Server Error 2032 + */ 2033 + 500: unknown; 2034 + /** 2035 + * Custom message: Not Implemented 2036 + */ 2037 + 501: unknown; 2038 + /** 2039 + * Custom message: Bad Gateway 2040 + */ 2041 + 502: unknown; 2042 + /** 2043 + * Custom message: Service Unavailable 2044 + */ 2045 + 503: unknown; 2046 + }; 2047 + 2048 + export type TestErrorCodeResponses = { 2049 + /** 2050 + * Custom message: Successful response 2051 + */ 2052 + 200: unknown; 2053 + }; 2054 + 2055 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2056 + body?: never; 2057 + path?: never; 2058 + query: { 2059 + /** 2060 + * Dummy input param 2061 + */ 2062 + nonAsciiParamæøåÆØÅöôêÊ: number; 2063 + }; 2064 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2065 + }; 2066 + 2067 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2068 + /** 2069 + * Successful response 2070 + */ 2071 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2072 + }; 2073 + 2074 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2075 + 2076 + export type PutWithFormUrlEncodedData = { 2077 + body: ArrayWithStrings; 2078 + path?: never; 2079 + query?: never; 2080 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2081 + };
+824
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/@tanstack/react-query.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, useMutation, type UseMutationOptions } from '@tanstack/react-query'; 4 + 5 + import { client } from '../client.gen'; 6 + import { apiVVersionODataControllerCount, callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexParams, complexTypes, deleteCallWithoutParametersAndResponse, deleteFoo, deprecatedCall, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, export_, fileResponse, fooWow, getApiVbyApiVersionSimpleOperation, getCallWithOptionalParam, getCallWithoutParametersAndResponse, import_, multipartRequest, multipartResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionFormData, postApiVbyApiVersionRequestBody, postCallWithOptionalParam, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, putWithFormUrlEncoded, testErrorCode, types, uploadFile } from '../sdk.gen'; 7 + import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponse, DummyBData, DummyBResponse, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, TypesResponse, UploadFileData, UploadFileResponse } from '../types.gen'; 8 + 9 + export type QueryKey<TOptions extends Options> = [ 10 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 12 + _infinite?: boolean; 13 + tags?: ReadonlyArray<string>; 14 + } 15 + ]; 16 + 17 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 + QueryKey<TOptions>[0] 19 + ] => { 20 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 + if (infinite) { 22 + params._infinite = infinite; 23 + } 24 + if (tags) { 25 + params.tags = tags; 26 + } 27 + if (options?.body) { 28 + params.body = options.body; 29 + } 30 + if (options?.headers) { 31 + params.headers = options.headers; 32 + } 33 + if (options?.path) { 34 + params.path = options.path; 35 + } 36 + if (options?.query) { 37 + params.query = options.query; 38 + } 39 + return [params]; 40 + }; 41 + 42 + export const exportQueryKey = (options?: Options<ExportData>) => createQueryKey('export', options); 43 + 44 + export const exportOptions = (options?: Options<ExportData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof exportQueryKey>>({ 45 + queryFn: async ({ queryKey, signal }) => { 46 + const { data } = await export_({ 47 + ...options, 48 + ...queryKey[0], 49 + signal, 50 + throwOnError: true 51 + }); 52 + return data; 53 + }, 54 + queryKey: exportQueryKey(options) 55 + }); 56 + 57 + export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => { 58 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> = { 59 + mutationFn: async (fnOptions) => { 60 + const { data } = await patchApiVbyApiVersionNoTag({ 61 + ...options, 62 + ...fnOptions, 63 + throwOnError: true 64 + }); 65 + return data; 66 + } 67 + }; 68 + return mutationOptions; 69 + }; 70 + 71 + export const usePatchApiVbyApiVersionNoTagMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>>, 'mutationFn'>>) => useMutation({ ...patchApiVbyApiVersionNoTagMutation(), ...mutationOptions }); 72 + 73 + export const importMutation = (options?: Partial<Options<ImportData>>): UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>> => { 74 + const mutationOptions: UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>> = { 75 + mutationFn: async (fnOptions) => { 76 + const { data } = await import_({ 77 + ...options, 78 + ...fnOptions, 79 + throwOnError: true 80 + }); 81 + return data; 82 + } 83 + }; 84 + return mutationOptions; 85 + }; 86 + 87 + export const useImportMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<ImportResponse, DefaultError, Options<ImportData>>, 'mutationFn'>>) => useMutation({ ...importMutation(), ...mutationOptions }); 88 + 89 + export const fooWowMutation = (options?: Partial<Options<FooWowData>>): UseMutationOptions<unknown, DefaultError, Options<FooWowData>> => { 90 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<FooWowData>> = { 91 + mutationFn: async (fnOptions) => { 92 + const { data } = await fooWow({ 93 + ...options, 94 + ...fnOptions, 95 + throwOnError: true 96 + }); 97 + return data; 98 + } 99 + }; 100 + return mutationOptions; 101 + }; 102 + 103 + export const useFooWowMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<FooWowData>>, 'mutationFn'>>) => useMutation({ ...fooWowMutation(), ...mutationOptions }); 104 + 105 + export const apiVVersionODataControllerCountQueryKey = (options?: Options<ApiVVersionODataControllerCountData>) => createQueryKey('apiVVersionODataControllerCount', options); 106 + 107 + export const apiVVersionODataControllerCountOptions = (options?: Options<ApiVVersionODataControllerCountData>) => queryOptions<ApiVVersionODataControllerCountResponse, DefaultError, ApiVVersionODataControllerCountResponse, ReturnType<typeof apiVVersionODataControllerCountQueryKey>>({ 108 + queryFn: async ({ queryKey, signal }) => { 109 + const { data } = await apiVVersionODataControllerCount({ 110 + ...options, 111 + ...queryKey[0], 112 + signal, 113 + throwOnError: true 114 + }); 115 + return data; 116 + }, 117 + queryKey: apiVVersionODataControllerCountQueryKey(options) 118 + }); 119 + 120 + export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); 121 + 122 + export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => queryOptions<GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, ReturnType<typeof getApiVbyApiVersionSimpleOperationQueryKey>>({ 123 + queryFn: async ({ queryKey, signal }) => { 124 + const { data } = await getApiVbyApiVersionSimpleOperation({ 125 + ...options, 126 + ...queryKey[0], 127 + signal, 128 + throwOnError: true 129 + }); 130 + return data; 131 + }, 132 + queryKey: getApiVbyApiVersionSimpleOperationQueryKey(options) 133 + }); 134 + 135 + export const deleteCallWithoutParametersAndResponseMutation = (options?: Partial<Options<DeleteCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> => { 136 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>> = { 137 + mutationFn: async (fnOptions) => { 138 + const { data } = await deleteCallWithoutParametersAndResponse({ 139 + ...options, 140 + ...fnOptions, 141 + throwOnError: true 142 + }); 143 + return data; 144 + } 145 + }; 146 + return mutationOptions; 147 + }; 148 + 149 + export const useDeleteCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeleteCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...deleteCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 150 + 151 + export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 152 + 153 + export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getCallWithoutParametersAndResponseQueryKey>>({ 154 + queryFn: async ({ queryKey, signal }) => { 155 + const { data } = await getCallWithoutParametersAndResponse({ 156 + ...options, 157 + ...queryKey[0], 158 + signal, 159 + throwOnError: true 160 + }); 161 + return data; 162 + }, 163 + queryKey: getCallWithoutParametersAndResponseQueryKey(options) 164 + }); 165 + 166 + export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => { 167 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> = { 168 + mutationFn: async (fnOptions) => { 169 + const { data } = await patchCallWithoutParametersAndResponse({ 170 + ...options, 171 + ...fnOptions, 172 + throwOnError: true 173 + }); 174 + return data; 175 + } 176 + }; 177 + return mutationOptions; 178 + }; 179 + 180 + export const usePatchCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...patchCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 181 + 182 + export const postCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PostCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> => { 183 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>> = { 184 + mutationFn: async (fnOptions) => { 185 + const { data } = await postCallWithoutParametersAndResponse({ 186 + ...options, 187 + ...fnOptions, 188 + throwOnError: true 189 + }); 190 + return data; 191 + } 192 + }; 193 + return mutationOptions; 194 + }; 195 + 196 + export const usePostCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...postCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 197 + 198 + export const putCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PutCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> => { 199 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>> = { 200 + mutationFn: async (fnOptions) => { 201 + const { data } = await putCallWithoutParametersAndResponse({ 202 + ...options, 203 + ...fnOptions, 204 + throwOnError: true 205 + }); 206 + return data; 207 + } 208 + }; 209 + return mutationOptions; 210 + }; 211 + 212 + export const usePutCallWithoutParametersAndResponseMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PutCallWithoutParametersAndResponseData>>, 'mutationFn'>>) => useMutation({ ...putCallWithoutParametersAndResponseMutation(), ...mutationOptions }); 213 + 214 + export const deleteFooMutation = (options?: Partial<Options<DeleteFooData3>>): UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>> => { 215 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>> = { 216 + mutationFn: async (fnOptions) => { 217 + const { data } = await deleteFoo({ 218 + ...options, 219 + ...fnOptions, 220 + throwOnError: true 221 + }); 222 + return data; 223 + } 224 + }; 225 + return mutationOptions; 226 + }; 227 + 228 + export const useDeleteFooMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeleteFooData3>>, 'mutationFn'>>) => useMutation({ ...deleteFooMutation(), ...mutationOptions }); 229 + 230 + export const callWithDescriptionsMutation = (options?: Partial<Options<CallWithDescriptionsData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> => { 231 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>> = { 232 + mutationFn: async (fnOptions) => { 233 + const { data } = await callWithDescriptions({ 234 + ...options, 235 + ...fnOptions, 236 + throwOnError: true 237 + }); 238 + return data; 239 + } 240 + }; 241 + return mutationOptions; 242 + }; 243 + 244 + export const useCallWithDescriptionsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDescriptionsData>>, 'mutationFn'>>) => useMutation({ ...callWithDescriptionsMutation(), ...mutationOptions }); 245 + 246 + /** 247 + * @deprecated 248 + */ 249 + export const deprecatedCallMutation = (options?: Partial<Options<DeprecatedCallData>>): UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>> => { 250 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>> = { 251 + mutationFn: async (fnOptions) => { 252 + const { data } = await deprecatedCall({ 253 + ...options, 254 + ...fnOptions, 255 + throwOnError: true 256 + }); 257 + return data; 258 + } 259 + }; 260 + return mutationOptions; 261 + }; 262 + 263 + /** 264 + * @deprecated 265 + */ 266 + export const useDeprecatedCallMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DeprecatedCallData>>, 'mutationFn'>>) => useMutation({ ...deprecatedCallMutation(), ...mutationOptions }); 267 + 268 + export const callWithParametersMutation = (options?: Partial<Options<CallWithParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> => { 269 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>> = { 270 + mutationFn: async (fnOptions) => { 271 + const { data } = await callWithParameters({ 272 + ...options, 273 + ...fnOptions, 274 + throwOnError: true 275 + }); 276 + return data; 277 + } 278 + }; 279 + return mutationOptions; 280 + }; 281 + 282 + export const useCallWithParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithParametersMutation(), ...mutationOptions }); 283 + 284 + export const callWithWeirdParameterNamesMutation = (options?: Partial<Options<CallWithWeirdParameterNamesData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> => { 285 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 286 + mutationFn: async (fnOptions) => { 287 + const { data } = await callWithWeirdParameterNames({ 288 + ...options, 289 + ...fnOptions, 290 + throwOnError: true 291 + }); 292 + return data; 293 + } 294 + }; 295 + return mutationOptions; 296 + }; 297 + 298 + export const useCallWithWeirdParameterNamesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithWeirdParameterNamesData>>, 'mutationFn'>>) => useMutation({ ...callWithWeirdParameterNamesMutation(), ...mutationOptions }); 299 + 300 + export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => createQueryKey('getCallWithOptionalParam', options); 301 + 302 + export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getCallWithOptionalParamQueryKey>>({ 303 + queryFn: async ({ queryKey, signal }) => { 304 + const { data } = await getCallWithOptionalParam({ 305 + ...options, 306 + ...queryKey[0], 307 + signal, 308 + throwOnError: true 309 + }); 310 + return data; 311 + }, 312 + queryKey: getCallWithOptionalParamQueryKey(options) 313 + }); 314 + 315 + const createInfiniteParams = <K extends Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>>(queryKey: QueryKey<Options>, page: K) => { 316 + const params = { ...queryKey[0] }; 317 + if (page.body) { 318 + params.body = { 319 + ...queryKey[0].body as any, 320 + ...page.body as any 321 + }; 322 + } 323 + if (page.headers) { 324 + params.headers = { 325 + ...queryKey[0].headers, 326 + ...page.headers 327 + }; 328 + } 329 + if (page.path) { 330 + params.path = { 331 + ...queryKey[0].path as any, 332 + ...page.path as any 333 + }; 334 + } 335 + if (page.query) { 336 + params.query = { 337 + ...queryKey[0].query as any, 338 + ...page.query as any 339 + }; 340 + } 341 + return params as unknown as typeof page; 342 + }; 343 + 344 + export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => createQueryKey('getCallWithOptionalParam', options, true); 345 + 346 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => infiniteQueryOptions<unknown, DefaultError, InfiniteData<unknown>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( 347 + // @ts-ignore 348 + { 349 + queryFn: async ({ pageParam, queryKey, signal }) => { 350 + // @ts-ignore 351 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 352 + query: { 353 + page: pageParam 354 + } 355 + }; 356 + const params = createInfiniteParams(queryKey, page); 357 + const { data } = await getCallWithOptionalParam({ 358 + ...options, 359 + ...params, 360 + signal, 361 + throwOnError: true 362 + }); 363 + return data; 364 + }, 365 + queryKey: getCallWithOptionalParamInfiniteQueryKey(options) 366 + }); 367 + 368 + export const postCallWithOptionalParamMutation = (options?: Partial<Options<PostCallWithOptionalParamData>>): UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>> => { 369 + const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>> = { 370 + mutationFn: async (fnOptions) => { 371 + const { data } = await postCallWithOptionalParam({ 372 + ...options, 373 + ...fnOptions, 374 + throwOnError: true 375 + }); 376 + return data; 377 + } 378 + }; 379 + return mutationOptions; 380 + }; 381 + 382 + export const usePostCallWithOptionalParamMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<PostCallWithOptionalParamResponse, DefaultError, Options<PostCallWithOptionalParamData>>, 'mutationFn'>>) => useMutation({ ...postCallWithOptionalParamMutation(), ...mutationOptions }); 383 + 384 + export const postApiVbyApiVersionRequestBodyMutation = (options?: Partial<Options<PostApiVbyApiVersionRequestBodyData>>): UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> => { 385 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 386 + mutationFn: async (fnOptions) => { 387 + const { data } = await postApiVbyApiVersionRequestBody({ 388 + ...options, 389 + ...fnOptions, 390 + throwOnError: true 391 + }); 392 + return data; 393 + } 394 + }; 395 + return mutationOptions; 396 + }; 397 + 398 + export const usePostApiVbyApiVersionRequestBodyMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>>, 'mutationFn'>>) => useMutation({ ...postApiVbyApiVersionRequestBodyMutation(), ...mutationOptions }); 399 + 400 + export const postApiVbyApiVersionFormDataMutation = (options?: Partial<Options<PostApiVbyApiVersionFormDataData>>): UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>> => { 401 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 402 + mutationFn: async (fnOptions) => { 403 + const { data } = await postApiVbyApiVersionFormData({ 404 + ...options, 405 + ...fnOptions, 406 + throwOnError: true 407 + }); 408 + return data; 409 + } 410 + }; 411 + return mutationOptions; 412 + }; 413 + 414 + export const usePostApiVbyApiVersionFormDataMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PostApiVbyApiVersionFormDataData>>, 'mutationFn'>>) => useMutation({ ...postApiVbyApiVersionFormDataMutation(), ...mutationOptions }); 415 + 416 + export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 417 + 418 + export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof callWithDefaultParametersQueryKey>>({ 419 + queryFn: async ({ queryKey, signal }) => { 420 + const { data } = await callWithDefaultParameters({ 421 + ...options, 422 + ...queryKey[0], 423 + signal, 424 + throwOnError: true 425 + }); 426 + return data; 427 + }, 428 + queryKey: callWithDefaultParametersQueryKey(options) 429 + }); 430 + 431 + export const callWithDefaultOptionalParametersMutation = (options?: Partial<Options<CallWithDefaultOptionalParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> => { 432 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 433 + mutationFn: async (fnOptions) => { 434 + const { data } = await callWithDefaultOptionalParameters({ 435 + ...options, 436 + ...fnOptions, 437 + throwOnError: true 438 + }); 439 + return data; 440 + } 441 + }; 442 + return mutationOptions; 443 + }; 444 + 445 + export const useCallWithDefaultOptionalParametersMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>>, 'mutationFn'>>) => useMutation({ ...callWithDefaultOptionalParametersMutation(), ...mutationOptions }); 446 + 447 + export const callToTestOrderOfParamsMutation = (options?: Partial<Options<CallToTestOrderOfParamsData>>): UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> => { 448 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>> = { 449 + mutationFn: async (fnOptions) => { 450 + const { data } = await callToTestOrderOfParams({ 451 + ...options, 452 + ...fnOptions, 453 + throwOnError: true 454 + }); 455 + return data; 456 + } 457 + }; 458 + return mutationOptions; 459 + }; 460 + 461 + export const useCallToTestOrderOfParamsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallToTestOrderOfParamsData>>, 'mutationFn'>>) => useMutation({ ...callToTestOrderOfParamsMutation(), ...mutationOptions }); 462 + 463 + export const duplicateNameMutation = (options?: Partial<Options<DuplicateNameData>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> => { 464 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>> = { 465 + mutationFn: async (fnOptions) => { 466 + const { data } = await duplicateName({ 467 + ...options, 468 + ...fnOptions, 469 + throwOnError: true 470 + }); 471 + return data; 472 + } 473 + }; 474 + return mutationOptions; 475 + }; 476 + 477 + export const useDuplicateNameMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateNameData>>, 'mutationFn'>>) => useMutation({ ...duplicateNameMutation(), ...mutationOptions }); 478 + 479 + export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 480 + 481 + export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof duplicateName2QueryKey>>({ 482 + queryFn: async ({ queryKey, signal }) => { 483 + const { data } = await duplicateName2({ 484 + ...options, 485 + ...queryKey[0], 486 + signal, 487 + throwOnError: true 488 + }); 489 + return data; 490 + }, 491 + queryKey: duplicateName2QueryKey(options) 492 + }); 493 + 494 + export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => { 495 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> = { 496 + mutationFn: async (fnOptions) => { 497 + const { data } = await duplicateName3({ 498 + ...options, 499 + ...fnOptions, 500 + throwOnError: true 501 + }); 502 + return data; 503 + } 504 + }; 505 + return mutationOptions; 506 + }; 507 + 508 + export const useDuplicateName3Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName3Mutation(), ...mutationOptions }); 509 + 510 + export const duplicateName4Mutation = (options?: Partial<Options<DuplicateName4Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> => { 511 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>> = { 512 + mutationFn: async (fnOptions) => { 513 + const { data } = await duplicateName4({ 514 + ...options, 515 + ...fnOptions, 516 + throwOnError: true 517 + }); 518 + return data; 519 + } 520 + }; 521 + return mutationOptions; 522 + }; 523 + 524 + export const useDuplicateName4Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<DuplicateName4Data>>, 'mutationFn'>>) => useMutation({ ...duplicateName4Mutation(), ...mutationOptions }); 525 + 526 + export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 527 + 528 + export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => queryOptions<CallWithNoContentResponseResponse, DefaultError, CallWithNoContentResponseResponse, ReturnType<typeof callWithNoContentResponseQueryKey>>({ 529 + queryFn: async ({ queryKey, signal }) => { 530 + const { data } = await callWithNoContentResponse({ 531 + ...options, 532 + ...queryKey[0], 533 + signal, 534 + throwOnError: true 535 + }); 536 + return data; 537 + }, 538 + queryKey: callWithNoContentResponseQueryKey(options) 539 + }); 540 + 541 + export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 542 + 543 + export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => queryOptions<CallWithResponseAndNoContentResponseResponse, DefaultError, CallWithResponseAndNoContentResponseResponse, ReturnType<typeof callWithResponseAndNoContentResponseQueryKey>>({ 544 + queryFn: async ({ queryKey, signal }) => { 545 + const { data } = await callWithResponseAndNoContentResponse({ 546 + ...options, 547 + ...queryKey[0], 548 + signal, 549 + throwOnError: true 550 + }); 551 + return data; 552 + }, 553 + queryKey: callWithResponseAndNoContentResponseQueryKey(options) 554 + }); 555 + 556 + export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 557 + 558 + export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<DummyAResponse, DefaultError, DummyAResponse, ReturnType<typeof dummyAQueryKey>>({ 559 + queryFn: async ({ queryKey, signal }) => { 560 + const { data } = await dummyA({ 561 + ...options, 562 + ...queryKey[0], 563 + signal, 564 + throwOnError: true 565 + }); 566 + return data; 567 + }, 568 + queryKey: dummyAQueryKey(options) 569 + }); 570 + 571 + export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 572 + 573 + export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<DummyBResponse, DefaultError, DummyBResponse, ReturnType<typeof dummyBQueryKey>>({ 574 + queryFn: async ({ queryKey, signal }) => { 575 + const { data } = await dummyB({ 576 + ...options, 577 + ...queryKey[0], 578 + signal, 579 + throwOnError: true 580 + }); 581 + return data; 582 + }, 583 + queryKey: dummyBQueryKey(options) 584 + }); 585 + 586 + export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 587 + 588 + export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => queryOptions<CallWithResponseResponse, DefaultError, CallWithResponseResponse, ReturnType<typeof callWithResponseQueryKey>>({ 589 + queryFn: async ({ queryKey, signal }) => { 590 + const { data } = await callWithResponse({ 591 + ...options, 592 + ...queryKey[0], 593 + signal, 594 + throwOnError: true 595 + }); 596 + return data; 597 + }, 598 + queryKey: callWithResponseQueryKey(options) 599 + }); 600 + 601 + export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => { 602 + const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> = { 603 + mutationFn: async (fnOptions) => { 604 + const { data } = await callWithDuplicateResponses({ 605 + ...options, 606 + ...fnOptions, 607 + throwOnError: true 608 + }); 609 + return data; 610 + } 611 + }; 612 + return mutationOptions; 613 + }; 614 + 615 + export const useCallWithDuplicateResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithDuplicateResponsesMutation(), ...mutationOptions }); 616 + 617 + export const callWithResponsesMutation = (options?: Partial<Options<CallWithResponsesData>>): UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> => { 618 + const mutationOptions: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>> = { 619 + mutationFn: async (fnOptions) => { 620 + const { data } = await callWithResponses({ 621 + ...options, 622 + ...fnOptions, 623 + throwOnError: true 624 + }); 625 + return data; 626 + } 627 + }; 628 + return mutationOptions; 629 + }; 630 + 631 + export const useCallWithResponsesMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options<CallWithResponsesData>>, 'mutationFn'>>) => useMutation({ ...callWithResponsesMutation(), ...mutationOptions }); 632 + 633 + export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 634 + 635 + export const collectionFormatOptions = (options: Options<CollectionFormatData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof collectionFormatQueryKey>>({ 636 + queryFn: async ({ queryKey, signal }) => { 637 + const { data } = await collectionFormat({ 638 + ...options, 639 + ...queryKey[0], 640 + signal, 641 + throwOnError: true 642 + }); 643 + return data; 644 + }, 645 + queryKey: collectionFormatQueryKey(options) 646 + }); 647 + 648 + export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 649 + 650 + export const typesOptions = (options: Options<TypesData>) => queryOptions<TypesResponse, DefaultError, TypesResponse, ReturnType<typeof typesQueryKey>>({ 651 + queryFn: async ({ queryKey, signal }) => { 652 + const { data } = await types({ 653 + ...options, 654 + ...queryKey[0], 655 + signal, 656 + throwOnError: true 657 + }); 658 + return data; 659 + }, 660 + queryKey: typesQueryKey(options) 661 + }); 662 + 663 + export const uploadFileMutation = (options?: Partial<Options<UploadFileData>>): UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>> => { 664 + const mutationOptions: UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>> = { 665 + mutationFn: async (fnOptions) => { 666 + const { data } = await uploadFile({ 667 + ...options, 668 + ...fnOptions, 669 + throwOnError: true 670 + }); 671 + return data; 672 + } 673 + }; 674 + return mutationOptions; 675 + }; 676 + 677 + export const useUploadFileMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<UploadFileResponse, DefaultError, Options<UploadFileData>>, 'mutationFn'>>) => useMutation({ ...uploadFileMutation(), ...mutationOptions }); 678 + 679 + export const fileResponseQueryKey = (options: Options<FileResponseData>) => createQueryKey('fileResponse', options); 680 + 681 + export const fileResponseOptions = (options: Options<FileResponseData>) => queryOptions<FileResponseResponse, DefaultError, FileResponseResponse, ReturnType<typeof fileResponseQueryKey>>({ 682 + queryFn: async ({ queryKey, signal }) => { 683 + const { data } = await fileResponse({ 684 + ...options, 685 + ...queryKey[0], 686 + signal, 687 + throwOnError: true 688 + }); 689 + return data; 690 + }, 691 + queryKey: fileResponseQueryKey(options) 692 + }); 693 + 694 + export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 695 + 696 + export const complexTypesOptions = (options: Options<ComplexTypesData>) => queryOptions<ComplexTypesResponse, DefaultError, ComplexTypesResponse, ReturnType<typeof complexTypesQueryKey>>({ 697 + queryFn: async ({ queryKey, signal }) => { 698 + const { data } = await complexTypes({ 699 + ...options, 700 + ...queryKey[0], 701 + signal, 702 + throwOnError: true 703 + }); 704 + return data; 705 + }, 706 + queryKey: complexTypesQueryKey(options) 707 + }); 708 + 709 + export const multipartResponseQueryKey = (options?: Options<MultipartResponseData>) => createQueryKey('multipartResponse', options); 710 + 711 + export const multipartResponseOptions = (options?: Options<MultipartResponseData>) => queryOptions<MultipartResponseResponse, DefaultError, MultipartResponseResponse, ReturnType<typeof multipartResponseQueryKey>>({ 712 + queryFn: async ({ queryKey, signal }) => { 713 + const { data } = await multipartResponse({ 714 + ...options, 715 + ...queryKey[0], 716 + signal, 717 + throwOnError: true 718 + }); 719 + return data; 720 + }, 721 + queryKey: multipartResponseQueryKey(options) 722 + }); 723 + 724 + export const multipartRequestMutation = (options?: Partial<Options<MultipartRequestData>>): UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>> => { 725 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>> = { 726 + mutationFn: async (fnOptions) => { 727 + const { data } = await multipartRequest({ 728 + ...options, 729 + ...fnOptions, 730 + throwOnError: true 731 + }); 732 + return data; 733 + } 734 + }; 735 + return mutationOptions; 736 + }; 737 + 738 + export const useMultipartRequestMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<MultipartRequestData>>, 'mutationFn'>>) => useMutation({ ...multipartRequestMutation(), ...mutationOptions }); 739 + 740 + export const complexParamsMutation = (options?: Partial<Options<ComplexParamsData>>): UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>> => { 741 + const mutationOptions: UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>> = { 742 + mutationFn: async (fnOptions) => { 743 + const { data } = await complexParams({ 744 + ...options, 745 + ...fnOptions, 746 + throwOnError: true 747 + }); 748 + return data; 749 + } 750 + }; 751 + return mutationOptions; 752 + }; 753 + 754 + export const useComplexParamsMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<ComplexParamsResponse, DefaultError, Options<ComplexParamsData>>, 'mutationFn'>>) => useMutation({ ...complexParamsMutation(), ...mutationOptions }); 755 + 756 + export const callWithResultFromHeaderMutation = (options?: Partial<Options<CallWithResultFromHeaderData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> => { 757 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> = { 758 + mutationFn: async (fnOptions) => { 759 + const { data } = await callWithResultFromHeader({ 760 + ...options, 761 + ...fnOptions, 762 + throwOnError: true 763 + }); 764 + return data; 765 + } 766 + }; 767 + return mutationOptions; 768 + }; 769 + 770 + export const useCallWithResultFromHeaderMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>>, 'mutationFn'>>) => useMutation({ ...callWithResultFromHeaderMutation(), ...mutationOptions }); 771 + 772 + export const testErrorCodeMutation = (options?: Partial<Options<TestErrorCodeData>>): UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> => { 773 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>> = { 774 + mutationFn: async (fnOptions) => { 775 + const { data } = await testErrorCode({ 776 + ...options, 777 + ...fnOptions, 778 + throwOnError: true 779 + }); 780 + return data; 781 + } 782 + }; 783 + return mutationOptions; 784 + }; 785 + 786 + export const useTestErrorCodeMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<TestErrorCodeData>>, 'mutationFn'>>) => useMutation({ ...testErrorCodeMutation(), ...mutationOptions }); 787 + 788 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options?: Partial<Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>): UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> => { 789 + const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 790 + mutationFn: async (fnOptions) => { 791 + const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 792 + ...options, 793 + ...fnOptions, 794 + throwOnError: true 795 + }); 796 + return data; 797 + } 798 + }; 799 + return mutationOptions; 800 + }; 801 + 802 + export const useNonAsciiæøåÆøÅöôêÊ字符串Mutation = (mutationOptions?: Partial<Omit<UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultError, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>>, 'mutationFn'>>) => useMutation({ ...nonAsciiæøåÆøÅöôêÊ字符串Mutation(), ...mutationOptions }); 803 + 804 + /** 805 + * Login User 806 + */ 807 + export const putWithFormUrlEncodedMutation = (options?: Partial<Options<PutWithFormUrlEncodedData>>): UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>> => { 808 + const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>> = { 809 + mutationFn: async (fnOptions) => { 810 + const { data } = await putWithFormUrlEncoded({ 811 + ...options, 812 + ...fnOptions, 813 + throwOnError: true 814 + }); 815 + return data; 816 + } 817 + }; 818 + return mutationOptions; 819 + }; 820 + 821 + /** 822 + * Login User 823 + */ 824 + export const usePutWithFormUrlEncodedMutation = (mutationOptions?: Partial<Omit<UseMutationOptions<unknown, DefaultError, Options<PutWithFormUrlEncodedData>>, 'mutationFn'>>) => useMutation({ ...putWithFormUrlEncodedMutation(), ...mutationOptions });
+16
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 + import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:3000/base' }));
+288
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createSseClient } from '../core/serverSentEvents.gen'; 4 + import type { HttpMethod } from '../core/types.gen'; 5 + import { getValidRequestBody } from '../core/utils.gen'; 6 + import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen'; 7 + import { 8 + buildUrl, 9 + createConfig, 10 + createInterceptors, 11 + getParseAs, 12 + mergeConfigs, 13 + mergeHeaders, 14 + setAuthParams, 15 + } from './utils.gen'; 16 + 17 + type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 18 + body?: any; 19 + headers: ReturnType<typeof mergeHeaders>; 20 + }; 21 + 22 + export const createClient = (config: Config = {}): Client => { 23 + let _config = mergeConfigs(createConfig(), config); 24 + 25 + const getConfig = (): Config => ({ ..._config }); 26 + 27 + const setConfig = (config: Config): Config => { 28 + _config = mergeConfigs(_config, config); 29 + return getConfig(); 30 + }; 31 + 32 + const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 33 + 34 + const beforeRequest = async (options: RequestOptions) => { 35 + const opts = { 36 + ..._config, 37 + ...options, 38 + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 39 + headers: mergeHeaders(_config.headers, options.headers), 40 + serializedBody: undefined as string | undefined, 41 + }; 42 + 43 + if (opts.security) { 44 + await setAuthParams({ 45 + ...opts, 46 + security: opts.security, 47 + }); 48 + } 49 + 50 + if (opts.requestValidator) { 51 + await opts.requestValidator(opts); 52 + } 53 + 54 + if (opts.body !== undefined && opts.bodySerializer) { 55 + opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 56 + } 57 + 58 + // remove Content-Type header if body is empty to avoid sending invalid requests 59 + if (opts.body === undefined || opts.serializedBody === '') { 60 + opts.headers.delete('Content-Type'); 61 + } 62 + 63 + const url = buildUrl(opts); 64 + 65 + return { opts, url }; 66 + }; 67 + 68 + const request: Client['request'] = async (options) => { 69 + // @ts-expect-error 70 + const { opts, url } = await beforeRequest(options); 71 + const requestInit: ReqInit = { 72 + redirect: 'follow', 73 + ...opts, 74 + body: getValidRequestBody(opts), 75 + }; 76 + 77 + let request = new Request(url, requestInit); 78 + 79 + for (const fn of interceptors.request.fns) { 80 + if (fn) { 81 + request = await fn(request, opts); 82 + } 83 + } 84 + 85 + // fetch must be assigned here, otherwise it would throw the error: 86 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 + const _fetch = opts.fetch!; 88 + let response: Response; 89 + 90 + try { 91 + response = await _fetch(request); 92 + } catch (error) { 93 + // Handle fetch exceptions (AbortError, network errors, etc.) 94 + let finalError = error; 95 + 96 + for (const fn of interceptors.error.fns) { 97 + if (fn) { 98 + finalError = (await fn(error, undefined as any, request, opts)) as unknown; 99 + } 100 + } 101 + 102 + finalError = finalError || ({} as unknown); 103 + 104 + if (opts.throwOnError) { 105 + throw finalError; 106 + } 107 + 108 + // Return error response 109 + return opts.responseStyle === 'data' 110 + ? undefined 111 + : { 112 + error: finalError, 113 + request, 114 + response: undefined as any, 115 + }; 116 + } 117 + 118 + for (const fn of interceptors.response.fns) { 119 + if (fn) { 120 + response = await fn(response, request, opts); 121 + } 122 + } 123 + 124 + const result = { 125 + request, 126 + response, 127 + }; 128 + 129 + if (response.ok) { 130 + const parseAs = 131 + (opts.parseAs === 'auto' 132 + ? getParseAs(response.headers.get('Content-Type')) 133 + : opts.parseAs) ?? 'json'; 134 + 135 + if (response.status === 204 || response.headers.get('Content-Length') === '0') { 136 + let emptyData: any; 137 + switch (parseAs) { 138 + case 'arrayBuffer': 139 + case 'blob': 140 + case 'text': 141 + emptyData = await response[parseAs](); 142 + break; 143 + case 'formData': 144 + emptyData = new FormData(); 145 + break; 146 + case 'stream': 147 + emptyData = response.body; 148 + break; 149 + case 'json': 150 + default: 151 + emptyData = {}; 152 + break; 153 + } 154 + return opts.responseStyle === 'data' 155 + ? emptyData 156 + : { 157 + data: emptyData, 158 + ...result, 159 + }; 160 + } 161 + 162 + let data: any; 163 + switch (parseAs) { 164 + case 'arrayBuffer': 165 + case 'blob': 166 + case 'formData': 167 + case 'text': 168 + data = await response[parseAs](); 169 + break; 170 + case 'json': { 171 + // Some servers return 200 with no Content-Length and empty body. 172 + // response.json() would throw; read as text and parse if non-empty. 173 + const text = await response.text(); 174 + data = text ? JSON.parse(text) : {}; 175 + break; 176 + } 177 + case 'stream': 178 + return opts.responseStyle === 'data' 179 + ? response.body 180 + : { 181 + data: response.body, 182 + ...result, 183 + }; 184 + } 185 + 186 + if (parseAs === 'json') { 187 + if (opts.responseValidator) { 188 + await opts.responseValidator(data); 189 + } 190 + 191 + if (opts.responseTransformer) { 192 + data = await opts.responseTransformer(data); 193 + } 194 + } 195 + 196 + return opts.responseStyle === 'data' 197 + ? data 198 + : { 199 + data, 200 + ...result, 201 + }; 202 + } 203 + 204 + const textError = await response.text(); 205 + let jsonError: unknown; 206 + 207 + try { 208 + jsonError = JSON.parse(textError); 209 + } catch { 210 + // noop 211 + } 212 + 213 + const error = jsonError ?? textError; 214 + let finalError = error; 215 + 216 + for (const fn of interceptors.error.fns) { 217 + if (fn) { 218 + finalError = (await fn(error, response, request, opts)) as string; 219 + } 220 + } 221 + 222 + finalError = finalError || ({} as string); 223 + 224 + if (opts.throwOnError) { 225 + throw finalError; 226 + } 227 + 228 + // TODO: we probably want to return error and improve types 229 + return opts.responseStyle === 'data' 230 + ? undefined 231 + : { 232 + error: finalError, 233 + ...result, 234 + }; 235 + }; 236 + 237 + const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 238 + request({ ...options, method }); 239 + 240 + const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 241 + const { opts, url } = await beforeRequest(options); 242 + return createSseClient({ 243 + ...opts, 244 + body: opts.body as BodyInit | null | undefined, 245 + headers: opts.headers as unknown as Record<string, string>, 246 + method, 247 + onRequest: async (url, init) => { 248 + let request = new Request(url, init); 249 + for (const fn of interceptors.request.fns) { 250 + if (fn) { 251 + request = await fn(request, opts); 252 + } 253 + } 254 + return request; 255 + }, 256 + serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined, 257 + url, 258 + }); 259 + }; 260 + 261 + return { 262 + buildUrl, 263 + connect: makeMethodFn('CONNECT'), 264 + delete: makeMethodFn('DELETE'), 265 + get: makeMethodFn('GET'), 266 + getConfig, 267 + head: makeMethodFn('HEAD'), 268 + interceptors, 269 + options: makeMethodFn('OPTIONS'), 270 + patch: makeMethodFn('PATCH'), 271 + post: makeMethodFn('POST'), 272 + put: makeMethodFn('PUT'), 273 + request, 274 + setConfig, 275 + sse: { 276 + connect: makeSseFn('CONNECT'), 277 + delete: makeSseFn('DELETE'), 278 + get: makeSseFn('GET'), 279 + head: makeSseFn('HEAD'), 280 + options: makeSseFn('OPTIONS'), 281 + patch: makeSseFn('PATCH'), 282 + post: makeSseFn('POST'), 283 + put: makeSseFn('PUT'), 284 + trace: makeSseFn('TRACE'), 285 + }, 286 + trace: makeMethodFn('TRACE'), 287 + } as Client; 288 + };
+25
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 + export { createClient } from './client.gen'; 13 + export type { 14 + Client, 15 + ClientOptions, 16 + Config, 17 + CreateClientConfig, 18 + Options, 19 + RequestOptions, 20 + RequestResult, 21 + ResolvedRequestOptions, 22 + ResponseStyle, 23 + TDataShape, 24 + } from './types.gen'; 25 + export { createConfig, mergeHeaders } from './utils.gen';
+214
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth } from '../core/auth.gen'; 4 + import type { 5 + ServerSentEventsOptions, 6 + ServerSentEventsResult, 7 + } from '../core/serverSentEvents.gen'; 8 + import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen'; 9 + import type { Middleware } from './utils.gen'; 10 + 11 + export type ResponseStyle = 'data' | 'fields'; 12 + 13 + export interface Config<T extends ClientOptions = ClientOptions> 14 + extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig { 15 + /** 16 + * Base URL for all requests made by this client. 17 + */ 18 + baseUrl?: T['baseUrl']; 19 + /** 20 + * Fetch API implementation. You can use this option to provide a custom 21 + * fetch instance. 22 + * 23 + * @default globalThis.fetch 24 + */ 25 + fetch?: typeof fetch; 26 + /** 27 + * Please don't use the Fetch client for Next.js applications. The `next` 28 + * options won't have any effect. 29 + * 30 + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 31 + */ 32 + next?: never; 33 + /** 34 + * Return the response data parsed in a specified format. By default, `auto` 35 + * will infer the appropriate method from the `Content-Type` response header. 36 + * You can override this behavior with any of the {@link Body} methods. 37 + * Select `stream` if you don't want to parse response data at all. 38 + * 39 + * @default 'auto' 40 + */ 41 + parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 42 + /** 43 + * Should we return only data or multiple fields (data, error, response, etc.)? 44 + * 45 + * @default 'fields' 46 + */ 47 + responseStyle?: ResponseStyle; 48 + /** 49 + * Throw an error instead of returning it in the response? 50 + * 51 + * @default false 52 + */ 53 + throwOnError?: T['throwOnError']; 54 + } 55 + 56 + export interface RequestOptions< 57 + TData = unknown, 58 + TResponseStyle extends ResponseStyle = 'fields', 59 + ThrowOnError extends boolean = boolean, 60 + Url extends string = string, 61 + > 62 + extends 63 + Config<{ 64 + responseStyle: TResponseStyle; 65 + throwOnError: ThrowOnError; 66 + }>, 67 + Pick< 68 + ServerSentEventsOptions<TData>, 69 + | 'onRequest' 70 + | 'onSseError' 71 + | 'onSseEvent' 72 + | 'sseDefaultRetryDelay' 73 + | 'sseMaxRetryAttempts' 74 + | 'sseMaxRetryDelay' 75 + > { 76 + /** 77 + * Any body that you want to add to your request. 78 + * 79 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 80 + */ 81 + body?: unknown; 82 + path?: Record<string, unknown>; 83 + query?: Record<string, unknown>; 84 + /** 85 + * Security mechanism(s) to use for the request. 86 + */ 87 + security?: ReadonlyArray<Auth>; 88 + url: Url; 89 + } 90 + 91 + export interface ResolvedRequestOptions< 92 + TResponseStyle extends ResponseStyle = 'fields', 93 + ThrowOnError extends boolean = boolean, 94 + Url extends string = string, 95 + > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 96 + serializedBody?: string; 97 + } 98 + 99 + export type RequestResult< 100 + TData = unknown, 101 + TError = unknown, 102 + ThrowOnError extends boolean = boolean, 103 + TResponseStyle extends ResponseStyle = 'fields', 104 + > = ThrowOnError extends true 105 + ? Promise< 106 + TResponseStyle extends 'data' 107 + ? TData extends Record<string, unknown> 108 + ? TData[keyof TData] 109 + : TData 110 + : { 111 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 112 + request: Request; 113 + response: Response; 114 + } 115 + > 116 + : Promise< 117 + TResponseStyle extends 'data' 118 + ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined 119 + : ( 120 + | { 121 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 122 + error: undefined; 123 + } 124 + | { 125 + data: undefined; 126 + error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; 127 + } 128 + ) & { 129 + request: Request; 130 + response: Response; 131 + } 132 + >; 133 + 134 + export interface ClientOptions { 135 + baseUrl?: string; 136 + responseStyle?: ResponseStyle; 137 + throwOnError?: boolean; 138 + } 139 + 140 + type MethodFn = < 141 + TData = unknown, 142 + TError = unknown, 143 + ThrowOnError extends boolean = false, 144 + TResponseStyle extends ResponseStyle = 'fields', 145 + >( 146 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 147 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 148 + 149 + type SseFn = < 150 + TData = unknown, 151 + TError = unknown, 152 + ThrowOnError extends boolean = false, 153 + TResponseStyle extends ResponseStyle = 'fields', 154 + >( 155 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 156 + ) => Promise<ServerSentEventsResult<TData, TError>>; 157 + 158 + type RequestFn = < 159 + TData = unknown, 160 + TError = unknown, 161 + ThrowOnError extends boolean = false, 162 + TResponseStyle extends ResponseStyle = 'fields', 163 + >( 164 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 165 + Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>, 166 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 + 168 + type BuildUrlFn = < 169 + TData extends { 170 + body?: unknown; 171 + path?: Record<string, unknown>; 172 + query?: Record<string, unknown>; 173 + url: string; 174 + }, 175 + >( 176 + options: TData & Options<TData>, 177 + ) => string; 178 + 179 + export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { 180 + interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 181 + }; 182 + 183 + /** 184 + * The `createClientConfig()` function will be called on client initialization 185 + * and the returned object will become the client's initial configuration. 186 + * 187 + * You may want to initialize your client this way instead of calling 188 + * `setConfig()`. This is useful for example if you're using Next.js 189 + * to ensure your client always has the correct values. 190 + */ 191 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 192 + override?: Config<ClientOptions & T>, 193 + ) => Config<Required<ClientOptions> & T>; 194 + 195 + export interface TDataShape { 196 + body?: unknown; 197 + headers?: unknown; 198 + path?: unknown; 199 + query?: unknown; 200 + url: string; 201 + } 202 + 203 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 204 + 205 + export type Options< 206 + TData extends TDataShape = TDataShape, 207 + ThrowOnError extends boolean = boolean, 208 + TResponse = unknown, 209 + TResponseStyle extends ResponseStyle = 'fields', 210 + > = OmitKeys< 211 + RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 212 + 'body' | 'path' | 'query' | 'url' 213 + > & 214 + ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
+316
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 + import { 7 + serializeArrayParam, 8 + serializeObjectParam, 9 + serializePrimitiveParam, 10 + } from '../core/pathSerializer.gen'; 11 + import { getUrl } from '../core/utils.gen'; 12 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 + 14 + export const createQuerySerializer = <T = unknown>({ 15 + parameters = {}, 16 + ...args 17 + }: QuerySerializerOptions = {}) => { 18 + const querySerializer = (queryParams: T) => { 19 + const search: string[] = []; 20 + if (queryParams && typeof queryParams === 'object') { 21 + for (const name in queryParams) { 22 + const value = queryParams[name]; 23 + 24 + if (value === undefined || value === null) { 25 + continue; 26 + } 27 + 28 + const options = parameters[name] || args; 29 + 30 + if (Array.isArray(value)) { 31 + const serializedArray = serializeArrayParam({ 32 + allowReserved: options.allowReserved, 33 + explode: true, 34 + name, 35 + style: 'form', 36 + value, 37 + ...options.array, 38 + }); 39 + if (serializedArray) search.push(serializedArray); 40 + } else if (typeof value === 'object') { 41 + const serializedObject = serializeObjectParam({ 42 + allowReserved: options.allowReserved, 43 + explode: true, 44 + name, 45 + style: 'deepObject', 46 + value: value as Record<string, unknown>, 47 + ...options.object, 48 + }); 49 + if (serializedObject) search.push(serializedObject); 50 + } else { 51 + const serializedPrimitive = serializePrimitiveParam({ 52 + allowReserved: options.allowReserved, 53 + name, 54 + value: value as string, 55 + }); 56 + if (serializedPrimitive) search.push(serializedPrimitive); 57 + } 58 + } 59 + } 60 + return search.join('&'); 61 + }; 62 + return querySerializer; 63 + }; 64 + 65 + /** 66 + * Infers parseAs value from provided Content-Type header. 67 + */ 68 + export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => { 69 + if (!contentType) { 70 + // If no Content-Type header is provided, the best we can do is return the raw response body, 71 + // which is effectively the same as the 'stream' option. 72 + return 'stream'; 73 + } 74 + 75 + const cleanContent = contentType.split(';')[0]?.trim(); 76 + 77 + if (!cleanContent) { 78 + return; 79 + } 80 + 81 + if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) { 82 + return 'json'; 83 + } 84 + 85 + if (cleanContent === 'multipart/form-data') { 86 + return 'formData'; 87 + } 88 + 89 + if ( 90 + ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type)) 91 + ) { 92 + return 'blob'; 93 + } 94 + 95 + if (cleanContent.startsWith('text/')) { 96 + return 'text'; 97 + } 98 + 99 + return; 100 + }; 101 + 102 + const checkForExistence = ( 103 + options: Pick<RequestOptions, 'auth' | 'query'> & { 104 + headers: Headers; 105 + }, 106 + name?: string, 107 + ): boolean => { 108 + if (!name) { 109 + return false; 110 + } 111 + if ( 112 + options.headers.has(name) || 113 + options.query?.[name] || 114 + options.headers.get('Cookie')?.includes(`${name}=`) 115 + ) { 116 + return true; 117 + } 118 + return false; 119 + }; 120 + 121 + export const setAuthParams = async ({ 122 + security, 123 + ...options 124 + }: Pick<Required<RequestOptions>, 'security'> & 125 + Pick<RequestOptions, 'auth' | 'query'> & { 126 + headers: Headers; 127 + }) => { 128 + for (const auth of security) { 129 + if (checkForExistence(options, auth.name)) { 130 + continue; 131 + } 132 + 133 + const token = await getAuthToken(auth, options.auth); 134 + 135 + if (!token) { 136 + continue; 137 + } 138 + 139 + const name = auth.name ?? 'Authorization'; 140 + 141 + switch (auth.in) { 142 + case 'query': 143 + if (!options.query) { 144 + options.query = {}; 145 + } 146 + options.query[name] = token; 147 + break; 148 + case 'cookie': 149 + options.headers.append('Cookie', `${name}=${token}`); 150 + break; 151 + case 'header': 152 + default: 153 + options.headers.set(name, token); 154 + break; 155 + } 156 + } 157 + }; 158 + 159 + export const buildUrl: Client['buildUrl'] = (options) => 160 + getUrl({ 161 + baseUrl: options.baseUrl as string, 162 + path: options.path, 163 + query: options.query, 164 + querySerializer: 165 + typeof options.querySerializer === 'function' 166 + ? options.querySerializer 167 + : createQuerySerializer(options.querySerializer), 168 + url: options.url, 169 + }); 170 + 171 + export const mergeConfigs = (a: Config, b: Config): Config => { 172 + const config = { ...a, ...b }; 173 + if (config.baseUrl?.endsWith('/')) { 174 + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 175 + } 176 + config.headers = mergeHeaders(a.headers, b.headers); 177 + return config; 178 + }; 179 + 180 + const headersEntries = (headers: Headers): Array<[string, string]> => { 181 + const entries: Array<[string, string]> = []; 182 + headers.forEach((value, key) => { 183 + entries.push([key, value]); 184 + }); 185 + return entries; 186 + }; 187 + 188 + export const mergeHeaders = ( 189 + ...headers: Array<Required<Config>['headers'] | undefined> 190 + ): Headers => { 191 + const mergedHeaders = new Headers(); 192 + for (const header of headers) { 193 + if (!header) { 194 + continue; 195 + } 196 + 197 + const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header); 198 + 199 + for (const [key, value] of iterator) { 200 + if (value === null) { 201 + mergedHeaders.delete(key); 202 + } else if (Array.isArray(value)) { 203 + for (const v of value) { 204 + mergedHeaders.append(key, v as string); 205 + } 206 + } else if (value !== undefined) { 207 + // assume object headers are meant to be JSON stringified, i.e. their 208 + // content value in OpenAPI specification is 'application/json' 209 + mergedHeaders.set( 210 + key, 211 + typeof value === 'object' ? JSON.stringify(value) : (value as string), 212 + ); 213 + } 214 + } 215 + } 216 + return mergedHeaders; 217 + }; 218 + 219 + type ErrInterceptor<Err, Res, Req, Options> = ( 220 + error: Err, 221 + response: Res, 222 + request: Req, 223 + options: Options, 224 + ) => Err | Promise<Err>; 225 + 226 + type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; 227 + 228 + type ResInterceptor<Res, Req, Options> = ( 229 + response: Res, 230 + request: Req, 231 + options: Options, 232 + ) => Res | Promise<Res>; 233 + 234 + class Interceptors<Interceptor> { 235 + fns: Array<Interceptor | null> = []; 236 + 237 + clear(): void { 238 + this.fns = []; 239 + } 240 + 241 + eject(id: number | Interceptor): void { 242 + const index = this.getInterceptorIndex(id); 243 + if (this.fns[index]) { 244 + this.fns[index] = null; 245 + } 246 + } 247 + 248 + exists(id: number | Interceptor): boolean { 249 + const index = this.getInterceptorIndex(id); 250 + return Boolean(this.fns[index]); 251 + } 252 + 253 + getInterceptorIndex(id: number | Interceptor): number { 254 + if (typeof id === 'number') { 255 + return this.fns[id] ? id : -1; 256 + } 257 + return this.fns.indexOf(id); 258 + } 259 + 260 + update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false { 261 + const index = this.getInterceptorIndex(id); 262 + if (this.fns[index]) { 263 + this.fns[index] = fn; 264 + return id; 265 + } 266 + return false; 267 + } 268 + 269 + use(fn: Interceptor): number { 270 + this.fns.push(fn); 271 + return this.fns.length - 1; 272 + } 273 + } 274 + 275 + export interface Middleware<Req, Res, Err, Options> { 276 + error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 277 + request: Interceptors<ReqInterceptor<Req, Options>>; 278 + response: Interceptors<ResInterceptor<Res, Req, Options>>; 279 + } 280 + 281 + export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 282 + Req, 283 + Res, 284 + Err, 285 + Options 286 + > => ({ 287 + error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 288 + request: new Interceptors<ReqInterceptor<Req, Options>>(), 289 + response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 290 + }); 291 + 292 + const defaultQuerySerializer = createQuerySerializer({ 293 + allowReserved: false, 294 + array: { 295 + explode: true, 296 + style: 'form', 297 + }, 298 + object: { 299 + explode: true, 300 + style: 'deepObject', 301 + }, 302 + }); 303 + 304 + const defaultHeaders = { 305 + 'Content-Type': 'application/json', 306 + }; 307 + 308 + export const createConfig = <T extends ClientOptions = ClientOptions>( 309 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 310 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 311 + ...jsonBodySerializer, 312 + headers: defaultHeaders, 313 + parseAs: 'auto', 314 + querySerializer: defaultQuerySerializer, 315 + ...override, 316 + });
+41
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = typeof callback === 'function' ? await callback(auth) : callback; 27 + 28 + if (!token) { 29 + return; 30 + } 31 + 32 + if (auth.scheme === 'bearer') { 33 + return `Bearer ${token}`; 34 + } 35 + 36 + if (auth.scheme === 'basic') { 37 + return `Basic ${btoa(token)}`; 38 + } 39 + 40 + return token; 41 + };
+82
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen'; 4 + 5 + export type QuerySerializer = (query: Record<string, unknown>) => string; 6 + 7 + export type BodySerializer = (body: unknown) => unknown; 8 + 9 + type QuerySerializerOptionsObject = { 10 + allowReserved?: boolean; 11 + array?: Partial<SerializerOptions<ArrayStyle>>; 12 + object?: Partial<SerializerOptions<ObjectStyle>>; 13 + }; 14 + 15 + export type QuerySerializerOptions = QuerySerializerOptionsObject & { 16 + /** 17 + * Per-parameter serialization overrides. When provided, these settings 18 + * override the global array/object settings for specific parameter names. 19 + */ 20 + parameters?: Record<string, QuerySerializerOptionsObject>; 21 + }; 22 + 23 + const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => { 34 + if (typeof value === 'string') { 35 + data.append(key, value); 36 + } else { 37 + data.append(key, JSON.stringify(value)); 38 + } 39 + }; 40 + 41 + export const formDataBodySerializer = { 42 + bodySerializer: (body: unknown): FormData => { 43 + const data = new FormData(); 44 + 45 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 46 + if (value === undefined || value === null) { 47 + return; 48 + } 49 + if (Array.isArray(value)) { 50 + value.forEach((v) => serializeFormDataPair(data, key, v)); 51 + } else { 52 + serializeFormDataPair(data, key, value); 53 + } 54 + }); 55 + 56 + return data; 57 + }, 58 + }; 59 + 60 + export const jsonBodySerializer = { 61 + bodySerializer: (body: unknown): string => 62 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 63 + }; 64 + 65 + export const urlSearchParamsBodySerializer = { 66 + bodySerializer: (body: unknown): string => { 67 + const data = new URLSearchParams(); 68 + 69 + Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 70 + if (value === undefined || value === null) { 71 + return; 72 + } 73 + if (Array.isArray(value)) { 74 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 75 + } else { 76 + serializeUrlSearchParamsPair(data, key, value); 77 + } 78 + }); 79 + 80 + return data.toString(); 81 + }, 82 + };
+169
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + } 26 + | { 27 + /** 28 + * Field name. This is the name we want the user to see and use. 29 + */ 30 + key: string; 31 + /** 32 + * Field mapped name. This is the name we want to use in the request. 33 + * If `in` is omitted, `map` aliases `key` to the transport layer. 34 + */ 35 + map: Slot; 36 + }; 37 + 38 + export interface Fields { 39 + allowExtra?: Partial<Record<Slot, boolean>>; 40 + args?: ReadonlyArray<Field>; 41 + } 42 + 43 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 + 45 + const extraPrefixesMap: Record<string, Slot> = { 46 + $body_: 'body', 47 + $headers_: 'headers', 48 + $path_: 'path', 49 + $query_: 'query', 50 + }; 51 + const extraPrefixes = Object.entries(extraPrefixesMap); 52 + 53 + type KeyMap = Map< 54 + string, 55 + | { 56 + in: Slot; 57 + map?: string; 58 + } 59 + | { 60 + in?: never; 61 + map: Slot; 62 + } 63 + >; 64 + 65 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 + if (!map) { 67 + map = new Map(); 68 + } 69 + 70 + for (const config of fields) { 71 + if ('in' in config) { 72 + if (config.key) { 73 + map.set(config.key, { 74 + in: config.in, 75 + map: config.map, 76 + }); 77 + } 78 + } else if ('key' in config) { 79 + map.set(config.key, { 80 + map: config.map, 81 + }); 82 + } else if (config.args) { 83 + buildKeyMap(config.args, map); 84 + } 85 + } 86 + 87 + return map; 88 + }; 89 + 90 + interface Params { 91 + body: unknown; 92 + headers: Record<string, unknown>; 93 + path: Record<string, unknown>; 94 + query: Record<string, unknown>; 95 + } 96 + 97 + const stripEmptySlots = (params: Params) => { 98 + for (const [slot, value] of Object.entries(params)) { 99 + if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) { 100 + delete params[slot as Slot]; 101 + } 102 + } 103 + }; 104 + 105 + export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => { 106 + const params: Params = { 107 + body: {}, 108 + headers: {}, 109 + path: {}, 110 + query: {}, 111 + }; 112 + 113 + const map = buildKeyMap(fields); 114 + 115 + let config: FieldsConfig[number] | undefined; 116 + 117 + for (const [index, arg] of args.entries()) { 118 + if (fields[index]) { 119 + config = fields[index]; 120 + } 121 + 122 + if (!config) { 123 + continue; 124 + } 125 + 126 + if ('in' in config) { 127 + if (config.key) { 128 + const field = map.get(config.key)!; 129 + const name = field.map || config.key; 130 + if (field.in) { 131 + (params[field.in] as Record<string, unknown>)[name] = arg; 132 + } 133 + } else { 134 + params.body = arg; 135 + } 136 + } else { 137 + for (const [key, value] of Object.entries(arg ?? {})) { 138 + const field = map.get(key); 139 + 140 + if (field) { 141 + if (field.in) { 142 + const name = field.map || key; 143 + (params[field.in] as Record<string, unknown>)[name] = value; 144 + } else { 145 + params[field.map] = value; 146 + } 147 + } else { 148 + const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 149 + 150 + if (extra) { 151 + const [prefix, slot] = extra; 152 + (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value; 153 + } else if ('allowExtra' in config && config.allowExtra) { 154 + for (const [slot, allowed] of Object.entries(config.allowExtra)) { 155 + if (allowed) { 156 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 157 + break; 158 + } 159 + } 160 + } 161 + } 162 + } 163 + } 164 + } 165 + 166 + stripEmptySlots(params); 167 + 168 + return params; 169 + };
+171
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {} 4 + 5 + interface SerializePrimitiveOptions { 6 + allowReserved?: boolean; 7 + name: string; 8 + } 9 + 10 + export interface SerializerOptions<T> { 11 + /** 12 + * @default true 13 + */ 14 + explode: boolean; 15 + style: T; 16 + } 17 + 18 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 19 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 20 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 21 + export type ObjectStyle = 'form' | 'deepObject'; 22 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 23 + 24 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 25 + value: string; 26 + } 27 + 28 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 29 + switch (style) { 30 + case 'label': 31 + return '.'; 32 + case 'matrix': 33 + return ';'; 34 + case 'simple': 35 + return ','; 36 + default: 37 + return '&'; 38 + } 39 + }; 40 + 41 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 42 + switch (style) { 43 + case 'form': 44 + return ','; 45 + case 'pipeDelimited': 46 + return '|'; 47 + case 'spaceDelimited': 48 + return '%20'; 49 + default: 50 + return ','; 51 + } 52 + }; 53 + 54 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 55 + switch (style) { 56 + case 'label': 57 + return '.'; 58 + case 'matrix': 59 + return ';'; 60 + case 'simple': 61 + return ','; 62 + default: 63 + return '&'; 64 + } 65 + }; 66 + 67 + export const serializeArrayParam = ({ 68 + allowReserved, 69 + explode, 70 + name, 71 + style, 72 + value, 73 + }: SerializeOptions<ArraySeparatorStyle> & { 74 + value: unknown[]; 75 + }) => { 76 + if (!explode) { 77 + const joinedValues = ( 78 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 79 + ).join(separatorArrayNoExplode(style)); 80 + switch (style) { 81 + case 'label': 82 + return `.${joinedValues}`; 83 + case 'matrix': 84 + return `;${name}=${joinedValues}`; 85 + case 'simple': 86 + return joinedValues; 87 + default: 88 + return `${name}=${joinedValues}`; 89 + } 90 + } 91 + 92 + const separator = separatorArrayExplode(style); 93 + const joinedValues = value 94 + .map((v) => { 95 + if (style === 'label' || style === 'simple') { 96 + return allowReserved ? v : encodeURIComponent(v as string); 97 + } 98 + 99 + return serializePrimitiveParam({ 100 + allowReserved, 101 + name, 102 + value: v as string, 103 + }); 104 + }) 105 + .join(separator); 106 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 107 + }; 108 + 109 + export const serializePrimitiveParam = ({ 110 + allowReserved, 111 + name, 112 + value, 113 + }: SerializePrimitiveParam) => { 114 + if (value === undefined || value === null) { 115 + return ''; 116 + } 117 + 118 + if (typeof value === 'object') { 119 + throw new Error( 120 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 121 + ); 122 + } 123 + 124 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 125 + }; 126 + 127 + export const serializeObjectParam = ({ 128 + allowReserved, 129 + explode, 130 + name, 131 + style, 132 + value, 133 + valueOnly, 134 + }: SerializeOptions<ObjectSeparatorStyle> & { 135 + value: Record<string, unknown> | Date; 136 + valueOnly?: boolean; 137 + }) => { 138 + if (value instanceof Date) { 139 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 140 + } 141 + 142 + if (style !== 'deepObject' && !explode) { 143 + let values: string[] = []; 144 + Object.entries(value).forEach(([key, v]) => { 145 + values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]; 146 + }); 147 + const joinedValues = values.join(','); 148 + switch (style) { 149 + case 'form': 150 + return `${name}=${joinedValues}`; 151 + case 'label': 152 + return `.${joinedValues}`; 153 + case 'matrix': 154 + return `;${name}=${joinedValues}`; 155 + default: 156 + return joinedValues; 157 + } 158 + } 159 + 160 + const separator = separatorObjectExplode(style); 161 + const joinedValues = Object.entries(value) 162 + .map(([key, v]) => 163 + serializePrimitiveParam({ 164 + allowReserved, 165 + name: style === 'deepObject' ? `${name}[${key}]` : key, 166 + value: v as string, 167 + }), 168 + ) 169 + .join(separator); 170 + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 171 + };
+117
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/queryKeySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * JSON-friendly union that mirrors what Pinia Colada can hash. 5 + */ 6 + export type JsonValue = 7 + | null 8 + | string 9 + | number 10 + | boolean 11 + | JsonValue[] 12 + | { [key: string]: JsonValue }; 13 + 14 + /** 15 + * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 + */ 17 + export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 19 + return undefined; 20 + } 21 + if (typeof value === 'bigint') { 22 + return value.toString(); 23 + } 24 + if (value instanceof Date) { 25 + return value.toISOString(); 26 + } 27 + return value; 28 + }; 29 + 30 + /** 31 + * Safely stringifies a value and parses it back into a JsonValue. 32 + */ 33 + export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 34 + try { 35 + const json = JSON.stringify(input, queryKeyJsonReplacer); 36 + if (json === undefined) { 37 + return undefined; 38 + } 39 + return JSON.parse(json) as JsonValue; 40 + } catch { 41 + return undefined; 42 + } 43 + }; 44 + 45 + /** 46 + * Detects plain objects (including objects with a null prototype). 47 + */ 48 + const isPlainObject = (value: unknown): value is Record<string, unknown> => { 49 + if (value === null || typeof value !== 'object') { 50 + return false; 51 + } 52 + const prototype = Object.getPrototypeOf(value as object); 53 + return prototype === Object.prototype || prototype === null; 54 + }; 55 + 56 + /** 57 + * Turns URLSearchParams into a sorted JSON object for deterministic keys. 58 + */ 59 + const serializeSearchParams = (params: URLSearchParams): JsonValue => { 60 + const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b)); 61 + const result: Record<string, JsonValue> = {}; 62 + 63 + for (const [key, value] of entries) { 64 + const existing = result[key]; 65 + if (existing === undefined) { 66 + result[key] = value; 67 + continue; 68 + } 69 + 70 + if (Array.isArray(existing)) { 71 + (existing as string[]).push(value); 72 + } else { 73 + result[key] = [existing, value]; 74 + } 75 + } 76 + 77 + return result; 78 + }; 79 + 80 + /** 81 + * Normalizes any accepted value into a JSON-friendly shape for query keys. 82 + */ 83 + export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => { 84 + if (value === null) { 85 + return null; 86 + } 87 + 88 + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 89 + return value; 90 + } 91 + 92 + if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 93 + return undefined; 94 + } 95 + 96 + if (typeof value === 'bigint') { 97 + return value.toString(); 98 + } 99 + 100 + if (value instanceof Date) { 101 + return value.toISOString(); 102 + } 103 + 104 + if (Array.isArray(value)) { 105 + return stringifyToJsonValue(value); 106 + } 107 + 108 + if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) { 109 + return serializeSearchParams(value); 110 + } 111 + 112 + if (isPlainObject(value)) { 113 + return stringifyToJsonValue(value); 114 + } 115 + 116 + return undefined; 117 + };
+243
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & 6 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 7 + /** 8 + * Fetch API implementation. You can use this option to provide a custom 9 + * fetch instance. 10 + * 11 + * @default globalThis.fetch 12 + */ 13 + fetch?: typeof fetch; 14 + /** 15 + * Implementing clients can call request interceptors inside this hook. 16 + */ 17 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 18 + /** 19 + * Callback invoked when a network or parsing error occurs during streaming. 20 + * 21 + * This option applies only if the endpoint returns a stream of events. 22 + * 23 + * @param error The error that occurred. 24 + */ 25 + onSseError?: (error: unknown) => void; 26 + /** 27 + * Callback invoked when an event is streamed from the server. 28 + * 29 + * This option applies only if the endpoint returns a stream of events. 30 + * 31 + * @param event Event streamed from the server. 32 + * @returns Nothing (void). 33 + */ 34 + onSseEvent?: (event: StreamEvent<TData>) => void; 35 + serializedBody?: RequestInit['body']; 36 + /** 37 + * Default retry delay in milliseconds. 38 + * 39 + * This option applies only if the endpoint returns a stream of events. 40 + * 41 + * @default 3000 42 + */ 43 + sseDefaultRetryDelay?: number; 44 + /** 45 + * Maximum number of retry attempts before giving up. 46 + */ 47 + sseMaxRetryAttempts?: number; 48 + /** 49 + * Maximum retry delay in milliseconds. 50 + * 51 + * Applies only when exponential backoff is used. 52 + * 53 + * This option applies only if the endpoint returns a stream of events. 54 + * 55 + * @default 30000 56 + */ 57 + sseMaxRetryDelay?: number; 58 + /** 59 + * Optional sleep function for retry backoff. 60 + * 61 + * Defaults to using `setTimeout`. 62 + */ 63 + sseSleepFn?: (ms: number) => Promise<void>; 64 + url: string; 65 + }; 66 + 67 + export interface StreamEvent<TData = unknown> { 68 + data: TData; 69 + event?: string; 70 + id?: string; 71 + retry?: number; 72 + } 73 + 74 + export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { 75 + stream: AsyncGenerator< 76 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 77 + TReturn, 78 + TNext 79 + >; 80 + }; 81 + 82 + export const createSseClient = <TData = unknown>({ 83 + onRequest, 84 + onSseError, 85 + onSseEvent, 86 + responseTransformer, 87 + responseValidator, 88 + sseDefaultRetryDelay, 89 + sseMaxRetryAttempts, 90 + sseMaxRetryDelay, 91 + sseSleepFn, 92 + url, 93 + ...options 94 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 95 + let lastEventId: string | undefined; 96 + 97 + const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 98 + 99 + const createStream = async function* () { 100 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 101 + let attempt = 0; 102 + const signal = options.signal ?? new AbortController().signal; 103 + 104 + while (true) { 105 + if (signal.aborted) break; 106 + 107 + attempt++; 108 + 109 + const headers = 110 + options.headers instanceof Headers 111 + ? options.headers 112 + : new Headers(options.headers as Record<string, string> | undefined); 113 + 114 + if (lastEventId !== undefined) { 115 + headers.set('Last-Event-ID', lastEventId); 116 + } 117 + 118 + try { 119 + const requestInit: RequestInit = { 120 + redirect: 'follow', 121 + ...options, 122 + body: options.serializedBody, 123 + headers, 124 + signal, 125 + }; 126 + let request = new Request(url, requestInit); 127 + if (onRequest) { 128 + request = await onRequest(url, requestInit); 129 + } 130 + // fetch must be assigned here, otherwise it would throw the error: 131 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 132 + const _fetch = options.fetch ?? globalThis.fetch; 133 + const response = await _fetch(request); 134 + 135 + if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`); 136 + 137 + if (!response.body) throw new Error('No body in SSE response'); 138 + 139 + const reader = response.body.pipeThrough(new TextDecoderStream()).getReader(); 140 + 141 + let buffer = ''; 142 + 143 + const abortHandler = () => { 144 + try { 145 + reader.cancel(); 146 + } catch { 147 + // noop 148 + } 149 + }; 150 + 151 + signal.addEventListener('abort', abortHandler); 152 + 153 + try { 154 + while (true) { 155 + const { done, value } = await reader.read(); 156 + if (done) break; 157 + buffer += value; 158 + // Normalize line endings: CRLF -> LF, then CR -> LF 159 + buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 160 + 161 + const chunks = buffer.split('\n\n'); 162 + buffer = chunks.pop() ?? ''; 163 + 164 + for (const chunk of chunks) { 165 + const lines = chunk.split('\n'); 166 + const dataLines: Array<string> = []; 167 + let eventName: string | undefined; 168 + 169 + for (const line of lines) { 170 + if (line.startsWith('data:')) { 171 + dataLines.push(line.replace(/^data:\s*/, '')); 172 + } else if (line.startsWith('event:')) { 173 + eventName = line.replace(/^event:\s*/, ''); 174 + } else if (line.startsWith('id:')) { 175 + lastEventId = line.replace(/^id:\s*/, ''); 176 + } else if (line.startsWith('retry:')) { 177 + const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10); 178 + if (!Number.isNaN(parsed)) { 179 + retryDelay = parsed; 180 + } 181 + } 182 + } 183 + 184 + let data: unknown; 185 + let parsedJson = false; 186 + 187 + if (dataLines.length) { 188 + const rawData = dataLines.join('\n'); 189 + try { 190 + data = JSON.parse(rawData); 191 + parsedJson = true; 192 + } catch { 193 + data = rawData; 194 + } 195 + } 196 + 197 + if (parsedJson) { 198 + if (responseValidator) { 199 + await responseValidator(data); 200 + } 201 + 202 + if (responseTransformer) { 203 + data = await responseTransformer(data); 204 + } 205 + } 206 + 207 + onSseEvent?.({ 208 + data, 209 + event: eventName, 210 + id: lastEventId, 211 + retry: retryDelay, 212 + }); 213 + 214 + if (dataLines.length) { 215 + yield data as any; 216 + } 217 + } 218 + } 219 + } finally { 220 + signal.removeEventListener('abort', abortHandler); 221 + reader.releaseLock(); 222 + } 223 + 224 + break; // exit loop on normal completion 225 + } catch (error) { 226 + // connection failed or aborted; retry after delay 227 + onSseError?.(error); 228 + 229 + if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) { 230 + break; // stop after firing error 231 + } 232 + 233 + // exponential backoff: double retry each attempt, cap at 30s 234 + const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000); 235 + await sleep(backoff); 236 + } 237 + } 238 + }; 239 + 240 + const stream = createStream(); 241 + 242 + return { stream }; 243 + };
+104
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen'; 5 + 6 + export type HttpMethod = 7 + | 'connect' 8 + | 'delete' 9 + | 'get' 10 + | 'head' 11 + | 'options' 12 + | 'patch' 13 + | 'post' 14 + | 'put' 15 + | 'trace'; 16 + 17 + export type Client< 18 + RequestFn = never, 19 + Config = unknown, 20 + MethodFn = never, 21 + BuildUrlFn = never, 22 + SseFn = never, 23 + > = { 24 + /** 25 + * Returns the final request URL. 26 + */ 27 + buildUrl: BuildUrlFn; 28 + getConfig: () => Config; 29 + request: RequestFn; 30 + setConfig: (config: Config) => Config; 31 + } & { 32 + [K in HttpMethod]: MethodFn; 33 + } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } }); 34 + 35 + export interface Config { 36 + /** 37 + * Auth token or a function returning auth token. The resolved value will be 38 + * added to the request payload as defined by its `security` array. 39 + */ 40 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 41 + /** 42 + * A function for serializing request body parameter. By default, 43 + * {@link JSON.stringify()} will be used. 44 + */ 45 + bodySerializer?: BodySerializer | null; 46 + /** 47 + * An object containing any HTTP headers that you want to pre-populate your 48 + * `Headers` object with. 49 + * 50 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 51 + */ 52 + headers?: 53 + | RequestInit['headers'] 54 + | Record< 55 + string, 56 + string | number | boolean | (string | number | boolean)[] | null | undefined | unknown 57 + >; 58 + /** 59 + * The request method. 60 + * 61 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 62 + */ 63 + method?: Uppercase<HttpMethod>; 64 + /** 65 + * A function for serializing request query parameters. By default, arrays 66 + * will be exploded in form style, objects will be exploded in deepObject 67 + * style, and reserved characters are percent-encoded. 68 + * 69 + * This method will have no effect if the native `paramsSerializer()` Axios 70 + * API function is used. 71 + * 72 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 73 + */ 74 + querySerializer?: QuerySerializer | QuerySerializerOptions; 75 + /** 76 + * A function validating request data. This is useful if you want to ensure 77 + * the request conforms to the desired shape, so it can be safely sent to 78 + * the server. 79 + */ 80 + requestValidator?: (data: unknown) => Promise<unknown>; 81 + /** 82 + * A function transforming response data before it's returned. This is useful 83 + * for post-processing data, e.g. converting ISO strings into Date objects. 84 + */ 85 + responseTransformer?: (data: unknown) => Promise<unknown>; 86 + /** 87 + * A function validating response data. This is useful if you want to ensure 88 + * the response conforms to the desired shape, so it can be safely passed to 89 + * the transformers and returned to the user. 90 + */ 91 + responseValidator?: (data: unknown) => Promise<unknown>; 92 + } 93 + 94 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 95 + ? true 96 + : [T] extends [never | undefined] 97 + ? [undefined] extends [T] 98 + ? false 99 + : true 100 + : false; 101 + 102 + export type OmitNever<T extends Record<string, unknown>> = { 103 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]; 104 + };
+140
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace(match, serializeArrayParam({ explode, name, style, value })); 48 + continue; 49 + } 50 + 51 + if (typeof value === 'object') { 52 + url = url.replace( 53 + match, 54 + serializeObjectParam({ 55 + explode, 56 + name, 57 + style, 58 + value: value as Record<string, unknown>, 59 + valueOnly: true, 60 + }), 61 + ); 62 + continue; 63 + } 64 + 65 + if (style === 'matrix') { 66 + url = url.replace( 67 + match, 68 + `;${serializePrimitiveParam({ 69 + name, 70 + value: value as string, 71 + })}`, 72 + ); 73 + continue; 74 + } 75 + 76 + const replaceValue = encodeURIComponent( 77 + style === 'label' ? `.${value as string}` : (value as string), 78 + ); 79 + url = url.replace(match, replaceValue); 80 + } 81 + } 82 + return url; 83 + }; 84 + 85 + export const getUrl = ({ 86 + baseUrl, 87 + path, 88 + query, 89 + querySerializer, 90 + url: _url, 91 + }: { 92 + baseUrl?: string; 93 + path?: Record<string, unknown>; 94 + query?: Record<string, unknown>; 95 + querySerializer: QuerySerializer; 96 + url: string; 97 + }) => { 98 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 99 + let url = (baseUrl ?? '') + pathUrl; 100 + if (path) { 101 + url = defaultPathSerializer({ path, url }); 102 + } 103 + let search = query ? querySerializer(query) : ''; 104 + if (search.startsWith('?')) { 105 + search = search.substring(1); 106 + } 107 + if (search) { 108 + url += `?${search}`; 109 + } 110 + return url; 111 + }; 112 + 113 + export function getValidRequestBody(options: { 114 + body?: unknown; 115 + bodySerializer?: BodySerializer | null; 116 + serializedBody?: unknown; 117 + }) { 118 + const hasBody = options.body !== undefined; 119 + const isSerializedBody = hasBody && options.bodySerializer; 120 + 121 + if (isSerializedBody) { 122 + if ('serializedBody' in options) { 123 + const hasSerializedBody = 124 + options.serializedBody !== undefined && options.serializedBody !== ''; 125 + 126 + return hasSerializedBody ? options.serializedBody : null; 127 + } 128 + 129 + // not all clients implement a serializedBody property (i.e. client-axios) 130 + return options.body !== '' ? options.body : null; 131 + } 132 + 133 + // plain/text body 134 + if (hasBody) { 135 + return options.body; 136 + } 137 + 138 + // no body was provided 139 + return undefined; 140 + }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export { apiVVersionODataControllerCount, callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexParams, complexTypes, deleteCallWithoutParametersAndResponse, deleteFoo, deprecatedCall, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, export_, fileResponse, fooWow, getApiVbyApiVersionSimpleOperation, getCallWithOptionalParam, getCallWithoutParametersAndResponse, headCallWithoutParametersAndResponse, import_, multipartRequest, multipartResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, optionsCallWithoutParametersAndResponse, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionFormData, postApiVbyApiVersionRequestBody, postCallWithOptionalParam, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, putWithFormUrlEncoded, testErrorCode, types, uploadFile } from './sdk.gen'; 4 + export type { _3eNum1Период, _400, AdditionalPropertiesIntegerIssue, AdditionalPropertiesUnknownIssue, AdditionalPropertiesUnknownIssue2, AdditionalPropertiesUnknownIssue3, AdditionalPropertiesUnknownIssueWritable, AnyOfAnyAndNull, AnyOfArrays, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountResponses, ArrayWithAnyOfProperties, ArrayWithArray, ArrayWithBooleans, ArrayWithNumbers, ArrayWithProperties, ArrayWithReferences, ArrayWithStrings, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponse, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesError, CallWithResponsesErrors, CallWithResponsesResponse, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CamelCaseCommentWithBreaks, CharactersInDescription, ClientOptions, CollectionFormatData, CommentWithBackticks, CommentWithBackticksAndQuotes, CommentWithBreaks, CommentWithExpressionPlaceholders, CommentWithQuotes, CommentWithReservedCharacters, CommentWithSlashes, ComplexParamsData, ComplexParamsResponse, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponse, ComplexTypesResponses, CompositionBaseModel, CompositionExtendedModel, CompositionWithAllOfAndNullable, CompositionWithAnyOf, CompositionWithAnyOfAndNullable, CompositionWithAnyOfAnonymous, CompositionWithNestedAnyAndTypeNull, CompositionWithNestedAnyOfAndNull, CompositionWithOneOf, CompositionWithOneOfAndComplexArrayDictionary, CompositionWithOneOfAndNullable, CompositionWithOneOfAndProperties, CompositionWithOneOfAndSimpleArrayDictionary, CompositionWithOneOfAndSimpleDictionary, CompositionWithOneOfAnonymous, CompositionWithOneOfDiscriminator, ConstValue, Default, DeleteCallWithoutParametersAndResponseData, DeleteFooData, DeleteFooData2, DeleteFooData3, DeprecatedCallData, DeprecatedModel, DictionaryWithArray, DictionaryWithDictionary, DictionaryWithProperties, DictionaryWithPropertiesAndAdditionalProperties, DictionaryWithReference, DictionaryWithString, DummyAData, DummyAResponse, DummyAResponses, DummyBData, DummyBResponse, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, EnumFromDescription, EnumWithExtensions, EnumWithNumbers, EnumWithReplacedCharacters, EnumWithStrings, EnumWithXEnumNames, ExportData, ExternalRefA, ExternalRefB, ExternalSharedModel, File, FileResponseData, FileResponseResponse, FileResponseResponses, FileWritable, FooWowData, FooWowResponses, FreeFormObjectWithAdditionalPropertiesEqEmptyObject, FreeFormObjectWithAdditionalPropertiesEqTrue, FreeFormObjectWithoutAdditionalProperties, GenericSchemaDuplicateIssue1SystemBoolean, GenericSchemaDuplicateIssue1SystemBooleanWritable, GenericSchemaDuplicateIssue1SystemString, GenericSchemaDuplicateIssue1SystemStringWritable, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, Import, ImportData, ImportResponse, ImportResponses, IoK8sApimachineryPkgApisMetaV1DeleteOptions, IoK8sApimachineryPkgApisMetaV1Preconditions, ModelCircle, ModelFromZendesk, ModelSquare, ModelThatExtends, ModelThatExtendsExtends, ModelWithAdditionalPropertiesEqTrue, ModelWithAdditionalPropertiesRef, ModelWithAnyOfConstantSizeArray, ModelWithAnyOfConstantSizeArrayAndIntersect, ModelWithAnyOfConstantSizeArrayNullable, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable, ModelWithArray, ModelWithArrayReadOnlyAndWriteOnly, ModelWithArrayReadOnlyAndWriteOnlyWritable, ModelWithBackticksInDescription, ModelWithBoolean, ModelWithCircularReference, ModelWithConst, ModelWithConstantSizeArray, ModelWithDictionary, ModelWithDuplicateImports, ModelWithDuplicateProperties, ModelWithEnum, ModelWithEnumFromDescription, ModelWithEnumWithHyphen, ModelWithInteger, ModelWithNestedArrayEnums, ModelWithNestedArrayEnumsData, ModelWithNestedArrayEnumsDataBar, ModelWithNestedArrayEnumsDataFoo, ModelWithNestedCompositionEnums, ModelWithNestedEnums, ModelWithNestedProperties, ModelWithNullableObject, ModelWithNullableString, ModelWithNumericEnumUnion, ModelWithOneOfAndProperties, ModelWithOneOfEnum, ModelWithOrderedProperties, ModelWithPattern, ModelWithPatternWritable, ModelWithPrefixItemsConstantSizeArray, ModelWithProperties, ModelWithPropertiesWritable, ModelWithReadOnlyAndWriteOnly, ModelWithReadOnlyAndWriteOnlyWritable, ModelWithReference, ModelWithReferenceWritable, ModelWithString, ModelWithStringError, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, MultipartResponseResponses, NestedAnyOfArraysNullable, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Responses, NonAsciiStringæøåÆøÅöôêÊ字符串, NullableObject, OneOfAllOfIssue, OneOfAllOfIssueWritable, OptionsCallWithoutParametersAndResponseData, Pageable, ParameterSimpleParameterUnused, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PostServiceWithEmptyTagResponse, PostServiceWithEmptyTagResponse2, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, SchemaWithFormRestrictedKeys, SimpleBoolean, SimpleFile, SimpleFormData, SimpleInteger, SimpleParameter, SimpleReference, SimpleRequestBody, SimpleString, SimpleStringWithPattern, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponse, TypesResponses, UploadFileData, UploadFileResponse, UploadFileResponses, XFooBar } from './types.gen';
+206
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Client, formDataBodySerializer, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client'; 4 + import { client } from './client.gen'; 5 + import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponses, DummyBData, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ImportData, ImportResponses, MultipartRequestData, MultipartResponseData, MultipartResponseResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponses, UploadFileData, UploadFileResponses } from './types.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 22 + 23 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => (options?.client ?? client).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 24 + 25 + export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => (options.client ?? client).post<ImportResponses, unknown, ThrowOnError>({ 26 + url: '/api/v{api-version}/no+tag', 27 + ...options, 28 + headers: { 29 + 'Content-Type': 'application/json', 30 + ...options.headers 31 + } 32 + }); 33 + 34 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => (options?.client ?? client).put<FooWowResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 35 + 36 + export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => (options?.client ?? client).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple/$count', ...options }); 37 + 38 + export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => (options.client ?? client).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ url: '/api/v{api-version}/simple:operation', ...options }); 39 + 40 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 41 + 42 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 43 + 44 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).head<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 45 + 46 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).options<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 47 + 48 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).patch<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 49 + 50 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 51 + 52 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 53 + 54 + export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => (options.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); 55 + 56 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/descriptions', ...options }); 57 + 58 + /** 59 + * @deprecated 60 + */ 61 + export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/parameters/deprecated', ...options }); 62 + 63 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 64 + url: '/api/v{api-version}/parameters/{parameterPath}', 65 + ...options, 66 + headers: { 67 + 'Content-Type': 'application/json', 68 + ...options.headers 69 + } 70 + }); 71 + 72 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 73 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 74 + ...options, 75 + headers: { 76 + 'Content-Type': 'application/json', 77 + ...options.headers 78 + } 79 + }); 80 + 81 + export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ 82 + url: '/api/v{api-version}/parameters', 83 + ...options, 84 + headers: { 85 + 'Content-Type': 'application/json', 86 + ...options.headers 87 + } 88 + }); 89 + 90 + export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 91 + url: '/api/v{api-version}/parameters', 92 + ...options, 93 + headers: { 94 + 'Content-Type': 'application/json', 95 + ...options.headers 96 + } 97 + }); 98 + 99 + export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 100 + url: '/api/v{api-version}/requestBody', 101 + ...options, 102 + headers: { 103 + 'Content-Type': 'application/json', 104 + ...options?.headers 105 + } 106 + }); 107 + 108 + export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 109 + ...formDataBodySerializer, 110 + url: '/api/v{api-version}/formData', 111 + ...options, 112 + headers: { 113 + 'Content-Type': null, 114 + ...options?.headers 115 + } 116 + }); 117 + 118 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 119 + 120 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 121 + 122 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 123 + 124 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 125 + 126 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 127 + 128 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 129 + 130 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 131 + 132 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no-content', ...options }); 133 + 134 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); 135 + 136 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => (options?.client ?? client).get<DummyAResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/a', ...options }); 137 + 138 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => (options?.client ?? client).get<DummyBResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/b', ...options }); 139 + 140 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 141 + 142 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => (options?.client ?? client).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 143 + 144 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => (options?.client ?? client).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 145 + 146 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/collectionFormat', ...options }); 147 + 148 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => (options.client ?? client).get<TypesResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/types', ...options }); 149 + 150 + export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => (options.client ?? client).post<UploadFileResponses, unknown, ThrowOnError>({ 151 + ...urlSearchParamsBodySerializer, 152 + url: '/api/v{api-version}/upload', 153 + ...options, 154 + headers: { 155 + 'Content-Type': 'application/x-www-form-urlencoded', 156 + ...options.headers 157 + } 158 + }); 159 + 160 + export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => (options.client ?? client).get<FileResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/file/{id}', ...options }); 161 + 162 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => (options.client ?? client).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 163 + querySerializer: { parameters: { parameterObject: { object: { style: 'form' } } } }, 164 + url: '/api/v{api-version}/complex', 165 + ...options 166 + }); 167 + 168 + export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => (options?.client ?? client).get<MultipartResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multipart', ...options }); 169 + 170 + export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 171 + ...formDataBodySerializer, 172 + url: '/api/v{api-version}/multipart', 173 + ...options, 174 + headers: { 175 + 'Content-Type': null, 176 + ...options?.headers 177 + } 178 + }); 179 + 180 + export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => (options.client ?? client).put<ComplexParamsResponses, unknown, ThrowOnError>({ 181 + url: '/api/v{api-version}/complex/{id}', 182 + ...options, 183 + headers: { 184 + 'Content-Type': 'application/json-patch+json', 185 + ...options.headers 186 + } 187 + }); 188 + 189 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => (options?.client ?? client).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ url: '/api/v{api-version}/header', ...options }); 190 + 191 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => (options.client ?? client).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ url: '/api/v{api-version}/error', ...options }); 192 + 193 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => (options.client ?? client).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); 194 + 195 + /** 196 + * Login User 197 + */ 198 + export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ 199 + ...urlSearchParamsBodySerializer, 200 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 201 + ...options, 202 + headers: { 203 + 'Content-Type': 'application/x-www-form-urlencoded', 204 + ...options.headers 205 + } 206 + });
+2100
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/useMutation/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type ClientOptions = { 4 + baseUrl: 'http://localhost:3000/base' | (string & {}); 5 + }; 6 + 7 + /** 8 + * Model with number-only name 9 + */ 10 + export type _400 = string; 11 + 12 + /** 13 + * External ref to shared model (A) 14 + */ 15 + export type ExternalRefA = ExternalSharedModel; 16 + 17 + /** 18 + * External ref to shared model (B) 19 + */ 20 + export type ExternalRefB = ExternalSharedModel; 21 + 22 + /** 23 + * Testing multiline comments in string: First line 24 + * Second line 25 + * 26 + * Fourth line 27 + */ 28 + export type CamelCaseCommentWithBreaks = number; 29 + 30 + /** 31 + * Testing multiline comments in string: First line 32 + * Second line 33 + * 34 + * Fourth line 35 + */ 36 + export type CommentWithBreaks = number; 37 + 38 + /** 39 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 40 + */ 41 + export type CommentWithBackticks = number; 42 + 43 + /** 44 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 45 + */ 46 + export type CommentWithBackticksAndQuotes = number; 47 + 48 + /** 49 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 50 + */ 51 + export type CommentWithSlashes = number; 52 + 53 + /** 54 + * Testing expression placeholders in string: ${expression} should work 55 + */ 56 + export type CommentWithExpressionPlaceholders = number; 57 + 58 + /** 59 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 60 + */ 61 + export type CommentWithQuotes = number; 62 + 63 + /** 64 + * Testing reserved characters in string: * inline * and ** inline ** should work 65 + */ 66 + export type CommentWithReservedCharacters = number; 67 + 68 + /** 69 + * This is a simple number 70 + */ 71 + export type SimpleInteger = number; 72 + 73 + /** 74 + * This is a simple boolean 75 + */ 76 + export type SimpleBoolean = boolean; 77 + 78 + /** 79 + * This is a simple string 80 + */ 81 + export type SimpleString = string; 82 + 83 + /** 84 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 85 + */ 86 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 87 + 88 + /** 89 + * This is a simple file 90 + */ 91 + export type SimpleFile = Blob | File; 92 + 93 + /** 94 + * This is a simple reference 95 + */ 96 + export type SimpleReference = ModelWithString; 97 + 98 + /** 99 + * This is a simple string 100 + */ 101 + export type SimpleStringWithPattern = string | null; 102 + 103 + /** 104 + * This is a simple enum with strings 105 + */ 106 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | '\'Single Quote\'' | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 107 + 108 + export type EnumWithReplacedCharacters = '\'Single Quote\'' | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 109 + 110 + /** 111 + * This is a simple enum with numbers 112 + */ 113 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 114 + 115 + /** 116 + * Success=1,Warning=2,Error=3 117 + */ 118 + export type EnumFromDescription = number; 119 + 120 + /** 121 + * This is a simple enum with numbers 122 + */ 123 + export type EnumWithExtensions = 200 | 400 | 500; 124 + 125 + export type EnumWithXEnumNames = 0 | 1 | 2; 126 + 127 + /** 128 + * This is a simple array with numbers 129 + */ 130 + export type ArrayWithNumbers = Array<number>; 131 + 132 + /** 133 + * This is a simple array with booleans 134 + */ 135 + export type ArrayWithBooleans = Array<boolean>; 136 + 137 + /** 138 + * This is a simple array with strings 139 + */ 140 + export type ArrayWithStrings = Array<string>; 141 + 142 + /** 143 + * This is a simple array with references 144 + */ 145 + export type ArrayWithReferences = Array<ModelWithString>; 146 + 147 + /** 148 + * This is a simple array containing an array 149 + */ 150 + export type ArrayWithArray = Array<Array<ModelWithString>>; 151 + 152 + /** 153 + * This is a simple array with properties 154 + */ 155 + export type ArrayWithProperties = Array<{ 156 + '16x16'?: CamelCaseCommentWithBreaks; 157 + bar?: string; 158 + }>; 159 + 160 + /** 161 + * This is a simple array with any of properties 162 + */ 163 + export type ArrayWithAnyOfProperties = Array<{ 164 + foo?: string; 165 + } | { 166 + bar?: string; 167 + }>; 168 + 169 + export type AnyOfAnyAndNull = { 170 + data?: unknown | null; 171 + }; 172 + 173 + /** 174 + * This is a simple array with any of properties 175 + */ 176 + export type AnyOfArrays = { 177 + results?: Array<{ 178 + foo?: string; 179 + } | { 180 + bar?: string; 181 + }>; 182 + }; 183 + 184 + /** 185 + * This is a string dictionary 186 + */ 187 + export type DictionaryWithString = { 188 + [key: string]: string; 189 + }; 190 + 191 + export type DictionaryWithPropertiesAndAdditionalProperties = { 192 + foo?: number; 193 + bar?: boolean; 194 + [key: string]: string | number | boolean | undefined; 195 + }; 196 + 197 + /** 198 + * This is a string reference 199 + */ 200 + export type DictionaryWithReference = { 201 + [key: string]: ModelWithString; 202 + }; 203 + 204 + /** 205 + * This is a complex dictionary 206 + */ 207 + export type DictionaryWithArray = { 208 + [key: string]: Array<ModelWithString>; 209 + }; 210 + 211 + /** 212 + * This is a string dictionary 213 + */ 214 + export type DictionaryWithDictionary = { 215 + [key: string]: { 216 + [key: string]: string; 217 + }; 218 + }; 219 + 220 + /** 221 + * This is a complex dictionary 222 + */ 223 + export type DictionaryWithProperties = { 224 + [key: string]: { 225 + foo?: string; 226 + bar?: string; 227 + }; 228 + }; 229 + 230 + /** 231 + * This is a model with one number property 232 + */ 233 + export type ModelWithInteger = { 234 + /** 235 + * This is a simple number property 236 + */ 237 + prop?: number; 238 + }; 239 + 240 + /** 241 + * This is a model with one boolean property 242 + */ 243 + export type ModelWithBoolean = { 244 + /** 245 + * This is a simple boolean property 246 + */ 247 + prop?: boolean; 248 + }; 249 + 250 + /** 251 + * This is a model with one string property 252 + */ 253 + export type ModelWithString = { 254 + /** 255 + * This is a simple string property 256 + */ 257 + prop?: string; 258 + }; 259 + 260 + /** 261 + * This is a model with one string property 262 + */ 263 + export type ModelWithStringError = { 264 + /** 265 + * This is a simple string property 266 + */ 267 + prop?: string; 268 + }; 269 + 270 + /** 271 + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) 272 + */ 273 + export type ModelFromZendesk = string; 274 + 275 + /** 276 + * This is a model with one string property 277 + */ 278 + export type ModelWithNullableString = { 279 + /** 280 + * This is a simple string property 281 + */ 282 + nullableProp1?: string | null; 283 + /** 284 + * This is a simple string property 285 + */ 286 + nullableRequiredProp1: string | null; 287 + /** 288 + * This is a simple string property 289 + */ 290 + nullableProp2?: string | null; 291 + /** 292 + * This is a simple string property 293 + */ 294 + nullableRequiredProp2: string | null; 295 + /** 296 + * This is a simple enum with strings 297 + */ 298 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 299 + }; 300 + 301 + /** 302 + * This is a model with one enum 303 + */ 304 + export type ModelWithEnum = { 305 + /** 306 + * This is a simple enum with strings 307 + */ 308 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 309 + /** 310 + * These are the HTTP error code enums 311 + */ 312 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 313 + /** 314 + * Simple boolean enum 315 + */ 316 + bool?: true; 317 + }; 318 + 319 + /** 320 + * This is a model with one enum with escaped name 321 + */ 322 + export type ModelWithEnumWithHyphen = { 323 + /** 324 + * Foo-Bar-Baz-Qux 325 + */ 326 + 'foo-bar-baz-qux'?: '3.0'; 327 + }; 328 + 329 + /** 330 + * This is a model with one enum 331 + */ 332 + export type ModelWithEnumFromDescription = { 333 + /** 334 + * Success=1,Warning=2,Error=3 335 + */ 336 + test?: number; 337 + }; 338 + 339 + /** 340 + * This is a model with nested enums 341 + */ 342 + export type ModelWithNestedEnums = { 343 + dictionaryWithEnum?: { 344 + [key: string]: 'Success' | 'Warning' | 'Error'; 345 + }; 346 + dictionaryWithEnumFromDescription?: { 347 + [key: string]: number; 348 + }; 349 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 350 + arrayWithDescription?: Array<number>; 351 + /** 352 + * This is a simple enum with strings 353 + */ 354 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 355 + }; 356 + 357 + /** 358 + * This is a model with one property containing a reference 359 + */ 360 + export type ModelWithReference = { 361 + prop?: ModelWithProperties; 362 + }; 363 + 364 + /** 365 + * This is a model with one property containing an array 366 + */ 367 + export type ModelWithArrayReadOnlyAndWriteOnly = { 368 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 369 + propWithFile?: Array<Blob | File>; 370 + propWithNumber?: Array<number>; 371 + }; 372 + 373 + /** 374 + * This is a model with one property containing an array 375 + */ 376 + export type ModelWithArray = { 377 + prop?: Array<ModelWithString>; 378 + propWithFile?: Array<Blob | File>; 379 + propWithNumber?: Array<number>; 380 + }; 381 + 382 + /** 383 + * This is a model with one property containing a dictionary 384 + */ 385 + export type ModelWithDictionary = { 386 + prop?: { 387 + [key: string]: string; 388 + }; 389 + }; 390 + 391 + /** 392 + * This is a deprecated model with a deprecated property 393 + * 394 + * @deprecated 395 + */ 396 + export type DeprecatedModel = { 397 + /** 398 + * This is a deprecated property 399 + * 400 + * @deprecated 401 + */ 402 + prop?: string; 403 + }; 404 + 405 + /** 406 + * This is a model with one property containing a circular reference 407 + */ 408 + export type ModelWithCircularReference = { 409 + prop?: ModelWithCircularReference; 410 + }; 411 + 412 + /** 413 + * This is a model with one property with a 'one of' relationship 414 + */ 415 + export type CompositionWithOneOf = { 416 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 417 + }; 418 + 419 + /** 420 + * This is a model with one property with a 'one of' relationship where the options are not $ref 421 + */ 422 + export type CompositionWithOneOfAnonymous = { 423 + propA?: { 424 + propA?: string; 425 + } | string | number; 426 + }; 427 + 428 + /** 429 + * Circle 430 + */ 431 + export type ModelCircle = { 432 + kind: string; 433 + radius?: number; 434 + }; 435 + 436 + /** 437 + * Square 438 + */ 439 + export type ModelSquare = { 440 + kind: string; 441 + sideLength?: number; 442 + }; 443 + 444 + /** 445 + * This is a model with one property with a 'one of' relationship where the options are not $ref 446 + */ 447 + export type CompositionWithOneOfDiscriminator = ({ 448 + kind: 'circle'; 449 + } & ModelCircle) | ({ 450 + kind: 'square'; 451 + } & ModelSquare); 452 + 453 + /** 454 + * This is a model with one property with a 'any of' relationship 455 + */ 456 + export type CompositionWithAnyOf = { 457 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 458 + }; 459 + 460 + /** 461 + * This is a model with one property with a 'any of' relationship where the options are not $ref 462 + */ 463 + export type CompositionWithAnyOfAnonymous = { 464 + propA?: { 465 + propA?: string; 466 + } | string | number; 467 + }; 468 + 469 + /** 470 + * This is a model with nested 'any of' property with a type null 471 + */ 472 + export type CompositionWithNestedAnyAndTypeNull = { 473 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 474 + }; 475 + 476 + export type _3eNum1Период = 'Bird' | 'Dog'; 477 + 478 + export type ConstValue = 'ConstValue'; 479 + 480 + /** 481 + * This is a model with one property with a 'any of' relationship where the options are not $ref 482 + */ 483 + export type CompositionWithNestedAnyOfAndNull = { 484 + /** 485 + * Scopes 486 + */ 487 + propA?: Array<_3eNum1Период | ConstValue> | null; 488 + }; 489 + 490 + /** 491 + * This is a model with one property with a 'one of' relationship 492 + */ 493 + export type CompositionWithOneOfAndNullable = { 494 + propA?: { 495 + boolean?: boolean; 496 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 497 + }; 498 + 499 + /** 500 + * This is a model that contains a simple dictionary within composition 501 + */ 502 + export type CompositionWithOneOfAndSimpleDictionary = { 503 + propA?: boolean | { 504 + [key: string]: number; 505 + }; 506 + }; 507 + 508 + /** 509 + * This is a model that contains a dictionary of simple arrays within composition 510 + */ 511 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 512 + propA?: boolean | { 513 + [key: string]: Array<boolean>; 514 + }; 515 + }; 516 + 517 + /** 518 + * This is a model that contains a dictionary of complex arrays (composited) within composition 519 + */ 520 + export type CompositionWithOneOfAndComplexArrayDictionary = { 521 + propA?: boolean | { 522 + [key: string]: Array<number | string>; 523 + }; 524 + }; 525 + 526 + /** 527 + * This is a model with one property with a 'all of' relationship 528 + */ 529 + export type CompositionWithAllOfAndNullable = { 530 + propA?: ({ 531 + boolean?: boolean; 532 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 533 + }; 534 + 535 + /** 536 + * This is a model with one property with a 'any of' relationship 537 + */ 538 + export type CompositionWithAnyOfAndNullable = { 539 + propA?: { 540 + boolean?: boolean; 541 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 542 + }; 543 + 544 + /** 545 + * This is a base model with two simple optional properties 546 + */ 547 + export type CompositionBaseModel = { 548 + firstName?: string; 549 + lastname?: string; 550 + }; 551 + 552 + /** 553 + * This is a model that extends the base model 554 + */ 555 + export type CompositionExtendedModel = CompositionBaseModel & { 556 + age: number; 557 + firstName: string; 558 + lastname: string; 559 + }; 560 + 561 + /** 562 + * This is a model with one nested property 563 + */ 564 + export type ModelWithProperties = { 565 + required: string; 566 + readonly requiredAndReadOnly: string; 567 + requiredAndNullable: string | null; 568 + string?: string; 569 + number?: number; 570 + boolean?: boolean; 571 + reference?: ModelWithString; 572 + 'property with space'?: string; 573 + default?: string; 574 + try?: string; 575 + readonly '@namespace.string'?: string; 576 + readonly '@namespace.integer'?: number; 577 + }; 578 + 579 + /** 580 + * This is a model with one nested property 581 + */ 582 + export type ModelWithNestedProperties = { 583 + readonly first: { 584 + readonly second: { 585 + readonly third: string | null; 586 + } | null; 587 + } | null; 588 + }; 589 + 590 + /** 591 + * This is a model with duplicated properties 592 + */ 593 + export type ModelWithDuplicateProperties = { 594 + prop?: ModelWithString; 595 + }; 596 + 597 + /** 598 + * This is a model with ordered properties 599 + */ 600 + export type ModelWithOrderedProperties = { 601 + zebra?: string; 602 + apple?: string; 603 + hawaii?: string; 604 + }; 605 + 606 + /** 607 + * This is a model with duplicated imports 608 + */ 609 + export type ModelWithDuplicateImports = { 610 + propA?: ModelWithString; 611 + propB?: ModelWithString; 612 + propC?: ModelWithString; 613 + }; 614 + 615 + /** 616 + * This is a model that extends another model 617 + */ 618 + export type ModelThatExtends = ModelWithString & { 619 + propExtendsA?: string; 620 + propExtendsB?: ModelWithString; 621 + }; 622 + 623 + /** 624 + * This is a model that extends another model 625 + */ 626 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 627 + propExtendsC?: string; 628 + propExtendsD?: ModelWithString; 629 + }; 630 + 631 + /** 632 + * This is a model that contains a some patterns 633 + */ 634 + export type ModelWithPattern = { 635 + key: string; 636 + name: string; 637 + readonly enabled?: boolean; 638 + readonly modified?: string; 639 + id?: string; 640 + text?: string; 641 + patternWithSingleQuotes?: string; 642 + patternWithNewline?: string; 643 + patternWithBacktick?: string; 644 + patternWithUnicode?: string; 645 + }; 646 + 647 + export type File = { 648 + /** 649 + * Id 650 + */ 651 + readonly id?: string; 652 + /** 653 + * Updated at 654 + */ 655 + readonly updated_at?: string; 656 + /** 657 + * Created at 658 + */ 659 + readonly created_at?: string; 660 + /** 661 + * Mime 662 + */ 663 + mime: string; 664 + /** 665 + * File 666 + */ 667 + readonly file?: string; 668 + }; 669 + 670 + export type Default = { 671 + name?: string; 672 + }; 673 + 674 + export type Pageable = { 675 + page?: number; 676 + size?: number; 677 + sort?: Array<string>; 678 + }; 679 + 680 + /** 681 + * This is a free-form object without additionalProperties. 682 + */ 683 + export type FreeFormObjectWithoutAdditionalProperties = { 684 + [key: string]: unknown; 685 + }; 686 + 687 + /** 688 + * This is a free-form object with additionalProperties: true. 689 + */ 690 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 691 + [key: string]: unknown; 692 + }; 693 + 694 + /** 695 + * This is a free-form object with additionalProperties: {}. 696 + */ 697 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 698 + [key: string]: unknown; 699 + }; 700 + 701 + export type ModelWithConst = { 702 + String?: 'String'; 703 + number?: 0; 704 + null?: null; 705 + withType?: 'Some string'; 706 + }; 707 + 708 + /** 709 + * This is a model with one property and additionalProperties: true 710 + */ 711 + export type ModelWithAdditionalPropertiesEqTrue = { 712 + /** 713 + * This is a simple string property 714 + */ 715 + prop?: string; 716 + [key: string]: unknown; 717 + }; 718 + 719 + export type NestedAnyOfArraysNullable = { 720 + nullableArray?: Array<string | boolean> | null; 721 + }; 722 + 723 + export type CompositionWithOneOfAndProperties = ({ 724 + foo: SimpleParameter; 725 + } | { 726 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 727 + }) & { 728 + baz: number | null; 729 + qux: number; 730 + }; 731 + 732 + /** 733 + * An object that can be null 734 + */ 735 + export type NullableObject = { 736 + foo?: string; 737 + } | null; 738 + 739 + /** 740 + * Some % character 741 + */ 742 + export type CharactersInDescription = string; 743 + 744 + export type ModelWithNullableObject = { 745 + data?: NullableObject; 746 + }; 747 + 748 + /** 749 + * An object with additional properties that can be null (anyOf ref + null) 750 + */ 751 + export type ModelWithAdditionalPropertiesRef = { 752 + [key: string]: NullableObject | null; 753 + }; 754 + 755 + export type ModelWithOneOfEnum = { 756 + foo: 'Bar'; 757 + } | { 758 + foo: 'Baz'; 759 + } | { 760 + foo: 'Qux'; 761 + } | { 762 + content: string; 763 + foo: 'Quux'; 764 + } | { 765 + content: [ 766 + string, 767 + string 768 + ]; 769 + foo: 'Corge'; 770 + }; 771 + 772 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 773 + 774 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 775 + 776 + export type ModelWithNestedArrayEnumsData = { 777 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 778 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 779 + }; 780 + 781 + export type ModelWithNestedArrayEnums = { 782 + array_strings?: Array<string>; 783 + data?: ModelWithNestedArrayEnumsData; 784 + }; 785 + 786 + export type ModelWithNestedCompositionEnums = { 787 + foo?: ModelWithNestedArrayEnumsDataFoo; 788 + }; 789 + 790 + export type ModelWithReadOnlyAndWriteOnly = { 791 + foo: string; 792 + readonly bar: string; 793 + }; 794 + 795 + export type ModelWithConstantSizeArray = [ 796 + number, 797 + number 798 + ]; 799 + 800 + export type ModelWithAnyOfConstantSizeArray = [ 801 + number | string, 802 + number | string, 803 + number | string 804 + ]; 805 + 806 + export type ModelWithPrefixItemsConstantSizeArray = [ 807 + ModelWithInteger, 808 + number | string, 809 + string 810 + ]; 811 + 812 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 813 + number | null | string, 814 + number | null | string, 815 + number | null | string 816 + ]; 817 + 818 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 819 + number | Import, 820 + number | Import 821 + ]; 822 + 823 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 824 + number & string, 825 + number & string 826 + ]; 827 + 828 + export type ModelWithNumericEnumUnion = { 829 + /** 830 + * Период 831 + */ 832 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 833 + }; 834 + 835 + /** 836 + * Some description with `back ticks` 837 + */ 838 + export type ModelWithBackticksInDescription = { 839 + /** 840 + * The template `that` should be used for parsing and importing the contents of the CSV file. 841 + * 842 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 843 + * <pre> 844 + * [ 845 + * { 846 + * "resourceType": "Asset", 847 + * "identifier": { 848 + * "name": "${1}", 849 + * "domain": { 850 + * "name": "${2}", 851 + * "community": { 852 + * "name": "Some Community" 853 + * } 854 + * } 855 + * }, 856 + * "attributes" : { 857 + * "00000000-0000-0000-0000-000000003115" : [ { 858 + * "value" : "${3}" 859 + * } ], 860 + * "00000000-0000-0000-0000-000000000222" : [ { 861 + * "value" : "${4}" 862 + * } ] 863 + * } 864 + * } 865 + * ] 866 + * </pre> 867 + */ 868 + template?: string; 869 + }; 870 + 871 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 872 + baz: number | null; 873 + qux: number; 874 + }; 875 + 876 + /** 877 + * Model used to test deduplication strategy (unused) 878 + */ 879 + export type ParameterSimpleParameterUnused = string; 880 + 881 + /** 882 + * Model used to test deduplication strategy 883 + */ 884 + export type PostServiceWithEmptyTagResponse = string; 885 + 886 + /** 887 + * Model used to test deduplication strategy 888 + */ 889 + export type PostServiceWithEmptyTagResponse2 = string; 890 + 891 + /** 892 + * Model used to test deduplication strategy 893 + */ 894 + export type DeleteFooData = string; 895 + 896 + /** 897 + * Model used to test deduplication strategy 898 + */ 899 + export type DeleteFooData2 = string; 900 + 901 + /** 902 + * Model with restricted keyword name 903 + */ 904 + export type Import = string; 905 + 906 + export type SchemaWithFormRestrictedKeys = { 907 + description?: string; 908 + 'x-enum-descriptions'?: string; 909 + 'x-enum-varnames'?: string; 910 + 'x-enumNames'?: string; 911 + title?: string; 912 + object?: { 913 + description?: string; 914 + 'x-enum-descriptions'?: string; 915 + 'x-enum-varnames'?: string; 916 + 'x-enumNames'?: string; 917 + title?: string; 918 + }; 919 + array?: Array<{ 920 + description?: string; 921 + 'x-enum-descriptions'?: string; 922 + 'x-enum-varnames'?: string; 923 + 'x-enumNames'?: string; 924 + title?: string; 925 + }>; 926 + }; 927 + 928 + /** 929 + * This schema was giving PascalCase transformations a hard time 930 + */ 931 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 932 + /** 933 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 934 + */ 935 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 936 + }; 937 + 938 + /** 939 + * This schema was giving PascalCase transformations a hard time 940 + */ 941 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 942 + /** 943 + * Specifies the target ResourceVersion 944 + */ 945 + resourceVersion?: string; 946 + /** 947 + * Specifies the target UID. 948 + */ 949 + uid?: string; 950 + }; 951 + 952 + export type AdditionalPropertiesUnknownIssue = { 953 + [key: string]: string | number; 954 + }; 955 + 956 + export type AdditionalPropertiesUnknownIssue2 = { 957 + [key: string]: string | number; 958 + }; 959 + 960 + export type AdditionalPropertiesUnknownIssue3 = string & { 961 + entries: { 962 + [key: string]: AdditionalPropertiesUnknownIssue; 963 + }; 964 + }; 965 + 966 + export type AdditionalPropertiesIntegerIssue = { 967 + value: number; 968 + [key: string]: number; 969 + }; 970 + 971 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 972 + 973 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 974 + item?: boolean; 975 + error?: string | null; 976 + readonly hasError?: boolean; 977 + data?: { 978 + [key: string]: never; 979 + }; 980 + }; 981 + 982 + export type GenericSchemaDuplicateIssue1SystemString = { 983 + item?: string | null; 984 + error?: string | null; 985 + readonly hasError?: boolean; 986 + }; 987 + 988 + export type ExternalSharedModel = { 989 + id: string; 990 + name?: string; 991 + }; 992 + 993 + /** 994 + * This is a model with one property containing a reference 995 + */ 996 + export type ModelWithReferenceWritable = { 997 + prop?: ModelWithPropertiesWritable; 998 + }; 999 + 1000 + /** 1001 + * This is a model with one property containing an array 1002 + */ 1003 + export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { 1004 + prop?: Array<ModelWithReadOnlyAndWriteOnlyWritable>; 1005 + propWithFile?: Array<Blob | File>; 1006 + propWithNumber?: Array<number>; 1007 + }; 1008 + 1009 + /** 1010 + * This is a model with one nested property 1011 + */ 1012 + export type ModelWithPropertiesWritable = { 1013 + required: string; 1014 + requiredAndNullable: string | null; 1015 + string?: string; 1016 + number?: number; 1017 + boolean?: boolean; 1018 + reference?: ModelWithString; 1019 + 'property with space'?: string; 1020 + default?: string; 1021 + try?: string; 1022 + }; 1023 + 1024 + /** 1025 + * This is a model that contains a some patterns 1026 + */ 1027 + export type ModelWithPatternWritable = { 1028 + key: string; 1029 + name: string; 1030 + id?: string; 1031 + text?: string; 1032 + patternWithSingleQuotes?: string; 1033 + patternWithNewline?: string; 1034 + patternWithBacktick?: string; 1035 + patternWithUnicode?: string; 1036 + }; 1037 + 1038 + export type FileWritable = { 1039 + /** 1040 + * Mime 1041 + */ 1042 + mime: string; 1043 + }; 1044 + 1045 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1046 + foo: string; 1047 + baz: string; 1048 + }; 1049 + 1050 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ 1051 + number | Import, 1052 + number | Import 1053 + ]; 1054 + 1055 + export type AdditionalPropertiesUnknownIssueWritable = { 1056 + [key: string]: string | number; 1057 + }; 1058 + 1059 + export type OneOfAllOfIssueWritable = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 1060 + 1061 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1062 + item?: boolean; 1063 + error?: string | null; 1064 + data?: { 1065 + [key: string]: never; 1066 + }; 1067 + }; 1068 + 1069 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1070 + item?: string | null; 1071 + error?: string | null; 1072 + }; 1073 + 1074 + /** 1075 + * This is a reusable parameter 1076 + */ 1077 + export type SimpleParameter = string; 1078 + 1079 + /** 1080 + * Parameter with illegal characters 1081 + */ 1082 + export type XFooBar = ModelWithString; 1083 + 1084 + /** 1085 + * A reusable request body 1086 + */ 1087 + export type SimpleRequestBody = ModelWithString; 1088 + 1089 + /** 1090 + * A reusable request body 1091 + */ 1092 + export type SimpleFormData = ModelWithString; 1093 + 1094 + export type ExportData = { 1095 + body?: never; 1096 + path?: never; 1097 + query?: never; 1098 + url: '/api/v{api-version}/no+tag'; 1099 + }; 1100 + 1101 + export type PatchApiVbyApiVersionNoTagData = { 1102 + body?: never; 1103 + path?: never; 1104 + query?: never; 1105 + url: '/api/v{api-version}/no+tag'; 1106 + }; 1107 + 1108 + export type PatchApiVbyApiVersionNoTagResponses = { 1109 + /** 1110 + * OK 1111 + */ 1112 + default: unknown; 1113 + }; 1114 + 1115 + export type ImportData = { 1116 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; 1117 + path?: never; 1118 + query?: never; 1119 + url: '/api/v{api-version}/no+tag'; 1120 + }; 1121 + 1122 + export type ImportResponses = { 1123 + /** 1124 + * Success 1125 + */ 1126 + 200: ModelFromZendesk; 1127 + /** 1128 + * Default success response 1129 + */ 1130 + default: ModelWithReadOnlyAndWriteOnly; 1131 + }; 1132 + 1133 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1134 + 1135 + export type FooWowData = { 1136 + body?: never; 1137 + path?: never; 1138 + query?: never; 1139 + url: '/api/v{api-version}/no+tag'; 1140 + }; 1141 + 1142 + export type FooWowResponses = { 1143 + /** 1144 + * OK 1145 + */ 1146 + default: unknown; 1147 + }; 1148 + 1149 + export type ApiVVersionODataControllerCountData = { 1150 + body?: never; 1151 + path?: never; 1152 + query?: never; 1153 + url: '/api/v{api-version}/simple/$count'; 1154 + }; 1155 + 1156 + export type ApiVVersionODataControllerCountResponses = { 1157 + /** 1158 + * Success 1159 + */ 1160 + 200: ModelFromZendesk; 1161 + }; 1162 + 1163 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1164 + 1165 + export type GetApiVbyApiVersionSimpleOperationData = { 1166 + body?: never; 1167 + path: { 1168 + /** 1169 + * foo in method 1170 + */ 1171 + foo_param: string; 1172 + }; 1173 + query?: never; 1174 + url: '/api/v{api-version}/simple:operation'; 1175 + }; 1176 + 1177 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1178 + /** 1179 + * Default error response 1180 + */ 1181 + default: ModelWithBoolean; 1182 + }; 1183 + 1184 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1185 + 1186 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1187 + /** 1188 + * Response is a simple number 1189 + */ 1190 + 200: number; 1191 + }; 1192 + 1193 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1194 + 1195 + export type DeleteCallWithoutParametersAndResponseData = { 1196 + body?: never; 1197 + path?: never; 1198 + query?: never; 1199 + url: '/api/v{api-version}/simple'; 1200 + }; 1201 + 1202 + export type GetCallWithoutParametersAndResponseData = { 1203 + body?: never; 1204 + path?: never; 1205 + query?: never; 1206 + url: '/api/v{api-version}/simple'; 1207 + }; 1208 + 1209 + export type HeadCallWithoutParametersAndResponseData = { 1210 + body?: never; 1211 + path?: never; 1212 + query?: never; 1213 + url: '/api/v{api-version}/simple'; 1214 + }; 1215 + 1216 + export type OptionsCallWithoutParametersAndResponseData = { 1217 + body?: never; 1218 + path?: never; 1219 + query?: never; 1220 + url: '/api/v{api-version}/simple'; 1221 + }; 1222 + 1223 + export type PatchCallWithoutParametersAndResponseData = { 1224 + body?: never; 1225 + path?: never; 1226 + query?: never; 1227 + url: '/api/v{api-version}/simple'; 1228 + }; 1229 + 1230 + export type PostCallWithoutParametersAndResponseData = { 1231 + body?: never; 1232 + path?: never; 1233 + query?: never; 1234 + url: '/api/v{api-version}/simple'; 1235 + }; 1236 + 1237 + export type PutCallWithoutParametersAndResponseData = { 1238 + body?: never; 1239 + path?: never; 1240 + query?: never; 1241 + url: '/api/v{api-version}/simple'; 1242 + }; 1243 + 1244 + export type DeleteFooData3 = { 1245 + body?: never; 1246 + headers: { 1247 + /** 1248 + * Parameter with illegal characters 1249 + */ 1250 + 'x-Foo-Bar': ModelWithString; 1251 + }; 1252 + path: { 1253 + /** 1254 + * foo in method 1255 + */ 1256 + foo_param: string; 1257 + /** 1258 + * bar in method 1259 + */ 1260 + BarParam: string; 1261 + }; 1262 + query?: never; 1263 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1264 + }; 1265 + 1266 + export type CallWithDescriptionsData = { 1267 + body?: never; 1268 + path?: never; 1269 + query?: { 1270 + /** 1271 + * Testing multiline comments in string: First line 1272 + * Second line 1273 + * 1274 + * Fourth line 1275 + */ 1276 + parameterWithBreaks?: string; 1277 + /** 1278 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1279 + */ 1280 + parameterWithBackticks?: string; 1281 + /** 1282 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1283 + */ 1284 + parameterWithSlashes?: string; 1285 + /** 1286 + * Testing expression placeholders in string: ${expression} should work 1287 + */ 1288 + parameterWithExpressionPlaceholders?: string; 1289 + /** 1290 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1291 + */ 1292 + parameterWithQuotes?: string; 1293 + /** 1294 + * Testing reserved characters in string: * inline * and ** inline ** should work 1295 + */ 1296 + parameterWithReservedCharacters?: string; 1297 + }; 1298 + url: '/api/v{api-version}/descriptions'; 1299 + }; 1300 + 1301 + export type DeprecatedCallData = { 1302 + body?: never; 1303 + headers: { 1304 + /** 1305 + * This parameter is deprecated 1306 + * 1307 + * @deprecated 1308 + */ 1309 + parameter: DeprecatedModel | null; 1310 + }; 1311 + path?: never; 1312 + query?: never; 1313 + url: '/api/v{api-version}/parameters/deprecated'; 1314 + }; 1315 + 1316 + export type CallWithParametersData = { 1317 + /** 1318 + * This is the parameter that goes into the body 1319 + */ 1320 + body: { 1321 + [key: string]: unknown; 1322 + } | null; 1323 + headers: { 1324 + /** 1325 + * This is the parameter that goes into the header 1326 + */ 1327 + parameterHeader: string | null; 1328 + }; 1329 + path: { 1330 + /** 1331 + * This is the parameter that goes into the path 1332 + */ 1333 + parameterPath: string | null; 1334 + /** 1335 + * api-version should be required in standalone clients 1336 + */ 1337 + 'api-version': string | null; 1338 + }; 1339 + query: { 1340 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1341 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1342 + /** 1343 + * This is the parameter that goes into the query params 1344 + */ 1345 + cursor: string | null; 1346 + }; 1347 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1348 + }; 1349 + 1350 + export type CallWithWeirdParameterNamesData = { 1351 + /** 1352 + * This is the parameter that goes into the body 1353 + */ 1354 + body: ModelWithString | null; 1355 + headers: { 1356 + /** 1357 + * This is the parameter that goes into the request header 1358 + */ 1359 + 'parameter.header': string | null; 1360 + }; 1361 + path: { 1362 + /** 1363 + * This is the parameter that goes into the path 1364 + */ 1365 + 'parameter.path.1'?: string; 1366 + /** 1367 + * This is the parameter that goes into the path 1368 + */ 1369 + 'parameter-path-2'?: string; 1370 + /** 1371 + * This is the parameter that goes into the path 1372 + */ 1373 + 'PARAMETER-PATH-3'?: string; 1374 + /** 1375 + * api-version should be required in standalone clients 1376 + */ 1377 + 'api-version': string | null; 1378 + }; 1379 + query: { 1380 + /** 1381 + * This is the parameter with a reserved keyword 1382 + */ 1383 + default?: string; 1384 + /** 1385 + * This is the parameter that goes into the request query params 1386 + */ 1387 + 'parameter-query': string | null; 1388 + }; 1389 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1390 + }; 1391 + 1392 + export type GetCallWithOptionalParamData = { 1393 + /** 1394 + * This is a required parameter 1395 + */ 1396 + body: ModelWithOneOfEnum; 1397 + path?: never; 1398 + query?: { 1399 + /** 1400 + * This is an optional parameter 1401 + */ 1402 + page?: number; 1403 + }; 1404 + url: '/api/v{api-version}/parameters'; 1405 + }; 1406 + 1407 + export type PostCallWithOptionalParamData = { 1408 + /** 1409 + * This is an optional parameter 1410 + */ 1411 + body?: { 1412 + offset?: number | null; 1413 + }; 1414 + path?: never; 1415 + query: { 1416 + /** 1417 + * This is a required parameter 1418 + */ 1419 + parameter: Pageable; 1420 + }; 1421 + url: '/api/v{api-version}/parameters'; 1422 + }; 1423 + 1424 + export type PostCallWithOptionalParamResponses = { 1425 + /** 1426 + * Response is a simple number 1427 + */ 1428 + 200: number; 1429 + /** 1430 + * Success 1431 + */ 1432 + 204: void; 1433 + }; 1434 + 1435 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1436 + 1437 + export type PostApiVbyApiVersionRequestBodyData = { 1438 + /** 1439 + * A reusable request body 1440 + */ 1441 + body?: SimpleRequestBody; 1442 + path?: never; 1443 + query?: { 1444 + /** 1445 + * This is a reusable parameter 1446 + */ 1447 + parameter?: string; 1448 + }; 1449 + url: '/api/v{api-version}/requestBody'; 1450 + }; 1451 + 1452 + export type PostApiVbyApiVersionFormDataData = { 1453 + /** 1454 + * A reusable request body 1455 + */ 1456 + body?: SimpleFormData; 1457 + path?: never; 1458 + query?: { 1459 + /** 1460 + * This is a reusable parameter 1461 + */ 1462 + parameter?: string; 1463 + }; 1464 + url: '/api/v{api-version}/formData'; 1465 + }; 1466 + 1467 + export type CallWithDefaultParametersData = { 1468 + body?: never; 1469 + path?: never; 1470 + query?: { 1471 + /** 1472 + * This is a simple string with default value 1473 + */ 1474 + parameterString?: string | null; 1475 + /** 1476 + * This is a simple number with default value 1477 + */ 1478 + parameterNumber?: number | null; 1479 + /** 1480 + * This is a simple boolean with default value 1481 + */ 1482 + parameterBoolean?: boolean | null; 1483 + /** 1484 + * This is a simple enum with default value 1485 + */ 1486 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1487 + /** 1488 + * This is a simple model with default value 1489 + */ 1490 + parameterModel?: ModelWithString | null; 1491 + }; 1492 + url: '/api/v{api-version}/defaults'; 1493 + }; 1494 + 1495 + export type CallWithDefaultOptionalParametersData = { 1496 + body?: never; 1497 + path?: never; 1498 + query?: { 1499 + /** 1500 + * This is a simple string that is optional with default value 1501 + */ 1502 + parameterString?: string; 1503 + /** 1504 + * This is a simple number that is optional with default value 1505 + */ 1506 + parameterNumber?: number; 1507 + /** 1508 + * This is a simple boolean that is optional with default value 1509 + */ 1510 + parameterBoolean?: boolean; 1511 + /** 1512 + * This is a simple enum that is optional with default value 1513 + */ 1514 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1515 + /** 1516 + * This is a simple model that is optional with default value 1517 + */ 1518 + parameterModel?: ModelWithString; 1519 + }; 1520 + url: '/api/v{api-version}/defaults'; 1521 + }; 1522 + 1523 + export type CallToTestOrderOfParamsData = { 1524 + body?: never; 1525 + path?: never; 1526 + query: { 1527 + /** 1528 + * This is a optional string with default 1529 + */ 1530 + parameterOptionalStringWithDefault?: string; 1531 + /** 1532 + * This is a optional string with empty default 1533 + */ 1534 + parameterOptionalStringWithEmptyDefault?: string; 1535 + /** 1536 + * This is a optional string with no default 1537 + */ 1538 + parameterOptionalStringWithNoDefault?: string; 1539 + /** 1540 + * This is a string with default 1541 + */ 1542 + parameterStringWithDefault: string; 1543 + /** 1544 + * This is a string with empty default 1545 + */ 1546 + parameterStringWithEmptyDefault: string; 1547 + /** 1548 + * This is a string with no default 1549 + */ 1550 + parameterStringWithNoDefault: string; 1551 + /** 1552 + * This is a string that can be null with no default 1553 + */ 1554 + parameterStringNullableWithNoDefault?: string | null; 1555 + /** 1556 + * This is a string that can be null with default 1557 + */ 1558 + parameterStringNullableWithDefault?: string | null; 1559 + }; 1560 + url: '/api/v{api-version}/defaults'; 1561 + }; 1562 + 1563 + export type DuplicateNameData = { 1564 + body?: never; 1565 + path?: never; 1566 + query?: never; 1567 + url: '/api/v{api-version}/duplicate'; 1568 + }; 1569 + 1570 + export type DuplicateName2Data = { 1571 + body?: never; 1572 + path?: never; 1573 + query?: never; 1574 + url: '/api/v{api-version}/duplicate'; 1575 + }; 1576 + 1577 + export type DuplicateName3Data = { 1578 + body?: never; 1579 + path?: never; 1580 + query?: never; 1581 + url: '/api/v{api-version}/duplicate'; 1582 + }; 1583 + 1584 + export type DuplicateName4Data = { 1585 + body?: never; 1586 + path?: never; 1587 + query?: never; 1588 + url: '/api/v{api-version}/duplicate'; 1589 + }; 1590 + 1591 + export type CallWithNoContentResponseData = { 1592 + body?: never; 1593 + path?: never; 1594 + query?: never; 1595 + url: '/api/v{api-version}/no-content'; 1596 + }; 1597 + 1598 + export type CallWithNoContentResponseResponses = { 1599 + /** 1600 + * Success 1601 + */ 1602 + 204: void; 1603 + }; 1604 + 1605 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1606 + 1607 + export type CallWithResponseAndNoContentResponseData = { 1608 + body?: never; 1609 + path?: never; 1610 + query?: never; 1611 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1612 + }; 1613 + 1614 + export type CallWithResponseAndNoContentResponseResponses = { 1615 + /** 1616 + * Response is a simple number 1617 + */ 1618 + 200: number; 1619 + /** 1620 + * Success 1621 + */ 1622 + 204: void; 1623 + }; 1624 + 1625 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1626 + 1627 + export type DummyAData = { 1628 + body?: never; 1629 + path?: never; 1630 + query?: never; 1631 + url: '/api/v{api-version}/multiple-tags/a'; 1632 + }; 1633 + 1634 + export type DummyAResponses = { 1635 + 200: _400; 1636 + }; 1637 + 1638 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1639 + 1640 + export type DummyBData = { 1641 + body?: never; 1642 + path?: never; 1643 + query?: never; 1644 + url: '/api/v{api-version}/multiple-tags/b'; 1645 + }; 1646 + 1647 + export type DummyBResponses = { 1648 + /** 1649 + * Success 1650 + */ 1651 + 204: void; 1652 + }; 1653 + 1654 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1655 + 1656 + export type CallWithResponseData = { 1657 + body?: never; 1658 + path?: never; 1659 + query?: never; 1660 + url: '/api/v{api-version}/response'; 1661 + }; 1662 + 1663 + export type CallWithResponseResponses = { 1664 + default: Import; 1665 + }; 1666 + 1667 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1668 + 1669 + export type CallWithDuplicateResponsesData = { 1670 + body?: never; 1671 + path?: never; 1672 + query?: never; 1673 + url: '/api/v{api-version}/response'; 1674 + }; 1675 + 1676 + export type CallWithDuplicateResponsesErrors = { 1677 + /** 1678 + * Message for 500 error 1679 + */ 1680 + 500: ModelWithStringError; 1681 + /** 1682 + * Message for 501 error 1683 + */ 1684 + 501: ModelWithStringError; 1685 + /** 1686 + * Message for 502 error 1687 + */ 1688 + 502: ModelWithStringError; 1689 + /** 1690 + * Message for 4XX errors 1691 + */ 1692 + '4XX': DictionaryWithArray; 1693 + /** 1694 + * Default error response 1695 + */ 1696 + default: ModelWithBoolean; 1697 + }; 1698 + 1699 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1700 + 1701 + export type CallWithDuplicateResponsesResponses = { 1702 + /** 1703 + * Message for 200 response 1704 + */ 1705 + 200: ModelWithBoolean & ModelWithInteger; 1706 + /** 1707 + * Message for 201 response 1708 + */ 1709 + 201: ModelWithString; 1710 + /** 1711 + * Message for 202 response 1712 + */ 1713 + 202: ModelWithString; 1714 + }; 1715 + 1716 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1717 + 1718 + export type CallWithResponsesData = { 1719 + body?: never; 1720 + path?: never; 1721 + query?: never; 1722 + url: '/api/v{api-version}/response'; 1723 + }; 1724 + 1725 + export type CallWithResponsesErrors = { 1726 + /** 1727 + * Message for 500 error 1728 + */ 1729 + 500: ModelWithStringError; 1730 + /** 1731 + * Message for 501 error 1732 + */ 1733 + 501: ModelWithStringError; 1734 + /** 1735 + * Message for 502 error 1736 + */ 1737 + 502: ModelWithStringError; 1738 + /** 1739 + * Message for default response 1740 + */ 1741 + default: ModelWithStringError; 1742 + }; 1743 + 1744 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1745 + 1746 + export type CallWithResponsesResponses = { 1747 + /** 1748 + * Message for 200 response 1749 + */ 1750 + 200: { 1751 + readonly '@namespace.string'?: string; 1752 + readonly '@namespace.integer'?: number; 1753 + readonly value?: Array<ModelWithString>; 1754 + }; 1755 + /** 1756 + * Message for 201 response 1757 + */ 1758 + 201: ModelThatExtends; 1759 + /** 1760 + * Message for 202 response 1761 + */ 1762 + 202: ModelThatExtendsExtends; 1763 + }; 1764 + 1765 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1766 + 1767 + export type CollectionFormatData = { 1768 + body?: never; 1769 + path?: never; 1770 + query: { 1771 + /** 1772 + * This is an array parameter that is sent as csv format (comma-separated values) 1773 + */ 1774 + parameterArrayCSV: Array<string> | null; 1775 + /** 1776 + * This is an array parameter that is sent as ssv format (space-separated values) 1777 + */ 1778 + parameterArraySSV: Array<string> | null; 1779 + /** 1780 + * This is an array parameter that is sent as tsv format (tab-separated values) 1781 + */ 1782 + parameterArrayTSV: Array<string> | null; 1783 + /** 1784 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1785 + */ 1786 + parameterArrayPipes: Array<string> | null; 1787 + /** 1788 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1789 + */ 1790 + parameterArrayMulti: Array<string> | null; 1791 + }; 1792 + url: '/api/v{api-version}/collectionFormat'; 1793 + }; 1794 + 1795 + export type TypesData = { 1796 + body?: never; 1797 + path?: { 1798 + /** 1799 + * This is a number parameter 1800 + */ 1801 + id?: number; 1802 + }; 1803 + query: { 1804 + /** 1805 + * This is a number parameter 1806 + */ 1807 + parameterNumber: number; 1808 + /** 1809 + * This is a string parameter 1810 + */ 1811 + parameterString: string | null; 1812 + /** 1813 + * This is a boolean parameter 1814 + */ 1815 + parameterBoolean: boolean | null; 1816 + /** 1817 + * This is an object parameter 1818 + */ 1819 + parameterObject: { 1820 + [key: string]: unknown; 1821 + } | null; 1822 + /** 1823 + * This is an array parameter 1824 + */ 1825 + parameterArray: Array<string> | null; 1826 + /** 1827 + * This is a dictionary parameter 1828 + */ 1829 + parameterDictionary: { 1830 + [key: string]: unknown; 1831 + } | null; 1832 + /** 1833 + * This is an enum parameter 1834 + */ 1835 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1836 + }; 1837 + url: '/api/v{api-version}/types'; 1838 + }; 1839 + 1840 + export type TypesResponses = { 1841 + /** 1842 + * Response is a simple number 1843 + */ 1844 + 200: number; 1845 + /** 1846 + * Response is a simple string 1847 + */ 1848 + 201: string; 1849 + /** 1850 + * Response is a simple boolean 1851 + */ 1852 + 202: boolean; 1853 + /** 1854 + * Response is a simple object 1855 + */ 1856 + 203: { 1857 + [key: string]: unknown; 1858 + }; 1859 + }; 1860 + 1861 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1862 + 1863 + export type UploadFileData = { 1864 + body: Blob | File; 1865 + path: { 1866 + /** 1867 + * api-version should be required in standalone clients 1868 + */ 1869 + 'api-version': string | null; 1870 + }; 1871 + query?: never; 1872 + url: '/api/v{api-version}/upload'; 1873 + }; 1874 + 1875 + export type UploadFileResponses = { 1876 + 200: boolean; 1877 + }; 1878 + 1879 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1880 + 1881 + export type FileResponseData = { 1882 + body?: never; 1883 + path: { 1884 + id: string; 1885 + /** 1886 + * api-version should be required in standalone clients 1887 + */ 1888 + 'api-version': string; 1889 + }; 1890 + query?: never; 1891 + url: '/api/v{api-version}/file/{id}'; 1892 + }; 1893 + 1894 + export type FileResponseResponses = { 1895 + /** 1896 + * Success 1897 + */ 1898 + 200: Blob | File; 1899 + }; 1900 + 1901 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1902 + 1903 + export type ComplexTypesData = { 1904 + body?: never; 1905 + path?: never; 1906 + query: { 1907 + /** 1908 + * Parameter containing object 1909 + */ 1910 + parameterObject: { 1911 + first?: { 1912 + second?: { 1913 + third?: string; 1914 + }; 1915 + }; 1916 + }; 1917 + /** 1918 + * Parameter containing reference 1919 + */ 1920 + parameterReference: ModelWithString; 1921 + }; 1922 + url: '/api/v{api-version}/complex'; 1923 + }; 1924 + 1925 + export type ComplexTypesErrors = { 1926 + /** 1927 + * 400 `server` error 1928 + */ 1929 + 400: unknown; 1930 + /** 1931 + * 500 server error 1932 + */ 1933 + 500: unknown; 1934 + }; 1935 + 1936 + export type ComplexTypesResponses = { 1937 + /** 1938 + * Successful response 1939 + */ 1940 + 200: Array<ModelWithString>; 1941 + }; 1942 + 1943 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1944 + 1945 + export type MultipartResponseData = { 1946 + body?: never; 1947 + path?: never; 1948 + query?: never; 1949 + url: '/api/v{api-version}/multipart'; 1950 + }; 1951 + 1952 + export type MultipartResponseResponses = { 1953 + /** 1954 + * OK 1955 + */ 1956 + 200: { 1957 + file?: Blob | File; 1958 + metadata?: { 1959 + foo?: string; 1960 + bar?: string; 1961 + }; 1962 + }; 1963 + }; 1964 + 1965 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1966 + 1967 + export type MultipartRequestData = { 1968 + body?: { 1969 + content?: Blob | File; 1970 + data?: ModelWithString | null; 1971 + }; 1972 + path?: never; 1973 + query?: never; 1974 + url: '/api/v{api-version}/multipart'; 1975 + }; 1976 + 1977 + export type ComplexParamsData = { 1978 + body?: { 1979 + readonly key: string | null; 1980 + name: string | null; 1981 + enabled?: boolean; 1982 + type: 'Monkey' | 'Horse' | 'Bird'; 1983 + listOfModels?: Array<ModelWithString> | null; 1984 + listOfStrings?: Array<string> | null; 1985 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1986 + readonly user?: { 1987 + readonly id?: number; 1988 + readonly name?: string | null; 1989 + }; 1990 + }; 1991 + path: { 1992 + id: number; 1993 + /** 1994 + * api-version should be required in standalone clients 1995 + */ 1996 + 'api-version': string; 1997 + }; 1998 + query?: never; 1999 + url: '/api/v{api-version}/complex/{id}'; 2000 + }; 2001 + 2002 + export type ComplexParamsResponses = { 2003 + /** 2004 + * Success 2005 + */ 2006 + 200: ModelWithString; 2007 + }; 2008 + 2009 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 2010 + 2011 + export type CallWithResultFromHeaderData = { 2012 + body?: never; 2013 + path?: never; 2014 + query?: never; 2015 + url: '/api/v{api-version}/header'; 2016 + }; 2017 + 2018 + export type CallWithResultFromHeaderErrors = { 2019 + /** 2020 + * 400 server error 2021 + */ 2022 + 400: unknown; 2023 + /** 2024 + * 500 server error 2025 + */ 2026 + 500: unknown; 2027 + }; 2028 + 2029 + export type CallWithResultFromHeaderResponses = { 2030 + /** 2031 + * Successful response 2032 + */ 2033 + 200: unknown; 2034 + }; 2035 + 2036 + export type TestErrorCodeData = { 2037 + body?: never; 2038 + path?: never; 2039 + query: { 2040 + /** 2041 + * Status code to return 2042 + */ 2043 + status: number; 2044 + }; 2045 + url: '/api/v{api-version}/error'; 2046 + }; 2047 + 2048 + export type TestErrorCodeErrors = { 2049 + /** 2050 + * Custom message: Internal Server Error 2051 + */ 2052 + 500: unknown; 2053 + /** 2054 + * Custom message: Not Implemented 2055 + */ 2056 + 501: unknown; 2057 + /** 2058 + * Custom message: Bad Gateway 2059 + */ 2060 + 502: unknown; 2061 + /** 2062 + * Custom message: Service Unavailable 2063 + */ 2064 + 503: unknown; 2065 + }; 2066 + 2067 + export type TestErrorCodeResponses = { 2068 + /** 2069 + * Custom message: Successful response 2070 + */ 2071 + 200: unknown; 2072 + }; 2073 + 2074 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2075 + body?: never; 2076 + path?: never; 2077 + query: { 2078 + /** 2079 + * Dummy input param 2080 + */ 2081 + nonAsciiParamæøåÆØÅöôêÊ: number; 2082 + }; 2083 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2084 + }; 2085 + 2086 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2087 + /** 2088 + * Successful response 2089 + */ 2090 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2091 + }; 2092 + 2093 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2094 + 2095 + export type PutWithFormUrlEncodedData = { 2096 + body: ArrayWithStrings; 2097 + path?: never; 2098 + query?: never; 2099 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2100 + };
+14
packages/openapi-ts-tests/main/test/plugins.test.ts
··· 259 259 }, 260 260 { 261 261 config: createConfig({ 262 + output: 'useMutation', 263 + plugins: [ 264 + { 265 + name: '@tanstack/react-query', 266 + useMutation: true, 267 + }, 268 + '@hey-api/client-fetch', 269 + ], 270 + }), 271 + description: 272 + 'generate Fetch API client with TanStack React Query plugin with useMutation hooks', 273 + }, 274 + { 275 + config: createConfig({ 262 276 input: 'sdk-instance.yaml', 263 277 output: 'name-builder', 264 278 plugins: [
+1
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts
··· 38 38 defaultValue: { 39 39 case: plugin.config.case ?? 'camelCase', 40 40 enabled: true, 41 + exported: true, 41 42 name: '{{name}}Mutation', 42 43 }, 43 44 mappers,
+12
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.ts
··· 142 142 */ 143 143 enabled?: boolean; 144 144 /** 145 + * Whether to export generated symbols. 146 + * 147 + * @default true 148 + */ 149 + exported?: boolean; 150 + /** 145 151 * Custom function to generate metadata for the operation. 146 152 * Can return any valid meta object that will be included in the generated mutation options. 147 153 * @param operation - The operation object containing all available metadata ··· 340 346 */ 341 347 mutationOptions: NamingOptions & 342 348 FeatureToggle & { 349 + /** 350 + * Whether to export generated symbols. 351 + * 352 + * @default true 353 + */ 354 + exported: boolean; 343 355 /** 344 356 * Custom function to generate metadata for the operation. 345 357 * Can return any valid meta object that will be included in the generated mutation options.
+1 -1
packages/openapi-ts/src/plugins/@tanstack/query-core/v5/mutationOptions.ts
··· 66 66 }, 67 67 ); 68 68 const statement = $.const(symbolMutationOptions) 69 - .export() 69 + .export(plugin.config.mutationOptions.exported) 70 70 .$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)) 71 71 .assign( 72 72 $.func()
+12
packages/openapi-ts/src/plugins/@tanstack/query-core/v5/plugin.ts
··· 2 2 import { createInfiniteQueryOptions } from './infiniteQueryOptions'; 3 3 import { createMutationOptions } from './mutationOptions'; 4 4 import { createQueryOptions } from './queryOptions'; 5 + import { createUseMutation } from './useMutation'; 5 6 import { createUseQuery } from './useQuery'; 6 7 7 8 export const handlerV5: PluginHandler = ({ plugin }) => { ··· 49 50 resource: `${plugin.name}.queryOptions`, 50 51 }, 51 52 }); 53 + plugin.symbol('useMutation', { 54 + external: plugin.name, 55 + meta: { 56 + category: 'external', 57 + resource: `${plugin.name}.useMutation`, 58 + }, 59 + }); 52 60 plugin.symbol('useQuery', { 53 61 external: plugin.name, 54 62 meta: { ··· 85 93 if (plugin.hooks.operation.isMutation(operation)) { 86 94 if (plugin.config.mutationOptions.enabled) { 87 95 createMutationOptions({ operation, plugin }); 96 + } 97 + 98 + if ('useMutation' in plugin.config && plugin.config.useMutation.enabled) { 99 + createUseMutation({ operation, plugin }); 88 100 } 89 101 } 90 102 },
+63
packages/openapi-ts/src/plugins/@tanstack/query-core/v5/useMutation.ts
··· 1 + import type { IR } from '@hey-api/shared'; 2 + import { applyNaming } from '@hey-api/shared'; 3 + 4 + import { createOperationComment } from '../../../../plugins/shared/utils/operation'; 5 + import { $ } from '../../../../ts-dsl'; 6 + import { useTypeData, useTypeError, useTypeResponse } from '../shared/useType'; 7 + import type { PluginInstance } from '../types'; 8 + 9 + const mutationOptionsParamName = 'mutationOptions'; 10 + 11 + export const createUseMutation = ({ 12 + operation, 13 + plugin, 14 + }: { 15 + operation: IR.OperationObject; 16 + plugin: PluginInstance; 17 + }): void => { 18 + if (!('useMutation' in plugin.config)) { 19 + return; 20 + } 21 + 22 + const symbolUseMutationFn = plugin.symbol(applyNaming(operation.id, plugin.config.useMutation)); 23 + 24 + const symbolUseMutation = plugin.external(`${plugin.name}.useMutation`); 25 + 26 + const typeData = useTypeData({ operation, plugin }); 27 + 28 + const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`); 29 + const mutationType = $.type(symbolMutationOptionsType) 30 + .generic(useTypeResponse({ operation, plugin })) 31 + .generic(useTypeError({ operation, plugin })) 32 + .generic(typeData); 33 + 34 + const symbolMutationOptionsFn = plugin.referenceSymbol({ 35 + category: 'hook', 36 + resource: 'operation', 37 + resourceId: operation.id, 38 + role: 'mutationOptions', 39 + tool: plugin.name, 40 + }); 41 + 42 + const func = $.func().param(mutationOptionsParamName, (p) => 43 + p 44 + .optional() 45 + .type( 46 + $.type('Partial').generic( 47 + $.type('Omit', (t) => t.generics(mutationType, $.type.literal('mutationFn'))), 48 + ), 49 + ), 50 + ); 51 + 52 + func.do( 53 + $(symbolUseMutation) 54 + .call($.object().spread($(symbolMutationOptionsFn).call()).spread(mutationOptionsParamName)) 55 + .return(), 56 + ); 57 + 58 + const statement = $.const(symbolUseMutationFn) 59 + .export() 60 + .$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)) 61 + .assign(func); 62 + plugin.node(statement); 63 + };
+23 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 38 38 defaultValue: { 39 39 case: plugin.config.case ?? 'camelCase', 40 40 enabled: true, 41 + exported: true, 41 42 name: '{{name}}Mutation', 42 43 }, 43 44 mappers, ··· 66 67 value: plugin.config.queryOptions, 67 68 }); 68 69 70 + plugin.config.useMutation = context.valueToObject({ 71 + defaultValue: { 72 + case: plugin.config.case ?? 'camelCase', 73 + enabled: false, 74 + name: 'use{{name}}Mutation', 75 + }, 76 + mappers: { 77 + boolean: (enabled) => ({ enabled }), 78 + function: (name) => ({ enabled: true, name }), 79 + object: (fields) => ({ enabled: true, ...fields }), 80 + string: (name) => ({ enabled: true, name }), 81 + }, 82 + value: plugin.config.useMutation, 83 + }); 84 + 69 85 plugin.config.useQuery = context.valueToObject({ 70 86 defaultValue: { 71 87 case: plugin.config.case ?? 'camelCase', ··· 81 97 value: plugin.config.useQuery, 82 98 }); 83 99 100 + if (plugin.config.useMutation.enabled) { 101 + if (!plugin.config.mutationOptions.enabled) { 102 + plugin.config.mutationOptions.enabled = true; 103 + plugin.config.mutationOptions.exported = false; 104 + } 105 + } 106 + 84 107 if (plugin.config.useQuery.enabled) { 85 - // useQuery hooks consume queryOptions 86 108 if (!plugin.config.queryOptions.enabled) { 87 109 plugin.config.queryOptions.enabled = true; 88 110 plugin.config.queryOptions.exported = false;
+55
packages/openapi-ts/src/plugins/@tanstack/react-query/types.ts
··· 145 145 */ 146 146 enabled?: boolean; 147 147 /** 148 + * Whether to export generated symbols. 149 + * 150 + * @default true 151 + */ 152 + exported?: boolean; 153 + /** 148 154 * Custom function to generate metadata for the operation. 149 155 * Can return any valid meta object that will be included in the generated mutation options. 150 156 * ··· 287 293 name?: NameTransformer; 288 294 }; 289 295 /** 296 + * Configuration for generated `useMutation()` function helpers. 297 + * 298 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 299 + * 300 + * Can be: 301 + * - `boolean`: Shorthand for `{ enabled: boolean }` 302 + * - `string` or `function`: Shorthand for `{ name: string | function }` 303 + * - `object`: Full configuration object 304 + * 305 + * @default false 306 + */ 307 + useMutation?: 308 + | boolean 309 + | NameTransformer 310 + | { 311 + /** 312 + * Casing convention for generated names. 313 + * 314 + * @default 'camelCase' 315 + */ 316 + case?: Casing; 317 + /** 318 + * Whether this feature is enabled. 319 + * 320 + * @default false 321 + */ 322 + enabled?: boolean; 323 + /** 324 + * Naming pattern for generated names. 325 + * 326 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 327 + * 328 + * @default 'use{{name}}Mutation' 329 + */ 330 + name?: NameTransformer; 331 + }; 332 + /** 290 333 * Configuration for generated `useQuery()` function helpers. 291 334 * 292 335 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} ··· 387 430 mutationOptions: NamingOptions & 388 431 FeatureToggle & { 389 432 /** 433 + * Whether to export generated symbols. 434 + * 435 + * @default true 436 + */ 437 + exported: boolean; 438 + /** 390 439 * Custom function to generate metadata for the operation. 391 440 * Can return any valid meta object that will be included in the generated mutation options. 392 441 * ··· 462 511 */ 463 512 meta: (operation: IR.OperationObject) => Record<string, unknown>; 464 513 }; 514 + /** 515 + * Configuration for generated `useMutation()` function helpers. 516 + * 517 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 518 + */ 519 + useMutation: NamingOptions & FeatureToggle; 465 520 /** 466 521 * Configuration for generated `useQuery()` function helpers. 467 522 *
+1
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
··· 38 38 defaultValue: { 39 39 case: plugin.config.case ?? 'camelCase', 40 40 enabled: true, 41 + exported: true, 41 42 name: '{{name}}Mutation', 42 43 }, 43 44 mappers,
+12
packages/openapi-ts/src/plugins/@tanstack/solid-query/types.ts
··· 149 149 */ 150 150 enabled?: boolean; 151 151 /** 152 + * Whether to export generated symbols. 153 + * 154 + * @default true 155 + */ 156 + exported?: boolean; 157 + /** 152 158 * Custom function to generate metadata for the operation. 153 159 * Can return any valid meta object that will be included in the generated mutation options. 154 160 * @param operation - The operation object containing all available metadata ··· 347 353 */ 348 354 mutationOptions: NamingOptions & 349 355 FeatureToggle & { 356 + /** 357 + * Whether to export generated symbols. 358 + * 359 + * @default true 360 + */ 361 + exported: boolean; 350 362 /** 351 363 * Custom function to generate metadata for the operation. 352 364 * Can return any valid meta object that will be included in the generated mutation options.
+1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
··· 38 38 defaultValue: { 39 39 case: plugin.config.case ?? 'camelCase', 40 40 enabled: true, 41 + exported: true, 41 42 name: '{{name}}Mutation', 42 43 }, 43 44 mappers,
+12
packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.ts
··· 148 148 */ 149 149 enabled?: boolean; 150 150 /** 151 + * Whether to export generated symbols. 152 + * 153 + * @default true 154 + */ 155 + exported?: boolean; 156 + /** 151 157 * Custom function to generate metadata for the operation. 152 158 * Can return any valid meta object that will be included in the generated mutation options. 153 159 * @param operation - The operation object containing all available metadata ··· 346 352 */ 347 353 mutationOptions: NamingOptions & 348 354 FeatureToggle & { 355 + /** 356 + * Whether to export generated symbols. 357 + * 358 + * @default true 359 + */ 360 + exported: boolean; 349 361 /** 350 362 * Custom function to generate metadata for the operation. 351 363 * Can return any valid meta object that will be included in the generated mutation options.
+1
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
··· 38 38 defaultValue: { 39 39 case: plugin.config.case ?? 'camelCase', 40 40 enabled: true, 41 + exported: true, 41 42 name: '{{name}}Mutation', 42 43 }, 43 44 mappers,
+12
packages/openapi-ts/src/plugins/@tanstack/vue-query/types.ts
··· 149 149 */ 150 150 enabled?: boolean; 151 151 /** 152 + * Whether to export generated symbols. 153 + * 154 + * @default true 155 + */ 156 + exported?: boolean; 157 + /** 152 158 * Custom function to generate metadata for the operation. 153 159 * Can return any valid meta object that will be included in the generated mutation options. 154 160 * ··· 350 356 */ 351 357 mutationOptions: NamingOptions & 352 358 FeatureToggle & { 359 + /** 360 + * Whether to export generated symbols. 361 + * 362 + * @default true 363 + */ 364 + exported: boolean; 353 365 /** 354 366 * Custom function to generate metadata for the operation. 355 367 * Can return any valid meta object that will be included in the generated mutation options.