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

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 (2) hide show
  1. package/extension.yaml +793 -0
  2. package/package.json +8 -8
package/extension.yaml ADDED
@@ -0,0 +1,793 @@
1
+ $schema: https://kubb.dev/schemas/extension.json
2
+ kind: plugin
3
+ id: plugin-vue-query
4
+ name: Vue Query
5
+ description: Generate Vue Query composables from OpenAPI specifications.
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 type-safe Vue Query composables from your OpenAPI schema for data fetching, caching, and synchronization.
41
+ options:
42
+ - name: output
43
+ type: Output
44
+ required: false
45
+ default: "{ path: 'hooks', barrelType: 'named' }"
46
+ description: Specify the export location for the files and define the behavior of the output.
47
+ properties:
48
+ - name: path
49
+ type: string
50
+ required: true
51
+ description: Output directory or file for the generated code, relative to the global `output.path`.
52
+ tip: |
53
+ if `output.path` is a file, `group` cannot be used.
54
+ default: "'hooks'"
55
+ - name: barrelType
56
+ type: "'all' | 'named' | 'propagate' | false"
57
+ required: false
58
+ default: "'named'"
59
+ description: Specify what to export and optionally disable barrel-file generation.
60
+ tip: |
61
+ Using `propagate` will prevent a plugin from creating a barrel file, but it will still propagate, allowing [`output.barrelType`](https://kubb.dev/docs/5.x/configuration#output-barreltype) to export the specific function or type.
62
+ examples:
63
+ - name: all
64
+ files:
65
+ - lang: typescript
66
+ code: |
67
+ export * from './gen/petService.ts'
68
+ twoslash: false
69
+ - name: named
70
+ files:
71
+ - lang: typescript
72
+ code: |
73
+ export { PetService } from './gen/petService.ts'
74
+ twoslash: false
75
+ - name: propagate
76
+ files:
77
+ - lang: typescript
78
+ code: ""
79
+ twoslash: false
80
+ - name: "false"
81
+ files:
82
+ - lang: typescript
83
+ code: ""
84
+ twoslash: false
85
+ - name: banner
86
+ type: "string | ((node: RootNode) => string)"
87
+ required: false
88
+ description: Add a banner comment at the top of every generated file. Accepts a static string or a function that receives the `RootNode` and returns a string.
89
+ - name: footer
90
+ type: "string | ((node: RootNode) => string)"
91
+ required: false
92
+ description: Add a footer comment at the end of every generated file. Accepts a static string or a function that receives the `RootNode` and returns a string.
93
+ - name: override
94
+ type: boolean
95
+ required: false
96
+ default: "false"
97
+ description: Whether Kubb overrides existing external files that can be generated if they already exist.
98
+ - name: contentType
99
+ type: "'application/json' | (string & {})"
100
+ required: false
101
+ description: |
102
+ Define which content type to use.
103
+
104
+ By default, Kubb uses the first JSON-valid media type.
105
+ - name: group
106
+ type: Group
107
+ required: false
108
+ description: |
109
+ Grouping combines files in a folder based on a specific `type`.
110
+ examples:
111
+ - name: kubb.config.ts
112
+ files:
113
+ - lang: typescript
114
+ code: |
115
+ group: {
116
+ type: 'tag',
117
+ name({ group }) {
118
+ return `${group}Controller`
119
+ }
120
+ }
121
+ twoslash: false
122
+ body: |
123
+ With the configuration above, the generator emits:
124
+
125
+ ```text
126
+ .
127
+ ├── src/
128
+ │ └── petController/
129
+ │ │ ├── addPet.ts
130
+ │ │ └── getPet.ts
131
+ │ └── storeController/
132
+ │ ├── createStore.ts
133
+ │ └── getStoreById.ts
134
+ ├── petStore.yaml
135
+ ├── kubb.config.ts
136
+ └── package.json
137
+ ```
138
+ properties:
139
+ - name: type
140
+ type: "'tag'"
141
+ required: true
142
+ description: Specify the property to group files by. Required when `group` is defined.
143
+ note: |
144
+ `Required: true*` means this is required only when the `group` option is used. The `group` option itself is optional.
145
+ body: |
146
+ - `'tag'`: Uses the first tag from `operation.getTags().at(0)?.name`
147
+ - name: name
148
+ type: "(context: GroupContext) => string"
149
+ required: false
150
+ default: (ctx) => `${ctx.group}Controller`
151
+ description: Return the name of a group based on the group name. This is used for file and identifier generation.
152
+ - name: client
153
+ type: ClientImportPath & { clientType?, dataReturnType?, baseURL?, bundle?, paramsCasing? }
154
+ required: false
155
+ description: Client configuration for HTTP request generation.
156
+ properties:
157
+ - name: importPath
158
+ type: string
159
+ required: false
160
+ description: Path to the client used for API calls. Supports both relative and absolute paths.
161
+ details:
162
+ - title: When to use `importPath`
163
+ body: |
164
+ Use `importPath` when you want to:
165
+
166
+ - **Customize the HTTP client**: Provide your own client implementation with custom configurations (e.g., baseURL, headers, interceptors)
167
+ - **Add authentication**: Include authentication tokens or other security mechanisms in your client
168
+ - **Override default behavior**: Replace the default Kubb client with your own implementation
169
+ - title: Default behavior
170
+ body: |
171
+ When `importPath` is not specified:
172
+
173
+ - If `bundle: false` (default): Uses `@kubb/plugin-client/clients/${client}` where client is either `axios` or `fetch`.
174
+ - If `bundle: true`: Bundles the client into `.kubb/fetch.ts`.
175
+ - title: Import structure
176
+ body: "Generated code imports the client as a default import and the runtime types as named type imports:"
177
+ codeBlock:
178
+ lang: typescript
179
+ code: |-
180
+ /**
181
+ * Generated by Kubb (https://kubb.dev/).
182
+ * Do not edit manually.
183
+ */
184
+ import client from '${client.importPath}'
185
+ import type { RequestConfig, ResponseErrorConfig } from '${client.importPath}'
186
+ // ... rest of generated file
187
+ important: |
188
+ When using `importPath` with query plugins such as `@kubb/plugin-react-query` or `@kubb/plugin-vue-query`, the generated hooks also import a `Client` type alongside `RequestConfig` and `ResponseErrorConfig` from the custom module. Your custom client module **must** export all three types — if any is missing, TypeScript will report an unresolvable import error.
189
+ codeBlock:
190
+ lang: typescript
191
+ title: client.ts
192
+ code: |
193
+ export type RequestConfig<TData = unknown> = {
194
+ url?: string
195
+ method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE'
196
+ params?: object
197
+ data?: TData | FormData
198
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
199
+ signal?: AbortSignal
200
+ headers?: HeadersInit
201
+ }
202
+
203
+ export type ResponseConfig<TData = unknown> = {
204
+ data: TData
205
+ status: number
206
+ statusText: string
207
+ }
208
+
209
+ export type ResponseErrorConfig<TError = unknown> = TError
210
+
211
+ // The Client type alias is required when using query plugins
212
+ export type Client = <TData, _TError = unknown, TVariables = unknown>(
213
+ config: RequestConfig<TVariables>
214
+ ) => Promise<ResponseConfig<TData>>
215
+
216
+ export const client: Client = async (config) => { /* ... */ }
217
+ export default client
218
+ examples:
219
+ - name: kubb.config.ts
220
+ files:
221
+ - lang: typescript
222
+ code: |
223
+ import { defineConfig } from 'kubb'
224
+ import { pluginClient } from '@kubb/plugin-client'
225
+
226
+ export default defineConfig({
227
+ // ...
228
+ plugins: [
229
+ pluginClient({
230
+ importPath: './src/client.ts', // Path to your custom client
231
+ }),
232
+ ],
233
+ })
234
+ twoslash: false
235
+ tip: |
236
+ Learn more about defining a custom client [here](https://kubb.dev/plugins/plugin-client#importpath).
237
+ - name: dataReturnType
238
+ type: "'data' | 'full'"
239
+ required: false
240
+ default: "'data'"
241
+ description: |
242
+ Return type used when calling the client.
243
+
244
+ - `'data'` returns `ResponseConfig['data']`.
245
+ - `'full'` returns the full `ResponseConfig`.
246
+ examples:
247
+ - name: data
248
+ files:
249
+ - lang: typescript
250
+ code: |
251
+ export async function getPetById<TData>(
252
+ petId: GetPetByIdPathParams,
253
+ ): Promise<ResponseConfig<TData>['data']> {
254
+ ...
255
+ }
256
+ twoslash: false
257
+ - name: full
258
+ files:
259
+ - lang: typescript
260
+ code: |
261
+ export async function getPetById<TData>(
262
+ petId: GetPetByIdPathParams,
263
+ ): Promise<ResponseConfig<TData>> {
264
+ ...
265
+ }
266
+ twoslash: false
267
+ - name: baseURL
268
+ type: string
269
+ required: false
270
+ description: Sets a custom base URL for all generated calls. When not set, the base URL is automatically taken from the OAS spec via the adapter (e.g. the `servers[0].url` field).
271
+ - name: clientType
272
+ type: "'function' | 'class'"
273
+ required: false
274
+ default: "'function'"
275
+ description: Specify whether to use function-based or class-based clients.
276
+ warning: |
277
+ This plugin is only compatible with `clientType: 'function'` (the default). If `clientType: 'class'` is detected, the plugin will automatically generate its own inline function-based client instead of importing from `@kubb/plugin-client`.
278
+ - name: bundle
279
+ type: boolean
280
+ required: false
281
+ default: "false"
282
+ description: Controls whether the HTTP client runtime is copied into the generated `.kubb` directory.
283
+ body: |
284
+ - `true` adds a `.kubb/fetch.ts` file containing the selected client template (fetch or axios). Generated clients remain self-contained.
285
+ - `false` keeps generated clients slim by importing the shared runtime from `@kubb/plugin-client/clients/{client}`.
286
+ - Override this behavior by providing a custom `client.importPath`.
287
+ - name: paramsType
288
+ type: "'object' | 'inline'"
289
+ required: false
290
+ default: "'inline'"
291
+ description: Defines how parameters are passed to generated functions. Switch between object-style parameters and inline parameters.
292
+ tip: |
293
+ When `paramsType` is set to `'object'`, `pathParams` will also be set to `'object'`.
294
+ body: |
295
+ - `'object'` returns params and pathParams as an object.
296
+ - `'inline'` returns params as comma-separated params.
297
+ examples:
298
+ - name: object
299
+ files:
300
+ - lang: typescript
301
+ code: |
302
+ export async function deletePet(
303
+ {
304
+ petId,
305
+ headers,
306
+ }: {
307
+ petId: DeletePetPathParams['petId']
308
+ headers?: DeletePetHeaderParams
309
+ },
310
+ config: Partial<RequestConfig> = {},
311
+ ) {
312
+ ...
313
+ }
314
+ twoslash: false
315
+ - name: inline
316
+ files:
317
+ - lang: typescript
318
+ code: |
319
+ export async function deletePet(
320
+ petId: DeletePetPathParams['petId'],
321
+ headers?: DeletePetHeaderParams,
322
+ config: Partial<RequestConfig> = {}
323
+ ){
324
+ ...
325
+ }
326
+ twoslash: false
327
+ - name: paramsCasing
328
+ type: "'camelcase'"
329
+ required: false
330
+ description: Transform parameter names to a specific casing format for path, query, and header parameters in generated client code.
331
+ important: |
332
+ When using `paramsCasing`, ensure that `@kubb/plugin-ts` also has the same `paramsCasing` setting. This option automatically maps transformed parameter names back to their original API names in HTTP requests.
333
+ body: |
334
+ - `'camelcase'` transforms parameter names to camelCase.
335
+ examples:
336
+ - name: With paramsCasing camelcase
337
+ files:
338
+ - lang: typescript
339
+ code: |
340
+ // Function parameters use camelCase
341
+ export async function deletePet(
342
+ petId: DeletePetPathParams['petId'], // ✓ camelCase
343
+ headers?: DeletePetHeaderParams,
344
+ config: Partial<RequestConfig> = {}
345
+ ) {
346
+ // Automatically maps back to original name for the API
347
+ const pet_id = petId
348
+
349
+ return fetch({
350
+ method: 'DELETE',
351
+ url: `/pet/${pet_id}`, // Uses original API parameter name
352
+ ...
353
+ })
354
+ }
355
+ twoslash: false
356
+ - name: Without paramsCasing
357
+ files:
358
+ - lang: typescript
359
+ code: |
360
+ // Parameters use original API naming
361
+ export async function deletePet(
362
+ pet_id: DeletePetPathParams['pet_id'], // Original naming
363
+ headers?: DeletePetHeaderParams,
364
+ config: Partial<RequestConfig> = {}
365
+ ) {
366
+ return fetch({
367
+ method: 'DELETE',
368
+ url: `/pet/${pet_id}`,
369
+ ...
370
+ })
371
+ }
372
+ twoslash: false
373
+ tip: |
374
+ The client automatically generates mapping code to convert camelCase parameter names back to the original API format. You write code with developer-friendly camelCase names, but HTTP requests use the exact parameter names from your OpenAPI specification.
375
+ - name: pathParamsType
376
+ type: "'object' | 'inline'"
377
+ required: false
378
+ default: "'inline'"
379
+ description: Defines how pathParams are passed to generated functions.
380
+ body: |
381
+ - `'object'` returns pathParams as an object.
382
+ - `'inline'` returns pathParams as comma-separated params.
383
+ examples:
384
+ - name: object
385
+ files:
386
+ - lang: typescript
387
+ code: |
388
+ export async function getPetById(
389
+ { petId }: GetPetByIdPathParams,
390
+ ) {
391
+ ...
392
+ }
393
+ twoslash: false
394
+ - name: inline
395
+ files:
396
+ - lang: typescript
397
+ code: |
398
+ export async function getPetById(
399
+ petId: GetPetByIdPathParams,
400
+ ) {
401
+ ...
402
+ }
403
+ twoslash: false
404
+ - name: parser
405
+ type: "'client' | 'zod'"
406
+ required: false
407
+ default: "'client'"
408
+ description: Parser used before returning data.
409
+ body: |
410
+ - `'zod'` uses `@kubb/plugin-zod` to parse data.
411
+ - `'client'` returns data without parsing.
412
+ - name: infinite
413
+ type: Infinite | false
414
+ required: false
415
+ default: "false"
416
+ description: |
417
+ Generate an `infiniteQuery` composable for paginated queries. Pass `false` to disable.
418
+ typeDefinition: |
419
+ type Infinite = {
420
+ /**
421
+ * Specify the params key used for `pageParam`.
422
+ * @default `'id'`
423
+ */
424
+ queryParam: string
425
+ /**
426
+ * Which field of the data will be used, set it to undefined when no cursor is known.
427
+ * @deprecated Use `nextParam` and `previousParam` instead for more flexible pagination handling.
428
+ */
429
+ cursorParam?: string | undefined
430
+ /**
431
+ * Which field of the data will be used to get the cursor for the next page.
432
+ * Supports dot notation (e.g. 'pagination.next.id') or array path (e.g. ['pagination', 'next', 'id']) to access nested fields.
433
+ */
434
+ nextParam?: string | string[] | undefined
435
+ /**
436
+ * Which field of the data will be used to get the cursor for the previous page.
437
+ * Supports dot notation (e.g. 'pagination.prev.id') or array path (e.g. ['pagination', 'prev', 'id']) to access nested fields.
438
+ */
439
+ previousParam?: string | string[] | undefined
440
+ /**
441
+ * The initial value, the value of the first page.
442
+ * @default `0`
443
+ */
444
+ initialPageParam: unknown
445
+ } | false
446
+ properties:
447
+ - name: queryParam
448
+ type: string
449
+ required: false
450
+ default: "'id'"
451
+ description: Specify the params key used for `pageParam`.
452
+ - name: initialPageParam
453
+ type: unknown
454
+ required: false
455
+ default: "0"
456
+ description: Specify the initial page param value.
457
+ - name: cursorParam
458
+ type: string | undefined
459
+ required: false
460
+ deprecated:
461
+ note: "`cursorParam` is deprecated. Use `nextParam` and `previousParam` instead for more flexible pagination handling."
462
+ description: Which field of the data will be used, set it to undefined when no cursor is known.
463
+ - name: nextParam
464
+ type: string | string[] | undefined
465
+ required: false
466
+ description: |
467
+ Which field of the data will be used to get the cursor for the next page.
468
+
469
+ Supports dot notation (e.g. `'pagination.next.id'`) or array path (e.g. `['pagination', 'next', 'id']`) to access nested fields.
470
+ - name: previousParam
471
+ type: string | string[] | undefined
472
+ required: false
473
+ description: |
474
+ Which field of the data will be used to get the cursor for the previous page.
475
+
476
+ Supports dot notation (e.g. `'pagination.prev.id'`) or array path (e.g. `['pagination', 'prev', 'id']`) to access nested fields.
477
+ - name: queryKey
478
+ type: "(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]"
479
+ required: false
480
+ description: |
481
+ Customize the queryKey that will be used for the query.
482
+
483
+ The function receives an object with:
484
+ - `operation`: The OpenAPI operation object with methods like `getTags()`, `getOperationId()`, etc.
485
+ - `schemas`: An object containing operation schemas including `pathParams`, `queryParams`, `request`, `response`, etc.
486
+ warning: |
487
+ When using a string you need to use `JSON.stringify`.
488
+ details:
489
+ - title: Using tags and path parameters
490
+ body: |-
491
+ Generate a queryKey with operation tags and path parameters:
492
+
493
+ For a GET operation with tags `["user"]` and path parameter `username`, this generates:
494
+ codeBlock:
495
+ - lang: typescript
496
+ code: |-
497
+ import { defineConfig } from 'kubb'
498
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
499
+
500
+ export default defineConfig({
501
+ // ...
502
+ plugins: [
503
+ pluginVueQuery({
504
+ queryKey: ({ operation, schemas }) => {
505
+ const tags = operation.getTags().map(tag => JSON.stringify(tag.name))
506
+ const pathParams = schemas.pathParams?.keys || []
507
+ return [...tags, ...pathParams]
508
+ },
509
+ }),
510
+ ],
511
+ })
512
+ - lang: typescript
513
+ code: |-
514
+ export const getUserByNameQueryKey = ({ username }: { username: GetUserByNamePathParams["username"] }) =>
515
+ ['user', username] as const
516
+ - title: Using the default transformer
517
+ body: |-
518
+ You can extend the default queryKey transformer:
519
+
520
+ This prepends a version to the default queryKey:
521
+ codeBlock:
522
+ - lang: typescript
523
+ code: |-
524
+ import { defineConfig } from 'kubb'
525
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
526
+ import { QueryKey } from '@kubb/plugin-vue-query/components'
527
+
528
+ export default defineConfig({
529
+ // ...
530
+ plugins: [
531
+ pluginVueQuery({
532
+ queryKey: (props) => {
533
+ const defaultKeys = QueryKey.getTransformer(props)
534
+ return [JSON.stringify('v5'), ...defaultKeys]
535
+ },
536
+ }),
537
+ ],
538
+ })
539
+ - lang: typescript
540
+ code: |-
541
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) =>
542
+ ['v5', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
543
+ - title: Using operation ID
544
+ body: "Create a simple queryKey using the operation ID:"
545
+ codeBlock:
546
+ lang: typescript
547
+ code: |-
548
+ import { defineConfig } from 'kubb'
549
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
550
+
551
+ export default defineConfig({
552
+ // ...
553
+ plugins: [
554
+ pluginVueQuery({
555
+ queryKey: ({ operation }) => {
556
+ return [JSON.stringify(operation.getOperationId())]
557
+ },
558
+ }),
559
+ ],
560
+ })
561
+ - title: Conditional keys based on parameters
562
+ body: "Include query parameters when they exist:"
563
+ codeBlock:
564
+ lang: typescript
565
+ code: |-
566
+ import { defineConfig } from 'kubb'
567
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
568
+
569
+ export default defineConfig({
570
+ // ...
571
+ plugins: [
572
+ pluginVueQuery({
573
+ queryKey: ({ operation, schemas }) => {
574
+ const keys = [JSON.stringify(operation.getOperationId())]
575
+
576
+ // Add path parameter values (without quotes, so they reference the variables)
577
+ if (schemas.pathParams?.keys) {
578
+ keys.push(...schemas.pathParams.keys)
579
+ }
580
+
581
+ // Add query params conditionally (the string gets embedded as code)
582
+ if (schemas.queryParams?.name) {
583
+ keys.push('...(params ? [params] : [])')
584
+ }
585
+
586
+ return keys
587
+ },
588
+ }),
589
+ ],
590
+ })
591
+ - name: query
592
+ type: Query
593
+ required: false
594
+ description: |
595
+ Override some `useQuery` behaviors.
596
+
597
+ To disable the creation of hooks pass `false`, this will result in only creating `queryOptions`.
598
+ typeDefinition: |
599
+ type Query = {
600
+ methods: Array<HttpMethod>
601
+ importPath?: string
602
+ } | false
603
+ properties:
604
+ - name: methods
605
+ type: Array<HttpMethod>
606
+ required: false
607
+ default: "['get']"
608
+ description: Define which HttpMethods can be used for queries.
609
+ - name: importPath
610
+ type: string
611
+ required: false
612
+ default: "'@tanstack/vue-query'"
613
+ description: |
614
+ Path to the `useQuery` that will be used to do the `useQuery` functionality.
615
+
616
+ It will be used as `import { useQuery } from '${hook.importPath}'`. It allows both relative and absolute paths. The path will be applied as is, so relative paths should be based on the file being generated.
617
+ - name: mutation
618
+ type: Mutation
619
+ required: false
620
+ description: |
621
+ Override some `useMutation` behaviors.
622
+
623
+ To disable queries pass `false`.
624
+ typeDefinition: |
625
+ type Mutation = {
626
+ methods: Array<HttpMethod>
627
+ importPath?: string
628
+ } | false
629
+ properties:
630
+ - name: methods
631
+ type: Array<HttpMethod>
632
+ required: false
633
+ default: "['post', 'put', 'delete']"
634
+ description: Define which HttpMethods can be used for mutations.
635
+ - name: importPath
636
+ type: string
637
+ required: false
638
+ default: "'@tanstack/vue-query'"
639
+ description: |
640
+ Path to the `useMutation` that will be used to do the `useMutation` functionality.
641
+
642
+ It will be used as `import { useMutation } from '${hook.importPath}'`. It allows both relative and absolute paths. The path will be applied as is, so relative paths should be based on the file being generated.
643
+ - name: mutationKey
644
+ type: "(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]"
645
+ required: false
646
+ description: Customize the mutationKey.
647
+ warning: |
648
+ When using a string you need to use `JSON.stringify`.
649
+ - name: include
650
+ type: Array<Include>
651
+ required: false
652
+ description: Array containing include parameters to include tags, operations, methods, paths, or content types.
653
+ codeBlock:
654
+ lang: typescript
655
+ title: Include
656
+ code: |
657
+ export type Include = {
658
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
659
+ pattern: string | RegExp
660
+ }
661
+ - name: exclude
662
+ type: Array<Exclude>
663
+ required: false
664
+ description: Array containing exclude parameters to exclude or skip tags, operations, methods, paths, or content types.
665
+ codeBlock:
666
+ lang: typescript
667
+ title: Exclude
668
+ code: |
669
+ export type Exclude = {
670
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
671
+ pattern: string | RegExp
672
+ }
673
+ - name: override
674
+ type: Array<Override>
675
+ required: false
676
+ description: Array containing override parameters to override `options` based on tags, operations, methods, paths, or content types.
677
+ codeBlock:
678
+ lang: typescript
679
+ title: Override
680
+ code: |
681
+ export type Override = {
682
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
683
+ pattern: string | RegExp
684
+ options: PluginOptions
685
+ }
686
+ - name: generators
687
+ type: Array<Generator<PluginVueQuery>>
688
+ required: false
689
+ experimental: true
690
+ description: |
691
+ Define additional generators next to the built-in generators.
692
+
693
+ See [Generators](https://kubb.dev/docs/5.x/guides/creating-plugins) for more information on how to use generators.
694
+ - name: transformers
695
+ type: Visitor
696
+ required: false
697
+ description: |
698
+ A single AST visitor applied to every node before code is printed. Each method you provide replaces the corresponding built-in one. When a method returns `null` or `undefined`, the preset transformer's result is used as the fallback — so you only need to supply the methods you want to change.
699
+
700
+ Visitor methods receive the node and a context object. Return a modified node to replace it, or return `undefined`/`void` to leave it unchanged.
701
+ examples:
702
+ - name: Strip descriptions before printing
703
+ files:
704
+ - lang: typescript
705
+ code: |
706
+ import { pluginTs } from '@kubb/plugin-ts'
707
+
708
+ pluginTs({
709
+ transformer: {
710
+ schema(node) {
711
+ return { ...node, description: undefined }
712
+ },
713
+ },
714
+ })
715
+ twoslash: false
716
+ - name: Prefix every operationId
717
+ files:
718
+ - lang: typescript
719
+ code: |
720
+ import { pluginTs } from '@kubb/plugin-ts'
721
+
722
+ pluginTs({
723
+ transformer: {
724
+ operation(node) {
725
+ return { ...node, operationId: `api_${node.operationId}` }
726
+ },
727
+ },
728
+ })
729
+ twoslash: false
730
+ tip: |
731
+ Use `transformer` to rewrite node properties before printing. For output naming customization, use `resolver` instead.
732
+ properties:
733
+ - name: name
734
+ type: "(name: string, type?: ResolveType) => string"
735
+ required: false
736
+ description: Customize the names based on the type that is provided by the plugin.
737
+ codeBlock:
738
+ lang: typescript
739
+ code: |
740
+ type ResolveType = 'file' | 'function' | 'type' | 'const'
741
+ - name: resolver
742
+ type: Partial<ResolverVueQuery>
743
+ required: false
744
+ description: Override individual resolver methods to customize naming conventions.
745
+ - name: transformer
746
+ type: ast.Visitor
747
+ required: false
748
+ description: Single AST visitor applied to each node before printing.
749
+ examples:
750
+ - name: kubb.config.ts
751
+ files:
752
+ - lang: typescript
753
+ code: |
754
+ import { defineConfig } from 'kubb'
755
+ import { pluginTs } from '@kubb/plugin-ts'
756
+ import { pluginVueQuery } from '@kubb/plugin-vue-query'
757
+
758
+ export default defineConfig({
759
+ input: {
760
+ path: './petStore.yaml',
761
+ },
762
+ output: {
763
+ path: './src/gen',
764
+ },
765
+ plugins: [
766
+ pluginTs(),
767
+ pluginVueQuery({
768
+ output: {
769
+ path: './hooks',
770
+ },
771
+ group: {
772
+ type: 'tag',
773
+ name: ({ group }) => `${group}Hooks`,
774
+ },
775
+ client: {
776
+ dataReturnType: 'full',
777
+ },
778
+ mutation: {
779
+ methods: ['post', 'put', 'delete'],
780
+ },
781
+ infinite: {
782
+ queryParam: 'next_page',
783
+ initialPageParam: 0,
784
+ cursorParam: 'nextCursor',
785
+ },
786
+ query: {
787
+ methods: ['get'],
788
+ importPath: '@tanstack/vue-query',
789
+ },
790
+ }),
791
+ ],
792
+ })
793
+ twoslash: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-vue-query",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0-beta.4",
4
4
  "description": "Vue Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Vue.js applications.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -33,7 +33,7 @@
33
33
  "files": [
34
34
  "src",
35
35
  "dist",
36
- "plugin.json",
36
+ "extension.yaml",
37
37
  "!/**/**.test.**",
38
38
  "!/**/__tests__/**",
39
39
  "!/**/__snapshots__/**"
@@ -73,19 +73,19 @@
73
73
  "registry": "https://registry.npmjs.org/"
74
74
  },
75
75
  "dependencies": {
76
- "@kubb/core": "5.0.0-beta.3",
77
- "@kubb/renderer-jsx": "5.0.0-beta.3",
76
+ "@kubb/core": "5.0.0-beta.4",
77
+ "@kubb/renderer-jsx": "5.0.0-beta.4",
78
78
  "remeda": "^2.34.0",
79
- "@kubb/plugin-client": "5.0.0-beta.3",
80
- "@kubb/plugin-ts": "5.0.0-beta.3",
81
- "@kubb/plugin-zod": "5.0.0-beta.3"
79
+ "@kubb/plugin-client": "5.0.0-beta.4",
80
+ "@kubb/plugin-ts": "5.0.0-beta.4",
81
+ "@kubb/plugin-zod": "5.0.0-beta.4"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@internals/tanstack-query": "0.0.0",
85
85
  "@internals/utils": "0.0.0"
86
86
  },
87
87
  "peerDependencies": {
88
- "@kubb/renderer-jsx": "5.0.0-beta.3"
88
+ "@kubb/renderer-jsx": "5.0.0-beta.4"
89
89
  },
90
90
  "size-limit": [
91
91
  {