Socket
Socket
Sign inDemoInstall

swagger2openapi

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger2openapi

Convert Swagger 2.0 definitions to OpenApi 3.0 and validate


Version published
Weekly downloads
1.5M
increased by0.32%
Maintainers
1
Weekly downloads
 
Created

What is swagger2openapi?

The swagger2openapi npm package is designed to convert Swagger 2.0 definitions into OpenAPI 3.0.x, facilitating the transition to the newer OpenAPI specification. It supports both command-line and programmatic usage, making it a versatile tool for developers working with API documentation and specifications.

What are swagger2openapi's main functionalities?

Conversion of Swagger 2.0 to OpenAPI 3.0

This feature allows users to programmatically convert Swagger 2.0 API definitions to OpenAPI 3.0 specifications. The code sample demonstrates how to load a Swagger 2.0 JSON file, convert it, and then log the resulting OpenAPI 3.0 specification.

const converter = require('swagger2openapi');
const swagger = require('./swagger.json');

converter.convertObj(swagger, {}, (err, options) => {
  if (err) {
    console.error(err);
  } else {
    console.log(options.openapi);
  }
});

Validation of converted OpenAPI 3.0 definitions

Beyond conversion, the package also offers validation of the resulting OpenAPI 3.0 definitions. This ensures that the conversion process not only translates the specification but also checks for any inconsistencies or errors in the new format.

const converter = require('swagger2openapi');
const swagger = require('./swagger.json');

converter.convertObj(swagger, {validate: true}, (err, options) => {
  if (err) {
    console.error('Validation error:', err);
  } else {
    console.log('Validation successful. OpenAPI 3.0 output:', options.openapi);
  }
});

Command-line conversion

For users preferring command-line tools, swagger2openapi provides a straightforward way to convert Swagger 2.0 files to OpenAPI 3.0 by specifying the input and output files directly in the terminal.

swagger2openapi swagger.json -o openapi.json

Other packages similar to swagger2openapi

Keywords

FAQs

Package last updated on 17 Jan 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc