{
  "openapi": "3.0.3",
  "info": {
    "title": "Deals Today India API",
    "description": "Public real-time deals aggregation API for top Indian e-commerce platforms (Amazon, Flipkart, Myntra, Ajio).",
    "version": "1.0.0",
    "contact": {
      "name": "Deals Today India",
      "url": "https://deals-today.in"
    }
  },
  "servers": [
    {
      "url": "https://deals-today.in",
      "description": "Production Server"
    }
  ],
  "paths": {
    "/api/deals": {
      "get": {
        "summary": "Search and list live deals",
        "description": "Returns verified real-time discounts with pagination and store filtering.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Keywords to search (e.g. sneakers, kurta, watch)",
            "schema": { "type": "string" }
          },
          {
            "name": "source_type",
            "in": "query",
            "description": "Store filter",
            "schema": {
              "type": "string",
              "enum": ["amazon", "flipkart", "myntra", "ajio"]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of deals to return (default 20, max 100)",
            "schema": { "type": "integer", "default": 20 }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number",
            "schema": { "type": "integer", "default": 1 }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of deal objects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deals": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Deal" }
                    },
                    "total": { "type": "integer" },
                    "page": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/deals/{id}": {
      "get": {
        "summary": "Get deal by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric Deal ID",
            "schema": { "type": "integer" }
          }
        ],
        "responses": {
          "200": {
            "description": "Deal details",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Deal" }
              }
            }
          },
          "404": { "description": "Deal not found" }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "Service Health Check",
        "responses": {
          "200": { "description": "Service is healthy" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Deal": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "title": { "type": "string" },
          "source_type": { "type": "string" },
          "price": { "type": "string" },
          "current_price": { "type": "string" },
          "discount": { "type": "string" },
          "product_link": { "type": "string" },
          "image_url": { "type": "string" },
          "description": { "type": "string" },
          "deal_status": { "type": "string" },
          "is_active": { "type": "boolean" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      }
    }
  }
}
