You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

swagger-jsdoc

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-jsdoc - npm Package Compare versions

Comparing version

to
1.1.1

22

package.json
{
"name": "swagger-jsdoc",
"version": "1.1.0",
"version": "1.1.1",
"description": "Generates swagger doc based on JSDoc",

@@ -30,16 +30,16 @@ "main": "index.js",

"dependencies": {
"doctrine": "^0.6.4",
"js-yaml": "^3.3.1",
"swagger-parser": "^2.4.2"
"doctrine": "^0.7.0",
"js-yaml": "^3.4.2",
"swagger-parser": "^3.0.1"
},
"devDependencies": {
"body-parser": "^1.12.4",
"express": "^4.12.4",
"istanbul": "^0.3.14",
"jscs": "^1.13.1",
"mocha": "^2.2.5",
"mocha-jscs": "^1.1.0",
"body-parser": "^1.14.0",
"express": "^4.13.3",
"istanbul": "^0.3.21",
"jscs": "^2.1.1",
"mocha": "^2.3.3",
"mocha-jscs": "^3.0.0",
"mocha-jshint": "^2.2.3",
"supertest": "^1.0.1"
"supertest": "^1.1.0"
}
}

@@ -88,2 +88,89 @@ # swagger-jsdoc

### Re-using Model Definitions
A model may be the same for multiple endpoints (Ex. User POST,PUT responses).
In place of writing (or copy and pasting) the same code into multiple locations,
which can be error prone when adding a new field to the schema. You can define
a model and re-use it across multiple endpoints. You can also reference another
model and add fields.
```javascript
/**
* @swagger
* definition:
* NewUser:
* type: object
* required:
* - username
* - password
* properties:
* username:
* type: string
* password:
* type: string
* format: password
* User:
* allOf:
* - $ref: '#/definitions/NewUser'
* - required:
* - id
* - properties:
* id:
* type: integer
* format: int64
*/
/**
* @swagger
* /users:
* get:
* description: Returns users
* produces:
* - application/json
* responses:
* 200:
* description: users
* schema:
* type: array
* items:
* $ref: '#/definitions/User'
*/
app.get('/users', function(req, res) {
res.json([ {
id: 1,
username: 'jsmith',
}, {1
id: 2,
username: 'jdoe',
} ]);
});
/**
* @swagger
* /users:
* post:
* description: Returns users
* produces:
* - application/json
* parameters:
* - name: user
* description: User object
* in: body
* required: true
* type: string
* schema:
* $ref: '#/definitions/NewUser'
* responses:
* 200:
* description: users
* schema:
* $ref: '#/definitions/User'
*/
app.post('/users', function(req, res) {
// Generate ID
req.body.id = Math.floor(Math.random() * 100) * 1
res.json(req.body);
});
```
## Example App

@@ -101,2 +188,2 @@

The swagger spec will be served at http://localhost:3000/api-docs.json
The swagger spec will be served at http://localhost:3000/api-docs.json