Aktueller Stand
This commit is contained in:
9
backend/node_modules/@fastify/swagger-ui/lib/index-html.js
generated
vendored
9
backend/node_modules/@fastify/swagger-ui/lib/index-html.js
generated
vendored
@@ -1,10 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
function indexHtml (opts) {
|
||||
const hasLeadingSlash = /^\//.test(opts.prefix)
|
||||
let routePrefix = opts.prefix
|
||||
if (opts.indexPrefix) {
|
||||
routePrefix = `${opts.indexPrefix.replace(/\/$/, '')}/${opts.prefix.replace(/^\//, '')}`
|
||||
}
|
||||
return (url) => {
|
||||
const hasTrailingSlash = /\/$/.test(url)
|
||||
const prefix = hasTrailingSlash ? `.${opts.staticPrefix}` : `${hasLeadingSlash ? '.' : ''}${opts.prefix}${opts.staticPrefix}`
|
||||
const prefix = hasTrailingSlash ? `.${opts.staticPrefix}` : `${routePrefix}${opts.staticPrefix}`
|
||||
return `<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -21,7 +24,7 @@ function indexHtml (opts) {
|
||||
<link rel="icon" type="image/png" href="${prefix}/favicon-16x16.png" sizes="16x16" />
|
||||
`}
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="${prefix}/swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
|
||||
14
backend/node_modules/@fastify/swagger-ui/lib/routes.js
generated
vendored
14
backend/node_modules/@fastify/swagger-ui/lib/routes.js
generated
vendored
@@ -28,7 +28,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
}
|
||||
|
||||
if (typeof staticCSP === 'string' || typeof opts.transformStaticCSP === 'function') {
|
||||
fastify.addHook('onSend', function (request, reply, payload, done) {
|
||||
fastify.addHook('onSend', function (_request, reply, _payload, done) {
|
||||
// set static csp when it is passed
|
||||
if (typeof staticCSP === 'string') {
|
||||
reply.header('content-security-policy', staticCSP.trim())
|
||||
@@ -62,7 +62,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
method: 'GET',
|
||||
schema: { hide: true },
|
||||
...hooks,
|
||||
handler: (req, reply) => {
|
||||
handler: (_req, reply) => {
|
||||
reply
|
||||
.header('content-type', 'text/css; charset=UTF-8')
|
||||
.send(cssFile.content)
|
||||
@@ -78,7 +78,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
method: 'GET',
|
||||
schema: { hide: true },
|
||||
...hooks,
|
||||
handler: (req, reply) => {
|
||||
handler: (_req, reply) => {
|
||||
reply
|
||||
.header('content-type', 'application/javascript; charset=utf-8')
|
||||
.send(jsFile.content)
|
||||
@@ -94,7 +94,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
method: 'GET',
|
||||
schema: { hide: true },
|
||||
...hooks,
|
||||
handler: (req, reply) => {
|
||||
handler: (_req, reply) => {
|
||||
reply
|
||||
.header('content-type', favicon.type)
|
||||
.send(favicon.content)
|
||||
@@ -135,7 +135,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
method: 'GET',
|
||||
schema: { hide: true },
|
||||
...hooks,
|
||||
handler: (req, reply) => {
|
||||
handler: (_req, reply) => {
|
||||
reply
|
||||
.header('content-type', 'application/javascript; charset=utf-8')
|
||||
.send(swaggerInitializerContent)
|
||||
@@ -158,7 +158,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
: function (req, reply) {
|
||||
reply.send(transformSpecification(fastify.swagger(), req, reply))
|
||||
}
|
||||
: function (req, reply) {
|
||||
: function (_req, reply) {
|
||||
reply.send(fastify.swagger())
|
||||
}
|
||||
})
|
||||
@@ -180,7 +180,7 @@ function fastifySwagger (fastify, opts, done) {
|
||||
.type('application/x-yaml')
|
||||
.send(yaml.stringify(transformSpecification(fastify.swagger(), req, reply)))
|
||||
}
|
||||
: function (req, reply) {
|
||||
: function (_req, reply) {
|
||||
reply
|
||||
.type('application/x-yaml')
|
||||
.send(fastify.swagger({ yaml: true }))
|
||||
|
||||
28
backend/node_modules/@fastify/swagger-ui/lib/swagger-initializer.js
generated
vendored
28
backend/node_modules/@fastify/swagger-ui/lib/swagger-initializer.js
generated
vendored
@@ -3,8 +3,11 @@
|
||||
const serialize = require('./serialize')
|
||||
|
||||
function swaggerInitializer (opts) {
|
||||
const logoBase64 = Buffer.from(opts.logo.content).toString('base64')
|
||||
const logoData = `data:${opts.logo.type};base64,${logoBase64}`
|
||||
const hasLogo = opts.logo && opts.logo.content !== undefined
|
||||
const logoBase64 = hasLogo && Buffer.from(opts.logo.content).toString('base64')
|
||||
const logoData = hasLogo && `data:${opts.logo.type};base64,${logoBase64}`
|
||||
const logoHref = hasLogo && opts.logo.href
|
||||
const logoTarget = hasLogo && opts.logo.target
|
||||
|
||||
return `window.onload = function () {
|
||||
function waitForElement(selector) {
|
||||
@@ -12,14 +15,14 @@ function swaggerInitializer (opts) {
|
||||
if (document.querySelector(selector)) {
|
||||
return resolve(document.querySelector(selector));
|
||||
}
|
||||
|
||||
|
||||
const observer = new MutationObserver(mutations => {
|
||||
if (document.querySelector(selector)) {
|
||||
observer.disconnect();
|
||||
resolve(document.querySelector(selector));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
@@ -28,10 +31,10 @@ function swaggerInitializer (opts) {
|
||||
});
|
||||
}
|
||||
function resolveUrl(url) {
|
||||
var currentHref = window.location.href;
|
||||
let currentHref = window.location.href;
|
||||
currentHref = currentHref.split('#', 1)[0];
|
||||
currentHref = currentHref.endsWith('/') ? currentHref : currentHref + '/';
|
||||
var anchor = document.createElement('a');
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = currentHref + url;
|
||||
return anchor.href
|
||||
}
|
||||
@@ -55,17 +58,22 @@ function swaggerInitializer (opts) {
|
||||
});
|
||||
|
||||
const ui = SwaggerUIBundle(resConfig)
|
||||
const logoData = '${logoData}'
|
||||
|
||||
if (logoData && resConfig.layout === 'StandaloneLayout') {
|
||||
${logoData
|
||||
? `
|
||||
if (resConfig.layout === 'StandaloneLayout') {
|
||||
// Replace the logo
|
||||
waitForElement('#swagger-ui > section > div.topbar > div > div > a').then((link) => {
|
||||
const img = document.createElement('img')
|
||||
img.height = 40
|
||||
img.src = logoData
|
||||
img.src = '${logoData}'
|
||||
${logoHref ? `img.href = '${logoHref}'` : 'img.href = resolveUrl(\'/\')'}
|
||||
${logoTarget ? `img.target = '${logoTarget}'` : ''}
|
||||
link.innerHTML = ''
|
||||
link.appendChild(img)
|
||||
})
|
||||
}
|
||||
}`
|
||||
: ''}
|
||||
|
||||
ui.initOAuth(${serialize(opts.initOAuth)})
|
||||
}`
|
||||
|
||||
Reference in New Issue
Block a user