forked from fastify/fastify-swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (22 loc) · 787 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict'
const fp = require('fastify-plugin')
const { readFile } = require('fs/promises')
async function fastifySwaggerUi (fastify, opts) {
fastify.decorate('swaggerCSP', require('./static/csp.json'))
fastify.register(require('./lib/routes'), {
prefix: opts.routePrefix || '/documentation',
uiConfig: opts.uiConfig || {},
initOAuth: opts.initOAuth || {},
hooks: opts.uiHooks,
theme: opts.theme || {},
logo: opts.logo || { type: 'image/svg+xml', content: await readFile(require.resolve('./static/logo.svg')) },
...opts
})
}
module.exports = fp(fastifySwaggerUi, {
fastify: '4.x',
name: '@fastify/swagger-ui',
dependencies: ['@fastify/swagger']
})
module.exports.default = fastifySwaggerUi
module.exports.fastifySwaggerUi = fastifySwaggerUi