@kubb/plugin-swr 4.12.0 → 4.12.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-swr",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.2",
|
|
4
4
|
"description": "SWR hooks generator plugin for Kubb, creating type-safe data fetching hooks from OpenAPI specifications for React and Next.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swr",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@kubb/react-fabric": "0.7.0",
|
|
74
74
|
"remeda": "^2.32.0",
|
|
75
|
-
"@kubb/core": "4.12.
|
|
76
|
-
"@kubb/oas": "4.12.
|
|
77
|
-
"@kubb/plugin-client": "4.12.
|
|
78
|
-
"@kubb/plugin-oas": "4.12.
|
|
79
|
-
"@kubb/plugin-ts": "4.12.
|
|
80
|
-
"@kubb/plugin-zod": "4.12.
|
|
75
|
+
"@kubb/core": "4.12.2",
|
|
76
|
+
"@kubb/oas": "4.12.2",
|
|
77
|
+
"@kubb/plugin-client": "4.12.2",
|
|
78
|
+
"@kubb/plugin-oas": "4.12.2",
|
|
79
|
+
"@kubb/plugin-ts": "4.12.2",
|
|
80
|
+
"@kubb/plugin-zod": "4.12.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@kubb/react-fabric": "0.7.0"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import useSWR from 'swr'
|
|
6
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
|
|
9
|
+
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
10
|
+
|
|
11
|
+
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
15
|
+
* @summary Finds Pets by tags
|
|
16
|
+
* {@link /pet/findByTags}
|
|
17
|
+
*/
|
|
18
|
+
export async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {
|
|
19
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
20
|
+
|
|
21
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
|
+
method: 'GET',
|
|
23
|
+
url: `/pet/findByTags`,
|
|
24
|
+
baseURL: `${123456}`,
|
|
25
|
+
params,
|
|
26
|
+
...requestConfig,
|
|
27
|
+
})
|
|
28
|
+
return res.data
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function findPetsByTagsQueryOptions(
|
|
32
|
+
{ params }: { params?: FindPetsByTagsQueryParams },
|
|
33
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
34
|
+
) {
|
|
35
|
+
return {
|
|
36
|
+
fetcher: async () => {
|
|
37
|
+
return findPetsByTags({ params }, config)
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
44
|
+
* @summary Finds Pets by tags
|
|
45
|
+
* {@link /pet/findByTags}
|
|
46
|
+
*/
|
|
47
|
+
export function useFindPetsByTags(
|
|
48
|
+
{ params }: { params?: FindPetsByTagsQueryParams },
|
|
49
|
+
options: {
|
|
50
|
+
query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
|
|
51
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
52
|
+
shouldFetch?: boolean
|
|
53
|
+
immutable?: boolean
|
|
54
|
+
} = {},
|
|
55
|
+
) {
|
|
56
|
+
const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
|
|
57
|
+
|
|
58
|
+
const queryKey = findPetsByTagsQueryKey(params)
|
|
59
|
+
|
|
60
|
+
return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
|
|
61
|
+
...findPetsByTagsQueryOptions({ params }, config),
|
|
62
|
+
...(immutable
|
|
63
|
+
? {
|
|
64
|
+
revalidateIfStale: false,
|
|
65
|
+
revalidateOnFocus: false,
|
|
66
|
+
revalidateOnReconnect: false,
|
|
67
|
+
}
|
|
68
|
+
: {}),
|
|
69
|
+
...queryOptions,
|
|
70
|
+
})
|
|
71
|
+
}
|