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

@unleash/express-openapi

Package Overview
Dependencies
Maintainers
6
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.2 to 0.3.0

lib/extract-path.js

4

lib/generate-doc.js

@@ -5,2 +5,3 @@ 'use strict'

const { get: getSchema, set: setSchema } = require('./layer-schema')
const extractPath = require('./extract-path')

@@ -19,2 +20,5 @@ module.exports = function generateDocument (baseDocument, router) {

iterateStack('', null, _layer, (path, routeLayer, layer) => {
if (doc.servers && doc.servers.length === 1) {
path = path.replace(extractPath(doc.servers[0].url), '')
}
const schema = getSchema(layer.handle)

@@ -21,0 +25,0 @@ if (!schema || !layer.method) {

2

package.json
{
"name": "@unleash/express-openapi",
"version": "0.2.2",
"version": "0.3.0",
"description": "Middleware for generating OpenAPI/Swagger documentation for your Express app",

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

@@ -418,2 +418,51 @@ 'use strict'

test('support express nested sub-routes with base path', (done) => {
const app = express()
const router = express.Router()
const subrouter = express.Router()
const oapi = openapi({ servers: [ { url: '/sub-route' } ] })
const emptySchema = oapi.path({
responses: {
204: {
description: 'Successful response',
content: {
'application/json': {}
}
}
}
})
subrouter.get('/endpoint', emptySchema, (req, res) => {
res.status(204).send()
})
app.use(oapi)
app.use('/sub-route', router)
router.use('/sub-sub-route', subrouter)
supertest(app)
.get(`${openapi.defaultRoutePrefix}.json`)
.expect(200, (err, res) => {
assert(!err, err)
SwaggerParser.validate(res.body, (err, api) => {
if (err) {
logDocument(api)
done(err)
}
assert(api.paths['/sub-sub-route/endpoint'])
assert(api.paths['/sub-sub-route/endpoint'].get)
assert(api.paths['/sub-sub-route/endpoint'].get.responses[204])
assert.strictEqual(
api.paths['/sub-sub-route/endpoint'].get.responses[204].description,
'Successful response'
)
done()
})
})
})
// Other tests

@@ -420,0 +469,0 @@ require('./_validate')()

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