@kubb/plugin-cypress 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 +441 -0
  2. package/package.json +6 -6
package/extension.yaml ADDED
@@ -0,0 +1,441 @@
1
+ $schema: https://kubb.dev/schemas/extension.json
2
+ kind: plugin
3
+ id: plugin-cypress
4
+ name: Cypress
5
+ description: Generate Cypress end-to-end tests from OpenAPI specifications.
6
+ category: testing
7
+ type: official
8
+ npmPackage: "@kubb/plugin-cypress"
9
+ docsPath: /plugins/plugin-cypress
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
+ - cypress
19
+ - e2e-testing
20
+ - api-testing
21
+ - test-generation
22
+ - codegen
23
+ - openapi
24
+ dependencies:
25
+ - plugin-ts
26
+ resources:
27
+ documentation: https://kubb.dev/plugins/plugin-cypress
28
+ repository: https://github.com/kubb-labs/plugins
29
+ issues: https://github.com/kubb-labs/plugins/issues
30
+ changelog: https://github.com/kubb-labs/plugins/blob/main/packages/plugin-cypress/CHANGELOG.md
31
+ codesandbox: https://codesandbox.io/p/github/kubb-labs/plugins/main/examples/cypress
32
+ featured: false
33
+ icon:
34
+ light: https://kubb.dev/feature/cypress.svg
35
+ intro: |
36
+ # @kubb/plugin-cypress
37
+
38
+ Generate typed `cy.request()` wrappers from your OpenAPI schema. Each API operation becomes a reusable function you can call in Cypress tests, with full TypeScript support.
39
+ options:
40
+ - name: output
41
+ type: Output
42
+ required: false
43
+ default: "{ path: 'cypress', barrelType: 'named' }"
44
+ description: Specify the export location for the files and define the behavior of the output.
45
+ properties:
46
+ - name: path
47
+ type: string
48
+ required: true
49
+ description: Output directory or file for the generated code, relative to the global `output.path`.
50
+ tip: |
51
+ if `output.path` is a file, `group` cannot be used.
52
+ default: "'cypress'"
53
+ - name: barrelType
54
+ type: "'all' | 'named' | 'propagate' | false"
55
+ required: false
56
+ default: "'named'"
57
+ description: Specify what to export and optionally disable barrel-file generation.
58
+ tip: |
59
+ 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.
60
+ examples:
61
+ - name: all
62
+ files:
63
+ - lang: typescript
64
+ code: |
65
+ export * from './gen/petService.ts'
66
+ twoslash: false
67
+ - name: named
68
+ files:
69
+ - lang: typescript
70
+ code: |
71
+ export { PetService } from './gen/petService.ts'
72
+ twoslash: false
73
+ - name: propagate
74
+ files:
75
+ - lang: typescript
76
+ code: ""
77
+ twoslash: false
78
+ - name: "false"
79
+ files:
80
+ - lang: typescript
81
+ code: ""
82
+ twoslash: false
83
+ - name: banner
84
+ type: "string | ((node: RootNode) => string)"
85
+ required: false
86
+ 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.
87
+ - name: footer
88
+ type: "string | ((node: RootNode) => string)"
89
+ required: false
90
+ 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.
91
+ - name: override
92
+ type: boolean
93
+ required: false
94
+ default: "false"
95
+ description: Whether Kubb overrides existing external files that can be generated if they already exist.
96
+ - name: resolver
97
+ type: Partial<ResolverCypress> & ThisType<ResolverCypress>
98
+ required: false
99
+ description: |
100
+ A single resolver that overrides the naming and path-resolution conventions. Each method you provide replaces the corresponding built-in one. When a method returns `null` or `undefined`, the resolver's result is used as the fallback, so you only need to supply the methods you want to change.
101
+
102
+ `this` inside each method is bound to the **full** resolver, so you can call other resolver methods (e.g. `this.default(name, 'function')`) without losing context.
103
+ body: |
104
+ Each plugin ships a built-in resolver:
105
+
106
+ | Plugin | Default resolver |
107
+ | --- | --- |
108
+ | `@kubb/plugin-ts` | `resolverTs` |
109
+ | `@kubb/plugin-zod` | `resolverZod` |
110
+ | `@kubb/plugin-cypress` | `resolverCypress` |
111
+ | `@kubb/plugin-mcp` | `resolverMcp` |
112
+ codeBlock:
113
+ lang: typescript
114
+ title: Custom resolver (plugin-ts example)
115
+ code: |
116
+ import { pluginTs } from '@kubb/plugin-ts'
117
+
118
+ pluginTs({
119
+ resolver: {
120
+ resolveName(name) {
121
+ // Prefix every operation-derived name; falls back for names where
122
+ // this returns null/undefined.
123
+ return `Api${this.default(name, 'function')}`
124
+ },
125
+ },
126
+ })
127
+ tip: |
128
+ Use `resolver` for fine-grained control over naming conventions.
129
+ - name: paramsType
130
+ type: "'object' | 'inline'"
131
+ required: false
132
+ default: "'inline'"
133
+ description: Defines how parameters are passed to generated functions. Switch between object-style parameters and inline parameters.
134
+ tip: |
135
+ When `paramsType` is set to `'object'`, `pathParams` will also be set to `'object'`.
136
+ body: |
137
+ - `'object'` returns params and pathParams as an object.
138
+ - `'inline'` returns params as comma-separated params.
139
+ examples:
140
+ - name: object
141
+ files:
142
+ - lang: typescript
143
+ code: |
144
+ export async function deletePet(
145
+ {
146
+ petId,
147
+ headers,
148
+ }: {
149
+ petId: DeletePetPathParams['petId']
150
+ headers?: DeletePetHeaderParams
151
+ },
152
+ config: Partial<RequestConfig> = {},
153
+ ) {
154
+ ...
155
+ }
156
+ twoslash: false
157
+ - name: inline
158
+ files:
159
+ - lang: typescript
160
+ code: |
161
+ export async function deletePet(
162
+ petId: DeletePetPathParams['petId'],
163
+ headers?: DeletePetHeaderParams,
164
+ config: Partial<RequestConfig> = {}
165
+ ){
166
+ ...
167
+ }
168
+ twoslash: false
169
+ - name: paramsCasing
170
+ type: "'camelcase'"
171
+ required: false
172
+ description: Transform parameter names to a specific casing format for path, query, and header parameters in generated client code.
173
+ important: |
174
+ 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.
175
+ body: |
176
+ - `'camelcase'` transforms parameter names to camelCase.
177
+ examples:
178
+ - name: With paramsCasing camelcase
179
+ files:
180
+ - lang: typescript
181
+ code: |
182
+ // Function parameters use camelCase
183
+ export async function deletePet(
184
+ petId: DeletePetPathParams['petId'], // ✓ camelCase
185
+ headers?: DeletePetHeaderParams,
186
+ config: Partial<RequestConfig> = {}
187
+ ) {
188
+ // Automatically maps back to original name for the API
189
+ const pet_id = petId
190
+
191
+ return fetch({
192
+ method: 'DELETE',
193
+ url: `/pet/${pet_id}`, // Uses original API parameter name
194
+ ...
195
+ })
196
+ }
197
+ twoslash: false
198
+ - name: Without paramsCasing
199
+ files:
200
+ - lang: typescript
201
+ code: |
202
+ // Parameters use original API naming
203
+ export async function deletePet(
204
+ pet_id: DeletePetPathParams['pet_id'], // Original naming
205
+ headers?: DeletePetHeaderParams,
206
+ config: Partial<RequestConfig> = {}
207
+ ) {
208
+ return fetch({
209
+ method: 'DELETE',
210
+ url: `/pet/${pet_id}`,
211
+ ...
212
+ })
213
+ }
214
+ twoslash: false
215
+ tip: |
216
+ 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.
217
+ - name: pathParamsType
218
+ type: "'object' | 'inline'"
219
+ required: false
220
+ default: "'inline'"
221
+ description: Defines how pathParams are passed to generated functions.
222
+ body: |
223
+ - `'object'` returns pathParams as an object.
224
+ - `'inline'` returns pathParams as comma-separated params.
225
+ examples:
226
+ - name: object
227
+ files:
228
+ - lang: typescript
229
+ code: |
230
+ export async function getPetById(
231
+ { petId }: GetPetByIdPathParams,
232
+ ) {
233
+ ...
234
+ }
235
+ twoslash: false
236
+ - name: inline
237
+ files:
238
+ - lang: typescript
239
+ code: |
240
+ export async function getPetById(
241
+ petId: GetPetByIdPathParams,
242
+ ) {
243
+ ...
244
+ }
245
+ twoslash: false
246
+ - name: dataReturnType
247
+ type: "'data' | 'full'"
248
+ required: false
249
+ default: "'data'"
250
+ description: |
251
+ Return type used when calling the client.
252
+
253
+ - `'data'` returns `ResponseConfig['data']`.
254
+ - `'full'` returns the full `ResponseConfig`.
255
+ examples:
256
+ - name: data
257
+ files:
258
+ - lang: typescript
259
+ code: |
260
+ export async function getPetById<TData>(
261
+ petId: GetPetByIdPathParams,
262
+ ): Promise<ResponseConfig<TData>['data']> {
263
+ ...
264
+ }
265
+ twoslash: false
266
+ - name: full
267
+ files:
268
+ - lang: typescript
269
+ code: |
270
+ export async function getPetById<TData>(
271
+ petId: GetPetByIdPathParams,
272
+ ): Promise<ResponseConfig<TData>> {
273
+ ...
274
+ }
275
+ twoslash: false
276
+ - name: baseURL
277
+ type: string
278
+ required: false
279
+ 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).
280
+ - name: group
281
+ type: Group
282
+ required: false
283
+ description: |
284
+ Grouping combines files in a folder based on a specific `type`.
285
+ examples:
286
+ - name: kubb.config.ts
287
+ files:
288
+ - lang: typescript
289
+ code: |
290
+ group: {
291
+ type: 'tag',
292
+ name({ group }) {
293
+ return `${group}Controller`
294
+ }
295
+ }
296
+ twoslash: false
297
+ body: |
298
+ With the configuration above, the generator emits:
299
+
300
+ ```text
301
+ .
302
+ ├── src/
303
+ │ └── petController/
304
+ │ │ ├── addPet.ts
305
+ │ │ └── getPet.ts
306
+ │ └── storeController/
307
+ │ ├── createStore.ts
308
+ │ └── getStoreById.ts
309
+ ├── petStore.yaml
310
+ ├── kubb.config.ts
311
+ └── package.json
312
+ ```
313
+ properties:
314
+ - name: type
315
+ type: "'tag'"
316
+ required: true
317
+ description: Specify the property to group files by. Required when `group` is defined.
318
+ note: |
319
+ `Required: true*` means this is required only when the `group` option is used. The `group` option itself is optional.
320
+ body: |
321
+ - `'tag'`: Uses the first tag from `operation.getTags().at(0)?.name`
322
+ - name: name
323
+ type: "(context: GroupContext) => string"
324
+ required: false
325
+ default: (ctx) => `${ctx.group}Requests`
326
+ description: Return the name of a group based on the group name. This is used for file and identifier generation.
327
+ - name: include
328
+ type: Array<Include>
329
+ required: false
330
+ description: Array containing include parameters to include tags, operations, methods, paths, or content types.
331
+ codeBlock:
332
+ lang: typescript
333
+ title: Include
334
+ code: |
335
+ export type Include = {
336
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
337
+ pattern: string | RegExp
338
+ }
339
+ - name: exclude
340
+ type: Array<Exclude>
341
+ required: false
342
+ description: Array containing exclude parameters to exclude or skip tags, operations, methods, paths, or content types.
343
+ codeBlock:
344
+ lang: typescript
345
+ title: Exclude
346
+ code: |
347
+ export type Exclude = {
348
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
349
+ pattern: string | RegExp
350
+ }
351
+ - name: override
352
+ type: Array<Override>
353
+ required: false
354
+ description: Array containing override parameters to override `options` based on tags, operations, methods, paths, or content types.
355
+ codeBlock:
356
+ lang: typescript
357
+ title: Override
358
+ code: |
359
+ export type Override = {
360
+ type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
361
+ pattern: string | RegExp
362
+ options: PluginOptions
363
+ }
364
+ - name: generators
365
+ type: Array<Generator<PluginCypress>>
366
+ required: false
367
+ experimental: true
368
+ description: |
369
+ Define additional generators next to the built-in generators.
370
+
371
+ See [Generators](https://kubb.dev/docs/5.x/guides/creating-plugins) for more information on how to use generators.
372
+ - name: transformer
373
+ type: Visitor
374
+ required: false
375
+ description: |
376
+ 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.
377
+
378
+ Visitor methods receive the node and a context object. Return a modified node to replace it, or return `undefined`/`void` to leave it unchanged.
379
+ examples:
380
+ - name: Strip descriptions before printing
381
+ files:
382
+ - lang: typescript
383
+ code: |
384
+ import { pluginTs } from '@kubb/plugin-ts'
385
+
386
+ pluginTs({
387
+ transformer: {
388
+ schema(node) {
389
+ return { ...node, description: undefined }
390
+ },
391
+ },
392
+ })
393
+ twoslash: false
394
+ - name: Prefix every operationId
395
+ files:
396
+ - lang: typescript
397
+ code: |
398
+ import { pluginTs } from '@kubb/plugin-ts'
399
+
400
+ pluginTs({
401
+ transformer: {
402
+ operation(node) {
403
+ return { ...node, operationId: `api_${node.operationId}` }
404
+ },
405
+ },
406
+ })
407
+ twoslash: false
408
+ tip: |
409
+ Use `transformer` to rewrite node properties before printing. For output naming customization, use `resolver` instead.
410
+ examples:
411
+ - name: kubb.config.ts
412
+ files:
413
+ - lang: typescript
414
+ code: |
415
+ import { defineConfig } from 'kubb'
416
+ import { pluginTs } from '@kubb/plugin-ts'
417
+ import { pluginCypress } from '@kubb/plugin-cypress'
418
+
419
+ export default defineConfig({
420
+ input: {
421
+ path: './petStore.yaml',
422
+ },
423
+ output: {
424
+ path: './src/gen',
425
+ },
426
+ plugins: [
427
+ pluginTs(),
428
+ pluginCypress({
429
+ output: {
430
+ path: './cypress',
431
+ barrelType: 'named',
432
+ banner: '/* eslint-disable no-alert, no-console */',
433
+ },
434
+ group: {
435
+ type: 'tag',
436
+ name: ({ group }) => `${group}Requests`,
437
+ },
438
+ }),
439
+ ],
440
+ })
441
+ twoslash: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-cypress",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0-beta.4",
4
4
  "description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
5
5
  "keywords": [
6
6
  "api-testing",
@@ -30,7 +30,7 @@
30
30
  "files": [
31
31
  "src",
32
32
  "dist",
33
- "plugin.json",
33
+ "extension.yaml",
34
34
  "!/**/**.test.**",
35
35
  "!/**/__tests__/**",
36
36
  "!/**/__snapshots__/**"
@@ -53,15 +53,15 @@
53
53
  "registry": "https://registry.npmjs.org/"
54
54
  },
55
55
  "dependencies": {
56
- "@kubb/core": "5.0.0-beta.3",
57
- "@kubb/renderer-jsx": "5.0.0-beta.3",
58
- "@kubb/plugin-ts": "5.0.0-beta.3"
56
+ "@kubb/core": "5.0.0-beta.4",
57
+ "@kubb/renderer-jsx": "5.0.0-beta.4",
58
+ "@kubb/plugin-ts": "5.0.0-beta.4"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@internals/utils": "0.0.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@kubb/renderer-jsx": "5.0.0-beta.3"
64
+ "@kubb/renderer-jsx": "5.0.0-beta.4"
65
65
  },
66
66
  "size-limit": [
67
67
  {