Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 1.0.0 to 1.1.0

.editorconfig

42

lib/index.js

@@ -67,2 +67,23 @@ /** @module index */

/**
* Merges two objects
* @function
* @param {object} obj1 - Object 1
* @param {object} obj2 - Object 2
* @returns {object} Merged Object
*/
function objectMerge(obj1, obj2) {
var obj3 = {};
for (var attr in obj1) {
if (obj1.hasOwnProperty(attr)) {
obj3[attr] = obj1[attr];
}
}
for (var name in obj2) {
if (obj2.hasOwnProperty(name)) {
obj3[name] = obj2[name];
}
}
return obj3;
}

@@ -79,6 +100,21 @@ /**

var propertyNames = Object.getOwnPropertyNames(pathObject);
for (var j = 0; j < propertyNames.length; j = j + 1) {
var propertyName = propertyNames[j];
swaggerObject.paths[propertyName] = pathObject[propertyName];
switch (propertyName) {
case 'definition': {
var definitionNames = Object
.getOwnPropertyNames(pathObject[propertyName]);
for (var k = 0; k < definitionNames.length; k = k + 1) {
var definitionName = definitionNames[k];
swaggerObject.definitions[definitionName] =
pathObject[propertyName][definitionName];
}
break;
}
default: {
swaggerObject.paths[propertyName] = objectMerge(
swaggerObject.paths[propertyName], pathObject[propertyName]
);
}
}
}

@@ -88,3 +124,2 @@ }

/**

@@ -112,2 +147,3 @@ * Generates the swagger spec

swaggerObject.paths = {};
swaggerObject.definitions = {};

@@ -114,0 +150,0 @@ // Parse the documentation in the APIs array.

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

# swagger-jsdoc
**swagger-jsdoc** enables to integrate [Swagger](http://swagger.io) using JSDoc.
[![npm Version](https://img.shields.io/npm/v/swagger-jsdoc.svg)](https://www.npmjs.com/package/swagger-jsdoc)
[![npm Downloads](https://img.shields.io/npm/dm/swagger-jsdoc.svg)](https://www.npmjs.com/package/swagger-jsdoc)
[![Donate](https://img.shields.io/gratipay/Surnet.svg)](https://gratipay.com/Surnet)
[![Circle CI](https://img.shields.io/circleci/project/Surnet/swagger-jsdoc/master.svg)](https://circleci.com/gh/Surnet/swagger-jsdoc)

@@ -8,4 +14,2 @@ [![Codacy Badge](https://img.shields.io/codacy/c5d3d458d11a4fb88b55cd527b1c708f.svg)](https://www.codacy.com/app/Surnet/swagger-jsdoc)

**swagger-jsdoc** enables to integrate [Swagger](http://swagger.io) using JSDoc.
## Supported Swagger Versions

@@ -20,3 +24,3 @@ * 2.0

## Quick Start
### Quick Start

@@ -54,2 +58,34 @@ swagger-jsdoc returns the validated swagger specification as JSON.

### How to document the API
The API can now be documented in JSDoc-style with swagger spec in YAML.
```javascript
/**
* @swagger
* /login:
* post:
* description: Login to the application
* produces:
* - application/json
* parameters:
* - name: username
* description: Username to use for login.
* in: formData
* required: true
* type: string
* - name: password
* description: User's password.
* in: formData
* required: true
* type: string
* responses:
* 200:
* description: login
*/
app.post('/login', function(req, res) {
res.json(req.body);
});
```
## Example App

@@ -56,0 +92,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc