JSPM

@readme/openapi-schemas

3.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 234558
  • Score
    100M100P100Q176110F
  • License MIT

JSON Schemas for every version of the OpenAPI Specification

Package Exports

  • @readme/openapi-schemas
  • @readme/openapi-schemas/package.json

Readme

@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);