swagger-restify-express
This package will automagically wire your restify and express paths to swagger framework.
Make sure that your REST library is "restify"
npm install restifyvar restify = require('restify')
Include swagger-restify-express in your project.
sre = require('swagger-restify-express')
Have the restify server running
var server = restify.createServer({ name:"My REST server"}); server.pre(restify.pre.userAgentConnection());server.use(restify.bodyParser({ mapParams: false })); server.get('/xxx/:id', function(req, res) { res.send('hello from my REST server ' + req.params.name);}); server.get('/xxx/:id/getit/:here', function(req, res) { res.send('hello from my REST server ' + req.params.name);}); server.post('/offload', someClass.offload); sre.init(server, { resourceName : 'swag', server : 'restify', // or express httpMethods : ['GET', 'POST'], basePath : 'https://yourdomain.com', ignorePaths : { GET : ['path1', 'path2'], POST : ['path1'] } } ) server.listen(3000, function() { console.log('%s listening at %s', server.name, server.url);});
#### Make sure that you add the line, so that the auto wiring is done. ```console sre.init(server, { resourceName : 'swag', server : 'restify', // or express httpMethods : ['GET', 'POST'], basePath : 'https://yourdomain.com', // MANDATORY ignorePaths : { GET : ['path1', 'path2'], POST : ['path1'] } } ) ```
#### Crank up your server ```sh node app.js ```
#### Open up your browser ```sh http://localhost:3000/api-docs.html ```