@readme/openapi-schemas
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

@readme/openapi-schemas

Build

This package contains the official JSON Schemas for every version of Swagger/OpenAPI Specification:

Version Schema Docs
Swagger 1.2 v1.2 schema v1.2 docs
Swagger 2.0 v2.0 schema v2.0 docs
OpenAPI 3.0.x v3.0.x schema v3.0.3 docs
OpenAPI 3.1.x v3.1.x schema v3.1.0 docs

Installation

You can install OpenAPI Schemas via npm.

npm install @readme/openapi-schemas

Usage

The library contains all OpenAPI Specification versions:

import { openapi } from '@readme/openapi-schemas';

console.log(openapi.v1); // { $schema, id, properties, definitions, ... }
console.log(openapi.v2); // { $schema, id, properties, definitions, ... }
console.log(openapi.v3); // { $schema, id, properties, definitions, ... }
console.log(openapi.v31); // { $schema, id, properties, definitions, ... }

You can use a JSON Schema validator such as Z-Schema or AJV to validate OpenAPI definitions against the specification.

import { openapi } from '@readme/openapi-schemas';
import ZSchema from 'z-schema';

// Create a ZSchema validator
let validator = new ZSchema();

// Validate an OpenAPI definition against the OpenAPI v3.0 specification
validator.validate(openapiDefinition, openapi.v31);

Package Sidebar

Install

npm i @readme/openapi-schemas

Weekly Downloads

139,465

Version

3.1.0

License

MIT

Unpacked Size

1.1 MB

Total Files

9

Last publish

Collaborators

  • llimllib
  • darrenyong
  • gratcliff
  • dannobytes
  • gkoberger
  • domharrington
  • mjcuva
  • kanadgupta
  • jonursenbach
  • rafegoldberg
  • dashron
  • iliast