{
 "openapi": "3.1.0",
 "info": {
  "title": "YCP Optimizer API",
  "version": "1.0",
  "description": "Проверка товарного фида под Yandex Commerce Protocol (YCP): запуск по адресу фида, состояние и отчёт в JSON. Оператор — ООО «САРМАТЕХ». Не сервис Яндекса.",
  "contact": {
   "email": "info@ycp-optimizer.ru"
  },
  "license": {
   "name": "CC BY 4.0",
   "url": "https://creativecommons.org/licenses/by/4.0/"
  }
 },
 "servers": [
  {
   "url": "https://ycp-optimizer.ru"
  }
 ],
 "paths": {
  "/api/v1/check": {
   "post": {
    "operationId": "check",
    "summary": "Запустить проверку фида",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri",
          "description": "Адрес YML-фида или фида Google Merchant, http/https, до 50 МБ"
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Проверка создана",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Created"
        }
       }
      }
     },
     "400": {
      "description": "Неверный адрес"
     },
     "429": {
      "description": "Больше 12 проверок в час с одного адреса"
     }
    }
   }
  },
  "/api/v1/report/{id}": {
   "get": {
    "operationId": "report",
    "summary": "Состояние и отчёт",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z0-9]{16}$"
      }
     },
     {
      "name": "products",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "0",
        "1"
       ],
       "default": "1"
      },
      "description": "0 — без списка товаров"
     }
    ],
    "responses": {
     "200": {
      "description": "Отчёт или текущее состояние (status: queued, parsing, media, done, error)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Report"
        }
       }
      }
     },
     "404": {
      "description": "Отчёт не найден или удалён (90 дней)"
     }
    }
   }
  },
  "/api/v1/stats": {
   "get": {
    "operationId": "stats",
    "summary": "Счётчики проверок",
    "responses": {
     "200": {
      "description": "checks, products"
     }
    }
   }
  },
  "/methodology.json": {
   "get": {
    "operationId": "methodology",
    "summary": "Методика: оси, веса, правила",
    "responses": {
     "200": {
      "description": "JSON"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Created": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "id": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "report_url": {
      "type": "string"
     },
     "json_url": {
      "type": "string"
     },
     "methodology": {
      "type": "string"
     }
    }
   },
   "Issue": {
    "type": "object",
    "properties": {
     "code": {
      "type": "string",
      "example": "YCP-A03"
     },
     "detail": {
      "type": "string"
     }
    }
   },
   "Product": {
    "type": "object",
    "properties": {
     "n": {
      "type": "integer"
     },
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "url": {
      "type": "string"
     },
     "price": {
      "type": "string"
     },
     "cat": {
      "type": "string"
     },
     "score": {
      "type": "integer"
     },
     "axes": {
      "type": "object"
     },
     "issues": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Issue"
      }
     },
     "counts": {
      "type": "object"
     },
     "ucp": {
      "type": "boolean"
     }
    }
   },
   "Report": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "id": {
      "type": "string"
     },
     "number": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "error": {
      "type": "string"
     },
     "methodology": {
      "type": "string"
     },
     "format": {
      "type": "string",
      "enum": [
       "yml",
       "google",
       ""
      ]
     },
     "offers_total": {
      "type": "integer"
     },
     "offers_read": {
      "type": "integer"
     },
     "progress": {
      "type": "object"
     },
     "summary": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "score": {
        "type": "integer"
       },
       "verdict": {
        "type": "string"
       },
       "axes": {
        "type": "object"
       },
       "counts": {
        "type": "object"
       },
       "top": {
        "type": "array"
       },
       "good": {
        "type": "integer"
       },
       "ucp_share": {
        "type": "integer"
       }
      }
     },
     "prev": {
      "type": [
       "object",
       "null"
      ]
     },
     "products": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Product"
      }
     },
     "report_url": {
      "type": "string"
     }
    }
   }
  }
 }
}