fastify-swagger
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"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", |
@@ -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) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19608406
30
11222
7
8