Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
api-spec-transformer
Advanced tools
This package helps to convert between different API specifications. Supports OAS (Swagger 2), RAML 0.8, RAML 1.0, and Postman collections.
This package helps to convert between different API specifications. It currently supports OAS (Swagger 2), RAML 0.8, RAML 1.0, and Postman collections.
This package is used in production @ https://stoplight.io. If you are using this package in production, please let us know and we will link you.
A prior version of this library was available, but not published on NPM. If you are directly referencing the git URL in your package.json files, please update them to use the api-spec-transformer
package name, instead of https://github.com/stoplightio/api-spec-converter
. We will be re-naming the git repository to https://github.com/stoplightio/api-spec-transformer
in the near future.
npm install --save api-spec-transformer
var transformer = require('api-spec-transformer');
var ramlToSwagger = new transformer.Converter(transformer.Formats.RAML10, transformer.Formats.SWAGGER);
ramlToSwagger.loadFile('/source/raml.yaml', function(err) {
if (err) {
console.log(err.stack);
return;
}
ramlToSwagger.convert('yaml')
.then(function(convertedData) {
// convertedData is swagger YAML string
})
.catch(function(err){
console.log(err);
});
});
var transformer = require('api-spec-transformer');
// Convert swagger to raml, from a url.
var swaggerToRaml = new transformer.Converter(transformer.Formats.SWAGGER, transformer.Formats.RAML10);
swaggerToRaml.loadFile('http://petstore.swagger.io/v2/swagger.json', function(err) {
if (err) {
console.log(err.stack);
return;
}
swaggerToRaml.convert('yaml')
.then(function(convertedData) {
// convertedData is a raml YAML string
})
.catch(function(err){
console.log(err);
});
});
You can tell the converter to detect the input format automatically (by passing AUTO
format), it will detect the right format for the input.
var transformer = require('api-spec-transformer');
var myConverter = new transformer.Converter(transformer.Formats.AUTO, transformer.Formats.RAML10);
swaggerToRaml.loadFile('http://petstore.swagger.io/v2/swagger.json', function(err) {
// Will identify the input as swagger - the rest is the same as above.
});
var transformer = require('api-spec-transformer');
var swaggerToRaml = new transformer.Converter(transformer.Formats.SWAGGER, transformer.Formats.RAML10);
var mySwaggerString = '...';
swaggerToRaml.loadData(mySwaggerString)
.then(function() {
// Do the converstion, as in the first two examples.
});
Install dependencies:
npm install
Run tests:
npm test
Run eslint to check linting errors:
gulp lint
Contributions are welcome! Please check the current issues to make sure what you are trying to do has not already been discussed.
FAQs
This package helps to convert between different API specifications. Supports OAS (Swagger 2), RAML 0.8, RAML 1.0, and Postman collections.
The npm package api-spec-transformer receives a total of 69 weekly downloads. As such, api-spec-transformer popularity was classified as not popular.
We found that api-spec-transformer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.