@kubb/plugin-client
Version:
API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.
34 lines (30 loc) • 1.03 kB
text/typescript
/* eslint-disable no-alert, no-console */
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
import { fetch } from './test/.kubb/fetch'
export function getDeletePetUrl({ petId }: { petId: DeletePetPathParams['petId'] }) {
const res = { method: 'DELETE', url: `/pet/${petId}` as const }
return res
}
/**
* @description delete a pet
* @summary Deletes a pet
* {@link /pet/:petId}
*/
export async function deletePet(
{ petId }: { petId: DeletePetPathParams['petId'] },
headers?: DeletePetHeaderParams,
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
) {
const { client: request = fetch, ...requestConfig } = config
const res = await request<DeletePetMutationResponse, ResponseErrorConfig<DeletePet400>, unknown>({
method: 'DELETE',
url: getDeletePetUrl({ petId }).url.toString(),
...requestConfig,
headers: { ...headers, ...requestConfig.headers },
})
return res.data
}