@kubb/plugin-swr 4.29.1 → 4.31.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.
Files changed (30) hide show
  1. package/dist/components.d.ts +4 -3
  2. package/dist/generators.cjs +1 -1
  3. package/dist/generators.d.ts +4 -3
  4. package/dist/generators.js +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.js +1 -1
  8. package/dist/{queryGenerator-CEsWWhOe.js → queryGenerator-96wr4Uxr.js} +5 -5
  9. package/dist/queryGenerator-96wr4Uxr.js.map +1 -0
  10. package/dist/{queryGenerator-CfKDvnGS.cjs → queryGenerator-Dn8pnjT4.cjs} +5 -5
  11. package/dist/queryGenerator-Dn8pnjT4.cjs.map +1 -0
  12. package/package.json +11 -10
  13. package/src/generators/mutationGenerator.tsx +4 -2
  14. package/src/generators/queryGenerator.tsx +4 -2
  15. package/dist/queryGenerator-CEsWWhOe.js.map +0 -1
  16. package/dist/queryGenerator-CfKDvnGS.cjs.map +0 -1
  17. package/dist/types-wR9RZTnh.d.ts +0 -144
  18. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +0 -70
  19. package/src/generators/__snapshots__/clientGetImportPath.ts +0 -67
  20. package/src/generators/__snapshots__/clientPostImportPath.ts +0 -62
  21. package/src/generators/__snapshots__/findByTags.ts +0 -67
  22. package/src/generators/__snapshots__/findByTagsObject.ts +0 -67
  23. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +0 -67
  24. package/src/generators/__snapshots__/findByTagsTemplateString.ts +0 -68
  25. package/src/generators/__snapshots__/findByTagsWithZod.ts +0 -67
  26. package/src/generators/__snapshots__/getAsMutation.ts +0 -34
  27. package/src/generators/__snapshots__/postAsQuery.ts +0 -72
  28. package/src/generators/__snapshots__/updatePetById.ts +0 -62
  29. package/src/generators/__snapshots__/updatePetByIdParamsToTrigger.ts +0 -67
  30. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +0 -62
@@ -1,70 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, RequestConfig, ResponseErrorConfig, ResponseConfig } 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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return res
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(
57
- shouldFetch ? queryKey : null,
58
- {
59
- ...findPetsByTagsQueryOptions({ params }, config),
60
- ...(immutable
61
- ? {
62
- revalidateIfStale: false,
63
- revalidateOnFocus: false,
64
- revalidateOnReconnect: false,
65
- }
66
- : {}),
67
- ...queryOptions,
68
- },
69
- )
70
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import fetch from 'axios'
6
- import useSWR from 'swr'
7
- import type { Client, RequestConfig, ResponseErrorConfig } from 'axios'
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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return res.data
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
57
- ...findPetsByTagsQueryOptions({ params }, config),
58
- ...(immutable
59
- ? {
60
- revalidateIfStale: false,
61
- revalidateOnFocus: false,
62
- revalidateOnReconnect: false,
63
- }
64
- : {}),
65
- ...queryOptions,
66
- })
67
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import fetch from 'axios'
6
- import useSWRMutation from 'swr/mutation'
7
- import type { Client, RequestConfig, ResponseErrorConfig } from 'axios'
8
- import type { SWRMutationConfiguration } from 'swr/mutation'
9
-
10
- export const updatePetWithFormMutationKey = () => [{ url: '/pet/:petId' }] as const
11
-
12
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
13
-
14
- /**
15
- * @summary Updates a pet in the store with form data
16
- * {@link /pet/:petId}
17
- */
18
- export async function updatePetWithForm(
19
- petId: UpdatePetWithFormPathParams['petId'],
20
- params?: UpdatePetWithFormQueryParams,
21
- config: Partial<RequestConfig> & { client?: Client } = {},
22
- ) {
23
- const { client: request = fetch, ...requestConfig } = config
24
-
25
- const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
26
- method: 'POST',
27
- url: `/pet/${petId}`,
28
- params,
29
- ...requestConfig,
30
- })
31
- return res.data
32
- }
33
-
34
- /**
35
- * @summary Updates a pet in the store with form data
36
- * {@link /pet/:petId}
37
- */
38
- export function useUpdatePetWithForm(
39
- petId: UpdatePetWithFormPathParams['petId'],
40
- params?: UpdatePetWithFormQueryParams,
41
- options: {
42
- mutation?: SWRMutationConfiguration<
43
- UpdatePetWithFormMutationResponse,
44
- ResponseErrorConfig<UpdatePetWithForm405>,
45
- UpdatePetWithFormMutationKey | null,
46
- never
47
- > & { throwOnError?: boolean }
48
- client?: Partial<RequestConfig> & { client?: Client }
49
- shouldFetch?: boolean
50
- } = {},
51
- ) {
52
- const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
53
- const mutationKey = updatePetWithFormMutationKey()
54
-
55
- return useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey | null>(
56
- shouldFetch ? mutationKey : null,
57
- async (_url) => {
58
- return updatePetWithForm(petId, params, config)
59
- },
60
- mutationOptions,
61
- )
62
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, 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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return res.data
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
57
- ...findPetsByTagsQueryOptions({ params }, config),
58
- ...(immutable
59
- ? {
60
- revalidateIfStale: false,
61
- revalidateOnFocus: false,
62
- revalidateOnReconnect: false,
63
- }
64
- : {}),
65
- ...queryOptions,
66
- })
67
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, 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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return res.data
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
57
- ...findPetsByTagsQueryOptions({ params }, config),
58
- ...(immutable
59
- ? {
60
- revalidateIfStale: false,
61
- revalidateOnFocus: false,
62
- revalidateOnReconnect: false,
63
- }
64
- : {}),
65
- ...queryOptions,
66
- })
67
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, 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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return res.data
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
57
- ...findPetsByTagsQueryOptions({ params }, config),
58
- ...(immutable
59
- ? {
60
- revalidateIfStale: false,
61
- revalidateOnFocus: false,
62
- revalidateOnReconnect: false,
63
- }
64
- : {}),
65
- ...queryOptions,
66
- })
67
- }
@@ -1,68 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, 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?: Client } = {}) {
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({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
32
- return {
33
- fetcher: async () => {
34
- return findPetsByTags({ params }, config)
35
- },
36
- }
37
- }
38
-
39
- /**
40
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
41
- * @summary Finds Pets by tags
42
- * {@link /pet/findByTags}
43
- */
44
- export function useFindPetsByTags(
45
- { params }: { params?: FindPetsByTagsQueryParams } = {},
46
- options: {
47
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
48
- client?: Partial<RequestConfig> & { client?: Client }
49
- shouldFetch?: boolean
50
- immutable?: boolean
51
- } = {},
52
- ) {
53
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
54
-
55
- const queryKey = findPetsByTagsQueryKey(params)
56
-
57
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
58
- ...findPetsByTagsQueryOptions({ params }, config),
59
- ...(immutable
60
- ? {
61
- revalidateIfStale: false,
62
- revalidateOnFocus: false,
63
- revalidateOnReconnect: false,
64
- }
65
- : {}),
66
- ...queryOptions,
67
- })
68
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'swr'
6
- import type { Client, 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?: Client } = {}) {
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
- params,
25
- ...requestConfig,
26
- })
27
- return findPetsByTagsQueryResponse.parse(res.data)
28
- }
29
-
30
- export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: Client } = {}) {
31
- return {
32
- fetcher: async () => {
33
- return findPetsByTags({ params }, config)
34
- },
35
- }
36
- }
37
-
38
- /**
39
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
- * @summary Finds Pets by tags
41
- * {@link /pet/findByTags}
42
- */
43
- export function useFindPetsByTags(
44
- { params }: { params?: FindPetsByTagsQueryParams } = {},
45
- options: {
46
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>>>[2]
47
- client?: Partial<RequestConfig> & { client?: Client }
48
- shouldFetch?: boolean
49
- immutable?: boolean
50
- } = {},
51
- ) {
52
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
53
-
54
- const queryKey = findPetsByTagsQueryKey(params)
55
-
56
- return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
57
- ...findPetsByTagsQueryOptions({ params }, config),
58
- ...(immutable
59
- ? {
60
- revalidateIfStale: false,
61
- revalidateOnFocus: false,
62
- revalidateOnReconnect: false,
63
- }
64
- : {}),
65
- ...queryOptions,
66
- })
67
- }
@@ -1,34 +0,0 @@
1
- import client from "@kubb/plugin-client/clients/axios";
2
- import useSWRMutation from "custom-swr/mutation";
3
- import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
4
-
5
- export const findPetsByTagsMutationKey = () => [{ "url": "/pet/findByTags" }] as const;
6
-
7
- export type FindPetsByTagsMutationKey = ReturnType<typeof findPetsByTagsMutationKey>;
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?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
16
- return res.data;
17
- }
18
-
19
- /**
20
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
21
- * @summary Finds Pets by tags
22
- * @link /pet/findByTags
23
- */
24
- export function useFindPetsByTags(params?: FindPetsByTagsQueryParams, options: {
25
- mutation?: Parameters<typeof useSWRMutation<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsMutationKey>>[2];
26
- client?: Partial<RequestConfig>;
27
- shouldFetch?: boolean;
28
- } = {}) {
29
- const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {};
30
- const mutationKey = findPetsByTagsMutationKey();
31
- return useSWRMutation<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsMutationKey | null>(shouldFetch ? mutationKey : null, async (_url) => {
32
- return findPetsByTags(params, config);
33
- }, mutationOptions);
34
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import useSWR from 'custom-swr'
6
- import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
- import { fetch } from './test/.kubb/fetch'
8
-
9
- export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams) =>
10
- [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : [])] as const
11
-
12
- export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
13
-
14
- /**
15
- * @summary Updates a pet in the store with form data
16
- * {@link /pet/:petId}
17
- */
18
- export async function updatePetWithForm(
19
- { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
20
- config: Partial<RequestConfig> & { client?: Client } = {},
21
- ) {
22
- const { client: request = fetch, ...requestConfig } = config
23
-
24
- const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
25
- method: 'POST',
26
- url: `/pet/${petId}`,
27
- params,
28
- ...requestConfig,
29
- })
30
- return res.data
31
- }
32
-
33
- export function updatePetWithFormQueryOptions(
34
- { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
35
- config: Partial<RequestConfig> & { client?: Client } = {},
36
- ) {
37
- return {
38
- fetcher: async () => {
39
- return updatePetWithForm({ petId, params }, config)
40
- },
41
- }
42
- }
43
-
44
- /**
45
- * @summary Updates a pet in the store with form data
46
- * {@link /pet/:petId}
47
- */
48
- export function useUpdatePetWithForm(
49
- { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
50
- options: {
51
- query?: Parameters<typeof useSWR<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>>>[2]
52
- client?: Partial<RequestConfig> & { client?: Client }
53
- shouldFetch?: boolean
54
- immutable?: boolean
55
- } = {},
56
- ) {
57
- const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}
58
-
59
- const queryKey = updatePetWithFormQueryKey(petId, params)
60
-
61
- return useSWR<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormQueryKey | null>(shouldFetch ? queryKey : null, {
62
- ...updatePetWithFormQueryOptions({ petId, params }, config),
63
- ...(immutable
64
- ? {
65
- revalidateIfStale: false,
66
- revalidateOnFocus: false,
67
- revalidateOnReconnect: false,
68
- }
69
- : {}),
70
- ...queryOptions,
71
- })
72
- }