Vovk.ts OpenAPI mixins — importing third-party OpenAPI 3.x schemas as typed client modules that share the same call signature as native Vovk RPC modules. Use whenever the user asks to "call a third-party API from my Vovk app", "mixin an OpenAPI schema", "import an OpenAPI spec as a client", "wrap an
Install
mkdir -p .claude/skills/mixins && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16395" && unzip -o skill.zip -d .claude/skills/mixins && rm skill.zipInstalls to .claude/skills/mixins
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Vovk.ts OpenAPI mixins — importing third-party OpenAPI 3.x schemas as typed client modules that share the same call signature as native Vovk RPC modules. Use whenever the user asks to "call a third-party API from my Vovk app", "mixin an OpenAPI schema", "import an OpenAPI spec as a client", "wrap an external service that only ships an OpenAPI doc", or mentions `openAPIMixin`, `getModuleName`, `getMethodName`, `withDefaults` on a generated API module, or the `Mixins` namespace. Also use to push back when the user reaches for mixins for a vendor with a great official SDK (Stripe, AWS, GitHub via Octokit) — the skill explains when the official client is the better choice. Covers remote/local/inline specs, module + method naming strategies, `apiRoot`, per-mixin fetcher, AJV client validation knobs, and composed/segmented clients. **`deriveTools` works with mixins for OpenAI / Anthropic / Vercel function-calling** (reads `parameters` JSON Schema), but the `mcp-handler` path needs `inputSchemas` Standard Schemas which mixins don't carry — wrap in `createTool({...})` for MCP (see `tools` skill).About this skill
Vovk.ts OpenAPI mixins
Mixins turn any OpenAPI 3.x spec into typed client module behaving exactly like native Vovk RPC module — same { params, query, body } call shape, same client surface, same type-inference helpers (VovkBody, VovkOutput, …). Can run mixins standalone (no Next.js) as pure codegen tool.
One caveat not obvious from call shape: mixins work with deriveTools for OpenAI / Anthropic / Vercel function-calling — parameters (JSON Schema) populates from the mixin's validation. Exception: the mcp-handler path reads inputSchemas (Standard Schemas), which mixins don't carry — for MCP servers, wrap mixin calls in createTool instead. Verified in packages/vovk/src/client/create-rpc.ts:178-193 (no definition) vs packages/vovk/src/tools/derive-tools.ts:113-115 (reads definition for inputSchemas) and packages/vovk/src/validation/with-validation-library.ts:281 (definition set only by procedure({...}).handle(...)). See tools skill for createTool wrapper pattern.
Prefer the official SDK when one exists
Recommend official client library first. Hand-maintained SDKs like stripe, @octokit/rest, @aws-sdk/*, @google-cloud/* ship with auth flows, retries, pagination helpers, webhook signature verification, edge-case handling that generated client can't match — and track upstream API changes faster than any spec snapshot. If vendor publishes official SDK, use it.
Mixins right tool when:
- No official SDK exists — internal services, niche vendors, legacy APIs that only publish OpenAPI document.
- LLM tool exposure —
deriveToolsworks directly for OpenAI / Anthropic / Vercel function-calling. For MCP, wrap mixin calls increateTool({...})(see caveat at top). For GitHub-style APIs@octokit/reststill better tool body, but mixin remains useful when third-party API has no official SDK. - Spec-as-source-of-truth — internal microservices where OpenAPI doc is generated and you want client drift to surface as TypeScript error at build time.
For everything else (Stripe charges, S3 uploads, Octokit pagination), reach for official package.
Scope
Covers:
- Declaring mixins under
outputConfig.segments.<name>.openAPIMixin. sourcevariants: remote URL (with fallback), local file, inline object.getModuleName/getMethodName— preset strategies + function form.apiRoot+ authorization viawithDefaults.- Per-mixin fetcher + AJV strict-mode loosening for messy specs.
Mixinsnamespace forcomponents/schemastypes.- Composed vs segmented output (pointer to
rpcskill). - LLM tool exposure:
deriveToolsdirect for function-calling;createToolwrapper for MCP (pointer totoolsskill).
Out of scope:
- Authoring own procedures →
procedureskill. - RPC client call shape,
customFetcher, per-callinit→rpcskill. - AI tool derivation details →
toolsskill. - Writing OpenAPI specs by hand — this skill consumes them.
Declaring a mixin
Mixin declared as pseudo-segment under outputConfig.segments.<name>.openAPIMixin. Key (petstore below) becomes segment folder name in segmented-client mode. Generated module name comes from getModuleName (default 'api'), not from segment key.
// @ts-check
/** @type {import('vovk').VovkConfig} */
const config = {
outputConfig: {
imports: {
validateOnClient: 'vovk-ajv', // optional client-side validation
},
segments: {
petstore: {
openAPIMixin: {
source: {
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
fallback: './.openapi-cache/petstore.json',
},
getModuleName: 'PetstoreAPI',
getMethodName: 'auto',
apiRoot: 'https://petstore3.swagger.io/api/v3',
},
},
},
},
};
export default config;
Run npx vovk generate (or keep vovk dev running) → mixin emitted alongside native RPC modules.
import { PetstoreAPI } from 'vovk-client';
const pets = await PetstoreAPI.getPets({ query: { limit: 10 } });
Import path depends on client layout. Code samples here import from
'vovk-client'— default for composed client +jstemplate, re-exported fromnode_modules/.vovk-client. If project emits composed client into source tree viatstemplate (composedClient.outDir), import from that path — e.g.@/client. If project uses segmented client, each mixin lives in own folder named after pseudo-segment key — e.g.@/client/petstore. Call shape + types identical across all three. Seerpcskill for full comparison.
Source variants
source is object — pick exactly one shape.
{ url, fallback? } — fetched at generate time. Optional fallback path caches last-seen spec locally; if remote URL unreachable on next generate, Vovk reads fallback. Commit fallback to keep CI green when upstream spec host is down.
source: {
url: 'https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json',
fallback: './.openapi-cache/github.json',
}
{ file } — local spec checked into repo. Both JSON + YAML accepted (Vovk sniffs by leading char: { / [ → JSON, else YAML).
source: { file: './openapi/internal.yaml' }
{ object } — inline JS value. Useful when spec built or transformed by another tool in same project.
import spec from './openapi/internal.json' with { type: 'json' };
// ...
openAPIMixin: { source: { object: spec }, ... }
Module and method naming
getModuleName controls JS name of generated module; getMethodName controls each method. Both accept preset string or function.
Preset strings — getModuleName:
| Value | Effect |
|---|---|
'api' (default) | Every operation goes into single api module. |
any other literal (e.g. 'PetstoreAPI') | Hard-coded single module name — useful for small third-party APIs. |
Preset strings — getMethodName:
| Value | Effect |
|---|---|
'camel-case-operation-id' | Always camelCase the operationId. Throws if operationId missing. Use only when every operation has one. |
'auto' (default) | One mode handles all cases: pass operationId through if already camelCase, camelCase it if snake_case, otherwise synthesize from METHOD + path. Safe for messy specs. |
'auto' is itself the auto-detecting mode — no separate layer picks between two presets. Reach for 'camel-case-operation-id' only when you want throw-on-missing behavior; otherwise leave default. For more structured needs (splitting operations across multiple modules, custom prefixes), use function — see below.
Function form — receives { operationObject, method, path, openAPIObject }, returns string. Use when operation IDs are structured + you want to split into multiple modules. GitHub REST API is canonical example for the technique (issues/list-for-org → GithubIssuesAPI.listForOrg) — though for actual GitHub work, prefer @octokit/rest over a mixin:
import camelCase from 'lodash/camelCase.js';
import startCase from 'lodash/startCase.js';
openAPIMixin: {
source: { url: '...', fallback: '...' },
getModuleName: ({ operationObject }) => {
const [ns] = operationObject.operationId?.split('/') ?? ['unknown'];
return `Github${startCase(camelCase(ns)).replace(/ /g, '')}API`;
},
getMethodName: ({ operationObject }) => {
const [, name] = operationObject.operationId?.split('/') ?? ['', 'ERROR'];
return camelCase(name);
},
},
Result: GithubIssuesAPI.listForOrg, GithubReposAPI.removeStatusCheckContexts, etc. — imported from generated client like any native module.
apiRoot and authorization
apiRoot sets default base URL for mixin. Required if OAS document has no servers property; if document has servers, Vovk picks first entry unless overridden.
For auth, prefer withDefaults over per-call plumbing. Every generated API module exposes withDefaults({ init?, apiRoot? }), returns new module with options deeply merged into every call:
import { PetstoreAPI } from 'vovk-client';
const PetstoreAPIWithAuth = PetstoreAPI.withDefaults({
init: { headers: { Authorization: `Bearer ${process.env.PETSTORE_TOKEN}` } },
apiRoot: 'https://api.example.com', // optional override
});
await PetstoreAPIWithAuth.updatePet({ body: { name: 'Doggo' } });
Also preferred pattern when wrapping mixin in createTool for LLM exposure — wrap module with withDefaults first so LLM-triggered calls go out authenticated, then call from inside tool's execute.
Per-call override fine for one-off cases:
await PetstoreAPI.getPetById({
params: { petId: 1 },
apiRoot: 'https://staging.example.com',
init: { headers: { Authorization: `Bearer ${token}` } },
});
Never embed API secrets in browser bundle. Keep authorized calls server-side (server components, route handlers, server actions, controllers, services), or proxy through your own Vovk segment + add auth header there.
Per-mixin fetcher and AJV tuning
For auth needing dynamic logic (token refresh, signing), use custom fetcher scoped to mixin's segment. Fetcher runs request, performs client-side validation, prepares headers — see rpc skill for full contract.
outputConfig: {
segments: {
petstore: {
openAPIMixin: { /* ... */ },
imports: { fetcher: './src/lib/petstoreFetcher' },
},
},
},
Third-party specs often include non-standard keywords that trip AJV's strict mode. Loosen globally:
libs: {
/** @type {import('vovk-ajv').VovkAjvConfig} */
ajv: { options: { strict: false } },
},
Client-side validation opt-out per call:
await PetstoreAPI.getPetById({
params: { petId: 1 },
disableClientValidation: true,
});
Type inference and the Mixins namespace
Mixin
Content truncated.