{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/alfil-co/json-schema/alfil-co-voto-detalle-schema.json",
  "title": "VotoDetalle",
  "description": "Detalle de una votación del Congreso, con la respuesta de cada miembro (atribución Congreso Visible — Uniandes)",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/alfil-co-openapi.json#/components/schemas/VotoDetalle",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "fecha": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "es_nominal": {
      "type": "boolean"
    },
    "aprobada": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "conteo": {
      "$ref": "#/$defs/VotoConteo"
    },
    "individuales": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "estado_fuente": {
              "type": "string",
              "const": "sin_registro_nominal"
            },
            "registros": {
              "type": "null"
            }
          },
          "required": [
            "estado_fuente",
            "registros"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "estado_fuente": {
              "type": "string",
              "const": "ok"
            },
            "registros": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/VotoIndividual"
              }
            },
            "truncado": {
              "type": "boolean",
              "description": "true si la lista de respuestas se cortó al límite de lectura; el conteo (favor/contra/abstención) sigue siendo la fuente de verdad para el resultado"
            }
          },
          "required": [
            "estado_fuente",
            "registros",
            "truncado"
          ],
          "additionalProperties": false
        }
      ],
      "type": "object"
    },
    "fuente": {
      "$ref": "#/$defs/Fuente"
    },
    "referencias": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Referencia"
      }
    }
  },
  "required": [
    "id",
    "fecha",
    "es_nominal",
    "aprobada",
    "conteo",
    "individuales",
    "fuente",
    "referencias"
  ],
  "additionalProperties": false,
  "$defs": {
    "Fuente": {
      "type": "object",
      "properties": {
        "nombre": {
          "type": "string",
          "description": "Fuente oficial del dato"
        },
        "url": {
          "description": "URL de la fuente oficial",
          "type": "string"
        },
        "corte": {
          "type": "string",
          "description": "Fecha de corte del dato (ISO 8601)"
        },
        "licencia": {
          "description": "Licencia de la fuente",
          "type": "string"
        }
      },
      "required": [
        "nombre",
        "corte"
      ],
      "additionalProperties": false,
      "description": "Proveniencia: fuente oficial y fecha de corte (atribución Ley 1712)"
    },
    "Referencia": {
      "type": "object",
      "properties": {
        "tipo": {
          "type": "string",
          "enum": [
            "pagina_alfil",
            "registro_oficial",
            "documento_oficial",
            "coleccion_oficial"
          ]
        },
        "titulo": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "pattern": "^[hH][tT][tT][pP][sS]:\\/\\/[^/?#@]+(?:[/?#].*)?$",
          "format": "uri"
        },
        "proveedor": {
          "type": "string"
        },
        "id_externo": {
          "type": "string"
        }
      },
      "required": [
        "tipo",
        "titulo",
        "url",
        "proveedor"
      ],
      "additionalProperties": false,
      "description": "Enlace HTTPS navegable a Alfil o a una fuente oficial"
    },
    "VotoConteo": {
      "type": "object",
      "properties": {
        "favor": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "contra": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "abstencion": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "favor",
        "contra",
        "abstencion"
      ],
      "additionalProperties": false
    },
    "VotoIndividual": {
      "type": "object",
      "properties": {
        "votante_nombre": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "congresista_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "politico_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "respuesta": {
          "type": "string",
          "enum": [
            "favor",
            "contra",
            "abstencion",
            "ausente",
            "presente",
            "no_aplica"
          ]
        }
      },
      "required": [
        "votante_nombre",
        "congresista_id",
        "politico_id",
        "respuesta"
      ],
      "additionalProperties": false,
      "description": "Respuesta de un miembro del Congreso a una votación nominal"
    }
  }
}