• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swagger integration for sails.js

sails-swagger

NPM version Build status Dependency Status Code Climate

swagger.io (v2.0) hook for Sails. The application's models, controllers, and routes are aggregated and transformed into a Swagger Document. Supports the Swagger 2.0 specification.

Install

$ npm install sails-swagger --save

Configuration

// config/swagger.js
module.exports.swagger = {
  /**
   * require() the package.json file for your Sails app.
   */
  pkg: require('../package'),
  ui: {
    url: 'http://swagger.balderdash.io'
  }
};

Usage

After installing and configuring swagger, you can find the docs output on the /swagger/doc route.

You may also specify additional swagger endpoints by specifying the swagger spec in config/routes.js

/**
 * Route Mappings
 * @file config/routes.js
 * (sails.config.routes)
 *
 * Your routes map URLs to views and controllers.
 */

module.exports.routes = {

    /***************************************************************************
     *                                                                          *
     * Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, *
     * etc. depending on your default view engine) your home page.              *
     *                                                                          *
     * (Alternatively, remove this and add an `index.html` file in your         *
     * `assets` directory)                                                      *
     *                                                                          *
     ***************************************************************************/

    '/': {
        view: 'homepage'
    },

    /***************************************************************************
     *                                                                          *
     * Custom routes here...                                                    *
     *                                                                          *
     * If a request to a URL doesn't match any of the custom routes above, it   *
     * is matched against Sails route blueprints. See `config/blueprints.js`    *
     * for configuration options and examples.                                  *
     *                                                                          *
     ***************************************************************************/
    '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/:id': {
        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
            ]

        }
    }
};


License

MIT

Maintained By

More Repositories

1

trails

🌲 Modern Web Application Framework for Node.js.
JavaScript
1,665
star
2

sails-permissions

Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.
JavaScript
418
star
3

sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
JavaScript
265
star
4

trailpack-hapi

📦 Hapi.js Trailpack
JavaScript
19
star
5

doc

📚 Trails.js Documentation
CSS
18
star
6

trailpack

📦 Trailpack Module. All Trailpacks include and inherit this module.
JavaScript
17
star
7

trails-example-app

📗 An example Trails App
JavaScript
14
star
8

trailpack-router

📦 Router. Aggregate and Configure Application Routes.
JavaScript
11
star
9

trailpack-webpack

📦 Webpack Trailpack.
JavaScript
11
star
10

blaze

🔥 Blaze Trails. Create Views automatically from your Models (uses React.js)
10
star
11

trailpack-waterline

📦 Waterline.js Trailpack
JavaScript
8
star
12

trailpack-mongoose

📦 Mongoose.js Trailpack http://mongoosejs.com
JavaScript
8
star
13

trailpack-repl

📦 REPL Trailpack
JavaScript
8
star
14

generator-trailpack

JavaScript
7
star
15

trailpack-sails

📦 Run a Sails.js Application with Trails.
JavaScript
7
star
16

trailpack-microservices

📦 Microservices Trailpack
6
star
17

trailpack-auth

6
star
18

trailpack-swagger

📦 Swagger Trailpack
JavaScript
6
star
19

trailpack-footprints

📦 Footprints Trailpack
JavaScript
6
star
20

trailpack-core

📦 Core Trailpack
JavaScript
6
star
21

trailpack-sequelize

📦 Sequelize.js Trailpack http://sequelizejs.com
JavaScript
5
star
22

eslint-config-trails

:shipit: Trails ESLint Configuration
JavaScript
5
star
23

trailpack-realtime

📦 Realtime Trailpack. Synchronize the client and server via WebSockets
JavaScript
5
star
24

trailpack-autoreload

📦 Reload Trails on Code Changes
JavaScript
5
star
25

trailpack-knex

📦 Knex.js Trailpack
JavaScript
4
star
26

trailpack-bookshelf

📦 Bookshelf.js Trailpack
JavaScript
4
star
27

trailpack-permissions

4
star
28

trailpack-koa

📦 Koa Trailpack
JavaScript
3
star
29

trailpack-bootstrap

📦 bootstrap Trailpack (run a custom startup function in Trails)
JavaScript
3
star
30

smokesignals

🔥 Utilities for testing Trails Applications and Trailpacks
JavaScript
3
star
31

trailpack-tasker

📦 Easily set up background workers with a Message Broker (e.g. RabbitMQ, Kafka)
JavaScript
3
star
32

trailpack-cache

📦 Cache Trailpack
JavaScript
3
star
33

trailpack-fixtures

📦 Fixtures Trailpack. Prime the datastore with an initial dataset.
3
star
34

trailpack-elasticsearch

📦 Elasticsearch Trailpack
JavaScript
3
star
35

art

Trails Branding Materials
2
star
36

trailpack-markdown-doc

📦 Trailpack for Markdown Doc Bundler
JavaScript
2
star
37

trailpack-webserver

📦 Parent to the Web Server Trailpacks (hapi, koa, express4, etc)
JavaScript
2
star
38

trailpack-rethinkdb

Trailspack for https://rethinkdb.com
1
star
39

trails-relay-react-todomvc

TodoMVC Example using Trails, GraphQL, Relay, and React.js
1
star
40

trails-model

🌐 Trails Model Class
JavaScript
1
star
41

generator-util

Trails Generator Utilities
JavaScript
1
star
42

trailsjs.io

🌲 Trails website hosted on Trails
JavaScript
1
star
43

trailpack-typescript

1
star
44

trailpack-agenda

Trailpack for Agenda Job Scheduler - https://github.com/rschmukler/agenda
JavaScript
1
star
45

trailpack-winston

📦 Winston Logging Trailpack
JavaScript
1
star
46

trailsjs.github.io

📚 Trails Website
HTML
1
star
47

trails-todo-app

A todo list app built using Trails and React.js
JavaScript
1
star
48

trailpack-pubsub

Redis Pub/Sub implementation for Trails.js app
JavaScript
1
star
49

org

1
star
50

trailpack-datastore

📦 Parent to the Datastore Trailpacks (waterline, bookshelf, sequelize, etc)
JavaScript
1
star
51

trails-file-upload-example

Describes how to upload files using Trails.
JavaScript
1
star