@kubb/plugin-vue-query 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-BeGGMRuk.d.cts → types-B6HlLDzG.d.cts} +9 -2
- package/dist/{types-BeGGMRuk.d.ts → types-B6HlLDzG.d.ts} +9 -2
- package/package.json +10 -10
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +55 -36
- package/src/generators/__snapshots__/clientGetImportPath.ts +55 -36
- package/src/generators/__snapshots__/clientPostImportPath.ts +51 -33
- package/src/generators/__snapshots__/findByTags.ts +55 -36
- package/src/generators/__snapshots__/findByTagsObject.ts +57 -46
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +55 -36
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +56 -36
- package/src/generators/__snapshots__/findByTagsWithZod.ts +55 -36
- package/src/generators/__snapshots__/findInfiniteByTags.ts +62 -41
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +62 -41
- package/src/generators/__snapshots__/postAsQuery.ts +68 -38
- package/src/generators/__snapshots__/updatePetById.ts +51 -33
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +51 -35
- package/src/plugin.ts +1 -1
|
@@ -1,58 +1,79 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { infiniteQueryOptions, useInfiniteQuery } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from '@tanstack/react-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) =>
|
|
8
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
12
13
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
13
14
|
* @summary Finds Pets by tags
|
|
14
15
|
* {@link /pet/findByTags}
|
|
15
16
|
*/
|
|
16
17
|
async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
|
|
19
|
+
method: 'GET',
|
|
20
|
+
url: `/pet/findByTags`,
|
|
21
|
+
params,
|
|
22
|
+
headers: { ...headers, ...config.headers },
|
|
23
|
+
...config,
|
|
24
|
+
})
|
|
25
|
+
return findPetsByTagsQueryResponse.parse(res.data)
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export function findPetsByTagsInfiniteQueryOptions(
|
|
29
|
+
headers: MaybeRef<FindPetsByTagsHeaderParams>,
|
|
30
|
+
params?: MaybeRef<FindPetsByTagsQueryParams>,
|
|
31
|
+
config: Partial<RequestConfig> = {},
|
|
32
|
+
) {
|
|
33
|
+
const queryKey = findPetsByTagsInfiniteQueryKey(params)
|
|
34
|
+
return infiniteQueryOptions({
|
|
35
|
+
queryKey,
|
|
36
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
37
|
+
config.signal = signal
|
|
38
|
+
|
|
39
|
+
if (params) {
|
|
40
|
+
params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
|
|
41
|
+
}
|
|
42
|
+
return findPetsByTags(headers, params, config)
|
|
43
|
+
},
|
|
44
|
+
initialPageParam: 0,
|
|
45
|
+
getNextPageParam: (lastPage, _allPages, lastPageParam) => (Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1),
|
|
46
|
+
getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => (firstPageParam <= 1 ? undefined : firstPageParam - 1),
|
|
47
|
+
})
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
/**
|
|
39
51
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
40
52
|
* @summary Finds Pets by tags
|
|
41
53
|
* {@link /pet/findByTags}
|
|
42
54
|
*/
|
|
43
|
-
export function useFindPetsByTagsInfinite<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export function useFindPetsByTagsInfinite<
|
|
56
|
+
TData = InfiniteData<FindPetsByTagsQueryResponse>,
|
|
57
|
+
TQueryData = FindPetsByTagsQueryResponse,
|
|
58
|
+
TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
|
|
59
|
+
>(
|
|
60
|
+
headers: MaybeRef<FindPetsByTagsHeaderParams>,
|
|
61
|
+
params?: MaybeRef<FindPetsByTagsQueryParams>,
|
|
62
|
+
options: {
|
|
63
|
+
query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
|
|
64
|
+
client?: Partial<RequestConfig>
|
|
65
|
+
} = {},
|
|
66
|
+
) {
|
|
67
|
+
const { query: queryOptions, client: config = {} } = options ?? {}
|
|
68
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
|
|
69
|
+
|
|
70
|
+
const query = useInfiniteQuery({
|
|
71
|
+
...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
|
|
72
|
+
queryKey: queryKey as QueryKey,
|
|
73
|
+
...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
|
|
74
|
+
}) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & { queryKey: TQueryKey }
|
|
75
|
+
|
|
76
|
+
query.queryKey = queryKey as TQueryKey
|
|
77
|
+
|
|
78
|
+
return query
|
|
58
79
|
}
|
|
@@ -1,58 +1,79 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { infiniteQueryOptions, useInfiniteQuery } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from '@tanstack/react-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) =>
|
|
8
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
12
13
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
13
14
|
* @summary Finds Pets by tags
|
|
14
15
|
* {@link /pet/findByTags}
|
|
15
16
|
*/
|
|
16
17
|
async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
|
|
19
|
+
method: 'GET',
|
|
20
|
+
url: `/pet/findByTags`,
|
|
21
|
+
params,
|
|
22
|
+
headers: { ...headers, ...config.headers },
|
|
23
|
+
...config,
|
|
24
|
+
})
|
|
25
|
+
return findPetsByTagsQueryResponse.parse(res.data)
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export function findPetsByTagsInfiniteQueryOptions(
|
|
29
|
+
headers: MaybeRef<FindPetsByTagsHeaderParams>,
|
|
30
|
+
params?: MaybeRef<FindPetsByTagsQueryParams>,
|
|
31
|
+
config: Partial<RequestConfig> = {},
|
|
32
|
+
) {
|
|
33
|
+
const queryKey = findPetsByTagsInfiniteQueryKey(params)
|
|
34
|
+
return infiniteQueryOptions({
|
|
35
|
+
queryKey,
|
|
36
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
37
|
+
config.signal = signal
|
|
38
|
+
|
|
39
|
+
if (params) {
|
|
40
|
+
params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
|
|
41
|
+
}
|
|
42
|
+
return findPetsByTags(headers, params, config)
|
|
43
|
+
},
|
|
44
|
+
initialPageParam: 0,
|
|
45
|
+
getNextPageParam: (lastPage) => lastPage['cursor'],
|
|
46
|
+
getPreviousPageParam: (firstPage) => firstPage['cursor'],
|
|
47
|
+
})
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
/**
|
|
39
51
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
40
52
|
* @summary Finds Pets by tags
|
|
41
53
|
* {@link /pet/findByTags}
|
|
42
54
|
*/
|
|
43
|
-
export function useFindPetsByTagsInfinite<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export function useFindPetsByTagsInfinite<
|
|
56
|
+
TData = InfiniteData<FindPetsByTagsQueryResponse>,
|
|
57
|
+
TQueryData = FindPetsByTagsQueryResponse,
|
|
58
|
+
TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
|
|
59
|
+
>(
|
|
60
|
+
headers: MaybeRef<FindPetsByTagsHeaderParams>,
|
|
61
|
+
params?: MaybeRef<FindPetsByTagsQueryParams>,
|
|
62
|
+
options: {
|
|
63
|
+
query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
|
|
64
|
+
client?: Partial<RequestConfig>
|
|
65
|
+
} = {},
|
|
66
|
+
) {
|
|
67
|
+
const { query: queryOptions, client: config = {} } = options ?? {}
|
|
68
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
|
|
69
|
+
|
|
70
|
+
const query = useInfiniteQuery({
|
|
71
|
+
...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
|
|
72
|
+
queryKey: queryKey as QueryKey,
|
|
73
|
+
...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
|
|
74
|
+
}) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & { queryKey: TQueryKey }
|
|
75
|
+
|
|
76
|
+
query.queryKey = queryKey as TQueryKey
|
|
77
|
+
|
|
78
|
+
return query
|
|
58
79
|
}
|
|
@@ -1,52 +1,82 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { queryOptions, useQuery } from
|
|
6
|
-
import { unref } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from 'custom-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { queryOptions, useQuery } from 'custom-query'
|
|
6
|
+
import { unref } from 'vue'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export const updatePetWithFormQueryKey = (
|
|
9
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
10
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
11
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
12
|
+
) => [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
/**
|
|
13
17
|
* @summary Updates a pet in the store with form data
|
|
14
18
|
* {@link /pet/:petId}
|
|
15
19
|
*/
|
|
16
|
-
async function updatePetWithForm(
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
async function updatePetWithForm(
|
|
21
|
+
petId: UpdatePetWithFormPathParams['petId'],
|
|
22
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
23
|
+
params?: UpdatePetWithFormQueryParams,
|
|
24
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
25
|
+
) {
|
|
26
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
27
|
+
method: 'POST',
|
|
28
|
+
url: `/pet/${petId}`,
|
|
29
|
+
params,
|
|
30
|
+
data,
|
|
31
|
+
...config,
|
|
32
|
+
})
|
|
33
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
export function updatePetWithFormQueryOptions(
|
|
37
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
38
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
39
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
40
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
41
|
+
) {
|
|
42
|
+
const queryKey = updatePetWithFormQueryKey(petId, data, params)
|
|
43
|
+
return queryOptions({
|
|
44
|
+
enabled: !!petId,
|
|
45
|
+
queryKey,
|
|
46
|
+
queryFn: async ({ signal }) => {
|
|
47
|
+
config.signal = signal
|
|
48
|
+
return updatePetWithForm(unref(petId), unref(data), unref(params), unref(config))
|
|
49
|
+
},
|
|
50
|
+
})
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
/**
|
|
34
54
|
* @summary Updates a pet in the store with form data
|
|
35
55
|
* {@link /pet/:petId}
|
|
36
56
|
*/
|
|
37
|
-
export function useUpdatePetWithForm<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
export function useUpdatePetWithForm<
|
|
58
|
+
TData = UpdatePetWithFormMutationResponse,
|
|
59
|
+
TQueryData = UpdatePetWithFormMutationResponse,
|
|
60
|
+
TQueryKey extends QueryKey = UpdatePetWithFormQueryKey,
|
|
61
|
+
>(
|
|
62
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
63
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
64
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
65
|
+
options: {
|
|
66
|
+
query?: Partial<QueryObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>
|
|
67
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
68
|
+
} = {},
|
|
69
|
+
) {
|
|
70
|
+
const { query: queryOptions, client: config = {} } = options ?? {}
|
|
71
|
+
const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params)
|
|
72
|
+
|
|
73
|
+
const query = useQuery({
|
|
74
|
+
...(updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions),
|
|
75
|
+
queryKey: queryKey as QueryKey,
|
|
76
|
+
...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
|
|
77
|
+
}) as UseQueryReturnType<TData, UpdatePetWithForm405> & { queryKey: TQueryKey }
|
|
78
|
+
|
|
79
|
+
query.queryKey = queryKey as TQueryKey
|
|
80
|
+
|
|
81
|
+
return query
|
|
52
82
|
}
|
|
@@ -1,45 +1,63 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { MutationObserverOptions } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { useMutation } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { MutationObserverOptions } from '@tanstack/vue-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
12
|
* @summary Updates a pet in the store with form data
|
|
13
13
|
* {@link /pet/:petId}
|
|
14
14
|
*/
|
|
15
|
-
async function updatePetWithForm(
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
async function updatePetWithForm(
|
|
16
|
+
petId: UpdatePetWithFormPathParams['petId'],
|
|
17
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
18
|
+
params?: UpdatePetWithFormQueryParams,
|
|
19
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
20
|
+
) {
|
|
21
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
url: `/pet/${petId}`,
|
|
24
|
+
params,
|
|
25
|
+
data,
|
|
26
|
+
...config,
|
|
27
|
+
})
|
|
28
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
18
29
|
}
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
/**
|
|
21
32
|
* @summary Updates a pet in the store with form data
|
|
22
33
|
* {@link /pet/:petId}
|
|
23
34
|
*/
|
|
24
|
-
export function useUpdatePetWithForm(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
35
|
+
export function useUpdatePetWithForm(
|
|
36
|
+
options: {
|
|
37
|
+
mutation?: MutationObserverOptions<
|
|
38
|
+
UpdatePetWithFormMutationResponse,
|
|
39
|
+
UpdatePetWithForm405,
|
|
40
|
+
{
|
|
41
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>
|
|
42
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>
|
|
43
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
47
|
+
} = {},
|
|
48
|
+
) {
|
|
49
|
+
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
50
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
51
|
+
|
|
52
|
+
return useMutation<
|
|
53
|
+
UpdatePetWithFormMutationResponse,
|
|
54
|
+
UpdatePetWithForm405,
|
|
55
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
56
|
+
>({
|
|
57
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
58
|
+
return updatePetWithForm(petId, data, params, config)
|
|
59
|
+
},
|
|
60
|
+
mutationKey,
|
|
61
|
+
...mutationOptions,
|
|
62
|
+
})
|
|
45
63
|
}
|
|
@@ -1,47 +1,63 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { MutationObserverOptions } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { useMutation } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { MutationObserverOptions } from '@tanstack/vue-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
12
|
* @summary Updates a pet in the store with form data
|
|
13
13
|
* {@link /pet/:petId}
|
|
14
14
|
*/
|
|
15
|
-
async function updatePetWithForm(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
async function updatePetWithForm(
|
|
16
|
+
{ petId }: { petId: UpdatePetWithFormPathParams['petId'] },
|
|
17
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
18
|
+
params?: UpdatePetWithFormQueryParams,
|
|
19
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
20
|
+
) {
|
|
21
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
url: `/pet/${petId}`,
|
|
24
|
+
params,
|
|
25
|
+
data,
|
|
26
|
+
...config,
|
|
27
|
+
})
|
|
28
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
/**
|
|
23
32
|
* @summary Updates a pet in the store with form data
|
|
24
33
|
* {@link /pet/:petId}
|
|
25
34
|
*/
|
|
26
|
-
export function useUpdatePetWithForm(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
35
|
+
export function useUpdatePetWithForm(
|
|
36
|
+
options: {
|
|
37
|
+
mutation?: MutationObserverOptions<
|
|
38
|
+
UpdatePetWithFormMutationResponse,
|
|
39
|
+
UpdatePetWithForm405,
|
|
40
|
+
{
|
|
41
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>
|
|
42
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>
|
|
43
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
47
|
+
} = {},
|
|
48
|
+
) {
|
|
49
|
+
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
50
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
51
|
+
|
|
52
|
+
return useMutation<
|
|
53
|
+
UpdatePetWithFormMutationResponse,
|
|
54
|
+
UpdatePetWithForm405,
|
|
55
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
56
|
+
>({
|
|
57
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
58
|
+
return updatePetWithForm({ petId }, data, params, config)
|
|
59
|
+
},
|
|
60
|
+
mutationKey,
|
|
61
|
+
...mutationOptions,
|
|
62
|
+
})
|
|
47
63
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -40,7 +40,7 @@ export const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {
|
|
|
40
40
|
options: {
|
|
41
41
|
output,
|
|
42
42
|
client: {
|
|
43
|
-
importPath: '@kubb/plugin-client/
|
|
43
|
+
importPath: '@kubb/plugin-client/clients/axios',
|
|
44
44
|
dataReturnType: 'data',
|
|
45
45
|
pathParamsType: 'inline',
|
|
46
46
|
...options.client,
|