swagger-jsdoc
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12146
188
+ Addedcall-me-maybe@1.0.2(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddoctrine@0.7.2(transitive)
+ Addedes6-promise@3.3.14.2.8(transitive)
+ Addedformat-util@1.0.5(transitive)
+ Addedjson-schema-ref-parser@1.4.1(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedono@2.2.54.0.11(transitive)
+ Addedswagger-methods@1.0.8(transitive)
+ Addedswagger-parser@3.4.2(transitive)
+ Addedswagger-schema-official@2.0.0-bab6bed(transitive)
+ Addedvalidator@10.11.0(transitive)
+ Addedz-schema@3.25.1(transitive)
- Removeddoctrine@0.6.4(transitive)
- Removedlodash@3.10.1(transitive)
- Removedswagger-parser@2.5.0(transitive)
- Removedswagger-schema-official@2.0.0-96305d9(transitive)
- Removedtv4@1.3.0(transitive)
Updateddoctrine@^0.7.0
Updatedjs-yaml@^3.4.2
Updatedswagger-parser@^3.0.1