{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/alfil-co/json-schema/alfil-co-buscar-response-schema.json",
  "title": "BuscarResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/alfil-co-b-squeda-api-openapi.yml#/components/schemas/BuscarResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ResultadoBusqueda"
      }
    },
    "page": {
      "$ref": "#/$defs/Page"
    },
    "fuente": {
      "$ref": "#/$defs/Fuente"
    }
  },
  "required": [
    "data",
    "page",
    "fuente"
  ],
  "additionalProperties": false,
  "$defs": {
    "AccionSugerida": {
      "type": "object",
      "properties": {
        "tool": {
          "type": "string",
          "description": "Tool MCP para profundizar"
        },
        "args": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          },
          "description": "Argumentos ya armados"
        }
      },
      "required": [
        "tool",
        "args"
      ],
      "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)"
    },
    "Page": {
      "type": "object",
      "properties": {
        "cursor": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Cursor opaco de la siguiente página; null si no hay más"
        },
        "has_more": {
          "type": "boolean",
          "description": "Indica si existen más resultados"
        }
      },
      "required": [
        "cursor",
        "has_more"
      ],
      "additionalProperties": false,
      "description": "Paginación por cursor opaco (no offset)"
    },
    "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"
    },
    "ResultadoBusqueda": {
      "type": "object",
      "properties": {
        "tipo": {
          "type": "string",
          "enum": [
            "politico",
            "partido",
            "contrato",
            "investigacion"
          ]
        },
        "id": {
          "type": "string",
          "description": "Conector tipado a la tool de detalle"
        },
        "titulo": {
          "type": "string"
        },
        "resumen": {
          "type": "string"
        },
        "destacado": {
          "description": "Campos de desambiguación por tipo",
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        },
        "url": {
          "type": "string"
        },
        "referencias": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Referencia"
          }
        },
        "acciones": {
          "description": "Solo en response_format=detailed",
          "type": "array",
          "items": {
            "$ref": "#/$defs/AccionSugerida"
          }
        }
      },
      "required": [
        "tipo",
        "id",
        "titulo",
        "resumen",
        "url",
        "referencias"
      ],
      "additionalProperties": false
    }
  }
}