Skip to content

Instantly share code, notes, and snippets.

@cianclarke
Created August 23, 2016 15:07
Show Gist options
  • Save cianclarke/60c64418bebd96990da4b573c78ccbda to your computer and use it in GitHub Desktop.
Save cianclarke/60c64418bebd96990da4b573c78ccbda to your computer and use it in GitHub Desktop.
API blueprint to Swagger in application.js
// first npm install --save apib2swagger
var apib2swagger = require('apib2swagger');
var fs = require('fs');
app.get('/api.json', function(req, res){
fs.readFile('./README.md', function(err, file){
if (err){
return res.status(500).json(err);
}
apib2swagger.convert(file.toString(), function(err, converted){
if (err){
return res.status(500).json(err);
}
return res.json(converted.swagger);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment