Socket
Book a DemoInstallSign in
Socket

openapi-schema-validator

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-schema-validator

A validator for OpenAPI documents.

latest
Source
npmnpm
Version
12.1.3
Version published
Weekly downloads
226K
-4.33%
Maintainers
1
Weekly downloads
 
Created

What is openapi-schema-validator?

The openapi-schema-validator npm package is used to validate OpenAPI (formerly known as Swagger) schemas. It ensures that the OpenAPI documents adhere to the OpenAPI Specification, which is crucial for API documentation, client generation, and server stub generation.

What are openapi-schema-validator's main functionalities?

Validate OpenAPI Schema

This feature allows you to validate an OpenAPI schema against the OpenAPI Specification. The code sample demonstrates how to create a validator instance, validate a sample schema, and handle validation errors.

const OpenAPISchemaValidator = require('openapi-schema-validator').default;

const schema = {
  openapi: '3.0.0',
  info: {
    title: 'Sample API',
    version: '1.0.0'
  },
  paths: {}
};

const validator = new OpenAPISchemaValidator({ version: 3 });
const result = validator.validate(schema);

if (result.errors.length > 0) {
  console.error('Schema validation errors:', result.errors);
} else {
  console.log('Schema is valid!');
}

Other packages similar to openapi-schema-validator

Keywords

openapi

FAQs

Package last updated on 24 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts