{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://andresgmg.github.io/World-GeoJSON/schemas/index.schema.json",
  "title": "World GeoJSON global index",
  "description": "data/index.json — every territory and dataset in one file, generated by `wgj index` from the per-country manifests. See docs/reference/index-json.md.",
  "type": "object",
  "required": ["schema_version", "bodies", "totals", "countries"],
  "additionalProperties": false,
  "properties": {
    "schema_version": { "const": 1 },
    "bodies": {
      "type": "array",
      "items": { "enum": ["earth", "moon", "mars"] },
      "uniqueItems": true
    },
    "totals": {
      "type": "object",
      "required": ["countries", "datasets", "features", "bytes"],
      "additionalProperties": false,
      "properties": {
        "countries": { "type": "integer", "minimum": 0 },
        "datasets": { "type": "integer", "minimum": 0 },
        "features": { "type": "integer", "minimum": 0 },
        "bytes": { "type": "integer", "minimum": 0 }
      }
    },
    "countries": {
      "type": "array",
      "items": { "$ref": "#/$defs/country" }
    }
  },
  "$defs": {
    "country": {
      "type": "object",
      "required": ["body", "iso_a3", "name", "status", "manifest", "license", "licenses", "levels", "municipal_level", "crs", "source", "datasets"],
      "additionalProperties": false,
      "properties": {
        "body": { "enum": ["earth", "moon", "mars"] },
        "iso_a3": { "$ref": "manifest.schema.json#/$defs/iso3" },
        "iso_a2": { "type": "string", "pattern": "^[A-Z]{2}$" },
        "m49_region": { "type": "string" },
        "name": { "$ref": "manifest.schema.json#/$defs/localised" },
        "status": { "enum": ["ok", "review", "deprecated"] },
        "manifest": { "type": "string", "pattern": "^data/[a-z]+/[A-Z]{3}/manifest\\.json$" },
        "license": {
          "anyOf": [{ "$ref": "manifest.schema.json#/$defs/license" }, { "const": "mixed" }]
        },
        "licenses": {
          "description": "Every licence that governs a dataset of this territory, sorted.",
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "manifest.schema.json#/$defs/license" }
        },
        "levels": {
          "type": "array",
          "items": { "$ref": "manifest.schema.json#/$defs/level" },
          "uniqueItems": true
        },
        "municipal_level": {
          "description": "Which published level is the municipal tier (from the registry), or null.",
          "oneOf": [{ "$ref": "manifest.schema.json#/$defs/level" }, { "type": "null" }]
        },
        "terms": {
          "description": "Local names of the tiers, from the registry, when known.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "adm1": { "$ref": "manifest.schema.json#/$defs/localised" },
            "adm2": { "$ref": "manifest.schema.json#/$defs/localised" },
            "municipal": { "$ref": "manifest.schema.json#/$defs/localised" }
          }
        },
        "crs": { "$ref": "manifest.schema.json#/properties/crs" },
        "source": { "$ref": "manifest.schema.json#/properties/source" },
        "notes": { "$ref": "manifest.schema.json#/$defs/singleLine" },
        "datasets": {
          "type": "array",
          "items": { "$ref": "manifest.schema.json#/$defs/dataset" }
        }
      }
    }
  }
}
