{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.opencityitalia.it/website/comuni/image/v1.json",
  "title": "Immagine",
  "description": "Immagine o foto pubblicata da un comune. I campi elencati sono il contratto minimo garantito; tenant con moduli opzionali possono esporre campi aggiuntivi.",
  "type": "object",
  "required": ["id", "tenant_id", "created_at", "updated_at", "name"],
  "additionalProperties": true,
  "properties": {
    "id": {
      "type": "string",
      "description": "tenantId:objectId (es. bugliano:228)"
    },
    "tenant_id": {
      "type": "string",
      "format": "uuid"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "name": {
      "type": "string",
      "description": "Titolo dell'immagine"
    },
    "caption": {
      "type": ["string", "null"],
      "description": "Didascalia in formato HTML"
    },
    "image": {
      "oneOf": [
        {
          "type": "object",
          "required": ["filename", "url", "alt", "mime_type", "width", "height"],
          "properties": {
            "filename": {
              "type": "string",
              "description": "Nome del file immagine"
            },
            "url": {
              "type": "string",
              "format": "uri",
              "description": "URL assoluto del file immagine"
            },
            "alt": {
              "type": "string",
              "description": "Testo alternativo"
            },
            "mime_type": {
              "type": "string",
              "description": "Tipo MIME (es. image/jpeg)"
            },
            "width": {
              "type": "string",
              "description": "Larghezza in pixel (stringa per compatibilità con la serializzazione PHP)"
            },
            "height": {
              "type": "string",
              "description": "Altezza in pixel (stringa per compatibilità con la serializzazione PHP)"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "File immagine"
    },
    "tags": {
      "oneOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "Tag liberi associati all'immagine"
    },
    "license": {
      "oneOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "Licenza d'uso dell'immagine (tassonomia)"
    },
    "proprietary_license": {
      "type": ["string", "null"],
      "description": "Descrizione testuale di licenza proprietaria"
    },
    "proprietary_license_source": {
      "type": ["string", "null"],
      "description": "Fonte della licenza proprietaria"
    },
    "author": {
      "type": ["string", "null"],
      "description": "Autore o fotografo"
    }
  }
}
