{
    "openapi": "3.0.0",
    "info": {
        "title": "Unison API",
        "description": "REST API сервиса Unison — систематизация медицинских данных пользователя. Документация генерируется из PHPDoc (swagger-php). Swagger UI: \/api\/docs\/",
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "https:\/\/api.basisgg.com",
            "description": "Production"
        },
        {
            "url": "http:\/\/api.basisgg.local",
            "description": "Local"
        }
    ],
    "paths": {
        "\/api\/v1\/auth\/login\/": {
            "post": {
                "tags": [
                    "Auth"
                ],
                "summary": "Вход по телефону и паролю",
                "operationId": "authLogin",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application\/json": {
                            "schema": {
                                "required": [
                                    "phone",
                                    "password"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string",
                                        "example": "+79231024680"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "secret123"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Успешный вход",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthTokenResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Неверные учётные данные",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/v1\/auth\/register\/": {
            "post": {
                "tags": [
                    "Auth"
                ],
                "summary": "Регистрация пациента",
                "operationId": "authRegister",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application\/json": {
                            "schema": {
                                "required": [
                                    "name",
                                    "phone"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "example": "Алексей"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "example": "+79231024680"
                                    },
                                    "password": {
                                        "description": "Не короче 6 символов; если не передан — генерируется",
                                        "type": "string",
                                        "format": "password"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Пользователь создан",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthTokenResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ошибка валидации",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/v1\/auth\/me\/": {
            "get": {
                "tags": [
                    "Auth"
                ],
                "summary": "Текущий пользователь",
                "operationId": "authMe",
                "responses": {
                    "200": {
                        "description": "Профиль",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthProfileResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/auth\/logout\/": {
            "post": {
                "tags": [
                    "Auth"
                ],
                "summary": "Выход (отзыв токена)",
                "operationId": "authLogout",
                "responses": {
                    "200": {
                        "description": "Токен отозван",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/auth\/sms\/send\/": {
            "post": {
                "tags": [
                    "Auth"
                ],
                "summary": "Отправка SMS-кода для входа",
                "operationId": "authSmsSend",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application\/json": {
                            "schema": {
                                "required": [
                                    "phone"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string",
                                        "example": "+79231024680"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Код отправлен",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/SmsSendResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ошибка",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/SmsSendResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/v1\/auth\/sms\/verify\/": {
            "post": {
                "tags": [
                    "Auth"
                ],
                "summary": "Проверка SMS-кода и выдача токена",
                "operationId": "authSmsVerify",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application\/json": {
                            "schema": {
                                "required": [
                                    "phone",
                                    "code"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string",
                                        "example": "+79231024680"
                                    },
                                    "code": {
                                        "type": "string",
                                        "example": "123456"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Успешный вход",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthTokenResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Неверный или просроченный код",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/v1\/auth\/profile\/": {
            "patch": {
                "tags": [
                    "Auth"
                ],
                "summary": "Обновление профиля",
                "operationId": "authProfileUpdate",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application\/json": {
                            "schema": {
                                "required": [
                                    "firstName"
                                ],
                                "properties": {
                                    "firstName": {
                                        "type": "string",
                                        "example": "Алексей"
                                    },
                                    "lastName": {
                                        "type": "string",
                                        "example": "Иванов"
                                    },
                                    "secondName": {
                                        "type": "string",
                                        "example": "Петрович"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "alex@example.com"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Профиль обновлён",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/AuthProfileResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ошибка валидации",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/dashboard\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Главная ЛК",
                "description": "Статистика, риски, блок «обрати внимание», загрузка файлов",
                "operationId": "lkDashboard",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/navigation\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Меню и заглушки вкладок",
                "operationId": "lkNavigation",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/promo\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Промо в сайдбаре",
                "operationId": "lkPromo",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/labels\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Подписи UI и приветствие",
                "operationId": "lkLabels",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/risks\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Вкладка «Риски»",
                "operationId": "lkRisks",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/data\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Вкладка «Данные»",
                "operationId": "lkData",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/recommendations\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Вкладка «Рекомендации»",
                "operationId": "lkRecommendations",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/lk\/purchases\/": {
            "get": {
                "tags": [
                    "LK"
                ],
                "summary": "Вкладка «Покупки»",
                "operationId": "lkPurchases",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/LkOkResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Требуется авторизация",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/ApiError"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "unisonToken": []
                    }
                ]
            }
        },
        "\/api\/v1\/health\/": {
            "get": {
                "tags": [
                    "Public"
                ],
                "summary": "Проверка доступности API",
                "operationId": "health",
                "responses": {
                    "200": {
                        "description": "Сервис доступен",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/HealthResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/v1\/bootstrap\/": {
            "get": {
                "tags": [
                    "Public"
                ],
                "summary": "Гостевой контент для UI",
                "description": "Настройки приложения, навигация, тексты авторизации, промо",
                "operationId": "bootstrap",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "required": [
                                        "status",
                                        "app",
                                        "dashboard",
                                        "navigation",
                                        "auth",
                                        "promo"
                                    ],
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "enum": [
                                                "ok"
                                            ]
                                        },
                                        "app": {
                                            "type": "object"
                                        },
                                        "dashboard": {
                                            "type": "object"
                                        },
                                        "navigation": {
                                            "type": "object"
                                        },
                                        "auth": {
                                            "type": "object"
                                        },
                                        "promo": {
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "options": {
                "tags": [
                    "Public"
                ],
                "summary": "CORS preflight",
                "operationId": "bootstrapOptions",
                "responses": {
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "ApiError": {
                "required": [
                    "status",
                    "message"
                ],
                "properties": {
                    "status": {
                        "description": "Общие схемы Unison API v1.",
                        "type": "string",
                        "enum": [
                            "error"
                        ],
                        "example": "error"
                    },
                    "message": {
                        "type": "string",
                        "example": "Требуется авторизация"
                    }
                },
                "type": "object"
            },
            "AuthUser": {
                "required": [
                    "id",
                    "name",
                    "phone",
                    "initial"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "38032"
                    },
                    "name": {
                        "type": "string",
                        "example": "Алексей Иванов"
                    },
                    "firstName": {
                        "type": "string",
                        "example": "Алексей"
                    },
                    "lastName": {
                        "type": "string",
                        "example": "Иванов"
                    },
                    "secondName": {
                        "type": "string",
                        "example": "Петрович"
                    },
                    "phone": {
                        "type": "string",
                        "example": "+79231024680"
                    },
                    "email": {
                        "type": "string",
                        "example": "9231024680@unison.local"
                    },
                    "initial": {
                        "type": "string",
                        "example": "А"
                    }
                },
                "type": "object"
            },
            "AuthTokenResponse": {
                "required": [
                    "status",
                    "token",
                    "expires_at",
                    "user"
                ],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok"
                        ],
                        "example": "ok"
                    },
                    "token": {
                        "type": "string",
                        "example": "a1b2c3..."
                    },
                    "expires_at": {
                        "type": "string",
                        "format": "date-time",
                        "example": "2026-07-11T12:00:00+07:00"
                    },
                    "user": {
                        "$ref": "#\/components\/schemas\/AuthUser"
                    }
                },
                "type": "object"
            },
            "AuthProfileResponse": {
                "required": [
                    "status",
                    "user"
                ],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok"
                        ],
                        "example": "ok"
                    },
                    "user": {
                        "$ref": "#\/components\/schemas\/AuthUser"
                    }
                },
                "type": "object"
            },
            "AuthOkResponse": {
                "required": [
                    "status"
                ],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok"
                        ],
                        "example": "ok"
                    }
                },
                "type": "object"
            },
            "SmsSendResponse": {
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok",
                            "error"
                        ],
                        "example": "ok"
                    },
                    "message": {
                        "type": "string",
                        "example": "Код отправлен"
                    },
                    "expires_in": {
                        "type": "integer",
                        "example": 600
                    },
                    "retry_after": {
                        "type": "integer",
                        "example": 30
                    }
                },
                "type": "object"
            },
            "HealthResponse": {
                "required": [
                    "status",
                    "message",
                    "service",
                    "timestamp"
                ],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok"
                        ],
                        "example": "ok"
                    },
                    "message": {
                        "type": "string",
                        "example": "Unison API"
                    },
                    "service": {
                        "type": "string",
                        "example": "prakter"
                    },
                    "timestamp": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "type": "object"
            },
            "LkOkResponse": {
                "required": [
                    "status"
                ],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "ok"
                        ],
                        "example": "ok"
                    },
                    "stats": {
                        "description": "Статистика дашборда (dashboard)",
                        "type": "object"
                    },
                    "accordionRows": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "attentionItems": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "collect": {
                        "type": "object"
                    },
                    "uploadActions": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "tabs": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "stubTabs": {
                        "type": "object"
                    },
                    "promo": {
                        "type": "object"
                    },
                    "labels": {
                        "type": "object"
                    },
                    "risks": {
                        "type": "object"
                    },
                    "data": {
                        "type": "object"
                    },
                    "recommendations": {
                        "type": "object"
                    },
                    "purchases": {
                        "type": "object"
                    }
                },
                "type": "object"
            }
        },
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "description": "Токен из POST \/api\/v1\/auth\/login\/, register\/ или sms\/verify\/",
                "bearerFormat": "opaque",
                "scheme": "bearer"
            },
            "unisonToken": {
                "type": "apiKey",
                "description": "Запасной способ передачи токена (если nginx не пробрасывает Authorization)",
                "name": "X-Unison-Token",
                "in": "header"
            }
        }
    },
    "tags": [
        {
            "name": "Auth",
            "description": "Авторизация и регистрация"
        },
        {
            "name": "LK",
            "description": "Личный кабинет (мок-данные, требуется Bearer-токен)"
        },
        {
            "name": "Public",
            "description": "Публичные методы без авторизации"
        }
    ]
}