Socket
Socket
Sign inDemoInstall

@fastify/swagger

Package Overview
Dependencies
Maintainers
19
Versions
38
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 7.5.1 to 7.6.0

4

lib/mode/dynamic.js

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

const transformStaticCSP = opts.transformStaticCSP
const logLevel = opts.logLevel
fastify.register(require('../routes'), {

@@ -39,3 +40,4 @@ prefix,

transformStaticCSP,
hooks: opts.uiHooks
hooks: opts.uiHooks,
logLevel
})

@@ -42,0 +44,0 @@ }

@@ -69,3 +69,4 @@ 'use strict'

transformStaticCSP: opts.transformStaticCSP,
hooks: opts.uiHooks
hooks: opts.uiHooks,
logLevel: opts.logLevel
}

@@ -72,0 +73,0 @@

{
"name": "@fastify/swagger",
"version": "7.5.1",
"version": "7.6.0",
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation",

@@ -47,3 +47,3 @@ "main": "index.js",

"@fastify/basic-auth": "^4.0.0",
"@fastify/helmet": "^9.0.0",
"@fastify/helmet": "^10.0.0",
"@fastify/pre-commit": "^2.0.2",

@@ -60,3 +60,3 @@ "@types/node": "^18.0.0",

"tap": "^16.2.0",
"tsd": "^0.23.0"
"tsd": "^0.24.1"
},

@@ -66,3 +66,3 @@ "dependencies": {

"fastify-plugin": "^4.0.0",
"json-schema-resolver": "^1.3.0",
"json-schema-resolver": "^2.0.0",
"openapi-types": "^12.0.0",

@@ -69,0 +69,0 @@ "rfdc": "^1.3.0",

@@ -234,2 +234,3 @@ # @fastify/swagger

| refResolver | {} | Option to manage the `$ref`s of your application's schemas. Read the [`$ref` documentation](#register.options.refResolver) |
| logLevel | info | Allow to define route log level. |

@@ -236,0 +237,0 @@ If you set `exposeRoute` to `true` the plugin will expose the documentation with the following APIs:

@@ -1,1 +0,1 @@

{"script":["'sha256-g6TK8Crx7YtGVUN10j0q8wD3cvwyzlvBMzQx4UjBPg4='"],"style":[]}
{"script":["'sha256-4IiDsMH+GkJlxivIDNfi6qk0O5HPtzyvNwVT3Wt8TIw='"],"style":[]}

@@ -204,3 +204,3 @@ 'use strict'

transformStaticCSP: function (header) {
t.equal(header, "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests")
t.equal(header, "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests")
return "default-src 'self'; script-src 'self';"

@@ -233,4 +233,4 @@ }

t.equal(res.statusCode, 200)
t.equal(res.headers['content-security-policy'], "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests")
t.equal(res.headers['content-security-policy'], "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests")
}
})

@@ -13,3 +13,3 @@ 'use strict'

const styleCSP = swaggerCSP.style.length > 0 ? ` ${swaggerCSP.style.join(' ')}` : ''
const csp = `default-src 'self';img-src 'self' data: validator.swagger.io;script-src 'self'${scriptCSP};style-src 'self' https:${styleCSP};base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';object-src 'none';script-src-attr 'none';upgrade-insecure-requests`
const csp = `default-src 'self';img-src 'self' data: validator.swagger.io;script-src 'self'${scriptCSP};style-src 'self' https:${styleCSP};base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';object-src 'none';script-src-attr 'none';upgrade-insecure-requests`

@@ -16,0 +16,0 @@ const fastify = Fastify()

@@ -544,1 +544,37 @@ 'use strict'

})
test('should return silent log level of route /documentation', async (t) => {
const fastify = Fastify()
fastify.addHook('onRoute', function (route) {
t.equal(route.logLevel, 'silent')
})
await fastify.register(fastifySwagger, { ...swaggerOption, logLevel: 'silent' })
const res = await fastify.inject({
method: 'GET',
url: '/documentation'
})
t.equal(res.statusCode, 302)
t.equal(res.headers.location, './documentation/static/index.html')
t.equal(typeof res.payload, 'string')
})
test('should return empty log level of route /documentation', async (t) => {
const fastify = Fastify()
fastify.addHook('onRoute', function (route) {
t.equal(route.logLevel, '')
})
await fastify.register(fastifySwagger, swaggerOption)
const res = await fastify.inject({
method: 'GET',
url: '/documentation'
})
t.equal(res.statusCode, 302)
t.equal(res.headers.location, './documentation/static/index.html')
t.equal(typeof res.payload, 'string')
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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