JSPM

  • Created
  • Published
  • Downloads 518559
  • Score
    100M100P100Q191408F
  • License MIT

📃 TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation.

Package Exports

  • @hey-api/spec-types
  • @hey-api/spec-types/package.json

Readme

Hey API presents openapi-ts

Spec Types

TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation.

DevTrends badge for @hey-api/spec-types DevTrends badge for @hey-api/spec-types CI status GitHub stars MIT License

Manual  •  Issues  •  Contribute

About

TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation.

Part of the Hey API ecosystem.

Features

  • OpenAPI 2.0 (Swagger), 3.0, and 3.1 specifications
  • JSON Schema Draft 4 and Draft 2020-12
  • inline JSDoc on every property
  • zero runtime footprint, types only

Contributing

Want to see your code in products used by millions?

Start with our Contributing guide and release your first feature.

Sponsors

Hey API is sponsor-funded. If you rely on Hey API in production, consider becoming a sponsor to accelerate the roadmap.

Gold

Stainless logo
Best-in-class developer interfaces for your API.
stainless.com

Opencode logo
The open source coding agent.
opencode.ai

Silver

Scalar logo
scalar.com
FastAPI logo
fastapi.tiangolo.com

Bronze

Kinde logo Cella logo

Installation

You can download @hey-api/spec-types from npm using your favorite package manager.

npm

npm add @hey-api/spec-types -D -E

pnpm

pnpm add @hey-api/spec-types -D -E

yarn

yarn add @hey-api/spec-types -D -E

bun

bun add @hey-api/spec-types -D -E

Usage

OpenAPI

Hover over any property to see its definition from the specification.

import type { OpenAPIV3_1 } from '@hey-api/spec-types';

const doc = {
  openapi: '3.1.2',
  info: {
    title: 'My OpenAPI document',
    version: '1.0.0',
  },
} satisfies OpenAPIV3_1.Document;

JSON Schema

Full type coverage for Draft 4 and Draft 2020-12 schemas.

import type { JSONSchemaDraft2020_12 } from '@hey-api/spec-types';

const doc = {
  properties: {
    foo: {
      type: 'string',
    },
  },
  type: 'object',
} satisfies JSONSchemaDraft2020_12.Document;

License

Released under the MIT License.