Swagger Converter
Swagger Converter converts Swagger documents from version 1.2 to version 2.0
Installation
Use npm
npm install swagger-converter --save
Usage
Swagger Converter expects two arguments.
resourceListing
is Swagger 1.2 entry point file.apiDeclarations
is an array of objects that are listed in resourceListing
var convert = require('swagger-converter');
var fs = require('fs');
var resourceListing = JSON.parse(fs.readFileSync('/path/to/petstore/index.json').toString());
var apiDeclarations = [
JSON.parse(fs.readFileSync('/path/to/petstore/pet.json').toString()),
JSON.parse(fs.readFileSync('/path/to/petstore/user.json').toString()),
JSON.parse(fs.readFileSync('/path/to/petstore/store.json').toString())
];
var swagger2Document = convert(resourceListing, apiDeclarations);
console.log(JSON.stringify(swagger2Document, null, 2));
In browser
Install via Bower
bower install --save swagger-converter
Include the browser.js
script in your HTML
<script src="/path/to/swagger-converter/browser.js"></script>
Use the script
var convert = SwaggerConverter.convert;
Development
Install dependencies with npm install
command and use npm test
to run the test. Tests will fail if you break coding style.
Building for browser
Just run this command to make a new browser.js
npm run build
License
MIT. See LICENSE