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

Configure Feed

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

Merge pull request #3483 from lukaspodmelle/fix/pinia-colada-query-error-type

fix: pass error type generic to defineQueryOptions in @pinia/colada plugin

authored by

Lubos and committed by
GitHub
ce290205 3be5ff23

+148 -103
+5
.changeset/dry-waves-play.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + **plugin(@pinia/colada)**: fix: pass error type generic to `defineQueryOptions`
+73 -40
examples/openapi-ts-pinia-colada/src/client/@pinia/colada.gen.ts
··· 37 37 DeletePetData, 38 38 DeleteUserData, 39 39 FindPetsByStatusData, 40 + FindPetsByStatusResponse, 40 41 FindPetsByTagsData, 42 + FindPetsByTagsResponse, 41 43 GetInventoryData, 44 + GetInventoryResponse, 42 45 GetOrderByIdData, 46 + GetOrderByIdResponse, 43 47 GetPetByIdData, 48 + GetPetByIdResponse, 44 49 GetUserByNameData, 50 + GetUserByNameResponse, 45 51 LoginUserData, 52 + LoginUserResponse, 46 53 LogoutUserData, 47 54 PlaceOrderData, 48 55 PlaceOrderResponse, ··· 136 143 * 137 144 * Multiple status values can be provided with comma separated strings. 138 145 */ 139 - export const findPetsByStatusQuery = defineQueryOptions( 140 - (options: Options<FindPetsByStatusData>) => ({ 141 - key: createQueryKey('findPetsByStatus', options), 142 - query: async (context) => { 143 - const { data } = await findPetsByStatus({ 144 - ...options, 145 - ...context, 146 - throwOnError: true, 147 - }); 148 - return data; 149 - }, 150 - }), 151 - ); 146 + export const findPetsByStatusQuery = defineQueryOptions< 147 + Options<FindPetsByStatusData>, 148 + FindPetsByStatusResponse, 149 + Error 150 + >((options: Options<FindPetsByStatusData>) => ({ 151 + key: createQueryKey('findPetsByStatus', options), 152 + query: async (context) => { 153 + const { data } = await findPetsByStatus({ 154 + ...options, 155 + ...context, 156 + throwOnError: true, 157 + }); 158 + return data; 159 + }, 160 + })); 152 161 153 162 /** 154 163 * Finds Pets by tags. 155 164 * 156 165 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 157 166 */ 158 - export const findPetsByTagsQuery = defineQueryOptions((options: Options<FindPetsByTagsData>) => ({ 167 + export const findPetsByTagsQuery = defineQueryOptions< 168 + Options<FindPetsByTagsData>, 169 + FindPetsByTagsResponse, 170 + Error 171 + >((options: Options<FindPetsByTagsData>) => ({ 159 172 key: createQueryKey('findPetsByTags', options), 160 173 query: async (context) => { 161 174 const { data } = await findPetsByTags({ ··· 190 203 * 191 204 * Returns a single pet. 192 205 */ 193 - export const getPetByIdQuery = defineQueryOptions((options: Options<GetPetByIdData>) => ({ 206 + export const getPetByIdQuery = defineQueryOptions< 207 + Options<GetPetByIdData>, 208 + GetPetByIdResponse, 209 + Error 210 + >((options: Options<GetPetByIdData>) => ({ 194 211 key: createQueryKey('getPetById', options), 195 212 query: async (context) => { 196 213 const { data } = await getPetById({ ··· 243 260 * 244 261 * Returns a map of status codes to quantities. 245 262 */ 246 - export const getInventoryQuery = defineQueryOptions((options?: Options<GetInventoryData>) => ({ 263 + export const getInventoryQuery = defineQueryOptions< 264 + Options<GetInventoryData>, 265 + GetInventoryResponse, 266 + Error 267 + >((options?: Options<GetInventoryData>) => ({ 247 268 key: createQueryKey('getInventory', options), 248 269 query: async (context) => { 249 270 const { data } = await getInventory({ ··· 296 317 * 297 318 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 298 319 */ 299 - export const getOrderByIdQuery = defineQueryOptions((options: Options<GetOrderByIdData>) => ({ 320 + export const getOrderByIdQuery = defineQueryOptions< 321 + Options<GetOrderByIdData>, 322 + GetOrderByIdResponse, 323 + Error 324 + >((options: Options<GetOrderByIdData>) => ({ 300 325 key: createQueryKey('getOrderById', options), 301 326 query: async (context) => { 302 327 const { data } = await getOrderById({ ··· 353 378 * 354 379 * Log into the system. 355 380 */ 356 - export const loginUserQuery = defineQueryOptions((options?: Options<LoginUserData>) => ({ 357 - key: createQueryKey('loginUser', options), 358 - query: async (context) => { 359 - const { data } = await loginUser({ 360 - ...options, 361 - ...context, 362 - throwOnError: true, 363 - }); 364 - return data; 365 - }, 366 - })); 381 + export const loginUserQuery = defineQueryOptions<Options<LoginUserData>, LoginUserResponse, Error>( 382 + (options?: Options<LoginUserData>) => ({ 383 + key: createQueryKey('loginUser', options), 384 + query: async (context) => { 385 + const { data } = await loginUser({ 386 + ...options, 387 + ...context, 388 + throwOnError: true, 389 + }); 390 + return data; 391 + }, 392 + }), 393 + ); 367 394 368 395 /** 369 396 * Logs out current logged in user session. 370 397 * 371 398 * Log user out of the system. 372 399 */ 373 - export const logoutUserQuery = defineQueryOptions((options?: Options<LogoutUserData>) => ({ 374 - key: createQueryKey('logoutUser', options), 375 - query: async (context) => { 376 - const { data } = await logoutUser({ 377 - ...options, 378 - ...context, 379 - throwOnError: true, 380 - }); 381 - return data; 382 - }, 383 - })); 400 + export const logoutUserQuery = defineQueryOptions<Options<LogoutUserData>, unknown, Error>( 401 + (options?: Options<LogoutUserData>) => ({ 402 + key: createQueryKey('logoutUser', options), 403 + query: async (context) => { 404 + const { data } = await logoutUser({ 405 + ...options, 406 + ...context, 407 + throwOnError: true, 408 + }); 409 + return data; 410 + }, 411 + }), 412 + ); 384 413 385 414 /** 386 415 * Delete user resource. ··· 405 434 * 406 435 * Get user detail based on username. 407 436 */ 408 - export const getUserByNameQuery = defineQueryOptions((options: Options<GetUserByNameData>) => ({ 437 + export const getUserByNameQuery = defineQueryOptions< 438 + Options<GetUserByNameData>, 439 + GetUserByNameResponse, 440 + Error 441 + >((options: Options<GetUserByNameData>) => ({ 409 442 key: createQueryKey('getUserByName', options), 410 443 query: async (context) => { 411 444 const { data } = await getUserByName({
+3 -3
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 import { BarBazService, BarService, FooBazService, FooService, type Options } from '../sdk.gen'; 8 - import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooData } from '../types.gen'; 8 + import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, GetFooData, GetFooResponse } from '../types.gen'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 46 46 47 - export const getFooQuery = defineQueryOptions((options?: Options<GetFooData>) => ({ 47 + export const getFooQuery = defineQueryOptions<Options<GetFooData>, GetFooResponse, Error>((options?: Options<GetFooData>) => ({ 48 48 key: getFooQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await FooBazService.getFoo({ ··· 80 80 81 81 export const getFooBarQueryKey = (options?: Options<GetFooBarData>) => createQueryKey('getFooBar', options); 82 82 83 - export const getFooBarQuery = defineQueryOptions((options?: Options<GetFooBarData>) => ({ 83 + export const getFooBarQuery = defineQueryOptions<Options<GetFooBarData>, GetFooBarResponse, Error>((options?: Options<GetFooBarData>) => ({ 84 84 key: getFooBarQueryKey(options), 85 85 query: async (context) => { 86 86 const { data } = await BarBazService.getFooBar({
+13 -13
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 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'; 8 - import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexTypesData, DeleteCallWithoutParametersAndResponseData, DummyAData, DummyBData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, FooWowData, GetCallWithoutParametersAndResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, ServiceWithEmptyTagData, TestErrorCodeData, TypesData } from '../types.gen'; 8 + 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'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const serviceWithEmptyTagQueryKey = (options?: Options<ServiceWithEmptyTagData>) => createQueryKey('serviceWithEmptyTag', options); 46 46 47 - export const serviceWithEmptyTagQuery = defineQueryOptions((options?: Options<ServiceWithEmptyTagData>) => ({ 47 + export const serviceWithEmptyTagQuery = defineQueryOptions<Options<ServiceWithEmptyTagData>, unknown, Error>((options?: Options<ServiceWithEmptyTagData>) => ({ 48 48 key: serviceWithEmptyTagQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await serviceWithEmptyTag({ ··· 91 91 92 92 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 93 93 94 - export const getCallWithoutParametersAndResponseQuery = defineQueryOptions((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 94 + export const getCallWithoutParametersAndResponseQuery = defineQueryOptions<Options<GetCallWithoutParametersAndResponseData>, unknown, Error>((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 95 95 key: getCallWithoutParametersAndResponseQueryKey(options), 96 96 query: async (context) => { 97 97 const { data } = await getCallWithoutParametersAndResponse({ ··· 171 171 172 172 export const callWithDefaultParametersQueryKey = (options: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 173 173 174 - export const callWithDefaultParametersQuery = defineQueryOptions((options: Options<CallWithDefaultParametersData>) => ({ 174 + export const callWithDefaultParametersQuery = defineQueryOptions<Options<CallWithDefaultParametersData>, unknown, Error>((options: Options<CallWithDefaultParametersData>) => ({ 175 175 key: callWithDefaultParametersQueryKey(options), 176 176 query: async (context) => { 177 177 const { data } = await callWithDefaultParameters({ ··· 218 218 219 219 export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 220 220 221 - export const duplicateName2Query = defineQueryOptions((options?: Options<DuplicateName2Data>) => ({ 221 + export const duplicateName2Query = defineQueryOptions<Options<DuplicateName2Data>, unknown, Error>((options?: Options<DuplicateName2Data>) => ({ 222 222 key: duplicateName2QueryKey(options), 223 223 query: async (context) => { 224 224 const { data } = await duplicateName2({ ··· 254 254 255 255 export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 256 256 257 - export const callWithNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithNoContentResponseData>) => ({ 257 + export const callWithNoContentResponseQuery = defineQueryOptions<Options<CallWithNoContentResponseData>, unknown, Error>((options?: Options<CallWithNoContentResponseData>) => ({ 258 258 key: callWithNoContentResponseQueryKey(options), 259 259 query: async (context) => { 260 260 const { data } = await callWithNoContentResponse({ ··· 268 268 269 269 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 270 270 271 - export const callWithResponseAndNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 271 + export const callWithResponseAndNoContentResponseQuery = defineQueryOptions<Options<CallWithResponseAndNoContentResponseData>, CallWithResponseAndNoContentResponseResponse, Error>((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 272 272 key: callWithResponseAndNoContentResponseQueryKey(options), 273 273 query: async (context) => { 274 274 const { data } = await callWithResponseAndNoContentResponse({ ··· 282 282 283 283 export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 284 284 285 - export const dummyAQuery = defineQueryOptions((options?: Options<DummyAData>) => ({ 285 + export const dummyAQuery = defineQueryOptions<Options<DummyAData>, unknown, Error>((options?: Options<DummyAData>) => ({ 286 286 key: dummyAQueryKey(options), 287 287 query: async (context) => { 288 288 const { data } = await dummyA({ ··· 296 296 297 297 export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 298 298 299 - export const dummyBQuery = defineQueryOptions((options?: Options<DummyBData>) => ({ 299 + export const dummyBQuery = defineQueryOptions<Options<DummyBData>, unknown, Error>((options?: Options<DummyBData>) => ({ 300 300 key: dummyBQueryKey(options), 301 301 query: async (context) => { 302 302 const { data } = await dummyB({ ··· 310 310 311 311 export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 312 312 313 - export const callWithResponseQuery = defineQueryOptions((options?: Options<CallWithResponseData>) => ({ 313 + export const callWithResponseQuery = defineQueryOptions<Options<CallWithResponseData>, CallWithResponseResponse, Error>((options?: Options<CallWithResponseData>) => ({ 314 314 key: callWithResponseQueryKey(options), 315 315 query: async (context) => { 316 316 const { data } = await callWithResponse({ ··· 346 346 347 347 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 348 348 349 - export const collectionFormatQuery = defineQueryOptions((options: Options<CollectionFormatData>) => ({ 349 + export const collectionFormatQuery = defineQueryOptions<Options<CollectionFormatData>, unknown, Error>((options: Options<CollectionFormatData>) => ({ 350 350 key: collectionFormatQueryKey(options), 351 351 query: async (context) => { 352 352 const { data } = await collectionFormat({ ··· 360 360 361 361 export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 362 362 363 - export const typesQuery = defineQueryOptions((options: Options<TypesData>) => ({ 363 + export const typesQuery = defineQueryOptions<Options<TypesData>, TypesResponse, Error>((options: Options<TypesData>) => ({ 364 364 key: typesQueryKey(options), 365 365 query: async (context) => { 366 366 const { data } = await types({ ··· 374 374 375 375 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 376 376 377 - export const complexTypesQuery = defineQueryOptions((options: Options<ComplexTypesData>) => ({ 377 + export const complexTypesQuery = defineQueryOptions<Options<ComplexTypesData>, ComplexTypesResponse, Error>((options: Options<ComplexTypesData>) => ({ 378 378 key: complexTypesQueryKey(options), 379 379 query: async (context) => { 380 380 const { data } = await complexTypes({
+3 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 import { BarBazService, BarService, FooBazService, FooService, type Options } from '../sdk.gen'; 8 - import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooData } from '../types.gen'; 8 + import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, GetFooData, GetFooResponse } from '../types.gen'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 46 46 47 - export const getFooQuery = defineQueryOptions((options?: Options<GetFooData>) => ({ 47 + export const getFooQuery = defineQueryOptions<Options<GetFooData>, GetFooResponse, Error>((options?: Options<GetFooData>) => ({ 48 48 key: getFooQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await FooBazService.getFoo({ ··· 80 80 81 81 export const getFooBarQueryKey = (options?: Options<GetFooBarData>) => createQueryKey('getFooBar', options); 82 82 83 - export const getFooBarQuery = defineQueryOptions((options?: Options<GetFooBarData>) => ({ 83 + export const getFooBarQuery = defineQueryOptions<Options<GetFooBarData>, GetFooBarResponse, Error>((options?: Options<GetFooBarData>) => ({ 84 84 key: getFooBarQueryKey(options), 85 85 query: async (context) => { 86 86 const { data } = await BarBazService.getFooBar({
+18 -18
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 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'; 8 - import type { ApiVVersionODataControllerCountData, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyBData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, UploadFileData, UploadFileResponse } from '../types.gen'; 8 + 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'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const exportQueryKey = (options?: Options<ExportData>) => createQueryKey('export', options); 46 46 47 - export const exportQuery = defineQueryOptions((options?: Options<ExportData>) => ({ 47 + export const exportQuery = defineQueryOptions<Options<ExportData>, unknown, Error>((options?: Options<ExportData>) => ({ 48 48 key: exportQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await export_({ ··· 91 91 92 92 export const apiVVersionODataControllerCountQueryKey = (options?: Options<ApiVVersionODataControllerCountData>) => createQueryKey('apiVVersionODataControllerCount', options); 93 93 94 - export const apiVVersionODataControllerCountQuery = defineQueryOptions((options?: Options<ApiVVersionODataControllerCountData>) => ({ 94 + export const apiVVersionODataControllerCountQuery = defineQueryOptions<Options<ApiVVersionODataControllerCountData>, ApiVVersionODataControllerCountResponse, Error>((options?: Options<ApiVVersionODataControllerCountData>) => ({ 95 95 key: apiVVersionODataControllerCountQueryKey(options), 96 96 query: async (context) => { 97 97 const { data } = await apiVVersionODataControllerCount({ ··· 105 105 106 106 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); 107 107 108 - export const getApiVbyApiVersionSimpleOperationQuery = defineQueryOptions((options: Options<GetApiVbyApiVersionSimpleOperationData>) => ({ 108 + export const getApiVbyApiVersionSimpleOperationQuery = defineQueryOptions<Options<GetApiVbyApiVersionSimpleOperationData>, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError>((options: Options<GetApiVbyApiVersionSimpleOperationData>) => ({ 109 109 key: getApiVbyApiVersionSimpleOperationQueryKey(options), 110 110 query: async (context) => { 111 111 const { data } = await getApiVbyApiVersionSimpleOperation({ ··· 130 130 131 131 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 132 132 133 - export const getCallWithoutParametersAndResponseQuery = defineQueryOptions((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 133 + export const getCallWithoutParametersAndResponseQuery = defineQueryOptions<Options<GetCallWithoutParametersAndResponseData>, unknown, Error>((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 134 134 key: getCallWithoutParametersAndResponseQueryKey(options), 135 135 query: async (context) => { 136 136 const { data } = await getCallWithoutParametersAndResponse({ ··· 235 235 236 236 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => createQueryKey('getCallWithOptionalParam', options); 237 237 238 - export const getCallWithOptionalParamQuery = defineQueryOptions((options: Options<GetCallWithOptionalParamData>) => ({ 238 + export const getCallWithOptionalParamQuery = defineQueryOptions<Options<GetCallWithOptionalParamData>, unknown, Error>((options: Options<GetCallWithOptionalParamData>) => ({ 239 239 key: getCallWithOptionalParamQueryKey(options), 240 240 query: async (context) => { 241 241 const { data } = await getCallWithOptionalParam({ ··· 282 282 283 283 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 284 284 285 - export const callWithDefaultParametersQuery = defineQueryOptions((options?: Options<CallWithDefaultParametersData>) => ({ 285 + export const callWithDefaultParametersQuery = defineQueryOptions<Options<CallWithDefaultParametersData>, unknown, Error>((options?: Options<CallWithDefaultParametersData>) => ({ 286 286 key: callWithDefaultParametersQueryKey(options), 287 287 query: async (context) => { 288 288 const { data } = await callWithDefaultParameters({ ··· 329 329 330 330 export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 331 331 332 - export const duplicateName2Query = defineQueryOptions((options?: Options<DuplicateName2Data>) => ({ 332 + export const duplicateName2Query = defineQueryOptions<Options<DuplicateName2Data>, unknown, Error>((options?: Options<DuplicateName2Data>) => ({ 333 333 key: duplicateName2QueryKey(options), 334 334 query: async (context) => { 335 335 const { data } = await duplicateName2({ ··· 365 365 366 366 export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 367 367 368 - export const callWithNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithNoContentResponseData>) => ({ 368 + export const callWithNoContentResponseQuery = defineQueryOptions<Options<CallWithNoContentResponseData>, CallWithNoContentResponseResponse, Error>((options?: Options<CallWithNoContentResponseData>) => ({ 369 369 key: callWithNoContentResponseQueryKey(options), 370 370 query: async (context) => { 371 371 const { data } = await callWithNoContentResponse({ ··· 379 379 380 380 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 381 381 382 - export const callWithResponseAndNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 382 + export const callWithResponseAndNoContentResponseQuery = defineQueryOptions<Options<CallWithResponseAndNoContentResponseData>, CallWithResponseAndNoContentResponseResponse, Error>((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 383 383 key: callWithResponseAndNoContentResponseQueryKey(options), 384 384 query: async (context) => { 385 385 const { data } = await callWithResponseAndNoContentResponse({ ··· 393 393 394 394 export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 395 395 396 - export const dummyAQuery = defineQueryOptions((options?: Options<DummyAData>) => ({ 396 + export const dummyAQuery = defineQueryOptions<Options<DummyAData>, DummyAResponse, Error>((options?: Options<DummyAData>) => ({ 397 397 key: dummyAQueryKey(options), 398 398 query: async (context) => { 399 399 const { data } = await dummyA({ ··· 407 407 408 408 export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 409 409 410 - export const dummyBQuery = defineQueryOptions((options?: Options<DummyBData>) => ({ 410 + export const dummyBQuery = defineQueryOptions<Options<DummyBData>, DummyBResponse, Error>((options?: Options<DummyBData>) => ({ 411 411 key: dummyBQueryKey(options), 412 412 query: async (context) => { 413 413 const { data } = await dummyB({ ··· 421 421 422 422 export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 423 423 424 - export const callWithResponseQuery = defineQueryOptions((options?: Options<CallWithResponseData>) => ({ 424 + export const callWithResponseQuery = defineQueryOptions<Options<CallWithResponseData>, CallWithResponseResponse, Error>((options?: Options<CallWithResponseData>) => ({ 425 425 key: callWithResponseQueryKey(options), 426 426 query: async (context) => { 427 427 const { data } = await callWithResponse({ ··· 457 457 458 458 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 459 459 460 - export const collectionFormatQuery = defineQueryOptions((options: Options<CollectionFormatData>) => ({ 460 + export const collectionFormatQuery = defineQueryOptions<Options<CollectionFormatData>, unknown, Error>((options: Options<CollectionFormatData>) => ({ 461 461 key: collectionFormatQueryKey(options), 462 462 query: async (context) => { 463 463 const { data } = await collectionFormat({ ··· 471 471 472 472 export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 473 473 474 - export const typesQuery = defineQueryOptions((options: Options<TypesData>) => ({ 474 + export const typesQuery = defineQueryOptions<Options<TypesData>, TypesResponse, Error>((options: Options<TypesData>) => ({ 475 475 key: typesQueryKey(options), 476 476 query: async (context) => { 477 477 const { data } = await types({ ··· 496 496 497 497 export const fileResponseQueryKey = (options: Options<FileResponseData>) => createQueryKey('fileResponse', options); 498 498 499 - export const fileResponseQuery = defineQueryOptions((options: Options<FileResponseData>) => ({ 499 + export const fileResponseQuery = defineQueryOptions<Options<FileResponseData>, FileResponseResponse, Error>((options: Options<FileResponseData>) => ({ 500 500 key: fileResponseQueryKey(options), 501 501 query: async (context) => { 502 502 const { data } = await fileResponse({ ··· 510 510 511 511 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 512 512 513 - export const complexTypesQuery = defineQueryOptions((options: Options<ComplexTypesData>) => ({ 513 + export const complexTypesQuery = defineQueryOptions<Options<ComplexTypesData>, ComplexTypesResponse, Error>((options: Options<ComplexTypesData>) => ({ 514 514 key: complexTypesQueryKey(options), 515 515 query: async (context) => { 516 516 const { data } = await complexTypes({ ··· 524 524 525 525 export const multipartResponseQueryKey = (options?: Options<MultipartResponseData>) => createQueryKey('multipartResponse', options); 526 526 527 - export const multipartResponseQuery = defineQueryOptions((options?: Options<MultipartResponseData>) => ({ 527 + export const multipartResponseQuery = defineQueryOptions<Options<MultipartResponseData>, MultipartResponseResponse, Error>((options?: Options<MultipartResponseData>) => ({ 528 528 key: multipartResponseQueryKey(options), 529 529 query: async (context) => { 530 530 const { data } = await multipartResponse({
+3 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 import { BarBazService, BarService, FooBazService, FooService, type Options } from '../sdk.gen'; 8 - import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooData } from '../types.gen'; 8 + import type { FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, GetFooData, GetFooResponse } from '../types.gen'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 46 46 47 - export const getFooQuery = defineQueryOptions((options?: Options<GetFooData>) => ({ 47 + export const getFooQuery = defineQueryOptions<Options<GetFooData>, GetFooResponse, Error>((options?: Options<GetFooData>) => ({ 48 48 key: getFooQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await FooBazService.getFoo({ ··· 80 80 81 81 export const getFooBarQueryKey = (options?: Options<GetFooBarData>) => createQueryKey('getFooBar', options); 82 82 83 - export const getFooBarQuery = defineQueryOptions((options?: Options<GetFooBarData>) => ({ 83 + export const getFooBarQuery = defineQueryOptions<Options<GetFooBarData>, GetFooBarResponse, Error>((options?: Options<GetFooBarData>) => ({ 84 84 key: getFooBarQueryKey(options), 85 85 query: async (context) => { 86 86 const { data } = await BarBazService.getFooBar({
+18 -18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts
··· 5 5 import { serializeQueryKeyValue } from '../client'; 6 6 import { client } from '../client.gen'; 7 7 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'; 8 - import type { ApiVVersionODataControllerCountData, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyBData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, UploadFileData, UploadFileResponse } from '../types.gen'; 8 + 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'; 9 9 10 10 export type QueryKey<TOptions extends Options> = [ 11 11 Pick<TOptions, 'path'> & { ··· 44 44 45 45 export const exportQueryKey = (options?: Options<ExportData>) => createQueryKey('export', options); 46 46 47 - export const exportQuery = defineQueryOptions((options?: Options<ExportData>) => ({ 47 + export const exportQuery = defineQueryOptions<Options<ExportData>, unknown, Error>((options?: Options<ExportData>) => ({ 48 48 key: exportQueryKey(options), 49 49 query: async (context) => { 50 50 const { data } = await export_({ ··· 91 91 92 92 export const apiVVersionODataControllerCountQueryKey = (options?: Options<ApiVVersionODataControllerCountData>) => createQueryKey('apiVVersionODataControllerCount', options); 93 93 94 - export const apiVVersionODataControllerCountQuery = defineQueryOptions((options?: Options<ApiVVersionODataControllerCountData>) => ({ 94 + export const apiVVersionODataControllerCountQuery = defineQueryOptions<Options<ApiVVersionODataControllerCountData>, ApiVVersionODataControllerCountResponse, Error>((options?: Options<ApiVVersionODataControllerCountData>) => ({ 95 95 key: apiVVersionODataControllerCountQueryKey(options), 96 96 query: async (context) => { 97 97 const { data } = await apiVVersionODataControllerCount({ ··· 105 105 106 106 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); 107 107 108 - export const getApiVbyApiVersionSimpleOperationQuery = defineQueryOptions((options: Options<GetApiVbyApiVersionSimpleOperationData>) => ({ 108 + export const getApiVbyApiVersionSimpleOperationQuery = defineQueryOptions<Options<GetApiVbyApiVersionSimpleOperationData>, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError>((options: Options<GetApiVbyApiVersionSimpleOperationData>) => ({ 109 109 key: getApiVbyApiVersionSimpleOperationQueryKey(options), 110 110 query: async (context) => { 111 111 const { data } = await getApiVbyApiVersionSimpleOperation({ ··· 130 130 131 131 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options); 132 132 133 - export const getCallWithoutParametersAndResponseQuery = defineQueryOptions((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 133 + export const getCallWithoutParametersAndResponseQuery = defineQueryOptions<Options<GetCallWithoutParametersAndResponseData>, unknown, Error>((options?: Options<GetCallWithoutParametersAndResponseData>) => ({ 134 134 key: getCallWithoutParametersAndResponseQueryKey(options), 135 135 query: async (context) => { 136 136 const { data } = await getCallWithoutParametersAndResponse({ ··· 235 235 236 236 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => createQueryKey('getCallWithOptionalParam', options); 237 237 238 - export const getCallWithOptionalParamQuery = defineQueryOptions((options: Options<GetCallWithOptionalParamData>) => ({ 238 + export const getCallWithOptionalParamQuery = defineQueryOptions<Options<GetCallWithOptionalParamData>, unknown, Error>((options: Options<GetCallWithOptionalParamData>) => ({ 239 239 key: getCallWithOptionalParamQueryKey(options), 240 240 query: async (context) => { 241 241 const { data } = await getCallWithOptionalParam({ ··· 282 282 283 283 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options); 284 284 285 - export const callWithDefaultParametersQuery = defineQueryOptions((options?: Options<CallWithDefaultParametersData>) => ({ 285 + export const callWithDefaultParametersQuery = defineQueryOptions<Options<CallWithDefaultParametersData>, unknown, Error>((options?: Options<CallWithDefaultParametersData>) => ({ 286 286 key: callWithDefaultParametersQueryKey(options), 287 287 query: async (context) => { 288 288 const { data } = await callWithDefaultParameters({ ··· 329 329 330 330 export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options); 331 331 332 - export const duplicateName2Query = defineQueryOptions((options?: Options<DuplicateName2Data>) => ({ 332 + export const duplicateName2Query = defineQueryOptions<Options<DuplicateName2Data>, unknown, Error>((options?: Options<DuplicateName2Data>) => ({ 333 333 key: duplicateName2QueryKey(options), 334 334 query: async (context) => { 335 335 const { data } = await duplicateName2({ ··· 365 365 366 366 export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options); 367 367 368 - export const callWithNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithNoContentResponseData>) => ({ 368 + export const callWithNoContentResponseQuery = defineQueryOptions<Options<CallWithNoContentResponseData>, CallWithNoContentResponseResponse, Error>((options?: Options<CallWithNoContentResponseData>) => ({ 369 369 key: callWithNoContentResponseQueryKey(options), 370 370 query: async (context) => { 371 371 const { data } = await callWithNoContentResponse({ ··· 379 379 380 380 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options); 381 381 382 - export const callWithResponseAndNoContentResponseQuery = defineQueryOptions((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 382 + export const callWithResponseAndNoContentResponseQuery = defineQueryOptions<Options<CallWithResponseAndNoContentResponseData>, CallWithResponseAndNoContentResponseResponse, Error>((options?: Options<CallWithResponseAndNoContentResponseData>) => ({ 383 383 key: callWithResponseAndNoContentResponseQueryKey(options), 384 384 query: async (context) => { 385 385 const { data } = await callWithResponseAndNoContentResponse({ ··· 393 393 394 394 export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options); 395 395 396 - export const dummyAQuery = defineQueryOptions((options?: Options<DummyAData>) => ({ 396 + export const dummyAQuery = defineQueryOptions<Options<DummyAData>, DummyAResponse, Error>((options?: Options<DummyAData>) => ({ 397 397 key: dummyAQueryKey(options), 398 398 query: async (context) => { 399 399 const { data } = await dummyA({ ··· 407 407 408 408 export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options); 409 409 410 - export const dummyBQuery = defineQueryOptions((options?: Options<DummyBData>) => ({ 410 + export const dummyBQuery = defineQueryOptions<Options<DummyBData>, DummyBResponse, Error>((options?: Options<DummyBData>) => ({ 411 411 key: dummyBQueryKey(options), 412 412 query: async (context) => { 413 413 const { data } = await dummyB({ ··· 421 421 422 422 export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options); 423 423 424 - export const callWithResponseQuery = defineQueryOptions((options?: Options<CallWithResponseData>) => ({ 424 + export const callWithResponseQuery = defineQueryOptions<Options<CallWithResponseData>, CallWithResponseResponse, Error>((options?: Options<CallWithResponseData>) => ({ 425 425 key: callWithResponseQueryKey(options), 426 426 query: async (context) => { 427 427 const { data } = await callWithResponse({ ··· 457 457 458 458 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options); 459 459 460 - export const collectionFormatQuery = defineQueryOptions((options: Options<CollectionFormatData>) => ({ 460 + export const collectionFormatQuery = defineQueryOptions<Options<CollectionFormatData>, unknown, Error>((options: Options<CollectionFormatData>) => ({ 461 461 key: collectionFormatQueryKey(options), 462 462 query: async (context) => { 463 463 const { data } = await collectionFormat({ ··· 471 471 472 472 export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options); 473 473 474 - export const typesQuery = defineQueryOptions((options: Options<TypesData>) => ({ 474 + export const typesQuery = defineQueryOptions<Options<TypesData>, TypesResponse, Error>((options: Options<TypesData>) => ({ 475 475 key: typesQueryKey(options), 476 476 query: async (context) => { 477 477 const { data } = await types({ ··· 496 496 497 497 export const fileResponseQueryKey = (options: Options<FileResponseData>) => createQueryKey('fileResponse', options); 498 498 499 - export const fileResponseQuery = defineQueryOptions((options: Options<FileResponseData>) => ({ 499 + export const fileResponseQuery = defineQueryOptions<Options<FileResponseData>, FileResponseResponse, Error>((options: Options<FileResponseData>) => ({ 500 500 key: fileResponseQueryKey(options), 501 501 query: async (context) => { 502 502 const { data } = await fileResponse({ ··· 510 510 511 511 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options); 512 512 513 - export const complexTypesQuery = defineQueryOptions((options: Options<ComplexTypesData>) => ({ 513 + export const complexTypesQuery = defineQueryOptions<Options<ComplexTypesData>, ComplexTypesResponse, Error>((options: Options<ComplexTypesData>) => ({ 514 514 key: complexTypesQueryKey(options), 515 515 query: async (context) => { 516 516 const { data } = await complexTypes({ ··· 524 524 525 525 export const multipartResponseQueryKey = (options?: Options<MultipartResponseData>) => createQueryKey('multipartResponse', options); 526 526 527 - export const multipartResponseQuery = defineQueryOptions((options?: Options<MultipartResponseData>) => ({ 527 + export const multipartResponseQuery = defineQueryOptions<Options<MultipartResponseData>, MultipartResponseResponse, Error>((options?: Options<MultipartResponseData>) => ({ 528 528 key: multipartResponseQueryKey(options), 529 529 query: async (context) => { 530 530 const { data } = await multipartResponse({
+12 -5
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts
··· 12 12 import { handleMeta } from './meta'; 13 13 import { createQueryKeyFunction, createQueryKeyType, queryKeyStatement } from './queryKey'; 14 14 import type { PiniaColadaPlugin } from './types'; 15 + import { useTypeError, useTypeResponse } from './useType'; 15 16 import { getPublicTypeData } from './utils'; 16 17 17 18 const optionsParamName = 'options'; ··· 125 126 .export() 126 127 .$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)) 127 128 .assign( 128 - $(symbolDefineQueryOptions).call( 129 - $.func() 130 - .param(optionsParamName, (p) => p.required(isRequiredOptions).type(typeData)) 131 - .do($.return(queryOpts)), 132 - ), 129 + $(symbolDefineQueryOptions) 130 + .call( 131 + $.func() 132 + .param(optionsParamName, (p) => p.required(isRequiredOptions).type(typeData)) 133 + .do($.return(queryOpts)), 134 + ) 135 + .generics( 136 + typeData, 137 + useTypeResponse({ operation, plugin }), 138 + useTypeError({ operation, plugin }), 139 + ), 133 140 ); 134 141 plugin.node(statement); 135 142 };