Skip to content

Commit

Permalink
Add preliminary support for Postman
Browse files Browse the repository at this point in the history
  • Loading branch information
gkoberger committed Oct 4, 2016
1 parent 4bf6f73 commit bbcaaac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ exports.category = "services";
exports.desc = "Upload your docs to ReadMe ($)";

exports.run = function(config, info) {
console.log('Uploading Swagger file...');

console.log("You can view your new docs here:");
console.log("");
console.log(" https://swagger.readme.io/preview/" + new Buffer(info.swaggerUrl).toString('base64'));
Expand Down
28 changes: 28 additions & 0 deletions lib/try.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var Swagger2Postman = require('swagger2-to-postman');

exports.swagger = true;
exports.category = "services";
exports.desc = "Open your Swagger file in Postman ($)";

exports.run = function(config, info) {
var swaggerConverter = new Swagger2Postman();
//swaggerConverter.setLogger(console.log); // TODO! Add verbose mode?

var convertResult = swaggerConverter.convert(info.swagger);

if(convertResult.status === "failed") {
console.log("Error converting to Postman!".red);
if(convertResult.message) {
console.log(" " + convertResult.message);
}
return process.exit();
}

console.log("Success!".green + " Here's your Postman collection:");
console.log(JSON.stringify(convertResult.collection, undefined, 2));

console.log("");
console.log("Postman support is in beta.".yellow + " This doesn't quite do much yet, unfortunately!");

process.exit();
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"request": "^2.73.0",
"sinon-chai": "^2.8.0",
"swagger-parser": "^3.4.1",
"swagger2-to-postman": "^1.1.0",
"yamljs": "^0.2.8"
},
"devDependencies": {
Expand Down

0 comments on commit bbcaaac

Please sign in to comment.