diff --git a/.changeset/mighty-months-rhyme.md b/.changeset/mighty-months-rhyme.md new file mode 100644 index 000000000..f83af9cb8 --- /dev/null +++ b/.changeset/mighty-months-rhyme.md @@ -0,0 +1,7 @@ +--- +"@kubb/swagger-tanstack-query": patch +"@kubb/swagger-client": patch +"@kubb/swagger-swr": patch +--- + +use of `dataReturnType` to set res.data or res diff --git a/examples/advanced/src/gen/clients/axios/petService/addPet.ts b/examples/advanced/src/gen/clients/axios/petService/addPet.ts index 17a66f0b1..677eee7ca 100644 --- a/examples/advanced/src/gen/clients/axios/petService/addPet.ts +++ b/examples/advanced/src/gen/clients/axios/petService/addPet.ts @@ -10,10 +10,11 @@ export async function addPet( data: AddPetMutationRequest, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/pet`, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/deletePet.ts b/examples/advanced/src/gen/clients/axios/petService/deletePet.ts index 398931abd..50c2dfbe3 100644 --- a/examples/advanced/src/gen/clients/axios/petService/deletePet.ts +++ b/examples/advanced/src/gen/clients/axios/petService/deletePet.ts @@ -11,10 +11,11 @@ export async function deletePet( headers?: DeletePetHeaderParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...options.headers }, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts b/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts index c40484bf4..2f7d7d226 100644 --- a/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts +++ b/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts @@ -10,10 +10,11 @@ export async function findPetsByStatus( params?: FindPetsByStatusQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts b/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts index 53ae09557..60e667751 100644 --- a/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts +++ b/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts @@ -11,11 +11,12 @@ export async function findPetsByTags( params?: FindPetsByTagsQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'get', url: `/pet/findByTags`, params, headers: { ...headers, ...options.headers }, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/getPetById.ts b/examples/advanced/src/gen/clients/axios/petService/getPetById.ts index 7ff5d21dc..888249551 100644 --- a/examples/advanced/src/gen/clients/axios/petService/getPetById.ts +++ b/examples/advanced/src/gen/clients/axios/petService/getPetById.ts @@ -10,9 +10,10 @@ export async function getPetById( { petId }: GetPetByIdPathParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/updatePet.ts b/examples/advanced/src/gen/clients/axios/petService/updatePet.ts index 949a6be4c..5c6e70b87 100644 --- a/examples/advanced/src/gen/clients/axios/petService/updatePet.ts +++ b/examples/advanced/src/gen/clients/axios/petService/updatePet.ts @@ -10,10 +10,11 @@ export async function updatePet( data: UpdatePetMutationRequest, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'put', url: `/pet`, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts b/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts index 1d5911fd7..c5b3c8d42 100644 --- a/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts +++ b/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts @@ -14,10 +14,11 @@ export async function updatePetWithForm( params?: UpdatePetWithFormQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts b/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts index 523691afb..58c42e160 100644 --- a/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts +++ b/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts @@ -16,11 +16,12 @@ export async function uploadFile( params?: UploadFileQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/petsService/createPets.ts b/examples/advanced/src/gen/clients/axios/petsService/createPets.ts index 2dd084783..dd35c98f2 100644 --- a/examples/advanced/src/gen/clients/axios/petsService/createPets.ts +++ b/examples/advanced/src/gen/clients/axios/petsService/createPets.ts @@ -18,7 +18,7 @@ export async function createPets( params?: CreatePetsQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/pets/${uuid}`, params, @@ -26,4 +26,5 @@ export async function createPets( headers: { ...headers, ...options.headers }, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/createUser.ts b/examples/advanced/src/gen/clients/axios/userService/createUser.ts index d3d0c2b6c..5bb51ce0d 100644 --- a/examples/advanced/src/gen/clients/axios/userService/createUser.ts +++ b/examples/advanced/src/gen/clients/axios/userService/createUser.ts @@ -10,10 +10,11 @@ export async function createUser( data?: CreateUserMutationRequest, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/user`, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts b/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts index 85449c649..cd7e08c5c 100644 --- a/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts +++ b/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts @@ -13,10 +13,11 @@ export async function createUsersWithListInput( data?: CreateUsersWithListInputMutationRequest, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts b/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts index 294ab2982..7901ac9c9 100644 --- a/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts +++ b/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts @@ -10,9 +10,10 @@ export async function deleteUser( { username }: DeleteUserPathParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'delete', url: `/user/${username}`, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts b/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts index de2356d6e..be481ffd5 100644 --- a/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts +++ b/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts @@ -9,9 +9,10 @@ export async function getUserByName( { username }: GetUserByNamePathParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'get', url: `/user/${username}`, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/loginUser.ts b/examples/advanced/src/gen/clients/axios/userService/loginUser.ts index 24089da55..33448bf5a 100644 --- a/examples/advanced/src/gen/clients/axios/userService/loginUser.ts +++ b/examples/advanced/src/gen/clients/axios/userService/loginUser.ts @@ -9,10 +9,11 @@ export async function loginUser( params?: LoginUserQueryParams, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'get', url: `/user/login`, params, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts b/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts index 3c5771a37..8297c8cf9 100644 --- a/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts +++ b/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts @@ -6,9 +6,10 @@ import type { LogoutUserQueryResponse } from '../../../models/ts/userController/ * @summary Logs out current logged in user session * @link /user/logout */ export async function logoutUser(options: Partial[0]> = {}): Promise> { - return client({ + const res = await client({ method: 'get', url: `/user/logout`, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/axios/userService/updateUser.ts b/examples/advanced/src/gen/clients/axios/userService/updateUser.ts index bcd5b1025..9c386b159 100644 --- a/examples/advanced/src/gen/clients/axios/userService/updateUser.ts +++ b/examples/advanced/src/gen/clients/axios/userService/updateUser.ts @@ -11,10 +11,11 @@ export async function updateUser( data?: UpdateUserMutationRequest, options: Partial[0]> = {}, ): Promise> { - return client({ + const res = await client({ method: 'put', url: `/user/${username}`, data, ...options, }) + return res } diff --git a/examples/advanced/src/gen/clients/hooks/petController/useAddPet.ts b/examples/advanced/src/gen/clients/hooks/petController/useAddPet.ts index 9877dfb0f..62891b609 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useAddPet.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useAddPet.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet(options: { - mutation?: UseMutationOptions +export function useAddPet(options: { + mutation?: UseMutationOptions client?: AddPet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/petController/useDeletePet.ts b/examples/advanced/src/gen/clients/hooks/petController/useDeletePet.ts index 49ae90161..6a31d5ffd 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useDeletePet.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useDeletePet.ts @@ -12,7 +12,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: Awaited> - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,23 +21,20 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( - petId: DeletePetPathParams['petId'], - headers?: DeletePet['headerParams'], - options: { - mutation?: UseMutationOptions - client?: DeletePet['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useDeletePet(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { + mutation?: UseMutationOptions + client?: DeletePet['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts index 137b9fd9f..82dc00ddc 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts @@ -12,7 +12,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: Awaited> - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -81,12 +81,12 @@ export function findPetsByStatusInfiniteQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, ...options, @@ -95,7 +95,8 @@ export function findPetsByStatusInfiniteQueryOptions< ['test']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts index b7f65c4eb..89908c8a5 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts @@ -17,7 +17,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: FindPetsByTagsHeaderParams response: Awaited> - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -34,18 +33,19 @@ export function findPetsByTagsQueryOptions< headers: FindPetsByTags['headerParams'], params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, headers: { ...headers, ...options.headers }, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -88,12 +88,12 @@ export function findPetsByTagsInfiniteQueryOptions< headers: FindPetsByTags['headerParams'], params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByTags`, headers: { ...headers, ...options.headers }, @@ -103,7 +103,8 @@ export function findPetsByTagsInfiniteQueryOptions< ['test']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts b/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts index 875d46f87..bdd2f77ea 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts @@ -12,7 +12,6 @@ type GetPetById = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -79,16 +79,17 @@ export function getPetByIdInfiniteQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdInfiniteQueryKey(petId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/petController/useUpdatePet.ts b/examples/advanced/src/gen/clients/hooks/petController/useUpdatePet.ts index 97fa8f781..b0e3b6567 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useUpdatePet.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useUpdatePet.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet(options: { - mutation?: UseMutationOptions +export function useUpdatePet(options: { + mutation?: UseMutationOptions client?: UpdatePet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/petController/useUpdatePetWithForm.ts b/examples/advanced/src/gen/clients/hooks/petController/useUpdatePetWithForm.ts index 8c3eaa996..d0fd1bc35 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useUpdatePetWithForm.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useUpdatePetWithForm.ts @@ -17,7 +17,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: Awaited> - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,23 +25,20 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( - petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithForm['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UpdatePetWithForm['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { + mutation?: UseMutationOptions + client?: UpdatePetWithForm['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/petController/useUploadFile.ts b/examples/advanced/src/gen/clients/hooks/petController/useUploadFile.ts index f185e0cda..0f6a08ced 100644 --- a/examples/advanced/src/gen/clients/hooks/petController/useUploadFile.ts +++ b/examples/advanced/src/gen/clients/hooks/petController/useUploadFile.ts @@ -17,7 +17,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: Awaited> - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,24 +25,21 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( - petId: UploadFilePathParams['petId'], - params?: UploadFile['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UploadFile['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUploadFile(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { + mutation?: UseMutationOptions + client?: UploadFile['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/petsController/useCreatePets.ts b/examples/advanced/src/gen/clients/hooks/petsController/useCreatePets.ts index 94cfc5f64..8ddb334a5 100644 --- a/examples/advanced/src/gen/clients/hooks/petsController/useCreatePets.ts +++ b/examples/advanced/src/gen/clients/hooks/petsController/useCreatePets.ts @@ -20,7 +20,6 @@ type CreatePets = { queryParams: CreatePetsQueryParams headerParams: CreatePetsHeaderParams response: Awaited> - unionResponse: Awaited> | CreatePetsMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -29,26 +28,22 @@ type CreatePets = { /** * @summary Create a pet * @link /pets/:uuid */ -export function useCreatePets( - uuid: CreatePetsPathParams['uuid'], - headers: CreatePets['headerParams'], - params?: CreatePets['queryParams'], - options: { - mutation?: UseMutationOptions - client?: CreatePets['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useCreatePets(uuid: CreatePetsPathParams['uuid'], headers: CreatePets['headerParams'], params?: CreatePets['queryParams'], options: { + mutation?: UseMutationOptions + client?: CreatePets['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pets/${uuid}`, params, data, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts index 515dfa4a8..be5c38813 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser(options: { - mutation?: UseMutationOptions +export function useCreateUser(options: { + mutation?: UseMutationOptions client?: CreateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts b/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts index 4c3e90fc4..bfce5b40e 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,19 +29,20 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput(options: { - mutation?: UseMutationOptions +export function useCreateUsersWithListInput(options: { + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts index bbd14d424..6548355e1 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts @@ -12,7 +12,6 @@ type DeleteUser = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,18 +21,19 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useDeleteUser(username: DeleteUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: DeleteUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts b/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts index 0d50f6b72..8ed81d725 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts @@ -12,7 +12,6 @@ type GetUserByName = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -79,16 +79,17 @@ export function getUserByNameInfiniteQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameInfiniteQueryKey(username) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts index 2822b728b..34eaf1247 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts @@ -12,7 +12,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: Awaited> - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -79,12 +79,12 @@ export function loginUserInfiniteQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/login`, ...options, @@ -93,7 +93,8 @@ export function loginUserInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts index 3e550ccbe..5816a47b3 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts @@ -12,7 +12,6 @@ type LogoutUser = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,16 +24,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } @@ -72,16 +72,17 @@ export function logoutUserInfiniteQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res }, } } diff --git a/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts index 38d513ab1..c8f93844b 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts @@ -12,7 +12,6 @@ type UpdateUser = { queryParams: never headerParams: never response: Awaited> - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useUpdateUser(username: UpdateUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: UpdateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res }, ...mutationOptions, }) diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useAddPet.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useAddPet.ts index d7494dfc8..5cc127bb9 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useAddPet.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useAddPet.ts @@ -1,26 +1,40 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from '../../../models/ts/petController/AddPet' +type AddPetClient = typeof client +type AddPet = { + data: AddPetMutationResponse + error: AddPet405 + request: AddPetMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useAddPet(options?: { + mutation?: SWRMutationConfiguration + client?: AddPet['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url, { arg: data }) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useDeletePet.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useDeletePet.ts index de43ba451..a2814b41e 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useDeletePet.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useDeletePet.ts @@ -1,30 +1,40 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderParams, DeletePet400 } from '../../../models/ts/petController/DeletePet' +type DeletePetClient = typeof client +type DeletePet = { + data: DeletePetMutationResponse + error: DeletePet400 + request: never + pathParams: DeletePetPathParams + queryParams: never + headerParams: DeletePetHeaderParams + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( - petId: DeletePetPathParams['petId'], - headers?: DeletePetHeaderParams, - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useDeletePet(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options?: { + mutation?: SWRMutationConfiguration + client?: DeletePet['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url) => { + const res = await client({ method: 'delete', url, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByStatus.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByStatus.ts index b12b292bc..7e03d8cce 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByStatus.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByStatus.ts @@ -1,21 +1,35 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../../../models/ts/petController/FindPetsByStatus' -export function findPetsByStatusQueryOptions( - params?: FindPetsByStatusQueryParams, - options: Partial[0]> = {}, -): SWRConfiguration, TError> { +type FindPetsByStatusClient = typeof client +type FindPetsByStatus = { + data: FindPetsByStatusQueryResponse + error: FindPetsByStatus400 + request: never + pathParams: never + queryParams: FindPetsByStatusQueryParams + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function findPetsByStatusQueryOptions( + params?: FindPetsByStatus['queryParams'], + options: FindPetsByStatus['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res) + }) + return res }, } } @@ -23,15 +37,18 @@ export function findPetsByStatusQueryOptions(params?: FindPetsByStatusQueryParams, options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean -}): SWRResponse, TError> { +export function useFindPetsByStatus( + params?: FindPetsByStatus['queryParams'], + options?: { + query?: SWRConfiguration + client?: FindPetsByStatus['client']['paramaters'] + shouldFetch?: boolean + }, +): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/findByStatus` as const const query = useSWR< - ResponseConfig, + TData, TError, [ typeof url, diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByTags.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByTags.ts index 3b593611f..ca5a184ef 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByTags.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useFindPetsByTags.ts @@ -1,7 +1,6 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, @@ -9,20 +8,35 @@ import type { FindPetsByTags400, } from '../../../models/ts/petController/FindPetsByTags' -export function findPetsByTagsQueryOptions( - params?: FindPetsByTagsQueryParams, - headers?: FindPetsByTagsHeaderParams, - options: Partial[0]> = {}, -): SWRConfiguration, TError> { +type FindPetsByTagsClient = typeof client +type FindPetsByTags = { + data: FindPetsByTagsQueryResponse + error: FindPetsByTags400 + request: never + pathParams: never + queryParams: FindPetsByTagsQueryParams + headerParams: FindPetsByTagsHeaderParams + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function findPetsByTagsQueryOptions( + params?: FindPetsByTags['queryParams'], + headers?: FindPetsByTags['headerParams'], + options: FindPetsByTags['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, headers: { ...headers, ...options.headers }, ...options, - }).then(res => res) + }) + return res }, } } @@ -30,19 +44,19 @@ export function findPetsByTagsQueryOptions( - params?: FindPetsByTagsQueryParams, - headers?: FindPetsByTagsHeaderParams, +export function useFindPetsByTags( + params?: FindPetsByTags['queryParams'], + headers?: FindPetsByTags['headerParams'], options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> + query?: SWRConfiguration + client?: FindPetsByTags['client']['paramaters'] shouldFetch?: boolean }, -): SWRResponse, TError> { +): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/findByTags` as const const query = useSWR< - ResponseConfig, + TData, TError, [ typeof url, diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useGetPetById.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useGetPetById.ts index 286927ee6..bb0d390b1 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useGetPetById.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useGetPetById.ts @@ -1,20 +1,34 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../../../models/ts/petController/GetPetById' -export function getPetByIdQueryOptions( +type GetPetByIdClient = typeof client +type GetPetById = { + data: GetPetByIdQueryResponse + error: GetPetById400 | GetPetById404 + request: never + pathParams: GetPetByIdPathParams + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getPetByIdQueryOptions( petId: GetPetByIdPathParams['petId'], - options: Partial[0]> = {}, -): SWRConfiguration, TError> { + options: GetPetById['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res) + }) + return res }, } } @@ -22,14 +36,17 @@ export function getPetByIdQueryOptions(petId: GetPetByIdPathParams['petId'], options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean -}): SWRResponse, TError> { +export function useGetPetById( + petId: GetPetByIdPathParams['petId'], + options?: { + query?: SWRConfiguration + client?: GetPetById['client']['paramaters'] + shouldFetch?: boolean + }, +): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}` as const - const query = useSWR, TError, typeof url | null>(shouldFetch ? url : null, { + const query = useSWR(shouldFetch ? url : null, { ...getPetByIdQueryOptions(petId, clientOptions), ...queryOptions, }) diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePet.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePet.ts index 6f09be867..31cdca488 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePet.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePet.ts @@ -1,28 +1,40 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { UpdatePetMutationRequest, UpdatePetMutationResponse, UpdatePet400, UpdatePet404, UpdatePet405 } from '../../../models/ts/petController/UpdatePet' +type UpdatePetClient = typeof client +type UpdatePet = { + data: UpdatePetMutationResponse + error: UpdatePet400 | UpdatePet404 | UpdatePet405 + request: UpdatePetMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet( - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useUpdatePet(options?: { + mutation?: SWRMutationConfiguration + client?: UpdatePet['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url, { arg: data }) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url, { arg: data }) => { + const res = await client({ method: 'put', url, data, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePetWithForm.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePetWithForm.ts index c198862d7..97ba7b3b4 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePetWithForm.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useUpdatePetWithForm.ts @@ -1,7 +1,6 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { UpdatePetWithFormMutationResponse, UpdatePetWithFormPathParams, @@ -9,33 +8,44 @@ import type { UpdatePetWithForm405, } from '../../../models/ts/petController/UpdatePetWithForm' +type UpdatePetWithFormClient = typeof client +type UpdatePetWithForm = { + data: UpdatePetWithFormMutationResponse + error: UpdatePetWithForm405 + request: never + pathParams: UpdatePetWithFormPathParams + queryParams: UpdatePetWithFormQueryParams + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( - petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithFormQueryParams, - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options?: { + mutation?: SWRMutationConfiguration + client?: UpdatePetWithForm['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}` as const return useSWRMutation< - ResponseConfig, - TError, + UpdatePetWithForm['response'], + UpdatePetWithForm['error'], [ typeof url, typeof params, ] | null - >(shouldFetch ? [url, params] : null, (_url) => { - return client({ + >(shouldFetch ? [url, params] : null, async (_url) => { + const res = await client({ method: 'post', url, params, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/petSWRController/useUploadFile.ts b/examples/advanced/src/gen/clients/swr/petSWRController/useUploadFile.ts index d9ae1aeb6..ce10d5f64 100644 --- a/examples/advanced/src/gen/clients/swr/petSWRController/useUploadFile.ts +++ b/examples/advanced/src/gen/clients/swr/petSWRController/useUploadFile.ts @@ -1,7 +1,6 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { UploadFileMutationRequest, UploadFileMutationResponse, @@ -9,34 +8,45 @@ import type { UploadFileQueryParams, } from '../../../models/ts/petController/UploadFile' +type UploadFileClient = typeof client +type UploadFile = { + data: UploadFileMutationResponse + error: never + request: UploadFileMutationRequest + pathParams: UploadFilePathParams + queryParams: UploadFileQueryParams + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( - petId: UploadFilePathParams['petId'], - params?: UploadFileQueryParams, - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useUploadFile(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options?: { + mutation?: SWRMutationConfiguration + client?: UploadFile['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}/uploadImage` as const return useSWRMutation< - ResponseConfig, - TError, + UploadFile['response'], + UploadFile['error'], [ typeof url, typeof params, ] | null - >(shouldFetch ? [url, params] : null, (_url, { arg: data }) => { - return client({ + >(shouldFetch ? [url, params] : null, async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, params, data, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/petsSWRController/useCreatePets.ts b/examples/advanced/src/gen/clients/swr/petsSWRController/useCreatePets.ts index 04db511cc..5de1d4a8d 100644 --- a/examples/advanced/src/gen/clients/swr/petsSWRController/useCreatePets.ts +++ b/examples/advanced/src/gen/clients/swr/petsSWRController/useCreatePets.ts @@ -1,7 +1,6 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { CreatePetsMutationRequest, CreatePetsMutationResponse, @@ -12,30 +11,39 @@ import type { CreatePetsError, } from '../../../models/ts/petsController/CreatePets' +type CreatePetsClient = typeof client +type CreatePets = { + data: CreatePetsMutationResponse + error: CreatePets201 | CreatePetsError + request: CreatePetsMutationRequest + pathParams: CreatePetsPathParams + queryParams: CreatePetsQueryParams + headerParams: CreatePetsHeaderParams + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @summary Create a pet * @link /pets/:uuid */ -export function useCreatePets( - uuid: CreatePetsPathParams['uuid'], - params?: CreatePetsQueryParams, - headers?: CreatePetsHeaderParams, - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useCreatePets(uuid: CreatePetsPathParams['uuid'], params?: CreatePets['queryParams'], headers?: CreatePets['headerParams'], options?: { + mutation?: SWRMutationConfiguration + client?: CreatePets['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pets/${uuid}` as const return useSWRMutation< - ResponseConfig, - TError, + CreatePets['response'], + CreatePets['error'], [ typeof url, typeof params, ] | null - >(shouldFetch ? [url, params] : null, (_url, { arg: data }) => { - return client({ + >(shouldFetch ? [url, params] : null, async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, params, @@ -43,5 +51,6 @@ export function useCreatePets +type CreateUser = { + data: CreateUserMutationResponse + error: CreateUserError + request: CreateUserMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useCreateUser(options?: { + mutation?: SWRMutationConfiguration + client?: CreateUser['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url, { arg: data }) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useCreateUsersWithListInput.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useCreateUsersWithListInput.ts index df9cdb565..92ac04ef3 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useCreateUsersWithListInput.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useCreateUsersWithListInput.ts @@ -1,34 +1,52 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { CreateUsersWithListInputMutationRequest, CreateUsersWithListInputMutationResponse, CreateUsersWithListInputError, } from '../../../models/ts/userController/CreateUsersWithListInput' +type CreateUsersWithListInputClient = typeof client< + CreateUsersWithListInputMutationResponse, + CreateUsersWithListInputError, + CreateUsersWithListInputMutationRequest +> +type CreateUsersWithListInput = { + data: CreateUsersWithListInputMutationResponse + error: CreateUsersWithListInputError + request: CreateUsersWithListInputMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput< - TData = CreateUsersWithListInputMutationResponse, - TError = CreateUsersWithListInputError, - TVariables = CreateUsersWithListInputMutationRequest, ->(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useCreateUsersWithListInput(options?: { + mutation?: SWRMutationConfiguration + client?: CreateUsersWithListInput['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/createWithList` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url, { arg: data }) => { - return client({ - method: 'post', - url, - data, - ...clientOptions, - }) - }, mutationOptions) + return useSWRMutation( + shouldFetch ? url : null, + async (_url, { arg: data }) => { + const res = await client({ + method: 'post', + url, + data, + ...clientOptions, + }) + return res + }, + mutationOptions, + ) } diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useDeleteUser.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useDeleteUser.ts index 4363826e9..488690dfd 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useDeleteUser.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useDeleteUser.ts @@ -1,28 +1,39 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { DeleteUserMutationResponse, DeleteUserPathParams, DeleteUser400, DeleteUser404 } from '../../../models/ts/userController/DeleteUser' +type DeleteUserClient = typeof client +type DeleteUser = { + data: DeleteUserMutationResponse + error: DeleteUser400 | DeleteUser404 + request: never + pathParams: DeleteUserPathParams + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser( - username: DeleteUserPathParams['username'], - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useDeleteUser(username: DeleteUserPathParams['username'], options?: { + mutation?: SWRMutationConfiguration + client?: DeleteUser['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/${username}` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url) => { + const res = await client({ method: 'delete', url, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useGetUserByName.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useGetUserByName.ts index 9b3505155..17b2810f8 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useGetUserByName.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useGetUserByName.ts @@ -1,37 +1,51 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../../../models/ts/userController/GetUserByName' -export function getUserByNameQueryOptions( +type GetUserByNameClient = typeof client +type GetUserByName = { + data: GetUserByNameQueryResponse + error: GetUserByName400 | GetUserByName404 + request: never + pathParams: GetUserByNamePathParams + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getUserByNameQueryOptions( username: GetUserByNamePathParams['username'], - options: Partial[0]> = {}, -): SWRConfiguration, TError> { + options: GetUserByName['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res) + }) + return res }, } } /** * @summary Get user by user name * @link /user/:username */ -export function useGetUserByName( +export function useGetUserByName( username: GetUserByNamePathParams['username'], options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> + query?: SWRConfiguration + client?: GetUserByName['client']['paramaters'] shouldFetch?: boolean }, -): SWRResponse, TError> { +): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/${username}` as const - const query = useSWR, TError, typeof url | null>(shouldFetch ? url : null, { + const query = useSWR(shouldFetch ? url : null, { ...getUserByNameQueryOptions(username, clientOptions), ...queryOptions, }) diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useLoginUser.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useLoginUser.ts index 64b59be0e..2ac5b263d 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useLoginUser.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useLoginUser.ts @@ -1,36 +1,53 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../../../models/ts/userController/LoginUser' -export function loginUserQueryOptions( - params?: LoginUserQueryParams, - options: Partial[0]> = {}, -): SWRConfiguration, TError> { +type LoginUserClient = typeof client +type LoginUser = { + data: LoginUserQueryResponse + error: LoginUser400 + request: never + pathParams: never + queryParams: LoginUserQueryParams + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function loginUserQueryOptions( + params?: LoginUser['queryParams'], + options: LoginUser['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res) + }) + return res }, } } /** * @summary Logs user into the system * @link /user/login */ -export function useLoginUser(params?: LoginUserQueryParams, options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean -}): SWRResponse, TError> { +export function useLoginUser( + params?: LoginUser['queryParams'], + options?: { + query?: SWRConfiguration + client?: LoginUser['client']['paramaters'] + shouldFetch?: boolean + }, +): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/login` as const const query = useSWR< - ResponseConfig, + TData, TError, [ typeof url, diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useLogoutUser.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useLogoutUser.ts index ff64f2955..d3a9cbde0 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useLogoutUser.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useLogoutUser.ts @@ -1,33 +1,47 @@ import useSWR from 'swr' import client from '../../../../swr-client.ts' import type { SWRConfiguration, SWRResponse } from 'swr' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { LogoutUserQueryResponse, LogoutUserError } from '../../../models/ts/userController/LogoutUser' -export function logoutUserQueryOptions( - options: Partial[0]> = {}, -): SWRConfiguration, TError> { +type LogoutUserClient = typeof client +type LogoutUser = { + data: LogoutUserQueryResponse + error: LogoutUserError + request: never + pathParams: never + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function logoutUserQueryOptions( + options: LogoutUser['client']['paramaters'] = {}, +): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res) + }) + return res }, } } /** * @summary Logs out current logged in user session * @link /user/logout */ -export function useLogoutUser(options?: { - query?: SWRConfiguration, TError> - client?: Partial>[0]> +export function useLogoutUser(options?: { + query?: SWRConfiguration + client?: LogoutUser['client']['paramaters'] shouldFetch?: boolean -}): SWRResponse, TError> { +}): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/logout` as const - const query = useSWR, TError, typeof url | null>(shouldFetch ? url : null, { + const query = useSWR(shouldFetch ? url : null, { ...logoutUserQueryOptions(clientOptions), ...queryOptions, }) diff --git a/examples/advanced/src/gen/clients/swr/userSWRController/useUpdateUser.ts b/examples/advanced/src/gen/clients/swr/userSWRController/useUpdateUser.ts index 8839e4db1..f89c9d5df 100644 --- a/examples/advanced/src/gen/clients/swr/userSWRController/useUpdateUser.ts +++ b/examples/advanced/src/gen/clients/swr/userSWRController/useUpdateUser.ts @@ -1,29 +1,40 @@ import useSWRMutation from 'swr/mutation' import client from '../../../../swr-client.ts' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '../../../../swr-client.ts' import type { UpdateUserMutationRequest, UpdateUserMutationResponse, UpdateUserPathParams, UpdateUserError } from '../../../models/ts/userController/UpdateUser' +type UpdateUserClient = typeof client +type UpdateUser = { + data: UpdateUserMutationResponse + error: UpdateUserError + request: UpdateUserMutationRequest + pathParams: UpdateUserPathParams + queryParams: never + headerParams: never + response: Awaited> + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser( - username: UpdateUserPathParams['username'], - options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> - shouldFetch?: boolean - }, -): SWRMutationResponse, TError> { +export function useUpdateUser(username: UpdateUserPathParams['username'], options?: { + mutation?: SWRMutationConfiguration + client?: UpdateUser['client']['paramaters'] + shouldFetch?: boolean +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/${username}` as const - return useSWRMutation, TError, typeof url | null>(shouldFetch ? url : null, (_url, { arg: data }) => { - return client({ + return useSWRMutation(shouldFetch ? url : null, async (_url, { arg: data }) => { + const res = await client({ method: 'put', url, data, ...clientOptions, }) + return res }, mutationOptions) } diff --git a/examples/client/src/gen/clients/axios/petService/addPet.ts b/examples/client/src/gen/clients/axios/petService/addPet.ts index 2a54bd87b..51509d60d 100644 --- a/examples/client/src/gen/clients/axios/petService/addPet.ts +++ b/examples/client/src/gen/clients/axios/petService/addPet.ts @@ -10,11 +10,11 @@ export async function addPet( data: AddPetMutationRequest, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'post', url: `/pet`, data, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/deletePet.ts b/examples/client/src/gen/clients/axios/petService/deletePet.ts index f0a1df6d8..25862c28e 100644 --- a/examples/client/src/gen/clients/axios/petService/deletePet.ts +++ b/examples/client/src/gen/clients/axios/petService/deletePet.ts @@ -11,11 +11,11 @@ export async function deletePet( headers?: DeletePetHeaderParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...options.headers }, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/findPetsByStatus.ts b/examples/client/src/gen/clients/axios/petService/findPetsByStatus.ts index c5e6ef8d9..a6b7fc45b 100644 --- a/examples/client/src/gen/clients/axios/petService/findPetsByStatus.ts +++ b/examples/client/src/gen/clients/axios/petService/findPetsByStatus.ts @@ -10,11 +10,11 @@ export async function findPetsByStatus( params?: FindPetsByStatusQueryParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/findPetsByTags.ts b/examples/client/src/gen/clients/axios/petService/findPetsByTags.ts index 4ac24555f..dc00648b7 100644 --- a/examples/client/src/gen/clients/axios/petService/findPetsByTags.ts +++ b/examples/client/src/gen/clients/axios/petService/findPetsByTags.ts @@ -11,12 +11,12 @@ export async function findPetsByTags( params?: FindPetsByTagsQueryParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'get', url: `/pet/findByTags`, params, headers: { ...headers, ...options.headers }, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/getPetById.ts b/examples/client/src/gen/clients/axios/petService/getPetById.ts index 9325b9d31..f90e32424 100644 --- a/examples/client/src/gen/clients/axios/petService/getPetById.ts +++ b/examples/client/src/gen/clients/axios/petService/getPetById.ts @@ -10,10 +10,10 @@ export async function getPetById( petId: GetPetByIdPathParams['petId'], options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/updatePet.ts b/examples/client/src/gen/clients/axios/petService/updatePet.ts index b70ea8d85..aafbe1c5b 100644 --- a/examples/client/src/gen/clients/axios/petService/updatePet.ts +++ b/examples/client/src/gen/clients/axios/petService/updatePet.ts @@ -10,11 +10,11 @@ export async function updatePet( data: UpdatePetMutationRequest, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'put', url: `/pet`, data, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/updatePetWithForm.ts b/examples/client/src/gen/clients/axios/petService/updatePetWithForm.ts index 197ddd1d7..fd3c2aad8 100644 --- a/examples/client/src/gen/clients/axios/petService/updatePetWithForm.ts +++ b/examples/client/src/gen/clients/axios/petService/updatePetWithForm.ts @@ -14,11 +14,11 @@ export async function updatePetWithForm( params?: UpdatePetWithFormQueryParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petService/uploadFile.ts b/examples/client/src/gen/clients/axios/petService/uploadFile.ts index 5f14d2c9b..76700a923 100644 --- a/examples/client/src/gen/clients/axios/petService/uploadFile.ts +++ b/examples/client/src/gen/clients/axios/petService/uploadFile.ts @@ -16,12 +16,12 @@ export async function uploadFile( params?: UploadFileQueryParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...options, }) - return resData + return res.data } diff --git a/examples/client/src/gen/clients/axios/petsService/createPets.ts b/examples/client/src/gen/clients/axios/petsService/createPets.ts index ab0510261..192e8fc79 100644 --- a/examples/client/src/gen/clients/axios/petsService/createPets.ts +++ b/examples/client/src/gen/clients/axios/petsService/createPets.ts @@ -18,7 +18,7 @@ export async function createPets( params?: CreatePetsQueryParams, options: Partial[0]> = {}, ): Promise['data']> { - const { data: resData } = await client({ + const res = await client({ method: 'post', url: `/pets/${uuid}`, params, @@ -26,5 +26,5 @@ export async function createPets( headers: { ...headers, ...options.headers }, ...options, }) - return resData + return res.data } diff --git a/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts b/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts index 9f31fd315..ff782ee5d 100644 --- a/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPetHook(options: { - mutation?: UseMutationOptions +export function useAddPetHook(options: { + mutation?: UseMutationOptions client?: AddPet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts b/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts index 4712429a9..668d5dee2 100644 --- a/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUserHook(options: { - mutation?: UseMutationOptions +export function useCreateUserHook(options: { + mutation?: UseMutationOptions client?: CreateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts b/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts index 976a8bc7c..0a46fc3ab 100644 --- a/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,19 +29,20 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInputHook(options: { - mutation?: UseMutationOptions +export function useCreateUsersWithListInputHook(options: { + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts b/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts index 6aaff0d7c..1a99b2b4b 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts @@ -12,7 +12,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,18 +21,19 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions +export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { + mutation?: UseMutationOptions client?: DeleteOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts b/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts index 3a0fcfae9..41a97acf7 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts @@ -12,7 +12,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,23 +21,20 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePetHook( - petId: DeletePetPathParams['petId'], - headers?: DeletePet['headerParams'], - options: { - mutation?: UseMutationOptions - client?: DeletePet['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useDeletePetHook(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { + mutation?: UseMutationOptions + client?: DeletePet['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts b/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts index 9fe213ced..fe0e3a7c8 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts @@ -12,7 +12,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,18 +21,19 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: DeleteUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useFindPetsByStatusHook.ts b/examples/react-query-v5/src/gen/hooks/useFindPetsByStatusHook.ts index 26eb63dcf..11a902887 100644 --- a/examples/react-query-v5/src/gen/hooks/useFindPetsByStatusHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useFindPetsByStatusHook.ts @@ -21,7 +21,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,17 +36,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -90,12 +90,12 @@ export function findPetsByStatusInfiniteQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, ...options, @@ -104,7 +104,8 @@ export function findPetsByStatusInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -148,17 +149,18 @@ export function findPetsByStatusSuspenseQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusSuspenseQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useFindPetsByTagsHook.ts b/examples/react-query-v5/src/gen/hooks/useFindPetsByTagsHook.ts index 33a584236..3b86dc723 100644 --- a/examples/react-query-v5/src/gen/hooks/useFindPetsByTagsHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useFindPetsByTagsHook.ts @@ -21,7 +21,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,17 +36,18 @@ export function findPetsByTagsQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -89,12 +89,12 @@ export function findPetsByTagsInfiniteQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByTags`, ...options, @@ -103,7 +103,8 @@ export function findPetsByTagsInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -146,17 +147,18 @@ export function findPetsByTagsSuspenseQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsSuspenseQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useGetInventoryHook.ts b/examples/react-query-v5/src/gen/hooks/useGetInventoryHook.ts index ef5d93cef..84f816cca 100644 --- a/examples/react-query-v5/src/gen/hooks/useGetInventoryHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useGetInventoryHook.ts @@ -21,7 +21,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -34,18 +33,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -84,18 +82,17 @@ export function getInventoryInfiniteQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -135,16 +132,17 @@ export function getInventorySuspenseQueryOptions< TQueryFnData extends GetInventory['data'] = GetInventory['data'], TError = GetInventory['error'], TData = GetInventory['response'], ->(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventorySuspenseQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useGetOrderByIdHook.ts b/examples/react-query-v5/src/gen/hooks/useGetOrderByIdHook.ts index 639bd13d1..c1556e320 100644 --- a/examples/react-query-v5/src/gen/hooks/useGetOrderByIdHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useGetOrderByIdHook.ts @@ -21,7 +21,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,16 +36,17 @@ export function getOrderByIdQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -89,16 +89,17 @@ export function getOrderByIdInfiniteQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdInfiniteQueryKey(orderId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -142,16 +143,17 @@ export function getOrderByIdSuspenseQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdSuspenseQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useGetPetByIdHook.ts b/examples/react-query-v5/src/gen/hooks/useGetPetByIdHook.ts index aea3d3ba2..1c0086d63 100644 --- a/examples/react-query-v5/src/gen/hooks/useGetPetByIdHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useGetPetByIdHook.ts @@ -21,7 +21,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,16 +36,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -88,16 +88,17 @@ export function getPetByIdInfiniteQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdInfiniteQueryKey(petId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -140,16 +141,17 @@ export function getPetByIdSuspenseQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdSuspenseQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useGetUserByNameHook.ts b/examples/react-query-v5/src/gen/hooks/useGetUserByNameHook.ts index 18e26a741..e80d2b93d 100644 --- a/examples/react-query-v5/src/gen/hooks/useGetUserByNameHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useGetUserByNameHook.ts @@ -21,7 +21,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,16 +36,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -88,16 +88,17 @@ export function getUserByNameInfiniteQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameInfiniteQueryKey(username) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -140,16 +141,17 @@ export function getUserByNameSuspenseQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameSuspenseQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useLoginUserHook.ts b/examples/react-query-v5/src/gen/hooks/useLoginUserHook.ts index 3f77c4170..215fc8c56 100644 --- a/examples/react-query-v5/src/gen/hooks/useLoginUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useLoginUserHook.ts @@ -21,7 +21,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -37,17 +36,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -88,12 +88,12 @@ export function loginUserInfiniteQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/login`, ...options, @@ -102,7 +102,8 @@ export function loginUserInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -144,17 +145,18 @@ export function loginUserSuspenseQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserSuspenseQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/useLogoutUserHook.ts b/examples/react-query-v5/src/gen/hooks/useLogoutUserHook.ts index ea07c8746..cefab78f0 100644 --- a/examples/react-query-v5/src/gen/hooks/useLogoutUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useLogoutUserHook.ts @@ -21,7 +21,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -34,16 +33,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -81,16 +81,17 @@ export function logoutUserInfiniteQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, initialPageParam: 0, getNextPageParam: (lastPage) => lastPage['id'], @@ -129,16 +130,17 @@ export function logoutUserSuspenseQueryOptions< TQueryFnData extends LogoutUser['data'] = LogoutUser['data'], TError = LogoutUser['error'], TData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserSuspenseQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts b/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts index c4feff7a3..cb0f44765 100644 --- a/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts +++ b/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts @@ -12,7 +12,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrderHook(options: { - mutation?: UseMutationOptions +export function usePlaceOrderHook(options: { + mutation?: UseMutationOptions client?: PlaceOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts b/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts index e2807ba76..c814ffba4 100644 --- a/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts +++ b/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts @@ -12,7 +12,6 @@ type PlaceOrderPatch = { queryParams: never headerParams: never response: PlaceOrderPatchMutationResponse - unionResponse: Awaited> | PlaceOrderPatchMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type PlaceOrderPatch = { * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function usePlaceOrderPatchHook(options: { - mutation?: UseMutationOptions +export function usePlaceOrderPatchHook(options: { + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'patch', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts index 6e4aadcbf..a3279d22e 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePetHook(options: { - mutation?: UseMutationOptions +export function useUpdatePetHook(options: { + mutation?: UseMutationOptions client?: UpdatePet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts index 3afc99aa8..7b0d3f936 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts @@ -17,7 +17,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,23 +25,20 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithFormHook( - petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithForm['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UpdatePetWithForm['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUpdatePetWithFormHook(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { + mutation?: UseMutationOptions + client?: UpdatePetWithForm['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts index 2f4469cfe..0e3c2050b 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts @@ -12,7 +12,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: UpdateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts b/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts index 07038ab3c..86fae9575 100644 --- a/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts @@ -12,7 +12,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -21,24 +20,21 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFileHook( - petId: UploadFilePathParams['petId'], - params?: UploadFile['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UploadFile['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUploadFileHook(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { + mutation?: UseMutationOptions + client?: UploadFile['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useAddPetHook.ts b/examples/react-query/src/gen/hooks/useAddPetHook.ts index 9f31fd315..ff782ee5d 100644 --- a/examples/react-query/src/gen/hooks/useAddPetHook.ts +++ b/examples/react-query/src/gen/hooks/useAddPetHook.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPetHook(options: { - mutation?: UseMutationOptions +export function useAddPetHook(options: { + mutation?: UseMutationOptions client?: AddPet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useCreateUserHook.ts b/examples/react-query/src/gen/hooks/useCreateUserHook.ts index 4712429a9..668d5dee2 100644 --- a/examples/react-query/src/gen/hooks/useCreateUserHook.ts +++ b/examples/react-query/src/gen/hooks/useCreateUserHook.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUserHook(options: { - mutation?: UseMutationOptions +export function useCreateUserHook(options: { + mutation?: UseMutationOptions client?: CreateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts b/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts index 976a8bc7c..0a46fc3ab 100644 --- a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts +++ b/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,19 +29,20 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInputHook(options: { - mutation?: UseMutationOptions +export function useCreateUsersWithListInputHook(options: { + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts b/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts index 6aaff0d7c..1a99b2b4b 100644 --- a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts +++ b/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts @@ -12,7 +12,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,18 +21,19 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions +export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { + mutation?: UseMutationOptions client?: DeleteOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useDeletePetHook.ts b/examples/react-query/src/gen/hooks/useDeletePetHook.ts index 3a0fcfae9..41a97acf7 100644 --- a/examples/react-query/src/gen/hooks/useDeletePetHook.ts +++ b/examples/react-query/src/gen/hooks/useDeletePetHook.ts @@ -12,7 +12,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,23 +21,20 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePetHook( - petId: DeletePetPathParams['petId'], - headers?: DeletePet['headerParams'], - options: { - mutation?: UseMutationOptions - client?: DeletePet['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useDeletePetHook(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { + mutation?: UseMutationOptions + client?: DeletePet['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts b/examples/react-query/src/gen/hooks/useDeleteUserHook.ts index 9fe213ced..fe0e3a7c8 100644 --- a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts +++ b/examples/react-query/src/gen/hooks/useDeleteUserHook.ts @@ -12,7 +12,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,18 +21,19 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: DeleteUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts b/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts index 9b0f2b70d..f9a46fa33 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts +++ b/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts @@ -12,7 +12,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -81,12 +81,12 @@ export function findPetsByStatusInfiniteQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, ...options, @@ -95,7 +95,8 @@ export function findPetsByStatusInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts b/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts index 71801259e..29f35b1e3 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts +++ b/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts @@ -12,7 +12,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function findPetsByTagsQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -80,12 +80,12 @@ export function findPetsByTagsInfiniteQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByTags`, ...options, @@ -94,7 +94,8 @@ export function findPetsByTagsInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useGetInventoryHook.ts b/examples/react-query/src/gen/hooks/useGetInventoryHook.ts index 637797647..5f90845f4 100644 --- a/examples/react-query/src/gen/hooks/useGetInventoryHook.ts +++ b/examples/react-query/src/gen/hooks/useGetInventoryHook.ts @@ -12,7 +12,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,16 +24,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -73,18 +73,17 @@ export function getInventoryInfiniteQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts b/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts index 86785f988..4f95ccf58 100644 --- a/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts +++ b/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts @@ -12,7 +12,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getOrderByIdQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -80,16 +80,17 @@ export function getOrderByIdInfiniteQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdInfiniteQueryKey(orderId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts b/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts index ef06cea58..96c7dad72 100644 --- a/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts +++ b/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts @@ -12,7 +12,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -79,16 +79,17 @@ export function getPetByIdInfiniteQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdInfiniteQueryKey(petId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts b/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts index 9e85b35a0..37860ace5 100644 --- a/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts +++ b/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts @@ -12,7 +12,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -79,16 +79,17 @@ export function getUserByNameInfiniteQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameInfiniteQueryKey(username) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useLoginUserHook.ts b/examples/react-query/src/gen/hooks/useLoginUserHook.ts index 343a1f65a..313d4df70 100644 --- a/examples/react-query/src/gen/hooks/useLoginUserHook.ts +++ b/examples/react-query/src/gen/hooks/useLoginUserHook.ts @@ -12,7 +12,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -79,12 +79,12 @@ export function loginUserInfiniteQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/login`, ...options, @@ -93,7 +93,8 @@ export function loginUserInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/useLogoutUserHook.ts b/examples/react-query/src/gen/hooks/useLogoutUserHook.ts index 738163363..acb5b6e32 100644 --- a/examples/react-query/src/gen/hooks/useLogoutUserHook.ts +++ b/examples/react-query/src/gen/hooks/useLogoutUserHook.ts @@ -12,7 +12,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,16 +24,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -72,16 +72,17 @@ export function logoutUserInfiniteQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts b/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts index c4feff7a3..cb0f44765 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts +++ b/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts @@ -12,7 +12,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrderHook(options: { - mutation?: UseMutationOptions +export function usePlaceOrderHook(options: { + mutation?: UseMutationOptions client?: PlaceOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts b/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts index e2807ba76..c814ffba4 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts +++ b/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts @@ -12,7 +12,6 @@ type PlaceOrderPatch = { queryParams: never headerParams: never response: PlaceOrderPatchMutationResponse - unionResponse: Awaited> | PlaceOrderPatchMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type PlaceOrderPatch = { * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function usePlaceOrderPatchHook(options: { - mutation?: UseMutationOptions +export function usePlaceOrderPatchHook(options: { + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'patch', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts b/examples/react-query/src/gen/hooks/useUpdatePetHook.ts index 6e4aadcbf..a3279d22e 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdatePetHook.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePetHook(options: { - mutation?: UseMutationOptions +export function useUpdatePetHook(options: { + mutation?: UseMutationOptions client?: UpdatePet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts b/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts index 3afc99aa8..7b0d3f936 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts @@ -17,7 +17,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,23 +25,20 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithFormHook( - petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithForm['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UpdatePetWithForm['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUpdatePetWithFormHook(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { + mutation?: UseMutationOptions + client?: UpdatePetWithForm['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts b/examples/react-query/src/gen/hooks/useUpdateUserHook.ts index 2f4469cfe..0e3c2050b 100644 --- a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdateUserHook.ts @@ -12,7 +12,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,19 +21,20 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: UpdateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/react-query/src/gen/hooks/useUploadFileHook.ts b/examples/react-query/src/gen/hooks/useUploadFileHook.ts index 07038ab3c..86fae9575 100644 --- a/examples/react-query/src/gen/hooks/useUploadFileHook.ts +++ b/examples/react-query/src/gen/hooks/useUploadFileHook.ts @@ -12,7 +12,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -21,24 +20,21 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFileHook( - petId: UploadFilePathParams['petId'], - params?: UploadFile['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UploadFile['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUploadFileHook(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { + mutation?: UseMutationOptions + client?: UploadFile['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/simple-single/src/gen/hooks.ts b/examples/simple-single/src/gen/hooks.ts index b66ff0fd7..9d9142e13 100644 --- a/examples/simple-single/src/gen/hooks.ts +++ b/examples/simple-single/src/gen/hooks.ts @@ -81,7 +81,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -91,19 +90,20 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet(options: { - mutation?: UseMutationOptions +export function useUpdatePet(options: { + mutation?: UseMutationOptions client?: UpdatePet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -118,7 +118,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -128,19 +127,20 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet(options: { - mutation?: UseMutationOptions +export function useAddPet(options: { + mutation?: UseMutationOptions client?: AddPet['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -155,7 +155,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -171,17 +170,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -223,7 +223,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -239,17 +238,18 @@ export function findPetsByTagsQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -291,7 +291,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -307,16 +306,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -358,7 +358,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -367,23 +366,20 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( - petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithForm['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UpdatePetWithForm['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { + mutation?: UseMutationOptions + client?: UpdatePetWithForm['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -398,7 +394,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -408,23 +403,20 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( - petId: DeletePetPathParams['petId'], - headers?: DeletePet['headerParams'], - options: { - mutation?: UseMutationOptions - client?: DeletePet['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useDeletePet(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { + mutation?: UseMutationOptions + client?: DeletePet['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -439,7 +431,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -448,24 +439,21 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( - petId: UploadFilePathParams['petId'], - params?: UploadFile['queryParams'], - options: { - mutation?: UseMutationOptions - client?: UploadFile['client']['paramaters'] - } = {}, -): UseMutationResult { +export function useUploadFile(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { + mutation?: UseMutationOptions + client?: UploadFile['client']['paramaters'] +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -480,7 +468,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -493,16 +480,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -544,7 +532,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -554,19 +541,20 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrder(options: { - mutation?: UseMutationOptions +export function usePlaceOrder(options: { + mutation?: UseMutationOptions client?: PlaceOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -581,7 +569,6 @@ type PlaceOrderPatch = { queryParams: never headerParams: never response: PlaceOrderPatchMutationResponse - unionResponse: Awaited> | PlaceOrderPatchMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -591,19 +578,20 @@ type PlaceOrderPatch = { * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function usePlaceOrderPatch(options: { - mutation?: UseMutationOptions +export function usePlaceOrderPatch(options: { + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'patch', url: `/store/order`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -618,7 +606,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -634,16 +621,17 @@ export function getOrderByIdQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -685,7 +673,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -695,18 +682,19 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrder(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions +export function useDeleteOrder(orderId: DeleteOrderPathParams['orderId'], options: { + mutation?: UseMutationOptions client?: DeleteOrder['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -721,7 +709,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -731,19 +718,20 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser(options: { - mutation?: UseMutationOptions +export function useCreateUser(options: { + mutation?: UseMutationOptions client?: CreateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -762,7 +750,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -772,19 +759,20 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput(options: { - mutation?: UseMutationOptions +export function useCreateUsersWithListInput(options: { + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -799,7 +787,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -815,17 +802,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -866,7 +854,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -879,16 +866,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -929,7 +917,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -945,16 +932,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then(res => res?.data || res) + }) + return res.data }, } } @@ -995,7 +983,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -1005,19 +992,20 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useUpdateUser(username: UpdateUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: UpdateUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) @@ -1032,7 +1020,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -1042,18 +1029,19 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions +export function useDeleteUser(username: DeleteUserPathParams['username'], options: { + mutation?: UseMutationOptions client?: DeleteUser['client']['paramaters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { - return client({ + return useMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then(res => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/addPetQuery.ts b/examples/solid-query/src/gen/hooks/addPetQuery.ts index 510eafc0a..f29c289cf 100644 --- a/examples/solid-query/src/gen/hooks/addPetQuery.ts +++ b/examples/solid-query/src/gen/hooks/addPetQuery.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function addPetQuery( +export function addPetQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: AddPet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/createUserQuery.ts b/examples/solid-query/src/gen/hooks/createUserQuery.ts index 456cae9cb..8d007706d 100644 --- a/examples/solid-query/src/gen/hooks/createUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/createUserQuery.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function createUserQuery( +export function createUserQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: CreateUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts b/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts index c6db3714b..f7fb54321 100644 --- a/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts +++ b/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,21 +29,22 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function createUsersWithListInputQuery( +export function createUsersWithListInputQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts b/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts index 1c2daf0bd..33f224ec7 100644 --- a/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts +++ b/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts @@ -12,7 +12,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function deleteOrderQuery( +export function deleteOrderQuery( orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeleteOrder['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/deletePetQuery.ts b/examples/solid-query/src/gen/hooks/deletePetQuery.ts index 6dfb6ce42..6537bb571 100644 --- a/examples/solid-query/src/gen/hooks/deletePetQuery.ts +++ b/examples/solid-query/src/gen/hooks/deletePetQuery.ts @@ -12,7 +12,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,23 +21,24 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function deletePetQuery( +export function deletePetQuery( petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeletePet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/deleteUserQuery.ts b/examples/solid-query/src/gen/hooks/deleteUserQuery.ts index decd1d5b3..2dbb741f6 100644 --- a/examples/solid-query/src/gen/hooks/deleteUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/deleteUserQuery.ts @@ -12,7 +12,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function deleteUserQuery( +export function deleteUserQuery( username: DeleteUserPathParams['username'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeleteUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/findPetsByStatusQuery.ts b/examples/solid-query/src/gen/hooks/findPetsByStatusQuery.ts index 255cd1327..44e907f31 100644 --- a/examples/solid-query/src/gen/hooks/findPetsByStatusQuery.ts +++ b/examples/solid-query/src/gen/hooks/findPetsByStatusQuery.ts @@ -12,7 +12,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/findPetsByTagsQuery.ts b/examples/solid-query/src/gen/hooks/findPetsByTagsQuery.ts index 7047a05b5..9bddcbfc3 100644 --- a/examples/solid-query/src/gen/hooks/findPetsByTagsQuery.ts +++ b/examples/solid-query/src/gen/hooks/findPetsByTagsQuery.ts @@ -12,7 +12,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function findPetsByTagsQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/getInventoryQuery.ts b/examples/solid-query/src/gen/hooks/getInventoryQuery.ts index 54a3ebd23..386618a89 100644 --- a/examples/solid-query/src/gen/hooks/getInventoryQuery.ts +++ b/examples/solid-query/src/gen/hooks/getInventoryQuery.ts @@ -12,7 +12,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,18 +24,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/getOrderByIdQuery.ts b/examples/solid-query/src/gen/hooks/getOrderByIdQuery.ts index 6387ba855..b441ff2c2 100644 --- a/examples/solid-query/src/gen/hooks/getOrderByIdQuery.ts +++ b/examples/solid-query/src/gen/hooks/getOrderByIdQuery.ts @@ -12,7 +12,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getOrderByIdQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/getPetByIdQuery.ts b/examples/solid-query/src/gen/hooks/getPetByIdQuery.ts index b09527091..b11ea5976 100644 --- a/examples/solid-query/src/gen/hooks/getPetByIdQuery.ts +++ b/examples/solid-query/src/gen/hooks/getPetByIdQuery.ts @@ -12,7 +12,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/getUserByNameQuery.ts b/examples/solid-query/src/gen/hooks/getUserByNameQuery.ts index 05c92635a..4a7794a2e 100644 --- a/examples/solid-query/src/gen/hooks/getUserByNameQuery.ts +++ b/examples/solid-query/src/gen/hooks/getUserByNameQuery.ts @@ -12,7 +12,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,16 +27,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/loginUserQuery.ts b/examples/solid-query/src/gen/hooks/loginUserQuery.ts index f8672d650..33005a615 100644 --- a/examples/solid-query/src/gen/hooks/loginUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/loginUserQuery.ts @@ -12,7 +12,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,17 +27,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/logoutUserQuery.ts b/examples/solid-query/src/gen/hooks/logoutUserQuery.ts index 7db97d50d..0a9d45cda 100644 --- a/examples/solid-query/src/gen/hooks/logoutUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/logoutUserQuery.ts @@ -12,7 +12,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,16 +24,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts b/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts index d1f804cdc..1fe9d4ea6 100644 --- a/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts +++ b/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts @@ -12,7 +12,6 @@ type PlaceOrderPatch = { queryParams: never headerParams: never response: PlaceOrderPatchMutationResponse - unionResponse: Awaited> | PlaceOrderPatchMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type PlaceOrderPatch = { * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function placeOrderPatchQuery( +export function placeOrderPatchQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: PlaceOrderPatch['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'patch', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/placeOrderQuery.ts b/examples/solid-query/src/gen/hooks/placeOrderQuery.ts index 73e71809b..09b7c7140 100644 --- a/examples/solid-query/src/gen/hooks/placeOrderQuery.ts +++ b/examples/solid-query/src/gen/hooks/placeOrderQuery.ts @@ -12,7 +12,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function placeOrderQuery( +export function placeOrderQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: PlaceOrder['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/updatePetQuery.ts b/examples/solid-query/src/gen/hooks/updatePetQuery.ts index 881f194b5..b18b19295 100644 --- a/examples/solid-query/src/gen/hooks/updatePetQuery.ts +++ b/examples/solid-query/src/gen/hooks/updatePetQuery.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function updatePetQuery( +export function updatePetQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdatePet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts b/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts index 413170cd6..9f7de03f2 100644 --- a/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts +++ b/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts @@ -17,7 +17,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,23 +25,24 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function updatePetWithFormQuery( +export function updatePetWithFormQuery( petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdatePetWithForm['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/updateUserQuery.ts b/examples/solid-query/src/gen/hooks/updateUserQuery.ts index 0ac0161f2..4071e6f7d 100644 --- a/examples/solid-query/src/gen/hooks/updateUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/updateUserQuery.ts @@ -12,7 +12,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,22 +21,23 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function updateUserQuery( +export function updateUserQuery( username: UpdateUserPathParams['username'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdateUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/solid-query/src/gen/hooks/uploadFileQuery.ts b/examples/solid-query/src/gen/hooks/uploadFileQuery.ts index 564d2ebe9..e49b53982 100644 --- a/examples/solid-query/src/gen/hooks/uploadFileQuery.ts +++ b/examples/solid-query/src/gen/hooks/uploadFileQuery.ts @@ -12,7 +12,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -21,24 +20,25 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function uploadFileQuery( +export function uploadFileQuery( petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UploadFile['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/addPetQuery.ts b/examples/svelte-query/src/gen/hooks/addPetQuery.ts index 35951058f..e15416f0a 100644 --- a/examples/svelte-query/src/gen/hooks/addPetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/addPetQuery.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function addPetQuery( +export function addPetQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: AddPet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/createUserQuery.ts b/examples/svelte-query/src/gen/hooks/createUserQuery.ts index 3b2b078b1..0525427eb 100644 --- a/examples/svelte-query/src/gen/hooks/createUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/createUserQuery.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function createUserQuery( +export function createUserQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: CreateUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts b/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts index 6d16e9f68..666fcbdc3 100644 --- a/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts +++ b/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,21 +29,22 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function createUsersWithListInputQuery( +export function createUsersWithListInputQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts b/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts index 52dfed3b3..eec6aa5e2 100644 --- a/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts @@ -12,7 +12,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function deleteOrderQuery( +export function deleteOrderQuery( orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeleteOrder['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/deletePetQuery.ts b/examples/svelte-query/src/gen/hooks/deletePetQuery.ts index bf1de8a4d..b1aef9bf6 100644 --- a/examples/svelte-query/src/gen/hooks/deletePetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deletePetQuery.ts @@ -12,7 +12,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,23 +21,24 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function deletePetQuery( +export function deletePetQuery( petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeletePet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts b/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts index d64929c5e..3ac6f3b9e 100644 --- a/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts @@ -12,7 +12,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function deleteUserQuery( +export function deleteUserQuery( username: DeleteUserPathParams['username'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: DeleteUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/findPetsByStatusQuery.ts b/examples/svelte-query/src/gen/hooks/findPetsByStatusQuery.ts index 3201f9f7e..e57606c51 100644 --- a/examples/svelte-query/src/gen/hooks/findPetsByStatusQuery.ts +++ b/examples/svelte-query/src/gen/hooks/findPetsByStatusQuery.ts @@ -19,7 +19,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,17 +34,18 @@ export function findPetsByStatusQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -91,12 +91,12 @@ export function findPetsByStatusInfiniteQueryOptions< >( params?: FindPetsByStatus['queryParams'], options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, ...options, @@ -105,7 +105,8 @@ export function findPetsByStatusInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/findPetsByTagsQuery.ts b/examples/svelte-query/src/gen/hooks/findPetsByTagsQuery.ts index 71817f5af..128a31714 100644 --- a/examples/svelte-query/src/gen/hooks/findPetsByTagsQuery.ts +++ b/examples/svelte-query/src/gen/hooks/findPetsByTagsQuery.ts @@ -19,7 +19,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,17 +34,18 @@ export function findPetsByTagsQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -90,12 +90,12 @@ export function findPetsByTagsInfiniteQueryOptions< >( params?: FindPetsByTags['queryParams'], options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/findByTags`, ...options, @@ -104,7 +104,8 @@ export function findPetsByTagsInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/getInventoryQuery.ts b/examples/svelte-query/src/gen/hooks/getInventoryQuery.ts index 3896a5c0b..d6c63916d 100644 --- a/examples/svelte-query/src/gen/hooks/getInventoryQuery.ts +++ b/examples/svelte-query/src/gen/hooks/getInventoryQuery.ts @@ -19,7 +19,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -32,18 +31,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -86,16 +84,17 @@ export function getInventoryInfiniteQueryOptions< TQueryData = GetInventory['response'], >( options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getInventoryInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/getOrderByIdQuery.ts b/examples/svelte-query/src/gen/hooks/getOrderByIdQuery.ts index 64fdd7895..57b868bf7 100644 --- a/examples/svelte-query/src/gen/hooks/getOrderByIdQuery.ts +++ b/examples/svelte-query/src/gen/hooks/getOrderByIdQuery.ts @@ -19,7 +19,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,16 +34,17 @@ export function getOrderByIdQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(orderId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -90,16 +90,17 @@ export function getOrderByIdInfiniteQueryOptions< >( orderId: GetOrderByIdPathParams['orderId'], options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdInfiniteQueryKey(orderId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/getPetByIdQuery.ts b/examples/svelte-query/src/gen/hooks/getPetByIdQuery.ts index 5eef8fabc..72998be7c 100644 --- a/examples/svelte-query/src/gen/hooks/getPetByIdQuery.ts +++ b/examples/svelte-query/src/gen/hooks/getPetByIdQuery.ts @@ -19,7 +19,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,16 +34,17 @@ export function getPetByIdQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(petId) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -89,16 +89,17 @@ export function getPetByIdInfiniteQueryOptions< >( petId: GetPetByIdPathParams['petId'], options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdInfiniteQueryKey(petId) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/getUserByNameQuery.ts b/examples/svelte-query/src/gen/hooks/getUserByNameQuery.ts index 0624045be..83972b544 100644 --- a/examples/svelte-query/src/gen/hooks/getUserByNameQuery.ts +++ b/examples/svelte-query/src/gen/hooks/getUserByNameQuery.ts @@ -19,7 +19,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,16 +34,17 @@ export function getUserByNameQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(username) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -89,16 +89,17 @@ export function getUserByNameInfiniteQueryOptions< >( username: GetUserByNamePathParams['username'], options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameInfiniteQueryKey(username) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/loginUserQuery.ts b/examples/svelte-query/src/gen/hooks/loginUserQuery.ts index 53fe3a0b5..f3bbfaaab 100644 --- a/examples/svelte-query/src/gen/hooks/loginUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/loginUserQuery.ts @@ -19,7 +19,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -35,17 +34,18 @@ export function loginUserQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(params) return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -89,12 +89,12 @@ export function loginUserInfiniteQueryOptions< >( params?: LoginUser['queryParams'], options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserInfiniteQueryKey(params) return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/login`, ...options, @@ -103,7 +103,8 @@ export function loginUserInfiniteQueryOptions< ['id']: pageParam, ...(options.params || {}), }, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/logoutUserQuery.ts b/examples/svelte-query/src/gen/hooks/logoutUserQuery.ts index 156da527b..dc511bcf2 100644 --- a/examples/svelte-query/src/gen/hooks/logoutUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/logoutUserQuery.ts @@ -19,7 +19,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -32,16 +31,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } @@ -81,18 +81,17 @@ export function logoutUserInfiniteQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->( - options: LogoutUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserInfiniteQueryKey() return { queryKey, - queryFn: ({ pageParam }) => { - return client({ + queryFn: async ({ pageParam }) => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts b/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts index 9e73a141e..8dcbfbd1f 100644 --- a/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts +++ b/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts @@ -12,7 +12,6 @@ type PlaceOrderPatch = { queryParams: never headerParams: never response: PlaceOrderPatchMutationResponse - unionResponse: Awaited> | PlaceOrderPatchMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type PlaceOrderPatch = { * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function placeOrderPatchQuery( +export function placeOrderPatchQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: PlaceOrderPatch['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'patch', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts b/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts index b1a7eb6a7..e3ad13d7b 100644 --- a/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts +++ b/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts @@ -12,7 +12,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function placeOrderQuery( +export function placeOrderQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: PlaceOrder['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/updatePetQuery.ts b/examples/svelte-query/src/gen/hooks/updatePetQuery.ts index 204e4c8dd..02bea9249 100644 --- a/examples/svelte-query/src/gen/hooks/updatePetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updatePetQuery.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function updatePetQuery( +export function updatePetQuery( options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdatePet['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts b/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts index e8f4333b4..9a07ae767 100644 --- a/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts @@ -17,7 +17,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,23 +25,24 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function updatePetWithFormQuery( +export function updatePetWithFormQuery( petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdatePetWithForm['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: () => { - return client({ + return createMutation({ + mutationFn: async () => { + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/updateUserQuery.ts b/examples/svelte-query/src/gen/hooks/updateUserQuery.ts index 74adf54c5..e3aac6cce 100644 --- a/examples/svelte-query/src/gen/hooks/updateUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updateUserQuery.ts @@ -12,7 +12,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,22 +21,23 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function updateUserQuery( +export function updateUserQuery( username: UpdateUserPathParams['username'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UpdateUser['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts b/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts index 72899af55..b9352d3fe 100644 --- a/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts +++ b/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts @@ -12,7 +12,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -21,24 +20,25 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function uploadFileQuery( +export function uploadFileQuery( petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: CreateMutationOptions + mutation?: CreateMutationOptions client?: UploadFile['client']['paramaters'] } = {}, -): CreateMutationResult { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation({ - mutationFn: (data) => { - return client({ + return createMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/swr/src/gen/hooks/useAddPet.ts b/examples/swr/src/gen/hooks/useAddPet.ts index 65d67bb32..2cdbb0b5f 100644 --- a/examples/swr/src/gen/hooks/useAddPet.ts +++ b/examples/swr/src/gen/hooks/useAddPet.ts @@ -1,29 +1,43 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from '../models/AddPet' +type AddPetClient = typeof client +type AddPet = { + data: AddPetMutationResponse + error: AddPet405 + request: AddPetMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: AddPetMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useAddPet(options?: { + mutation?: SWRMutationConfiguration + client?: AddPet['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useCreateUser.ts b/examples/swr/src/gen/hooks/useCreateUser.ts index c7bae4ab9..59a1db7ef 100644 --- a/examples/swr/src/gen/hooks/useCreateUser.ts +++ b/examples/swr/src/gen/hooks/useCreateUser.ts @@ -1,29 +1,43 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { CreateUserMutationRequest, CreateUserMutationResponse, CreateUserError } from '../models/CreateUser' +type CreateUserClient = typeof client +type CreateUser = { + data: CreateUserMutationResponse + error: CreateUserError + request: CreateUserMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: CreateUserMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useCreateUser(options?: { + mutation?: SWRMutationConfiguration + client?: CreateUser['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useCreateUsersWithListInput.ts b/examples/swr/src/gen/hooks/useCreateUsersWithListInput.ts index 0d551ffab..ebc9c85e3 100644 --- a/examples/swr/src/gen/hooks/useCreateUsersWithListInput.ts +++ b/examples/swr/src/gen/hooks/useCreateUsersWithListInput.ts @@ -1,37 +1,51 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { CreateUsersWithListInputMutationRequest, CreateUsersWithListInputMutationResponse, CreateUsersWithListInputError, } from '../models/CreateUsersWithListInput' +type CreateUsersWithListInputClient = typeof client< + CreateUsersWithListInputMutationResponse, + CreateUsersWithListInputError, + CreateUsersWithListInputMutationRequest +> +type CreateUsersWithListInput = { + data: CreateUsersWithListInputMutationResponse + error: CreateUsersWithListInputError + request: CreateUsersWithListInputMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: CreateUsersWithListInputMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput< - TData = CreateUsersWithListInputMutationResponse, - TError = CreateUsersWithListInputError, - TVariables = CreateUsersWithListInputMutationRequest, ->(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useCreateUsersWithListInput(options?: { + mutation?: SWRMutationConfiguration + client?: CreateUsersWithListInput['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/createWithList` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useDeleteOrder.ts b/examples/swr/src/gen/hooks/useDeleteOrder.ts index 6ef56cb19..7470eb198 100644 --- a/examples/swr/src/gen/hooks/useDeleteOrder.ts +++ b/examples/swr/src/gen/hooks/useDeleteOrder.ts @@ -1,31 +1,45 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { DeleteOrderMutationResponse, DeleteOrderPathParams, DeleteOrder400, DeleteOrder404 } from '../models/DeleteOrder' +type DeleteOrderClient = typeof client +type DeleteOrder = { + data: DeleteOrderMutationResponse + error: DeleteOrder400 | DeleteOrder404 + request: never + pathParams: DeleteOrderPathParams + queryParams: never + headerParams: never + response: DeleteOrderMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrder( +export function useDeleteOrder( orderId: DeleteOrderPathParams['orderId'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: DeleteOrder['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/store/order/${orderId}` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url) => { - return client({ + async (_url) => { + const res = await client({ method: 'delete', url, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useDeletePet.ts b/examples/swr/src/gen/hooks/useDeletePet.ts index 3600890ae..34770bb8b 100644 --- a/examples/swr/src/gen/hooks/useDeletePet.ts +++ b/examples/swr/src/gen/hooks/useDeletePet.ts @@ -1,33 +1,47 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderParams, DeletePet400 } from '../models/DeletePet' +type DeletePetClient = typeof client +type DeletePet = { + data: DeletePetMutationResponse + error: DeletePet400 + request: never + pathParams: DeletePetPathParams + queryParams: never + headerParams: DeletePetHeaderParams + response: DeletePetMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( +export function useDeletePet( petId: DeletePetPathParams['petId'], - headers?: DeletePetHeaderParams, + headers?: DeletePet['headerParams'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: DeletePet['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url) => { - return client({ + async (_url) => { + const res = await client({ method: 'delete', url, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useDeleteUser.ts b/examples/swr/src/gen/hooks/useDeleteUser.ts index 60be150bb..de7618c48 100644 --- a/examples/swr/src/gen/hooks/useDeleteUser.ts +++ b/examples/swr/src/gen/hooks/useDeleteUser.ts @@ -1,31 +1,45 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { DeleteUserMutationResponse, DeleteUserPathParams, DeleteUser400, DeleteUser404 } from '../models/DeleteUser' +type DeleteUserClient = typeof client +type DeleteUser = { + data: DeleteUserMutationResponse + error: DeleteUser400 | DeleteUser404 + request: never + pathParams: DeleteUserPathParams + queryParams: never + headerParams: never + response: DeleteUserMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser( +export function useDeleteUser( username: DeleteUserPathParams['username'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: DeleteUser['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/${username}` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url) => { - return client({ + async (_url) => { + const res = await client({ method: 'delete', url, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useFindPetsByStatus.ts b/examples/swr/src/gen/hooks/useFindPetsByStatus.ts index fd6e3a3dc..4a6592008 100644 --- a/examples/swr/src/gen/hooks/useFindPetsByStatus.ts +++ b/examples/swr/src/gen/hooks/useFindPetsByStatus.ts @@ -3,18 +3,33 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../models/FindPetsByStatus' -export function findPetsByStatusQueryOptions( - params?: FindPetsByStatusQueryParams, - options: Partial[0]> = {}, +type FindPetsByStatusClient = typeof client +type FindPetsByStatus = { + data: FindPetsByStatusQueryResponse + error: FindPetsByStatus400 + request: never + pathParams: never + queryParams: FindPetsByStatusQueryParams + headerParams: never + response: FindPetsByStatusQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function findPetsByStatusQueryOptions( + params?: FindPetsByStatus['queryParams'], + options: FindPetsByStatus['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then((res) => res.data) + }) + return res.data }, } } @@ -22,11 +37,11 @@ export function findPetsByStatusQueryOptions( - params?: FindPetsByStatusQueryParams, +export function useFindPetsByStatus( + params?: FindPetsByStatus['queryParams'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: FindPetsByStatus['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useFindPetsByTags.ts b/examples/swr/src/gen/hooks/useFindPetsByTags.ts index 687c0009b..ef31a943f 100644 --- a/examples/swr/src/gen/hooks/useFindPetsByTags.ts +++ b/examples/swr/src/gen/hooks/useFindPetsByTags.ts @@ -3,18 +3,33 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../models/FindPetsByTags' -export function findPetsByTagsQueryOptions( - params?: FindPetsByTagsQueryParams, - options: Partial[0]> = {}, +type FindPetsByTagsClient = typeof client +type FindPetsByTags = { + data: FindPetsByTagsQueryResponse + error: FindPetsByTags400 + request: never + pathParams: never + queryParams: FindPetsByTagsQueryParams + headerParams: never + response: FindPetsByTagsQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function findPetsByTagsQueryOptions( + params?: FindPetsByTags['queryParams'], + options: FindPetsByTags['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then((res) => res.data) + }) + return res.data }, } } @@ -22,11 +37,11 @@ export function findPetsByTagsQueryOptions( - params?: FindPetsByTagsQueryParams, +export function useFindPetsByTags( + params?: FindPetsByTags['queryParams'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: FindPetsByTags['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useGetInventory.ts b/examples/swr/src/gen/hooks/useGetInventory.ts index 1dcd39c56..53d3bfd40 100644 --- a/examples/swr/src/gen/hooks/useGetInventory.ts +++ b/examples/swr/src/gen/hooks/useGetInventory.ts @@ -3,16 +3,31 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { GetInventoryQueryResponse } from '../models/GetInventory' -export function getInventoryQueryOptions( - options: Partial[0]> = {}, +type GetInventoryClient = typeof client +type GetInventory = { + data: GetInventoryQueryResponse + error: never + request: never + pathParams: never + queryParams: never + headerParams: never + response: GetInventoryQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getInventoryQueryOptions( + options: GetInventory['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res.data) + }) + return res.data }, } } @@ -20,9 +35,9 @@ export function getInventoryQueryOptions(options?: { +export function useGetInventory(options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: GetInventory['client']['paramaters'] shouldFetch?: boolean }): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} diff --git a/examples/swr/src/gen/hooks/useGetOrderById.ts b/examples/swr/src/gen/hooks/useGetOrderById.ts index 18a35c410..c0bb05d6a 100644 --- a/examples/swr/src/gen/hooks/useGetOrderById.ts +++ b/examples/swr/src/gen/hooks/useGetOrderById.ts @@ -3,17 +3,32 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { GetOrderByIdQueryResponse, GetOrderByIdPathParams, GetOrderById400, GetOrderById404 } from '../models/GetOrderById' -export function getOrderByIdQueryOptions( +type GetOrderByIdClient = typeof client +type GetOrderById = { + data: GetOrderByIdQueryResponse + error: GetOrderById400 | GetOrderById404 + request: never + pathParams: GetOrderByIdPathParams + queryParams: never + headerParams: never + response: GetOrderByIdQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getOrderByIdQueryOptions( orderId: GetOrderByIdPathParams['orderId'], - options: Partial[0]> = {}, + options: GetOrderById['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res.data) + }) + return res.data }, } } @@ -21,11 +36,11 @@ export function getOrderByIdQueryOptions 10. Other values will generate exceptions. * @summary Find purchase order by ID * @link /store/order/:orderId */ -export function useGetOrderById( +export function useGetOrderById( orderId: GetOrderByIdPathParams['orderId'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: GetOrderById['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useGetPetById.ts b/examples/swr/src/gen/hooks/useGetPetById.ts index 12e9aa5a8..8951c6a6f 100644 --- a/examples/swr/src/gen/hooks/useGetPetById.ts +++ b/examples/swr/src/gen/hooks/useGetPetById.ts @@ -3,17 +3,32 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../models/GetPetById' -export function getPetByIdQueryOptions( +type GetPetByIdClient = typeof client +type GetPetById = { + data: GetPetByIdQueryResponse + error: GetPetById400 | GetPetById404 + request: never + pathParams: GetPetByIdPathParams + queryParams: never + headerParams: never + response: GetPetByIdQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getPetByIdQueryOptions( petId: GetPetByIdPathParams['petId'], - options: Partial[0]> = {}, + options: GetPetById['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res.data) + }) + return res.data }, } } @@ -21,11 +36,11 @@ export function getPetByIdQueryOptions( +export function useGetPetById( petId: GetPetByIdPathParams['petId'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: GetPetById['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useGetUserByName.ts b/examples/swr/src/gen/hooks/useGetUserByName.ts index 99fef6b74..d06f4024c 100644 --- a/examples/swr/src/gen/hooks/useGetUserByName.ts +++ b/examples/swr/src/gen/hooks/useGetUserByName.ts @@ -3,28 +3,43 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../models/GetUserByName' -export function getUserByNameQueryOptions( +type GetUserByNameClient = typeof client +type GetUserByName = { + data: GetUserByNameQueryResponse + error: GetUserByName400 | GetUserByName404 + request: never + pathParams: GetUserByNamePathParams + queryParams: never + headerParams: never + response: GetUserByNameQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function getUserByNameQueryOptions( username: GetUserByNamePathParams['username'], - options: Partial[0]> = {}, + options: GetUserByName['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res.data) + }) + return res.data }, } } /** * @summary Get user by user name * @link /user/:username */ -export function useGetUserByName( +export function useGetUserByName( username: GetUserByNamePathParams['username'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: GetUserByName['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useLoginUser.ts b/examples/swr/src/gen/hooks/useLoginUser.ts index 037411876..2717269c4 100644 --- a/examples/swr/src/gen/hooks/useLoginUser.ts +++ b/examples/swr/src/gen/hooks/useLoginUser.ts @@ -3,29 +3,44 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../models/LoginUser' -export function loginUserQueryOptions( - params?: LoginUserQueryParams, - options: Partial[0]> = {}, +type LoginUserClient = typeof client +type LoginUser = { + data: LoginUserQueryResponse + error: LoginUser400 + request: never + pathParams: never + queryParams: LoginUserQueryParams + headerParams: never + response: LoginUserQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function loginUserQueryOptions( + params?: LoginUser['queryParams'], + options: LoginUser['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then((res) => res.data) + }) + return res.data }, } } /** * @summary Logs user into the system * @link /user/login */ -export function useLoginUser( - params?: LoginUserQueryParams, +export function useLoginUser( + params?: LoginUser['queryParams'], options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: LoginUser['client']['paramaters'] shouldFetch?: boolean }, ): SWRResponse { diff --git a/examples/swr/src/gen/hooks/useLogoutUser.ts b/examples/swr/src/gen/hooks/useLogoutUser.ts index 4684678c2..d2bea44b3 100644 --- a/examples/swr/src/gen/hooks/useLogoutUser.ts +++ b/examples/swr/src/gen/hooks/useLogoutUser.ts @@ -3,25 +3,40 @@ import client from '@kubb/swagger-client/client' import type { SWRConfiguration, SWRResponse } from 'swr' import type { LogoutUserQueryResponse, LogoutUserError } from '../models/LogoutUser' -export function logoutUserQueryOptions( - options: Partial[0]> = {}, +type LogoutUserClient = typeof client +type LogoutUser = { + data: LogoutUserQueryResponse + error: LogoutUserError + request: never + pathParams: never + queryParams: never + headerParams: never + response: LogoutUserQueryResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} +export function logoutUserQueryOptions( + options: LogoutUser['client']['paramaters'] = {}, ): SWRConfiguration { return { - fetcher: () => { - return client({ + fetcher: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res.data) + }) + return res.data }, } } /** * @summary Logs out current logged in user session * @link /user/logout */ -export function useLogoutUser(options?: { +export function useLogoutUser(options?: { query?: SWRConfiguration - client?: Partial>[0]> + client?: LogoutUser['client']['paramaters'] shouldFetch?: boolean }): SWRResponse { const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} diff --git a/examples/swr/src/gen/hooks/usePlaceOrder.ts b/examples/swr/src/gen/hooks/usePlaceOrder.ts index 520bd4773..301df4cc5 100644 --- a/examples/swr/src/gen/hooks/usePlaceOrder.ts +++ b/examples/swr/src/gen/hooks/usePlaceOrder.ts @@ -1,29 +1,43 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { PlaceOrderMutationRequest, PlaceOrderMutationResponse, PlaceOrder405 } from '../models/PlaceOrder' +type PlaceOrderClient = typeof client +type PlaceOrder = { + data: PlaceOrderMutationResponse + error: PlaceOrder405 + request: PlaceOrderMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: PlaceOrderMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrder(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function usePlaceOrder(options?: { + mutation?: SWRMutationConfiguration + client?: PlaceOrder['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/store/order` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/usePlaceOrderPatch.ts b/examples/swr/src/gen/hooks/usePlaceOrderPatch.ts index 00bb339c8..8cd6300c5 100644 --- a/examples/swr/src/gen/hooks/usePlaceOrderPatch.ts +++ b/examples/swr/src/gen/hooks/usePlaceOrderPatch.ts @@ -1,33 +1,43 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { PlaceOrderPatchMutationRequest, PlaceOrderPatchMutationResponse, PlaceOrderPatch405 } from '../models/PlaceOrderPatch' +type PlaceOrderPatchClient = typeof client +type PlaceOrderPatch = { + data: PlaceOrderPatchMutationResponse + error: PlaceOrderPatch405 + request: PlaceOrderPatchMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: PlaceOrderPatchMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Place a new order in the store with patch * @summary Place an order for a pet with patch * @link /store/order */ -export function usePlaceOrderPatch< - TData = PlaceOrderPatchMutationResponse, - TError = PlaceOrderPatch405, - TVariables = PlaceOrderPatchMutationRequest, ->(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function usePlaceOrderPatch(options?: { + mutation?: SWRMutationConfiguration + client?: PlaceOrderPatch['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/store/order` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'patch', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useUpdatePet.ts b/examples/swr/src/gen/hooks/useUpdatePet.ts index 616739bd8..180814e20 100644 --- a/examples/swr/src/gen/hooks/useUpdatePet.ts +++ b/examples/swr/src/gen/hooks/useUpdatePet.ts @@ -1,33 +1,43 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { UpdatePetMutationRequest, UpdatePetMutationResponse, UpdatePet400, UpdatePet404, UpdatePet405 } from '../models/UpdatePet' +type UpdatePetClient = typeof client +type UpdatePet = { + data: UpdatePetMutationResponse + error: UpdatePet400 | UpdatePet404 | UpdatePet405 + request: UpdatePetMutationRequest + pathParams: never + queryParams: never + headerParams: never + response: UpdatePetMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet< - TData = UpdatePetMutationResponse, - TError = UpdatePet400 | UpdatePet404 | UpdatePet405, - TVariables = UpdatePetMutationRequest, ->(options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> +export function useUpdatePet(options?: { + mutation?: SWRMutationConfiguration + client?: UpdatePet['client']['paramaters'] shouldFetch?: boolean -}): SWRMutationResponse, TError> { +}): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'put', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useUpdatePetWithForm.ts b/examples/swr/src/gen/hooks/useUpdatePetWithForm.ts index e0d180525..7b175750c 100644 --- a/examples/swr/src/gen/hooks/useUpdatePetWithForm.ts +++ b/examples/swr/src/gen/hooks/useUpdatePetWithForm.ts @@ -1,7 +1,6 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { UpdatePetWithFormMutationResponse, UpdatePetWithFormPathParams, @@ -9,29 +8,44 @@ import type { UpdatePetWithForm405, } from '../models/UpdatePetWithForm' +type UpdatePetWithFormClient = typeof client +type UpdatePetWithForm = { + data: UpdatePetWithFormMutationResponse + error: UpdatePetWithForm405 + request: never + pathParams: UpdatePetWithFormPathParams + queryParams: UpdatePetWithFormQueryParams + headerParams: never + response: UpdatePetWithFormMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( +export function useUpdatePetWithForm( petId: UpdatePetWithFormPathParams['petId'], - params?: UpdatePetWithFormQueryParams, + params?: UpdatePetWithForm['queryParams'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: UpdatePetWithForm['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}` as const - return useSWRMutation, TError, [typeof url, typeof params] | null>( + return useSWRMutation( shouldFetch ? [url, params] : null, - (_url) => { - return client({ + async (_url) => { + const res = await client({ method: 'post', url, params, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useUpdateUser.ts b/examples/swr/src/gen/hooks/useUpdateUser.ts index 99ed44ff1..beefb284c 100644 --- a/examples/swr/src/gen/hooks/useUpdateUser.ts +++ b/examples/swr/src/gen/hooks/useUpdateUser.ts @@ -1,32 +1,46 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { UpdateUserMutationRequest, UpdateUserMutationResponse, UpdateUserPathParams, UpdateUserError } from '../models/UpdateUser' +type UpdateUserClient = typeof client +type UpdateUser = { + data: UpdateUserMutationResponse + error: UpdateUserError + request: UpdateUserMutationRequest + pathParams: UpdateUserPathParams + queryParams: never + headerParams: never + response: UpdateUserMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser( +export function useUpdateUser( username: UpdateUserPathParams['username'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: UpdateUser['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/user/${username}` as const - return useSWRMutation, TError, typeof url | null>( + return useSWRMutation( shouldFetch ? url : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'put', url, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/swr/src/gen/hooks/useUploadFile.ts b/examples/swr/src/gen/hooks/useUploadFile.ts index bc8ff08bc..e6aa6dbe1 100644 --- a/examples/swr/src/gen/hooks/useUploadFile.ts +++ b/examples/swr/src/gen/hooks/useUploadFile.ts @@ -1,33 +1,47 @@ import useSWRMutation from 'swr/mutation' import client from '@kubb/swagger-client/client' import type { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation' -import type { ResponseConfig } from '@kubb/swagger-client/client' import type { UploadFileMutationRequest, UploadFileMutationResponse, UploadFilePathParams, UploadFileQueryParams } from '../models/UploadFile' +type UploadFileClient = typeof client +type UploadFile = { + data: UploadFileMutationResponse + error: never + request: UploadFileMutationRequest + pathParams: UploadFilePathParams + queryParams: UploadFileQueryParams + headerParams: never + response: UploadFileMutationResponse + client: { + paramaters: Partial[0]> + return: Awaited> + } +} /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( +export function useUploadFile( petId: UploadFilePathParams['petId'], - params?: UploadFileQueryParams, + params?: UploadFile['queryParams'], options?: { - mutation?: SWRMutationConfiguration, TError> - client?: Partial>[0]> + mutation?: SWRMutationConfiguration + client?: UploadFile['client']['paramaters'] shouldFetch?: boolean }, -): SWRMutationResponse, TError> { +): SWRMutationResponse { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {} const url = `/pet/${petId}/uploadImage` as const - return useSWRMutation, TError, [typeof url, typeof params] | null>( + return useSWRMutation( shouldFetch ? [url, params] : null, - (_url, { arg: data }) => { - return client({ + async (_url, { arg: data }) => { + const res = await client({ method: 'post', url, params, data, ...clientOptions, }) + return res.data }, mutationOptions, ) diff --git a/examples/vue-query-v5/src/gen/hooks/useAddPet.ts b/examples/vue-query-v5/src/gen/hooks/useAddPet.ts index 99c796558..e8f9fb039 100644 --- a/examples/vue-query-v5/src/gen/hooks/useAddPet.ts +++ b/examples/vue-query-v5/src/gen/hooks/useAddPet.ts @@ -12,7 +12,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet( +export function useAddPet( options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: AddPet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useCreateUser.ts b/examples/vue-query-v5/src/gen/hooks/useCreateUser.ts index 0de00fe4f..d52b192aa 100644 --- a/examples/vue-query-v5/src/gen/hooks/useCreateUser.ts +++ b/examples/vue-query-v5/src/gen/hooks/useCreateUser.ts @@ -12,7 +12,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser( +export function useCreateUser( options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useCreateUsersWithListInput.ts b/examples/vue-query-v5/src/gen/hooks/useCreateUsersWithListInput.ts index 76b2adaff..3168903b7 100644 --- a/examples/vue-query-v5/src/gen/hooks/useCreateUsersWithListInput.ts +++ b/examples/vue-query-v5/src/gen/hooks/useCreateUsersWithListInput.ts @@ -20,7 +20,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,21 +29,22 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput( +export function useCreateUsersWithListInput( options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useDeleteOrder.ts b/examples/vue-query-v5/src/gen/hooks/useDeleteOrder.ts index 69c32e1e8..f6d338496 100644 --- a/examples/vue-query-v5/src/gen/hooks/useDeleteOrder.ts +++ b/examples/vue-query-v5/src/gen/hooks/useDeleteOrder.ts @@ -14,7 +14,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -24,22 +23,23 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrder( +export function useDeleteOrder( refOrderId: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteOrder['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const orderId = unref(refOrderId) - return client({ + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useDeletePet.ts b/examples/vue-query-v5/src/gen/hooks/useDeletePet.ts index f3564e8ac..e8deb433e 100644 --- a/examples/vue-query-v5/src/gen/hooks/useDeletePet.ts +++ b/examples/vue-query-v5/src/gen/hooks/useDeletePet.ts @@ -14,7 +14,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -24,25 +23,26 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( +export function useDeletePet( refPetId: MaybeRef, refHeaders?: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeletePet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const petId = unref(refPetId) const headers = unref(refHeaders) - return client({ + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useDeleteUser.ts b/examples/vue-query-v5/src/gen/hooks/useDeleteUser.ts index fa86b9612..acbfe5a58 100644 --- a/examples/vue-query-v5/src/gen/hooks/useDeleteUser.ts +++ b/examples/vue-query-v5/src/gen/hooks/useDeleteUser.ts @@ -14,7 +14,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -24,22 +23,23 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser( +export function useDeleteUser( refUsername: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useFindPetsByStatus.ts b/examples/vue-query-v5/src/gen/hooks/useFindPetsByStatus.ts index 3c76b7a4b..a91d85c5f 100644 --- a/examples/vue-query-v5/src/gen/hooks/useFindPetsByStatus.ts +++ b/examples/vue-query-v5/src/gen/hooks/useFindPetsByStatus.ts @@ -14,7 +14,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,18 +30,19 @@ export function findPetsByStatusQueryOptions< >( refParams?: MaybeRef, options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useFindPetsByTags.ts b/examples/vue-query-v5/src/gen/hooks/useFindPetsByTags.ts index df7712958..44df0041f 100644 --- a/examples/vue-query-v5/src/gen/hooks/useFindPetsByTags.ts +++ b/examples/vue-query-v5/src/gen/hooks/useFindPetsByTags.ts @@ -14,7 +14,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,18 +29,19 @@ export function findPetsByTagsQueryOptions< >( refParams?: MaybeRef, options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useGetInventory.ts b/examples/vue-query-v5/src/gen/hooks/useGetInventory.ts index 42a9e3bce..b55c04b47 100644 --- a/examples/vue-query-v5/src/gen/hooks/useGetInventory.ts +++ b/examples/vue-query-v5/src/gen/hooks/useGetInventory.ts @@ -12,7 +12,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,18 +24,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useGetOrderById.ts b/examples/vue-query-v5/src/gen/hooks/useGetOrderById.ts index 3f4386ee4..f2bf7ed16 100644 --- a/examples/vue-query-v5/src/gen/hooks/useGetOrderById.ts +++ b/examples/vue-query-v5/src/gen/hooks/useGetOrderById.ts @@ -14,7 +14,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,17 +30,18 @@ export function getOrderByIdQueryOptions< >( refOrderId: MaybeRef, options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(refOrderId) return { queryKey, - queryFn: () => { + queryFn: async () => { const orderId = unref(refOrderId) - return client({ + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useGetPetById.ts b/examples/vue-query-v5/src/gen/hooks/useGetPetById.ts index 3c3047d05..efca1451b 100644 --- a/examples/vue-query-v5/src/gen/hooks/useGetPetById.ts +++ b/examples/vue-query-v5/src/gen/hooks/useGetPetById.ts @@ -14,7 +14,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,17 +29,18 @@ export function getPetByIdQueryOptions< >( refPetId: MaybeRef, options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(refPetId) return { queryKey, - queryFn: () => { + queryFn: async () => { const petId = unref(refPetId) - return client({ + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useGetUserByName.ts b/examples/vue-query-v5/src/gen/hooks/useGetUserByName.ts index 6730928b8..66840f704 100644 --- a/examples/vue-query-v5/src/gen/hooks/useGetUserByName.ts +++ b/examples/vue-query-v5/src/gen/hooks/useGetUserByName.ts @@ -14,7 +14,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,17 +30,18 @@ export function getUserByNameQueryOptions< >( refUsername: MaybeRef, options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(refUsername) return { queryKey, - queryFn: () => { + queryFn: async () => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useLoginUser.ts b/examples/vue-query-v5/src/gen/hooks/useLoginUser.ts index 10c35291f..618fabda1 100644 --- a/examples/vue-query-v5/src/gen/hooks/useLoginUser.ts +++ b/examples/vue-query-v5/src/gen/hooks/useLoginUser.ts @@ -14,7 +14,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -30,18 +29,19 @@ export function loginUserQueryOptions< >( refParams?: MaybeRef, options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/useLogoutUser.ts b/examples/vue-query-v5/src/gen/hooks/useLogoutUser.ts index 773feeac1..2fc4a5459 100644 --- a/examples/vue-query-v5/src/gen/hooks/useLogoutUser.ts +++ b/examples/vue-query-v5/src/gen/hooks/useLogoutUser.ts @@ -12,7 +12,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,16 +24,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query-v5/src/gen/hooks/usePlaceOrder.ts b/examples/vue-query-v5/src/gen/hooks/usePlaceOrder.ts index d2764cf7d..eb0e9ca78 100644 --- a/examples/vue-query-v5/src/gen/hooks/usePlaceOrder.ts +++ b/examples/vue-query-v5/src/gen/hooks/usePlaceOrder.ts @@ -12,7 +12,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrder( +export function usePlaceOrder( options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrder['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useUpdatePet.ts b/examples/vue-query-v5/src/gen/hooks/useUpdatePet.ts index bb470ae09..e9b32b6b5 100644 --- a/examples/vue-query-v5/src/gen/hooks/useUpdatePet.ts +++ b/examples/vue-query-v5/src/gen/hooks/useUpdatePet.ts @@ -12,7 +12,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -22,21 +21,22 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet( +export function useUpdatePet( options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useUpdatePetWithForm.ts b/examples/vue-query-v5/src/gen/hooks/useUpdatePetWithForm.ts index 184f7e057..5548a3fbe 100644 --- a/examples/vue-query-v5/src/gen/hooks/useUpdatePetWithForm.ts +++ b/examples/vue-query-v5/src/gen/hooks/useUpdatePetWithForm.ts @@ -19,7 +19,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -28,25 +27,26 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( +export function useUpdatePetWithForm( refPetId: MaybeRef, refParams?: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePetWithForm['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const petId = unref(refPetId) const params = unref(refParams) - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useUpdateUser.ts b/examples/vue-query-v5/src/gen/hooks/useUpdateUser.ts index 598217f27..df32e13bf 100644 --- a/examples/vue-query-v5/src/gen/hooks/useUpdateUser.ts +++ b/examples/vue-query-v5/src/gen/hooks/useUpdateUser.ts @@ -14,7 +14,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -24,23 +23,24 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser( +export function useUpdateUser( refUsername: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdateUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { + return useMutation({ + mutationFn: async (data) => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query-v5/src/gen/hooks/useUploadFile.ts b/examples/vue-query-v5/src/gen/hooks/useUploadFile.ts index edfd8a26f..8fb2ebcf0 100644 --- a/examples/vue-query-v5/src/gen/hooks/useUploadFile.ts +++ b/examples/vue-query-v5/src/gen/hooks/useUploadFile.ts @@ -14,7 +14,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -23,26 +22,27 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( +export function useUploadFile( refPetId: MaybeRef, refParams?: MaybeRef, options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UploadFile['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { + return useMutation({ + mutationFn: async (data) => { const petId = unref(refPetId) const params = unref(refParams) - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useAddPet.ts b/examples/vue-query/src/gen/hooks/useAddPet.ts index 3721f79c1..94c9cf3ce 100644 --- a/examples/vue-query/src/gen/hooks/useAddPet.ts +++ b/examples/vue-query/src/gen/hooks/useAddPet.ts @@ -13,7 +13,6 @@ type AddPet = { queryParams: never headerParams: never response: AddPetMutationResponse - unionResponse: Awaited> | AddPetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -23,21 +22,22 @@ type AddPet = { * @description Add a new pet to the store * @summary Add a new pet to the store * @link /pet */ -export function useAddPet( +export function useAddPet( options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: AddPet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useCreateUser.ts b/examples/vue-query/src/gen/hooks/useCreateUser.ts index e11f74910..775daa909 100644 --- a/examples/vue-query/src/gen/hooks/useCreateUser.ts +++ b/examples/vue-query/src/gen/hooks/useCreateUser.ts @@ -13,7 +13,6 @@ type CreateUser = { queryParams: never headerParams: never response: CreateUserMutationResponse - unionResponse: Awaited> | CreateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -23,21 +22,22 @@ type CreateUser = { * @description This can only be done by the logged in user. * @summary Create user * @link /user */ -export function useCreateUser( +export function useCreateUser( options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: CreateUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useCreateUsersWithListInput.ts b/examples/vue-query/src/gen/hooks/useCreateUsersWithListInput.ts index 55ed5e496..8a4ddcbf0 100644 --- a/examples/vue-query/src/gen/hooks/useCreateUsersWithListInput.ts +++ b/examples/vue-query/src/gen/hooks/useCreateUsersWithListInput.ts @@ -21,7 +21,6 @@ type CreateUsersWithListInput = { queryParams: never headerParams: never response: CreateUsersWithListInputMutationResponse - unionResponse: Awaited> | CreateUsersWithListInputMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,21 +30,22 @@ type CreateUsersWithListInput = { * @description Creates list of users with given input array * @summary Creates list of users with given input array * @link /user/createWithList */ -export function useCreateUsersWithListInput( +export function useCreateUsersWithListInput( options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: CreateUsersWithListInput['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/user/createWithList`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useDeleteOrder.ts b/examples/vue-query/src/gen/hooks/useDeleteOrder.ts index bef6a1f34..83fdc193d 100644 --- a/examples/vue-query/src/gen/hooks/useDeleteOrder.ts +++ b/examples/vue-query/src/gen/hooks/useDeleteOrder.ts @@ -15,7 +15,6 @@ type DeleteOrder = { queryParams: never headerParams: never response: DeleteOrderMutationResponse - unionResponse: Awaited> | DeleteOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,22 +24,23 @@ type DeleteOrder = { * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @summary Delete purchase order by ID * @link /store/order/:orderId */ -export function useDeleteOrder( +export function useDeleteOrder( refOrderId: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: DeleteOrder['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const orderId = unref(refOrderId) - return client({ + const res = await client({ method: 'delete', url: `/store/order/${orderId}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useDeletePet.ts b/examples/vue-query/src/gen/hooks/useDeletePet.ts index 15c06458c..92f670a9f 100644 --- a/examples/vue-query/src/gen/hooks/useDeletePet.ts +++ b/examples/vue-query/src/gen/hooks/useDeletePet.ts @@ -15,7 +15,6 @@ type DeletePet = { queryParams: never headerParams: DeletePetHeaderParams response: DeletePetMutationResponse - unionResponse: Awaited> | DeletePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,25 +24,26 @@ type DeletePet = { * @description delete a pet * @summary Deletes a pet * @link /pet/:petId */ -export function useDeletePet( +export function useDeletePet( refPetId: MaybeRef, refHeaders?: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: DeletePet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const petId = unref(refPetId) const headers = unref(refHeaders) - return client({ + const res = await client({ method: 'delete', url: `/pet/${petId}`, headers: { ...headers, ...clientOptions.headers }, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useDeleteUser.ts b/examples/vue-query/src/gen/hooks/useDeleteUser.ts index fff11f521..8f5dc99b6 100644 --- a/examples/vue-query/src/gen/hooks/useDeleteUser.ts +++ b/examples/vue-query/src/gen/hooks/useDeleteUser.ts @@ -15,7 +15,6 @@ type DeleteUser = { queryParams: never headerParams: never response: DeleteUserMutationResponse - unionResponse: Awaited> | DeleteUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,22 +24,23 @@ type DeleteUser = { * @description This can only be done by the logged in user. * @summary Delete user * @link /user/:username */ -export function useDeleteUser( +export function useDeleteUser( refUsername: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: DeleteUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'delete', url: `/user/${username}`, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useFindPetsByStatus.ts b/examples/vue-query/src/gen/hooks/useFindPetsByStatus.ts index 3b8327855..1cfeea808 100644 --- a/examples/vue-query/src/gen/hooks/useFindPetsByStatus.ts +++ b/examples/vue-query/src/gen/hooks/useFindPetsByStatus.ts @@ -15,7 +15,6 @@ type FindPetsByStatus = { queryParams: FindPetsByStatusQueryParams headerParams: never response: FindPetsByStatusQueryResponse - unionResponse: Awaited> | FindPetsByStatusQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -32,18 +31,19 @@ export function findPetsByStatusQueryOptions< >( refParams?: MaybeRef, options: FindPetsByStatus['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByStatusQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/pet/findByStatus`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useFindPetsByTags.ts b/examples/vue-query/src/gen/hooks/useFindPetsByTags.ts index 920cd0277..2bb94cc3e 100644 --- a/examples/vue-query/src/gen/hooks/useFindPetsByTags.ts +++ b/examples/vue-query/src/gen/hooks/useFindPetsByTags.ts @@ -15,7 +15,6 @@ type FindPetsByTags = { queryParams: FindPetsByTagsQueryParams headerParams: never response: FindPetsByTagsQueryResponse - unionResponse: Awaited> | FindPetsByTagsQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,18 +30,19 @@ export function findPetsByTagsQueryOptions< >( refParams?: MaybeRef, options: FindPetsByTags['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = findPetsByTagsQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/pet/findByTags`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useGetInventory.ts b/examples/vue-query/src/gen/hooks/useGetInventory.ts index dfae6f52a..bd9d663f9 100644 --- a/examples/vue-query/src/gen/hooks/useGetInventory.ts +++ b/examples/vue-query/src/gen/hooks/useGetInventory.ts @@ -13,7 +13,6 @@ type GetInventory = { queryParams: never headerParams: never response: GetInventoryQueryResponse - unionResponse: Awaited> | GetInventoryQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,18 +25,17 @@ export function getInventoryQueryOptions< TError = GetInventory['error'], TData = GetInventory['response'], TQueryData = GetInventory['response'], ->( - options: GetInventory['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +>(options: GetInventory['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = getInventoryQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/store/inventory`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useGetOrderById.ts b/examples/vue-query/src/gen/hooks/useGetOrderById.ts index ee4894287..2c7341683 100644 --- a/examples/vue-query/src/gen/hooks/useGetOrderById.ts +++ b/examples/vue-query/src/gen/hooks/useGetOrderById.ts @@ -15,7 +15,6 @@ type GetOrderById = { queryParams: never headerParams: never response: GetOrderByIdQueryResponse - unionResponse: Awaited> | GetOrderByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -32,17 +31,18 @@ export function getOrderByIdQueryOptions< >( refOrderId: MaybeRef, options: GetOrderById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getOrderByIdQueryKey(refOrderId) return { queryKey, - queryFn: () => { + queryFn: async () => { const orderId = unref(refOrderId) - return client({ + const res = await client({ method: 'get', url: `/store/order/${orderId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useGetPetById.ts b/examples/vue-query/src/gen/hooks/useGetPetById.ts index 0fbf5f2d0..be5ce2b7a 100644 --- a/examples/vue-query/src/gen/hooks/useGetPetById.ts +++ b/examples/vue-query/src/gen/hooks/useGetPetById.ts @@ -15,7 +15,6 @@ type GetPetById = { queryParams: never headerParams: never response: GetPetByIdQueryResponse - unionResponse: Awaited> | GetPetByIdQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,17 +30,18 @@ export function getPetByIdQueryOptions< >( refPetId: MaybeRef, options: GetPetById['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getPetByIdQueryKey(refPetId) return { queryKey, - queryFn: () => { + queryFn: async () => { const petId = unref(refPetId) - return client({ + const res = await client({ method: 'get', url: `/pet/${petId}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useGetUserByName.ts b/examples/vue-query/src/gen/hooks/useGetUserByName.ts index 501f8cd4a..e96f2f2a2 100644 --- a/examples/vue-query/src/gen/hooks/useGetUserByName.ts +++ b/examples/vue-query/src/gen/hooks/useGetUserByName.ts @@ -15,7 +15,6 @@ type GetUserByName = { queryParams: never headerParams: never response: GetUserByNameQueryResponse - unionResponse: Awaited> | GetUserByNameQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -32,17 +31,18 @@ export function getUserByNameQueryOptions< >( refUsername: MaybeRef, options: GetUserByName['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = getUserByNameQueryKey(refUsername) return { queryKey, - queryFn: () => { + queryFn: async () => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'get', url: `/user/${username}`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useLoginUser.ts b/examples/vue-query/src/gen/hooks/useLoginUser.ts index ba2e50406..e6da7ef43 100644 --- a/examples/vue-query/src/gen/hooks/useLoginUser.ts +++ b/examples/vue-query/src/gen/hooks/useLoginUser.ts @@ -15,7 +15,6 @@ type LoginUser = { queryParams: LoginUserQueryParams headerParams: never response: LoginUserQueryResponse - unionResponse: Awaited> | LoginUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -31,18 +30,19 @@ export function loginUserQueryOptions< >( refParams?: MaybeRef, options: LoginUser['client']['paramaters'] = {}, -): WithRequired, 'queryKey'> { +): WithRequired, 'queryKey'> { const queryKey = loginUserQueryKey(refParams) return { queryKey, - queryFn: () => { + queryFn: async () => { const params = unref(refParams) - return client({ + const res = await client({ method: 'get', url: `/user/login`, params, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/useLogoutUser.ts b/examples/vue-query/src/gen/hooks/useLogoutUser.ts index ec7634b29..c5af20f36 100644 --- a/examples/vue-query/src/gen/hooks/useLogoutUser.ts +++ b/examples/vue-query/src/gen/hooks/useLogoutUser.ts @@ -13,7 +13,6 @@ type LogoutUser = { queryParams: never headerParams: never response: LogoutUserQueryResponse - unionResponse: Awaited> | LogoutUserQueryResponse client: { paramaters: Partial[0]> return: Awaited> @@ -26,16 +25,17 @@ export function logoutUserQueryOptions< TError = LogoutUser['error'], TData = LogoutUser['response'], TQueryData = LogoutUser['response'], ->(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { +>(options: LogoutUser['client']['paramaters'] = {}): WithRequired, 'queryKey'> { const queryKey = logoutUserQueryKey() return { queryKey, - queryFn: () => { - return client({ + queryFn: async () => { + const res = await client({ method: 'get', url: `/user/logout`, ...options, - }).then((res) => res?.data || res) + }) + return res.data }, } } diff --git a/examples/vue-query/src/gen/hooks/usePlaceOrder.ts b/examples/vue-query/src/gen/hooks/usePlaceOrder.ts index 0079a52d7..d9f50d3f4 100644 --- a/examples/vue-query/src/gen/hooks/usePlaceOrder.ts +++ b/examples/vue-query/src/gen/hooks/usePlaceOrder.ts @@ -13,7 +13,6 @@ type PlaceOrder = { queryParams: never headerParams: never response: PlaceOrderMutationResponse - unionResponse: Awaited> | PlaceOrderMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -23,21 +22,22 @@ type PlaceOrder = { * @description Place a new order in the store * @summary Place an order for a pet * @link /store/order */ -export function usePlaceOrder( +export function usePlaceOrder( options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: PlaceOrder['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'post', url: `/store/order`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useUpdatePet.ts b/examples/vue-query/src/gen/hooks/useUpdatePet.ts index d2264bd4f..767f04996 100644 --- a/examples/vue-query/src/gen/hooks/useUpdatePet.ts +++ b/examples/vue-query/src/gen/hooks/useUpdatePet.ts @@ -13,7 +13,6 @@ type UpdatePet = { queryParams: never headerParams: never response: UpdatePetMutationResponse - unionResponse: Awaited> | UpdatePetMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -23,21 +22,22 @@ type UpdatePet = { * @description Update an existing pet by Id * @summary Update an existing pet * @link /pet */ -export function useUpdatePet( +export function useUpdatePet( options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: UpdatePet['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { - return client({ + return useMutation({ + mutationFn: async (data) => { + const res = await client({ method: 'put', url: `/pet`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useUpdatePetWithForm.ts b/examples/vue-query/src/gen/hooks/useUpdatePetWithForm.ts index 07ae818ce..a6e2cfef3 100644 --- a/examples/vue-query/src/gen/hooks/useUpdatePetWithForm.ts +++ b/examples/vue-query/src/gen/hooks/useUpdatePetWithForm.ts @@ -20,7 +20,6 @@ type UpdatePetWithForm = { queryParams: UpdatePetWithFormQueryParams headerParams: never response: UpdatePetWithFormMutationResponse - unionResponse: Awaited> | UpdatePetWithFormMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -29,25 +28,26 @@ type UpdatePetWithForm = { /** * @summary Updates a pet in the store with form data * @link /pet/:petId */ -export function useUpdatePetWithForm( +export function useUpdatePetWithForm( refPetId: MaybeRef, refParams?: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: UpdatePetWithForm['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: () => { + return useMutation({ + mutationFn: async () => { const petId = unref(refPetId) const params = unref(refParams) - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}`, params, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useUpdateUser.ts b/examples/vue-query/src/gen/hooks/useUpdateUser.ts index 273683ed4..14845db75 100644 --- a/examples/vue-query/src/gen/hooks/useUpdateUser.ts +++ b/examples/vue-query/src/gen/hooks/useUpdateUser.ts @@ -15,7 +15,6 @@ type UpdateUser = { queryParams: never headerParams: never response: UpdateUserMutationResponse - unionResponse: Awaited> | UpdateUserMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -25,23 +24,24 @@ type UpdateUser = { * @description This can only be done by the logged in user. * @summary Update user * @link /user/:username */ -export function useUpdateUser( +export function useUpdateUser( refUsername: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: UpdateUser['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { + return useMutation({ + mutationFn: async (data) => { const username = unref(refUsername) - return client({ + const res = await client({ method: 'put', url: `/user/${username}`, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/examples/vue-query/src/gen/hooks/useUploadFile.ts b/examples/vue-query/src/gen/hooks/useUploadFile.ts index e641f9702..51e61688e 100644 --- a/examples/vue-query/src/gen/hooks/useUploadFile.ts +++ b/examples/vue-query/src/gen/hooks/useUploadFile.ts @@ -15,7 +15,6 @@ type UploadFile = { queryParams: UploadFileQueryParams headerParams: never response: UploadFileMutationResponse - unionResponse: Awaited> | UploadFileMutationResponse client: { paramaters: Partial[0]> return: Awaited> @@ -24,26 +23,27 @@ type UploadFile = { /** * @summary uploads an image * @link /pet/:petId/uploadImage */ -export function useUploadFile( +export function useUploadFile( refPetId: MaybeRef, refParams?: MaybeRef, options: { - mutation?: VueMutationObserverOptions + mutation?: VueMutationObserverOptions client?: UploadFile['client']['paramaters'] } = {}, -): UseMutationReturnType { +): UseMutationReturnType { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: (data) => { + return useMutation({ + mutationFn: async (data) => { const petId = unref(refPetId) const params = unref(refParams) - return client({ + const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, params, data, ...clientOptions, - }).then((res) => res as TData) + }) + return res.data }, ...mutationOptions, }) diff --git a/packages/swagger-client/src/__snapshots__/OperationGenerator.test.tsx.snap b/packages/swagger-client/src/__snapshots__/OperationGenerator.test.tsx.snap index d97b1e6f3..266940b9f 100644 --- a/packages/swagger-client/src/__snapshots__/OperationGenerator.test.tsx.snap +++ b/packages/swagger-client/src/__snapshots__/OperationGenerator.test.tsx.snap @@ -43,12 +43,12 @@ exports[`OperationGenerator > [GET] should generate with pathParamsType \`inline * @summary Info for a specific pet * @link /pets/:pet_id */ export async function showPetById(petId: ShowPetByIdPathParams["pet_id"], testId: ShowPetByIdPathParams["testId"], options: Partial[0]> = {}): Promise["data"]> { - const { data: resData } = await client({ + const res = await client({ method: "get", url: \`/pets/\${petId}\`, ...options }); - return resData; + return res.data; } ", }, @@ -98,12 +98,12 @@ exports[`OperationGenerator > [GET] should generate with pathParamsType \`object * @summary Info for a specific pet * @link /pets/:pet_id */ export async function showPetById({ petId, testId }: ShowPetByIdPathParams, options: Partial[0]> = {}): Promise["data"]> { - const { data: resData } = await client({ + const res = await client({ method: "get", url: \`/pets/\${petId}\`, ...options }); - return resData; + return res.data; } ", }, diff --git a/packages/swagger-client/src/components/Client.tsx b/packages/swagger-client/src/components/Client.tsx index 848a3fc75..46f1cdc77 100644 --- a/packages/swagger-client/src/components/Client.tsx +++ b/packages/swagger-client/src/components/Client.tsx @@ -64,25 +64,14 @@ function Template({ const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\n${transformers.createIndent(4)}`)}` - if (client.dataReturnType === 'full') { - return ( - - {` - return client<${client.generics}>({ -${resolvedClientOptions} - })`} - - ) - } - return ( {` -const { data: resData } = await client<${client.generics}>({ +const res = await client<${client.generics}>({ ${resolvedClientOptions} }) - -return resData`} +return ${client.dataReturnType === 'data' ? 'res.data' : 'res'} +`} ) } diff --git a/packages/swagger-swr/src/components/Mutation.tsx b/packages/swagger-swr/src/components/Mutation.tsx index 308331b42..d162f2497 100644 --- a/packages/swagger-swr/src/components/Mutation.tsx +++ b/packages/swagger-swr/src/components/Mutation.tsx @@ -5,6 +5,8 @@ import { useOperation, useOperationFile, useOperationName, useSchemas } from '@k import { getASTParams, getComments } from '@kubb/swagger/utils' import { pluginKey as swaggerTsPluginKey } from '@kubb/swagger-ts' +import { SchemaType } from './SchemaType.tsx' + import type { HttpMethod } from '@kubb/swagger/oas' import type { ReactNode } from 'react' import type { FileMeta, PluginOptions } from '../types.ts' @@ -45,6 +47,7 @@ type TemplateProps = { withHeaders: boolean path: URLPath } + dataReturnType: NonNullable } function Template({ @@ -55,6 +58,7 @@ function Template({ JSDoc, client, hook, + dataReturnType, }: TemplateProps): ReactNode { const clientOptions = [ `method: "${client.method}"`, @@ -75,10 +79,12 @@ function Template({ const url = ${client.path.template} as const return ${hook.name}<${hook.generics}>( shouldFetch ? [url, params]: null, - (_url${client.withData ? ', { arg: data }' : ''}) => { - return client<${client.generics}>({ + async (_url${client.withData ? ', { arg: data }' : ''}) => { + const res = await client<${client.generics}>({ ${resolvedClientOptions} }) + + return ${dataReturnType === 'data' ? 'res.data' : 'res'} }, mutationOptions ) @@ -94,10 +100,12 @@ function Template({ const url = ${client.path.template} as const return ${hook.name}<${hook.generics}>( shouldFetch ? url : null, - (_url${client.withData ? ', { arg: data }' : ''}) => { - return client<${client.generics}>({ + async (_url${client.withData ? ', { arg: data }' : ''}) => { + const res = await client<${client.generics}>({ ${resolvedClientOptions} }) + + return ${dataReturnType === 'data' ? 'res.data' : 'res'} }, mutationOptions ) @@ -111,6 +119,9 @@ const defaultTemplates = { } as const type Props = { + factory: { + name: string + } /** * This will make it possible to override the default behaviour. */ @@ -118,18 +129,19 @@ type Props = { } export function Mutation({ + factory, Template = defaultTemplates.default, }: Props): ReactNode { + const { options: { dataReturnType } } = usePlugin() const operation = useOperation() const name = useOperationName({ type: 'function' }) const schemas = useSchemas() - const generics = new FunctionParams() const params = new FunctionParams() const client = { method: operation.method, path: new URLPath(operation.path), - generics: ['TData', 'TError', schemas.request?.name ? `TVariables` : undefined].filter(Boolean).join(', '), + generics: [`${factory.name}["data"]`, `${factory.name}["error"]`, schemas.request?.name ? `${factory.name}["request"]` : ''].filter(Boolean).join(', '), withQueryParams: !!schemas.queryParams?.name, withData: !!schemas.request?.name, withPathParams: !!schemas.pathParams?.name, @@ -137,27 +149,21 @@ export function Mutation({ } const resultGenerics = [ - 'ResponseConfig', - 'TError', + `${factory.name}["response"]`, + `${factory.name}["error"]`, ] - generics.add([ - { type: 'TData', default: schemas.response.name }, - { type: 'TError', default: schemas.errors?.map((error) => error.name).join(' | ') || 'unknown' }, - { type: 'TVariables', default: schemas.request?.name, enabled: !!schemas.request?.name }, - ]) - params.add([ ...getASTParams(schemas.pathParams, { typed: true }), { name: 'params', - type: schemas.queryParams?.name, + type: `${factory.name}['queryParams']`, enabled: client.withQueryParams, required: false, }, { name: 'headers', - type: schemas.headerParams?.name, + type: `${factory.name}['headerParams']`, enabled: client.withHeaders, required: false, }, @@ -166,7 +172,7 @@ export function Mutation({ required: false, type: `{ mutation?: SWRMutationConfiguration<${resultGenerics.join(', ')}>, - client?: Partial>[0]>, + client?: ${factory.name}['client']['paramaters'], shouldFetch?: boolean, }`, default: '{}', @@ -181,12 +187,12 @@ export function Mutation({ return (