Package Exports
- @hey-api/spec-types
- @hey-api/spec-types/package.json
Readme
Spec Types
TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation.
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
|
|
|
Silver
|
scalar.com |
fastapi.tiangolo.com |
Bronze
|
|
Installation
You can download @hey-api/spec-types from npm using your favorite package manager.
npm
npm add @hey-api/spec-types -D -Epnpm
pnpm add @hey-api/spec-types -D -Eyarn
yarn add @hey-api/spec-types -D -Ebun
bun add @hey-api/spec-types -D -EUsage
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.