
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@contractkit/openapi-to-ck
Advanced tools
Convert OpenAPI specs (2.0/3.0/3.1) to Contract Kit .ck files
Convert OpenAPI specs (2.0, 3.0, 3.1) into ContractKit .ck files. Useful for adopting ContractKit in projects that already have an OpenAPI document, or for round-tripping a spec through CK.
pnpm add -D @contractkit/openapi-to-ck
When the package is installed, the @contractkit/cli binary picks up an openapi-to-ck subcommand:
contractkit openapi-to-ck --input openapi.yaml --output contracts/
| Flag | Description |
|---|---|
--input <path> | Path to an OpenAPI YAML or JSON file. |
--output <dir> | Directory to write .ck files into. |
--split <single | by-tag> | Output mode. by-tag (default) writes one file per OpenAPI tag; single writes one combined file. |
--no-comments | Don't emit OpenAPI descriptions as # comments. |
import { convertOpenApiToCk } from '@contractkit/openapi-to-ck';
const { files, warnings } = await convertOpenApiToCk({
input: 'openapi.yaml', // file path, JSON/YAML string, or pre-parsed object
split: 'by-tag', // 'single' | 'by-tag' (default: 'by-tag')
includeComments: true, // emit OpenAPI descriptions as # comments (default: true)
onWarning: w => console.warn(w),
});
// `files` is a Map<filename, ckSource>
for (const [filename, source] of files) {
await fs.writeFile(filename, source);
}
Warning entries carry a JSON-pointer-style path into the OpenAPI spec, a human-readable message, and a severity of 'info' | 'warn'.
| OpenAPI | .ck |
|---|---|
paths | operation /path: { ... } blocks |
components.schemas | contract Name: { ... } declarations |
parameters (path / query / header) | params: { ... } / query: { ... } / headers: { ... } blocks |
requestBody.content[mime].schema | request: { mime: Type } |
responses[code].content[mime].schema | response: { code: { mime: Type } } |
responses[code].headers | per-status headers: { name: type } |
allOf | & intersection on contract declarations |
oneOf + discriminator | discriminated(by=field, A | B) |
oneOf / anyOf (no discriminator) | | union |
enum, pattern, minimum/maximum, minLength/maxLength | type constraint args |
For tools that want to operate on the intermediate AST rather than emit .ck source:
import {
schemasToModels, // OpenAPI schemas → ContractKit ModelNode[]
pathsToRoutes, // OpenAPI paths → ContractKit OpRouteNode[]
splitByTag, // group routes by OpenAPI tag
mergeIntoSingle, // collapse roots into one
detectCircularRefs, // find $ref cycles
extractRefName, // "#/components/schemas/Foo" → "Foo"
sanitizeName, // turn an arbitrary string into a valid CK identifier
normalize, // upgrade 2.0/3.0 → 3.1 + dereference
astToCk, // ContractKit AST → `.ck` source string
serializeType, // ContractTypeNode → `.ck` type expression
} from '@contractkit/openapi-to-ck';
FAQs
Convert OpenAPI specs (2.0/3.0/3.1) to Contract Kit .ck files
We found that @contractkit/openapi-to-ck demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.