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

fastify-swagger

Package Overview
Dependencies
Maintainers
13
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-swagger - npm Package Compare versions

Comparing version 4.9.0 to 4.9.1

6

lib/util/common.js

@@ -68,4 +68,5 @@ 'use strict'

// => '/user/{id}'
// custom verbs at the end of a url are okay => /user::watch but should be rendered as /user:watch in swagger
function formatParamUrl (url) {
const regex = /:([a-zA-Z0-9_]+)/g
const regex = /(?<!:):([a-zA-Z0-9_]+)/g
let found = regex.exec(url)

@@ -77,3 +78,4 @@ while (found !== null) {

}
return url
return url.replace(/::/g, ':')
}

@@ -80,0 +82,0 @@

{
"name": "fastify-swagger",
"version": "4.9.0",
"version": "4.9.1",
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation",

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

@@ -303,2 +303,41 @@ 'use strict'

test('custom verbs should not be interpreted as path params', t => {
t.plan(3)
const opts = {
schema: {
params: {
type: 'object',
properties: {
id: { type: 'string' }
}
}
}
}
const fastify = Fastify()
fastify.register(fastifySwagger, swaggerOption)
fastify.get('/resource/:id/sub-resource::watch', opts, () => {})
fastify.ready(err => {
t.error(err)
const swaggerObject = fastify.swagger()
Swagger.validate(swaggerObject)
.then((api) => {
const definedPath = api.paths['/resource/{id}/sub-resource:watch'].get
t.ok(definedPath)
t.same(definedPath.parameters, [{
in: 'path',
name: 'id',
type: 'string',
required: true
}])
})
.catch(err => {
console.log(err)
t.error(err)
})
})
})
test('swagger json output should not omit consume in querystring schema', async (t) => {

@@ -305,0 +344,0 @@ t.plan(1)

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