{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://analisi-spesa-ict.mxmap.it/dati/ambito-soggettivo/ambito.schema.json",
 "title": "Ambito soggettivo dell'accesso civico per ente (analisi-spesa-ict)",
 "type": "object",
 "required": [
  "formato",
  "versione",
  "data",
  "fonte",
  "enti"
 ],
 "properties": {
  "formato": {
   "const": "spesaict.ambito-soggettivo-dati/1"
  },
  "versione": {
   "type": "string"
  },
  "data": {
   "type": "string"
  },
  "fonte": {
   "type": "object",
   "required": [
    "file",
    "sha256",
    "url"
   ]
  },
  "enti": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "cf",
     "denominazione",
     "tipo",
     "categoria_art2bis",
     "esito",
     "livello",
     "url_analisi"
    ],
    "properties": {
     "cf": {
      "type": "string",
      "pattern": "^[0-9]{11}$"
     },
     "slug": {
      "type": [
       "string",
       "null"
      ]
     },
     "denominazione": {
      "type": "string"
     },
     "tipo": {
      "type": "string"
     },
     "categoria_art2bis": {
      "type": "string"
     },
     "esito": {
      "enum": [
       "includere",
       "escludere",
       "includere-pubblico-interesse",
       "incerto",
       "includere-ente-di-appartenenza"
      ]
     },
     "livello": {
      "enum": [
       "V",
       "R"
      ]
     },
     "motivazione": {
      "type": "string"
     },
     "catena": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "lett_c": {
      "type": [
       "object",
       "null"
      ]
     },
     "obbligazioni": {
      "type": [
       "object",
       "null"
      ]
     },
     "titoli": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "isin": {
         "type": [
          "string",
          "null"
         ]
        },
        "emissione": {
         "type": [
          "string",
          "null"
         ]
        },
        "scadenza": {
         "type": [
          "string",
          "null"
         ]
        },
        "mercato": {
         "type": [
          "string",
          "null"
         ],
         "description": "codice MIC ISO 10383 o nome della sede"
        },
        "regolamentato": {
         "type": [
          "boolean",
          "null"
         ]
        },
        "rimborso": {
         "type": [
          "string",
          "null"
         ]
        },
        "in_circolazione": {
         "type": [
          "boolean",
          "null"
         ]
        },
        "entro_termine": {
         "type": [
          "boolean",
          "null"
         ],
         "description": "emesso entro il termine della lett. p"
        },
        "livello": {
         "enum": [
          "V",
          "R"
         ]
        },
        "nota": {
         "type": [
          "string",
          "null"
         ]
        },
        "mercato_descrizione": {
         "type": [
          "string",
          "null"
         ]
        },
        "fonte": {
         "$ref": "#/$defs/prova"
        }
       },
       "required": [
        "isin",
        "emissione",
        "mercato",
        "livello"
       ]
      }
     },
     "prove": {
      "type": "array",
      "items": {
       "$ref": "#/$defs/prova"
      }
     },
     "fonti": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "url_analisi": {
      "type": "string",
      "format": "uri"
     },
     "termine": {
      "type": [
       "string",
       "null"
      ],
      "description": "termine della lett. p (2015-12-31, o 2021-12-31 per l'energia)"
     },
     "controllo": {
      "type": [
       "string",
       "null"
      ]
     },
     "controllo_livello": {
      "enum": [
       "V",
       "R",
       null
      ]
     },
     "categoria_richiesta": {
      "type": [
       "string",
       "null"
      ]
     },
     "conclusione_richiesta": {
      "type": [
       "string",
       "null"
      ],
      "description": "frase per il blocco «Ambito di applicazione»; null = nessun blocco"
     },
     "analisi_giuridica": {
      "type": [
       "object",
       "null"
      ],
      "description": "esito dell'analisi giuridica del progetto (da revisione legale): conclusione inclusa / inclusa-rischio-alto / esclusa, rischio di diniego, rendiconto, nota"
     }
    }
   }
  }
 },
 "$defs": {
  "prova": {
   "type": [
    "object",
    "null"
   ],
   "properties": {
    "file": {
     "type": [
      "string",
      "null"
     ]
    },
    "sha256": {
     "type": [
      "string",
      "null"
     ],
     "pattern": "^[0-9a-f]{64}$"
    },
    "url": {
     "type": [
      "string",
      "null"
     ]
    },
    "nota": {
     "type": [
      "string",
      "null"
     ]
    }
   }
  }
 }
}
