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

fastify-swagger

Package Overview
Dependencies
Maintainers
7
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 0.9.0 to 0.10.0

.npmignore

5

package.json
{
"name": "fastify-swagger",
"version": "0.9.0",
"version": "0.10.0",
"description": "Generate Swagger files automatically for Fastify.",

@@ -27,3 +27,4 @@ "main": "index.js",

"fastify": "^1.3.1",
"fs-extra": "^5.0.0",
"fs-extra": "^6.0.0",
"pre-commit": "^1.2.2",
"standard": "^11.0.0",

@@ -30,0 +31,0 @@ "swagger-parser": "^4.1.0",

2

routes.js

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

schema: { hide: true },
handler: (request, reply) => reply.redirect(`.${opts.prefix}/`)
handler: (request, reply) => reply.redirect(`${fastify.basePath}/index.html`)
})

@@ -13,0 +13,0 @@

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

test('/documentation should redirect to /documentation/', t => {
test('/documentation should redirect to /documentation/index.html', t => {
t.plan(4)

@@ -187,3 +187,3 @@ const fastify = Fastify()

t.strictEqual(res.statusCode, 302)
t.strictEqual(res.headers['location'], './documentation/')
t.strictEqual(res.headers['location'], '/documentation/index.html')
t.is(typeof res.payload, 'string')

@@ -193,2 +193,57 @@ })

test('/v1/documentation should redirect to /v1/documentation/index.html', t => {
t.plan(4)
const fastify = Fastify()
const opts = JSON.parse(JSON.stringify(swaggerInfo))
opts.routePrefix = '/v1/documentation'
fastify.register(fastifySwagger, opts)
fastify.get('/', () => {})
fastify.post('/', () => {})
fastify.get('/example', opts1, () => {})
fastify.post('/example', opts2, () => {})
fastify.get('/parameters/:id', opts3, () => {})
fastify.get('/example1', opts4, () => {})
fastify.inject({
method: 'GET',
url: '/v1/documentation'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 302)
t.strictEqual(res.headers['location'], '/v1/documentation/index.html')
t.is(typeof res.payload, 'string')
})
})
test('/v1/foobar should redirect to /v1/foobar/index.html - in plugin', t => {
t.plan(4)
const fastify = Fastify()
fastify.register(function (fastify, options, next) {
const opts = JSON.parse(JSON.stringify(swaggerInfo))
opts.routePrefix = '/foobar'
fastify.register(fastifySwagger, opts)
fastify.get('/', () => {})
fastify.post('/', () => {})
fastify.get('/example', opts1, () => {})
fastify.post('/example', opts2, () => {})
fastify.get('/parameters/:id', opts3, () => {})
fastify.get('/example1', opts4, () => {})
next()
}, { prefix: '/v1' })
fastify.inject({
method: 'GET',
url: '/v1/foobar'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 302)
t.strictEqual(res.headers['location'], '/v1/foobar/index.html')
t.is(typeof res.payload, 'string')
})
})
test('/documentation/:file should send back the correct file', t => {

@@ -195,0 +250,0 @@ t.plan(21)

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