Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trailsjs/sails-swagger
Swagger integration for sails.js
https://github.com/trailsjs/sails-swagger
Last synced: 12 days ago
JSON representation
Swagger integration for sails.js
- Host: GitHub
- URL: https://github.com/trailsjs/sails-swagger
- Owner: trailsjs
- Created: 2015-05-01T06:17:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-12T13:36:46.000Z (almost 8 years ago)
- Last Synced: 2024-04-23T05:46:21.197Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 63.5 KB
- Stars: 104
- Watchers: 8
- Forks: 47
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sails-swagger
[![NPM version][npm-image]][npm-url]
[![Build status][ci-image]][ci-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Code Climate][codeclimate-image]][codeclimate-url][swagger.io](http://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
```sh
$ npm install sails-swagger --save
```## Configuration
```js
// 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](http://localhost:1337/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
[](http://langa.io)[sails-version-image]: https://goo.gl/gTUV5x
[sails-url]: http://sailsjs.org
[npm-image]: https://img.shields.io/npm/v/sails-swagger.svg?style=flat
[npm-url]: https://npmjs.org/package/sails-swagger
[ci-image]: https://img.shields.io/travis/langateam/sails-swagger/master.svg?style=flat
[ci-url]: https://travis-ci.org/langateam/sails-swagger
[daviddm-image]: http://img.shields.io/david/langateam/sails-swagger.svg?style=flat
[daviddm-url]: https://david-dm.org/langateam/sails-swagger
[codeclimate-image]: https://img.shields.io/codeclimate/github/langateam/sails-swagger.svg?style=flat
[codeclimate-url]: https://codeclimate.com/github/langateam/sails-swagger