Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

sails-swaggify

0.0.2 • Public • Published

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

npm version dependencies Build Status Pledge To Arupex!

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
            ]

        }
    }
};

install

npm i sails-swaggify

Downloadsweekly downloads

3

version

0.0.2

license

UNLICENSED

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability