-
-
Save lordlycastle/e5e3f01f25831039e88d39b1aa63a5a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
Converter = require('swagger2-postman2-converter'); | |
function handleConversion(originalFileName, newFileName) { | |
// read the local swagger file | |
var swaggerObject = JSON.parse( | |
fs.readFileSync(originalFileName, 'utf8') | |
); | |
// convert Swagger 2.0 to Postman 2.0 | |
var conversionResult = Converter.convert(swaggerObject); | |
// create a new local file in Postman v2.0 format | |
fs.writeFileSync(newFileName, JSON.stringify(conversionResult.collection, null, 2)); | |
console.log('Converted ' + originalFileName + ' to ' + newFileName); | |
} | |
handleConversion(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment