Created
August 23, 2016 15:07
-
-
Save cianclarke/60c64418bebd96990da4b573c78ccbda to your computer and use it in GitHub Desktop.
API blueprint to Swagger in application.js
This file contains hidden or 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
// 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