{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/alfil-co/json-schema/alfil-co-politico-perfil-schema.json",
  "title": "PoliticoPerfil",
  "description": "Perfil de político (sin datos de contacto semiprivados)",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/alfil-co-openapi.json#/components/schemas/PoliticoPerfil",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string"
        },
        "nombre": {
          "type": "string"
        },
        "partido": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "trayectoria": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Cargo"
          }
        },
        "sanciones": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "no_consultado"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "null"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "ok"
                },
                "registros": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/Sancion"
                  }
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "string"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "error"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "codigo": {
                      "type": "string",
                      "const": "FUENTE_NO_DISPONIBLE"
                    },
                    "mensaje": {
                      "type": "string",
                      "const": "No se pudo consultar en este momento"
                    }
                  },
                  "required": [
                    "codigo",
                    "mensaje"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            }
          ],
          "type": "object"
        },
        "responsabilidad_fiscal": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "no_consultado"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "null"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "ok"
                },
                "registros": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/ResponsabilidadFiscal"
                  }
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "string"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "error"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "codigo": {
                      "type": "string",
                      "const": "FUENTE_NO_DISPONIBLE"
                    },
                    "mensaje": {
                      "type": "string",
                      "const": "No se pudo consultar en este momento"
                    }
                  },
                  "required": [
                    "codigo",
                    "mensaje"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            }
          ],
          "type": "object"
        },
        "fuente": {
          "$ref": "#/$defs/Fuente"
        },
        "referencias": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Referencia"
          }
        },
        "cedula": {
          "type": "string",
          "pattern": "^[1-9]\\d{5,11}$",
          "description": "Presente con participación política pública; dato público (T-254/24)"
        },
        "cedula_fuente": {
          "type": "string",
          "pattern": "^\\S(?:[\\s\\S]*\\S)?$",
          "description": "Fuente de la cédula (trazabilidad)"
        }
      },
      "required": [
        "slug",
        "nombre",
        "partido",
        "trayectoria",
        "sanciones",
        "responsabilidad_fiscal",
        "fuente",
        "referencias",
        "cedula",
        "cedula_fuente"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string"
        },
        "nombre": {
          "type": "string"
        },
        "partido": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "trayectoria": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Cargo"
          }
        },
        "sanciones": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "no_consultado"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "null"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "ok"
                },
                "registros": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/Sancion"
                  }
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "string"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "error"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "codigo": {
                      "type": "string",
                      "const": "FUENTE_NO_DISPONIBLE"
                    },
                    "mensaje": {
                      "type": "string",
                      "const": "No se pudo consultar en este momento"
                    }
                  },
                  "required": [
                    "codigo",
                    "mensaje"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            }
          ],
          "type": "object"
        },
        "responsabilidad_fiscal": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "no_consultado"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "null"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "ok"
                },
                "registros": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/ResponsabilidadFiscal"
                  }
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "string"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "null"
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "estado_fuente": {
                  "type": "string",
                  "const": "error"
                },
                "registros": {
                  "type": "null"
                },
                "fuente": {
                  "type": "string"
                },
                "corte": {
                  "type": "null"
                },
                "consultado_en": {
                  "type": "string"
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "codigo": {
                      "type": "string",
                      "const": "FUENTE_NO_DISPONIBLE"
                    },
                    "mensaje": {
                      "type": "string",
                      "const": "No se pudo consultar en este momento"
                    }
                  },
                  "required": [
                    "codigo",
                    "mensaje"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "estado_fuente",
                "registros",
                "fuente",
                "corte",
                "consultado_en",
                "error"
              ],
              "additionalProperties": false
            }
          ],
          "type": "object"
        },
        "fuente": {
          "$ref": "#/$defs/Fuente"
        },
        "referencias": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Referencia"
          }
        },
        "cedula": {
          "type": "null",
          "description": "Omitida cuando no hay participación política pública respaldada"
        },
        "cedula_fuente": {
          "type": "null",
          "description": "Omitida junto con la cédula"
        }
      },
      "required": [
        "slug",
        "nombre",
        "partido",
        "trayectoria",
        "sanciones",
        "responsabilidad_fiscal",
        "fuente",
        "referencias",
        "cedula",
        "cedula_fuente"
      ],
      "additionalProperties": false
    }
  ],
  "$defs": {
    "Cargo": {
      "type": "object",
      "properties": {
        "titulo": {
          "type": "string"
        },
        "desde": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "hasta": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "fuente": {
          "type": "string"
        }
      },
      "required": [
        "titulo",
        "desde",
        "hasta"
      ],
      "additionalProperties": false
    },
    "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"
    },
    "ResponsabilidadFiscal": {
      "type": "object",
      "properties": {
        "entidad": {
          "type": "string"
        },
        "tipo_sancion": {
          "type": "string"
        },
        "tema": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "fecha_resolucion": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "monto": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "estado": {
          "type": "string",
          "enum": [
            "ACTIVA",
            "ARCHIVADA",
            "NO_DETERMINADA"
          ]
        }
      },
      "required": [
        "entidad",
        "tipo_sancion",
        "tema",
        "fecha_resolucion",
        "monto",
        "estado"
      ],
      "additionalProperties": false,
      "description": "Responsabilidad fiscal contextualizada (Contraloría)"
    },
    "Sancion": {
      "type": "object",
      "properties": {
        "tipo": {
          "type": "string"
        },
        "estado": {
          "type": "string",
          "enum": [
            "vigente",
            "historica"
          ]
        },
        "fecha": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "fuente": {
          "type": "string"
        },
        "verificado": {
          "description": "Fecha de última verificación",
          "type": "string"
        }
      },
      "required": [
        "tipo",
        "estado",
        "fecha",
        "fuente"
      ],
      "additionalProperties": false,
      "description": "Sanción contextualizada (con estado vigente/histórica)"
    }
  }
}