'use strict'

const fp = require('fastify-plugin')
const swagger = require('fastify-swagger')

module.exports = fp(async (fastify, opts) => {
  const swaggerOptions = Object.assign ({}, {
    routePrefix: '/documentation',
    swagger: {
      info: {{{json generic.info}}},
      host: {{{json generic.host}}},
      tags: {{{json generic.tags}}},
      schemes: {{{json generic.schemes}}},
      securityDefinitions: {{{json generic.securityDefinitions}}},
      externalDocs: {{{json generic.externalDocs}}},
      endpoints: {{{json generic.endpoints}}}
    },
    exposeRoute: true
  }, opts.swagger)

  fastify.register(swagger, swaggerOptions)
})
