diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index a4f436e78..55306c172 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -167,7 +167,7 @@ export default defineConfig({
},
{
text: '@kubb/react-templates under construction',
- link: '/plugins/react-templates',
+ link: '/plugins/react-template',
},
{
text: 'Swagger plugins',
diff --git a/docs/plugins/react-template.md b/docs/plugins/react-template.md
index aecebdaa7..304a1671b 100644
--- a/docs/plugins/react-template.md
+++ b/docs/plugins/react-template.md
@@ -6,8 +6,11 @@ outline: deep
---
# @kubb/react-template
+Use React to create templates/variants for any plugin.
+
+
## Installation
::: code-group
diff --git a/docs/plugins/swagger-client/index.md b/docs/plugins/swagger-client/index.md
index b5b80e412..0b5710188 100644
--- a/docs/plugins/swagger-client/index.md
+++ b/docs/plugins/swagger-client/index.md
@@ -70,6 +70,15 @@ Relative to the root
Type: `string`
Default: `"@kubb/swagger-client/ts-client"`
+### dataReturnType
+ReturnType that needs to be used when calling client().
+
+`Data` will return ResponseConfig[data].
+`Full` will return ResponseConfig.
+
+Type: `string`
+Default: `"data"`
+
### skipBy
Array containing skipBy paramaters to exclude/skip tags/operations/methods/paths.
@@ -86,6 +95,7 @@ Override the name of the client that is getting generated, this will also overri
Type: `(name: string) => string`
+
## Depended
- [`@kubb/swagger`](/plugins/swagger)
diff --git a/docs/plugins/swagger-swr.md b/docs/plugins/swagger-swr.md
index d8397e213..65b150233 100644
--- a/docs/plugins/swagger-swr.md
+++ b/docs/plugins/swagger-swr.md
@@ -30,7 +30,6 @@ yarn add @kubb/swagger-swr
:::
-
## Options
@@ -70,6 +69,15 @@ Relative to the root
Type: `string`
Default: `"@kubb/swagger-client/ts-client"`
+### dataReturnType
+ReturnType that needs to be used when calling client().
+
+`Data` will return ResponseConfig[data].
+`Full` will return ResponseConfig.
+
+Type: `string`
+Default: `"data"`
+
### skipBy
Array containing skipBy paramaters to exclude/skip tags/operations/methods/paths.
diff --git a/docs/plugins/swagger-tanstack-query.md b/docs/plugins/swagger-tanstack-query.md
index 5ae09a3bc..97691ee53 100644
--- a/docs/plugins/swagger-tanstack-query.md
+++ b/docs/plugins/swagger-tanstack-query.md
@@ -75,6 +75,15 @@ Relative to the root
Type: `string`
Default: `"@kubb/swagger-client/ts-client"`
+### dataReturnType
+ReturnType that needs to be used when calling client().
+
+`Data` will return ResponseConfig[data].
+`Full` will return ResponseConfig.
+
+Type: `string`
+Default: `"data"`
+
### framework
Framework to be generated for.
diff --git a/docs/plugins/swagger-ts.md b/docs/plugins/swagger-ts.md
index 21b58e401..1bf0a7f41 100644
--- a/docs/plugins/swagger-ts.md
+++ b/docs/plugins/swagger-ts.md
@@ -81,7 +81,6 @@ date: Date
Type: `'string' | 'date'`
Default: `'string'`
-
### optionalType
Choose what to use as mode for an optional value.
diff --git a/examples/advanced/kubb.config.ts b/examples/advanced/kubb.config.ts
index 1b4a4998a..438aaa7ad 100644
--- a/examples/advanced/kubb.config.ts
+++ b/examples/advanced/kubb.config.ts
@@ -46,6 +46,7 @@ export default defineConfig(async () => {
groupBy: { type: 'tag' },
client: './src/client.ts',
infinite: {},
+ dataReturnType: 'full',
},
],
[
@@ -60,6 +61,7 @@ export default defineConfig(async () => {
],
groupBy: { type: 'tag' },
client: './src/client.ts',
+ dataReturnType: 'full',
},
],
[
@@ -74,6 +76,7 @@ export default defineConfig(async () => {
],
groupBy: { type: 'tag', output: './clients/axios/{{tag}}Service' },
client: './src/client.ts',
+ dataReturnType: 'full',
},
],
[
diff --git a/examples/advanced/src/gen/clients/axios/petService/addPet.ts b/examples/advanced/src/gen/clients/axios/petService/addPet.ts
index 0281cc40a..59bd56483 100644
--- a/examples/advanced/src/gen/clients/axios/petService/addPet.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/addPet.ts
@@ -10,13 +10,11 @@ import type { AddPetMutationRequest, AddPetMutationResponse } from '../../../mod
export async function addPet(
data: TVariables,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/pet`,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/deletePet.ts b/examples/advanced/src/gen/clients/axios/petService/deletePet.ts
index 78773ad4c..203de3fd0 100644
--- a/examples/advanced/src/gen/clients/axios/petService/deletePet.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/deletePet.ts
@@ -11,13 +11,11 @@ export async function deletePet(
petId: DeletePetPathParams['petId'],
headers?: DeletePetHeaderParams,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'delete',
url: `/pet/${petId}`,
headers: { ...headers, ...options.headers },
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts b/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts
index 26831e0a8..583153934 100644
--- a/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/findPetsByStatus.ts
@@ -10,13 +10,11 @@ import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams } from
export async function findPetsByStatus(
params?: FindPetsByStatusQueryParams,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'get',
url: `/pet/findByStatus`,
params,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts b/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts
index 5acc83b54..0e7210703 100644
--- a/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/findPetsByTags.ts
@@ -11,14 +11,12 @@ export async function findPetsByTags(
headers: FindPetsByTagsHeaderParams,
params?: FindPetsByTagsQueryParams,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'get',
url: `/pet/findByTags`,
params,
headers: { ...headers, ...options.headers },
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/getPetById.ts b/examples/advanced/src/gen/clients/axios/petService/getPetById.ts
index c15ef61da..86c11721f 100644
--- a/examples/advanced/src/gen/clients/axios/petService/getPetById.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/getPetById.ts
@@ -10,12 +10,10 @@ import type { GetPetByIdQueryResponse, GetPetByIdPathParams } from '../../../mod
export async function getPetById(
petId: GetPetByIdPathParams['petId'],
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'get',
url: `/pet/${petId}`,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/updatePet.ts b/examples/advanced/src/gen/clients/axios/petService/updatePet.ts
index bddaf9b77..3e8e972b4 100644
--- a/examples/advanced/src/gen/clients/axios/petService/updatePet.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/updatePet.ts
@@ -10,13 +10,11 @@ import type { UpdatePetMutationRequest, UpdatePetMutationResponse } from '../../
export async function updatePet(
data: TVariables,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'put',
url: `/pet`,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts b/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts
index 082c4d70c..9aef29da9 100644
--- a/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/updatePetWithForm.ts
@@ -14,13 +14,11 @@ export async function updatePetWithForm[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/pet/${petId}`,
params,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts b/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts
index f13b380d5..334b0f69e 100644
--- a/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts
+++ b/examples/advanced/src/gen/clients/axios/petService/uploadFile.ts
@@ -16,14 +16,12 @@ export async function uploadFile[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/pet/${petId}/uploadImage`,
params,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/petsService/createPets.ts b/examples/advanced/src/gen/clients/axios/petsService/createPets.ts
index ce210e5c8..b21bc8e25 100644
--- a/examples/advanced/src/gen/clients/axios/petsService/createPets.ts
+++ b/examples/advanced/src/gen/clients/axios/petsService/createPets.ts
@@ -18,8 +18,8 @@ export async function createPets[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/pets/${uuid}`,
params,
@@ -27,6 +27,4 @@ export async function createPets(
data?: TVariables,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/user`,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts b/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts
index cf69a376d..e452c36f8 100644
--- a/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/createUsersWithListInput.ts
@@ -13,13 +13,11 @@ import type {
export async function createUsersWithListInput(
data?: TVariables,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'post',
url: `/user/createWithList`,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts b/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts
index 1fd85b5f7..287503988 100644
--- a/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/deleteUser.ts
@@ -10,12 +10,10 @@ import type { DeleteUserMutationResponse, DeleteUserPathParams } from '../../../
export async function deleteUser(
username: DeleteUserPathParams['username'],
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'delete',
url: `/user/${username}`,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts b/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts
index 70791c301..2b1046cf5 100644
--- a/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/getUserByName.ts
@@ -9,12 +9,10 @@ import type { GetUserByNameQueryResponse, GetUserByNamePathParams } from '../../
export async function getUserByName(
username: GetUserByNamePathParams['username'],
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'get',
url: `/user/${username}`,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/loginUser.ts b/examples/advanced/src/gen/clients/axios/userService/loginUser.ts
index c67386564..0e62a0556 100644
--- a/examples/advanced/src/gen/clients/axios/userService/loginUser.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/loginUser.ts
@@ -9,13 +9,11 @@ import type { LoginUserQueryResponse, LoginUserQueryParams } from '../../../mode
export async function loginUser(
params?: LoginUserQueryParams,
options: Partial[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'get',
url: `/user/login`,
params,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts b/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts
index e5dc557bf..2eb677777 100644
--- a/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/logoutUser.ts
@@ -6,12 +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['data']> {
- const { data: resData } = await client({
+export async function logoutUser(options: Partial[0]> = {}): Promise> {
+ return client({
method: 'get',
url: `/user/logout`,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/axios/userService/updateUser.ts b/examples/advanced/src/gen/clients/axios/userService/updateUser.ts
index a41f5f31b..de85310a1 100644
--- a/examples/advanced/src/gen/clients/axios/userService/updateUser.ts
+++ b/examples/advanced/src/gen/clients/axios/userService/updateUser.ts
@@ -11,13 +11,11 @@ export async function updateUser[0]> = {},
-): Promise['data']> {
- const { data: resData } = await client({
+): Promise> {
+ return client({
method: 'put',
url: `/user/${username}`,
data,
...options,
})
-
- return resData
}
diff --git a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts
index 684ac3d82..63ecaa100 100644
--- a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts
+++ b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByStatus.ts
@@ -1,6 +1,7 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../../../models/ts/petController/FindPetsByStatus'
export const findPetsByStatusQueryKey = (params?: FindPetsByStatusQueryParams) => [`/pet/findByStatus`, ...(params ? [params] : [])] as const
@@ -8,7 +9,7 @@ export const findPetsByStatusQueryKey = (params?: FindPetsByStatusQueryParams) =
export function findPetsByStatusQueryOptions(
params?: FindPetsByStatusQueryParams,
options: Partial[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions, TError> {
const queryKey = findPetsByStatusQueryKey(params)
return {
@@ -20,7 +21,7 @@ export function findPetsByStatusQueryOptions res.data)
+ }).then((res) => res)
},
}
}
@@ -34,17 +35,17 @@ export function findPetsByStatusQueryOptions(
params?: FindPetsByStatusQueryParams,
options: {
- query?: UseQueryOptions
+ query?: UseQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseQueryResult & { queryKey: QueryKey } {
+): UseQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? findPetsByStatusQueryKey(params)
- const query = useQuery({
+ const query = useQuery, TError>({
...findPetsByStatusQueryOptions(params, clientOptions),
...queryOptions,
- }) as UseQueryResult & { queryKey: QueryKey }
+ }) as UseQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
@@ -54,7 +55,7 @@ export function useFindPetsByStatus(
params?: FindPetsByStatusQueryParams,
options: Partial[0]> = {},
-): UseInfiniteQueryOptions {
+): UseInfiniteQueryOptions, TError> {
const queryKey = findPetsByStatusQueryKey(params)
return {
@@ -70,7 +71,7 @@ export function findPetsByStatusQueryOptionsInfinite res.data)
+ }).then((res) => res)
},
}
}
@@ -84,17 +85,17 @@ export function findPetsByStatusQueryOptionsInfinite(
params?: FindPetsByStatusQueryParams,
options: {
- query?: UseInfiniteQueryOptions
+ query?: UseInfiniteQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseInfiniteQueryResult & { queryKey: QueryKey } {
+): UseInfiniteQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? findPetsByStatusQueryKey(params)
- const query = useInfiniteQuery({
+ const query = useInfiniteQuery, TError>({
...findPetsByStatusQueryOptionsInfinite(params, clientOptions),
...queryOptions,
- }) as UseInfiniteQueryResult & { queryKey: QueryKey }
+ }) as UseInfiniteQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
diff --git a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts
index f8b112daa..ff2d156d8 100644
--- a/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts
+++ b/examples/advanced/src/gen/clients/hooks/petController/useFindPetsByTags.ts
@@ -1,6 +1,7 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type {
FindPetsByTagsQueryResponse,
FindPetsByTagsQueryParams,
@@ -14,7 +15,7 @@ export function findPetsByTagsQueryOptions[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions, TError> {
const queryKey = findPetsByTagsQueryKey(params)
return {
@@ -26,7 +27,7 @@ export function findPetsByTagsQueryOptions res.data)
+ }).then((res) => res)
},
}
}
@@ -41,17 +42,17 @@ export function useFindPetsByTags
+ query?: UseQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseQueryResult & { queryKey: QueryKey } {
+): UseQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
- const query = useQuery({
+ const query = useQuery, TError>({
...findPetsByTagsQueryOptions(headers, params, clientOptions),
...queryOptions,
- }) as UseQueryResult & { queryKey: QueryKey }
+ }) as UseQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
@@ -62,7 +63,7 @@ export function findPetsByTagsQueryOptionsInfinite[0]> = {},
-): UseInfiniteQueryOptions {
+): UseInfiniteQueryOptions, TError> {
const queryKey = findPetsByTagsQueryKey(params)
return {
@@ -78,7 +79,7 @@ export function findPetsByTagsQueryOptionsInfinite res.data)
+ }).then((res) => res)
},
}
}
@@ -93,17 +94,17 @@ export function useFindPetsByTagsInfinite
+ query?: UseInfiniteQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseInfiniteQueryResult & { queryKey: QueryKey } {
+): UseInfiniteQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
- const query = useInfiniteQuery({
+ const query = useInfiniteQuery, TError>({
...findPetsByTagsQueryOptionsInfinite(headers, params, clientOptions),
...queryOptions,
- }) as UseInfiniteQueryResult & { queryKey: QueryKey }
+ }) as UseInfiniteQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
diff --git a/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts b/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts
index b7cc61cc3..52b467f77 100644
--- a/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts
+++ b/examples/advanced/src/gen/clients/hooks/petController/useGetPetById.ts
@@ -1,6 +1,7 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../../../models/ts/petController/GetPetById'
export const getPetByIdQueryKey = (petId: GetPetByIdPathParams['petId']) => [`/pet/${petId}`] as const
@@ -8,7 +9,7 @@ export const getPetByIdQueryKey = (petId: GetPetByIdPathParams['petId']) => [`/p
export function getPetByIdQueryOptions(
petId: GetPetByIdPathParams['petId'],
options: Partial[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions, TError> {
const queryKey = getPetByIdQueryKey(petId)
return {
@@ -19,7 +20,7 @@ export function getPetByIdQueryOptions res.data)
+ }).then((res) => res)
},
}
}
@@ -33,17 +34,17 @@ export function getPetByIdQueryOptions(
petId: GetPetByIdPathParams['petId'],
options: {
- query?: UseQueryOptions
+ query?: UseQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseQueryResult & { queryKey: QueryKey } {
+): UseQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey(petId)
- const query = useQuery({
+ const query = useQuery, TError>({
...getPetByIdQueryOptions(petId, clientOptions),
...queryOptions,
- }) as UseQueryResult & { queryKey: QueryKey }
+ }) as UseQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
@@ -53,7 +54,7 @@ export function useGetPetById(
petId: GetPetByIdPathParams['petId'],
options: Partial[0]> = {},
-): UseInfiniteQueryOptions {
+): UseInfiniteQueryOptions, TError> {
const queryKey = getPetByIdQueryKey(petId)
return {
@@ -64,7 +65,7 @@ export function getPetByIdQueryOptionsInfinite res.data)
+ }).then((res) => res)
},
}
}
@@ -78,17 +79,17 @@ export function getPetByIdQueryOptionsInfinite(
petId: GetPetByIdPathParams['petId'],
options: {
- query?: UseInfiniteQueryOptions
+ query?: UseInfiniteQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseInfiniteQueryResult & { queryKey: QueryKey } {
+): UseInfiniteQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey(petId)
- const query = useInfiniteQuery({
+ const query = useInfiniteQuery, TError>({
...getPetByIdQueryOptionsInfinite(petId, clientOptions),
...queryOptions,
- }) as UseInfiniteQueryResult & { queryKey: QueryKey }
+ }) as UseInfiniteQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
diff --git a/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts b/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts
index ac31e6057..1bf1b63c4 100644
--- a/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts
+++ b/examples/advanced/src/gen/clients/hooks/userController/useGetUserByName.ts
@@ -1,6 +1,7 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../../../models/ts/userController/GetUserByName'
export const getUserByNameQueryKey = (username: GetUserByNamePathParams['username']) => [`/user/${username}`] as const
@@ -8,7 +9,7 @@ export const getUserByNameQueryKey = (username: GetUserByNamePathParams['usernam
export function getUserByNameQueryOptions(
username: GetUserByNamePathParams['username'],
options: Partial[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions, TError> {
const queryKey = getUserByNameQueryKey(username)
return {
@@ -19,7 +20,7 @@ export function getUserByNameQueryOptions res.data)
+ }).then((res) => res)
},
}
}
@@ -32,17 +33,17 @@ export function getUserByNameQueryOptions(
username: GetUserByNamePathParams['username'],
options: {
- query?: UseQueryOptions
+ query?: UseQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseQueryResult & { queryKey: QueryKey } {
+): UseQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? getUserByNameQueryKey(username)
- const query = useQuery({
+ const query = useQuery, TError>({
...getUserByNameQueryOptions(username, clientOptions),
...queryOptions,
- }) as UseQueryResult & { queryKey: QueryKey }
+ }) as UseQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
@@ -52,7 +53,7 @@ export function useGetUserByName(
username: GetUserByNamePathParams['username'],
options: Partial[0]> = {},
-): UseInfiniteQueryOptions {
+): UseInfiniteQueryOptions, TError> {
const queryKey = getUserByNameQueryKey(username)
return {
@@ -63,7 +64,7 @@ export function getUserByNameQueryOptionsInfinite res.data)
+ }).then((res) => res)
},
}
}
@@ -76,17 +77,17 @@ export function getUserByNameQueryOptionsInfinite(
username: GetUserByNamePathParams['username'],
options: {
- query?: UseInfiniteQueryOptions
+ query?: UseInfiniteQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseInfiniteQueryResult & { queryKey: QueryKey } {
+): UseInfiniteQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? getUserByNameQueryKey(username)
- const query = useInfiniteQuery({
+ const query = useInfiniteQuery, TError>({
...getUserByNameQueryOptionsInfinite(username, clientOptions),
...queryOptions,
- }) as UseInfiniteQueryResult & { queryKey: QueryKey }
+ }) as UseInfiniteQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
diff --git a/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts
index e9b110942..5650b3462 100644
--- a/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts
+++ b/examples/advanced/src/gen/clients/hooks/userController/useLoginUser.ts
@@ -1,6 +1,7 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../../../models/ts/userController/LoginUser'
export const loginUserQueryKey = (params?: LoginUserQueryParams) => [`/user/login`, ...(params ? [params] : [])] as const
@@ -8,7 +9,7 @@ export const loginUserQueryKey = (params?: LoginUserQueryParams) => [`/user/logi
export function loginUserQueryOptions(
params?: LoginUserQueryParams,
options: Partial[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions, TError> {
const queryKey = loginUserQueryKey(params)
return {
@@ -20,7 +21,7 @@ export function loginUserQueryOptions res.data)
+ }).then((res) => res)
},
}
}
@@ -33,17 +34,17 @@ export function loginUserQueryOptions(
params?: LoginUserQueryParams,
options: {
- query?: UseQueryOptions
+ query?: UseQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseQueryResult & { queryKey: QueryKey } {
+): UseQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? loginUserQueryKey(params)
- const query = useQuery({
+ const query = useQuery, TError>({
...loginUserQueryOptions(params, clientOptions),
...queryOptions,
- }) as UseQueryResult & { queryKey: QueryKey }
+ }) as UseQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
@@ -53,7 +54,7 @@ export function useLoginUser(
params?: LoginUserQueryParams,
options: Partial[0]> = {},
-): UseInfiniteQueryOptions {
+): UseInfiniteQueryOptions, TError> {
const queryKey = loginUserQueryKey(params)
return {
@@ -69,7 +70,7 @@ export function loginUserQueryOptionsInfinite res.data)
+ }).then((res) => res)
},
}
}
@@ -82,17 +83,17 @@ export function loginUserQueryOptionsInfinite(
params?: LoginUserQueryParams,
options: {
- query?: UseInfiniteQueryOptions
+ query?: UseInfiniteQueryOptions, TError>
client?: Partial>[0]>
} = {},
-): UseInfiniteQueryResult & { queryKey: QueryKey } {
+): UseInfiniteQueryResult, TError> & { queryKey: QueryKey } {
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
const queryKey = queryOptions?.queryKey ?? loginUserQueryKey(params)
- const query = useInfiniteQuery({
+ const query = useInfiniteQuery, TError>({
...loginUserQueryOptionsInfinite(params, clientOptions),
...queryOptions,
- }) as UseInfiniteQueryResult & { queryKey: QueryKey }
+ }) as UseInfiniteQueryResult, TError> & { queryKey: QueryKey }
query.queryKey = queryKey as QueryKey
diff --git a/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts
index f42aeba57..725e00035 100644
--- a/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts
+++ b/examples/advanced/src/gen/clients/hooks/userController/useLogoutUser.ts
@@ -1,13 +1,14 @@
import type { QueryKey, UseQueryResult, UseQueryOptions, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'
import client from '../../../../client'
+import type { ResponseConfig } from '../../../../client'
import type { LogoutUserQueryResponse } from '../../../models/ts/userController/LogoutUser'
export const logoutUserQueryKey = () => [`/user/logout`] as const
export function logoutUserQueryOptions(
options: Partial[0]> = {},
-): UseQueryOptions {
+): UseQueryOptions