@kubb/plugin-vue-query 5.0.0-beta.3 → 5.0.0-beta.30

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 (41) hide show
  1. package/README.md +26 -5
  2. package/dist/{components-D1UhYFgY.js → components-B4IlVmNa.js} +244 -353
  3. package/dist/components-B4IlVmNa.js.map +1 -0
  4. package/dist/{components-qfOFRSoM.cjs → components-CIedagno.cjs} +269 -354
  5. package/dist/components-CIedagno.cjs.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +3 -67
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-CbnIVBgY.js → generators-ClYptnDj.js} +144 -132
  10. package/dist/generators-ClYptnDj.js.map +1 -0
  11. package/dist/{generators-C4gs_P1i.cjs → generators-D7kNtBBo.cjs} +142 -130
  12. package/dist/generators-D7kNtBBo.cjs.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +17 -1
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +100 -17
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +29 -1
  19. package/dist/index.js +100 -17
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-D-LjzI_Q.d.ts +270 -0
  22. package/extension.yaml +1273 -0
  23. package/package.json +16 -18
  24. package/src/components/InfiniteQuery.tsx +11 -48
  25. package/src/components/InfiniteQueryOptions.tsx +38 -50
  26. package/src/components/Mutation.tsx +33 -42
  27. package/src/components/Query.tsx +11 -49
  28. package/src/components/QueryKey.tsx +8 -61
  29. package/src/components/QueryOptions.tsx +14 -67
  30. package/src/generators/infiniteQueryGenerator.tsx +46 -51
  31. package/src/generators/mutationGenerator.tsx +41 -49
  32. package/src/generators/queryGenerator.tsx +43 -49
  33. package/src/plugin.ts +43 -15
  34. package/src/resolvers/resolverVueQuery.ts +61 -4
  35. package/src/types.ts +129 -53
  36. package/src/utils.ts +44 -25
  37. package/dist/components-D1UhYFgY.js.map +0 -1
  38. package/dist/components-qfOFRSoM.cjs.map +0 -1
  39. package/dist/generators-C4gs_P1i.cjs.map +0 -1
  40. package/dist/generators-CbnIVBgY.js.map +0 -1
  41. package/dist/types-nVDTfuS1.d.ts +0 -194
package/extension.yaml ADDED
@@ -0,0 +1,1273 @@
1
+ $schema: https://kubb.dev/schemas/extension.json
2
+ kind: plugin
3
+ id: plugin-vue-query
4
+ name: Vue Query
5
+ description: Generate TanStack Query composables for Vue (useQuery, useMutation, useInfiniteQuery) from OpenAPI.
6
+ category: framework
7
+ type: official
8
+ npmPackage: '@kubb/plugin-vue-query'
9
+ docsPath: /plugins/plugin-vue-query
10
+ repo: https://github.com/kubb-labs/plugins
11
+ maintainers:
12
+ - name: Stijn Van Hulle
13
+ github: stijnvanhulle
14
+ compatibility:
15
+ kubb: '>=5.0.0'
16
+ node: '>=22'
17
+ tags:
18
+ - vue-query
19
+ - tanstack-query
20
+ - vue
21
+ - composables
22
+ - data-fetching
23
+ - codegen
24
+ - openapi
25
+ dependencies:
26
+ - plugin-ts
27
+ - plugin-client
28
+ resources:
29
+ documentation: https://kubb.dev/plugins/plugin-vue-query
30
+ repository: https://github.com/kubb-labs/plugins
31
+ issues: https://github.com/kubb-labs/plugins/issues
32
+ changelog: https://github.com/kubb-labs/plugins/blob/main/packages/plugin-vue-query/CHANGELOG.md
33
+ codesandbox: https://codesandbox.io/p/github/kubb-labs/plugins/main/examples/vue-query
34
+ featured: false
35
+ icon:
36
+ light: https://kubb.dev/feature/tanstack.svg
37
+ intro: |
38
+ # @kubb/plugin-vue-query
39
+
40
+ Generate one [TanStack Query](https://tanstack.com/query) composable per OpenAPI operation, ready to use inside Vue's Composition API. Queries become `useFooQuery` (and optionally `useFooInfiniteQuery`); mutations become `useFooMutation`. Each composable is fully typed end to end.
41
+
42
+ Pairs with `@kubb/plugin-client` for the HTTP layer and `@kubb/plugin-ts` for types.
43
+ options:
44
+ - name: output
45
+ type: Output
46
+ required: false
47
+ default: "{ path: 'hooks', barrel: { type: 'named' } }"
48
+ description: Where the generated composables are written and how they are exported.
49
+ properties:
50
+ - name: path
51
+ type: string
52
+ required: true
53
+ description: |
54
+ Folder (or single file) where the plugin writes its generated code. The path is resolved against the global `output.path` set on `defineConfig`.
55
+
56
+ Use a folder to keep each generator's output isolated (`'types'`, `'clients'`, `'hooks'`). Use a single file when you want everything in one place, for example `'api.ts'`.
57
+ tip: |
58
+ When `output.path` points to a single file, the `group` option cannot be used because every operation ends up in the same file.
59
+ examples:
60
+ - name: kubb.config.ts
61
+ files:
62
+ - lang: typescript
63
+ twoslash: false
64
+ code: |
65
+ import { defineConfig } from 'kubb'
66
+ import { pluginTs } from '@kubb/plugin-ts'
67
+
68
+ export default defineConfig({
69
+ input: { path: './petStore.yaml' },
70
+ output: { path: './src/gen' },
71
+ plugins: [
72
+ pluginTs({
73
+ output: { path: './types' },
74
+ }),
75
+ ],
76
+ })
77
+ - name: Resulting tree
78
+ files:
79
+ - lang: text
80
+ twoslash: false
81
+ code: |
82
+ src/
83
+ └── gen/
84
+ └── types/
85
+ ├── Pet.ts
86
+ └── Store.ts
87
+ default: "'hooks'"
88
+ - name: barrel
89
+ type: "{ type: 'named' | 'all', nested?: boolean } | false"
90
+ required: false
91
+ default: "{ type: 'named' }"
92
+ description: |
93
+ Controls how the generated `index.ts` (barrel) file re-exports the plugin's output.
94
+
95
+ - `{ type: 'named' }` re-exports each symbol by name. Best for tree-shaking and explicit imports.
96
+ - `{ type: 'all' }` uses `export *`. Smaller barrel file, but exports everything.
97
+ - `{ nested: true }` creates a barrel in every subdirectory, so callers can import from any depth.
98
+ - `false` skips the barrel entirely. The plugin's files are also excluded from the root `index.ts`.
99
+ tip: |
100
+ Pick `'named'` when consumers care about which symbols they import (better tree-shaking, friendlier auto-import). Pick `'all'` when the file count is small and you want a one-line barrel.
101
+ examples:
102
+ - name: "'named' (default)"
103
+ files:
104
+ - name: kubb.config.ts
105
+ lang: typescript
106
+ twoslash: false
107
+ code: |
108
+ import { defineConfig } from 'kubb'
109
+ import { pluginTs } from '@kubb/plugin-ts'
110
+
111
+ export default defineConfig({
112
+ input: { path: './petStore.yaml' },
113
+ output: { path: './src/gen' },
114
+ plugins: [
115
+ pluginTs({
116
+ output: { barrel: { type: 'named' } },
117
+ }),
118
+ ],
119
+ })
120
+ - name: src/gen/types/index.ts
121
+ lang: typescript
122
+ twoslash: false
123
+ code: |
124
+ export { Pet, PetStatus } from './Pet'
125
+ export { Store } from './Store'
126
+ - name: "'all'"
127
+ files:
128
+ - name: kubb.config.ts
129
+ lang: typescript
130
+ twoslash: false
131
+ code: |
132
+ import { defineConfig } from 'kubb'
133
+ import { pluginTs } from '@kubb/plugin-ts'
134
+
135
+ export default defineConfig({
136
+ input: { path: './petStore.yaml' },
137
+ output: { path: './src/gen' },
138
+ plugins: [
139
+ pluginTs({
140
+ output: { barrel: { type: 'all' } },
141
+ }),
142
+ ],
143
+ })
144
+ - name: src/gen/types/index.ts
145
+ lang: typescript
146
+ twoslash: false
147
+ code: |
148
+ export * from './Pet'
149
+ export * from './Store'
150
+ - name: nested
151
+ files:
152
+ - name: kubb.config.ts
153
+ lang: typescript
154
+ twoslash: false
155
+ code: |
156
+ import { defineConfig } from 'kubb'
157
+ import { pluginTs } from '@kubb/plugin-ts'
158
+
159
+ export default defineConfig({
160
+ input: { path: './petStore.yaml' },
161
+ output: { path: './src/gen' },
162
+ plugins: [
163
+ pluginTs({
164
+ output: { barrel: { type: 'named', nested: true } },
165
+ }),
166
+ ],
167
+ })
168
+ - name: Generated tree
169
+ lang: text
170
+ twoslash: false
171
+ code: |
172
+ src/gen/types/
173
+ ├── index.ts # re-exports ./petController and ./storeController
174
+ ├── petController/
175
+ │ ├── index.ts # re-exports Pet, Store, ...
176
+ │ └── Pet.ts
177
+ └── storeController/
178
+ ├── index.ts
179
+ └── Store.ts
180
+ - name: 'false'
181
+ files:
182
+ - name: kubb.config.ts
183
+ lang: typescript
184
+ twoslash: false
185
+ code: |
186
+ import { defineConfig } from 'kubb'
187
+ import { pluginTs } from '@kubb/plugin-ts'
188
+
189
+ export default defineConfig({
190
+ input: { path: './petStore.yaml' },
191
+ output: { path: './src/gen' },
192
+ plugins: [
193
+ pluginTs({
194
+ output: { barrel: false },
195
+ }),
196
+ ],
197
+ })
198
+ - name: Result
199
+ lang: text
200
+ twoslash: false
201
+ code: |
202
+ # No index.ts is generated for this plugin.
203
+ # Its files are also excluded from the root index.ts.
204
+ - name: banner
205
+ type: 'string | ((node: RootNode) => string)'
206
+ required: false
207
+ description: |
208
+ Text prepended to every generated file. Useful for license headers, lint disables, or `@ts-nocheck` directives.
209
+
210
+ Pass a string for a static banner. Pass a function to compute the banner from each file's `RootNode` (the AST root containing path, schema, and operation context).
211
+ examples:
212
+ - name: Static banner
213
+ files:
214
+ - name: kubb.config.ts
215
+ lang: typescript
216
+ twoslash: false
217
+ code: |
218
+ import { defineConfig } from 'kubb'
219
+ import { pluginTs } from '@kubb/plugin-ts'
220
+
221
+ export default defineConfig({
222
+ input: { path: './petStore.yaml' },
223
+ output: { path: './src/gen' },
224
+ plugins: [
225
+ pluginTs({
226
+ output: {
227
+ banner: '/* eslint-disable */\n// @ts-nocheck',
228
+ },
229
+ }),
230
+ ],
231
+ })
232
+ - name: Generated file
233
+ lang: typescript
234
+ twoslash: false
235
+ code: |
236
+ /* eslint-disable */
237
+ // @ts-nocheck
238
+ export type Pet = {
239
+ id: number
240
+ name: string
241
+ }
242
+ - name: Dynamic banner
243
+ files:
244
+ - name: kubb.config.ts
245
+ lang: typescript
246
+ twoslash: false
247
+ code: |
248
+ import { defineConfig } from 'kubb'
249
+ import { pluginTs } from '@kubb/plugin-ts'
250
+
251
+ export default defineConfig({
252
+ input: { path: './petStore.yaml' },
253
+ output: { path: './src/gen' },
254
+ plugins: [
255
+ pluginTs({
256
+ output: {
257
+ banner: (node) => `// Source: ${node.path}\n// Generated at ${new Date().toISOString()}`,
258
+ },
259
+ }),
260
+ ],
261
+ })
262
+ - name: footer
263
+ type: 'string | ((node: RootNode) => string)'
264
+ required: false
265
+ description: |
266
+ Text appended at the end of every generated file. The mirror of `banner` — use it for closing comments, re-enabling lint rules, or marker lines.
267
+
268
+ Pass a string for a static footer, or a function that receives the file's `RootNode` and returns the footer text.
269
+ examples:
270
+ - name: Re-enable lint after a banner disable
271
+ files:
272
+ - name: kubb.config.ts
273
+ lang: typescript
274
+ twoslash: false
275
+ code: |
276
+ import { defineConfig } from 'kubb'
277
+ import { pluginTs } from '@kubb/plugin-ts'
278
+
279
+ export default defineConfig({
280
+ input: { path: './petStore.yaml' },
281
+ output: { path: './src/gen' },
282
+ plugins: [
283
+ pluginTs({
284
+ output: {
285
+ banner: '/* eslint-disable */',
286
+ footer: '/* eslint-enable */',
287
+ },
288
+ }),
289
+ ],
290
+ })
291
+ - name: override
292
+ type: boolean
293
+ required: false
294
+ default: 'false'
295
+ description: |
296
+ Allows the plugin to overwrite hand-written files that share a name with a generated file.
297
+
298
+ - `false` (default): Kubb skips a file if it already exists and is not marked as generated. This protects manual edits.
299
+ - `true`: Kubb overwrites any file at the target path, including hand-written ones.
300
+ warning: |
301
+ Enable this only when you are sure the target folder contains nothing you need to keep. Local edits are lost on the next generation.
302
+ examples:
303
+ - name: kubb.config.ts
304
+ files:
305
+ - lang: typescript
306
+ twoslash: false
307
+ code: |
308
+ import { defineConfig } from 'kubb'
309
+ import { pluginTs } from '@kubb/plugin-ts'
310
+
311
+ export default defineConfig({
312
+ input: { path: './petStore.yaml' },
313
+ output: { path: './src/gen' },
314
+ plugins: [
315
+ pluginTs({
316
+ output: { override: true },
317
+ }),
318
+ ],
319
+ })
320
+ - name: contentType
321
+ type: "'application/json' | (string & {})"
322
+ required: false
323
+ description: |
324
+ Selects which request/response media type the generator reads from the OpenAPI spec.
325
+
326
+ When omitted, Kubb picks the first JSON-compatible media type it finds (`application/json`, `application/vnd.api+json`, anything ending in `+json`). Set this when your spec defines multiple media types for the same operation and you want a non-default one.
327
+ examples:
328
+ - name: JSON API media type
329
+ files:
330
+ - lang: typescript
331
+ twoslash: false
332
+ code: |
333
+ import { defineConfig } from 'kubb'
334
+ import { pluginTs } from '@kubb/plugin-ts'
335
+
336
+ export default defineConfig({
337
+ input: { path: './petStore.yaml' },
338
+ output: { path: './src/gen' },
339
+ plugins: [
340
+ pluginTs({
341
+ contentType: 'application/vnd.api+json',
342
+ }),
343
+ ],
344
+ })
345
+ - name: group
346
+ type: Group
347
+ required: false
348
+ description: |
349
+ Splits generated files into subfolders based on the operation's tag, so each tag in your OpenAPI spec gets its own directory.
350
+
351
+ Without `group`, every file lands in the plugin's `output.path` folder. With `group`, files are bucketed under `{output.path}/{groupName}/`, where `groupName` is derived from the operation's first tag.
352
+ tip: |
353
+ Use `group` to mirror your API's domain structure (pet, store, user) in the generated code. Combine it with `output.barrel: { type: 'named', nested: true }` to get per-tag barrel files.
354
+ examples:
355
+ - name: kubb.config.ts
356
+ files:
357
+ - lang: typescript
358
+ twoslash: false
359
+ code: |
360
+ import { defineConfig } from 'kubb'
361
+ import { pluginTs } from '@kubb/plugin-ts'
362
+
363
+ export default defineConfig({
364
+ input: { path: './petStore.yaml' },
365
+ output: { path: './src/gen' },
366
+ plugins: [
367
+ pluginTs({
368
+ group: {
369
+ type: 'tag',
370
+ name: ({ group }) => `${group}Controller`,
371
+ },
372
+ }),
373
+ ],
374
+ })
375
+ body: |
376
+ With the configuration above, the generator emits:
377
+
378
+ ```text
379
+ src/gen/
380
+ ├── petController/
381
+ │ ├── AddPet.ts
382
+ │ └── GetPet.ts
383
+ └── storeController/
384
+ ├── CreateStore.ts
385
+ └── GetStoreById.ts
386
+ ```
387
+ properties:
388
+ - name: type
389
+ type: "'tag'"
390
+ required: true
391
+ description: |
392
+ Property used to assign each operation to a group. Required whenever `group` is set.
393
+
394
+ Today only `'tag'` is supported: Kubb reads the first tag on the operation (`operation.getTags().at(0)?.name`) and uses it as the group key. Operations without a tag are placed in a default group.
395
+ note: |
396
+ `Required: true*` is conditional — only required when the parent `group` option is used. `group` itself stays optional.
397
+ - name: name
398
+ type: '(context: GroupContext) => string'
399
+ required: false
400
+ default: (ctx) => `${ctx.group}Controller`
401
+ description: Function that builds the folder/identifier name from a group key (the operation's first tag).
402
+ - name: client
403
+ type: ClientImportPath & { clientType?, dataReturnType?, baseURL?, bundle?, paramsCasing? }
404
+ required: false
405
+ description: |
406
+ HTTP client used inside every generated composable. Each composable calls into this client to perform the request.
407
+
408
+ Mirrors a subset of `pluginClient` options. Set these here when the Vue composables need different client behavior than the rest of your app.
409
+ properties:
410
+ - name: importPath
411
+ type: string
412
+ required: false
413
+ description: |
414
+ Path or module specifier of a custom client module. Generated code imports its HTTP runtime from here instead of `@kubb/plugin-client/clients/{client}`.
415
+
416
+ Use this when you need to inject auth headers, add interceptors, change the base URL at runtime, or wrap a different HTTP library (ky, ofetch, ...). Both relative paths (`./src/client.ts`) and bare specifiers (`@my-org/api-client`) work.
417
+ details:
418
+ - title: When to use `importPath`
419
+ body: |
420
+ Reach for a custom client when you need to:
421
+
422
+ - Add an auth token to every request.
423
+ - Plug in interceptors, retries, or logging.
424
+ - Configure `baseURL` and headers from environment variables.
425
+ - Wrap a library other than `axios`/`fetch`.
426
+ - title: Default behavior
427
+ body: |
428
+ Without `importPath`:
429
+
430
+ - `bundle: false` (default) — generated code imports from `@kubb/plugin-client/clients/{axios|fetch}`.
431
+ - `bundle: true` — Kubb writes `.kubb/client.ts` and generated code imports from there.
432
+ - title: Required exports
433
+ body: |
434
+ The module pointed to by `importPath` must satisfy the same shape as the built-in client. At minimum:
435
+
436
+ - A default export of the `client` function.
437
+ - A `RequestConfig` type.
438
+ - A `ResponseErrorConfig` type.
439
+
440
+ When used together with a query plugin (`@kubb/plugin-react-query`, `@kubb/plugin-vue-query`), it must also export a `Client` type alias.
441
+ - title: How generated files import it
442
+ body: |
443
+ Generated code imports the client as a default import (bound to the local name `client`) and the runtime types as named type imports:
444
+ codeBlock:
445
+ lang: typescript
446
+ code: |
447
+ import client from '${client.importPath}'
448
+ import type { RequestConfig, ResponseErrorConfig } from '${client.importPath}'
449
+ // ... rest of the generated file
450
+ important: |
451
+ When used with query plugins (`@kubb/plugin-react-query`, `@kubb/plugin-vue-query`), generated hooks also import a `Client` type alias. Your module **must** export `Client`, `RequestConfig`, and `ResponseErrorConfig` — TypeScript will fail the import otherwise.
452
+ codeBlock:
453
+ lang: typescript
454
+ title: src/client.ts
455
+ code: |
456
+ import axios from 'axios'
457
+
458
+ export type RequestConfig<TData = unknown> = {
459
+ url?: string
460
+ method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE'
461
+ params?: object
462
+ data?: TData | FormData
463
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
464
+ signal?: AbortSignal
465
+ headers?: HeadersInit
466
+ }
467
+
468
+ export type ResponseConfig<TData = unknown> = {
469
+ data: TData
470
+ status: number
471
+ statusText: string
472
+ }
473
+
474
+ export type ResponseErrorConfig<TError = unknown> = TError
475
+
476
+ // Required when used with @kubb/plugin-react-query or @kubb/plugin-vue-query
477
+ export type Client = <TData, _TError = unknown, TVariables = unknown>(
478
+ config: RequestConfig<TVariables>,
479
+ ) => Promise<ResponseConfig<TData>>
480
+
481
+ const client: Client = async (config) => {
482
+ const response = await axios.request<TData>({
483
+ ...config,
484
+ headers: {
485
+ Authorization: `Bearer ${process.env.API_TOKEN}`,
486
+ ...config.headers,
487
+ },
488
+ })
489
+
490
+ return response
491
+ }
492
+
493
+ export default client
494
+ examples:
495
+ - name: Wire up a custom client
496
+ files:
497
+ - name: kubb.config.ts
498
+ lang: typescript
499
+ twoslash: false
500
+ code: |
501
+ import { defineConfig } from 'kubb'
502
+ import { pluginClient } from '@kubb/plugin-client'
503
+
504
+ export default defineConfig({
505
+ input: { path: './petStore.yaml' },
506
+ output: { path: './src/gen' },
507
+ plugins: [
508
+ pluginClient({
509
+ importPath: './src/client.ts',
510
+ }),
511
+ ],
512
+ })
513
+ tip: |
514
+ See the [custom client guide](https://kubb.dev/plugins/plugin-client#importpath) for a worked example.
515
+ - name: dataReturnType
516
+ type: "'data' | 'full'"
517
+ required: false
518
+ default: "'data'"
519
+ description: |
520
+ Shape of the value returned from each generated client function.
521
+
522
+ - `'data'` returns only the response body (`response.data`). Concise and matches what most apps need.
523
+ - `'full'` returns the full response config — body, status code, headers, and the original request. Use this when callers need to inspect headers or status.
524
+ examples:
525
+ - name: "'data' (default)"
526
+ files:
527
+ - name: getPetById.ts
528
+ lang: typescript
529
+ twoslash: false
530
+ code: |
531
+ export async function getPetById<TData>(
532
+ petId: GetPetByIdPathParams,
533
+ ): Promise<ResponseConfig<TData>['data']> {
534
+ // ...
535
+ }
536
+ - name: usage.ts
537
+ lang: typescript
538
+ twoslash: false
539
+ code: |
540
+ const pet = await getPetById(1)
541
+ // ^? Pet
542
+ - name: "'full'"
543
+ files:
544
+ - name: getPetById.ts
545
+ lang: typescript
546
+ twoslash: false
547
+ code: |
548
+ export async function getPetById<TData>(
549
+ petId: GetPetByIdPathParams,
550
+ ): Promise<ResponseConfig<TData>> {
551
+ // ...
552
+ }
553
+ - name: usage.ts
554
+ lang: typescript
555
+ twoslash: false
556
+ code: |
557
+ const response = await getPetById(1)
558
+ // ^? ResponseConfig<Pet>
559
+ console.log(response.status, response.headers)
560
+ const pet = response.data
561
+ - name: baseURL
562
+ type: string
563
+ required: false
564
+ description: |
565
+ Base URL prepended to every request URL in the generated client. When omitted, the URL comes from the OpenAPI spec's `servers[0].url` (or whichever index the adapter is configured to read).
566
+
567
+ Set this when the generated client should point at a different environment (staging, production) than the one written in the spec.
568
+ examples:
569
+ - name: Override the spec's server URL
570
+ files:
571
+ - lang: typescript
572
+ twoslash: false
573
+ code: |
574
+ import { defineConfig } from 'kubb'
575
+ import { pluginClient } from '@kubb/plugin-client'
576
+
577
+ export default defineConfig({
578
+ input: { path: './petStore.yaml' },
579
+ output: { path: './src/gen' },
580
+ plugins: [
581
+ pluginClient({
582
+ baseURL: 'https://petstore.swagger.io/v2',
583
+ }),
584
+ ],
585
+ })
586
+ - name: clientType
587
+ type: "'function' | 'class'"
588
+ required: false
589
+ default: "'function'"
590
+ description: |
591
+ Style of the HTTP client that this plugin imports from `@kubb/plugin-client`.
592
+
593
+ - `'function'` — imports the function client (`getPetById(...)`). Required for query plugins.
594
+ - `'class'` — also generates a wrapper class on top, but only usable inside `@kubb/plugin-client`.
595
+ warning: |
596
+ Query plugins (`@kubb/plugin-react-query`, `@kubb/plugin-vue-query`, `@kubb/plugin-svelte-query`, `@kubb/plugin-solid-query`) work only with `clientType: 'function'`. If you set `clientType: 'class'` here, the plugin falls back to generating its own inline function-based client instead of importing from `@kubb/plugin-client`.
597
+ - name: bundle
598
+ type: boolean
599
+ required: false
600
+ default: 'false'
601
+ description: |
602
+ Copies the HTTP client runtime into the generated output, so the consuming app does not need `@kubb/plugin-client` installed at runtime.
603
+
604
+ - `false` (default) — generated files import from `@kubb/plugin-client/clients/{client}`. Smaller diff, but the package must be a runtime dependency.
605
+ - `true` — Kubb writes a `.kubb/client.ts` file with the client implementation. Generated code imports from that local file and the project no longer pulls `@kubb/plugin-client` at runtime.
606
+ - Setting `client.importPath` overrides both behaviors and uses your custom client instead.
607
+ examples:
608
+ - name: Bundle the runtime
609
+ files:
610
+ - lang: typescript
611
+ twoslash: false
612
+ code: |
613
+ import { defineConfig } from 'kubb'
614
+ import { pluginClient } from '@kubb/plugin-client'
615
+
616
+ export default defineConfig({
617
+ input: { path: './petStore.yaml' },
618
+ output: { path: './src/gen' },
619
+ plugins: [
620
+ pluginClient({
621
+ client: 'fetch',
622
+ bundle: true,
623
+ }),
624
+ ],
625
+ })
626
+ - name: paramsType
627
+ type: "'object' | 'inline'"
628
+ required: false
629
+ default: "'inline'"
630
+ description: |
631
+ How operation parameters (path, query, headers) are exposed in the generated function signature.
632
+
633
+ - `'inline'` (default) — each parameter is a separate positional argument. Compact for operations with one or two params.
634
+ - `'object'` — every parameter is wrapped in a single object argument. Easier to read for operations with many params and named at the call site.
635
+ tip: |
636
+ Setting `paramsType: 'object'` implicitly sets `pathParamsType: 'object'` as well, so call sites are consistent.
637
+ examples:
638
+ - name: "'inline' (default)"
639
+ files:
640
+ - name: Generated client
641
+ lang: typescript
642
+ twoslash: false
643
+ code: |
644
+ export async function deletePet(
645
+ petId: DeletePetPathParams['petId'],
646
+ headers?: DeletePetHeaderParams,
647
+ config: Partial<RequestConfig> = {},
648
+ ) {
649
+ // ...
650
+ }
651
+ - name: Caller
652
+ lang: typescript
653
+ twoslash: false
654
+ code: |
655
+ await deletePet(42)
656
+ - name: "'object'"
657
+ files:
658
+ - name: Generated client
659
+ lang: typescript
660
+ twoslash: false
661
+ code: |
662
+ export async function deletePet(
663
+ {
664
+ petId,
665
+ headers,
666
+ }: {
667
+ petId: DeletePetPathParams['petId']
668
+ headers?: DeletePetHeaderParams
669
+ },
670
+ config: Partial<RequestConfig> = {},
671
+ ) {
672
+ // ...
673
+ }
674
+ - name: Caller
675
+ lang: typescript
676
+ twoslash: false
677
+ code: |
678
+ await deletePet({ petId: 42, headers: { 'X-Api-Key': 'secret' } })
679
+ - name: paramsCasing
680
+ type: "'camelcase'"
681
+ required: false
682
+ description: |
683
+ Renames path, query, and header parameters in the generated client to the chosen casing. The HTTP request still uses the original names from the OpenAPI spec — Kubb writes the mapping for you.
684
+
685
+ - `'camelcase'` — turn `pet_id` and `X-Api-Key` into `petId` and `xApiKey` in your TypeScript code. The runtime URL still uses `/pet/{pet_id}` and the header is still sent as `X-Api-Key`.
686
+ important: |
687
+ Set the same `paramsCasing` on every plugin that touches operation parameters (`@kubb/plugin-ts`, `@kubb/plugin-client`, `@kubb/plugin-react-query`, `@kubb/plugin-faker`, `@kubb/plugin-mcp`). Mismatched casing causes type errors between generated layers.
688
+ examples:
689
+ - name: "With paramsCasing: 'camelcase'"
690
+ files:
691
+ - name: Generated client
692
+ lang: typescript
693
+ twoslash: false
694
+ code: |
695
+ // Function takes camelCase parameters
696
+ export async function deletePet(
697
+ petId: DeletePetPathParams['petId'],
698
+ headers?: DeletePetHeaderParams,
699
+ config: Partial<RequestConfig> = {},
700
+ ) {
701
+ // ...mapped back to the original API name internally
702
+ const pet_id = petId
703
+
704
+ return client({
705
+ method: 'DELETE',
706
+ url: `/pet/${pet_id}`,
707
+ ...config,
708
+ })
709
+ }
710
+ - name: Caller
711
+ lang: typescript
712
+ twoslash: false
713
+ code: |
714
+ await deletePet(42)
715
+ - name: Without paramsCasing
716
+ files:
717
+ - name: Generated client
718
+ lang: typescript
719
+ twoslash: false
720
+ code: |
721
+ // Function parameters mirror the OpenAPI spec
722
+ export async function deletePet(
723
+ pet_id: DeletePetPathParams['pet_id'],
724
+ headers?: DeletePetHeaderParams,
725
+ config: Partial<RequestConfig> = {},
726
+ ) {
727
+ return client({
728
+ method: 'DELETE',
729
+ url: `/pet/${pet_id}`,
730
+ ...config,
731
+ })
732
+ }
733
+ tip: |
734
+ Callers write friendly camelCase names. The generated client maps them back to whatever the API expects (snake_case path params, kebab-case headers, ...).
735
+ - name: pathParamsType
736
+ type: "'object' | 'inline'"
737
+ required: false
738
+ default: "'inline'"
739
+ description: |
740
+ How URL path parameters appear in the generated function signature. Affects only path params; query/header params follow `paramsType`.
741
+
742
+ - `'inline'` (default) — each path param is a positional argument: `getPetById(petId)`.
743
+ - `'object'` — path params are wrapped in a single object: `getPetById({ petId })`.
744
+ examples:
745
+ - name: "'inline' (default)"
746
+ files:
747
+ - lang: typescript
748
+ twoslash: false
749
+ code: |
750
+ export async function getPetById(
751
+ petId: GetPetByIdPathParams,
752
+ ) {
753
+ // ...
754
+ }
755
+ - name: "'object'"
756
+ files:
757
+ - lang: typescript
758
+ twoslash: false
759
+ code: |
760
+ export async function getPetById(
761
+ { petId }: GetPetByIdPathParams,
762
+ ) {
763
+ // ...
764
+ }
765
+ - name: parser
766
+ type: "'client' | 'zod'"
767
+ required: false
768
+ default: "'client'"
769
+ description: |
770
+ Runtime validator applied to the response body before it is returned to the caller.
771
+
772
+ - `'client'` (default) — no validation. The response is cast to the generated TypeScript type and returned as-is. Fastest path, trusts the API.
773
+ - `'zod'` — pipes the response through the Zod schema produced by `@kubb/plugin-zod`. Catches mismatches between spec and API at runtime, at the cost of a parse on every call.
774
+
775
+ Use `'zod'` when you want a defensive boundary against drift between your OpenAPI spec and the live API. Requires `@kubb/plugin-zod` in the plugins list.
776
+ examples:
777
+ - name: Validate responses with Zod
778
+ files:
779
+ - lang: typescript
780
+ twoslash: false
781
+ code: |
782
+ import { defineConfig } from 'kubb'
783
+ import { pluginClient } from '@kubb/plugin-client'
784
+ import { pluginTs } from '@kubb/plugin-ts'
785
+ import { pluginZod } from '@kubb/plugin-zod'
786
+
787
+ export default defineConfig({
788
+ input: { path: './petStore.yaml' },
789
+ output: { path: './src/gen' },
790
+ plugins: [
791
+ pluginTs(),
792
+ pluginZod(),
793
+ pluginClient({
794
+ parser: 'zod',
795
+ }),
796
+ ],
797
+ })
798
+ - name: infinite
799
+ type: Infinite | false
800
+ required: false
801
+ default: 'false'
802
+ description: |
803
+ Enables `useInfiniteQuery` composables for cursor- or page-based pagination. Pass an object to configure how the cursor is read from the response; pass `false` (default) to skip.
804
+ typeDefinition: |
805
+ type Infinite = {
806
+ /** Query-param key used as the page cursor. Defaults to `'id'`. */
807
+ queryParam: string
808
+ /** @deprecated Use `nextParam` / `previousParam` instead. */
809
+ cursorParam?: string
810
+ /** Path to the next-page cursor in the response. Dot or array form. */
811
+ nextParam?: string | string[]
812
+ /** Path to the previous-page cursor in the response. Dot or array form. */
813
+ previousParam?: string | string[]
814
+ /** Value of `pageParam` for the first page. Defaults to `0`. */
815
+ initialPageParam: unknown
816
+ } | false
817
+ properties:
818
+ - name: queryParam
819
+ type: string
820
+ required: false
821
+ default: "'id'"
822
+ description: Name of the query parameter that holds the page cursor.
823
+ - name: initialPageParam
824
+ type: unknown
825
+ required: false
826
+ default: '0'
827
+ description: Initial value for `pageParam` on the first fetch.
828
+ - name: cursorParam
829
+ type: string | undefined
830
+ required: false
831
+ deprecated:
832
+ note: '`cursorParam` is deprecated. Use `nextParam` and `previousParam` for richer pagination control.'
833
+ description: Path to the cursor field on the response. Leave undefined when the cursor is not known.
834
+ - name: nextParam
835
+ type: string | string[] | undefined
836
+ required: false
837
+ description: |
838
+ Path to the next-page cursor on the response. Supports dot notation (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
839
+ - name: previousParam
840
+ type: string | string[] | undefined
841
+ required: false
842
+ description: |
843
+ Path to the previous-page cursor on the response. Supports dot notation (`'pagination.prev.id'`) or array form.
844
+ - name: queryKey
845
+ type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
846
+ required: false
847
+ description: |
848
+ Builds the `queryKey` for each generated composable. Use this to add a version namespace, swap to operation IDs, or shape keys to match an existing invalidation strategy.
849
+
850
+ The callback receives the OpenAPI `operation` and a `schemas` object containing `pathParams`, `queryParams`, `request`, and `response`.
851
+ warning: |
852
+ String values are inlined verbatim into generated code. Wrap any literal string in `JSON.stringify(...)`.
853
+ details:
854
+ - title: Keys from tags and path parameters
855
+ body: "Build a key from the operation's first tag plus its path parameters:"
856
+ codeBlock:
857
+ - lang: typescript
858
+ code: |-
859
+ import { defineConfig } from 'kubb'
860
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
861
+
862
+ export default defineConfig({
863
+ input: { path: './petStore.yaml' },
864
+ output: { path: './src/gen' },
865
+ plugins: [
866
+ pluginVueQuery({
867
+ queryKey: ({ operation, schemas }) => {
868
+ const tags = operation.getTags().map((tag) => JSON.stringify(tag.name))
869
+ const pathParams = schemas.pathParams?.keys ?? []
870
+ return [...tags, ...pathParams]
871
+ },
872
+ }),
873
+ ],
874
+ })
875
+ - lang: typescript
876
+ code: |-
877
+ export const getUserByNameQueryKey = ({ username }: { username: GetUserByNamePathParams['username'] }) =>
878
+ ['user', username] as const
879
+ - title: Extend the default transformer
880
+ body: 'Prepend a version prefix to the default query key:'
881
+ codeBlock:
882
+ - lang: typescript
883
+ code: |-
884
+ import { defineConfig } from 'kubb'
885
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
886
+ import { QueryKey } from '@kubb/plugin-vue-query/components'
887
+
888
+ export default defineConfig({
889
+ input: { path: './petStore.yaml' },
890
+ output: { path: './src/gen' },
891
+ plugins: [
892
+ pluginVueQuery({
893
+ queryKey: (props) => {
894
+ const defaultKeys = QueryKey.getTransformer(props)
895
+ return [JSON.stringify('v5'), ...defaultKeys]
896
+ },
897
+ }),
898
+ ],
899
+ })
900
+ - lang: typescript
901
+ code: |-
902
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) =>
903
+ ['v5', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
904
+ - title: Key from operationId
905
+ codeBlock:
906
+ lang: typescript
907
+ code: |-
908
+ import { defineConfig } from 'kubb'
909
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
910
+
911
+ export default defineConfig({
912
+ input: { path: './petStore.yaml' },
913
+ output: { path: './src/gen' },
914
+ plugins: [
915
+ pluginVueQuery({
916
+ queryKey: ({ operation }) => [JSON.stringify(operation.getOperationId())],
917
+ }),
918
+ ],
919
+ })
920
+ - title: Conditional keys based on params
921
+ codeBlock:
922
+ lang: typescript
923
+ code: |-
924
+ import { defineConfig } from 'kubb'
925
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
926
+
927
+ export default defineConfig({
928
+ input: { path: './petStore.yaml' },
929
+ output: { path: './src/gen' },
930
+ plugins: [
931
+ pluginVueQuery({
932
+ queryKey: ({ operation, schemas }) => {
933
+ const keys: unknown[] = [JSON.stringify(operation.getOperationId())]
934
+
935
+ if (schemas.pathParams?.keys) {
936
+ keys.push(...schemas.pathParams.keys)
937
+ }
938
+
939
+ if (schemas.queryParams?.name) {
940
+ keys.push('...(params ? [params] : [])')
941
+ }
942
+
943
+ return keys
944
+ },
945
+ }),
946
+ ],
947
+ })
948
+ - name: query
949
+ type: Query
950
+ required: false
951
+ description: |
952
+ Configures the query composables. Pass `false` to skip composable generation and emit only `queryOptions(...)` helpers.
953
+ typeDefinition: |
954
+ type Query = {
955
+ methods: Array<HttpMethod>
956
+ importPath?: string
957
+ } | false
958
+ properties:
959
+ - name: methods
960
+ type: Array<HttpMethod>
961
+ required: false
962
+ default: "['get']"
963
+ description: |
964
+ HTTP methods treated as queries. Operations using one of these methods generate a `useQuery`-style hook (or `queryOptions` helper) instead of a mutation.
965
+
966
+ Defaults to `['get']`. Add other methods (for example `'head'`) only when your API uses them for cache-friendly reads.
967
+ examples:
968
+ - name: Allow HEAD as a query method
969
+ files:
970
+ - lang: typescript
971
+ twoslash: false
972
+ code: |
973
+ import { defineConfig } from 'kubb'
974
+ import { pluginReactQuery } from '@kubb/plugin-react-query'
975
+
976
+ export default defineConfig({
977
+ input: { path: './petStore.yaml' },
978
+ output: { path: './src/gen' },
979
+ plugins: [
980
+ pluginReactQuery({
981
+ query: { methods: ['get', 'head'] },
982
+ }),
983
+ ],
984
+ })
985
+ - name: importPath
986
+ type: string
987
+ required: false
988
+ default: "'@tanstack/vue-query'"
989
+ description: |
990
+ Module specifier used in the `import { useQuery } from '...'` statement at the top of every generated composable file. Useful for routing through your own wrapper.
991
+ - name: mutation
992
+ type: Mutation
993
+ required: false
994
+ description: |
995
+ Configures mutation composables. Set to `false` to skip mutation generation.
996
+ typeDefinition: |
997
+ type Mutation = {
998
+ methods: Array<HttpMethod>
999
+ importPath?: string
1000
+ } | false
1001
+ properties:
1002
+ - name: methods
1003
+ type: Array<HttpMethod>
1004
+ required: false
1005
+ default: "['post', 'put', 'delete']"
1006
+ description: |
1007
+ HTTP methods treated as mutations. Operations using one of these methods generate a `useMutation`-style hook instead of a query.
1008
+
1009
+ Defaults to `['post', 'put', 'delete']`. Add `'patch'` if your API uses it for partial updates.
1010
+ examples:
1011
+ - name: Include PATCH as a mutation
1012
+ files:
1013
+ - lang: typescript
1014
+ twoslash: false
1015
+ code: |
1016
+ import { defineConfig } from 'kubb'
1017
+ import { pluginReactQuery } from '@kubb/plugin-react-query'
1018
+
1019
+ export default defineConfig({
1020
+ input: { path: './petStore.yaml' },
1021
+ output: { path: './src/gen' },
1022
+ plugins: [
1023
+ pluginReactQuery({
1024
+ mutation: { methods: ['post', 'put', 'patch', 'delete'] },
1025
+ }),
1026
+ ],
1027
+ })
1028
+ - name: importPath
1029
+ type: string
1030
+ required: false
1031
+ default: "'@tanstack/vue-query'"
1032
+ description: |
1033
+ Module specifier used in the `import { useMutation } from '...'` statement at the top of every generated composable file.
1034
+ - name: mutationKey
1035
+ type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
1036
+ required: false
1037
+ description: |
1038
+ Builds the `mutationKey` for each mutation composable. Useful when you batch invalidations or read mutation state via `useMutationState`.
1039
+ warning: |
1040
+ String values are inlined verbatim into generated code. Wrap any literal string in `JSON.stringify(...)`.
1041
+ - name: include
1042
+ type: Array<Include>
1043
+ required: false
1044
+ description: |
1045
+ Restricts generation to operations that match at least one entry in the list. Anything not matched is skipped.
1046
+
1047
+ Each entry filters by one of:
1048
+
1049
+ - `tag` — the operation's first tag in the OpenAPI spec.
1050
+ - `operationId` — the operation's `operationId`.
1051
+ - `path` — the URL pattern (`'/pet/{petId}'`).
1052
+ - `method` — HTTP method (`'get'`, `'post'`, ...).
1053
+ - `contentType` — the media type of the request body.
1054
+
1055
+ `pattern` accepts either a string (exact match) or a `RegExp` for fuzzy matches.
1056
+ codeBlock:
1057
+ lang: typescript
1058
+ title: Type definition
1059
+ code: |
1060
+ export type Include = {
1061
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
1062
+ pattern: string | RegExp
1063
+ }
1064
+ examples:
1065
+ - name: Only the pet tag
1066
+ files:
1067
+ - name: kubb.config.ts
1068
+ lang: typescript
1069
+ twoslash: false
1070
+ code: |
1071
+ import { defineConfig } from 'kubb'
1072
+ import { pluginTs } from '@kubb/plugin-ts'
1073
+
1074
+ export default defineConfig({
1075
+ input: { path: './petStore.yaml' },
1076
+ output: { path: './src/gen' },
1077
+ plugins: [
1078
+ pluginTs({
1079
+ include: [
1080
+ { type: 'tag', pattern: 'pet' },
1081
+ ],
1082
+ }),
1083
+ ],
1084
+ })
1085
+ - name: Only GET operations under /pet
1086
+ files:
1087
+ - name: kubb.config.ts
1088
+ lang: typescript
1089
+ twoslash: false
1090
+ code: |
1091
+ import { defineConfig } from 'kubb'
1092
+ import { pluginTs } from '@kubb/plugin-ts'
1093
+
1094
+ export default defineConfig({
1095
+ input: { path: './petStore.yaml' },
1096
+ output: { path: './src/gen' },
1097
+ plugins: [
1098
+ pluginTs({
1099
+ include: [
1100
+ { type: 'method', pattern: 'get' },
1101
+ { type: 'path', pattern: /^\/pet/ },
1102
+ ],
1103
+ }),
1104
+ ],
1105
+ })
1106
+ - name: exclude
1107
+ type: Array<Exclude>
1108
+ required: false
1109
+ description: |
1110
+ Skips any operation that matches at least one entry in the list. The opposite of `include`.
1111
+
1112
+ Each entry filters by one of:
1113
+
1114
+ - `tag` — the operation's first tag.
1115
+ - `operationId` — the operation's `operationId`.
1116
+ - `path` — the URL pattern (`'/pet/{petId}'`).
1117
+ - `method` — HTTP method (`'get'`, `'post'`, ...).
1118
+ - `contentType` — the media type of the request body.
1119
+
1120
+ `pattern` accepts a plain string or a `RegExp`. When both `include` and `exclude` are set, `exclude` wins.
1121
+ codeBlock:
1122
+ lang: typescript
1123
+ title: Type definition
1124
+ code: |
1125
+ export type Exclude = {
1126
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
1127
+ pattern: string | RegExp
1128
+ }
1129
+ examples:
1130
+ - name: Skip everything under the store tag
1131
+ files:
1132
+ - name: kubb.config.ts
1133
+ lang: typescript
1134
+ twoslash: false
1135
+ code: |
1136
+ import { defineConfig } from 'kubb'
1137
+ import { pluginTs } from '@kubb/plugin-ts'
1138
+
1139
+ export default defineConfig({
1140
+ input: { path: './petStore.yaml' },
1141
+ output: { path: './src/gen' },
1142
+ plugins: [
1143
+ pluginTs({
1144
+ exclude: [
1145
+ { type: 'tag', pattern: 'store' },
1146
+ ],
1147
+ }),
1148
+ ],
1149
+ })
1150
+ - name: Skip a specific operation and all delete methods
1151
+ files:
1152
+ - name: kubb.config.ts
1153
+ lang: typescript
1154
+ twoslash: false
1155
+ code: |
1156
+ import { defineConfig } from 'kubb'
1157
+ import { pluginTs } from '@kubb/plugin-ts'
1158
+
1159
+ export default defineConfig({
1160
+ input: { path: './petStore.yaml' },
1161
+ output: { path: './src/gen' },
1162
+ plugins: [
1163
+ pluginTs({
1164
+ exclude: [
1165
+ { type: 'operationId', pattern: 'deletePet' },
1166
+ { type: 'method', pattern: 'delete' },
1167
+ ],
1168
+ }),
1169
+ ],
1170
+ })
1171
+ - name: override
1172
+ type: Array<Override>
1173
+ required: false
1174
+ description: |
1175
+ Applies a different set of plugin options to operations that match a pattern. Use this when most of your API should follow the global config, but a handful of endpoints need different treatment.
1176
+
1177
+ Each entry has the same `type` and `pattern` shape as `include`/`exclude`, plus an `options` object that overrides the plugin's options for matched operations.
1178
+
1179
+ Entries are evaluated top to bottom. The first matching entry's `options` is merged onto the plugin defaults; later entries do not stack.
1180
+ codeBlock:
1181
+ lang: typescript
1182
+ title: Type definition
1183
+ code: |
1184
+ export type Override = {
1185
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
1186
+ pattern: string | RegExp
1187
+ options: PluginOptions
1188
+ }
1189
+ examples:
1190
+ - name: Use a different enum style for the user tag
1191
+ files:
1192
+ - name: kubb.config.ts
1193
+ lang: typescript
1194
+ twoslash: false
1195
+ code: |
1196
+ import { defineConfig } from 'kubb'
1197
+ import { pluginTs } from '@kubb/plugin-ts'
1198
+
1199
+ export default defineConfig({
1200
+ input: { path: './petStore.yaml' },
1201
+ output: { path: './src/gen' },
1202
+ plugins: [
1203
+ pluginTs({
1204
+ enumType: 'asConst',
1205
+ override: [
1206
+ {
1207
+ type: 'tag',
1208
+ pattern: 'user',
1209
+ options: { enumType: 'literal' },
1210
+ },
1211
+ ],
1212
+ }),
1213
+ ],
1214
+ })
1215
+ - name: generators
1216
+ type: Array<Generator<PluginVueQuery>>
1217
+ required: false
1218
+ experimental: true
1219
+ description: |
1220
+ Adds custom generators that run alongside the plugin's built-in generators. Each generator can emit additional files or post-process existing ones using the plugin's AST and options.
1221
+
1222
+ Use this when you need output the plugin does not produce out of the box (a custom client wrapper, an extra index, a metadata file). For end-to-end guidance, see [Creating plugins](https://kubb.dev/docs/5.x/guides/creating-plugins).
1223
+ warning: |
1224
+ Generators are an experimental, low-level API. The signature may change between minor releases.
1225
+ - name: resolver
1226
+ type: Partial<ResolverVueQuery>
1227
+ required: false
1228
+ description: |
1229
+ Overrides naming and path resolution for the generated composables. Supply only the methods you want to change; everything else falls back to the default resolver.
1230
+ - name: transformer
1231
+ type: ast.Visitor
1232
+ required: false
1233
+ description: |
1234
+ AST visitor applied to operation nodes before code is printed. Use this to rewrite operation IDs, tags, or descriptions across the entire output.
1235
+ notes:
1236
+ - type: tip
1237
+ body: |
1238
+ Reference: [TanStack Query for Vue](https://tanstack.com/query/latest/docs/framework/vue/overview) for cache, retries, and devtools.
1239
+ examples:
1240
+ - name: kubb.config.ts
1241
+ files:
1242
+ - lang: typescript
1243
+ twoslash: false
1244
+ code: |
1245
+ import { defineConfig } from 'kubb'
1246
+ import { pluginTs } from '@kubb/plugin-ts'
1247
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
1248
+
1249
+ export default defineConfig({
1250
+ input: { path: './petStore.yaml' },
1251
+ output: { path: './src/gen' },
1252
+ plugins: [
1253
+ pluginTs(),
1254
+ pluginVueQuery({
1255
+ output: { path: './hooks' },
1256
+ group: {
1257
+ type: 'tag',
1258
+ name: ({ group }) => `${group}Hooks`,
1259
+ },
1260
+ client: { dataReturnType: 'full' },
1261
+ mutation: { methods: ['post', 'put', 'delete'] },
1262
+ infinite: {
1263
+ queryParam: 'next_page',
1264
+ initialPageParam: 0,
1265
+ nextParam: 'pagination.next.cursor',
1266
+ },
1267
+ query: {
1268
+ methods: ['get'],
1269
+ importPath: '@tanstack/vue-query',
1270
+ },
1271
+ }),
1272
+ ],
1273
+ })