@kubb/plugin-react-query
Version:
React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.
32 lines (30 loc) • 1.03 kB
text/typescript
import client from '@kubb/plugin-client/clients/axios'
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
import type { UseMutationOptions } from 'custom-swr/mutation'
import { useMutation } from 'custom-swr/mutation'
/**
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @summary Finds Pets by tags
* @link /pet/findByTags
*/
export function findPetsByTags(
options: {
mutation?: UseMutationOptions<
FindPetsByTagsQueryResponse,
FindPetsByTags400,
{
headers: FindPetsByTagsHeaderParams
params?: FindPetsByTagsQueryParams
}
>
client?: Partial<RequestConfig>
} = {},
) {
const { mutation: mutationOptions, client: config = {} } = options ?? {}
return useMutation({
mutationFn: async ({ headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams }) => {
return findPetsByTags(headers, params, config)
},
...mutationOptions,
})
}