{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/astranexo-com/json-schema/astranexo-com-service-status-schema.json",
  "title": "ServiceStatus",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/astranexo-com-estado-api-openapi.yml#/components/schemas/ServiceStatus",
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "ok",
        "degraded"
      ],
      "description": "`degraded` (con HTTP 503) cuando la API no puede atender solicitudes."
    },
    "version": {
      "type": "string"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "database": {
      "type": "string",
      "enum": [
        "connected",
        "disconnected"
      ]
    },
    "hacienda": {
      "type": "object",
      "description": "Disponibilidad de Hacienda por ambiente (`staging`, `production`).",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "token": {
            "$ref": "#/$defs/ServiceCheck"
          },
          "api": {
            "$ref": "#/$defs/ServiceCheck"
          },
          "response_time_ms": {
            "type": "number"
          },
          "message": {
            "type": "string",
            "enum": [
              "ok",
              "token_unavailable",
              "api_unavailable",
              "down"
            ]
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "$defs": {
    "ServiceCheck": {
      "type": "object",
      "properties": {
        "available": {
          "type": "boolean"
        },
        "response_time_ms": {
          "type": "number"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}