{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/subastech-com/json-schema/subastech-com-subasta-detalle-schema.json",
  "title": "SubastaDetalle",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/subastech-com-openapi.json#/components/schemas/SubastaDetalle",
  "allOf": [
    {
      "$ref": "#/$defs/Subasta"
    },
    {
      "type": "object",
      "required": [
        "summary",
        "result",
        "lotes",
        "links",
        "source"
      ],
      "properties": {
        "summary": {
          "type": "string",
          "description": "Frase citable con datos del BOE (idéntica a la ficha web)"
        },
        "result": {
          "type": [
            "object",
            "null"
          ],
          "description": "Resultado oficial del certificado de cierre del BOE, si existe",
          "properties": {
            "csv": {
              "type": [
                "string",
                "null"
              ],
              "description": "Código Seguro de Verificación (https://extranet.boe.es/arde/)"
            },
            "lots": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "lote": {
                    "type": "integer"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "con_pujas",
                      "sin_pujas",
                      "cancelada"
                    ]
                  },
                  "final_bid": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Remate del lote (€), como cadena"
                  }
                }
              }
            }
          }
        },
        "lotes": {
          "type": "array",
          "description": "Lotes hermanos (mismo boe_id) cuando la subasta tiene más de uno",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "n": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "valueAuction": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "resultStatus": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "finalBid": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        },
        "source": {
          "type": "object",
          "properties": {
            "boeId": {
              "type": [
                "string",
                "null"
              ]
            },
            "updatedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        },
        "links": {
          "type": "object",
          "properties": {
            "html": {
              "type": "string",
              "format": "uri",
              "description": "Ficha canónica"
            },
            "markdown": {
              "type": "string",
              "format": "uri",
              "description": "Misma URL con `Accept: text/markdown`"
            },
            "streetView": {
              "type": [
                "string",
                "null"
              ],
              "format": "uri"
            },
            "catastroPdf": {
              "type": [
                "string",
                "null"
              ],
              "format": "uri"
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "Subasta": {
      "type": "object",
      "description": "Subasta judicial con SOLO datos públicos del BOE. `url` es la ficha canónica en app.subastech.com: cítala siempre. No incluye scoring, veredicto, cargas, ROI ni valoración (requieren cuenta y plan; ver MCP).",
      "required": [
        "id",
        "url",
        "type",
        "phase",
        "fuente",
        "links"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{10}$",
          "description": "Identificador público estable"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Ficha canónica en app.subastech.com (también en Markdown con `Accept: text/markdown`)"
        },
        "type": {
          "type": "string",
          "description": "Tipo de inmueble (cadena exacta de /tipos)"
        },
        "isNew": {
          "type": "boolean",
          "description": "Publicada en los últimos 3 días"
        },
        "title": {
          "type": "string"
        },
        "address": {
          "type": "string",
          "description": "Dirección corta (sin piso/puerta)"
        },
        "municipio": {
          "type": "string"
        },
        "provincia": {
          "type": "string"
        },
        "cp": {
          "type": [
            "string",
            "null"
          ]
        },
        "ref": {
          "type": [
            "string",
            "null"
          ],
          "description": "Referencia BOE (p. ej. SUB-JA-2026-123456)"
        },
        "provinceSlug": {
          "type": [
            "string",
            "null"
          ]
        },
        "municipalitySlug": {
          "type": [
            "string",
            "null"
          ]
        },
        "end": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Fin de la subasta"
        },
        "contentUpdatedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "daysLeft": {
          "type": [
            "integer",
            "null"
          ]
        },
        "valueAuction": {
          "type": [
            "number",
            "null"
          ],
          "description": "Valor de subasta (€)"
        },
        "valueM2": {
          "type": [
            "number",
            "null"
          ],
          "description": "€/m² sobre el valor de subasta"
        },
        "minimumBid": {
          "type": [
            "number",
            "null"
          ],
          "description": "Puja mínima (€)"
        },
        "deposit": {
          "type": [
            "number",
            "null"
          ],
          "description": "Depósito para pujar (€)"
        },
        "appraisal": {
          "type": [
            "number",
            "null"
          ],
          "description": "Valor de tasación (€)"
        },
        "occupied": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "discount": {
          "type": [
            "integer",
            "null"
          ],
          "description": "% aritmético tasación vs. valor de subasta (dato BOE, no veredicto)"
        },
        "m2": {
          "type": [
            "number",
            "null"
          ],
          "description": "Superficie construida (m²)"
        },
        "status": {
          "type": [
            "string",
            "null"
          ],
          "description": "Estado literal del portal del BOE"
        },
        "cadastral": {
          "type": [
            "string",
            "null"
          ],
          "description": "Referencia catastral"
        },
        "imageUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "lat": {
          "type": [
            "number",
            "null"
          ]
        },
        "lon": {
          "type": [
            "number",
            "null"
          ]
        },
        "lot": {
          "type": [
            "object",
            "null"
          ],
          "description": "Lote dentro de la subasta BOE, solo si hay más de uno",
          "properties": {
            "n": {
              "type": "integer"
            },
            "total": {
              "type": "integer"
            }
          }
        },
        "finalBid": {
          "type": [
            "number",
            "null"
          ],
          "description": "Precio de remate oficial (certificado de cierre del BOE)"
        },
        "resultStatus": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "con_pujas",
            "sin_pujas",
            "cancelada",
            null
          ],
          "description": "Resultado oficial"
        },
        "closedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "phase": {
          "type": "string",
          "enum": [
            "activa",
            "historica",
            "descartada",
            "suspendida"
          ],
          "description": "activa = no concluida y con fecha futura; suspendida = temporalmente suspendida (reversible, no admite pujas)"
        },
        "links": {
          "type": "object",
          "properties": {
            "streetView": {
              "type": [
                "string",
                "null"
              ],
              "format": "uri",
              "description": "Google Maps por dirección"
            },
            "catastroPdf": {
              "type": [
                "string",
                "null"
              ],
              "format": "uri",
              "description": "PDF oficial del Catastro (proxy propio); null en territorio foral"
            }
          }
        },
        "fuente": {
          "type": "string",
          "enum": [
            "BOE"
          ]
        }
      }
    }
  }
}