import swaggerJsdoc from "swagger-jsdoc";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const options = {
  definition: {
    openapi: "3.0.0",
    info: {
      title: "Airpero SaaS API Documentation",
      version: "1.0.0",
      description: "API for Merchant Dashboards, SuperAdmin controls, and External Integrations.",
      contact: {
        name: "Airpero Support",
        email: "support@airpero.com",
      },
    },
    servers: [
      {
        url: "http://localhost:8200/api/v1",
        description: "Development server",
      },
      {
        url: "https://sandbox.v1.airpero.com/api/v1",
        description: "Sandbox server",
      },
      {
        url: "https://saasstaging.airpero.com/api/v1",
        description: "Staging server",
      },
    ],
  },
  // --- SCAN THE DEDICATED DOCS FOLDER USING ABSOLUTE PATH ---
  apis: [path.join(__dirname, "../docs/*.yaml")], 
};

const swaggerSpec = swaggerJsdoc(options);

export default swaggerSpec;
