Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oas-raml-converter

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oas-raml-converter

This package helps to convert between different API specifications. Supports OAS (Swagger 2), RAML 0.8, RAML 1.0.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by10.72%
Maintainers
2
Weekly downloads
 
Created
Source

OAS RAML Converter Build Status Coverage Status npm version

This package helps to convert between different API specifications. It was originally forked from the stoplight.io converter.

Supported Conversions (beta)

Using

1. Online web page

For an online conversion, use: https://mulesoft.github.io/oas-raml-converter.

2. Command line tool

./lib/bin/converter.js --from SWAGGER --to RAML10 ./path/to/swagger.json

Or install globally and then:

oas-raml-converter --from SWAGGER --to RAML10 ./path/to/swagger.json

3. As a service

For a REST API of the converter, you can start it in an express server, checkout the oas-raml-converter-service project.

4. As a dependency

Installation (NodeJS or Browser)
npm install --save oas-raml-converter
Initializing a converter

Raml 1.0 to OAS 2.0:

var converter = require('oas-raml-converter');
var ramlToSwagger = new converter.Converter(converter.Formats.RAML10, converter.Formats.SWAGGER);

OAS 2.0 to Raml 1.0:

var converter = require('oas-raml-converter');
var swaggerToRaml = new converter.Converter(converter.Formats.SWAGGER, converter.Formats.RAML10);

You can tell the converter to detect the input format automatically by passing AUTO format:

var converter = require('oas-raml-converter');
var autoToRaml = new converter.Converter(converter.Formats.AUTO, converter.Formats.RAML10);
Converting from a file or url
swaggerToRaml.convertFile('/path/to/swagger.json').then(function(raml) {
  console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
  console.error(err);
});
Converting from a string or json
var mySwaggerString = '...';
swaggerToRaml.convertData(mySwaggerString).then(function(raml) {
  console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
  console.error(err);
});
Passing options
var options = {
    validate: false, // Parse both input and output to check that its a valid document
    validateImport: false, // Only validate input
    validateExport: false, // Only validate output
    format: 'yaml', // Output format: json (default for OAS) or yaml (default for RAML)
    fs: { ... } // Use a custom file system solver (not yet available)
};

swaggerToRaml.convertFile('/path/to/swagger.json', options).then(function(raml) {
  console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
  console.error(err);
});

Contributing

Contributions are welcome! Please check the current issues to make sure what you are trying to do has not already been discussed.

Steps

  1. Fork.
  2. Make changes.
  3. Write tests.
  4. Send a pull request.

Develop

Install dependencies:

npm install

Run tests:

npm test

Run eslint to check linting errors:

npm run eslint

FAQs

Package last updated on 21 Jan 2017

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