"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupSwagger = setupSwagger;
const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
const argusSwagger_1 = require("./argusSwagger");
const options = {
    definition: {
        openapi: '3.0.0',
        info: {
            title: 'Ask Argus API',
            version: '1.0.0',
            description: 'API documentation for Ask Argus - AI-powered query agent for traces, spans, sessions, and more',
            contact: {
                name: 'Trusys Support',
            },
        },
        servers: [
            {
                url: '/api/argus',
                description: 'API Server',
            },
        ],
        tags: [
            {
                name: 'Ask Argus',
                description: 'Main query endpoint for Ask Argus AI agent',
            },
            {
                name: 'TruPulse - Traces',
                description: 'TruPulse domain APIs for traces',
            },
            {
                name: 'TruPulse - Spans',
                description: 'TruPulse domain APIs for spans',
            },
            {
                name: 'TruPulse - Sessions',
                description: 'TruPulse domain APIs for sessions',
            },
            {
                name: 'TruEval - Evaluations',
                description: 'TruEval domain APIs for evaluation results and rollups',
            },
            {
                name: 'TruScout - Security Findings',
                description: 'TruScout domain APIs for security findings and rollups',
            },
        ],
        components: {
            parameters: {
                projectId: {
                    name: 'projectId',
                    in: 'query',
                    required: false,
                    schema: {
                        type: 'string',
                    },
                    description: 'Project ID (required if using bearer token, automatically provided with API key)',
                },
                orgId: {
                    name: 'orgId',
                    in: 'query',
                    required: false,
                    schema: {
                        type: 'string',
                    },
                    description: 'Organization ID (required if using bearer token, automatically provided with API key)',
                },
            },
            securitySchemes: {
                bearerAuth: {
                    type: 'http',
                    scheme: 'bearer',
                    bearerFormat: 'JWT',
                    description: 'JWT Bearer token authentication. When using this method, you must provide projectId and orgId in query parameters.',
                },
                apiKeyAuth: {
                    type: 'apiKey',
                    in: 'header',
                    name: 'x-api-key',
                    description: 'API Key authentication. When using this method, projectId and orgId are automatically provided from the API key.',
                },
            },
        },
        security: [
            {
                bearerAuth: [],
            },
            {
                apiKeyAuth: [],
            },
        ],
        paths: {
            ...argusSwagger_1.argusSwaggerSpec,
        },
    },
    apis: [], // We're defining paths directly in the spec
};
const swaggerSpec = (0, swagger_jsdoc_1.default)(options);
/**
 * Setup Swagger UI
 */
function setupSwagger(app) {
    app.use('/api-docs', swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(swaggerSpec, {
        customCss: '.swagger-ui .topbar { display: none }',
        customSiteTitle: 'Ask Argus API Documentation',
        swaggerOptions: {
            persistAuthorization: true,
            displayRequestDuration: true,
            filter: true,
            tryItOutEnabled: true,
        },
    }));
}
//# sourceMappingURL=swaggerSetup.js.map