{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://r3dz4r.github.io/datapulse-my/datapulse.schema.json",
  "title": "DataPulse MY dataset manifest",
  "type": "object",
  "required": [
    "$schema",
    "datasets"
  ],
  "properties": {
    "$schema": {
      "const": "https://r3dz4r.github.io/datapulse-my/datapulse.schema.json"
    },
    "datasets": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/dataset"
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "healthStatus": {
      "description": "Dataset health statuses emitted by scripts/check.sh.",
      "type": "string",
      "enum": [
        "fresh",
        "aging",
        "stale",
        "degraded",
        "browser-dependent",
        "unreachable",
        "unknown",
        "unknown-freshness"
      ]
    },
    "dataset": {
      "type": "object",
      "required": [
        "id",
        "name",
        "source",
        "steward",
        "url",
        "licence",
        "attribution",
        "refresh_frequency",
        "expected_record_count",
        "geo_coverage",
        "health_report",
        "namespace"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "steward": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "licence": {
          "type": "string",
          "minLength": 1
        },
        "attribution": {
          "type": "string",
          "minLength": 1
        },
        "refresh_frequency": {
          "type": "string",
          "minLength": 1
        },
        "expected_record_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "geo_coverage": {
          "type": "string",
          "minLength": 1
        },
        "health_report": {
          "type": "string",
          "pattern": "^data/[A-Za-z0-9_-]+\\.md$"
        },
        "namespace": {
          "type": "string",
          "enum": [
            "economy",
            "government_open_data",
            "environment",
            "weather",
            "healthcare",
            "financial",
            "transport",
            "other"
          ]
        }
      },
      "additionalProperties": false
    }
  }
}
