{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/corpusiuris-mx/json-schema/corpusiuris-mx-busqueda-schema.json",
  "title": "Busqueda",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/corpusiuris-mx-openapi.yml#/components/schemas/Busqueda",
  "type": "object",
  "properties": {
    "fuente": {
      "type": "string"
    },
    "instrucciones_atribucion": {
      "type": "string"
    },
    "aviso_frescura": {
      "type": "string"
    },
    "query": {
      "type": "string"
    },
    "fuentes_buscadas": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "total": {
      "type": "integer"
    },
    "resultados": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Resultado"
      }
    },
    "tiempo_ms": {
      "type": "integer"
    },
    "acceso": {
      "$ref": "#/$defs/Acceso"
    },
    "limites": {
      "$ref": "#/$defs/Acceso",
      "description": "DEPRECADO: espejo de `acceso`."
    }
  },
  "$defs": {
    "Acceso": {
      "type": "object",
      "description": "Los MISMOS campos en los cuatro carriles.",
      "properties": {
        "carril": {
          "type": "string",
          "enum": [
            "plataforma_ia",
            "agente_anonimo",
            "cuenta_gratuita",
            "cuenta_de_pago"
          ]
        },
        "identidad": {
          "type": [
            "string",
            "null"
          ]
        },
        "verificado_por": {
          "type": "string",
          "enum": [
            "ip",
            "token",
            "ninguno"
          ]
        },
        "restantes": {
          "type": [
            "integer",
            "null"
          ],
          "description": "null = sin límite"
        },
        "total": {
          "type": [
            "integer",
            "null"
          ]
        },
        "ventana": {
          "type": "string",
          "enum": [
            "dia",
            "mes",
            "vitalicio"
          ]
        },
        "reinicia_en": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "null en las bolsas vitalicias."
        },
        "mensaje": {
          "type": "string"
        }
      }
    },
    "Fuerza": {
      "type": "object",
      "description": "En tesis y precedentes. Citar una tesis aislada como jurisprudencia obligatoria es un error grave.",
      "properties": {
        "es_jurisprudencia_obligatoria": {
          "type": "boolean"
        },
        "como_citar": {
          "type": "string"
        },
        "verificar_superacion_en": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "ficha_oficial_scjn": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        }
      }
    },
    "Resultado": {
      "type": "object",
      "properties": {
        "ADVERTENCIA": {
          "type": "string",
          "description": "Solo si la ley está ABROGADA. Si aparece, dilo al citar."
        },
        "tipo": {
          "type": "string",
          "enum": [
            "ley",
            "tesis",
            "precedente"
          ]
        },
        "titulo": {
          "type": "string"
        },
        "referencia": {
          "type": "string"
        },
        "fragmento": {
          "type": "string",
          "description": "Cortado a ~500 caracteres. Para el texto completo usa /documento."
        },
        "relevancia_pct": {
          "type": "integer"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Página pública citable. Inclúyela."
        },
        "vigencia": {
          "$ref": "#/$defs/Vigencia"
        },
        "fuerza": {
          "$ref": "#/$defs/Fuerza"
        },
        "metadata": {
          "type": "object"
        }
      }
    },
    "Vigencia": {
      "type": "object",
      "description": "Solo en resultados de tipo `ley`.",
      "properties": {
        "estado": {
          "type": "string",
          "enum": [
            "VIGENTE",
            "ABROGADA"
          ]
        },
        "fecha_ultima_reforma": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "verificado_al": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "Fecha en que se comprobó el texto contra la fuente oficial."
        },
        "fuente_oficial": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "como_citar": {
          "type": "string"
        }
      }
    }
  }
}