-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
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
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
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(); | ||
}; |
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