Package Exports
- swagger-converter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (swagger-converter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Swagger Converter
Converts Swagger documents from version
1.xto version2.0
Installation
Use npm
npm install swagger-converter --saveUsage
It's recommended to use command line tools like swagger-tools or swagger-spec-converter for converting your spec. This module will not handle validation and if your spec is not valid can produce invalid spec.
Swagger Converter expects two arguments.
resourceListingis Swagger 1.x entry point file.apiDeclarationsis a map with paths fromresourceListingas keys and resources as values
var swaggerConverter = require('swagger-converter');
var resourceListing = require('/path/to/petstore/index.json');
var apiDeclarations = {
'/pet': require('/path/to/petstore/pet.json'),
'/user': require('/path/to/petstore/user.json'),
'/store': require('/path/to/petstore/store.json')
};
var swagger2Document = swaggerConverter.convert(resourceListing, apiDeclarations);
console.log(JSON.stringify(swagger2Document, null, 2));In browser
Install via Bower
bower install --save swagger-converterInclude the browser.js script in your HTML
<script src="/path/to/swagger-converter/browser.js"></script>Use the script
var swagger2Document = SwaggerConverter.convert(resourceListing, apiDeclarations);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 buildLicense
MIT. See LICENSE