{
  "openapi": "3.1.0",
  "info": {
    "title": "AI Лоцман — копия API НАШ.ДОМ.РФ",
    "version": "1.0.0",
    "description": "REST API для данных и аналитики новостроек. Обогащаемый источник данных — API НАШ.ДОМ.РФ."
  },
  "servers": [{"url": "https://ailotsman.ru"}],
  "components": {
    "securitySchemes": {"bearerAuth": {"type": "http", "scheme": "bearer"}},
    "schemas": {
      "Error": {"type": "object", "properties": {"error": {"type": "string"}}, "required": ["error"]},
      "District": {"type": "object", "properties": {"around_id": {"type": "string"}, "city": {"type": ["string", "null"]}, "jk_count": {"type": ["integer", "null"]}}},
      "JK": {"type": "object", "properties": {"jk_name": {"type": "string"}, "developer_name": {"type": ["string", "null"]}, "total_lots": {"type": ["integer", "null"]}, "avg_sqm_price_ths": {"type": ["number", "null"]}}}
    },
    "responses": {
      "Unauthorized": {"description": "Токен отсутствует или недействителен", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "Forbidden": {"description": "Нет доступа к окружению", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}
    }
  },
  "paths": {
    "/api/v1/health": {
      "get": {"summary": "Проверка REST-сервиса", "responses": {"200": {"description": "Сервис доступен"}}}
    },
    "/api/v1/districts": {
      "get": {"summary": "Окружения, доступные токену", "security": [{"bearerAuth": []}], "responses": {"200": {"description": "Список окружений"}, "401": {"$ref": "#/components/responses/Unauthorized"}}}
    },
    "/api/v1/districts/{around_id}/jk": {
      "get": {"summary": "ЖК окружения", "security": [{"bearerAuth": []}], "parameters": [{"name": "around_id", "in": "path", "required": true, "schema": {"type": "string"}}], "responses": {"200": {"description": "Список ЖК"}, "401": {"$ref": "#/components/responses/Unauthorized"}, "403": {"$ref": "#/components/responses/Forbidden"}}}
    },
    "/api/v1/districts/{around_id}/sales/{jk_name}": {
      "get": {"summary": "Продажи ЖК по месяцам", "security": [{"bearerAuth": []}], "parameters": [{"name": "around_id", "in": "path", "required": true, "schema": {"type": "string"}}, {"name": "jk_name", "in": "path", "required": true, "schema": {"type": "string"}}], "responses": {"200": {"description": "Статистика продаж"}, "401": {"$ref": "#/components/responses/Unauthorized"}, "403": {"$ref": "#/components/responses/Forbidden"}}}
    }
  }
}
