"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc")); const http_1 = require("../base/http"); const swagger_ui_express_1 = __importDefault(require("swagger-ui-express")); const i18n_1 = require("../base/i18n"); class SwaggerUiSetupMiddleware extends http_1.Middleware { constructor() { super(...arguments); this.order = -96; this.route = this.context.swaggerRoute; this.action = this.getSetup(); } getSetup() { if (!this.context.swaggerDocsPath) return (req, res, next) => { next(); }; const swaggerOptions = { swaggerDefinition: { openapi: '3.0.1', info: { title: this.context.swaggerTitle, version: this.context.swaggerApiVersion, description: this.context.swaggerDescription, }, servers: [ { url: this.context.host } ], }, apis: [this.context.swaggerDocsPath], }; if (this.context.swaggerComponents) swaggerOptions.swaggerDefinition.components = this.context.swaggerComponents; if (this.context.swaggerSecurity) swaggerOptions.swaggerDefinition.security = this.context.swaggerSecurity; const swaggerDocs = (0, swagger_jsdoc_1.default)(swaggerOptions); this.context.logInfo((0, i18n_1.$$)('org.crazydoctor.expressts.swagger.registered', { path: this.context.swaggerRoute })); return swagger_ui_express_1.default.setup(swaggerDocs); } } exports.default = SwaggerUiSetupMiddleware; //# sourceMappingURL=SwaggerUiSetupMiddleware.js.map