openapi-typescript
$ openapi-typescript Community Low Riskopenapi-typescript converts OpenAPI 3.0 and 3.1 YAML/JSON specs into pure, zero-runtime TypeScript .d.ts definitions. It prints to stdout by default when -o is omitted, and provides --check for read-only CI verification that generated types match the current schema.
npm install -g openapi-typescript Deterministic local TypeScript codegen from OpenAPI files via openapi-typescript belongs directly in build scripts rather than MCP.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Clean non-interactive execution with stdout default, -o explicit output, --check verification mode, and clear exit codes, though diagnostics are plain text.
--checkexits non-zero when generated types are stale- Writes to stdout unless
-ois explicitly passed
Purely local type generation by default; --check and omitted -o never write to disk.
- Non-mutating
--checkmode and explicit-ooutput path
Available everywhere Node.js runs via npm or npx openapi-typescript with fast startup.
- Zero-config execution via
npx openapi-typescript
Produces clean, zero-runtime .d.ts types that pair directly with openapi-fetch and TypeScript tsc checks.
- Full OpenAPI 3.0 and 3.1 support without heavy runtime wrappers
Active open-source project (openapi-ts/openapi-typescript) under MIT.
- Active
openapi-tsorganization on GitHub
Crisp official CLI documentation at openapi-ts.dev/cli.
- Official docs at openapi-ts.dev/cli
Security, Auth & Guardrails
None required for local specs; optional auth headers can be configured in redocly.yaml for remote specs.
100% free and MIT open-source.
# openapi-typescript Agent Rules - Use `--check` first to verify whether generated `.d.ts` files are already in sync. - Always pass `-o <path>` when updating files so generated TypeScript is written deterministically instead of dumped to stdout.
Agent-Ready Command Recipes
Safe Read-Only Queries
openapi-typescript schema.yaml -o src/api/schema.d.ts --check
Reads schema.yaml and exits non-zero if src/api/schema.d.ts is out of date, without writing files.
Controlled Writes & Previews
openapi-typescript schema.yaml -o src/api/schema.d.ts
Writes updated zero-runtime OpenAPI TypeScript declarations to src/api/schema.d.ts.
Strengths for Agents
- +
--checkflag gives agents a reliable read-only staleness check for generated types. - + Outputs to stdout by default and only writes files when
-ois provided. - + Generates zero-runtime TypeScript types with full OpenAPI 3.1 support.
Caveats & Pitfalls
- ! Only generates TypeScript types, not runtime HTTP client functions (pair with
openapi-fetchor useorval). - ! Does not support Swagger 2.0 directly without converting to OpenAPI 3.