Build a URL without sending
The bundled client, written under output, exposes getUrl to build an operation's final URL without sending the request, useful for cache keys, prefetch, and links.
typescript
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginFetch } from '@kubb/plugin-fetch'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen', clean: true },
plugins: [
pluginTs(),
pluginFetch(),
],
})Output example
typescript
import { client } from './src/gen/.kubb/client'
import { getPetById } from './src/gen/clients/getPetById'
const cacheKey = client.getUrl({ url: '/pet/{petId}', path: { petId: 1 } })
const cached = cache.get(cacheKey)
if (!cached) {
const { data } = await getPetById({ path: { petId: 1 } })
cache.set(cacheKey, data)
}