@kubb/plugin-swr 0.0.0-canary-20241104172400

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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/chunk-2KDZWGWG.js +342 -0
  4. package/dist/chunk-2KDZWGWG.js.map +1 -0
  5. package/dist/chunk-64KLXAGI.cjs +237 -0
  6. package/dist/chunk-64KLXAGI.cjs.map +1 -0
  7. package/dist/chunk-AFAHUG3Q.cjs +348 -0
  8. package/dist/chunk-AFAHUG3Q.cjs.map +1 -0
  9. package/dist/chunk-T6K6P5I7.js +234 -0
  10. package/dist/chunk-T6K6P5I7.js.map +1 -0
  11. package/dist/components.cjs +28 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +95 -0
  14. package/dist/components.d.ts +95 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +17 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +11 -0
  20. package/dist/generators.d.ts +11 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +127 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +10 -0
  26. package/dist/index.d.ts +10 -0
  27. package/dist/index.js +120 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-AhGZx7jH.d.cts +272 -0
  30. package/dist/types-AhGZx7jH.d.ts +272 -0
  31. package/package.json +104 -0
  32. package/src/components/Mutation.tsx +129 -0
  33. package/src/components/MutationKey.tsx +54 -0
  34. package/src/components/Query.tsx +175 -0
  35. package/src/components/QueryKey.tsx +83 -0
  36. package/src/components/QueryOptions.tsx +116 -0
  37. package/src/components/index.ts +5 -0
  38. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -0
  39. package/src/generators/__snapshots__/clientGetImportPath.ts +49 -0
  40. package/src/generators/__snapshots__/clientPostImportPath.ts +32 -0
  41. package/src/generators/__snapshots__/findByTags.ts +49 -0
  42. package/src/generators/__snapshots__/findByTagsObject.ts +49 -0
  43. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -0
  44. package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -0
  45. package/src/generators/__snapshots__/getAsMutation.ts +34 -0
  46. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  47. package/src/generators/__snapshots__/updatePetById.ts +32 -0
  48. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +34 -0
  49. package/src/generators/index.ts +2 -0
  50. package/src/generators/mutationGenerator.tsx +117 -0
  51. package/src/generators/queryGenerator.tsx +127 -0
  52. package/src/index.ts +4 -0
  53. package/src/plugin.ts +141 -0
  54. package/src/types.ts +126 -0
@@ -0,0 +1,175 @@
1
+ import { URLPath } from '@kubb/core/utils'
2
+ import { File, Function, FunctionParams } from '@kubb/react'
3
+
4
+ import { type Operation, isOptional } from '@kubb/oas'
5
+ import type { OperationSchemas } from '@kubb/plugin-oas'
6
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
7
+ import type { ReactNode } from 'react'
8
+ import type { PluginSwr } from '../types.ts'
9
+ import { QueryKey } from './QueryKey.tsx'
10
+ import { QueryOptions } from './QueryOptions.tsx'
11
+
12
+ type Props = {
13
+ /**
14
+ * Name of the function
15
+ */
16
+ name: string
17
+ queryOptionsName: string
18
+ queryKeyName: string
19
+ queryKeyTypeName: string
20
+ typeSchemas: OperationSchemas
21
+ paramsType: PluginSwr['resolvedOptions']['paramsType']
22
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
23
+ dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
24
+ operation: Operation
25
+ }
26
+
27
+ type GetParamsProps = {
28
+ paramsType: PluginSwr['resolvedOptions']['paramsType']
29
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
30
+ dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
31
+ queryKeyTypeName: string
32
+ typeSchemas: OperationSchemas
33
+ }
34
+
35
+ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: GetParamsProps) {
36
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
37
+
38
+ if (paramsType === 'object') {
39
+ return FunctionParams.factory({
40
+ data: {
41
+ mode: 'object',
42
+ children: {
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
44
+ data: typeSchemas.request?.name
45
+ ? {
46
+ type: typeSchemas.request?.name,
47
+ optional: isOptional(typeSchemas.request?.schema),
48
+ }
49
+ : undefined,
50
+ params: typeSchemas.queryParams?.name
51
+ ? {
52
+ type: typeSchemas.queryParams?.name,
53
+ optional: isOptional(typeSchemas.queryParams?.schema),
54
+ }
55
+ : undefined,
56
+ headers: typeSchemas.headerParams?.name
57
+ ? {
58
+ type: typeSchemas.headerParams?.name,
59
+ optional: isOptional(typeSchemas.headerParams?.schema),
60
+ }
61
+ : undefined,
62
+ },
63
+ },
64
+ options: {
65
+ type: `
66
+ {
67
+ query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
68
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
69
+ shouldFetch?: boolean,
70
+ }
71
+ `,
72
+ default: '{}',
73
+ },
74
+ })
75
+ }
76
+
77
+ return FunctionParams.factory({
78
+ pathParams: typeSchemas.pathParams?.name
79
+ ? {
80
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
81
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
82
+ type: typeSchemas.pathParams?.name,
83
+ optional: isOptional(typeSchemas.pathParams?.schema),
84
+ }
85
+ : undefined,
86
+ data: typeSchemas.request?.name
87
+ ? {
88
+ type: typeSchemas.request?.name,
89
+ optional: isOptional(typeSchemas.request?.schema),
90
+ }
91
+ : undefined,
92
+ params: typeSchemas.queryParams?.name
93
+ ? {
94
+ type: typeSchemas.queryParams?.name,
95
+ optional: isOptional(typeSchemas.queryParams?.schema),
96
+ }
97
+ : undefined,
98
+ headers: typeSchemas.headerParams?.name
99
+ ? {
100
+ type: typeSchemas.headerParams?.name,
101
+ optional: isOptional(typeSchemas.headerParams?.schema),
102
+ }
103
+ : undefined,
104
+ options: {
105
+ type: `
106
+ {
107
+ query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
108
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
109
+ shouldFetch?: boolean,
110
+ }
111
+ `,
112
+ default: '{}',
113
+ },
114
+ })
115
+ }
116
+
117
+ export function Query({
118
+ name,
119
+ typeSchemas,
120
+ queryKeyName,
121
+ queryKeyTypeName,
122
+ queryOptionsName,
123
+ operation,
124
+ dataReturnType,
125
+ paramsType,
126
+ pathParamsType,
127
+ }: Props): ReactNode {
128
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
129
+ const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`]
130
+
131
+ const queryKeyParams = QueryKey.getParams({
132
+ pathParamsType,
133
+ typeSchemas,
134
+ })
135
+ const params = getParams({
136
+ paramsType,
137
+ pathParamsType,
138
+ dataReturnType,
139
+ typeSchemas,
140
+ queryKeyTypeName,
141
+ })
142
+
143
+ const queryOptionsParams = QueryOptions.getParams({
144
+ paramsType,
145
+ pathParamsType,
146
+ typeSchemas,
147
+ })
148
+
149
+ return (
150
+ <File.Source name={name} isExportable isIndexable>
151
+ <Function
152
+ name={name}
153
+ export
154
+ params={params.toConstructor()}
155
+ JSDoc={{
156
+ comments: getComments(operation),
157
+ }}
158
+ >
159
+ {`
160
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
161
+
162
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
163
+
164
+ return useSWR<${generics.join(', ')}>(
165
+ shouldFetch ? queryKey : null,
166
+ {
167
+ ...${queryOptionsName}(${queryOptionsParams.toCall()})
168
+ ...queryOptions
169
+ }
170
+ )
171
+ `}
172
+ </Function>
173
+ </File.Source>
174
+ )
175
+ }
@@ -0,0 +1,83 @@
1
+ import { URLPath } from '@kubb/core/utils'
2
+ import { getPathParams } from '@kubb/plugin-oas/utils'
3
+ import { File, Function, FunctionParams, Type } from '@kubb/react'
4
+
5
+ import { type Operation, isOptional } from '@kubb/oas'
6
+ import type { OperationSchemas } from '@kubb/plugin-oas'
7
+ import type { ReactNode } from 'react'
8
+ import type { PluginSwr, Transformer } from '../types'
9
+
10
+ type Props = {
11
+ name: string
12
+ typeName: string
13
+ typeSchemas: OperationSchemas
14
+ operation: Operation
15
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
16
+ transformer: Transformer | undefined
17
+ }
18
+
19
+ type GetParamsProps = {
20
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
21
+ typeSchemas: OperationSchemas
22
+ }
23
+
24
+ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
25
+ return FunctionParams.factory({
26
+ pathParams: {
27
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
28
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
29
+ },
30
+ data: typeSchemas.request?.name
31
+ ? {
32
+ type: typeSchemas.request?.name,
33
+ optional: isOptional(typeSchemas.request?.schema),
34
+ }
35
+ : undefined,
36
+ params: typeSchemas.queryParams?.name
37
+ ? {
38
+ type: typeSchemas.queryParams?.name,
39
+ optional: isOptional(typeSchemas.queryParams?.schema),
40
+ }
41
+ : undefined,
42
+ })
43
+ }
44
+
45
+ const getTransformer: Transformer = ({ operation, schemas }) => {
46
+ const path = new URLPath(operation.path)
47
+ const keys = [
48
+ path.toObject({
49
+ type: 'path',
50
+ stringify: true,
51
+ }),
52
+ schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
53
+ schemas.request?.name ? '...(data ? [data] : [])' : undefined,
54
+ ].filter(Boolean)
55
+
56
+ return keys
57
+ }
58
+
59
+ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
60
+ const params = getParams({ pathParamsType, typeSchemas })
61
+ const keys = transformer({
62
+ operation,
63
+ schemas: typeSchemas,
64
+ })
65
+
66
+ return (
67
+ <>
68
+ <File.Source name={name} isExportable isIndexable>
69
+ <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
70
+ {`[${keys.join(', ')}] as const`}
71
+ </Function.Arrow>
72
+ </File.Source>
73
+ <File.Source name={typeName} isExportable isIndexable isTypeOnly>
74
+ <Type name={typeName} export>
75
+ {`ReturnType<typeof ${name}>`}
76
+ </Type>
77
+ </File.Source>
78
+ </>
79
+ )
80
+ }
81
+
82
+ QueryKey.getParams = getParams
83
+ QueryKey.getTransformer = getTransformer
@@ -0,0 +1,116 @@
1
+ import { getPathParams } from '@kubb/plugin-oas/utils'
2
+ import { File, Function, FunctionParams } from '@kubb/react'
3
+
4
+ import type { ReactNode } from 'react'
5
+ import type { PluginSwr } from '../types.ts'
6
+
7
+ import { isOptional } from '@kubb/oas'
8
+ import { Client } from '@kubb/plugin-client/components'
9
+ import type { OperationSchemas } from '@kubb/plugin-oas'
10
+
11
+ type Props = {
12
+ name: string
13
+ clientName: string
14
+ typeSchemas: OperationSchemas
15
+ paramsType: PluginSwr['resolvedOptions']['paramsType']
16
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
17
+ }
18
+
19
+ type GetParamsProps = {
20
+ paramsType: PluginSwr['resolvedOptions']['paramsType']
21
+ pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
22
+ typeSchemas: OperationSchemas
23
+ }
24
+
25
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
26
+ if (paramsType === 'object') {
27
+ return FunctionParams.factory({
28
+ data: {
29
+ mode: 'object',
30
+ children: {
31
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
32
+ data: typeSchemas.request?.name
33
+ ? {
34
+ type: typeSchemas.request?.name,
35
+ optional: isOptional(typeSchemas.request?.schema),
36
+ }
37
+ : undefined,
38
+ params: typeSchemas.queryParams?.name
39
+ ? {
40
+ type: typeSchemas.queryParams?.name,
41
+ optional: isOptional(typeSchemas.queryParams?.schema),
42
+ }
43
+ : undefined,
44
+ headers: typeSchemas.headerParams?.name
45
+ ? {
46
+ type: typeSchemas.headerParams?.name,
47
+ optional: isOptional(typeSchemas.headerParams?.schema),
48
+ }
49
+ : undefined,
50
+ },
51
+ },
52
+ config: {
53
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
54
+ default: '{}',
55
+ },
56
+ })
57
+ }
58
+
59
+ return FunctionParams.factory({
60
+ pathParams: typeSchemas.pathParams?.name
61
+ ? {
62
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
63
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
64
+ type: typeSchemas.pathParams?.name,
65
+ optional: isOptional(typeSchemas.pathParams?.schema),
66
+ }
67
+ : undefined,
68
+ data: typeSchemas.request?.name
69
+ ? {
70
+ type: typeSchemas.request?.name,
71
+ optional: isOptional(typeSchemas.request?.schema),
72
+ }
73
+ : undefined,
74
+ params: typeSchemas.queryParams?.name
75
+ ? {
76
+ type: typeSchemas.queryParams?.name,
77
+ optional: isOptional(typeSchemas.queryParams?.schema),
78
+ }
79
+ : undefined,
80
+ headers: typeSchemas.headerParams?.name
81
+ ? {
82
+ type: typeSchemas.headerParams?.name,
83
+ optional: isOptional(typeSchemas.headerParams?.schema),
84
+ }
85
+ : undefined,
86
+ config: {
87
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
88
+ default: '{}',
89
+ },
90
+ })
91
+ }
92
+
93
+ export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType }: Props): ReactNode {
94
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
95
+ const clientParams = Client.getParams({
96
+ paramsType,
97
+ typeSchemas,
98
+ pathParamsType,
99
+ })
100
+
101
+ return (
102
+ <File.Source name={name} isExportable isIndexable>
103
+ <Function name={name} export params={params.toConstructor()}>
104
+ {`
105
+ return {
106
+ fetcher: async () => {
107
+ return ${clientName}(${clientParams.toCall()})
108
+ },
109
+ }
110
+ `}
111
+ </Function>
112
+ </File.Source>
113
+ )
114
+ }
115
+
116
+ QueryOptions.getParams = getParams
@@ -0,0 +1,5 @@
1
+ export { Mutation } from './Mutation.tsx'
2
+ export { Query } from './Query.tsx'
3
+ export { QueryOptions } from './QueryOptions.tsx'
4
+ export { QueryKey } from './QueryKey.tsx'
5
+ export { MutationKey } from './MutationKey.tsx'
@@ -0,0 +1,49 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import useSWR from "swr";
3
+ import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
4
+
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+
9
+ /**
10
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
+ * @summary Finds Pets by tags
12
+ * @link /pet/findByTags
13
+ */
14
+ async function findPetsByTags({ params }: {
15
+ params?: FindPetsByTagsQueryParams;
16
+ }, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
+ return res;
19
+ }
20
+
21
+ export function findPetsByTagsQueryOptions({ params }: {
22
+ params?: FindPetsByTagsQueryParams;
23
+ }, config: Partial<RequestConfig> = {}) {
24
+ return {
25
+ fetcher: async () => {
26
+ return findPetsByTags({ params }, config);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags({ params }: {
37
+ params?: FindPetsByTagsQueryParams;
38
+ }, options: {
39
+ query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
+ client?: Partial<RequestConfig>;
41
+ shouldFetch?: boolean;
42
+ } = {}) {
43
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
+ const queryKey = findPetsByTagsQueryKey(params);
45
+ return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
+ ...findPetsByTagsQueryOptions({ params }, config),
47
+ ...queryOptions
48
+ });
49
+ }
@@ -0,0 +1,49 @@
1
+ import client from "axios";
2
+ import useSWR from "swr";
3
+ import type { RequestConfig } from "axios";
4
+
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+
9
+ /**
10
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
+ * @summary Finds Pets by tags
12
+ * @link /pet/findByTags
13
+ */
14
+ async function findPetsByTags({ params }: {
15
+ params?: FindPetsByTagsQueryParams;
16
+ }, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
+ return res.data;
19
+ }
20
+
21
+ export function findPetsByTagsQueryOptions({ params }: {
22
+ params?: FindPetsByTagsQueryParams;
23
+ }, config: Partial<RequestConfig> = {}) {
24
+ return {
25
+ fetcher: async () => {
26
+ return findPetsByTags({ params }, config);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags({ params }: {
37
+ params?: FindPetsByTagsQueryParams;
38
+ }, options: {
39
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
+ client?: Partial<RequestConfig>;
41
+ shouldFetch?: boolean;
42
+ } = {}) {
43
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
+ const queryKey = findPetsByTagsQueryKey(params);
45
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
+ ...findPetsByTagsQueryOptions({ params }, config),
47
+ ...queryOptions
48
+ });
49
+ }
@@ -0,0 +1,32 @@
1
+ import client from "axios";
2
+ import useSWRMutation from "swr/mutation";
3
+ import type { RequestConfig } from "axios";
4
+
5
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+
7
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
8
+
9
+ /**
10
+ * @summary Updates a pet in the store with form data
11
+ * @link /pet/:petId
12
+ */
13
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: "POST", url: `/pet/${petId}`, params, ...config });
15
+ return res.data;
16
+ }
17
+
18
+ /**
19
+ * @summary Updates a pet in the store with form data
20
+ * @link /pet/:petId
21
+ */
22
+ export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, options: {
23
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2];
24
+ client?: Partial<RequestConfig>;
25
+ shouldFetch?: boolean;
26
+ } = {}) {
27
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {};
28
+ const mutationKey = updatePetWithFormMutationKey();
29
+ return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(shouldFetch ? mutationKey : null, async (_url) => {
30
+ return updatePetWithForm(petId, params, config);
31
+ }, mutationOptions);
32
+ }
@@ -0,0 +1,49 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import useSWR from "swr";
3
+ import type { RequestConfig } from "@kubb/plugin-client/client";
4
+
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+
9
+ /**
10
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
+ * @summary Finds Pets by tags
12
+ * @link /pet/findByTags
13
+ */
14
+ async function findPetsByTags({ params }: {
15
+ params?: FindPetsByTagsQueryParams;
16
+ }, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
+ return res.data;
19
+ }
20
+
21
+ export function findPetsByTagsQueryOptions({ params }: {
22
+ params?: FindPetsByTagsQueryParams;
23
+ }, config: Partial<RequestConfig> = {}) {
24
+ return {
25
+ fetcher: async () => {
26
+ return findPetsByTags({ params }, config);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags({ params }: {
37
+ params?: FindPetsByTagsQueryParams;
38
+ }, options: {
39
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
+ client?: Partial<RequestConfig>;
41
+ shouldFetch?: boolean;
42
+ } = {}) {
43
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
+ const queryKey = findPetsByTagsQueryKey(params);
45
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
+ ...findPetsByTagsQueryOptions({ params }, config),
47
+ ...queryOptions
48
+ });
49
+ }
@@ -0,0 +1,49 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import useSWR from "swr";
3
+ import type { RequestConfig } from "@kubb/plugin-client/client";
4
+
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+
9
+ /**
10
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
+ * @summary Finds Pets by tags
12
+ * @link /pet/findByTags
13
+ */
14
+ async function findPetsByTags({ params }: {
15
+ params?: FindPetsByTagsQueryParams;
16
+ }, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
+ return res.data;
19
+ }
20
+
21
+ export function findPetsByTagsQueryOptions({ params }: {
22
+ params?: FindPetsByTagsQueryParams;
23
+ }, config: Partial<RequestConfig> = {}) {
24
+ return {
25
+ fetcher: async () => {
26
+ return findPetsByTags({ params }, config);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags({ params }: {
37
+ params?: FindPetsByTagsQueryParams;
38
+ }, options: {
39
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
+ client?: Partial<RequestConfig>;
41
+ shouldFetch?: boolean;
42
+ } = {}) {
43
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
+ const queryKey = findPetsByTagsQueryKey(params);
45
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
+ ...findPetsByTagsQueryOptions({ params }, config),
47
+ ...queryOptions
48
+ });
49
+ }
@@ -0,0 +1,49 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import useSWR from "swr";
3
+ import type { RequestConfig } from "@kubb/plugin-client/client";
4
+
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+
9
+ /**
10
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
+ * @summary Finds Pets by tags
12
+ * @link /pet/findByTags
13
+ */
14
+ async function findPetsByTags({ params }: {
15
+ params?: FindPetsByTagsQueryParams;
16
+ }, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
+ return res.data;
19
+ }
20
+
21
+ export function findPetsByTagsQueryOptions({ params }: {
22
+ params?: FindPetsByTagsQueryParams;
23
+ }, config: Partial<RequestConfig> = {}) {
24
+ return {
25
+ fetcher: async () => {
26
+ return findPetsByTags({ params }, config);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags({ params }: {
37
+ params?: FindPetsByTagsQueryParams;
38
+ }, options: {
39
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
+ client?: Partial<RequestConfig>;
41
+ shouldFetch?: boolean;
42
+ } = {}) {
43
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
+ const queryKey = findPetsByTagsQueryKey(params);
45
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
+ ...findPetsByTagsQueryOptions({ params }, config),
47
+ ...queryOptions
48
+ });
49
+ }