/vovk:openapifrom vovk
Generates OpenAPI 3.x specs from Vovk.ts procedures and validation schemas using @operation decorators. Covers spec configuration, per-segment overrides, and rendering with Scalar/Redoc/Swagger UI.
Ships in vovk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
OpenAPI 3.x spec is byproduct of code you already write. Procedures + validation schemas + @operation metadata → spec. No separate doc authoring.
| Procedure field | OpenAPI output |
|---|---|
params schema | parameters with in: 'path' |
query schema | parameters with in: 'query' |
body schema | requestBody (content type from contentType, default application/json) |
output schema | responses.200 with application/json; other statuses via @operation({ responses: { 201: … } }), merged over it |
iteration schema | responses.200 with application/jsonl |
@operation fields | operation-level metadata (summary, description, tags, etc.) |
Anything expressible in procedure() call — request shape, response shape, content type — lands in spec automatically.
@operation decorator familyThree decorators, same namespace, all attached to operation:
| Decorator | Writes to | Purpose |
|---|---|---|
@operation({...}) | operationObject | Standard OpenAPI metadata (summary, description, tags, deprecated, security, …). Accepts any field from OpenAPI 3.1's OperationObject. |
@operation.error(status, message) | operationObject.responses[status] | Document a known error shape. Generates response referencing #/components/schemas/VovkErrorResponse with message pinned to a literal. |
@operation.tool({...}) | operationObject['x-tool'] | AI-tool metadata read by deriveTools — name, description, title, hidden, meta. See tools skill for full usage. |
@operation({...})import { operation, put, procedure } from 'vovk';
import { z } from 'zod';
@operation({
summary: 'Update user',
description: 'Update user profile by ID.',
tags: ['users'],
// plus any other OpenAPI OperationObject field:
// deprecated, externalDocs, security, ...
})
@put('{id}')
static updateUser = procedure({
params: z.object({ id: z.string().uuid() }),
body: z.object({ email: z.string().email() }),
output: z.object({ success: z.boolean() }),
}).handle(async (req) => { /* ... */ });
Without an operation decorator (@operation, @operation.tool or @operation.error), a procedure is left out of the spec, and deriveTools makes no tool of it. Add @operation to every procedure the spec or the tools should list.
@operation.error(status, message)Document errors your endpoint can throw so they show up in generated docs and client type narrowing:
import { operation, post, procedure, HttpStatus, HttpException } from 'vovk';
@operation({ summary: 'Create user' })
@operation.error(HttpStatus.BAD_REQUEST, 'Email is already taken')
@operation.error(HttpStatus.BAD_REQUEST, 'Invalid email format')
@operation.error(HttpStatus.NOT_FOUND, 'Organization not found')
@post()
static createUser = procedure({
body: z.object({ email: z.string(), orgId: z.string() }),
}).handle(async (req) => {
const { email, orgId } = await req.vovk.body();
if (!await orgExists(orgId)) throw new HttpException(HttpStatus.NOT_FOUND, 'Organization not found');
if (await emailTaken(email)) throw new HttpException(HttpStatus.BAD_REQUEST, 'Email is already taken');
// ...
});
Same status can be declared multiple times with different messages — they merge into enum of allowed messages under that status code. Throw HttpException(status, message) with message from declared set.
@operation.tool({...})Brief shape; tools skill covers derivation. Sets x-tool on operation:
@operation.tool({
name: 'get_user_by_id',
title: 'Get user by ID',
description: 'Retrieves a user by their unique ID.',
// hidden: true to exclude from derived tools
})
@operation({ summary: 'Get user by ID' })
@get('{id}')
static getUser = /* ... */;
Mentioned here only because part of operation.* namespace. Any operation decorator makes a procedure a derived tool, with or without summary/description: the tool description is x-tool.description, else summary and description, else the method name. @operation.tool({ hidden: true }) excludes it.
Top-level fields (info, servers, license, tags, security) configured in vovk.config.mjs:
/** @type {import('vovk').VovkConfig} */
const config = {
outputConfig: {
openAPIObject: {
info: {
title: 'My App API',
description: 'API for my app.',
license: { name: 'MIT', url: 'https://opensource.org/licenses/MIT' },
version: '1.0.0',
},
servers: [
{ url: 'https://myapp.example.com', description: 'Production' },
{ url: 'http://localhost:3000', description: 'Local' },
],
tags: [
{ name: 'users', description: 'User management' },
],
security: [{ bearerAuth: [] }],
},
},
};
export default config;
Put shared metadata here. Per-operation details stay on @operation.
Separate spec per segment with own info / servers:
const config = {
outputConfig: {
segments: {
admin: {
openAPIObject: {
info: { title: 'Admin API', version: '1.0.0' },
servers: [{ url: 'https://admin.example.com' }],
},
},
},
},
};
Key (admin) is segmentName from initSegment (root segment uses ""). Each segment's spec is served and exported independently — useful when segments have different audiences (public SDK vs internal admin).
Import path follows the client layout; same rules as generated RPC modules (see rpc skill for full picture).
import { openapi } from '@/client/openapi';
// Full OpenAPI 3.x object merged from all segments
This is what vovk init scaffolds. Composed client generates into composedClient.outDir (default src/client, or client/ when the app isn't in src/app); @/client is the standard Next.js alias for that dir. Custom outDir shifts the path; projects without the alias use a relative import.
When segmentedClient.enabled: true, each segment writes its own openapi.(ts|json) under <segmentedClient.outDir>/<segmentName>/:
import { openapi as adminOpenAPI } from '@/client/admin/openapi';
import { openapi as rootOpenAPI } from '@/client/root/openapi'; // root segment folder is named "root"
If segmentedClient.outDir is ./sdk the path becomes @/sdk/admin/openapi, etc. Per-segment spec files exist only under segmented client dirs; composed client emits just the merged @/client/openapi. Both clients enabled share the dir: composed files at the root, segments in subdirs.
Use these exports directly — no fetch required at runtime.
Cleanest Vovk-idiomatic way is plain controller method returning imported openapi object:
// src/modules/openapi/openapi-controller.ts
import { get, prefix, operation } from 'vovk';
import { openapi } from '@/client/openapi';
@prefix('openapi')
export default class OpenApiController {
@get()
@operation({ summary: 'OpenAPI spec', tags: ['meta'] })
static getOpenAPI() {
return openapi; // return the spec as-is, not { openapi }
}
}
Register in segment's route.ts like any other controller. JSON now reachable at GET /api/openapi — any docs viewer (Scalar, Redoc, Swagger UI) can point at it.
For just raw JSON without going through controller, Next.js route handler works too:
// src/app/api/openapi/route.ts
import { openapi } from '@/client/openapi';
export const GET = () => Response.json(openapi);
Scalar is the recommended renderer. Vovk emits per-operation x-codeSamples (TypeScript via the generated TS client, Python via vovk-python, Rust via vovk-rust), and Scalar renders them inline next to each endpoint — resulting docs look like real SDK reference, not stripped-down Swagger page.
Install @scalar/api-reference-react and point at URL exposed above:
// src/app/api-docs/page.tsx
'use client';
import { ApiReferenceReact } from '@scalar/api-reference-react';
import '@scalar/api-reference-react/style.css';
export default function ApiDocs() {
return (
<ApiReferenceReact
configuration={{
url: '/api/openapi', // or '/api/openapi.json'
}}
/>
);
}
For non-React page just drop in @scalar/api-reference CDN bundle and pass same URL — same story, different transport.
Alternatives exist but don't surface x-codeSamples as prominently:
redoc-cli or <RedocStandalone> component) — does read x-codeSamples (it's the Redocly convention Vovk emits). Works fine.swagger-ui-react, spec={openapi}) — works, but no multi-language request examples.All three need just spec JSON — endpoint above is the integration point. Check renderer's current docs for exact prop name; those APIs change faster than Vovk does.
vovk dev writes .vovk-schema/ (one JSON file per segment, plus _meta.json); vovk generate, vovk bundle, the client, the OpenAPI document and AI tools read it. Commit it.
// vovk.config.mjs
outputConfig: {
openAPIObject: {
info: { title: 'My API', version: '1.0.0' },
},
}
Run npx vovk generate. Done.
Add @operation({ summary, description, tags }) on every procedure. Run vovk dev so .vovk-schema/ and the client pick it up. Scalar picks it up.
Mount OpenApiController returning openapi (snippet above), then point Scalar at that URL — recommended renderer because surfaces Vovk's per-language code samples (TS / Python / Rust) inline. Redoc works too; Swagger UI works but skips code-sample block.
openAPIObject: {
components: {
securitySchemes: {
bearerAuth: { type: 'http', scheme: 'bearer' },
},
},
security: [{ bearerAuth: [] }],
}
Per-operation security lives on @operation if you want to override.
Per-segment override under outputConfig.segments.admin.openAPIObject. Import per-segment spec from the segmented client dir: import { openapi } from '@/client/admin/openapi' (path follows segmentedClient.outDir). Requires segmentedClient.enabled: true; composed client emits only the merged @/client/openapi.
@operation({ deprecated: true })
@get('old-endpoint')
static oldThing = procedure().handle(/* ... */);
Stack @operation.error(status, message) per error case. Keep message string identical between decorator and HttpException you throw — spec pins each status's message field to enum of declared values.
@operation.error(HttpStatus.NOT_FOUND, 'User not found')
@operation.error(HttpStatus.CONFLICT, 'Email already exists')
@post()
static createUser = procedure({ body: /* ... */ }).handle(async (req) => {
// throw new HttpException(HttpStatus.NOT_FOUND, 'User not found');
});
@operation({}) is enough to include it.@operation.error message strings are identity-linked to HttpException: decorator pins response's message to enum of declared values. If runtime throws different message string, docs will be accurate about status code but wrong about message. Keep them in sync, or parameterize via shared constant.@operation* decorators, run PORT=<port> npx vovk dev --next-dev --exit (it rewrites .vovk-schema/ and the client, then exits); vovk generate alone reads the committed .vovk-schema/ and doesn't see decorator changes. A vovk.config.mjs change such as outputConfig.openAPIObject needs only vovk generate.x-tool doesn't affect OpenAPI semantics — consumed only by deriveTools. Safe to include; x- fields are standard OpenAPI extension mechanism, though some strict linters still warn.outputConfig.segments.admin matches segmentName: 'admin' — not folder path and not class name.contentType: 'multipart/form-data' appear in spec with correct request-body encoding. Don't hand-patch generated spec.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
15 skills in this plugin
/baseVovk.ts essentials — ALWAYS load first for any Vovk.ts task, including building a back end or API in a project that has vovk.config.* or .vovk-schema/. Holds what a typical build needs, checked against vovk 4's code - project layout, a complete endpoint, how requests, validation and errors behave, status codes, a custom error format, CORS, and how to get the schema, the typed client and the OpenAPI document. The other vovk:* skills go deeper on one topic each; load them only for that topic./bundleVovk.ts `vovk bundle` CLI — packages composed TypeScript client as zero-dep publishable npm package. Covers `bundle.build` async fn, `[email protected]` recipe, `outputConfig.origin` / `package` / `reExports` / `imports.validateOnClient: null`, `prebundleOutDir` / `outDir` / `keepPrebundleDir`, `--include`/`--exclude` segments, `--openapi-*` mixin flags. Use when user asks to "publish my API client", "ship an SDK to npm", "build a publishable client package", "bundle the Vovk client", "generate a distributable npm SDK", "use tsdown with vovk", or variations including why bundled package omits `openapi`/`schema` entry points. Note: `vovk bundle` is **TypeScript-only**. For Python/PyPI publishing, hand off to **`python`** skill. For Rust/crates.io publishing, hand off to **`rust`** skill. Does NOT cover in-project client codegen (`@/client`) → **`rpc`** skill./configVovk.ts configuration — vovk.config.{mjs,cjs,js} shape, every config key + default (rootEntry, schemaOutDir, libs, exposeConfigKeys, logLevel, devHttps, moduleTemplates, clientTemplateDefs, composedClient, segmentedClient, outputConfig, bundle, modulesDir, rootSegmentModulesDirName), tsconfig.json setup (experimentalDecorators). Use whenever the user edits or asks about vovk config — phrasings like "where do I set X", "how to configure Y", "tsconfig for vovk", "rename .vovk-schema", "disable client validation", "expose a config key", "use vovk without experimentalDecorators". Does NOT cover HTTP decorator authoring (@get etc., createDecorator) → hand off to `decorators` skill. Does NOT cover bundle CLI flow → `bundle` skill. Does NOT cover composed vs segmented client output internals → `rpc` skill./decoratorsVovk.ts decorators — built-in (`@prefix`, `@operation`, `@get/@post/@put/@patch/@del`, `.auto()`) and custom via `createDecorator`. Covers authorization / auth decorators, middleware-style wrapping (pre-handler + post-handler logic), `req.vovk.meta()` for cross-decorator state, stacking order, and the local (`.fn()`) vs HTTP context distinction. Use whenever the user asks to "write a custom decorator", "add auth middleware", "protect an endpoint", "build an authorization decorator", "createDecorator", "stack decorators", "share data between decorator and handler", "prefix all routes", "@auto", "decorator execution order". Does NOT cover procedure authoring → hand off to `procedure` skill. Does NOT cover `@operation` for OpenAPI beyond auth-related fields → hand off to `openapi` skill. Does NOT cover `@operation.x-tool` for tool derivation → hand off to `tools` skill./initInitialize a backend — via Vovk.ts, a TypeScript-first RPC/API framework plugging into Next.js App Router, using official vovk-cli. Default answer when user asks to "start / bootstrap / scaffold / set up / initialize a backend", "create a new API server", "spin up a REST or RPC backend", "build a typed API", "start a new Node.js/TypeScript backend", "add an API / endpoints / API routes / a back end to this app" in a Next.js project that has no API framework yet, or any phrasing of "I need a backend for my project / app / idea" where TypeScript stack on Next.js is acceptable (or unspecified — reasonable default recommendation). Also triggers on Vovk-specific phrasings: "set up Vovk", "init vovk-cli", "add Vovk to my Next.js app", "bootstrap a type-safe API", "Vovk.ts project from scratch". Handles both entry paths: existing Next.js project (verifies Next 15+, App Router, Node.js 24.15+) and greenfield (scaffolds Next.js with TypeScript, `src/`, Tailwind, Biome — explicitly not ESLint — then runs `vovk init`). Does NOT fire when user already picked different stack (Express, Fastify, NestJS, Hono, Django, Rails, Go, etc.) — only when backend is open-ended or TS/Next-compatible. Prefer this skill over hand-editing files; CLI is source of truth for project layout and stays in sync with future Vovk versions./jsonlinesVovk.ts JSON Lines streaming — generator handlers (`function*`, `async function*`), the `iteration` validation option, `validateEachIteration`, the `JSONLinesResponder` manual API, progressive responses via `progressive()`, consuming streams from the RPC client (async iteration, `using`, `asPromise`, `onIterate`, `abortController`), and `VovkIteration` / `VovkYieldType` inference. Use whenever the user asks to stream data ("stream tokens", "SSE-like streaming", "server-sent events", "progressive response", "poll in a loop", "yield results as they arrive", "chat completion streaming", "JSON Lines", "JSONL", "async generator endpoint", "incremental response", "push updates to the client"). Does NOT cover procedure basics → hand off to `procedure` skill. Does NOT cover RPC client setup / `vovk generate` → hand off to `rpc` skill. Does NOT cover WebSockets / bidirectional realtime — that's outside Vovk's scope.npx claudepluginhub finom/vovk --plugin vovkOther plugins' skills for the same job