You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@apidevtools/swagger-parser

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apidevtools/swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers

12.0.0
latest
Source
npmnpm
Version published
Weekly downloads
2.6M
-0.76%
Maintainers
2
Weekly downloads
 
Created

What is @apidevtools/swagger-parser?

The @apidevtools/swagger-parser npm package is a tool that allows you to parse, validate, and dereference Swagger files (now known as OpenAPI Specifications). It supports Swagger 2.0 and OpenAPI 3.0, providing a way to ensure that API documentation is correct and adheres to the specification standards.

What are @apidevtools/swagger-parser's main functionalities?

Parse and Validate

This feature allows you to parse and validate a Swagger/OpenAPI file, ensuring it is correct and follows the specification.

const SwaggerParser = require('@apidevtools/swagger-parser');

SwaggerParser.validate('path/to/swagger.yaml')
  .then(api => {
    console.log('API name: %s, Version: %s', api.info.title, api.info.version);
  })
  .catch(err => {
    console.error(err);
  });

Dereference

Dereferencing resolves all $ref pointers in the Swagger/OpenAPI document, replacing them with their referenced objects or values.

const SwaggerParser = require('@apidevtools/swagger-parser');

SwaggerParser.dereference('path/to/swagger.yaml')
  .then(api => {
    console.log('Dereferenced API:', api);
  })
  .catch(err => {
    console.error(err);
  });

Bundle

Bundling takes all the separate files that make up a Swagger/OpenAPI document and bundles them into a single file.

const SwaggerParser = require('@apidevtools/swagger-parser');

SwaggerParser.bundle('path/to/swagger.yaml')
  .then(api => {
    console.log('Bundled API:', api);
  })
  .catch(err => {
    console.error(err);
  });

Other packages similar to @apidevtools/swagger-parser

Keywords

swagger

FAQs

Package last updated on 16 Jun 2025

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