openapi-types

Type-safe TypeScript definitions for OpenAPI 2.0, 3.0, and 3.1 specification documents, covering paths, schemas, and components.

Library
npm
v12.1.3
921 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
46 /100 Fair
Development Activity 0
Maintenance 20
Community 76
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
60 /100 Good
Architecture 88
Code Quality 45
Innovation 68
Learning Curve 40

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

TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,924

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
TypeScript
70%
Other

Budibase

Low Code Platforms · No Code Platforms

28,324

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 70%
Svelte 26%
Updated 1 weeks ago
Java
48%
Apache 2.0

ClearFlask

Community · Product Management

451

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
62
Dependency
Built with
Java 48%
TypeScript 47%
Updated 6 days ago
TypeScript
92%
MIT

Dittofeed

Automation · Marketing

2,968

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 months ago
TypeScript
100%
Other

Dub

Analytics · Marketing

24,835

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
81
Repo Health
78
Technical
62
Dependency
Built with
TypeScript 100%
Updated 4 days ago
TypeScript
90%
Other

FastGPT

AI Agents · AI Development

29,758

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 90%
Updated 4 days ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,787

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 75%
Updated 4 days ago
TypeScript
94%
Apache 2.0

flue

AI Agents · Developer Tools

8,383

Build autonomous AI agents and powerful workflows with a programmable TypeScript harness that gives any model sessions, tools, sandboxes, and durable execution.

View details
80
Repo Health
82
Technical
70
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
TypeScript
48%
AGPL 3.0

Grafana

Analytics · Monitoring

76,962

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript 48%
Go 46%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers