express-jsdoc-swagger
Advanced tools
Comparing version 1.3.0 to 1.3.1
64
index.js
@@ -6,3 +6,2 @@ const swaggerUi = require('swagger-ui-express'); | ||
let instance = null; | ||
const DEFAULT_SWAGGERUI_URL = '/api-docs'; | ||
@@ -13,41 +12,38 @@ const DEFAULT_EXPOSE_SWAGGERUI = true; | ||
const expressJSDocSwagger = app => { | ||
if (instance) return () => instance; | ||
return (options = {}, userSwagger = {}) => { | ||
const events = swaggerEvents(); | ||
instance = events.instance; | ||
let swaggerObject = {}; | ||
const expressJSDocSwagger = app => (options = {}, userSwagger = {}) => { | ||
const events = swaggerEvents(); | ||
const { instance } = events; | ||
let swaggerObject = {}; | ||
processSwagger(options, events.processFile) | ||
.then(result => { | ||
swaggerObject = { | ||
...swaggerObject, | ||
...result, | ||
}; | ||
swaggerObject = merge.recursive(true, swaggerObject, userSwagger); | ||
events.finish(swaggerObject); | ||
}) | ||
.catch(events.error); | ||
processSwagger(options, events.processFile) | ||
.then(result => { | ||
swaggerObject = { | ||
...swaggerObject, | ||
...result, | ||
}; | ||
swaggerObject = merge.recursive(true, swaggerObject, userSwagger); | ||
events.finish(swaggerObject); | ||
}) | ||
.catch(events.error); | ||
if (options.exposeSwaggerUI || DEFAULT_EXPOSE_SWAGGERUI) { | ||
app.use(options.swaggerUIPath || DEFAULT_SWAGGERUI_URL, (req, res, next) => { | ||
swaggerObject = { | ||
...swaggerObject, | ||
host: req.get('host'), | ||
}; | ||
req.swaggerDoc = swaggerObject; | ||
next(); | ||
}, swaggerUi.serve, swaggerUi.setup()); | ||
} | ||
if (options.exposeSwaggerUI || DEFAULT_EXPOSE_SWAGGERUI) { | ||
app.use(options.swaggerUIPath || DEFAULT_SWAGGERUI_URL, (req, res, next) => { | ||
swaggerObject = { | ||
...swaggerObject, | ||
host: req.get('host'), | ||
}; | ||
req.swaggerDoc = swaggerObject; | ||
next(); | ||
}, swaggerUi.serve, swaggerUi.setup()); | ||
} | ||
if (options.exposeApiDocs || DEFAULT_EXPOSE_APIDOCS) { | ||
app.get(options.apiDocsPath || DEFAULT_APIDOCS_URL, (req, res) => { | ||
res.json(swaggerObject); | ||
}); | ||
} | ||
if (options.exposeApiDocs || DEFAULT_EXPOSE_APIDOCS) { | ||
app.get(options.apiDocsPath || DEFAULT_APIDOCS_URL, (req, res) => { | ||
res.json(swaggerObject); | ||
}); | ||
} | ||
return instance; | ||
}; | ||
return instance; | ||
}; | ||
module.exports = expressJSDocSwagger; |
{ | ||
"name": "express-jsdoc-swagger", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Swagger OpenAPI 3.x generator", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"merge": "^2.1.0", | ||
"swagger-ui-express": "^4.1.4" | ||
"swagger-ui-express": "^4.1.5" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
@@ -166,19 +166,21 @@ ![npm](https://img.shields.io/npm/v/express-jsdoc-swagger) | ||
<tr> | ||
<td align="center"><a href="https://github.com/bri06"><img src="https://avatars0.githubusercontent.com/u/24435223?v=4" width="100px;" alt=""/><br /><sub><b>Briam Martinez Escobar</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=bri06" title="Code">💻</a></td> | ||
<td align="center"><a href="https://twitter.com/kjmesc"><img src="https://avatars2.githubusercontent.com/u/12685053?v=4" width="100px;" alt=""/><br /><sub><b>Kevin Julián Martínez Escobar</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=kevinccbsg" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/hoonga"><img src="https://avatars3.githubusercontent.com/u/10708927?v=4" width="100px;" alt=""/><br /><sub><b>Heung-yeon Oh</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=hoonga" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/LonelyPrincess"><img src="https://avatars1.githubusercontent.com/u/17673317?v=4" width="100px;" alt=""/><br /><sub><b>Sara Hernández</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=LonelyPrincess" title="Code">💻</a></td> | ||
<td align="center"><a href="http://servatj.me"><img src="https://avatars0.githubusercontent.com/u/3521485?v=4" width="100px;" alt=""/><br /><sub><b>Josep Servat</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=servatj" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/thuydx55"><img src="https://avatars2.githubusercontent.com/u/1469984?v=4" width="100px;" alt=""/><br /><sub><b>Nick Dong</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=thuydx55" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/Stosiu"><img src="https://avatars1.githubusercontent.com/u/10252063?v=4" width="100px;" alt=""/><br /><sub><b>Aleksander Stós</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=Stosiu" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/bri06"><img src="https://avatars0.githubusercontent.com/u/24435223?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Briam Martinez Escobar</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=bri06" title="Code">💻</a></td> | ||
<td align="center"><a href="https://twitter.com/kjmesc"><img src="https://avatars2.githubusercontent.com/u/12685053?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Julián Martínez Escobar</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=kevinccbsg" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/hoonga"><img src="https://avatars3.githubusercontent.com/u/10708927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Heung-yeon Oh</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=hoonga" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/LonelyPrincess"><img src="https://avatars1.githubusercontent.com/u/17673317?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sara Hernández</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=LonelyPrincess" title="Code">💻</a></td> | ||
<td align="center"><a href="http://servatj.me"><img src="https://avatars0.githubusercontent.com/u/3521485?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Josep Servat</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=servatj" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/thuydx55"><img src="https://avatars2.githubusercontent.com/u/1469984?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick Dong</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=thuydx55" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/Stosiu"><img src="https://avatars1.githubusercontent.com/u/10252063?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aleksander Stós</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=Stosiu" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/kdankert"><img src="https://avatars0.githubusercontent.com/u/46489624?v=4" width="100px;" alt=""/><br /><sub><b>Kjell Dankert</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=kdankert" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/kdankert"><img src="https://avatars0.githubusercontent.com/u/46489624?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kjell Dankert</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=kdankert" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/juliendu11"><img src="https://avatars0.githubusercontent.com/u/18739442?v=4?s=100" width="100px;" alt=""/><br /><sub><b>juliendu11</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=juliendu11" title="Code">💻</a></td> | ||
</tr> | ||
</table> | ||
<!-- markdownlint-enable --> | ||
<!-- markdownlint-restore --> | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances 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
777857
146
2098
186
2
80
1
Updatedswagger-ui-express@^4.1.5