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

feat: generate useMutation hooks for TanStack React Query plugin

+14111 -2
+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 usePatchApiVbyApiVersionNoTag = (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 useFooWow = (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 useDeleteCallWithoutParametersAndResponse = (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 usePatchCallWithoutParametersAndResponse = (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 usePostCallWithoutParametersAndResponse = (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 usePutCallWithoutParametersAndResponse = (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 useCallWithDescriptions = (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 useCallWithParameters = (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 useCallWithWeirdParameterNames = (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 useCallWithDefaultOptionalParameters = (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 useCallToTestOrderOfParams = (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 useDuplicateName = (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 useDuplicateName3 = (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 useDuplicateName4 = (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 useCallWithDuplicateResponses = (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 useCallWithResponses = (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 useCallWithResultFromHeader = (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 useTestErrorCode = (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æøåÆøÅöôêÊ字符串 = (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 usePostApiVbyApiVersionBody = (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, 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); 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 + };
+84
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: any) => any; 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: <T extends Record<string, any> | Array<Record<string, any>>>( 43 + body: T, 44 + ): FormData => { 45 + const data = new FormData(); 46 + 47 + Object.entries(body).forEach(([key, value]) => { 48 + if (value === undefined || value === null) { 49 + return; 50 + } 51 + if (Array.isArray(value)) { 52 + value.forEach((v) => serializeFormDataPair(data, key, v)); 53 + } else { 54 + serializeFormDataPair(data, key, value); 55 + } 56 + }); 57 + 58 + return data; 59 + }, 60 + }; 61 + 62 + export const jsonBodySerializer = { 63 + bodySerializer: <T>(body: T): string => 64 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 65 + }; 66 + 67 + export const urlSearchParamsBodySerializer = { 68 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => { 69 + const data = new URLSearchParams(); 70 + 71 + Object.entries(body).forEach(([key, value]) => { 72 + if (value === undefined || value === null) { 73 + return; 74 + } 75 + if (Array.isArray(value)) { 76 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 77 + } else { 78 + serializeUrlSearchParamsPair(data, key, value); 79 + } 80 + }); 81 + 82 + return data.toString(); 83 + }, 84 + };
+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' && !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 + });
+1188
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 + }; 394 + 395 + export type ParameterActivityParams = { 396 + description?: string; 397 + graduate_id?: number; 398 + organization_id?: number; 399 + parent_activity?: number; 400 + post_id?: number; 401 + }; 402 + 403 + export type ResponsePostActivityResponse = { 404 + description?: string; 405 + graduate_id?: number; 406 + organization_id?: number; 407 + parent_activity_id?: number; 408 + post_id?: number; 409 + }; 410 + 411 + export type FailureFailure = { 412 + error?: string; 413 + message?: string; 414 + reference_code?: string; 415 + }; 416 + 417 + export type ExternalSharedModel = { 418 + id: string; 419 + name?: string; 420 + }; 421 + 422 + /** 423 + * This is a model with one property containing a reference 424 + */ 425 + export type ModelWithReferenceWritable = { 426 + prop?: ModelWithPropertiesWritable; 427 + }; 428 + 429 + /** 430 + * This is a model with one nested property 431 + */ 432 + export type ModelWithPropertiesWritable = { 433 + required: string; 434 + string?: string; 435 + number?: number; 436 + boolean?: boolean; 437 + reference?: ModelWithString; 438 + 'property with space'?: string; 439 + default?: string; 440 + try?: string; 441 + }; 442 + 443 + /** 444 + * This is a model that contains a some patterns 445 + */ 446 + export type ModelWithPatternWritable = { 447 + key: string; 448 + name: string; 449 + id?: string; 450 + text?: string; 451 + patternWithSingleQuotes?: string; 452 + patternWithNewline?: string; 453 + patternWithBacktick?: string; 454 + }; 455 + 456 + export type ServiceWithEmptyTagData = { 457 + body?: never; 458 + path?: never; 459 + query?: never; 460 + url: '/api/v{api-version}/no+tag'; 461 + }; 462 + 463 + export type PatchApiVbyApiVersionNoTagData = { 464 + body?: never; 465 + path?: never; 466 + query?: never; 467 + url: '/api/v{api-version}/no+tag'; 468 + }; 469 + 470 + export type PatchApiVbyApiVersionNoTagResponses = { 471 + /** 472 + * OK 473 + */ 474 + default: unknown; 475 + }; 476 + 477 + export type FooWowData = { 478 + body?: never; 479 + path?: never; 480 + query?: never; 481 + url: '/api/v{api-version}/no+tag'; 482 + }; 483 + 484 + export type FooWowResponses = { 485 + /** 486 + * OK 487 + */ 488 + default: unknown; 489 + }; 490 + 491 + export type DeleteCallWithoutParametersAndResponseData = { 492 + body?: never; 493 + path?: never; 494 + query?: never; 495 + url: '/api/v{api-version}/simple'; 496 + }; 497 + 498 + export type GetCallWithoutParametersAndResponseData = { 499 + body?: never; 500 + path?: never; 501 + query?: never; 502 + url: '/api/v{api-version}/simple'; 503 + }; 504 + 505 + export type HeadCallWithoutParametersAndResponseData = { 506 + body?: never; 507 + path?: never; 508 + query?: never; 509 + url: '/api/v{api-version}/simple'; 510 + }; 511 + 512 + export type OptionsCallWithoutParametersAndResponseData = { 513 + body?: never; 514 + path?: never; 515 + query?: never; 516 + url: '/api/v{api-version}/simple'; 517 + }; 518 + 519 + export type PatchCallWithoutParametersAndResponseData = { 520 + body?: never; 521 + path?: never; 522 + query?: never; 523 + url: '/api/v{api-version}/simple'; 524 + }; 525 + 526 + export type PostCallWithoutParametersAndResponseData = { 527 + body?: never; 528 + path?: never; 529 + query?: never; 530 + url: '/api/v{api-version}/simple'; 531 + }; 532 + 533 + export type PutCallWithoutParametersAndResponseData = { 534 + body?: never; 535 + path?: never; 536 + query?: never; 537 + url: '/api/v{api-version}/simple'; 538 + }; 539 + 540 + export type CallWithDescriptionsData = { 541 + body?: never; 542 + path?: never; 543 + query?: { 544 + /** 545 + * Testing multiline comments in string: First line 546 + * Second line 547 + * 548 + * Fourth line 549 + */ 550 + parameterWithBreaks?: string; 551 + /** 552 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 553 + */ 554 + parameterWithBackticks?: string; 555 + /** 556 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 557 + */ 558 + parameterWithSlashes?: string; 559 + /** 560 + * Testing expression placeholders in string: ${expression} should work 561 + */ 562 + parameterWithExpressionPlaceholders?: string; 563 + /** 564 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 565 + */ 566 + parameterWithQuotes?: string; 567 + /** 568 + * Testing reserved characters in string: * inline * and ** inline ** should work 569 + */ 570 + parameterWithReservedCharacters?: string; 571 + }; 572 + url: '/api/v{api-version}/descriptions/'; 573 + }; 574 + 575 + export type CallWithParametersData = { 576 + body?: never; 577 + headers: { 578 + /** 579 + * This is the parameter that goes into the header 580 + */ 581 + parameterHeader: string; 582 + }; 583 + path: { 584 + /** 585 + * This is the parameter that goes into the path 586 + */ 587 + parameterPath: string; 588 + /** 589 + * api-version should be required in standalone clients 590 + */ 591 + 'api-version': string; 592 + }; 593 + query: { 594 + /** 595 + * This is the parameter that goes into the query params 596 + */ 597 + parameterQuery: string; 598 + }; 599 + url: '/api/v{api-version}/parameters/{parameterPath}'; 600 + }; 601 + 602 + export type CallWithWeirdParameterNamesData = { 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 607 + headers: { 608 + /** 609 + * This is the parameter that goes into the request header 610 + */ 611 + 'parameter.header': string; 612 + }; 613 + path: { 614 + /** 615 + * This is the parameter that goes into the path 616 + */ 617 + 'parameter.path.1'?: string; 618 + /** 619 + * This is the parameter that goes into the path 620 + */ 621 + 'parameter-path-2'?: string; 622 + /** 623 + * This is the parameter that goes into the path 624 + */ 625 + 'PARAMETER-PATH-3'?: string; 626 + /** 627 + * api-version should be required in standalone clients 628 + */ 629 + 'api-version': string; 630 + }; 631 + query: { 632 + /** 633 + * This is the parameter with a reserved keyword 634 + */ 635 + default?: string; 636 + /** 637 + * This is the parameter that goes into the request query params 638 + */ 639 + 'parameter-query': string; 640 + }; 641 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 642 + }; 643 + 644 + export type CallWithDefaultParametersData = { 645 + body?: never; 646 + path?: never; 647 + query: { 648 + /** 649 + * This is a simple string with default value 650 + */ 651 + parameterString: string; 652 + /** 653 + * This is a simple number with default value 654 + */ 655 + parameterNumber: number; 656 + /** 657 + * This is a simple boolean with default value 658 + */ 659 + parameterBoolean: boolean; 660 + /** 661 + * This is a simple enum with default value 662 + */ 663 + parameterEnum: 'Success' | 'Warning' | 'Error'; 664 + /** 665 + * This is a model with one string property 666 + */ 667 + parameterModel: { 668 + /** 669 + * This is a simple string property 670 + */ 671 + prop?: string; 672 + }; 673 + }; 674 + url: '/api/v{api-version}/defaults'; 675 + }; 676 + 677 + export type CallWithDefaultOptionalParametersData = { 678 + body?: never; 679 + path?: never; 680 + query?: { 681 + /** 682 + * This is a simple string that is optional with default value 683 + */ 684 + parameterString?: string; 685 + /** 686 + * This is a simple number that is optional with default value 687 + */ 688 + parameterNumber?: number; 689 + /** 690 + * This is a simple boolean that is optional with default value 691 + */ 692 + parameterBoolean?: boolean; 693 + /** 694 + * This is a simple enum that is optional with default value 695 + */ 696 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 697 + }; 698 + url: '/api/v{api-version}/defaults'; 699 + }; 700 + 701 + export type CallToTestOrderOfParamsData = { 702 + body?: never; 703 + path?: never; 704 + query: { 705 + /** 706 + * This is a optional string with default 707 + */ 708 + parameterOptionalStringWithDefault?: string; 709 + /** 710 + * This is a optional string with empty default 711 + */ 712 + parameterOptionalStringWithEmptyDefault?: string; 713 + /** 714 + * This is a optional string with no default 715 + */ 716 + parameterOptionalStringWithNoDefault?: string; 717 + /** 718 + * This is a string with default 719 + */ 720 + parameterStringWithDefault: string; 721 + /** 722 + * This is a string with empty default 723 + */ 724 + parameterStringWithEmptyDefault: string; 725 + /** 726 + * This is a string with no default 727 + */ 728 + parameterStringWithNoDefault: string; 729 + /** 730 + * This is a string that can be null with no default 731 + */ 732 + parameterStringNullableWithNoDefault?: string | null; 733 + /** 734 + * This is a string that can be null with default 735 + */ 736 + parameterStringNullableWithDefault?: string | null; 737 + }; 738 + url: '/api/v{api-version}/defaults'; 739 + }; 740 + 741 + export type DuplicateNameData = { 742 + body?: never; 743 + path?: never; 744 + query?: never; 745 + url: '/api/v{api-version}/duplicate'; 746 + }; 747 + 748 + export type DuplicateName2Data = { 749 + body?: never; 750 + path?: never; 751 + query?: never; 752 + url: '/api/v{api-version}/duplicate'; 753 + }; 754 + 755 + export type DuplicateName3Data = { 756 + body?: never; 757 + path?: never; 758 + query?: never; 759 + url: '/api/v{api-version}/duplicate'; 760 + }; 761 + 762 + export type DuplicateName4Data = { 763 + body?: never; 764 + path?: never; 765 + query?: never; 766 + url: '/api/v{api-version}/duplicate'; 767 + }; 768 + 769 + export type CallWithNoContentResponseData = { 770 + body?: never; 771 + path?: never; 772 + query?: never; 773 + url: '/api/v{api-version}/no-content'; 774 + }; 775 + 776 + export type CallWithNoContentResponseResponses = { 777 + /** 778 + * Success 779 + */ 780 + 204: unknown; 781 + }; 782 + 783 + export type CallWithResponseAndNoContentResponseData = { 784 + body?: never; 785 + path?: never; 786 + query?: never; 787 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 788 + }; 789 + 790 + export type CallWithResponseAndNoContentResponseResponses = { 791 + /** 792 + * Response is a simple number 793 + */ 794 + 200: number; 795 + /** 796 + * Success 797 + */ 798 + 204: unknown; 799 + }; 800 + 801 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 802 + 803 + export type DummyAData = { 804 + body?: never; 805 + path?: never; 806 + query?: never; 807 + url: '/api/v{api-version}/multiple-tags/a'; 808 + }; 809 + 810 + export type DummyAResponses = { 811 + /** 812 + * Success 813 + */ 814 + 204: unknown; 815 + }; 816 + 817 + export type DummyBData = { 818 + body?: never; 819 + path?: never; 820 + query?: never; 821 + url: '/api/v{api-version}/multiple-tags/b'; 822 + }; 823 + 824 + export type DummyBResponses = { 825 + /** 826 + * Success 827 + */ 828 + 204: unknown; 829 + }; 830 + 831 + export type CallWithResponseData = { 832 + body?: never; 833 + path?: never; 834 + query?: never; 835 + url: '/api/v{api-version}/response'; 836 + }; 837 + 838 + export type CallWithResponseResponses = { 839 + /** 840 + * Message for default response 841 + */ 842 + default: ModelWithString; 843 + }; 844 + 845 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 846 + 847 + export type CallWithDuplicateResponsesData = { 848 + body?: never; 849 + path?: never; 850 + query?: never; 851 + url: '/api/v{api-version}/response'; 852 + }; 853 + 854 + export type CallWithDuplicateResponsesErrors = { 855 + /** 856 + * Message for 500 error 857 + */ 858 + 500: ModelWithStringError; 859 + /** 860 + * Message for 501 error 861 + */ 862 + 501: ModelWithStringError; 863 + /** 864 + * Message for 502 error 865 + */ 866 + 502: ModelWithStringError; 867 + /** 868 + * Message for default response 869 + */ 870 + default: ModelWithString; 871 + }; 872 + 873 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 874 + 875 + export type CallWithDuplicateResponsesResponses = { 876 + /** 877 + * Message for 201 response 878 + */ 879 + 201: ModelWithString; 880 + /** 881 + * Message for 202 response 882 + */ 883 + 202: ModelWithString; 884 + }; 885 + 886 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 887 + 888 + export type CallWithResponsesData = { 889 + body?: never; 890 + path?: never; 891 + query?: never; 892 + url: '/api/v{api-version}/response'; 893 + }; 894 + 895 + export type CallWithResponsesErrors = { 896 + /** 897 + * Message for 500 error 898 + */ 899 + 500: ModelWithStringError; 900 + /** 901 + * Message for 501 error 902 + */ 903 + 501: ModelWithStringError; 904 + /** 905 + * Message for 502 error 906 + */ 907 + 502: ModelWithStringError; 908 + /** 909 + * Message for default response 910 + */ 911 + default: ModelWithString; 912 + }; 913 + 914 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 915 + 916 + export type CallWithResponsesResponses = { 917 + /** 918 + * Message for 200 response 919 + */ 920 + 200: { 921 + readonly '@namespace.string'?: string; 922 + readonly '@namespace.integer'?: number; 923 + readonly value?: Array<ModelWithString>; 924 + }; 925 + /** 926 + * Message for 201 response 927 + */ 928 + 201: ModelThatExtends; 929 + /** 930 + * Message for 202 response 931 + */ 932 + 202: ModelThatExtendsExtends; 933 + }; 934 + 935 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 936 + 937 + export type CollectionFormatData = { 938 + body?: never; 939 + path?: never; 940 + query: { 941 + /** 942 + * This is an array parameter that is sent as csv format (comma-separated values) 943 + */ 944 + parameterArrayCSV: Array<string>; 945 + /** 946 + * This is an array parameter that is sent as ssv format (space-separated values) 947 + */ 948 + parameterArraySSV: Array<string>; 949 + /** 950 + * This is an array parameter that is sent as tsv format (tab-separated values) 951 + */ 952 + parameterArrayTSV: Array<string>; 953 + /** 954 + * This is an array parameter that is sent as pipes format (pipe-separated values) 955 + */ 956 + parameterArrayPipes: Array<string>; 957 + /** 958 + * This is an array parameter that is sent as multi format (multiple parameter instances) 959 + */ 960 + parameterArrayMulti: Array<string>; 961 + }; 962 + url: '/api/v{api-version}/collectionFormat'; 963 + }; 964 + 965 + export type TypesData = { 966 + body?: never; 967 + path?: { 968 + /** 969 + * This is a number parameter 970 + */ 971 + id?: number; 972 + }; 973 + query: { 974 + /** 975 + * This is a number parameter 976 + */ 977 + parameterNumber: number; 978 + /** 979 + * This is a string parameter 980 + */ 981 + parameterString: string; 982 + /** 983 + * This is a boolean parameter 984 + */ 985 + parameterBoolean: boolean; 986 + /** 987 + * This is an array parameter 988 + */ 989 + parameterArray: Array<string>; 990 + /** 991 + * This is a dictionary parameter 992 + */ 993 + parameterDictionary: { 994 + [key: string]: unknown; 995 + }; 996 + /** 997 + * This is an enum parameter 998 + */ 999 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1000 + }; 1001 + url: '/api/v{api-version}/types'; 1002 + }; 1003 + 1004 + export type TypesResponses = { 1005 + /** 1006 + * Response is a simple number 1007 + */ 1008 + 200: number; 1009 + /** 1010 + * Response is a simple string 1011 + */ 1012 + 201: string; 1013 + /** 1014 + * Response is a simple boolean 1015 + */ 1016 + 202: boolean; 1017 + /** 1018 + * Response is a simple object 1019 + */ 1020 + 203: { 1021 + [key: string]: unknown; 1022 + }; 1023 + }; 1024 + 1025 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1026 + 1027 + export type ComplexTypesData = { 1028 + body?: never; 1029 + path?: never; 1030 + query: { 1031 + /** 1032 + * Parameter containing object 1033 + */ 1034 + parameterObject: { 1035 + first?: { 1036 + second?: { 1037 + third?: string; 1038 + }; 1039 + }; 1040 + }; 1041 + /** 1042 + * This is a model with one string property 1043 + */ 1044 + parameterReference: { 1045 + /** 1046 + * This is a simple string property 1047 + */ 1048 + prop?: string; 1049 + }; 1050 + }; 1051 + url: '/api/v{api-version}/complex'; 1052 + }; 1053 + 1054 + export type ComplexTypesErrors = { 1055 + /** 1056 + * 400 server error 1057 + */ 1058 + 400: unknown; 1059 + /** 1060 + * 500 server error 1061 + */ 1062 + 500: unknown; 1063 + }; 1064 + 1065 + export type ComplexTypesResponses = { 1066 + /** 1067 + * Successful response 1068 + */ 1069 + 200: Array<ModelWithString>; 1070 + }; 1071 + 1072 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1073 + 1074 + export type CallWithResultFromHeaderData = { 1075 + body?: never; 1076 + path?: never; 1077 + query?: never; 1078 + url: '/api/v{api-version}/header'; 1079 + }; 1080 + 1081 + export type CallWithResultFromHeaderErrors = { 1082 + /** 1083 + * 400 server error 1084 + */ 1085 + 400: unknown; 1086 + /** 1087 + * 500 server error 1088 + */ 1089 + 500: unknown; 1090 + }; 1091 + 1092 + export type CallWithResultFromHeaderResponses = { 1093 + /** 1094 + * Successful response 1095 + */ 1096 + 200: unknown; 1097 + }; 1098 + 1099 + export type TestErrorCodeData = { 1100 + body?: never; 1101 + path?: never; 1102 + query: { 1103 + /** 1104 + * Status code to return 1105 + */ 1106 + status: string; 1107 + }; 1108 + url: '/api/v{api-version}/error'; 1109 + }; 1110 + 1111 + export type TestErrorCodeErrors = { 1112 + /** 1113 + * Custom message: Internal Server Error 1114 + */ 1115 + 500: unknown; 1116 + /** 1117 + * Custom message: Not Implemented 1118 + */ 1119 + 501: unknown; 1120 + /** 1121 + * Custom message: Bad Gateway 1122 + */ 1123 + 502: unknown; 1124 + /** 1125 + * Custom message: Service Unavailable 1126 + */ 1127 + 503: unknown; 1128 + }; 1129 + 1130 + export type TestErrorCodeResponses = { 1131 + /** 1132 + * Custom message: Successful response 1133 + */ 1134 + 200: unknown; 1135 + }; 1136 + 1137 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 1138 + body?: never; 1139 + path?: never; 1140 + query: { 1141 + /** 1142 + * Dummy input param 1143 + */ 1144 + nonAsciiParamæøåÆØÅöôêÊ: number; 1145 + }; 1146 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 1147 + }; 1148 + 1149 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 1150 + /** 1151 + * Successful response 1152 + */ 1153 + 200: NonAsciiStringæøåÆøÅöôêÊ字符串; 1154 + }; 1155 + 1156 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 1157 + 1158 + export type PostApiVbyApiVersionBodyData = { 1159 + /** 1160 + * Body should not be unknown 1161 + */ 1162 + body: ParameterActivityParams; 1163 + path?: never; 1164 + query?: never; 1165 + url: '/api/v{api-version}/body'; 1166 + }; 1167 + 1168 + export type PostApiVbyApiVersionBodyErrors = { 1169 + /** 1170 + * Bad Request 1171 + */ 1172 + 400: FailureFailure; 1173 + /** 1174 + * Internal Server Error 1175 + */ 1176 + 500: FailureFailure; 1177 + }; 1178 + 1179 + export type PostApiVbyApiVersionBodyError = PostApiVbyApiVersionBodyErrors[keyof PostApiVbyApiVersionBodyErrors]; 1180 + 1181 + export type PostApiVbyApiVersionBodyResponses = { 1182 + /** 1183 + * OK 1184 + */ 1185 + 200: ResponsePostActivityResponse; 1186 + }; 1187 + 1188 + 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 usePatchApiVbyApiVersionNoTag = (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 useImport = (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 useFooWow = (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 useDeleteCallWithoutParametersAndResponse = (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 usePatchCallWithoutParametersAndResponse = (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 usePostCallWithoutParametersAndResponse = (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 usePutCallWithoutParametersAndResponse = (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 useDeleteFoo = (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 useCallWithDescriptions = (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 useDeprecatedCall = (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 useCallWithParameters = (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 useCallWithWeirdParameterNames = (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 usePostCallWithOptionalParam = (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 usePostApiVbyApiVersionRequestBody = (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 usePostApiVbyApiVersionFormData = (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 useCallWithDefaultOptionalParameters = (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 useCallToTestOrderOfParams = (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 useDuplicateName = (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 useDuplicateName3 = (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 useDuplicateName4 = (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 useCallWithDuplicateResponses = (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 useCallWithResponses = (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 useUploadFile = (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 useMultipartRequest = (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 useComplexParams = (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 useCallWithResultFromHeader = (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 useTestErrorCode = (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æøåÆøÅöôêÊ字符串 = (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 usePutWithFormUrlEncoded = (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, 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); 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 + };
+84
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: any) => any; 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: <T extends Record<string, any> | Array<Record<string, any>>>( 43 + body: T, 44 + ): FormData => { 45 + const data = new FormData(); 46 + 47 + Object.entries(body).forEach(([key, value]) => { 48 + if (value === undefined || value === null) { 49 + return; 50 + } 51 + if (Array.isArray(value)) { 52 + value.forEach((v) => serializeFormDataPair(data, key, v)); 53 + } else { 54 + serializeFormDataPair(data, key, value); 55 + } 56 + }); 57 + 58 + return data; 59 + }, 60 + }; 61 + 62 + export const jsonBodySerializer = { 63 + bodySerializer: <T>(body: T): string => 64 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 65 + }; 66 + 67 + export const urlSearchParamsBodySerializer = { 68 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => { 69 + const data = new URLSearchParams(); 70 + 71 + Object.entries(body).forEach(([key, value]) => { 72 + if (value === undefined || value === null) { 73 + return; 74 + } 75 + if (Array.isArray(value)) { 76 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 77 + } else { 78 + serializeUrlSearchParamsPair(data, key, value); 79 + } 80 + }); 81 + 82 + return data.toString(); 83 + }, 84 + };
+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' && !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, 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 + });
+2072
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 + }; 636 + 637 + export type File = { 638 + /** 639 + * Id 640 + */ 641 + readonly id?: string; 642 + /** 643 + * Updated at 644 + */ 645 + readonly updated_at?: string; 646 + /** 647 + * Created at 648 + */ 649 + readonly created_at?: string; 650 + /** 651 + * Mime 652 + */ 653 + mime: string; 654 + /** 655 + * File 656 + */ 657 + readonly file?: string; 658 + }; 659 + 660 + export type Default = { 661 + name?: string; 662 + }; 663 + 664 + export type Pageable = { 665 + page?: number; 666 + size?: number; 667 + sort?: Array<string>; 668 + }; 669 + 670 + /** 671 + * This is a free-form object without additionalProperties. 672 + */ 673 + export type FreeFormObjectWithoutAdditionalProperties = { 674 + [key: string]: unknown; 675 + }; 676 + 677 + /** 678 + * This is a free-form object with additionalProperties: true. 679 + */ 680 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 681 + [key: string]: unknown; 682 + }; 683 + 684 + /** 685 + * This is a free-form object with additionalProperties: {}. 686 + */ 687 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 688 + [key: string]: unknown; 689 + }; 690 + 691 + export type ModelWithConst = { 692 + String?: 'String'; 693 + number?: 0; 694 + null?: unknown; 695 + withType?: 'Some string'; 696 + }; 697 + 698 + /** 699 + * This is a model with one property and additionalProperties: true 700 + */ 701 + export type ModelWithAdditionalPropertiesEqTrue = { 702 + /** 703 + * This is a simple string property 704 + */ 705 + prop?: string; 706 + [key: string]: unknown | string | undefined; 707 + }; 708 + 709 + export type NestedAnyOfArraysNullable = { 710 + nullableArray?: Array<string | boolean> | null; 711 + }; 712 + 713 + export type CompositionWithOneOfAndProperties = ({ 714 + foo: SimpleParameter; 715 + } | { 716 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 717 + }) & { 718 + baz: number | null; 719 + qux: number; 720 + }; 721 + 722 + /** 723 + * An object that can be null 724 + */ 725 + export type NullableObject = { 726 + foo?: string; 727 + } | null; 728 + 729 + /** 730 + * Some % character 731 + */ 732 + export type CharactersInDescription = string; 733 + 734 + export type ModelWithNullableObject = { 735 + data?: NullableObject; 736 + }; 737 + 738 + export type ModelWithOneOfEnum = { 739 + foo: 'Bar'; 740 + } | { 741 + foo: 'Baz'; 742 + } | { 743 + foo: 'Qux'; 744 + } | { 745 + content: string; 746 + foo: 'Quux'; 747 + } | { 748 + content: [ 749 + string, 750 + string 751 + ]; 752 + foo: 'Corge'; 753 + }; 754 + 755 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 756 + 757 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 758 + 759 + export type ModelWithNestedArrayEnumsData = { 760 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 761 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 762 + }; 763 + 764 + export type ModelWithNestedArrayEnums = { 765 + array_strings?: Array<string>; 766 + data?: ModelWithNestedArrayEnumsData; 767 + }; 768 + 769 + export type ModelWithNestedCompositionEnums = { 770 + foo?: ModelWithNestedArrayEnumsDataFoo; 771 + }; 772 + 773 + export type ModelWithReadOnlyAndWriteOnly = { 774 + foo: string; 775 + readonly bar: string; 776 + }; 777 + 778 + export type ModelWithConstantSizeArray = [ 779 + number, 780 + number 781 + ]; 782 + 783 + export type ModelWithAnyOfConstantSizeArray = [ 784 + number | string, 785 + number | string, 786 + number | string 787 + ]; 788 + 789 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 790 + 791 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 792 + number | null | string, 793 + number | null | string, 794 + number | null | string 795 + ]; 796 + 797 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 798 + number | Import, 799 + number | Import 800 + ]; 801 + 802 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 803 + number & string, 804 + number & string 805 + ]; 806 + 807 + export type ModelWithNumericEnumUnion = { 808 + /** 809 + * Период 810 + */ 811 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 812 + }; 813 + 814 + /** 815 + * Some description with `back ticks` 816 + */ 817 + export type ModelWithBackticksInDescription = { 818 + /** 819 + * The template `that` should be used for parsing and importing the contents of the CSV file. 820 + * 821 + * <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> 822 + * <pre> 823 + * [ 824 + * { 825 + * "resourceType": "Asset", 826 + * "identifier": { 827 + * "name": "${1}", 828 + * "domain": { 829 + * "name": "${2}", 830 + * "community": { 831 + * "name": "Some Community" 832 + * } 833 + * } 834 + * }, 835 + * "attributes" : { 836 + * "00000000-0000-0000-0000-000000003115" : [ { 837 + * "value" : "${3}" 838 + * } ], 839 + * "00000000-0000-0000-0000-000000000222" : [ { 840 + * "value" : "${4}" 841 + * } ] 842 + * } 843 + * } 844 + * ] 845 + * </pre> 846 + */ 847 + template?: string; 848 + }; 849 + 850 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 851 + baz: number | null; 852 + qux: number; 853 + }; 854 + 855 + /** 856 + * Model used to test deduplication strategy (unused) 857 + */ 858 + export type ParameterSimpleParameterUnused = string; 859 + 860 + /** 861 + * Model used to test deduplication strategy 862 + */ 863 + export type PostServiceWithEmptyTagResponse = string; 864 + 865 + /** 866 + * Model used to test deduplication strategy 867 + */ 868 + export type PostServiceWithEmptyTagResponse2 = string; 869 + 870 + /** 871 + * Model used to test deduplication strategy 872 + */ 873 + export type DeleteFooData = string; 874 + 875 + /** 876 + * Model used to test deduplication strategy 877 + */ 878 + export type DeleteFooData2 = string; 879 + 880 + /** 881 + * Model with restricted keyword name 882 + */ 883 + export type Import = string; 884 + 885 + export type SchemaWithFormRestrictedKeys = { 886 + description?: string; 887 + 'x-enum-descriptions'?: string; 888 + 'x-enum-varnames'?: string; 889 + 'x-enumNames'?: string; 890 + title?: string; 891 + object?: { 892 + description?: string; 893 + 'x-enum-descriptions'?: string; 894 + 'x-enum-varnames'?: string; 895 + 'x-enumNames'?: string; 896 + title?: string; 897 + }; 898 + array?: Array<{ 899 + description?: string; 900 + 'x-enum-descriptions'?: string; 901 + 'x-enum-varnames'?: string; 902 + 'x-enumNames'?: string; 903 + title?: string; 904 + }>; 905 + }; 906 + 907 + /** 908 + * This schema was giving PascalCase transformations a hard time 909 + */ 910 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 911 + /** 912 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 913 + */ 914 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 915 + }; 916 + 917 + /** 918 + * This schema was giving PascalCase transformations a hard time 919 + */ 920 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 921 + /** 922 + * Specifies the target ResourceVersion 923 + */ 924 + resourceVersion?: string; 925 + /** 926 + * Specifies the target UID. 927 + */ 928 + uid?: string; 929 + }; 930 + 931 + export type AdditionalPropertiesUnknownIssue = { 932 + [key: string]: string | number; 933 + }; 934 + 935 + export type AdditionalPropertiesUnknownIssue2 = { 936 + [key: string]: string | number; 937 + }; 938 + 939 + export type AdditionalPropertiesUnknownIssue3 = string & { 940 + entries: { 941 + [key: string]: AdditionalPropertiesUnknownIssue; 942 + }; 943 + }; 944 + 945 + export type AdditionalPropertiesIntegerIssue = { 946 + value: number; 947 + [key: string]: number; 948 + }; 949 + 950 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 951 + 952 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 953 + item?: boolean; 954 + error?: string | null; 955 + readonly hasError?: boolean; 956 + data?: { 957 + [key: string]: never; 958 + }; 959 + }; 960 + 961 + export type GenericSchemaDuplicateIssue1SystemString = { 962 + item?: string | null; 963 + error?: string | null; 964 + readonly hasError?: boolean; 965 + }; 966 + 967 + export type ExternalSharedModel = { 968 + id: string; 969 + name?: string; 970 + }; 971 + 972 + /** 973 + * This is a model with one property containing a reference 974 + */ 975 + export type ModelWithReferenceWritable = { 976 + prop?: ModelWithPropertiesWritable; 977 + }; 978 + 979 + /** 980 + * This is a model with one property containing an array 981 + */ 982 + export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { 983 + prop?: Array<ModelWithReadOnlyAndWriteOnlyWritable>; 984 + propWithFile?: Array<Blob | File>; 985 + propWithNumber?: Array<number>; 986 + }; 987 + 988 + /** 989 + * This is a model with one nested property 990 + */ 991 + export type ModelWithPropertiesWritable = { 992 + required: string; 993 + requiredAndNullable: string | null; 994 + string?: string; 995 + number?: number; 996 + boolean?: boolean; 997 + reference?: ModelWithString; 998 + 'property with space'?: string; 999 + default?: string; 1000 + try?: string; 1001 + }; 1002 + 1003 + /** 1004 + * This is a model that contains a some patterns 1005 + */ 1006 + export type ModelWithPatternWritable = { 1007 + key: string; 1008 + name: string; 1009 + id?: string; 1010 + text?: string; 1011 + patternWithSingleQuotes?: string; 1012 + patternWithNewline?: string; 1013 + patternWithBacktick?: string; 1014 + }; 1015 + 1016 + export type FileWritable = { 1017 + /** 1018 + * Mime 1019 + */ 1020 + mime: string; 1021 + }; 1022 + 1023 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1024 + foo: string; 1025 + baz: string; 1026 + }; 1027 + 1028 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ 1029 + number | Import, 1030 + number | Import 1031 + ]; 1032 + 1033 + export type AdditionalPropertiesUnknownIssueWritable = { 1034 + [key: string]: string | number; 1035 + }; 1036 + 1037 + export type OneOfAllOfIssueWritable = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 1038 + 1039 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1040 + item?: boolean; 1041 + error?: string | null; 1042 + data?: { 1043 + [key: string]: never; 1044 + }; 1045 + }; 1046 + 1047 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1048 + item?: string | null; 1049 + error?: string | null; 1050 + }; 1051 + 1052 + /** 1053 + * This is a reusable parameter 1054 + */ 1055 + export type SimpleParameter = string; 1056 + 1057 + /** 1058 + * Parameter with illegal characters 1059 + */ 1060 + export type XFooBar = ModelWithString; 1061 + 1062 + export type SimpleRequestBody = ModelWithString; 1063 + 1064 + export type SimpleFormData = ModelWithString; 1065 + 1066 + export type ExportData = { 1067 + body?: never; 1068 + path?: never; 1069 + query?: never; 1070 + url: '/api/v{api-version}/no+tag'; 1071 + }; 1072 + 1073 + export type PatchApiVbyApiVersionNoTagData = { 1074 + body?: never; 1075 + path?: never; 1076 + query?: never; 1077 + url: '/api/v{api-version}/no+tag'; 1078 + }; 1079 + 1080 + export type PatchApiVbyApiVersionNoTagResponses = { 1081 + /** 1082 + * OK 1083 + */ 1084 + default: unknown; 1085 + }; 1086 + 1087 + export type ImportData = { 1088 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; 1089 + path?: never; 1090 + query?: never; 1091 + url: '/api/v{api-version}/no+tag'; 1092 + }; 1093 + 1094 + export type ImportResponses = { 1095 + /** 1096 + * Success 1097 + */ 1098 + 200: ModelFromZendesk; 1099 + /** 1100 + * Default success response 1101 + */ 1102 + default: ModelWithReadOnlyAndWriteOnly; 1103 + }; 1104 + 1105 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1106 + 1107 + export type FooWowData = { 1108 + body?: never; 1109 + path?: never; 1110 + query?: never; 1111 + url: '/api/v{api-version}/no+tag'; 1112 + }; 1113 + 1114 + export type FooWowResponses = { 1115 + /** 1116 + * OK 1117 + */ 1118 + default: unknown; 1119 + }; 1120 + 1121 + export type ApiVVersionODataControllerCountData = { 1122 + body?: never; 1123 + path?: never; 1124 + query?: never; 1125 + url: '/api/v{api-version}/simple/$count'; 1126 + }; 1127 + 1128 + export type ApiVVersionODataControllerCountResponses = { 1129 + /** 1130 + * Success 1131 + */ 1132 + 200: ModelFromZendesk; 1133 + }; 1134 + 1135 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1136 + 1137 + export type GetApiVbyApiVersionSimpleOperationData = { 1138 + body?: never; 1139 + path: { 1140 + /** 1141 + * foo in method 1142 + */ 1143 + foo_param: string; 1144 + }; 1145 + query?: never; 1146 + url: '/api/v{api-version}/simple:operation'; 1147 + }; 1148 + 1149 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1150 + /** 1151 + * Default error response 1152 + */ 1153 + default: ModelWithBoolean; 1154 + }; 1155 + 1156 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1157 + 1158 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1159 + /** 1160 + * Response is a simple number 1161 + */ 1162 + 200: number; 1163 + }; 1164 + 1165 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1166 + 1167 + export type DeleteCallWithoutParametersAndResponseData = { 1168 + body?: never; 1169 + path?: never; 1170 + query?: never; 1171 + url: '/api/v{api-version}/simple'; 1172 + }; 1173 + 1174 + export type GetCallWithoutParametersAndResponseData = { 1175 + body?: never; 1176 + path?: never; 1177 + query?: never; 1178 + url: '/api/v{api-version}/simple'; 1179 + }; 1180 + 1181 + export type HeadCallWithoutParametersAndResponseData = { 1182 + body?: never; 1183 + path?: never; 1184 + query?: never; 1185 + url: '/api/v{api-version}/simple'; 1186 + }; 1187 + 1188 + export type OptionsCallWithoutParametersAndResponseData = { 1189 + body?: never; 1190 + path?: never; 1191 + query?: never; 1192 + url: '/api/v{api-version}/simple'; 1193 + }; 1194 + 1195 + export type PatchCallWithoutParametersAndResponseData = { 1196 + body?: never; 1197 + path?: never; 1198 + query?: never; 1199 + url: '/api/v{api-version}/simple'; 1200 + }; 1201 + 1202 + export type PostCallWithoutParametersAndResponseData = { 1203 + body?: never; 1204 + path?: never; 1205 + query?: never; 1206 + url: '/api/v{api-version}/simple'; 1207 + }; 1208 + 1209 + export type PutCallWithoutParametersAndResponseData = { 1210 + body?: never; 1211 + path?: never; 1212 + query?: never; 1213 + url: '/api/v{api-version}/simple'; 1214 + }; 1215 + 1216 + export type DeleteFooData3 = { 1217 + body?: never; 1218 + headers: { 1219 + /** 1220 + * Parameter with illegal characters 1221 + */ 1222 + 'x-Foo-Bar': ModelWithString; 1223 + }; 1224 + path: { 1225 + /** 1226 + * foo in method 1227 + */ 1228 + foo_param: string; 1229 + /** 1230 + * bar in method 1231 + */ 1232 + BarParam: string; 1233 + }; 1234 + query?: never; 1235 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1236 + }; 1237 + 1238 + export type CallWithDescriptionsData = { 1239 + body?: never; 1240 + path?: never; 1241 + query?: { 1242 + /** 1243 + * Testing multiline comments in string: First line 1244 + * Second line 1245 + * 1246 + * Fourth line 1247 + */ 1248 + parameterWithBreaks?: string; 1249 + /** 1250 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1251 + */ 1252 + parameterWithBackticks?: string; 1253 + /** 1254 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1255 + */ 1256 + parameterWithSlashes?: string; 1257 + /** 1258 + * Testing expression placeholders in string: ${expression} should work 1259 + */ 1260 + parameterWithExpressionPlaceholders?: string; 1261 + /** 1262 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1263 + */ 1264 + parameterWithQuotes?: string; 1265 + /** 1266 + * Testing reserved characters in string: * inline * and ** inline ** should work 1267 + */ 1268 + parameterWithReservedCharacters?: string; 1269 + }; 1270 + url: '/api/v{api-version}/descriptions'; 1271 + }; 1272 + 1273 + export type DeprecatedCallData = { 1274 + body?: never; 1275 + headers: { 1276 + /** 1277 + * This parameter is deprecated 1278 + * 1279 + * @deprecated 1280 + */ 1281 + parameter: DeprecatedModel | null; 1282 + }; 1283 + path?: never; 1284 + query?: never; 1285 + url: '/api/v{api-version}/parameters/deprecated'; 1286 + }; 1287 + 1288 + export type CallWithParametersData = { 1289 + /** 1290 + * This is the parameter that goes into the body 1291 + */ 1292 + body: { 1293 + [key: string]: unknown; 1294 + } | null; 1295 + headers: { 1296 + /** 1297 + * This is the parameter that goes into the header 1298 + */ 1299 + parameterHeader: string | null; 1300 + }; 1301 + path: { 1302 + /** 1303 + * This is the parameter that goes into the path 1304 + */ 1305 + parameterPath: string | null; 1306 + /** 1307 + * api-version should be required in standalone clients 1308 + */ 1309 + 'api-version': string | null; 1310 + }; 1311 + query: { 1312 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1313 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1314 + /** 1315 + * This is the parameter that goes into the query params 1316 + */ 1317 + cursor: string | null; 1318 + }; 1319 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1320 + }; 1321 + 1322 + export type CallWithWeirdParameterNamesData = { 1323 + /** 1324 + * This is the parameter that goes into the body 1325 + */ 1326 + body: ModelWithString | null; 1327 + headers: { 1328 + /** 1329 + * This is the parameter that goes into the request header 1330 + */ 1331 + 'parameter.header': string | null; 1332 + }; 1333 + path: { 1334 + /** 1335 + * This is the parameter that goes into the path 1336 + */ 1337 + 'parameter.path.1'?: string; 1338 + /** 1339 + * This is the parameter that goes into the path 1340 + */ 1341 + 'parameter-path-2'?: string; 1342 + /** 1343 + * This is the parameter that goes into the path 1344 + */ 1345 + 'PARAMETER-PATH-3'?: string; 1346 + /** 1347 + * api-version should be required in standalone clients 1348 + */ 1349 + 'api-version': string | null; 1350 + }; 1351 + query: { 1352 + /** 1353 + * This is the parameter with a reserved keyword 1354 + */ 1355 + default?: string; 1356 + /** 1357 + * This is the parameter that goes into the request query params 1358 + */ 1359 + 'parameter-query': string | null; 1360 + }; 1361 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1362 + }; 1363 + 1364 + export type GetCallWithOptionalParamData = { 1365 + /** 1366 + * This is a required parameter 1367 + */ 1368 + body: ModelWithOneOfEnum; 1369 + path?: never; 1370 + query?: { 1371 + /** 1372 + * This is an optional parameter 1373 + */ 1374 + page?: number; 1375 + }; 1376 + url: '/api/v{api-version}/parameters'; 1377 + }; 1378 + 1379 + export type PostCallWithOptionalParamData = { 1380 + /** 1381 + * This is an optional parameter 1382 + */ 1383 + body?: { 1384 + offset?: number | null; 1385 + }; 1386 + path?: never; 1387 + query: { 1388 + /** 1389 + * This is a required parameter 1390 + */ 1391 + parameter: Pageable; 1392 + }; 1393 + url: '/api/v{api-version}/parameters'; 1394 + }; 1395 + 1396 + export type PostCallWithOptionalParamResponses = { 1397 + /** 1398 + * Response is a simple number 1399 + */ 1400 + 200: number; 1401 + /** 1402 + * Success 1403 + */ 1404 + 204: void; 1405 + }; 1406 + 1407 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1408 + 1409 + export type PostApiVbyApiVersionRequestBodyData = { 1410 + /** 1411 + * A reusable request body 1412 + */ 1413 + body?: SimpleRequestBody; 1414 + path?: never; 1415 + query?: { 1416 + /** 1417 + * This is a reusable parameter 1418 + */ 1419 + parameter?: string; 1420 + }; 1421 + url: '/api/v{api-version}/requestBody'; 1422 + }; 1423 + 1424 + export type PostApiVbyApiVersionFormDataData = { 1425 + /** 1426 + * A reusable request body 1427 + */ 1428 + body?: SimpleFormData; 1429 + path?: never; 1430 + query?: { 1431 + /** 1432 + * This is a reusable parameter 1433 + */ 1434 + parameter?: string; 1435 + }; 1436 + url: '/api/v{api-version}/formData'; 1437 + }; 1438 + 1439 + export type CallWithDefaultParametersData = { 1440 + body?: never; 1441 + path?: never; 1442 + query?: { 1443 + /** 1444 + * This is a simple string with default value 1445 + */ 1446 + parameterString?: string | null; 1447 + /** 1448 + * This is a simple number with default value 1449 + */ 1450 + parameterNumber?: number | null; 1451 + /** 1452 + * This is a simple boolean with default value 1453 + */ 1454 + parameterBoolean?: boolean | null; 1455 + /** 1456 + * This is a simple enum with default value 1457 + */ 1458 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1459 + /** 1460 + * This is a simple model with default value 1461 + */ 1462 + parameterModel?: ModelWithString | null; 1463 + }; 1464 + url: '/api/v{api-version}/defaults'; 1465 + }; 1466 + 1467 + export type CallWithDefaultOptionalParametersData = { 1468 + body?: never; 1469 + path?: never; 1470 + query?: { 1471 + /** 1472 + * This is a simple string that is optional with default value 1473 + */ 1474 + parameterString?: string; 1475 + /** 1476 + * This is a simple number that is optional with default value 1477 + */ 1478 + parameterNumber?: number; 1479 + /** 1480 + * This is a simple boolean that is optional with default value 1481 + */ 1482 + parameterBoolean?: boolean; 1483 + /** 1484 + * This is a simple enum that is optional with default value 1485 + */ 1486 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1487 + /** 1488 + * This is a simple model that is optional with default value 1489 + */ 1490 + parameterModel?: ModelWithString; 1491 + }; 1492 + url: '/api/v{api-version}/defaults'; 1493 + }; 1494 + 1495 + export type CallToTestOrderOfParamsData = { 1496 + body?: never; 1497 + path?: never; 1498 + query: { 1499 + /** 1500 + * This is a optional string with default 1501 + */ 1502 + parameterOptionalStringWithDefault?: string; 1503 + /** 1504 + * This is a optional string with empty default 1505 + */ 1506 + parameterOptionalStringWithEmptyDefault?: string; 1507 + /** 1508 + * This is a optional string with no default 1509 + */ 1510 + parameterOptionalStringWithNoDefault?: string; 1511 + /** 1512 + * This is a string with default 1513 + */ 1514 + parameterStringWithDefault: string; 1515 + /** 1516 + * This is a string with empty default 1517 + */ 1518 + parameterStringWithEmptyDefault: string; 1519 + /** 1520 + * This is a string with no default 1521 + */ 1522 + parameterStringWithNoDefault: string; 1523 + /** 1524 + * This is a string that can be null with no default 1525 + */ 1526 + parameterStringNullableWithNoDefault?: string | null; 1527 + /** 1528 + * This is a string that can be null with default 1529 + */ 1530 + parameterStringNullableWithDefault?: string | null; 1531 + }; 1532 + url: '/api/v{api-version}/defaults'; 1533 + }; 1534 + 1535 + export type DuplicateNameData = { 1536 + body?: never; 1537 + path?: never; 1538 + query?: never; 1539 + url: '/api/v{api-version}/duplicate'; 1540 + }; 1541 + 1542 + export type DuplicateName2Data = { 1543 + body?: never; 1544 + path?: never; 1545 + query?: never; 1546 + url: '/api/v{api-version}/duplicate'; 1547 + }; 1548 + 1549 + export type DuplicateName3Data = { 1550 + body?: never; 1551 + path?: never; 1552 + query?: never; 1553 + url: '/api/v{api-version}/duplicate'; 1554 + }; 1555 + 1556 + export type DuplicateName4Data = { 1557 + body?: never; 1558 + path?: never; 1559 + query?: never; 1560 + url: '/api/v{api-version}/duplicate'; 1561 + }; 1562 + 1563 + export type CallWithNoContentResponseData = { 1564 + body?: never; 1565 + path?: never; 1566 + query?: never; 1567 + url: '/api/v{api-version}/no-content'; 1568 + }; 1569 + 1570 + export type CallWithNoContentResponseResponses = { 1571 + /** 1572 + * Success 1573 + */ 1574 + 204: void; 1575 + }; 1576 + 1577 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1578 + 1579 + export type CallWithResponseAndNoContentResponseData = { 1580 + body?: never; 1581 + path?: never; 1582 + query?: never; 1583 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1584 + }; 1585 + 1586 + export type CallWithResponseAndNoContentResponseResponses = { 1587 + /** 1588 + * Response is a simple number 1589 + */ 1590 + 200: number; 1591 + /** 1592 + * Success 1593 + */ 1594 + 204: void; 1595 + }; 1596 + 1597 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1598 + 1599 + export type DummyAData = { 1600 + body?: never; 1601 + path?: never; 1602 + query?: never; 1603 + url: '/api/v{api-version}/multiple-tags/a'; 1604 + }; 1605 + 1606 + export type DummyAResponses = { 1607 + 200: _400; 1608 + }; 1609 + 1610 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1611 + 1612 + export type DummyBData = { 1613 + body?: never; 1614 + path?: never; 1615 + query?: never; 1616 + url: '/api/v{api-version}/multiple-tags/b'; 1617 + }; 1618 + 1619 + export type DummyBResponses = { 1620 + /** 1621 + * Success 1622 + */ 1623 + 204: void; 1624 + }; 1625 + 1626 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1627 + 1628 + export type CallWithResponseData = { 1629 + body?: never; 1630 + path?: never; 1631 + query?: never; 1632 + url: '/api/v{api-version}/response'; 1633 + }; 1634 + 1635 + export type CallWithResponseResponses = { 1636 + default: Import; 1637 + }; 1638 + 1639 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1640 + 1641 + export type CallWithDuplicateResponsesData = { 1642 + body?: never; 1643 + path?: never; 1644 + query?: never; 1645 + url: '/api/v{api-version}/response'; 1646 + }; 1647 + 1648 + export type CallWithDuplicateResponsesErrors = { 1649 + /** 1650 + * Message for 500 error 1651 + */ 1652 + 500: ModelWithStringError; 1653 + /** 1654 + * Message for 501 error 1655 + */ 1656 + 501: ModelWithStringError; 1657 + /** 1658 + * Message for 502 error 1659 + */ 1660 + 502: ModelWithStringError; 1661 + /** 1662 + * Message for 4XX errors 1663 + */ 1664 + '4XX': DictionaryWithArray; 1665 + /** 1666 + * Default error response 1667 + */ 1668 + default: ModelWithBoolean; 1669 + }; 1670 + 1671 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1672 + 1673 + export type CallWithDuplicateResponsesResponses = { 1674 + /** 1675 + * Message for 200 response 1676 + */ 1677 + 200: ModelWithBoolean & ModelWithInteger; 1678 + /** 1679 + * Message for 201 response 1680 + */ 1681 + 201: ModelWithString; 1682 + /** 1683 + * Message for 202 response 1684 + */ 1685 + 202: ModelWithString; 1686 + }; 1687 + 1688 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1689 + 1690 + export type CallWithResponsesData = { 1691 + body?: never; 1692 + path?: never; 1693 + query?: never; 1694 + url: '/api/v{api-version}/response'; 1695 + }; 1696 + 1697 + export type CallWithResponsesErrors = { 1698 + /** 1699 + * Message for 500 error 1700 + */ 1701 + 500: ModelWithStringError; 1702 + /** 1703 + * Message for 501 error 1704 + */ 1705 + 501: ModelWithStringError; 1706 + /** 1707 + * Message for 502 error 1708 + */ 1709 + 502: ModelWithStringError; 1710 + /** 1711 + * Message for default response 1712 + */ 1713 + default: ModelWithStringError; 1714 + }; 1715 + 1716 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1717 + 1718 + export type CallWithResponsesResponses = { 1719 + /** 1720 + * Message for 200 response 1721 + */ 1722 + 200: { 1723 + readonly '@namespace.string'?: string; 1724 + readonly '@namespace.integer'?: number; 1725 + readonly value?: Array<ModelWithString>; 1726 + }; 1727 + /** 1728 + * Message for 201 response 1729 + */ 1730 + 201: ModelThatExtends; 1731 + /** 1732 + * Message for 202 response 1733 + */ 1734 + 202: ModelThatExtendsExtends; 1735 + }; 1736 + 1737 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1738 + 1739 + export type CollectionFormatData = { 1740 + body?: never; 1741 + path?: never; 1742 + query: { 1743 + /** 1744 + * This is an array parameter that is sent as csv format (comma-separated values) 1745 + */ 1746 + parameterArrayCSV: Array<string> | null; 1747 + /** 1748 + * This is an array parameter that is sent as ssv format (space-separated values) 1749 + */ 1750 + parameterArraySSV: Array<string> | null; 1751 + /** 1752 + * This is an array parameter that is sent as tsv format (tab-separated values) 1753 + */ 1754 + parameterArrayTSV: Array<string> | null; 1755 + /** 1756 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1757 + */ 1758 + parameterArrayPipes: Array<string> | null; 1759 + /** 1760 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1761 + */ 1762 + parameterArrayMulti: Array<string> | null; 1763 + }; 1764 + url: '/api/v{api-version}/collectionFormat'; 1765 + }; 1766 + 1767 + export type TypesData = { 1768 + body?: never; 1769 + path?: { 1770 + /** 1771 + * This is a number parameter 1772 + */ 1773 + id?: number; 1774 + }; 1775 + query: { 1776 + /** 1777 + * This is a number parameter 1778 + */ 1779 + parameterNumber: number; 1780 + /** 1781 + * This is a string parameter 1782 + */ 1783 + parameterString: string | null; 1784 + /** 1785 + * This is a boolean parameter 1786 + */ 1787 + parameterBoolean: boolean | null; 1788 + /** 1789 + * This is an object parameter 1790 + */ 1791 + parameterObject: { 1792 + [key: string]: unknown; 1793 + } | null; 1794 + /** 1795 + * This is an array parameter 1796 + */ 1797 + parameterArray: Array<string> | null; 1798 + /** 1799 + * This is a dictionary parameter 1800 + */ 1801 + parameterDictionary: { 1802 + [key: string]: unknown; 1803 + } | null; 1804 + /** 1805 + * This is an enum parameter 1806 + */ 1807 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1808 + }; 1809 + url: '/api/v{api-version}/types'; 1810 + }; 1811 + 1812 + export type TypesResponses = { 1813 + /** 1814 + * Response is a simple number 1815 + */ 1816 + 200: number; 1817 + /** 1818 + * Response is a simple string 1819 + */ 1820 + 201: string; 1821 + /** 1822 + * Response is a simple boolean 1823 + */ 1824 + 202: boolean; 1825 + /** 1826 + * Response is a simple object 1827 + */ 1828 + 203: { 1829 + [key: string]: unknown; 1830 + }; 1831 + }; 1832 + 1833 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1834 + 1835 + export type UploadFileData = { 1836 + body: Blob | File; 1837 + path: { 1838 + /** 1839 + * api-version should be required in standalone clients 1840 + */ 1841 + 'api-version': string | null; 1842 + }; 1843 + query?: never; 1844 + url: '/api/v{api-version}/upload'; 1845 + }; 1846 + 1847 + export type UploadFileResponses = { 1848 + 200: boolean; 1849 + }; 1850 + 1851 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1852 + 1853 + export type FileResponseData = { 1854 + body?: never; 1855 + path: { 1856 + id: string; 1857 + /** 1858 + * api-version should be required in standalone clients 1859 + */ 1860 + 'api-version': string; 1861 + }; 1862 + query?: never; 1863 + url: '/api/v{api-version}/file/{id}'; 1864 + }; 1865 + 1866 + export type FileResponseResponses = { 1867 + /** 1868 + * Success 1869 + */ 1870 + 200: Blob | File; 1871 + }; 1872 + 1873 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1874 + 1875 + export type ComplexTypesData = { 1876 + body?: never; 1877 + path?: never; 1878 + query: { 1879 + /** 1880 + * Parameter containing object 1881 + */ 1882 + parameterObject: { 1883 + first?: { 1884 + second?: { 1885 + third?: string; 1886 + }; 1887 + }; 1888 + }; 1889 + /** 1890 + * Parameter containing reference 1891 + */ 1892 + parameterReference: ModelWithString; 1893 + }; 1894 + url: '/api/v{api-version}/complex'; 1895 + }; 1896 + 1897 + export type ComplexTypesErrors = { 1898 + /** 1899 + * 400 `server` error 1900 + */ 1901 + 400: unknown; 1902 + /** 1903 + * 500 server error 1904 + */ 1905 + 500: unknown; 1906 + }; 1907 + 1908 + export type ComplexTypesResponses = { 1909 + /** 1910 + * Successful response 1911 + */ 1912 + 200: Array<ModelWithString>; 1913 + }; 1914 + 1915 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1916 + 1917 + export type MultipartResponseData = { 1918 + body?: never; 1919 + path?: never; 1920 + query?: never; 1921 + url: '/api/v{api-version}/multipart'; 1922 + }; 1923 + 1924 + export type MultipartResponseResponses = { 1925 + /** 1926 + * OK 1927 + */ 1928 + 200: { 1929 + file?: Blob | File; 1930 + metadata?: { 1931 + foo?: string; 1932 + bar?: string; 1933 + }; 1934 + }; 1935 + }; 1936 + 1937 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1938 + 1939 + export type MultipartRequestData = { 1940 + body?: { 1941 + content?: Blob | File; 1942 + data?: ModelWithString | null; 1943 + }; 1944 + path?: never; 1945 + query?: never; 1946 + url: '/api/v{api-version}/multipart'; 1947 + }; 1948 + 1949 + export type ComplexParamsData = { 1950 + body?: { 1951 + readonly key: string | null; 1952 + name: string | null; 1953 + enabled?: boolean; 1954 + type: 'Monkey' | 'Horse' | 'Bird'; 1955 + listOfModels?: Array<ModelWithString> | null; 1956 + listOfStrings?: Array<string> | null; 1957 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1958 + readonly user?: { 1959 + readonly id?: number; 1960 + readonly name?: string | null; 1961 + }; 1962 + }; 1963 + path: { 1964 + id: number; 1965 + /** 1966 + * api-version should be required in standalone clients 1967 + */ 1968 + 'api-version': string; 1969 + }; 1970 + query?: never; 1971 + url: '/api/v{api-version}/complex/{id}'; 1972 + }; 1973 + 1974 + export type ComplexParamsResponses = { 1975 + /** 1976 + * Success 1977 + */ 1978 + 200: ModelWithString; 1979 + }; 1980 + 1981 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1982 + 1983 + export type CallWithResultFromHeaderData = { 1984 + body?: never; 1985 + path?: never; 1986 + query?: never; 1987 + url: '/api/v{api-version}/header'; 1988 + }; 1989 + 1990 + export type CallWithResultFromHeaderErrors = { 1991 + /** 1992 + * 400 server error 1993 + */ 1994 + 400: unknown; 1995 + /** 1996 + * 500 server error 1997 + */ 1998 + 500: unknown; 1999 + }; 2000 + 2001 + export type CallWithResultFromHeaderResponses = { 2002 + /** 2003 + * Successful response 2004 + */ 2005 + 200: unknown; 2006 + }; 2007 + 2008 + export type TestErrorCodeData = { 2009 + body?: never; 2010 + path?: never; 2011 + query: { 2012 + /** 2013 + * Status code to return 2014 + */ 2015 + status: number; 2016 + }; 2017 + url: '/api/v{api-version}/error'; 2018 + }; 2019 + 2020 + export type TestErrorCodeErrors = { 2021 + /** 2022 + * Custom message: Internal Server Error 2023 + */ 2024 + 500: unknown; 2025 + /** 2026 + * Custom message: Not Implemented 2027 + */ 2028 + 501: unknown; 2029 + /** 2030 + * Custom message: Bad Gateway 2031 + */ 2032 + 502: unknown; 2033 + /** 2034 + * Custom message: Service Unavailable 2035 + */ 2036 + 503: unknown; 2037 + }; 2038 + 2039 + export type TestErrorCodeResponses = { 2040 + /** 2041 + * Custom message: Successful response 2042 + */ 2043 + 200: unknown; 2044 + }; 2045 + 2046 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2047 + body?: never; 2048 + path?: never; 2049 + query: { 2050 + /** 2051 + * Dummy input param 2052 + */ 2053 + nonAsciiParamæøåÆØÅöôêÊ: number; 2054 + }; 2055 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2056 + }; 2057 + 2058 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2059 + /** 2060 + * Successful response 2061 + */ 2062 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2063 + }; 2064 + 2065 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2066 + 2067 + export type PutWithFormUrlEncodedData = { 2068 + body: ArrayWithStrings; 2069 + path?: never; 2070 + query?: never; 2071 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2072 + };
+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 usePatchApiVbyApiVersionNoTag = (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 useImport = (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 useFooWow = (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 useDeleteCallWithoutParametersAndResponse = (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 usePatchCallWithoutParametersAndResponse = (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 usePostCallWithoutParametersAndResponse = (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 usePutCallWithoutParametersAndResponse = (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 useDeleteFoo = (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 useCallWithDescriptions = (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 useDeprecatedCall = (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 useCallWithParameters = (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 useCallWithWeirdParameterNames = (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 usePostCallWithOptionalParam = (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 usePostApiVbyApiVersionRequestBody = (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 usePostApiVbyApiVersionFormData = (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 useCallWithDefaultOptionalParameters = (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 useCallToTestOrderOfParams = (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 useDuplicateName = (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 useDuplicateName3 = (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 useDuplicateName4 = (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 useCallWithDuplicateResponses = (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 useCallWithResponses = (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 useUploadFile = (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 useMultipartRequest = (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 useComplexParams = (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 useCallWithResultFromHeader = (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 useTestErrorCode = (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æøåÆøÅöôêÊ字符串 = (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 usePutWithFormUrlEncoded = (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, 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); 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 + };
+84
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: any) => any; 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: <T extends Record<string, any> | Array<Record<string, any>>>( 43 + body: T, 44 + ): FormData => { 45 + const data = new FormData(); 46 + 47 + Object.entries(body).forEach(([key, value]) => { 48 + if (value === undefined || value === null) { 49 + return; 50 + } 51 + if (Array.isArray(value)) { 52 + value.forEach((v) => serializeFormDataPair(data, key, v)); 53 + } else { 54 + serializeFormDataPair(data, key, value); 55 + } 56 + }); 57 + 58 + return data; 59 + }, 60 + }; 61 + 62 + export const jsonBodySerializer = { 63 + bodySerializer: <T>(body: T): string => 64 + JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 65 + }; 66 + 67 + export const urlSearchParamsBodySerializer = { 68 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => { 69 + const data = new URLSearchParams(); 70 + 71 + Object.entries(body).forEach(([key, value]) => { 72 + if (value === undefined || value === null) { 73 + return; 74 + } 75 + if (Array.isArray(value)) { 76 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 77 + } else { 78 + serializeUrlSearchParamsPair(data, key, value); 79 + } 80 + }); 81 + 82 + return data.toString(); 83 + }, 84 + };
+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' && !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, 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 + });
+2091
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 + }; 645 + 646 + export type File = { 647 + /** 648 + * Id 649 + */ 650 + readonly id?: string; 651 + /** 652 + * Updated at 653 + */ 654 + readonly updated_at?: string; 655 + /** 656 + * Created at 657 + */ 658 + readonly created_at?: string; 659 + /** 660 + * Mime 661 + */ 662 + mime: string; 663 + /** 664 + * File 665 + */ 666 + readonly file?: string; 667 + }; 668 + 669 + export type Default = { 670 + name?: string; 671 + }; 672 + 673 + export type Pageable = { 674 + page?: number; 675 + size?: number; 676 + sort?: Array<string>; 677 + }; 678 + 679 + /** 680 + * This is a free-form object without additionalProperties. 681 + */ 682 + export type FreeFormObjectWithoutAdditionalProperties = { 683 + [key: string]: unknown; 684 + }; 685 + 686 + /** 687 + * This is a free-form object with additionalProperties: true. 688 + */ 689 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 690 + [key: string]: unknown; 691 + }; 692 + 693 + /** 694 + * This is a free-form object with additionalProperties: {}. 695 + */ 696 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 697 + [key: string]: unknown; 698 + }; 699 + 700 + export type ModelWithConst = { 701 + String?: 'String'; 702 + number?: 0; 703 + null?: null; 704 + withType?: 'Some string'; 705 + }; 706 + 707 + /** 708 + * This is a model with one property and additionalProperties: true 709 + */ 710 + export type ModelWithAdditionalPropertiesEqTrue = { 711 + /** 712 + * This is a simple string property 713 + */ 714 + prop?: string; 715 + [key: string]: unknown | string | undefined; 716 + }; 717 + 718 + export type NestedAnyOfArraysNullable = { 719 + nullableArray?: Array<string | boolean> | null; 720 + }; 721 + 722 + export type CompositionWithOneOfAndProperties = ({ 723 + foo: SimpleParameter; 724 + } | { 725 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 726 + }) & { 727 + baz: number | null; 728 + qux: number; 729 + }; 730 + 731 + /** 732 + * An object that can be null 733 + */ 734 + export type NullableObject = { 735 + foo?: string; 736 + } | null; 737 + 738 + /** 739 + * Some % character 740 + */ 741 + export type CharactersInDescription = string; 742 + 743 + export type ModelWithNullableObject = { 744 + data?: NullableObject; 745 + }; 746 + 747 + export type ModelWithOneOfEnum = { 748 + foo: 'Bar'; 749 + } | { 750 + foo: 'Baz'; 751 + } | { 752 + foo: 'Qux'; 753 + } | { 754 + content: string; 755 + foo: 'Quux'; 756 + } | { 757 + content: [ 758 + string, 759 + string 760 + ]; 761 + foo: 'Corge'; 762 + }; 763 + 764 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 765 + 766 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 767 + 768 + export type ModelWithNestedArrayEnumsData = { 769 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 770 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 771 + }; 772 + 773 + export type ModelWithNestedArrayEnums = { 774 + array_strings?: Array<string>; 775 + data?: ModelWithNestedArrayEnumsData; 776 + }; 777 + 778 + export type ModelWithNestedCompositionEnums = { 779 + foo?: ModelWithNestedArrayEnumsDataFoo; 780 + }; 781 + 782 + export type ModelWithReadOnlyAndWriteOnly = { 783 + foo: string; 784 + readonly bar: string; 785 + }; 786 + 787 + export type ModelWithConstantSizeArray = [ 788 + number, 789 + number 790 + ]; 791 + 792 + export type ModelWithAnyOfConstantSizeArray = [ 793 + number | string, 794 + number | string, 795 + number | string 796 + ]; 797 + 798 + export type ModelWithPrefixItemsConstantSizeArray = [ 799 + ModelWithInteger, 800 + number | string, 801 + string 802 + ]; 803 + 804 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 805 + number | null | string, 806 + number | null | string, 807 + number | null | string 808 + ]; 809 + 810 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 811 + number | Import, 812 + number | Import 813 + ]; 814 + 815 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 816 + number & string, 817 + number & string 818 + ]; 819 + 820 + export type ModelWithNumericEnumUnion = { 821 + /** 822 + * Период 823 + */ 824 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 825 + }; 826 + 827 + /** 828 + * Some description with `back ticks` 829 + */ 830 + export type ModelWithBackticksInDescription = { 831 + /** 832 + * The template `that` should be used for parsing and importing the contents of the CSV file. 833 + * 834 + * <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> 835 + * <pre> 836 + * [ 837 + * { 838 + * "resourceType": "Asset", 839 + * "identifier": { 840 + * "name": "${1}", 841 + * "domain": { 842 + * "name": "${2}", 843 + * "community": { 844 + * "name": "Some Community" 845 + * } 846 + * } 847 + * }, 848 + * "attributes" : { 849 + * "00000000-0000-0000-0000-000000003115" : [ { 850 + * "value" : "${3}" 851 + * } ], 852 + * "00000000-0000-0000-0000-000000000222" : [ { 853 + * "value" : "${4}" 854 + * } ] 855 + * } 856 + * } 857 + * ] 858 + * </pre> 859 + */ 860 + template?: string; 861 + }; 862 + 863 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 864 + baz: number | null; 865 + qux: number; 866 + }; 867 + 868 + /** 869 + * Model used to test deduplication strategy (unused) 870 + */ 871 + export type ParameterSimpleParameterUnused = string; 872 + 873 + /** 874 + * Model used to test deduplication strategy 875 + */ 876 + export type PostServiceWithEmptyTagResponse = string; 877 + 878 + /** 879 + * Model used to test deduplication strategy 880 + */ 881 + export type PostServiceWithEmptyTagResponse2 = string; 882 + 883 + /** 884 + * Model used to test deduplication strategy 885 + */ 886 + export type DeleteFooData = string; 887 + 888 + /** 889 + * Model used to test deduplication strategy 890 + */ 891 + export type DeleteFooData2 = string; 892 + 893 + /** 894 + * Model with restricted keyword name 895 + */ 896 + export type Import = string; 897 + 898 + export type SchemaWithFormRestrictedKeys = { 899 + description?: string; 900 + 'x-enum-descriptions'?: string; 901 + 'x-enum-varnames'?: string; 902 + 'x-enumNames'?: string; 903 + title?: string; 904 + object?: { 905 + description?: string; 906 + 'x-enum-descriptions'?: string; 907 + 'x-enum-varnames'?: string; 908 + 'x-enumNames'?: string; 909 + title?: string; 910 + }; 911 + array?: Array<{ 912 + description?: string; 913 + 'x-enum-descriptions'?: string; 914 + 'x-enum-varnames'?: string; 915 + 'x-enumNames'?: string; 916 + title?: string; 917 + }>; 918 + }; 919 + 920 + /** 921 + * This schema was giving PascalCase transformations a hard time 922 + */ 923 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 924 + /** 925 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 926 + */ 927 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 928 + }; 929 + 930 + /** 931 + * This schema was giving PascalCase transformations a hard time 932 + */ 933 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 934 + /** 935 + * Specifies the target ResourceVersion 936 + */ 937 + resourceVersion?: string; 938 + /** 939 + * Specifies the target UID. 940 + */ 941 + uid?: string; 942 + }; 943 + 944 + export type AdditionalPropertiesUnknownIssue = { 945 + [key: string]: string | number; 946 + }; 947 + 948 + export type AdditionalPropertiesUnknownIssue2 = { 949 + [key: string]: string | number; 950 + }; 951 + 952 + export type AdditionalPropertiesUnknownIssue3 = string & { 953 + entries: { 954 + [key: string]: AdditionalPropertiesUnknownIssue; 955 + }; 956 + }; 957 + 958 + export type AdditionalPropertiesIntegerIssue = { 959 + value: number; 960 + [key: string]: number; 961 + }; 962 + 963 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 964 + 965 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 966 + item?: boolean; 967 + error?: string | null; 968 + readonly hasError?: boolean; 969 + data?: { 970 + [key: string]: never; 971 + }; 972 + }; 973 + 974 + export type GenericSchemaDuplicateIssue1SystemString = { 975 + item?: string | null; 976 + error?: string | null; 977 + readonly hasError?: boolean; 978 + }; 979 + 980 + export type ExternalSharedModel = { 981 + id: string; 982 + name?: string; 983 + }; 984 + 985 + /** 986 + * This is a model with one property containing a reference 987 + */ 988 + export type ModelWithReferenceWritable = { 989 + prop?: ModelWithPropertiesWritable; 990 + }; 991 + 992 + /** 993 + * This is a model with one property containing an array 994 + */ 995 + export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { 996 + prop?: Array<ModelWithReadOnlyAndWriteOnlyWritable>; 997 + propWithFile?: Array<Blob | File>; 998 + propWithNumber?: Array<number>; 999 + }; 1000 + 1001 + /** 1002 + * This is a model with one nested property 1003 + */ 1004 + export type ModelWithPropertiesWritable = { 1005 + required: string; 1006 + requiredAndNullable: string | null; 1007 + string?: string; 1008 + number?: number; 1009 + boolean?: boolean; 1010 + reference?: ModelWithString; 1011 + 'property with space'?: string; 1012 + default?: string; 1013 + try?: string; 1014 + }; 1015 + 1016 + /** 1017 + * This is a model that contains a some patterns 1018 + */ 1019 + export type ModelWithPatternWritable = { 1020 + key: string; 1021 + name: string; 1022 + id?: string; 1023 + text?: string; 1024 + patternWithSingleQuotes?: string; 1025 + patternWithNewline?: string; 1026 + patternWithBacktick?: string; 1027 + }; 1028 + 1029 + export type FileWritable = { 1030 + /** 1031 + * Mime 1032 + */ 1033 + mime: string; 1034 + }; 1035 + 1036 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1037 + foo: string; 1038 + baz: string; 1039 + }; 1040 + 1041 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ 1042 + number | Import, 1043 + number | Import 1044 + ]; 1045 + 1046 + export type AdditionalPropertiesUnknownIssueWritable = { 1047 + [key: string]: string | number; 1048 + }; 1049 + 1050 + export type OneOfAllOfIssueWritable = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 1051 + 1052 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1053 + item?: boolean; 1054 + error?: string | null; 1055 + data?: { 1056 + [key: string]: never; 1057 + }; 1058 + }; 1059 + 1060 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1061 + item?: string | null; 1062 + error?: string | null; 1063 + }; 1064 + 1065 + /** 1066 + * This is a reusable parameter 1067 + */ 1068 + export type SimpleParameter = string; 1069 + 1070 + /** 1071 + * Parameter with illegal characters 1072 + */ 1073 + export type XFooBar = ModelWithString; 1074 + 1075 + /** 1076 + * A reusable request body 1077 + */ 1078 + export type SimpleRequestBody = ModelWithString; 1079 + 1080 + /** 1081 + * A reusable request body 1082 + */ 1083 + export type SimpleFormData = ModelWithString; 1084 + 1085 + export type ExportData = { 1086 + body?: never; 1087 + path?: never; 1088 + query?: never; 1089 + url: '/api/v{api-version}/no+tag'; 1090 + }; 1091 + 1092 + export type PatchApiVbyApiVersionNoTagData = { 1093 + body?: never; 1094 + path?: never; 1095 + query?: never; 1096 + url: '/api/v{api-version}/no+tag'; 1097 + }; 1098 + 1099 + export type PatchApiVbyApiVersionNoTagResponses = { 1100 + /** 1101 + * OK 1102 + */ 1103 + default: unknown; 1104 + }; 1105 + 1106 + export type ImportData = { 1107 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; 1108 + path?: never; 1109 + query?: never; 1110 + url: '/api/v{api-version}/no+tag'; 1111 + }; 1112 + 1113 + export type ImportResponses = { 1114 + /** 1115 + * Success 1116 + */ 1117 + 200: ModelFromZendesk; 1118 + /** 1119 + * Default success response 1120 + */ 1121 + default: ModelWithReadOnlyAndWriteOnly; 1122 + }; 1123 + 1124 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1125 + 1126 + export type FooWowData = { 1127 + body?: never; 1128 + path?: never; 1129 + query?: never; 1130 + url: '/api/v{api-version}/no+tag'; 1131 + }; 1132 + 1133 + export type FooWowResponses = { 1134 + /** 1135 + * OK 1136 + */ 1137 + default: unknown; 1138 + }; 1139 + 1140 + export type ApiVVersionODataControllerCountData = { 1141 + body?: never; 1142 + path?: never; 1143 + query?: never; 1144 + url: '/api/v{api-version}/simple/$count'; 1145 + }; 1146 + 1147 + export type ApiVVersionODataControllerCountResponses = { 1148 + /** 1149 + * Success 1150 + */ 1151 + 200: ModelFromZendesk; 1152 + }; 1153 + 1154 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1155 + 1156 + export type GetApiVbyApiVersionSimpleOperationData = { 1157 + body?: never; 1158 + path: { 1159 + /** 1160 + * foo in method 1161 + */ 1162 + foo_param: string; 1163 + }; 1164 + query?: never; 1165 + url: '/api/v{api-version}/simple:operation'; 1166 + }; 1167 + 1168 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1169 + /** 1170 + * Default error response 1171 + */ 1172 + default: ModelWithBoolean; 1173 + }; 1174 + 1175 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1176 + 1177 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1178 + /** 1179 + * Response is a simple number 1180 + */ 1181 + 200: number; 1182 + }; 1183 + 1184 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1185 + 1186 + export type DeleteCallWithoutParametersAndResponseData = { 1187 + body?: never; 1188 + path?: never; 1189 + query?: never; 1190 + url: '/api/v{api-version}/simple'; 1191 + }; 1192 + 1193 + export type GetCallWithoutParametersAndResponseData = { 1194 + body?: never; 1195 + path?: never; 1196 + query?: never; 1197 + url: '/api/v{api-version}/simple'; 1198 + }; 1199 + 1200 + export type HeadCallWithoutParametersAndResponseData = { 1201 + body?: never; 1202 + path?: never; 1203 + query?: never; 1204 + url: '/api/v{api-version}/simple'; 1205 + }; 1206 + 1207 + export type OptionsCallWithoutParametersAndResponseData = { 1208 + body?: never; 1209 + path?: never; 1210 + query?: never; 1211 + url: '/api/v{api-version}/simple'; 1212 + }; 1213 + 1214 + export type PatchCallWithoutParametersAndResponseData = { 1215 + body?: never; 1216 + path?: never; 1217 + query?: never; 1218 + url: '/api/v{api-version}/simple'; 1219 + }; 1220 + 1221 + export type PostCallWithoutParametersAndResponseData = { 1222 + body?: never; 1223 + path?: never; 1224 + query?: never; 1225 + url: '/api/v{api-version}/simple'; 1226 + }; 1227 + 1228 + export type PutCallWithoutParametersAndResponseData = { 1229 + body?: never; 1230 + path?: never; 1231 + query?: never; 1232 + url: '/api/v{api-version}/simple'; 1233 + }; 1234 + 1235 + export type DeleteFooData3 = { 1236 + body?: never; 1237 + headers: { 1238 + /** 1239 + * Parameter with illegal characters 1240 + */ 1241 + 'x-Foo-Bar': ModelWithString; 1242 + }; 1243 + path: { 1244 + /** 1245 + * foo in method 1246 + */ 1247 + foo_param: string; 1248 + /** 1249 + * bar in method 1250 + */ 1251 + BarParam: string; 1252 + }; 1253 + query?: never; 1254 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1255 + }; 1256 + 1257 + export type CallWithDescriptionsData = { 1258 + body?: never; 1259 + path?: never; 1260 + query?: { 1261 + /** 1262 + * Testing multiline comments in string: First line 1263 + * Second line 1264 + * 1265 + * Fourth line 1266 + */ 1267 + parameterWithBreaks?: string; 1268 + /** 1269 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1270 + */ 1271 + parameterWithBackticks?: string; 1272 + /** 1273 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1274 + */ 1275 + parameterWithSlashes?: string; 1276 + /** 1277 + * Testing expression placeholders in string: ${expression} should work 1278 + */ 1279 + parameterWithExpressionPlaceholders?: string; 1280 + /** 1281 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1282 + */ 1283 + parameterWithQuotes?: string; 1284 + /** 1285 + * Testing reserved characters in string: * inline * and ** inline ** should work 1286 + */ 1287 + parameterWithReservedCharacters?: string; 1288 + }; 1289 + url: '/api/v{api-version}/descriptions'; 1290 + }; 1291 + 1292 + export type DeprecatedCallData = { 1293 + body?: never; 1294 + headers: { 1295 + /** 1296 + * This parameter is deprecated 1297 + * 1298 + * @deprecated 1299 + */ 1300 + parameter: DeprecatedModel | null; 1301 + }; 1302 + path?: never; 1303 + query?: never; 1304 + url: '/api/v{api-version}/parameters/deprecated'; 1305 + }; 1306 + 1307 + export type CallWithParametersData = { 1308 + /** 1309 + * This is the parameter that goes into the body 1310 + */ 1311 + body: { 1312 + [key: string]: unknown; 1313 + } | null; 1314 + headers: { 1315 + /** 1316 + * This is the parameter that goes into the header 1317 + */ 1318 + parameterHeader: string | null; 1319 + }; 1320 + path: { 1321 + /** 1322 + * This is the parameter that goes into the path 1323 + */ 1324 + parameterPath: string | null; 1325 + /** 1326 + * api-version should be required in standalone clients 1327 + */ 1328 + 'api-version': string | null; 1329 + }; 1330 + query: { 1331 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1332 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1333 + /** 1334 + * This is the parameter that goes into the query params 1335 + */ 1336 + cursor: string | null; 1337 + }; 1338 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1339 + }; 1340 + 1341 + export type CallWithWeirdParameterNamesData = { 1342 + /** 1343 + * This is the parameter that goes into the body 1344 + */ 1345 + body: ModelWithString | null; 1346 + headers: { 1347 + /** 1348 + * This is the parameter that goes into the request header 1349 + */ 1350 + 'parameter.header': string | null; 1351 + }; 1352 + path: { 1353 + /** 1354 + * This is the parameter that goes into the path 1355 + */ 1356 + 'parameter.path.1'?: string; 1357 + /** 1358 + * This is the parameter that goes into the path 1359 + */ 1360 + 'parameter-path-2'?: string; 1361 + /** 1362 + * This is the parameter that goes into the path 1363 + */ 1364 + 'PARAMETER-PATH-3'?: string; 1365 + /** 1366 + * api-version should be required in standalone clients 1367 + */ 1368 + 'api-version': string | null; 1369 + }; 1370 + query: { 1371 + /** 1372 + * This is the parameter with a reserved keyword 1373 + */ 1374 + default?: string; 1375 + /** 1376 + * This is the parameter that goes into the request query params 1377 + */ 1378 + 'parameter-query': string | null; 1379 + }; 1380 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1381 + }; 1382 + 1383 + export type GetCallWithOptionalParamData = { 1384 + /** 1385 + * This is a required parameter 1386 + */ 1387 + body: ModelWithOneOfEnum; 1388 + path?: never; 1389 + query?: { 1390 + /** 1391 + * This is an optional parameter 1392 + */ 1393 + page?: number; 1394 + }; 1395 + url: '/api/v{api-version}/parameters'; 1396 + }; 1397 + 1398 + export type PostCallWithOptionalParamData = { 1399 + /** 1400 + * This is an optional parameter 1401 + */ 1402 + body?: { 1403 + offset?: number | null; 1404 + }; 1405 + path?: never; 1406 + query: { 1407 + /** 1408 + * This is a required parameter 1409 + */ 1410 + parameter: Pageable; 1411 + }; 1412 + url: '/api/v{api-version}/parameters'; 1413 + }; 1414 + 1415 + export type PostCallWithOptionalParamResponses = { 1416 + /** 1417 + * Response is a simple number 1418 + */ 1419 + 200: number; 1420 + /** 1421 + * Success 1422 + */ 1423 + 204: void; 1424 + }; 1425 + 1426 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1427 + 1428 + export type PostApiVbyApiVersionRequestBodyData = { 1429 + /** 1430 + * A reusable request body 1431 + */ 1432 + body?: SimpleRequestBody; 1433 + path?: never; 1434 + query?: { 1435 + /** 1436 + * This is a reusable parameter 1437 + */ 1438 + parameter?: string; 1439 + }; 1440 + url: '/api/v{api-version}/requestBody'; 1441 + }; 1442 + 1443 + export type PostApiVbyApiVersionFormDataData = { 1444 + /** 1445 + * A reusable request body 1446 + */ 1447 + body?: SimpleFormData; 1448 + path?: never; 1449 + query?: { 1450 + /** 1451 + * This is a reusable parameter 1452 + */ 1453 + parameter?: string; 1454 + }; 1455 + url: '/api/v{api-version}/formData'; 1456 + }; 1457 + 1458 + export type CallWithDefaultParametersData = { 1459 + body?: never; 1460 + path?: never; 1461 + query?: { 1462 + /** 1463 + * This is a simple string with default value 1464 + */ 1465 + parameterString?: string | null; 1466 + /** 1467 + * This is a simple number with default value 1468 + */ 1469 + parameterNumber?: number | null; 1470 + /** 1471 + * This is a simple boolean with default value 1472 + */ 1473 + parameterBoolean?: boolean | null; 1474 + /** 1475 + * This is a simple enum with default value 1476 + */ 1477 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1478 + /** 1479 + * This is a simple model with default value 1480 + */ 1481 + parameterModel?: ModelWithString | null; 1482 + }; 1483 + url: '/api/v{api-version}/defaults'; 1484 + }; 1485 + 1486 + export type CallWithDefaultOptionalParametersData = { 1487 + body?: never; 1488 + path?: never; 1489 + query?: { 1490 + /** 1491 + * This is a simple string that is optional with default value 1492 + */ 1493 + parameterString?: string; 1494 + /** 1495 + * This is a simple number that is optional with default value 1496 + */ 1497 + parameterNumber?: number; 1498 + /** 1499 + * This is a simple boolean that is optional with default value 1500 + */ 1501 + parameterBoolean?: boolean; 1502 + /** 1503 + * This is a simple enum that is optional with default value 1504 + */ 1505 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1506 + /** 1507 + * This is a simple model that is optional with default value 1508 + */ 1509 + parameterModel?: ModelWithString; 1510 + }; 1511 + url: '/api/v{api-version}/defaults'; 1512 + }; 1513 + 1514 + export type CallToTestOrderOfParamsData = { 1515 + body?: never; 1516 + path?: never; 1517 + query: { 1518 + /** 1519 + * This is a optional string with default 1520 + */ 1521 + parameterOptionalStringWithDefault?: string; 1522 + /** 1523 + * This is a optional string with empty default 1524 + */ 1525 + parameterOptionalStringWithEmptyDefault?: string; 1526 + /** 1527 + * This is a optional string with no default 1528 + */ 1529 + parameterOptionalStringWithNoDefault?: string; 1530 + /** 1531 + * This is a string with default 1532 + */ 1533 + parameterStringWithDefault: string; 1534 + /** 1535 + * This is a string with empty default 1536 + */ 1537 + parameterStringWithEmptyDefault: string; 1538 + /** 1539 + * This is a string with no default 1540 + */ 1541 + parameterStringWithNoDefault: string; 1542 + /** 1543 + * This is a string that can be null with no default 1544 + */ 1545 + parameterStringNullableWithNoDefault?: string | null; 1546 + /** 1547 + * This is a string that can be null with default 1548 + */ 1549 + parameterStringNullableWithDefault?: string | null; 1550 + }; 1551 + url: '/api/v{api-version}/defaults'; 1552 + }; 1553 + 1554 + export type DuplicateNameData = { 1555 + body?: never; 1556 + path?: never; 1557 + query?: never; 1558 + url: '/api/v{api-version}/duplicate'; 1559 + }; 1560 + 1561 + export type DuplicateName2Data = { 1562 + body?: never; 1563 + path?: never; 1564 + query?: never; 1565 + url: '/api/v{api-version}/duplicate'; 1566 + }; 1567 + 1568 + export type DuplicateName3Data = { 1569 + body?: never; 1570 + path?: never; 1571 + query?: never; 1572 + url: '/api/v{api-version}/duplicate'; 1573 + }; 1574 + 1575 + export type DuplicateName4Data = { 1576 + body?: never; 1577 + path?: never; 1578 + query?: never; 1579 + url: '/api/v{api-version}/duplicate'; 1580 + }; 1581 + 1582 + export type CallWithNoContentResponseData = { 1583 + body?: never; 1584 + path?: never; 1585 + query?: never; 1586 + url: '/api/v{api-version}/no-content'; 1587 + }; 1588 + 1589 + export type CallWithNoContentResponseResponses = { 1590 + /** 1591 + * Success 1592 + */ 1593 + 204: void; 1594 + }; 1595 + 1596 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1597 + 1598 + export type CallWithResponseAndNoContentResponseData = { 1599 + body?: never; 1600 + path?: never; 1601 + query?: never; 1602 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1603 + }; 1604 + 1605 + export type CallWithResponseAndNoContentResponseResponses = { 1606 + /** 1607 + * Response is a simple number 1608 + */ 1609 + 200: number; 1610 + /** 1611 + * Success 1612 + */ 1613 + 204: void; 1614 + }; 1615 + 1616 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1617 + 1618 + export type DummyAData = { 1619 + body?: never; 1620 + path?: never; 1621 + query?: never; 1622 + url: '/api/v{api-version}/multiple-tags/a'; 1623 + }; 1624 + 1625 + export type DummyAResponses = { 1626 + 200: _400; 1627 + }; 1628 + 1629 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1630 + 1631 + export type DummyBData = { 1632 + body?: never; 1633 + path?: never; 1634 + query?: never; 1635 + url: '/api/v{api-version}/multiple-tags/b'; 1636 + }; 1637 + 1638 + export type DummyBResponses = { 1639 + /** 1640 + * Success 1641 + */ 1642 + 204: void; 1643 + }; 1644 + 1645 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1646 + 1647 + export type CallWithResponseData = { 1648 + body?: never; 1649 + path?: never; 1650 + query?: never; 1651 + url: '/api/v{api-version}/response'; 1652 + }; 1653 + 1654 + export type CallWithResponseResponses = { 1655 + default: Import; 1656 + }; 1657 + 1658 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1659 + 1660 + export type CallWithDuplicateResponsesData = { 1661 + body?: never; 1662 + path?: never; 1663 + query?: never; 1664 + url: '/api/v{api-version}/response'; 1665 + }; 1666 + 1667 + export type CallWithDuplicateResponsesErrors = { 1668 + /** 1669 + * Message for 500 error 1670 + */ 1671 + 500: ModelWithStringError; 1672 + /** 1673 + * Message for 501 error 1674 + */ 1675 + 501: ModelWithStringError; 1676 + /** 1677 + * Message for 502 error 1678 + */ 1679 + 502: ModelWithStringError; 1680 + /** 1681 + * Message for 4XX errors 1682 + */ 1683 + '4XX': DictionaryWithArray; 1684 + /** 1685 + * Default error response 1686 + */ 1687 + default: ModelWithBoolean; 1688 + }; 1689 + 1690 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1691 + 1692 + export type CallWithDuplicateResponsesResponses = { 1693 + /** 1694 + * Message for 200 response 1695 + */ 1696 + 200: ModelWithBoolean & ModelWithInteger; 1697 + /** 1698 + * Message for 201 response 1699 + */ 1700 + 201: ModelWithString; 1701 + /** 1702 + * Message for 202 response 1703 + */ 1704 + 202: ModelWithString; 1705 + }; 1706 + 1707 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1708 + 1709 + export type CallWithResponsesData = { 1710 + body?: never; 1711 + path?: never; 1712 + query?: never; 1713 + url: '/api/v{api-version}/response'; 1714 + }; 1715 + 1716 + export type CallWithResponsesErrors = { 1717 + /** 1718 + * Message for 500 error 1719 + */ 1720 + 500: ModelWithStringError; 1721 + /** 1722 + * Message for 501 error 1723 + */ 1724 + 501: ModelWithStringError; 1725 + /** 1726 + * Message for 502 error 1727 + */ 1728 + 502: ModelWithStringError; 1729 + /** 1730 + * Message for default response 1731 + */ 1732 + default: ModelWithStringError; 1733 + }; 1734 + 1735 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1736 + 1737 + export type CallWithResponsesResponses = { 1738 + /** 1739 + * Message for 200 response 1740 + */ 1741 + 200: { 1742 + readonly '@namespace.string'?: string; 1743 + readonly '@namespace.integer'?: number; 1744 + readonly value?: Array<ModelWithString>; 1745 + }; 1746 + /** 1747 + * Message for 201 response 1748 + */ 1749 + 201: ModelThatExtends; 1750 + /** 1751 + * Message for 202 response 1752 + */ 1753 + 202: ModelThatExtendsExtends; 1754 + }; 1755 + 1756 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1757 + 1758 + export type CollectionFormatData = { 1759 + body?: never; 1760 + path?: never; 1761 + query: { 1762 + /** 1763 + * This is an array parameter that is sent as csv format (comma-separated values) 1764 + */ 1765 + parameterArrayCSV: Array<string> | null; 1766 + /** 1767 + * This is an array parameter that is sent as ssv format (space-separated values) 1768 + */ 1769 + parameterArraySSV: Array<string> | null; 1770 + /** 1771 + * This is an array parameter that is sent as tsv format (tab-separated values) 1772 + */ 1773 + parameterArrayTSV: Array<string> | null; 1774 + /** 1775 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1776 + */ 1777 + parameterArrayPipes: Array<string> | null; 1778 + /** 1779 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1780 + */ 1781 + parameterArrayMulti: Array<string> | null; 1782 + }; 1783 + url: '/api/v{api-version}/collectionFormat'; 1784 + }; 1785 + 1786 + export type TypesData = { 1787 + body?: never; 1788 + path?: { 1789 + /** 1790 + * This is a number parameter 1791 + */ 1792 + id?: number; 1793 + }; 1794 + query: { 1795 + /** 1796 + * This is a number parameter 1797 + */ 1798 + parameterNumber: number; 1799 + /** 1800 + * This is a string parameter 1801 + */ 1802 + parameterString: string | null; 1803 + /** 1804 + * This is a boolean parameter 1805 + */ 1806 + parameterBoolean: boolean | null; 1807 + /** 1808 + * This is an object parameter 1809 + */ 1810 + parameterObject: { 1811 + [key: string]: unknown; 1812 + } | null; 1813 + /** 1814 + * This is an array parameter 1815 + */ 1816 + parameterArray: Array<string> | null; 1817 + /** 1818 + * This is a dictionary parameter 1819 + */ 1820 + parameterDictionary: { 1821 + [key: string]: unknown; 1822 + } | null; 1823 + /** 1824 + * This is an enum parameter 1825 + */ 1826 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1827 + }; 1828 + url: '/api/v{api-version}/types'; 1829 + }; 1830 + 1831 + export type TypesResponses = { 1832 + /** 1833 + * Response is a simple number 1834 + */ 1835 + 200: number; 1836 + /** 1837 + * Response is a simple string 1838 + */ 1839 + 201: string; 1840 + /** 1841 + * Response is a simple boolean 1842 + */ 1843 + 202: boolean; 1844 + /** 1845 + * Response is a simple object 1846 + */ 1847 + 203: { 1848 + [key: string]: unknown; 1849 + }; 1850 + }; 1851 + 1852 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1853 + 1854 + export type UploadFileData = { 1855 + body: Blob | File; 1856 + path: { 1857 + /** 1858 + * api-version should be required in standalone clients 1859 + */ 1860 + 'api-version': string | null; 1861 + }; 1862 + query?: never; 1863 + url: '/api/v{api-version}/upload'; 1864 + }; 1865 + 1866 + export type UploadFileResponses = { 1867 + 200: boolean; 1868 + }; 1869 + 1870 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1871 + 1872 + export type FileResponseData = { 1873 + body?: never; 1874 + path: { 1875 + id: string; 1876 + /** 1877 + * api-version should be required in standalone clients 1878 + */ 1879 + 'api-version': string; 1880 + }; 1881 + query?: never; 1882 + url: '/api/v{api-version}/file/{id}'; 1883 + }; 1884 + 1885 + export type FileResponseResponses = { 1886 + /** 1887 + * Success 1888 + */ 1889 + 200: Blob | File; 1890 + }; 1891 + 1892 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1893 + 1894 + export type ComplexTypesData = { 1895 + body?: never; 1896 + path?: never; 1897 + query: { 1898 + /** 1899 + * Parameter containing object 1900 + */ 1901 + parameterObject: { 1902 + first?: { 1903 + second?: { 1904 + third?: string; 1905 + }; 1906 + }; 1907 + }; 1908 + /** 1909 + * Parameter containing reference 1910 + */ 1911 + parameterReference: ModelWithString; 1912 + }; 1913 + url: '/api/v{api-version}/complex'; 1914 + }; 1915 + 1916 + export type ComplexTypesErrors = { 1917 + /** 1918 + * 400 `server` error 1919 + */ 1920 + 400: unknown; 1921 + /** 1922 + * 500 server error 1923 + */ 1924 + 500: unknown; 1925 + }; 1926 + 1927 + export type ComplexTypesResponses = { 1928 + /** 1929 + * Successful response 1930 + */ 1931 + 200: Array<ModelWithString>; 1932 + }; 1933 + 1934 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1935 + 1936 + export type MultipartResponseData = { 1937 + body?: never; 1938 + path?: never; 1939 + query?: never; 1940 + url: '/api/v{api-version}/multipart'; 1941 + }; 1942 + 1943 + export type MultipartResponseResponses = { 1944 + /** 1945 + * OK 1946 + */ 1947 + 200: { 1948 + file?: Blob | File; 1949 + metadata?: { 1950 + foo?: string; 1951 + bar?: string; 1952 + }; 1953 + }; 1954 + }; 1955 + 1956 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1957 + 1958 + export type MultipartRequestData = { 1959 + body?: { 1960 + content?: Blob | File; 1961 + data?: ModelWithString | null; 1962 + }; 1963 + path?: never; 1964 + query?: never; 1965 + url: '/api/v{api-version}/multipart'; 1966 + }; 1967 + 1968 + export type ComplexParamsData = { 1969 + body?: { 1970 + readonly key: string | null; 1971 + name: string | null; 1972 + enabled?: boolean; 1973 + type: 'Monkey' | 'Horse' | 'Bird'; 1974 + listOfModels?: Array<ModelWithString> | null; 1975 + listOfStrings?: Array<string> | null; 1976 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1977 + readonly user?: { 1978 + readonly id?: number; 1979 + readonly name?: string | null; 1980 + }; 1981 + }; 1982 + path: { 1983 + id: number; 1984 + /** 1985 + * api-version should be required in standalone clients 1986 + */ 1987 + 'api-version': string; 1988 + }; 1989 + query?: never; 1990 + url: '/api/v{api-version}/complex/{id}'; 1991 + }; 1992 + 1993 + export type ComplexParamsResponses = { 1994 + /** 1995 + * Success 1996 + */ 1997 + 200: ModelWithString; 1998 + }; 1999 + 2000 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 2001 + 2002 + export type CallWithResultFromHeaderData = { 2003 + body?: never; 2004 + path?: never; 2005 + query?: never; 2006 + url: '/api/v{api-version}/header'; 2007 + }; 2008 + 2009 + export type CallWithResultFromHeaderErrors = { 2010 + /** 2011 + * 400 server error 2012 + */ 2013 + 400: unknown; 2014 + /** 2015 + * 500 server error 2016 + */ 2017 + 500: unknown; 2018 + }; 2019 + 2020 + export type CallWithResultFromHeaderResponses = { 2021 + /** 2022 + * Successful response 2023 + */ 2024 + 200: unknown; 2025 + }; 2026 + 2027 + export type TestErrorCodeData = { 2028 + body?: never; 2029 + path?: never; 2030 + query: { 2031 + /** 2032 + * Status code to return 2033 + */ 2034 + status: number; 2035 + }; 2036 + url: '/api/v{api-version}/error'; 2037 + }; 2038 + 2039 + export type TestErrorCodeErrors = { 2040 + /** 2041 + * Custom message: Internal Server Error 2042 + */ 2043 + 500: unknown; 2044 + /** 2045 + * Custom message: Not Implemented 2046 + */ 2047 + 501: unknown; 2048 + /** 2049 + * Custom message: Bad Gateway 2050 + */ 2051 + 502: unknown; 2052 + /** 2053 + * Custom message: Service Unavailable 2054 + */ 2055 + 503: unknown; 2056 + }; 2057 + 2058 + export type TestErrorCodeResponses = { 2059 + /** 2060 + * Custom message: Successful response 2061 + */ 2062 + 200: unknown; 2063 + }; 2064 + 2065 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2066 + body?: never; 2067 + path?: never; 2068 + query: { 2069 + /** 2070 + * Dummy input param 2071 + */ 2072 + nonAsciiParamæøåÆØÅöôêÊ: number; 2073 + }; 2074 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2075 + }; 2076 + 2077 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2078 + /** 2079 + * Successful response 2080 + */ 2081 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2082 + }; 2083 + 2084 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2085 + 2086 + export type PutWithFormUrlEncodedData = { 2087 + body: ArrayWithStrings; 2088 + path?: never; 2089 + query?: never; 2090 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2091 + };
+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
··· 59 59 }, 60 60 ); 61 61 const statement = $.const(symbolMutationOptions) 62 - .export() 62 + .export(plugin.config.mutationOptions.exported) 63 63 .$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)) 64 64 .assign( 65 65 $.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 }) => { ··· 56 57 resource: `${plugin.name}.useQuery`, 57 58 }, 58 59 }); 60 + plugin.symbol('useMutation', { 61 + external: plugin.name, 62 + meta: { 63 + category: 'external', 64 + resource: `${plugin.name}.useMutation`, 65 + }, 66 + }); 59 67 plugin.symbol('AxiosError', { 60 68 external: 'axios', 61 69 kind: 'type', ··· 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 },
+78
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 optionsParamName = 'options'; 10 + const mutationOptionsParamName = 'mutationOptions'; 11 + 12 + export const createUseMutation = ({ 13 + operation, 14 + plugin, 15 + }: { 16 + operation: IR.OperationObject; 17 + plugin: PluginInstance; 18 + }): void => { 19 + if (!('useMutation' in plugin.config)) { 20 + return; 21 + } 22 + 23 + const symbolUseMutationFn = plugin.symbol(applyNaming(operation.id, plugin.config.useMutation)); 24 + 25 + const symbolUseMutation = plugin.external(`${plugin.name}.useMutation`); 26 + 27 + const typeData = useTypeData({ operation, plugin }); 28 + 29 + const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`); 30 + const mutationType = $.type(symbolMutationOptionsType) 31 + .generic(useTypeResponse({ operation, plugin })) 32 + .generic(useTypeError({ operation, plugin })) 33 + .generic(typeData); 34 + 35 + const symbolMutationOptionsFn = plugin.referenceSymbol({ 36 + category: 'hook', 37 + resource: 'operation', 38 + resourceId: operation.id, 39 + role: 'mutationOptions', 40 + tool: plugin.name, 41 + }); 42 + const includeRequestOptions = 43 + 'useMutation' in plugin.config && plugin.config.useMutation.requestOptions; 44 + 45 + const func = $.func().param(mutationOptionsParamName, (p) => 46 + p 47 + .optional() 48 + .type( 49 + $.type('Partial').generic( 50 + $.type('Omit', (t) => t.generics(mutationType, $.type.literal('mutationFn'))), 51 + ), 52 + ), 53 + ); 54 + 55 + if (includeRequestOptions) { 56 + func.param(optionsParamName, (p) => p.optional().type($.type('Partial').generic(typeData))); 57 + } 58 + 59 + func.do( 60 + $(symbolUseMutation) 61 + .call( 62 + $.object() 63 + .spread( 64 + includeRequestOptions 65 + ? $(symbolMutationOptionsFn).call(optionsParamName) 66 + : $(symbolMutationOptionsFn).call(), 67 + ) 68 + .spread(mutationOptionsParamName), 69 + ) 70 + .return(), 71 + ); 72 + 73 + const statement = $.const(symbolUseMutationFn) 74 + .export() 75 + .$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)) 76 + .assign(func); 77 + plugin.node(statement); 78 + };
+24 -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}}', 75 + requestOptions: false, 76 + }, 77 + mappers: { 78 + boolean: (enabled) => ({ enabled }), 79 + function: (name) => ({ enabled: true, name }), 80 + object: (fields) => ({ enabled: true, ...fields }), 81 + string: (name) => ({ enabled: true, name }), 82 + }, 83 + value: plugin.config.useMutation, 84 + }); 85 + 69 86 plugin.config.useQuery = context.valueToObject({ 70 87 defaultValue: { 71 88 case: plugin.config.case ?? 'camelCase', ··· 81 98 value: plugin.config.useQuery, 82 99 }); 83 100 101 + if (plugin.config.useMutation.enabled) { 102 + if (!plugin.config.mutationOptions.enabled) { 103 + plugin.config.mutationOptions.enabled = true; 104 + plugin.config.mutationOptions.exported = false; 105 + } 106 + } 107 + 84 108 if (plugin.config.useQuery.enabled) { 85 - // useQuery hooks consume queryOptions 86 109 if (!plugin.config.queryOptions.enabled) { 87 110 plugin.config.queryOptions.enabled = true; 88 111 plugin.config.queryOptions.exported = false;
+46
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 * ··· 298 304 * 299 305 * @default false 300 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}}' 329 + */ 330 + name?: NameTransformer; 331 + /** 332 + * Include SDK request options as second parameter. 333 + * When `false` (default), hooks take `(mutationOptions?)`. 334 + * When `true`, hooks take `(mutationOptions?, options?)`. 335 + * 336 + * @default false 337 + */ 338 + requestOptions?: boolean; 339 + }; 301 340 useQuery?: 302 341 | boolean 303 342 | NameTransformer ··· 387 426 mutationOptions: NamingOptions & 388 427 FeatureToggle & { 389 428 /** 429 + * Whether to export generated symbols. 430 + * 431 + * @default true 432 + */ 433 + exported: boolean; 434 + /** 390 435 * Custom function to generate metadata for the operation. 391 436 * Can return any valid meta object that will be included in the generated mutation options. 392 437 * ··· 467 512 * 468 513 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 469 514 */ 515 + useMutation: NamingOptions & FeatureToggle & { requestOptions: boolean }; 470 516 useQuery: NamingOptions & FeatureToggle; 471 517 }; 472 518
+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.