{
  "openapi": "3.0.3",
  "info": {
    "title": "Sous Clinic — Public API",
    "version": "1.0.0",
    "description": "Superfície pública da API Sous Clinic usada pela landing page (registro, verificação de telefone e health). Endpoints autenticados da clínica exigem JWT via app.sousclinic.com.",
    "contact": {
      "name": "Sous Clinic",
      "email": "contato@sousclinic.com",
      "url": "https://sousclinic.com"
    }
  },
  "servers": [
    {
      "url": "https://api.sousclinic.com",
      "description": "Produção"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Health check da API",
        "tags": ["Health"],
        "responses": {
          "200": {
            "description": "API saudável",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" },
                    "timestamp": { "type": "string", "format": "date-time" },
                    "version": { "type": "string" },
                    "environment": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/register": {
      "post": {
        "operationId": "registerClinic",
        "summary": "Registra uma nova clínica",
        "tags": ["Auth"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "business_name",
                  "business_type",
                  "full_name",
                  "email",
                  "phone_number_id",
                  "password"
                ],
                "properties": {
                  "business_name": { "type": "string", "minLength": 2 },
                  "business_type": {
                    "type": "string",
                    "enum": ["clinic", "consulting_room", "hospital", "other"]
                  },
                  "full_name": { "type": "string", "minLength": 2 },
                  "email": { "type": "string", "format": "email" },
                  "phone_number_id": { "type": "string" },
                  "password": { "type": "string", "minLength": 8 },
                  "specialty": { "type": "string" },
                  "number_of_employees": { "type": "integer", "minimum": 1 },
                  "privacy_policy_accepted": { "type": "boolean" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Conta criada; verificação de telefone pendente" },
          "409": { "description": "E-mail já cadastrado" }
        }
      }
    },
    "/api/auth/verify-phone": {
      "post": {
        "operationId": "verifyPhone",
        "summary": "Confirma o código de 6 dígitos enviado por WhatsApp",
        "tags": ["Auth"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["code"],
                "properties": {
                  "code": { "type": "string", "minLength": 6, "maxLength": 6 }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Telefone verificado" },
          "400": { "description": "Código inválido ou expirado" }
        }
      }
    },
    "/api/auth/resend-phone-verification": {
      "post": {
        "operationId": "resendPhoneVerification",
        "summary": "Reenvia o código de verificação por WhatsApp",
        "tags": ["Auth"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": { "type": "string", "format": "email" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Código reenviado" }
        }
      }
    }
  }
}
