{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:cede:schema:exchange-model-index:v0",
  "title": "Craton model exchange index, v0",
  "description": "The body of GET /exchange/models: every model listed on the model exchange, in order of name and then id. Never ranked, never filtered by anything but listing: a model that is a draft, waiting for review or withdrawn is not here. Readable without a key. Each entry is a whole listing, the same document GET /exchange/models/{id} answers with, and exchange-model.v0.schema.json is the authority on its shape. This schema states the members an entry must carry rather than restating that one in full, because two schemas describing the same bytes drift and then disagree; the contract suite validates every entry here against exchange-model.v0 as well.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "count", "models"],
  "properties": {
    "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "count": {
      "type": "integer",
      "minimum": 0,
      "description": "How many models are listed. Equal to the length of `models`: Craton pages nothing."
    },
    "models": {
      "type": "array",
      "description": "The listed models, in order of name and then id.",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "schema_version",
          "id",
          "provider",
          "name",
          "version",
          "perils",
          "coverage",
          "access",
          "access_url",
          "card",
          "connector",
          "status",
          "review"
        ],
        "properties": {
          "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
          "id": { "type": "string", "pattern": "^xm_[0-9a-f]{16}$" },
          "provider": { "type": "object", "required": ["account_id", "name"] },
          "name": { "type": "string", "minLength": 1 },
          "version": { "type": "string", "minLength": 1 },
          "perils": { "type": "array", "minItems": 1, "items": { "type": "string" } },
          "coverage": { "type": "object", "required": ["description", "bbox"] },
          "access": { "enum": ["free", "by_grant"] },
          "access_url": { "type": ["string", "null"] },
          "card": { "type": "object" },
          "connector": {
            "type": "object",
            "description": "Never carries credentials.",
            "not": { "required": ["credentials"] }
          },
          "status": { "const": "listed" },
          "review": { "type": "object", "required": ["state"] }
        }
      }
    }
  }
}
