@fastify/swagger-ui
Advanced tools
Comparing version 5.0.0-pre.fv5.2 to 5.0.0
@@ -114,4 +114,7 @@ 'use strict' | ||
querystring: { | ||
hello: { type: 'string' }, | ||
world: { type: 'string' } | ||
type: 'object', | ||
properties: { | ||
hello: { type: 'string' }, | ||
world: { type: 'string' } | ||
} | ||
} | ||
@@ -118,0 +121,0 @@ } |
{ | ||
"name": "@fastify/swagger-ui", | ||
"version": "5.0.0-pre.fv5.2", | ||
"version": "5.0.0", | ||
"description": "Serve Swagger-ui for Fastify", | ||
@@ -9,3 +9,2 @@ "main": "index.js", | ||
"scripts": { | ||
"coverage": "npm run unit -- --coverage-report=lcovonly", | ||
"lint": "standard", | ||
@@ -15,3 +14,3 @@ "lint:fix": "npm run lint -- --fix", | ||
"prepublishOnly": "npm run prepare", | ||
"test": "npm run prepare && npm run coverage && npm run typescript", | ||
"test": "npm run prepare && npm run unit && npm run typescript", | ||
"test:dev": "npm run lint && npm run unit && npm run typescript", | ||
@@ -22,5 +21,3 @@ "test:e2e:command": "node ./examples/example-e2e.js", | ||
"typescript": "tsd", | ||
"unit": "tap", | ||
"unit:report": "npm run unit -- --coverage-report=html", | ||
"unit:verbose": "npm run unit -- -Rspec" | ||
"unit": "c8 --100 node --test" | ||
}, | ||
@@ -53,11 +50,11 @@ "repository": { | ||
"@apidevtools/swagger-parser": "^10.1.0", | ||
"@fastify/basic-auth": "^6.0.0-pre.fv5.2", | ||
"@fastify/helmet": "^12.0.0-pre.fv5.2", | ||
"@fastify/basic-auth": "^6.0.0", | ||
"@fastify/helmet": "^12.0.0", | ||
"@fastify/pre-commit": "^2.1.0", | ||
"@fastify/swagger": "^9.0.0-pre.fv5.1", | ||
"@fastify/swagger": "^9.0.0", | ||
"@playwright/test": "^1.43.1", | ||
"@tapjs/snapshot": "^4.0.0", | ||
"@types/node": "^22.0.0", | ||
"ajv": "^8.12.0", | ||
"fastify": "5.0.0-alpha.3", | ||
"c8": "^10.1.2", | ||
"fastify": "5.0.0-alpha.4", | ||
"fs-extra": "^11.2.0", | ||
@@ -67,8 +64,7 @@ "qs": "^6.12.1", | ||
"swagger-ui-dist": "5.17.14", | ||
"tap": "^19.2.5", | ||
"tsd": "^0.31.0" | ||
}, | ||
"dependencies": { | ||
"@fastify/static": "^8.0.0-pre.fv5.1", | ||
"fastify-plugin": "^5.0.0-pre.fv5.1", | ||
"@fastify/static": "^8.0.0", | ||
"fastify-plugin": "^5.0.0", | ||
"openapi-types": "^12.1.3", | ||
@@ -75,0 +71,0 @@ "rfdc": "^1.3.1", |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -36,5 +36,5 @@ const fastifyHelmet = require('@fastify/helmet') | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(typeof res.headers['content-security-policy'], 'undefined') | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(typeof res.headers['content-security-policy'], 'undefined') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
}) | ||
@@ -63,5 +63,5 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-security-policy'], `default-src 'self'; base-uri 'self'; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data: validator.swagger.io; object-src 'none'; script-src 'self' ${csp.script.join(' ')}; script-src-attr 'none'; style-src 'self' https: ${csp.style.join(' ')}; upgrade-insecure-requests;`) | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], `default-src 'self'; base-uri 'self'; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data: validator.swagger.io; object-src 'none'; script-src 'self' ${csp.script.join(' ')}; script-src-attr 'none'; style-src 'self' https: ${csp.style.join(' ')}; upgrade-insecure-requests;`) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
} | ||
@@ -74,4 +74,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(typeof res.headers['content-security-policy'], 'undefined') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(typeof res.headers['content-security-policy'], 'undefined') | ||
} | ||
@@ -101,5 +101,5 @@ }) | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-security-policy'], "default-src 'self';") | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], "default-src 'self';") | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
} | ||
@@ -112,4 +112,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(typeof res.headers['content-security-policy'], 'undefined') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(typeof res.headers['content-security-policy'], 'undefined') | ||
} | ||
@@ -142,5 +142,5 @@ }) | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
} | ||
@@ -153,4 +153,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(typeof res.headers['content-security-policy'], 'undefined') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(typeof res.headers['content-security-policy'], 'undefined') | ||
} | ||
@@ -167,3 +167,3 @@ }) | ||
transformStaticCSP: function (header) { | ||
t.equal(header, "default-src 'self';") | ||
t.assert.deepStrictEqual(header, "default-src 'self';") | ||
return "default-src 'self'; script-src 'self';" | ||
@@ -185,5 +185,5 @@ } | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
} | ||
@@ -196,4 +196,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(typeof res.headers['content-security-policy'], 'undefined') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(typeof res.headers['content-security-policy'], 'undefined') | ||
} | ||
@@ -210,3 +210,3 @@ }) | ||
transformStaticCSP: function (header) { | ||
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") | ||
t.assert.deepStrictEqual(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';" | ||
@@ -228,5 +228,5 @@ } | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.equal(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], "default-src 'self'; script-src 'self';") | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
} | ||
@@ -239,5 +239,5 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
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") | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(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") | ||
} | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -15,5 +15,5 @@ const fastifySwagger = require('@fastify/swagger') | ||
t.ok(fastify.swaggerCSP) | ||
t.ok(Array.isArray(fastify.swaggerCSP.script)) | ||
t.ok(Array.isArray(fastify.swaggerCSP.style)) | ||
t.assert.ok(fastify.swaggerCSP) | ||
t.assert.ok(Array.isArray(fastify.swaggerCSP.script)) | ||
t.assert.ok(Array.isArray(fastify.swaggerCSP.style)) | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -42,6 +42,6 @@ const yaml = require('yaml') | ||
let res = await fastify.inject('/documentation') | ||
t.equal(res.statusCode, 401, 'root auth required') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'root auth required') | ||
res = await fastify.inject('/documentation/yaml') | ||
t.equal(res.statusCode, 401, 'auth required yaml') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'auth required yaml') | ||
res = await fastify.inject({ | ||
@@ -52,13 +52,13 @@ method: 'GET', | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
try { | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
} catch (err) { | ||
t.fail(err) | ||
t.assert.fail(err) | ||
} | ||
res = await fastify.inject('/documentation/json') | ||
t.equal(res.statusCode, 401, 'auth required json') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'auth required json') | ||
res = await fastify.inject({ | ||
@@ -69,7 +69,7 @@ method: 'GET', | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
try { | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger json') | ||
t.assert.ok(true, 'valid swagger json') | ||
} catch (err) { | ||
@@ -97,9 +97,9 @@ t.fail(err) | ||
let res = await fastify.inject('/documentation') | ||
t.equal(res.statusCode, 401, 'root auth required') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'root auth required') | ||
res = await fastify.inject('/documentation/yaml') | ||
t.equal(res.statusCode, 401, 'auth required yaml') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'auth required yaml') | ||
res = await fastify.inject('/documentation/json') | ||
t.equal(res.statusCode, 401, 'auth required json') | ||
t.assert.deepStrictEqual(res.statusCode, 401, 'auth required json') | ||
res = await fastify.inject({ | ||
@@ -110,8 +110,8 @@ method: 'GET', | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
const swaggerObject = res.json() | ||
t.ok(swaggerObject.paths) | ||
t.ok(swaggerObject.paths['/fooBar123']) | ||
t.assert.ok(swaggerObject.paths) | ||
t.assert.ok(swaggerObject.paths['/fooBar123']) | ||
}) | ||
@@ -144,3 +144,3 @@ | ||
const openapi = fastify.swagger() | ||
t.same(Object.keys(openapi.components.schemas), ['Root', 'Instance', 'Sub-Instance']) | ||
t.assert.deepStrictEqual(Object.keys(openapi.components.schemas), ['Root', 'Instance', 'Sub-Instance']) | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -46,3 +46,3 @@ const fastifySwagger = require('@fastify/swagger') | ||
}) | ||
t.same(res.headers['content-security-policy'], csp) | ||
t.assert.deepStrictEqual(res.headers['content-security-policy'], csp) | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -20,4 +20,4 @@ const fastifySwagger = require('@fastify/swagger') | ||
const includesSourceMap = res.payload.includes('sourceMappingURL') | ||
t.equal(includesSourceMap, false) | ||
t.equal(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
t.assert.deepStrictEqual(includesSourceMap, false) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
}) | ||
@@ -37,4 +37,4 @@ | ||
const includesSourceMap = res.payload.includes('sourceMappingURL') | ||
t.equal(includesSourceMap, false) | ||
t.equal(res.headers['content-type'], 'text/css; charset=UTF-8') | ||
t.assert.deepStrictEqual(includesSourceMap, false) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/css; charset=UTF-8') | ||
}) |
'use strict' | ||
const t = require('tap') | ||
const t = require('node:test') | ||
const test = t.test | ||
@@ -74,3 +74,3 @@ const Fastify = require('fastify') | ||
await Swagger.validate(payload) | ||
t.pass('valid swagger object') | ||
t.assert.ok(true, 'valid swagger object') | ||
}) | ||
@@ -98,6 +98,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
}) | ||
@@ -122,6 +122,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -146,6 +146,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -170,6 +170,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -194,6 +194,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -221,6 +221,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -248,6 +248,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -268,6 +268,6 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers.location, undefined) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal('text/html; charset=utf-8', res.headers['content-type']) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers.location, undefined) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual('text/html; charset=utf-8', res.headers['content-type']) | ||
}) | ||
@@ -296,4 +296,4 @@ | ||
}) | ||
t.equal(res.statusCode, 302) | ||
t.equal(res.headers.location, '/documentation/') | ||
t.assert.deepStrictEqual(res.statusCode, 302) | ||
t.assert.deepStrictEqual(res.headers.location, '/documentation/') | ||
} | ||
@@ -306,5 +306,5 @@ | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'text/html; charset=UTF-8') | ||
t.equal( | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=UTF-8') | ||
t.assert.deepStrictEqual( | ||
readFileSync( | ||
@@ -316,3 +316,3 @@ resolve(__dirname, '..', 'static', 'index.html'), | ||
) | ||
t.ok(res.payload.indexOf('swagger-initializer.js') !== -1) | ||
t.assert.ok(res.payload.indexOf('swagger-initializer.js') !== -1) | ||
} | ||
@@ -325,5 +325,5 @@ | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/javascript; charset=utf-8') | ||
t.ok(res.payload.indexOf('resolveUrl') !== -1) | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/javascript; charset=utf-8') | ||
t.assert.ok(res.payload.indexOf('resolveUrl') !== -1) | ||
} | ||
@@ -336,5 +336,5 @@ | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'text/html; charset=UTF-8') | ||
t.equal( | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=UTF-8') | ||
t.assert.deepStrictEqual( | ||
readFileSync( | ||
@@ -353,5 +353,5 @@ resolve(__dirname, '..', 'static', 'oauth2-redirect.html'), | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'text/css; charset=UTF-8') | ||
t.equal( | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/css; charset=UTF-8') | ||
t.assert.deepStrictEqual( | ||
readFileSync( | ||
@@ -370,5 +370,5 @@ resolve(__dirname, '..', 'static', 'swagger-ui.css'), | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
t.equal( | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
t.assert.deepStrictEqual( | ||
readFileSync( | ||
@@ -387,5 +387,5 @@ resolve(__dirname, '..', 'static', 'swagger-ui-bundle.js'), | ||
}) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
t.equal( | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/javascript; charset=UTF-8') | ||
t.assert.deepStrictEqual( | ||
readFileSync( | ||
@@ -416,4 +416,4 @@ resolve(__dirname, '..', 'static', 'swagger-ui-standalone-preset.js'), | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal( | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual( | ||
res.payload, | ||
@@ -447,5 +447,6 @@ readFileSync( | ||
const payload = JSON.parse(res.payload) | ||
t.equal(res.statusCode, 404) | ||
t.match(payload, { | ||
t.assert.deepStrictEqual(res.statusCode, 404) | ||
t.assert.deepStrictEqual(payload, { | ||
error: 'Not Found', | ||
message: 'Route GET:/documentation/static/stuff.css not found', | ||
statusCode: 404 | ||
@@ -477,3 +478,3 @@ }) | ||
await Swagger.validate(payload) | ||
t.pass('valid swagger object') | ||
t.assert.ok(true, 'valid swagger object') | ||
}) | ||
@@ -491,3 +492,3 @@ | ||
}) | ||
t.equal(res.statusCode, 404) | ||
t.assert.deepStrictEqual(res.statusCode, 404) | ||
}) | ||
@@ -509,3 +510,3 @@ | ||
}) | ||
t.equal(res.statusCode, 410) | ||
t.assert.deepStrictEqual(res.statusCode, 410) | ||
}) | ||
@@ -523,3 +524,3 @@ | ||
}) | ||
t.equal(res.statusCode, 404) | ||
t.assert.deepStrictEqual(res.statusCode, 404) | ||
}) | ||
@@ -531,3 +532,3 @@ | ||
fastify.addHook('onRoute', function (route) { | ||
t.equal(route.logLevel, 'silent') | ||
t.assert.deepStrictEqual(route.logLevel, 'silent') | ||
}) | ||
@@ -542,4 +543,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
}) | ||
@@ -551,3 +552,3 @@ | ||
fastify.addHook('onRoute', function (route) { | ||
t.equal(route.logLevel, '') | ||
t.assert.deepStrictEqual(route.logLevel, '') | ||
}) | ||
@@ -562,4 +563,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
}) | ||
@@ -578,6 +579,6 @@ | ||
t.equal(res.payload.includes('href="/documentation/static/index.css"'), true) | ||
t.equal(res.payload.includes('src="/documentation/static/theme/theme-js.js"'), true) | ||
t.equal(res.payload.includes('href="/documentation/index.css"'), false) | ||
t.equal(res.payload.includes('src="/documentation/theme/theme-js.js"'), false) | ||
t.assert.deepStrictEqual(res.payload.includes('href="/documentation/static/index.css"'), true) | ||
t.assert.deepStrictEqual(res.payload.includes('src="/documentation/static/theme/theme-js.js"'), true) | ||
t.assert.deepStrictEqual(res.payload.includes('href="/documentation/index.css"'), false) | ||
t.assert.deepStrictEqual(res.payload.includes('src="/documentation/theme/theme-js.js"'), false) | ||
}) | ||
@@ -596,6 +597,6 @@ | ||
t.equal(res.payload.includes('href="./static/index.css"'), true) | ||
t.equal(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.equal(res.payload.includes('href="./index.css"'), false) | ||
t.equal(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
t.assert.strictEqual(res.payload.includes('href="./static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="./index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
}) | ||
@@ -614,6 +615,6 @@ | ||
t.equal(res.payload.includes('href="/docs/static/index.css"'), true) | ||
t.equal(res.payload.includes('src="/docs/static/theme/theme-js.js"'), true) | ||
t.equal(res.payload.includes('href="/docs/index.css"'), false) | ||
t.equal(res.payload.includes('src="/docs/theme/theme-js.js"'), false) | ||
t.assert.strictEqual(res.payload.includes('href="/docs/static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="/docs/static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="/docs/index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="/docs/theme/theme-js.js"'), false) | ||
}) | ||
@@ -632,6 +633,57 @@ | ||
t.equal(res.payload.includes('href="./static/index.css"'), true) | ||
t.equal(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.equal(res.payload.includes('href="./index.css"'), false) | ||
t.equal(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
t.assert.strictEqual(res.payload.includes('href="./static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="./index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
}) | ||
test('/documentation/ should display index html with correct asset urls', async (t) => { | ||
t.plan(4) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger, swaggerOption) | ||
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] } }) | ||
const res = await fastify.inject({ | ||
method: 'GET', | ||
url: '/documentation/' | ||
}) | ||
t.assert.strictEqual(res.payload.includes('href="./static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="./index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
}) | ||
test('/docs should display index html with correct asset urls when documentation prefix is set', async (t) => { | ||
t.plan(4) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger, swaggerOption) | ||
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] }, routePrefix: '/docs' }) | ||
const res = await fastify.inject({ | ||
method: 'GET', | ||
url: '/docs' | ||
}) | ||
t.assert.strictEqual(res.payload.includes('href="/docs/static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="/docs/static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="/docs/index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="/docs/theme/theme-js.js"'), false) | ||
}) | ||
test('/docs/ should display index html with correct asset urls when documentation prefix is set', async (t) => { | ||
t.plan(4) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger, swaggerOption) | ||
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] }, routePrefix: '/docs' }) | ||
const res = await fastify.inject({ | ||
method: 'GET', | ||
url: '/docs/' | ||
}) | ||
t.assert.strictEqual(res.payload.includes('href="./static/index.css"'), true) | ||
t.assert.strictEqual(res.payload.includes('src="./static/theme/theme-js.js"'), true) | ||
t.assert.strictEqual(res.payload.includes('href="./index.css"'), false) | ||
t.assert.strictEqual(res.payload.includes('src="./theme/theme-js.js"'), false) | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const serialize = require('../lib/serialize') | ||
test('serialize', async (t) => { | ||
t.plan(8) | ||
test('serialize boolean', t => { | ||
t.plan(2) | ||
t.test('boolean', t => { | ||
t.plan(2) | ||
t.assert.deepStrictEqual(serialize(true), 'true') | ||
t.assert.deepStrictEqual(serialize(false), 'false') | ||
}) | ||
t.equal(serialize(true), 'true') | ||
t.equal(serialize(false), 'false') | ||
}) | ||
test('serialize number', t => { | ||
t.plan(7) | ||
t.test('number', t => { | ||
t.plan(7) | ||
t.assert.deepStrictEqual(serialize(0), '0') | ||
t.assert.deepStrictEqual(serialize(1), '1') | ||
t.assert.deepStrictEqual(serialize(1.0), '1') | ||
t.assert.deepStrictEqual(serialize(1.01), '1.01') | ||
t.assert.deepStrictEqual(serialize(Infinity), 'Infinity') | ||
t.assert.deepStrictEqual(serialize(-Infinity), '-Infinity') | ||
t.assert.deepStrictEqual(serialize(NaN), 'NaN') | ||
}) | ||
t.equal(serialize(0), '0') | ||
t.equal(serialize(1), '1') | ||
t.equal(serialize(1.0), '1') | ||
t.equal(serialize(1.01), '1.01') | ||
t.equal(serialize(Infinity), 'Infinity') | ||
t.equal(serialize(-Infinity), '-Infinity') | ||
t.equal(serialize(NaN), 'NaN') | ||
}) | ||
test('serialize string', t => { | ||
t.plan(3) | ||
t.test('string', t => { | ||
t.plan(3) | ||
t.assert.deepStrictEqual(serialize('0'), '"0"') | ||
t.assert.deepStrictEqual(serialize('abc'), '"abc"') | ||
t.assert.deepStrictEqual(serialize('"a'), '"\\\"a"') // eslint-disable-line no-useless-escape | ||
}) | ||
t.equal(serialize('0'), '"0"') | ||
t.equal(serialize('abc'), '"abc"') | ||
t.equal(serialize('"a'), '"\\\"a"') // eslint-disable-line no-useless-escape | ||
}) | ||
test('serialize bigint', t => { | ||
t.plan(3) | ||
t.test('bigint', t => { | ||
t.plan(3) | ||
t.assert.deepStrictEqual(serialize(0n), '0n') | ||
t.assert.deepStrictEqual(serialize(1000000000n), '1000000000n') | ||
t.assert.deepStrictEqual(serialize(-9999n), '-9999n') | ||
}) | ||
t.equal(serialize(0n), '0n') | ||
t.equal(serialize(1000000000n), '1000000000n') | ||
t.equal(serialize(-9999n), '-9999n') | ||
}) | ||
test('serialize function', t => { | ||
t.plan(7) | ||
t.test('function', t => { | ||
t.plan(7) | ||
t.assert.deepStrictEqual(serialize(function a () { }), 'function a () { }') | ||
t.assert.deepStrictEqual(serialize(async function a () { }), 'async function a () { }') | ||
t.assert.deepStrictEqual(serialize(() => { }), '() => { }') | ||
t.assert.deepStrictEqual(serialize(async () => { }), 'async () => { }') | ||
t.assert.deepStrictEqual(serialize(() => Date.now), '() => Date.now') | ||
t.assert.deepStrictEqual(serialize(function () { }), 'function () { }') | ||
t.assert.deepStrictEqual(serialize(async function () { }), 'async function () { }') | ||
}) | ||
t.equal(serialize(function a () {}), 'function a () {}') | ||
t.equal(serialize(async function a () {}), 'async function a () {}') | ||
t.equal(serialize(() => {}), '() => {}') | ||
t.equal(serialize(async () => {}), 'async () => {}') | ||
t.equal(serialize(() => Date.now), '() => Date.now') | ||
test('serialize undefined', t => { | ||
t.plan(1) | ||
t.equal(serialize(function () {}), 'function () {}') | ||
t.equal(serialize(async function () {}), 'async function () {}') | ||
}) | ||
t.assert.deepStrictEqual(serialize(undefined), 'undefined') | ||
}) | ||
t.test('undefined', t => { | ||
t.plan(1) | ||
test('serialize symbol', t => { | ||
t.plan(2) | ||
t.equal(serialize(undefined), 'undefined') | ||
}) | ||
t.assert.deepStrictEqual(serialize(Symbol('a')), 'Symbol("a")') | ||
t.assert.deepStrictEqual(serialize(Symbol()), 'Symbol()') // eslint-disable-line symbol-description | ||
}) | ||
t.test('symbol', t => { | ||
t.plan(2) | ||
test('serialize null', t => { | ||
t.plan(1) | ||
t.equal(serialize(Symbol('a')), 'Symbol("a")') | ||
t.equal(serialize(Symbol()), 'Symbol()') // eslint-disable-line symbol-description | ||
}) | ||
t.assert.deepStrictEqual(serialize(null), 'null') | ||
}) | ||
t.test('object', t => { | ||
t.plan(7) | ||
test('serialize RegExp', t => { | ||
t.plan(1) | ||
t.test('null', t => { | ||
t.plan(1) | ||
t.assert.deepStrictEqual(serialize(/0-9/gi), '/0-9/gi') | ||
}) | ||
t.equal(serialize(null), 'null') | ||
}) | ||
test('serialize Date', t => { | ||
t.plan(1) | ||
t.test('RegExp', t => { | ||
t.plan(1) | ||
t.assert.deepStrictEqual(serialize(new Date(0)), 'new Date(0)') | ||
}) | ||
t.equal(serialize(/0-9/gi), '/0-9/gi') | ||
}) | ||
test('serialize Array', t => { | ||
t.plan(5) | ||
t.test('Date', t => { | ||
t.plan(1) | ||
t.assert.deepStrictEqual(serialize([]), '[]') | ||
t.assert.deepStrictEqual(serialize(['a']), '["a"]') | ||
t.assert.deepStrictEqual(serialize([1, 1n, 'a', true]), '[1,1n,"a",true]') | ||
t.assert.deepStrictEqual(serialize([{}]), '[{}]') | ||
t.assert.deepStrictEqual(serialize([{ a: [{}] }]), '[{"a":[{}]}]') | ||
}) | ||
t.equal(serialize(new Date(0)), 'new Date(0)') | ||
}) | ||
test('serialize POJO', t => { | ||
t.plan(3) | ||
t.test('Array', t => { | ||
t.plan(5) | ||
t.assert.deepStrictEqual(serialize({}), '{}') | ||
t.assert.deepStrictEqual(serialize({ key: 'value' }), '{"key":"value"}') | ||
t.assert.deepStrictEqual(serialize({ null: null, undefined }), '{"null":null,"undefined":undefined}') | ||
}) | ||
t.equal(serialize([]), '[]') | ||
t.equal(serialize(['a']), '["a"]') | ||
t.equal(serialize([1, 1n, 'a', true]), '[1,1n,"a",true]') | ||
t.equal(serialize([{}]), '[{}]') | ||
t.equal(serialize([{ a: [{}] }]), '[{"a":[{}]}]') | ||
}) | ||
test('serialize Set', t => { | ||
t.plan(3) | ||
t.test('POJO', t => { | ||
t.plan(3) | ||
t.assert.deepStrictEqual(serialize(new Set()), 'new Set([])') | ||
t.assert.deepStrictEqual(serialize(new Set(['a'])), 'new Set(["a"])') | ||
t.assert.deepStrictEqual(serialize(new Set(['a', {}])), 'new Set(["a",{}])') | ||
}) | ||
t.equal(serialize({}), '{}') | ||
t.equal(serialize({ key: 'value' }), '{"key":"value"}') | ||
t.equal(serialize({ null: null, undefined }), '{"null":null,"undefined":undefined}') | ||
}) | ||
test('serialize Map', t => { | ||
t.plan(3) | ||
t.test('Set', t => { | ||
t.plan(3) | ||
t.assert.deepStrictEqual(serialize(new Map()), 'new Map([])') | ||
t.assert.deepStrictEqual(serialize(new Map([['a', 1]])), 'new Map([["a",1]])') | ||
const map = new Map() | ||
map.set('b', 1) | ||
t.equal(serialize(new Set()), 'new Set([])') | ||
t.equal(serialize(new Set(['a'])), 'new Set(["a"])') | ||
t.equal(serialize(new Set(['a', {}])), 'new Set(["a",{}])') | ||
}) | ||
t.test('Map', t => { | ||
t.plan(3) | ||
t.equal(serialize(new Map()), 'new Map([])') | ||
t.equal(serialize(new Map([['a', 1]])), 'new Map([["a",1]])') | ||
const map = new Map() | ||
map.set('b', 1) | ||
t.equal(serialize(map), 'new Map([["b",1]])') | ||
}) | ||
}) | ||
t.assert.deepStrictEqual(serialize(map), 'new Map([["b",1]])') | ||
}) |
@@ -5,3 +5,3 @@ 'use strict' | ||
const resolve = require('node:path').resolve | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const yaml = require('yaml') | ||
@@ -38,6 +38,6 @@ const Fastify = require('fastify') | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
}) | ||
@@ -65,6 +65,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger json') | ||
t.assert.ok(true, 'valid swagger json') | ||
}) | ||
@@ -96,7 +96,38 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.matchSnapshot(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.strictEqual(res.payload, `openapi: 3.0.0 | ||
info: | ||
description: Test swagger specification | ||
version: 1.0.0 | ||
title: Test swagger specification | ||
contact: | ||
email: super.developer@gmail.com | ||
servers: | ||
- url: http://localhost:4000/ | ||
description: Localhost (uses test data) | ||
paths: | ||
/status: | ||
get: | ||
description: Status route, so we can check if server is alive | ||
tags: | ||
- Status | ||
responses: | ||
"200": | ||
description: Server is alive | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
health: | ||
type: boolean | ||
date: | ||
type: string | ||
example: | ||
health: true | ||
date: 2018-02-19T15:36:46.758Z | ||
`) | ||
t.assert.ok(true, 'valid swagger yaml') | ||
}) | ||
@@ -132,4 +163,8 @@ | ||
const payload = JSON.parse(res.payload) | ||
t.matchSnapshot(JSON.stringify(payload, null, 2)) | ||
t.pass('valid explicitly passed spec document') | ||
t.assert.deepStrictEqual(payload, { | ||
message: 'Route GET:/documentation/json not found', | ||
error: 'Not Found', | ||
statusCode: 404 | ||
}) | ||
t.assert.ok(true, 'valid explicitly passed spec document') | ||
}) | ||
@@ -161,3 +196,3 @@ | ||
t.equal(res.statusCode, 404) | ||
t.assert.deepStrictEqual(res.statusCode, 404) | ||
} | ||
@@ -171,4 +206,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.equal(exampleStaticSpecificationYaml, res.payload) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(exampleStaticSpecificationYaml, res.payload) | ||
} | ||
@@ -182,3 +217,3 @@ | ||
t.equal(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
} | ||
@@ -209,3 +244,3 @@ }) | ||
t.equal(res.statusCode, 410) | ||
t.assert.deepStrictEqual(res.statusCode, 410) | ||
}) | ||
@@ -237,4 +272,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.equal(oauthRedirectHtml, res.payload) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(oauthRedirectHtml, res.payload) | ||
}) | ||
@@ -265,4 +300,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.equal(oauthRedirectHtml, res.payload) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(oauthRedirectHtml, res.payload) | ||
}) | ||
@@ -290,6 +325,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
} | ||
@@ -303,6 +338,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
} | ||
@@ -331,5 +366,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.pass('valid swagger json') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.ok(true, 'valid swagger json') | ||
} | ||
@@ -343,5 +378,5 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.pass('valid swagger json') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.ok(true, 'valid swagger json') | ||
} | ||
@@ -369,6 +404,6 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
} | ||
@@ -382,6 +417,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/x-yaml') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/x-yaml') | ||
yaml.parse(res.payload) | ||
t.pass('valid swagger yaml') | ||
t.assert.ok(true, 'valid swagger yaml') | ||
} | ||
@@ -409,5 +444,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.pass('valid swagger json') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.ok(true, 'valid swagger json') | ||
} | ||
@@ -421,6 +456,6 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.equal(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.pass('valid swagger json') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'application/json; charset=utf-8') | ||
t.assert.ok(true, 'valid swagger json') | ||
} | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -20,4 +20,4 @@ const fastifySwagger = require('@fastify/swagger') | ||
t.equal(res.statusCode, 200) | ||
t.ok(res.payload.includes('const config = {}')) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.ok(res.payload.includes('const config = {}')) | ||
}) | ||
@@ -41,4 +41,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.ok(res.payload.includes("const config = {\"onComplete\":() => { alert('test') }}")) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.ok(res.payload.includes("const config = {\"onComplete\":() => { alert('test') }}")) | ||
}) | ||
@@ -58,4 +58,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.ok(res.payload.includes('ui.initOAuth({})')) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.ok(res.payload.includes('ui.initOAuth({})')) | ||
}) | ||
@@ -79,4 +79,4 @@ | ||
t.equal(res.statusCode, 200) | ||
t.ok(res.payload.includes('ui.initOAuth({"clientId":"someId"})')) | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.ok(res.payload.includes('ui.initOAuth({"clientId":"someId"})')) | ||
}) | ||
@@ -97,3 +97,3 @@ | ||
const res = await fastify.inject('/documentation/static/swagger-initializer.js') | ||
t.equal(res.body.indexOf(Buffer.from('foobar').toString('base64')) > -1, true) | ||
t.assert.deepStrictEqual(res.body.indexOf(Buffer.from('foobar').toString('base64')) > -1, true) | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -26,7 +26,7 @@ const fastifySwagger = require('@fastify/swagger') | ||
t.equal(typeof res.payload, 'string') | ||
t.notMatch(res.payload, /theme\/special\.js/) | ||
t.notMatch(res.payload, /theme\/favicon\.png/) | ||
t.notMatch(res.payload, /theme\/theme\.css/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.deepStrictEqual(/theme\/special\.js/.test(res.payload), false) | ||
t.assert.deepStrictEqual(/theme\/favicon\.png/.test(res.payload), false) | ||
t.assert.deepStrictEqual(/theme\/theme\.css/.test(res.payload), false) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
}) | ||
@@ -70,7 +70,7 @@ | ||
t.equal(typeof res.payload, 'string') | ||
t.match(res.payload, /theme\/special\.js/) | ||
t.match(res.payload, /theme\/favicon\.png/) | ||
t.match(res.payload, /theme\/theme\.css/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.match(res.payload, /theme\/special\.js/) | ||
t.assert.match(res.payload, /theme\/favicon\.png/) | ||
t.assert.match(res.payload, /theme\/theme\.css/) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
@@ -82,3 +82,3 @@ { | ||
}) | ||
t.equal(res.payload, 'alert("loaded test-theme")') | ||
t.assert.deepStrictEqual(res.payload, 'alert("loaded test-theme")') | ||
} | ||
@@ -91,4 +91,4 @@ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'image/png') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'image/png') | ||
} | ||
@@ -101,3 +101,3 @@ | ||
}) | ||
t.equal(res.payload, '* {border: 1px red solid;}') | ||
t.assert.deepStrictEqual(res.payload, '* {border: 1px red solid;}') | ||
} | ||
@@ -130,5 +130,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.match(res.payload, /theme\/special\.js/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.match(res.payload, /theme\/special\.js/) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
@@ -140,3 +140,3 @@ { | ||
}) | ||
t.equal(res.payload, 'alert("loaded test-theme")') | ||
t.assert.deepStrictEqual(res.payload, 'alert("loaded test-theme")') | ||
} | ||
@@ -169,5 +169,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.match(res.payload, /theme\/theme\.css/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.match(res.payload, /theme\/theme\.css/) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
@@ -179,3 +179,3 @@ { | ||
}) | ||
t.equal(res.payload, '* {border: 1px red solid;}') | ||
t.assert.deepStrictEqual(res.payload, '* {border: 1px red solid;}') | ||
} | ||
@@ -214,5 +214,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.match(res.payload, /theme\/favicon\.png/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.match(res.payload, /theme\/favicon\.png/) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
@@ -224,4 +224,4 @@ { | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'image/png') | ||
t.assert.deepStrictEqual(res.statusCode, 200) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'image/png') | ||
} | ||
@@ -252,5 +252,5 @@ }) | ||
t.equal(typeof res.payload, 'string') | ||
t.match(res.payload, /<title>My custom title<\/title>/) | ||
t.equal(res.headers['content-type'], 'text/html; charset=utf-8') | ||
t.assert.deepStrictEqual(typeof res.payload, 'string') | ||
t.assert.match(res.payload, /<title>My custom title<\/title>/) | ||
t.assert.deepStrictEqual(res.headers['content-type'], 'text/html; charset=utf-8') | ||
}) |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
@@ -55,5 +55,5 @@ const fastifySwagger = require('@fastify/swagger') | ||
transformSpecification: function (swaggerObject, req, reply) { | ||
t.not(swaggerObject, fastify.swagger()) | ||
t.ok(req) | ||
t.ok(reply) | ||
t.assert.notEqual(swaggerObject, fastify.swagger()) | ||
t.assert.ok(req) | ||
t.assert.ok(reply) | ||
swaggerObject.swagger = '2.1' | ||
@@ -71,4 +71,4 @@ return swaggerObject | ||
t.notSame(fastify.swagger(), JSON.parse(res.body)) | ||
t.equal(JSON.parse(res.body).swagger, '2.1') | ||
t.assert.notDeepEqual(fastify.swagger(), JSON.parse(res.body)) | ||
t.assert.strictEqual(JSON.parse(res.body).swagger, '2.1') | ||
}) | ||
@@ -123,5 +123,5 @@ | ||
transformSpecification: function (swaggerObject, req, reply) { | ||
t.equal(swaggerObject, fastify.swagger()) | ||
t.ok(req) | ||
t.ok(reply) | ||
t.assert.deepStrictEqual(swaggerObject, fastify.swagger()) | ||
t.assert.ok(req) | ||
t.assert.ok(reply) | ||
return swaggerObject | ||
@@ -141,3 +141,3 @@ } | ||
t.strictSame(swagger, JSON.parse(res.body)) | ||
t.assert.deepStrictEqual(swagger, JSON.parse(res.body)) | ||
}) | ||
@@ -192,4 +192,4 @@ | ||
swaggerObject.swagger = '2.1' | ||
t.ok(req) | ||
t.ok(reply) | ||
t.assert.ok(req) | ||
t.assert.ok(reply) | ||
return swaggerObject | ||
@@ -207,4 +207,4 @@ } | ||
t.same(fastify.swagger(), swaggerPre) | ||
t.equal(yaml.parse(res.body).swagger, '2.1') | ||
t.assert.deepStrictEqual(fastify.swagger(), swaggerPre) | ||
t.assert.deepStrictEqual(yaml.parse(res.body).swagger, '2.1') | ||
}) | ||
@@ -259,5 +259,5 @@ | ||
transformSpecification: function (swaggerObject, req, reply) { | ||
t.equal(swaggerObject, fastify.swagger()) | ||
t.ok(req) | ||
t.ok(reply) | ||
t.assert.deepStrictEqual(swaggerObject, fastify.swagger()) | ||
t.assert.ok(req) | ||
t.assert.ok(reply) | ||
return swaggerObject | ||
@@ -275,3 +275,3 @@ } | ||
t.same(fastify.swagger(), swaggerPre) | ||
t.assert.deepStrictEqual(fastify.swagger(), swaggerPre) | ||
}) |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2575673
15
90
8671
1
Updated@fastify/static@^8.0.0
Updatedfastify-plugin@^5.0.0