Skip to content

Commit fea32b5

Browse files
Cleanup README.md
1 parent 535b66d commit fea32b5

File tree

1 file changed

+6
-246
lines changed

1 file changed

+6
-246
lines changed

README.md

+6-246
Original file line numberDiff line numberDiff line change
@@ -1,255 +1,15 @@
1-
{swagger-express}
2-
=========
1+
# swaggger-jsdoc
32

4-
# Notes
5-
* YAML does not like tabs. Do no use them in the Swagger JSDoc comments!!!
3+
**swagger-jsdoc** enables to integrate [Swagger](http://swagger.io) using JSDoc.
64

7-
[Swagger](https://developers.helloreverb.com/swagger/) is a specification and complete framework
8-
implementation for describing, producing, consuming, and visualizing RESTful web services.
9-
View [demo](http://petstore.swagger.wordnik.com/).
5+
## Supported Swagger Versions
6+
* 2.0
107

11-
__{swagger-express}__ is a simple and clean solution to integrate swagger with express.
8+
## Install
129

13-
## Installation
14-
15-
$ npm install swagger-express
1610

1711
## Quick Start
1812

19-
Configure {swagger-express} as express middleware.
20-
21-
22-
`apiVersion` -> Your api version.
23-
24-
`swaggerVersion` -> Swagger version.
25-
26-
`swaggerUI` -> Where is your swagger-ui?
27-
28-
`swaggerURL` -> Path to use for swagger ui web interface.
29-
30-
`swaggerJSON` -> Path to use for swagger ui JSON.
31-
32-
`basePath` -> The basePath for swagger.js
33-
34-
`info` -> [Metadata][info] about the API
35-
36-
`apis` -> Define your api array.
37-
38-
`middleware` -> Function before response.
39-
40-
```
41-
var swagger = require('swagger-express');
42-
43-
app.configure(function(){
44-
...
45-
app.use(swagger.init(app, {
46-
apiVersion: '1.0',
47-
swaggerVersion: '1.0',
48-
swaggerURL: '/swagger',
49-
swaggerJSON: '/api-docs.json',
50-
swaggerUI: './public/swagger/',
51-
basePath: 'http://localhost:3000',
52-
info: {
53-
title: 'swagger-express sample app',
54-
description: 'Swagger + Express = {swagger-express}'
55-
},
56-
apis: ['./api.js', './api.yml'],
57-
middleware: function(req, res){}
58-
}));
59-
app.use(app.router);
60-
...
61-
});
62-
```
63-
64-
[info]: https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object
65-
66-
## Read from jsdoc
67-
68-
Example 'api.js'
69-
70-
```js
71-
72-
/**
73-
* @swagger
74-
* resourcePath: /api
75-
* description: All about API
76-
*/
77-
78-
/**
79-
* @swagger
80-
* path: /login
81-
* operations:
82-
* - httpMethod: POST
83-
* summary: Login with username and password
84-
* notes: Returns a user based on username
85-
* responseClass: User
86-
* nickname: login
87-
* consumes:
88-
* - text/html
89-
* parameters:
90-
* - name: username
91-
* description: Your username
92-
* paramType: query
93-
* required: true
94-
* dataType: string
95-
* - name: password
96-
* description: Your password
97-
* paramType: query
98-
* required: true
99-
* dataType: string
100-
*/
101-
exports.login = function (req, res) {
102-
var user = {};
103-
user.username = req.param('username');
104-
user.password = req.param('password');
105-
res.json(user);
106-
}
107-
108-
/**
109-
* @swagger
110-
* models:
111-
* User:
112-
* id: User
113-
* properties:
114-
* username:
115-
* type: String
116-
* password:
117-
* type: String
118-
*/
119-
```
120-
121-
## Read from yaml file
122-
123-
Example 'api.yml'
124-
125-
```yml
126-
resourcePath: /api
127-
description: All about API
128-
apis:
129-
130-
- path: /login
131-
operations:
132-
133-
- httpMethod: POST
134-
summary: Login with username and password
135-
notes: Returns a user based on username
136-
responseClass: User
137-
nickname: login
138-
consumes:
139-
- text/html
140-
parameters:
141-
142-
- name: username
143-
dataType: string
144-
paramType: query
145-
required: true
146-
description: Your username
147-
148-
- name: password
149-
dataType: string
150-
paramType: query
151-
required: true
152-
description: Your password
153-
154-
models:
155-
User:
156-
id: User
157-
properties:
158-
username:
159-
type: String
160-
password:
161-
type: String
162-
```
163-
164-
## Read from jsdoc
165-
166-
Example 'api.coffee'
167-
168-
```coffee
169-
170-
###
171-
* @swagger
172-
* resourcePath: /api
173-
* description: All about API
174-
###
175-
176-
###
177-
* @swagger
178-
* path: /login
179-
* operations:
180-
* - httpMethod: POST
181-
* summary: Login with username and password
182-
* notes: Returns a user based on username
183-
* responseClass: User
184-
* nickname: login
185-
* consumes:
186-
* - text/html
187-
* parameters:
188-
* - name: username
189-
* description: Your username
190-
* paramType: query
191-
* required: true
192-
* dataType: string
193-
* - name: password
194-
* description: Your password
195-
* paramType: query
196-
* required: true
197-
* dataType: string
198-
###
199-
200-
###
201-
* @swagger
202-
* models:
203-
* User:
204-
* id: User
205-
* properties:
206-
* username:
207-
* type: String
208-
* password:
209-
* type: String
210-
###
211-
```
212-
213-
214-
## Examples
215-
216-
Clone the {swagger-express} repo, then install the dev dependencies:
217-
218-
$ git clone git://github.com/fliptoo/swagger-express.git --depth 1
219-
$ cd swagger-express
220-
$ npm install
221-
222-
and run the example:
223-
224-
$ cd example
225-
$ node app.js
226-
227-
# Credits
228-
229-
- [Express](https://github.com/visionmedia/express)
230-
- [swagger-jack](https://github.com/feugy/swagger-jack)
231-
232-
## License
233-
234-
(The MIT License)
235-
236-
Copyright (c) 2013 Fliptoo <fliptoo.studio@gmail.com>
237-
238-
Permission is hereby granted, free of charge, to any person obtaining
239-
a copy of this software and associated documentation files (the
240-
'Software'), to deal in the Software without restriction, including
241-
without limitation the rights to use, copy, modify, merge, publish,
242-
distribute, sublicense, and/or sell copies of the Software, and to
243-
permit persons to whom the Software is furnished to do so, subject to
244-
the following conditions:
24513

246-
The above copyright notice and this permission notice shall be
247-
included in all copies or substantial portions of the Software.
14+
## Example App
24815

249-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
250-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
251-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
252-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
253-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
254-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
255-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)