openapi-types
Type-safe TypeScript definitions for OpenAPI 2.0, 3.0, and 3.1 specification documents, covering paths, schemas, and components.
Repository Health
Technical Analysis
openapi-types provides a complete set of TypeScript interfaces and namespaces (OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1) that mirror the structure of the OpenAPI and Swagger specifications. It types every part of a document — info blocks, paths, operations, parameters, schemas, security requirements, and components — so tools that read or generate OpenAPI documents get compile-time safety without writing their own type layer.
Maintained as one package inside the kogosoftwarellc/open-api monorepo (alongside express-openapi and related tooling), it has become the de facto standard for typing OpenAPI documents in the Node/TypeScript ecosystem, pulling in tens of millions of weekly downloads.
What You Get
- Version-specific namespaces — OpenAPIV2, OpenAPIV3, and OpenAPIV3_1 each fully model their respective specification version
- A version-agnostic OpenAPI namespace with union types (Document, Operation, Parameter) for code that needs to handle any spec version
- Complete coverage of specification objects — paths, operations, parameters, schemas, responses, security schemes, servers, and components
- Zero runtime footprint — pure type declarations with no bundled JavaScript logic to execute or maintain
Common Use Cases
- Typing the input/output of OpenAPI parsers and validators (e.g. swagger-parser, express-openapi) so consumers get IntelliSense on spec documents
- Building code generators that read an OpenAPI document and emit clients, servers, or mock data
- Writing custom middleware that inspects request-scoped OpenAPI metadata (route, operation, schema) in a type-safe way
- Authoring or transforming OpenAPI documents programmatically instead of by hand-editing YAML/JSON
Under The Hood
Architecture
The entire package is a single 918-line index.ts organized into four namespaces: OpenAPIV2, OpenAPIV3, and OpenAPIV3_1 each independently model one specification version’s object graph, while the top-level OpenAPI namespace layers version-spanning union types (Document, Operation, Parameter) over the other three. Rather than redefining every OpenAPIV3_1 type from scratch, the 3.1 namespace builds on the 3.0 namespace through Modify/Omit/Pick mapped-type transformations, expressing only what changed between spec versions — a deliberate reuse pattern that keeps the three version namespaces from drifting apart. There is no other source layout to speak of: tsconfig.json restricts compilation to this one file, and the shared bin/tsc wrapper (used by every package in the monorepo) compiles it to a declaration-only dist/ output.
Tech Stack
The package has zero runtime dependencies — package.json declares none — and is built with TypeScript 4.7.2 in strict mode via the monorepo’s shared bin/tsc wrapper, targeting CommonJS with declaration and source-map output enabled. It is one workspace inside a Lerna-orchestrated monorepo (kogosoftwarellc/open-api) alongside sibling packages like express-openapi and koa-openapi, and is published independently to npm through lerna publish.
Code Quality
No test files exist for this package specifically — correctness rests entirely on the TypeScript compiler’s strict-mode checking rather than on unit tests, which is a meaningfully weaker guarantee for a types-only package since there’s no way to assert at build time that a given type actually matches real-world OpenAPI documents. The monorepo does wire up mocha/chai/nyc/istanbul and tslint+prettier repo-wide for its runtime packages, but that tooling isn’t exercised against openapi-types itself. Naming is consistent throughout, mirroring the official OpenAPI specification vocabulary object-for-object (ParameterObject, SchemaObject, ComponentsObject), which makes the types easy to cross-reference against the spec.
API Design The split between version-specific namespaces and a version-agnostic union namespace is a considered design choice: consumers who know they’re working with one spec version get precise types (OpenAPIV3.Document), while consumers that must accept any version get OpenAPI.Document without extra runtime cost. A generic parameter on Document<T> lets consumers type vendor extensions (like x-amazon-apigateway-integration) instead of losing type safety on custom fields. Adoption requires zero boilerplate — a single named import — though the pattern itself (a types-only package mirroring an external spec) is standard practice rather than a novel approach.
Used by 25 apps in this directory
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Kibana
Analytics · Monitoring
Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.
LibreChat
AI Assistants · Developer Tools
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
Logto
Authentication
Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC
medusa
Ecommerce
The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.
n8n
Automation · No Code Platforms
Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.
NocoBase
Low Code Platforms · No Code Platforms
Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.
openwork
AI Assistants · Automation
OpenWork is a free, open-source desktop app for running AI agent workflows on your own files with 50+ LLMs, extensible skills, and MCP server support — the open-source alternative to Claude Cowork and Codex.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.