sails-swaggify
v0.0.2
Published
creates swagger doc json for your sails routes
Downloads
2
Maintainers
Readme
sails-swaggify
Make Swagger Docs for Sails App in a way that interspects sails routes, but gives you a clean callback function to call in your controller
#Install
npm install sails-swaggify --save
#Usage
#In a Controller
module.exports = {
getSwagger : function(req, res){
SwaggerService.getSwagger(this, res.swagger);
}
};
#In your Routes
/**
* Route Mappings
* @file config/routes.js
* (sails.config.routes)
*
* Your routes map URLs to views and controllers.
*/
module.exports.routes = {
'/': {
view: 'homepage'
},
'get /groups/:id': {
controller: 'GroupController',
action: 'test',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['GET', 'POST'],
summary: ' Get Groups ',
description: 'Get Groups Description',
produces: [
'application/json'
],
tags: [
'Groups'
],
responses: {
'200': {
description: 'List of Groups',
schema: 'Group', // api/model/Group.js,
type: 'array'
}
},
parameters: []
}
},
'put /groups/team': {
controller: 'GroupController',
action: 'test',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['PUT', 'POST'],
summary: 'Update Groups ',
description: 'Update Groups Description',
produces: [
'application/json'
],
tags: [
'Groups'
],
responses: {
'200': {
description: 'Updated Group',
schema: 'Group' // api/model/Group.js
}
},
parameters: [
'Group' // api/model/Group.js
]
}
}
};