Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unleash/express-openapi

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unleash/express-openapi - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1-beta.0

.github/stale.yml

31

lib/ui.js

@@ -6,4 +6,19 @@ 'use strict'

module.exports.serveSwaggerUI = function serveSwaggerUI (documentUrl) {
return [serve(path.resolve(require.resolve('swagger-ui-dist'), '..'), { index: false }), function renderSwaggerHtml (req, res) {
res.type('html').send(renderHtmlPage('Swagger UI', `
return [serve(path.resolve(require.resolve('swagger-ui-dist'), '..'), { index: false }),
function returnUiInit (req, res, next) {
if (req.path.endsWith('/swagger-ui-init.js')) {
res.type('.js')
res.send(`window.onload = function () {
window.ui = SwaggerUIBundle({
url: "${documentUrl}",
dom_id: '#swagger-ui'
})
}
`)
} else {
next()
}
},
function renderSwaggerHtml (req, res) {
res.type('html').send(renderHtmlPage('Swagger UI', `
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >

@@ -14,12 +29,6 @@ `, `

<script src="./swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function () {
window.ui = SwaggerUIBundle({
url: "${documentUrl}",
dom_id: '#swagger-ui'
})
}
</script>
<script src="./swagger-ui-init.js"></script>
`))
}]
}
]
}

@@ -26,0 +35,0 @@

{
"name": "@unleash/express-openapi",
"version": "0.2.0",
"version": "0.2.1-beta.0",
"description": "Middleware for generating OpenAPI/Swagger documentation for your Express app",

@@ -5,0 +5,0 @@ "author": "@unleash",

@@ -7,3 +7,1 @@ # unleash-express-openapi

2. removes the redoc dependency which we don't use.
The fork is not published to npm, and only used by https://github.com/Unleash/unleash.

@@ -84,2 +84,14 @@ 'use strict'

test('serves onload function in swagger-ui-init.js file', function (done) {
const app = express()
app.use(openapi().swaggerui)
supertest(app)
.get(`${openapi.defaultRoutePrefix}/swagger-ui-init.js`)
.end((err, res) => {
assert(!err, err)
assert(res.text.includes('window.onload = function () {'))
done()
})
})
test('load routes from the express app', function (done) {

@@ -86,0 +98,0 @@ const app = express()

Sorry, the diff of this file is not supported yet

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