@kubb/plugin-react-query 3.1.0 → 3.3.0

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.
Files changed (58) hide show
  1. package/dist/{chunk-PBJIUPCN.cjs → chunk-4I6UYXEA.cjs} +33 -18
  2. package/dist/chunk-4I6UYXEA.cjs.map +1 -0
  3. package/dist/{chunk-YGWYQQ6H.js → chunk-JICGDXHM.js} +86 -55
  4. package/dist/chunk-JICGDXHM.js.map +1 -0
  5. package/dist/{chunk-GMONUHPD.js → chunk-QFITPKDT.js} +18 -3
  6. package/dist/chunk-QFITPKDT.js.map +1 -0
  7. package/dist/{chunk-WOYQTGDC.cjs → chunk-YNY2PBUX.cjs} +86 -55
  8. package/dist/chunk-YNY2PBUX.cjs.map +1 -0
  9. package/dist/components.cjs +9 -9
  10. package/dist/components.d.cts +29 -15
  11. package/dist/components.d.ts +29 -15
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +6 -6
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +8 -6
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +6 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-BBt81Oun.d.cts → types-DbdPn2MA.d.cts} +22 -2
  24. package/dist/{types-BBt81Oun.d.ts → types-DbdPn2MA.d.ts} +22 -2
  25. package/package.json +11 -11
  26. package/src/components/InfiniteQuery.tsx +9 -3
  27. package/src/components/InfiniteQueryOptions.tsx +25 -13
  28. package/src/components/Mutation.tsx +18 -4
  29. package/src/components/MutationKey.tsx +5 -4
  30. package/src/components/Query.tsx +9 -3
  31. package/src/components/QueryKey.tsx +9 -6
  32. package/src/components/QueryOptions.tsx +9 -5
  33. package/src/components/SuspenseQuery.tsx +9 -3
  34. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
  35. package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
  36. package/src/generators/__snapshots__/clientPostImportPath.ts +48 -34
  37. package/src/generators/__snapshots__/findByTags.ts +49 -34
  38. package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
  39. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
  40. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
  41. package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
  42. package/src/generators/__snapshots__/findInfiniteByTags.ts +60 -40
  43. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +60 -40
  44. package/src/generators/__snapshots__/getAsMutation.ts +2 -2
  45. package/src/generators/__snapshots__/getPetIdCamelCase.ts +56 -0
  46. package/src/generators/__snapshots__/postAsQuery.ts +68 -38
  47. package/src/generators/__snapshots__/updatePetById.ts +48 -34
  48. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +48 -36
  49. package/src/generators/infiniteQueryGenerator.tsx +4 -1
  50. package/src/generators/mutationGenerator.tsx +3 -0
  51. package/src/generators/queryGenerator.tsx +4 -0
  52. package/src/generators/suspenseQueryGenerator.tsx +4 -0
  53. package/src/plugin.ts +3 -1
  54. package/src/types.ts +7 -0
  55. package/dist/chunk-GMONUHPD.js.map +0 -1
  56. package/dist/chunk-PBJIUPCN.cjs.map +0 -1
  57. package/dist/chunk-WOYQTGDC.cjs.map +0 -1
  58. package/dist/chunk-YGWYQQ6H.js.map +0 -1
@@ -14,23 +14,25 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
17
18
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
18
19
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
19
20
  }
20
21
 
21
22
  type GetParamsProps = {
23
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
22
24
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
23
25
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
24
26
  typeSchemas: OperationSchemas
25
27
  }
26
28
 
27
- function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
29
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
28
30
  if (paramsType === 'object') {
29
31
  return FunctionParams.factory({
30
32
  data: {
31
33
  mode: 'object',
32
34
  children: {
33
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
35
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
34
36
  data: typeSchemas.request?.name
35
37
  ? {
36
38
  type: typeSchemas.request?.name,
@@ -62,7 +64,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
62
64
  pathParams: typeSchemas.pathParams?.name
63
65
  ? {
64
66
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
65
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
67
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
66
68
  optional: isOptional(typeSchemas.pathParams?.schema),
67
69
  }
68
70
  : undefined,
@@ -91,16 +93,18 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
91
93
  })
92
94
  }
93
95
 
94
- export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
95
- const params = getParams({ paramsType, pathParamsType, typeSchemas })
96
+ export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
97
+ const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
96
98
  const clientParams = Client.getParams({
97
99
  typeSchemas,
100
+ paramsCasing,
98
101
  paramsType,
99
102
  pathParamsType,
100
103
  })
101
104
  const queryKeyParams = QueryKey.getParams({
102
105
  pathParamsType,
103
106
  typeSchemas,
107
+ paramsCasing,
104
108
  })
105
109
 
106
110
  const enabled = Object.entries(queryKeyParams.flatParams)
@@ -18,19 +18,21 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
21
22
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
23
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
24
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
24
25
  }
25
26
 
26
27
  type GetParamsProps = {
28
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
27
29
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
28
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
 
36
38
  if (paramsType === 'object') {
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
38
40
  data: {
39
41
  mode: 'object',
40
42
  children: {
41
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
42
44
  data: typeSchemas.request?.name
43
45
  ? {
44
46
  type: typeSchemas.request?.name,
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
75
77
  pathParams: typeSchemas.pathParams?.name
76
78
  ? {
77
79
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
80
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
79
81
  optional: isOptional(typeSchemas.pathParams?.schema),
80
82
  }
81
83
  : undefined,
@@ -115,6 +117,7 @@ export function SuspenseQuery({
115
117
  queryOptionsName,
116
118
  queryKeyName,
117
119
  paramsType,
120
+ paramsCasing,
118
121
  pathParamsType,
119
122
  dataReturnType,
120
123
  typeSchemas,
@@ -127,13 +130,16 @@ export function SuspenseQuery({
127
130
  const queryKeyParams = QueryKey.getParams({
128
131
  pathParamsType,
129
132
  typeSchemas,
133
+ paramsCasing,
130
134
  })
131
135
  const queryOptionsParams = QueryOptions.getParams({
136
+ paramsCasing,
132
137
  paramsType,
133
138
  pathParamsType,
134
139
  typeSchemas,
135
140
  })
136
141
  const params = getParams({
142
+ paramsCasing,
137
143
  paramsType,
138
144
  pathParamsType,
139
145
  dataReturnType,
@@ -1,51 +1,66 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
- import { queryOptions, useQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
4
+ import { queryOptions, useQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) }
18
24
  }
19
25
 
20
- export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = ResponseConfig<FindPetsByTagsQueryResponse>,
44
+ TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,51 +1,66 @@
1
- import client from "axios";
2
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
3
- import type { RequestConfig } from "axios";
4
- import { queryOptions, useQuery } from "@tanstack/react-query";
1
+ import client from 'axios'
2
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { queryOptions, useQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return findPetsByTagsQueryResponse.parse(res.data);
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return findPetsByTagsQueryResponse.parse(res.data)
18
24
  }
19
25
 
20
- export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,44 +1,58 @@
1
- import client from "axios";
2
- import type { UseMutationOptions } from "@tanstack/react-query";
3
- import type { RequestConfig } from "axios";
4
- import { useMutation } from "@tanstack/react-query";
1
+ import client from 'axios'
2
+ import type { UseMutationOptions } from '@tanstack/react-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { useMutation } from '@tanstack/react-query'
5
5
 
6
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{pet_id}' }] as const
7
7
 
8
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @summary Updates a pet in the store with form data
12
- * {@link /pet/:petId}
12
+ * {@link /pet/:pet_id}
13
13
  */
14
- async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
- return updatePetWithFormMutationResponse.parse(res.data);
14
+ async function updatePetWithForm(
15
+ petId: UpdatePetWithFormPathParams['petId'],
16
+ data?: UpdatePetWithFormMutationRequest,
17
+ params?: UpdatePetWithFormQueryParams,
18
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
19
+ ) {
20
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
21
+ method: 'POST',
22
+ url: `/pet/${pet_id}`,
23
+ params,
24
+ data,
25
+ ...config,
26
+ })
27
+ return updatePetWithFormMutationResponse.parse(res.data)
17
28
  }
18
29
 
19
- /**
30
+ /**
20
31
  * @summary Updates a pet in the store with form data
21
- * {@link /pet/:petId}
32
+ * {@link /pet/:pet_id}
22
33
  */
23
- export function useUpdatePetWithForm(options: {
24
- mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
- petId: UpdatePetWithFormPathParams["petId"];
26
- data?: UpdatePetWithFormMutationRequest;
27
- params?: UpdatePetWithFormQueryParams;
28
- }>;
29
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
- } = {}) {
31
- const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
- return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
- petId: UpdatePetWithFormPathParams["petId"];
35
- data?: UpdatePetWithFormMutationRequest;
36
- params?: UpdatePetWithFormQueryParams;
37
- }>({
38
- mutationFn: async ({ petId, data, params }) => {
39
- return updatePetWithForm(petId, data, params, config);
40
- },
41
- mutationKey,
42
- ...mutationOptions
43
- });
34
+ export function useUpdatePetWithForm(
35
+ options: {
36
+ mutation?: UseMutationOptions<
37
+ UpdatePetWithFormMutationResponse,
38
+ UpdatePetWithForm405,
39
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
40
+ >
41
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
42
+ } = {},
43
+ ) {
44
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
45
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
46
+
47
+ return useMutation<
48
+ UpdatePetWithFormMutationResponse,
49
+ UpdatePetWithForm405,
50
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
51
+ >({
52
+ mutationFn: async ({ petId, data, params }) => {
53
+ return updatePetWithForm(petId, data, params, config)
54
+ },
55
+ mutationKey,
56
+ ...mutationOptions,
57
+ })
44
58
  }
@@ -1,51 +1,66 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
- import { queryOptions, useQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
4
+ import { queryOptions, useQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return findPetsByTagsQueryResponse.parse(res.data);
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return findPetsByTagsQueryResponse.parse(res.data)
18
24
  }
19
25
 
20
- export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,60 +1,71 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
- import { queryOptions, useQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
4
+ import { queryOptions, useQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
- async function findPetsByTags({ headers, params }: {
16
- headers: FindPetsByTagsHeaderParams;
17
- params?: FindPetsByTagsQueryParams;
18
- }, config: Partial<RequestConfig> = {}) {
19
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
20
- return findPetsByTagsQueryResponse.parse(res.data);
15
+ async function findPetsByTags(
16
+ { headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams },
17
+ config: Partial<RequestConfig> = {},
18
+ ) {
19
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
20
+ method: 'GET',
21
+ url: `/pet/findByTags`,
22
+ params,
23
+ headers: { ...headers, ...config.headers },
24
+ ...config,
25
+ })
26
+ return findPetsByTagsQueryResponse.parse(res.data)
21
27
  }
22
28
 
23
- export function findPetsByTagsQueryOptions({ headers, params }: {
24
- headers: FindPetsByTagsHeaderParams;
25
- params?: FindPetsByTagsQueryParams;
26
- }, config: Partial<RequestConfig> = {}) {
27
- const queryKey = findPetsByTagsQueryKey(params);
28
- return queryOptions({
29
- queryKey,
30
- queryFn: async ({ signal }) => {
31
- config.signal = signal;
32
- return findPetsByTags({ headers, params }, config);
33
- },
34
- });
29
+ export function findPetsByTagsQueryOptions(
30
+ { headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams },
31
+ config: Partial<RequestConfig> = {},
32
+ ) {
33
+ const queryKey = findPetsByTagsQueryKey(params)
34
+ return queryOptions({
35
+ queryKey,
36
+ queryFn: async ({ signal }) => {
37
+ config.signal = signal
38
+ return findPetsByTags({ headers, params }, config)
39
+ },
40
+ })
35
41
  }
36
42
 
37
- /**
43
+ /**
38
44
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
45
  * @summary Finds Pets by tags
40
46
  * {@link /pet/findByTags}
41
47
  */
42
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>({ headers, params }: {
43
- headers: FindPetsByTagsHeaderParams;
44
- params?: FindPetsByTagsQueryParams;
45
- }, options: {
46
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
47
- client?: Partial<RequestConfig>;
48
- } = {}) {
49
- const { query: queryOptions, client: config = {} } = options ?? {};
50
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
51
- const query = useQuery({
52
- ...findPetsByTagsQueryOptions({ headers, params }, config) as unknown as QueryObserverOptions,
53
- queryKey,
54
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
55
- }) as UseQueryResult<TData, FindPetsByTags400> & {
56
- queryKey: TQueryKey;
57
- };
58
- query.queryKey = queryKey as TQueryKey;
59
- return query;
48
+ export function useFindPetsByTags<
49
+ TData = FindPetsByTagsQueryResponse,
50
+ TQueryData = FindPetsByTagsQueryResponse,
51
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
52
+ >(
53
+ { headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams },
54
+ options: {
55
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
56
+ client?: Partial<RequestConfig>
57
+ } = {},
58
+ ) {
59
+ const { query: queryOptions, client: config = {} } = options ?? {}
60
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
61
+
62
+ const query = useQuery({
63
+ ...(findPetsByTagsQueryOptions({ headers, params }, config) as unknown as QueryObserverOptions),
64
+ queryKey,
65
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
66
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
67
+
68
+ query.queryKey = queryKey as TQueryKey
69
+
70
+ return query
60
71
  }