swagger-restify-express
v0.2.1
Published
This module will automagically wire your restify and express paths to swagger framework.
Downloads
14
Readme
swagger-restify-express
Make sure that your REST library is "restify"
npm install restify
var 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);
});