Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
run: pnpm run build

- name: Publish preview packages
run: pnpx pkg-pr-new publish --pnpm --owner=stijnvanhulle --repo=https://github.com/kubb-labs/plugins.git './packages/*' --template './examples/*'
run: pnpx pkg-pr-new publish --pnpm --owner=stijnvanhulle --repo=https://github.com/kubb-labs/plugins.git './packages/*' --template './examples/*/*'

dependency-diff:
name: Dependency Diff
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:
run: pnpm run build

- name: Run E2E tests
working-directory: ./tests/e2e
working-directory: ./tests/openapi/e2e
env:
NODE_OPTIONS: '--max_old_space_size=4096'
KUBB_DISABLE_TELEMETRY: '1'
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ plugins/
β”‚ β”œβ”€β”€ shared/ # Shared AST helpers used across packages
β”‚ β”œβ”€β”€ tanstack-query/ # Shared TanStack Query utilities
β”‚ └── utils/ # General utilities
β”œβ”€β”€ examples/ # A runnable project per plugin
β”œβ”€β”€ tests/ # End-to-end, performance, and version-specific suites
β”œβ”€β”€ examples/ # A runnable project per plugin, grouped by adapter (openapi, arazzo)
β”œβ”€β”€ tests/ # End-to-end, performance, and version-specific suites, grouped by adapter
β”œβ”€β”€ schemas/ # OpenAPI specs used for testing
β”œβ”€β”€ configs/ # Shared build and test configuration
└── assets/ # Static assets
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,29 @@ Plugins built and maintained by the community. Want to add yours? See [CONTRIBUT

## Examples

| Example | Description |
| --------------------------------------- | ----------------------------------- |
| [`typescript`](./examples/typescript) | Generate TypeScript types |
| [`client`](./examples/client) | Generate API clients with Axios |
| [`fetch`](./examples/fetch) | Generate API clients with Fetch |
| [`zod`](./examples/zod) | Generate Zod validation schemas |
| [`react-query`](./examples/react-query) | Generate React Query hooks |
| [`vue-query`](./examples/vue-query) | Generate Vue Query composables |
| [`faker`](./examples/faker) | Generate Faker.js mock data |
| [`msw`](./examples/msw) | Generate MSW handlers |
| [`cypress`](./examples/cypress) | Generate Cypress tests |
| [`mcp`](./examples/mcp) | Generate MCP tools |
| [`advanced`](./examples/advanced) | Advanced multi-plugin configuration |
Examples are grouped by adapter, `openapi` or `arazzo`, under `./examples/<adapter>/<name>`.

### OpenAPI adapter

| Example | Description |
| ------------------------------------------------------------ | ----------------------------------- |
| [`typescript`](./examples/openapi/typescript) | Generate TypeScript types |
| [`client`](./examples/openapi/client) | Generate API clients with Axios |
| [`fetch`](./examples/openapi/fetch) | Generate API clients with Fetch |
| [`zod`](./examples/openapi/zod) | Generate Zod validation schemas |
| [`react-query`](./examples/openapi/react-query) | Generate React Query hooks |
| [`vue-query`](./examples/openapi/vue-query) | Generate Vue Query composables |
| [`faker`](./examples/openapi/faker) | Generate Faker.js mock data |
| [`msw`](./examples/openapi/msw) | Generate MSW handlers |
| [`cypress`](./examples/openapi/cypress) | Generate Cypress tests |
| [`mcp`](./examples/openapi/mcp) | Generate MCP tools |
| [`advanced`](./examples/openapi/advanced) | Advanced multi-plugin configuration |

### Arazzo adapter

| Example | Description |
| ---------------------------------------------- | --------------------------------------------- |
| [`typescript`](./examples/arazzo/typescript) | Generate TypeScript types from Arazzo workflows |

## Contributing

Expand Down
22 changes: 22 additions & 0 deletions examples/arazzo/typescript/kubb.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { adapterArazzo } from '@kubb/adapter-arazzo'
import { pluginTs } from '@kubb/plugin-ts'
import { defineConfig } from 'kubb/config'

export default defineConfig({
root: '.',
input: './workflows.arazzo.yaml',
output: {
path: './src/gen',
clean: true,
},
adapter: adapterArazzo(),
plugins: [
pluginTs({
output: {
path: 'models',
mode: 'directory',
},
enum: { type: 'asConst' },
}),
],
})
35 changes: 35 additions & 0 deletions examples/arazzo/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "typescript-arazzo-pet-store",
"version": "0.0.0",
"private": true,
"description": "TypeScript Arazzo workflow example",
"license": "MIT",
"author": "stijnvanhulle",
"repository": {
"type": "git",
"url": "https://github.com/kubb-labs/plugins.git",
"directory": "examples/arazzo/typescript"
},
"sideEffects": false,
"scripts": {
"clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
"generate": "KUBB_DISABLE_TELEMETRY=1 kubb generate",
"generate:debug": "NODE_OPTIONS='--inspect-brk' KUBB_DISABLE_TELEMETRY=1 kubb generate",
"validate": "kubb validate workflows.arazzo.yaml",
"test": "vitest",
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@kubb/adapter-arazzo": "catalog:",
"@kubb/plugin-ts": "workspace:*",
"kubb": "catalog:"
},
"devDependencies": {
"typescript": "catalog:"
},
"engines": {
"node": ">=22",
"pnpm": ">=11.0.0"
},
"packageManager": "pnpm@11.20.0"
}
77 changes: 77 additions & 0 deletions examples/arazzo/typescript/petStore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
openapi: 3.1.0
info:
title: Pet Store
version: 1.0.0
servers:
- url: https://petstore.example.com/v1
paths:
/user/login:
get:
operationId: loginUser
parameters:
- name: username
in: query
required: true
schema:
type: string
responses:
'200':
description: Logged in
headers:
X-Expires-After:
schema:
type: string
format: date-time
content:
application/json:
schema:
$ref: '#/components/schemas/Session'
/pet/{petId}:
get:
operationId: getPetById
parameters:
- name: petId
in: path
required: true
schema:
type: integer
responses:
'200':
description: A pet
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Session:
type: object
required:
- token
properties:
token:
type: string
user:
$ref: '#/components/schemas/User'
User:
type: object
properties:
id:
type: integer
name:
type: string
Pet:
type: object
required:
- id
properties:
id:
type: integer
name:
type: string
status:
type: string
enum:
- available
- pending
- sold
9 changes: 9 additions & 0 deletions examples/arazzo/typescript/src/gen/models/Credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

export type Credentials = {
username?: string
password?: string
}
27 changes: 27 additions & 0 deletions examples/arazzo/typescript/src/gen/models/LoginAndReadPet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

import type { LoginAndReadPetInputs } from './LoginAndReadPetInputs'
import type { LoginAndReadPetOutputs } from './LoginAndReadPetOutputs'

export type LoginAndReadPetStatus200 = LoginAndReadPetOutputs

export type LoginAndReadPetBody = LoginAndReadPetInputs

export type LoginAndReadPetOptions = {
body: LoginAndReadPetBody
path?: never
query?: never
headers?: never
}

export type LoginAndReadPetResponses = {
'200': LoginAndReadPetStatus200
}

/**
* @description Union of all possible responses
*/
export type LoginAndReadPetResponse = LoginAndReadPetStatus200
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

export type LoginAndReadPetInputs = {
username: string
petId?: number
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

import type { Pet } from './Pet'

export const statusEnum = {
available: 'available',
pending: 'pending',
sold: 'sold',
} as const

export type StatusEnumKey = (typeof statusEnum)[keyof typeof statusEnum]

export type LoginAndReadPetOutputs = {
token: string
pet: Pet
status: StatusEnumKey
}
24 changes: 24 additions & 0 deletions examples/arazzo/typescript/src/gen/models/ReadPetOnly.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

import type { ReadPetOnlyOutputs } from './ReadPetOnlyOutputs'

export type ReadPetOnlyStatus200 = ReadPetOnlyOutputs

export type ReadPetOnlyOptions = {
body?: never
path?: never
query?: never
headers?: never
}

export type ReadPetOnlyResponses = {
'200': ReadPetOnlyStatus200
}

/**
* @description Union of all possible responses
*/
export type ReadPetOnlyResponse = ReadPetOnlyStatus200
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/

export type ReadPetOnlyOutputs = {
petId: number
}
File renamed without changes.
Loading
Loading