From 8133ee0e2cf5231c94cfac8a4a510acbe2a7364c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 15:39:18 +0000 Subject: [PATCH 1/2] Initial plan From c49afffc969d925a97346144881e0e6cd60223cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:04:37 +0000 Subject: [PATCH 2/2] Add explicit return types to SDK functions to prevent circular type inference Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../src/client/sdk.gen.ts | 85 ++++++++++++++----- .../openapi-ts-axios/src/client/sdk.gen.ts | 57 ++++++++----- .../openapi-ts-fastify/src/client/sdk.gen.ts | 13 ++- .../openapi-ts-fetch/src/client/sdk.gen.ts | 57 ++++++++----- .../openapi-ts-next/src/client/sdk.gen.ts | 57 ++++++++----- .../openapi-ts-ofetch/src/client/sdk.gen.ts | 57 ++++++++----- .../src/client/sdk.gen.ts | 40 ++++----- .../openapi-ts-sample/src/client/sdk.gen.ts | 57 ++++++++----- .../src/client/sdk.gen.ts | 57 ++++++++----- .../src/client/sdk.gen.ts | 57 ++++++++----- .../src/client/sdk.gen.ts | 57 ++++++++----- .../src/client/sdk.gen.ts | 40 ++++----- .../plugins/@hey-api/sdk/shared/functions.ts | 54 +++++++++++- 13 files changed, 463 insertions(+), 225 deletions(-) diff --git a/examples/openapi-ts-angular-common/src/client/sdk.gen.ts b/examples/openapi-ts-angular-common/src/client/sdk.gen.ts index d1c943a6c..b748dc26e 100644 --- a/examples/openapi-ts-angular-common/src/client/sdk.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< AddPetResponses, AddPetErrors, @@ -115,7 +120,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -144,7 +149,12 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -169,7 +179,12 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult< + FindPetsByTagsResponses, + FindPetsByTagsErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -194,7 +209,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -219,7 +234,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -248,7 +263,12 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -273,7 +293,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -303,7 +323,12 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult< + GetInventoryResponses, + GetInventoryErrors, + ThrowOnError, + 'data' +> => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -328,7 +353,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -351,7 +376,12 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult< + DeleteOrderResponses, + DeleteOrderErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -370,7 +400,12 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult< + GetOrderByIdResponses, + GetOrderByIdErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -389,7 +424,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -412,7 +447,12 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError, + 'data' +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -435,7 +475,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -454,7 +494,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -473,7 +513,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -492,7 +532,12 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult< + GetUserByNameResponses, + GetUserByNameErrors, + ThrowOnError, + 'data' +> => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -511,7 +556,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-axios/src/client/sdk.gen.ts b/examples/openapi-ts-axios/src/client/sdk.gen.ts index bb7cee4ba..519b17bfb 100644 --- a/examples/openapi-ts-axios/src/client/sdk.gen.ts +++ b/examples/openapi-ts-axios/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ responseType: 'json', security: [ @@ -110,7 +115,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -138,7 +143,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -162,7 +171,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -186,7 +195,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -209,7 +218,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -237,7 +246,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -261,7 +274,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -290,7 +303,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -314,7 +327,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -336,7 +349,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -353,7 +366,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -371,7 +384,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -393,7 +406,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -415,7 +432,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -433,7 +450,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -450,7 +467,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -467,7 +484,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -485,7 +502,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-fastify/src/client/sdk.gen.ts b/examples/openapi-ts-fastify/src/client/sdk.gen.ts index c60e38505..02d74cd80 100644 --- a/examples/openapi-ts-fastify/src/client/sdk.gen.ts +++ b/examples/openapi-ts-fastify/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { CreatePetsData, @@ -36,7 +41,7 @@ export type Options< */ export const listPets = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< ListPetsResponses, ListPetsErrors, @@ -51,7 +56,7 @@ export const listPets = ( */ export const createPets = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreatePetsResponses, CreatePetsErrors, @@ -66,7 +71,7 @@ export const createPets = ( */ export const showPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< ShowPetByIdResponses, ShowPetByIdErrors, diff --git a/examples/openapi-ts-fetch/src/client/sdk.gen.ts b/examples/openapi-ts-fetch/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-fetch/src/client/sdk.gen.ts +++ b/examples/openapi-ts-fetch/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-next/src/client/sdk.gen.ts b/examples/openapi-ts-next/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-next/src/client/sdk.gen.ts +++ b/examples/openapi-ts-next/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-ofetch/src/client/sdk.gen.ts b/examples/openapi-ts-ofetch/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-ofetch/src/client/sdk.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-pinia-colada/src/client/sdk.gen.ts b/examples/openapi-ts-pinia-colada/src/client/sdk.gen.ts index 6743104bb..94c2036d8 100644 --- a/examples/openapi-ts-pinia-colada/src/client/sdk.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/sdk.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client' +import type { Client, Options as Options2, RequestResult, TDataShape } from './client' import { client } from './client.gen' import type { AddPetData, @@ -86,7 +86,7 @@ export type Options< */ export const addPet = ( options: Options -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +109,7 @@ export const addPet = ( */ export const updatePet = ( options: Options -) => +): RequestResult => (options.client ?? client).put({ security: [ { @@ -132,7 +132,7 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -151,7 +151,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -170,7 +170,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ security: [ { @@ -189,7 +189,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -212,7 +212,7 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options -) => +): RequestResult => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -235,7 +235,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options -) => +): RequestResult => (options.client ?? client).post({ bodySerializer: null, security: [ @@ -259,7 +259,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ security: [ { @@ -278,7 +278,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post({ url: '/store/order', ...options, @@ -295,7 +295,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ url: '/store/order/{orderId}', ...options @@ -308,7 +308,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ url: '/store/order/{orderId}', ...options @@ -321,7 +321,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post({ url: '/user', ...options, @@ -338,7 +338,7 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -359,7 +359,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ url: '/user/login', ...options @@ -372,7 +372,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ url: '/user/logout', ...options @@ -385,7 +385,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ url: '/user/{username}', ...options @@ -398,7 +398,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ url: '/user/{username}', ...options @@ -411,7 +411,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options -) => +): RequestResult => (options.client ?? client).put({ url: '/user/{username}', ...options, diff --git a/examples/openapi-ts-sample/src/client/sdk.gen.ts b/examples/openapi-ts-sample/src/client/sdk.gen.ts index 867b5a377..836ace894 100644 --- a/examples/openapi-ts-sample/src/client/sdk.gen.ts +++ b/examples/openapi-ts-sample/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -121,7 +126,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ requestValidator: async (data) => await zAddPetData.parseAsync(data), responseValidator: async (data) => await zAddPetResponse.parseAsync(data), @@ -146,7 +151,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -176,7 +181,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -203,7 +212,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -230,7 +239,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -254,7 +263,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -284,7 +293,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -311,7 +324,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -342,7 +355,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -368,7 +381,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -392,7 +405,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -410,7 +423,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -430,7 +443,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -454,7 +467,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -479,7 +496,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -499,7 +516,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -517,7 +534,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -535,7 +552,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -555,7 +572,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/sdk.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/sdk.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-tanstack-react-query/src/client/sdk.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/sdk.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/sdk.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/sdk.gen.ts index f424fe675..2c7207308 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/sdk.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/sdk.gen.ts @@ -1,6 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client'; +import type { + Client, + Options as Options2, + RequestResult, + TDataShape, +} from './client'; import { client } from './client.gen'; import type { AddPetData, @@ -86,7 +91,7 @@ export type Options< */ export const addPet = ( options: Options, -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +114,7 @@ export const addPet = ( */ export const updatePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdatePetResponses, UpdatePetErrors, @@ -136,7 +141,11 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options, -) => +): RequestResult< + FindPetsByStatusResponses, + FindPetsByStatusErrors, + ThrowOnError +> => (options.client ?? client).get< FindPetsByStatusResponses, FindPetsByStatusErrors, @@ -159,7 +168,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< FindPetsByTagsResponses, FindPetsByTagsErrors, @@ -182,7 +191,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeletePetResponses, DeletePetErrors, @@ -205,7 +214,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetPetByIdResponses, GetPetByIdErrors, @@ -232,7 +241,11 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options, -) => +): RequestResult< + UpdatePetWithFormResponses, + UpdatePetWithFormErrors, + ThrowOnError +> => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -255,7 +268,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options, -) => +): RequestResult => (options.client ?? client).post< UploadFileResponses, UploadFileErrors, @@ -283,7 +296,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< GetInventoryResponses, GetInventoryErrors, @@ -306,7 +319,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< PlaceOrderResponses, PlaceOrderErrors, @@ -327,7 +340,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteOrderResponses, DeleteOrderErrors, @@ -344,7 +357,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetOrderByIdResponses, GetOrderByIdErrors, @@ -361,7 +374,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).post< CreateUserResponses, CreateUserErrors, @@ -382,7 +395,11 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options, -) => +): RequestResult< + CreateUsersWithListInputResponses, + CreateUsersWithListInputErrors, + ThrowOnError +> => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -403,7 +420,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LoginUserResponses, LoginUserErrors, @@ -420,7 +437,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options, -) => +): RequestResult => (options?.client ?? client).get< LogoutUserResponses, LogoutUserErrors, @@ -437,7 +454,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).delete< DeleteUserResponses, DeleteUserErrors, @@ -454,7 +471,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options, -) => +): RequestResult => (options.client ?? client).get< GetUserByNameResponses, GetUserByNameErrors, @@ -471,7 +488,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options, -) => +): RequestResult => (options.client ?? client).put< UpdateUserResponses, UpdateUserErrors, diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/sdk.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/sdk.gen.ts index 6743104bb..94c2036d8 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/sdk.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/sdk.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Client, Options as Options2, TDataShape } from './client' +import type { Client, Options as Options2, RequestResult, TDataShape } from './client' import { client } from './client.gen' import type { AddPetData, @@ -86,7 +86,7 @@ export type Options< */ export const addPet = ( options: Options -) => +): RequestResult => (options.client ?? client).post({ security: [ { @@ -109,7 +109,7 @@ export const addPet = ( */ export const updatePet = ( options: Options -) => +): RequestResult => (options.client ?? client).put({ security: [ { @@ -132,7 +132,7 @@ export const updatePet = ( */ export const findPetsByStatus = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -151,7 +151,7 @@ export const findPetsByStatus = ( */ export const findPetsByTags = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -170,7 +170,7 @@ export const findPetsByTags = ( */ export const deletePet = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ security: [ { @@ -189,7 +189,7 @@ export const deletePet = ( */ export const getPetById = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ security: [ { @@ -212,7 +212,7 @@ export const getPetById = ( */ export const updatePetWithForm = ( options: Options -) => +): RequestResult => (options.client ?? client).post< UpdatePetWithFormResponses, UpdatePetWithFormErrors, @@ -235,7 +235,7 @@ export const updatePetWithForm = ( */ export const uploadFile = ( options: Options -) => +): RequestResult => (options.client ?? client).post({ bodySerializer: null, security: [ @@ -259,7 +259,7 @@ export const uploadFile = ( */ export const getInventory = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ security: [ { @@ -278,7 +278,7 @@ export const getInventory = ( */ export const placeOrder = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post({ url: '/store/order', ...options, @@ -295,7 +295,7 @@ export const placeOrder = ( */ export const deleteOrder = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ url: '/store/order/{orderId}', ...options @@ -308,7 +308,7 @@ export const deleteOrder = ( */ export const getOrderById = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ url: '/store/order/{orderId}', ...options @@ -321,7 +321,7 @@ export const getOrderById = ( */ export const createUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post({ url: '/user', ...options, @@ -338,7 +338,7 @@ export const createUser = ( */ export const createUsersWithListInput = ( options?: Options -) => +): RequestResult => (options?.client ?? client).post< CreateUsersWithListInputResponses, CreateUsersWithListInputErrors, @@ -359,7 +359,7 @@ export const createUsersWithListInput = ( */ export const loginUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ url: '/user/login', ...options @@ -372,7 +372,7 @@ export const loginUser = ( */ export const logoutUser = ( options?: Options -) => +): RequestResult => (options?.client ?? client).get({ url: '/user/logout', ...options @@ -385,7 +385,7 @@ export const logoutUser = ( */ export const deleteUser = ( options: Options -) => +): RequestResult => (options.client ?? client).delete({ url: '/user/{username}', ...options @@ -398,7 +398,7 @@ export const deleteUser = ( */ export const getUserByName = ( options: Options -) => +): RequestResult => (options.client ?? client).get({ url: '/user/{username}', ...options @@ -411,7 +411,7 @@ export const getUserByName = ( */ export const updateUser = ( options: Options -) => +): RequestResult => (options.client ?? client).put({ url: '/user/{username}', ...options, diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/functions.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/functions.ts index 836b9bb2e..9dc2e9b5d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/functions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/functions.ts @@ -1,3 +1,4 @@ +import { clientFolderAbsolutePath } from '~/generate/client'; import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils'; import { createOperationComment, @@ -18,6 +19,16 @@ export const generateFlatSdk = ({ const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; + // Register RequestResult type for explicit return type annotations + const clientModule = clientFolderAbsolutePath(plugin.context.config); + const symbolRequestResult = !isNuxtClient + ? plugin.registerSymbol({ + external: clientModule, + kind: 'type', + name: 'RequestResult', + }) + : undefined; + plugin.forEach( 'operation', (event) => { @@ -61,12 +72,53 @@ export const generateFlatSdk = ({ operation, }), }); + + // Construct explicit return type to prevent circular type inference issues + // Only for non-Nuxt clients (Nuxt has a different return type structure) + let returnType: any; + + if (!isNuxtClient && symbolRequestResult) { + // Query symbols for response and error types + const symbolResponseType = plugin.querySymbol({ + category: 'type', + resource: 'operation', + resourceId: operation.id, + role: 'responses', + }); + const responseType = symbolResponseType?.placeholder || 'unknown'; + + const symbolErrorType = plugin.querySymbol({ + category: 'type', + resource: 'operation', + resourceId: operation.id, + role: 'errors', + }); + const errorType = symbolErrorType?.placeholder || 'unknown'; + + // Build return type: RequestResult + const typeArguments = [ + tsc.typeNode(responseType), + tsc.typeNode(errorType), + tsc.typeNode('ThrowOnError'), + ]; + + // Add responseStyle type argument if using 'data' response style + if (plugin.config.responseStyle === 'data') { + typeArguments.push(tsc.typeNode(tsc.ots.string('data'))); + } + + returnType = tsc.typeReferenceNode({ + typeArguments, + typeName: symbolRequestResult.placeholder, + }); + } + const node = tsc.constVariable({ comment: createOperationComment({ operation }), exportConst: true, expression: tsc.arrowFunction({ parameters: opParameters.parameters, - returnType: undefined, + returnType, statements, types: isNuxtClient ? [