Lin X. 판매

Kubb transforms Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 specifications into TypeScript types, Zod schemas, React Query hooks, and API clients via an extensible plugin system. Designed for teams who want automated, type-safe client generation integrated into any build pipeline.
This block provides the full Kubb plugin framework: a pipeline for parsing OpenAPI documents, building a typed AST, driving code generation plugins, managing output files, and exposing a CLI. The intended buyer is a TypeScript developer building custom code generators, SDK factories, or API tooling on top of OpenAPI specifications.
adapter-oas/ - OpenAPI document parsing, validation, and schema/operation extractionagent/ - Nitro-based HTTP/WebSocket server that runs Kubb generation remotely and streams resultsast/ - Typed AST node definitions, factory functions, visitors, and transformers for code generationcli/ - Command-line interface (kubb generate, validate, mcp, agent, init)core/ - Plugin driver, file manager, renderer, storage, and all base define* factorieskubb/ - Top-level meta-package re-exporting core and adapter surfacesmcp/ - Model Context Protocol server integration for AI-assisted generationparser-ts/ - TypeScript source parser utilitiesrenderer-jsx/ - JSX-based template renderer for code outputunplugin-kubb/ - Vite/Rollup/webpack unplugin adapternpm install @kubb/core @kubb/ast @kubb/adapter-oas typescript
# For CLI usage
npm install @kubb/cli
# For unplugin (Vite/Rollup/webpack)
npm install unplugin-kubb
# For OpenAPI parsing (peer dependency of adapter-oas)
npm install oas
No native modules, pod installs, or prebuild steps are required. This is a pure Node.js/TypeScript stack.
source/ directory into your project root (e.g. packages/).tsconfig.json so local cross-package imports resolve:{
"compilerOptions": {
"moduleResolution": "bundler",
"paths": {
"@kubb/ast": ["./packages/ast/src/index.ts"],
"@kubb/core": ["./packages/core/src/index.ts"],
"@kubb/adapter-oas": ["./packages/adapter-oas/src/index.ts"]
}
}
}
KUBB_DISABLE_TELEMETRY=1 # disable anonymous telemetry in CLI
격리된 샌드박스를 띄워 서버에서 바로 실행하세요 — 로컬 설정 불필요.
이 버전에 대한 Tetrees AI Review
This TypeScript cli / script completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
파이프라인 avcp-2026-08-04.1 · SHA-256 394dc22844c07952…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
검토일 2026년 8월 4일
이 제품을 AI IDE, 웹 빌더 또는 클라우드 IDE로 바로 가져오세요.
Tetrees를 호환 AI IDE에 연결해 보유 제품을 불러오고, 판매자 업로드 권한을 노출하지 않은 채 검증된 ZIP을 받으세요.
아직 리뷰가 없습니다.
토론을 불러오는 중…
tsdown.config.ts; run tsdown --config packages/core/tsdown.config.ts to build individual packages, or wire them all through your monorepo build script.nitro build inside packages/agent/ and start with node .output/server/index.mjs.parseDocumentimport { parseDocument } from '@kubb/adapter-oas'
async function parseDocument(
source: string | Document,
options?: ParseOptions
): Promise<Document>
Parses a raw OpenAPI YAML/JSON string or URL into a validated Document object. Use this as the first step in any generation pipeline before handing the document off to the plugin driver.
createKubbimport { createKubb } from '@kubb/core'
function createKubb(options: KubbConfig): Kubb
Instantiates the main Kubb orchestrator, wiring together plugins, the file manager, and the plugin driver. This is the central entry point for programmatic generation; call .build() on the returned instance to run the full pipeline.
definePluginimport { definePlugin } from '@kubb/core'
function definePlugin<TOptions>(factory: (options: TOptions) => Plugin): PluginFactory<TOptions>
Creates a typed plugin factory. Plugins define hooks (buildStart, buildEnd, generateFiles, etc.) and are consumed by createKubb. Use this whenever you want to extend the generation pipeline with custom output logic.
createSchemaimport { createSchema } from '@kubb/ast'
function createSchema(options: SchemaOptions): SchemaNode
Constructs a typed SchemaNode in the Kubb AST. Use this inside a plugin's file-generation step to represent an OpenAPI schema as an AST node that printers can later render to TypeScript, Zod, etc.
walkimport { walk } from '@kubb/ast'
function walk(node: Node, visitor: Visitor): void
Traverses an AST tree depth-first, calling visitor hooks on each node. Use this when you need to inspect or transform all schema nodes of a specific kind (e.g. collect all enum nodes before rendering).
Load a local OpenAPI file and confirm it is valid before passing it downstream.
import { readFileSync } from 'node:fs'
import { parseDocument, validateDocument } from '@kubb/adapter-oas'
const raw = readFileSync('./openapi.yaml', 'utf-8')
const doc = await parseDocument(raw)
const result = await validateDocument(doc, { strict: true })
if (result.errors.length) {
console.error('OpenAPI validation errors:', result.errors)
process.exit(1)
}
console.log('Operations found:', Object.keys(doc.paths ?? {}).length)
Define a minimal plugin that logs every generated file path.
import { createKubb, definePlugin } from '@kubb/core'
import { adapterOas } from '@kubb/adapter-oas'
const loggerPlugin = definePlugin<{ prefix: string }>((options) => ({
name: 'logger-plugin',
async buildEnd({ files }) {
for (const file of files) {
console.log(`${options.prefix}: ${file.path}`)
}
},
}))
const kubb = createKubb({
input: { path: './openapi.yaml' },
output: { path: './src/generated' },
plugins: [
adapterOas({}),
loggerPlugin({ prefix: '[generated]' }),
],
})
await kubb.build()
Construct an object schema with two properties and visit each property node.
import { createSchema, createProperty } from '@kubb/ast'
import { walk } from '@kubb/ast'
import type { SchemaNode, PropertyNode } from '@kubb/ast'
const schema: SchemaNode = createSchema({
type: 'object',
properties: [
createProperty({ name: 'id', schema: createSchema({ type: 'number' }) }),
createProperty({ name: 'name', schema: createSchema({ type: 'string' }) }),
],
})
walk(schema, {
Property(node: PropertyNode) {
console.log('property:', node.name)
},
})
Invoke the Kubb CLI runner from a Node.js script without spawning a child process.
import { run } from '@kubb/cli'
await run(['node', 'kubb', 'generate', '--config', './kubb.config.ts'])
adapter-oas/ - Contains adapterOas plugin factory, parseDocument, validateDocument, mergeDocuments, and all OpenAPI type exports (Operation, SchemaObject, HttpMethods, etc.).agent/ - Nitro server that exposes REST and WebSocket endpoints for remote generation; houses route handlers, plugin loaders, config resolvers, and WebSocket publish utilities.ast/ - Core AST layer: factory.ts has all create* functions, visitor.ts has walk/collect/transform, transformers.ts has schema mutation helpers, nodes/ contains all TypeScript node type definitions.cli/ - Exports a single run(argv) function that registers generate, validate, mcp, agent, and init commands and dispatches to them.core/ - The orchestration layer: createKubb, definePlugin, defineGenerator, FileManager, PluginDriver, FileProcessor, storage adapters (fsStorage, memoryStorage), and all shared types.kubb/ - Thin re-export meta-package bundling core and adapter surfaces for consumers who want a single install.mcp/ - MCP server for AI tool integrations; exposes generation capabilities over the Model Context Protocol.parser-ts/ - Utilities for parsing TypeScript source files, used by renderers and plugins that analyze existing code.renderer-jsx/ - JSX printer adapter; turns AST nodes into TypeScript/JSX source strings.unplugin-kubb/ - Wraps createKubb in an unplugin so Kubb generation runs inside Vite, Rollup, or webpack build pipelines."type": "commonjs" you must use dynamic import() or switch to "type": "module". Fix: add "type": "module" to your package.json.moduleResolution must be bundler or node16: Imports use .ts extensions. Fix: set "moduleResolution": "bundler" in tsconfig.json.oas peer dependency: adapter-oas does not bundle oas. Fix: npm install oas.KUBB_DISABLE_TELEMETRY=1 in your CI environment.createKubb called before document is reachable: If input.path is a URL that requires auth, the default fetch will fail silently. Fix: use parseDocument manually and pass the resulting Document object as input.data.adapterOas must appear before any generator plugin in the plugins array because generator plugins depend on the parsed document being present in the context. Fix: always list adapterOas({}) first.I have a copy of the Kubb plugin packages in `source/` and a usage guide in `USAGE.md`.
The upstream npm package is `@kubb/root@0.0.0` (monorepo: core, AST, CLI, adapter-oas, etc.).
Please help me integrate Kubb into my existing TypeScript project step by step:
1. Read USAGE.md and the file excerpts I have provided.
2. Install the required dependencies listed in the "Required dependencies" section.
3. Update my tsconfig.json with the path aliases from the "Project setup" section.
4. Create a `kubb.config.ts` at the project root that uses `createKubb` from `source/core/src/index.ts`
and `adapterOas` from `source/adapter-oas/src/index.ts`, pointing to my OpenAPI file at `./openapi.yaml`
and outputting to `./src/generated`.
5. Add a `generate` npm script that calls the CLI `run()` from `source/cli/src/index.ts`.
6. If I need a custom plugin, scaffold one using `definePlugin` from `source/core/src/index.ts`.
Only use symbols that appear in USAGE.md or in the source index files. Do not invent APIs.
Ask me for clarification if my project structure requires deviating from the setup steps.
See source/LICENSE if present in the upstream repository, or refer to the license field in each package's package.json. Upstream source: @kubb/root by Kubb Labs. All credit for the original implementation belongs to the Kubb Labs contributors.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
전체 설치 가이드와 연동 프롬프트는 구매 후 열람할 수 있습니다.
Automation, Utilities & Developer Tools
무료