API Spec Transformer
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.
Note
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.
Installation
NodeJS or Browser
npm install --save api-spec-transformer
Usage
Convert RAML1.0 to OAS (Swagger), from a file.
var transformer = ; var ramlToSwagger = transformerFormatsRAML10 transformerFormatsSWAGGER; ramlToSwagger;
Convert OAS (Swagger) to RAML1.0, from a URL.
var transformer = ; // Convert swagger to raml, from a url. var swaggerToRaml = transformerFormatsSWAGGER transformerFormatsRAML10; swaggerToRaml;
Convert unknown input to RAML1.0:
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 = ; var myConverter = transformerFormatsAUTO transformerFormatsRAML10; swaggerToRaml;
Load a string:
var transformer = ; var swaggerToRaml = transformerFormatsSWAGGER transformerFormatsRAML10; var mySwaggerString = '...'; swaggerToRaml ;
Supported Conversions
- OAS (Swagger 2) -> RAML 0.8
- OAS (Swagger 2) -> RAML 1.0
- RAML 1.0 -> OAS (Swagger 2)
- RAML 0.8 -> OAS (Swagger 2)
- Postman -> OAS (Swagger 2) * Experimental
- Postman -> RAML 0.8 * Experimental
- Postman -> RAML 1.0 * Experimental
Development
Install dependencies:
npm install
Run tests:
npm test
Run eslint to check linting errors:
gulp lint
Contributing
Contributions are welcome! Please check the current issues to make sure what you are trying to do has not already been discussed.
- Fork.
- Make changes.
- Write tests.
- Send a pull request.