{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://evcc.coauto.cc/evccapi/schemas/download-manifest.schema.json",
  "title": "EvccApi Demo download manifest",
  "type": "object",
  "required": ["schema", "generatedAt", "artifacts"],
  "properties": {
    "schema": {"const": "evccapi.downloads/1"},
    "generatedAt": {"type": "string"},
    "artifacts": {
      "type": "array",
      "maxItems": 2,
      "description": "At most one independently latest source ZIP and one Demo APK.",
      "items": {
        "type": "object",
        "required": [
          "type", "fileName", "version", "protocolVersion",
          "minEvccVersion", "releaseNotes", "size", "sha256", "url"
        ],
        "properties": {
          "type": {"enum": ["source", "apk"]},
          "fileName": {"type": "string"},
          "version": {"type": "string"},
          "protocolVersion": {"type": "string"},
          "minEvccVersion": {"type": "string"},
          "releaseNotes": {"type": "string", "minLength": 1, "maxLength": 1000},
          "size": {"type": "integer", "minimum": 1},
          "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
          "certificateSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
          "url": {"type": "string", "pattern": "^/evccapi/downloads/"}
        },
        "additionalProperties": false,
        "allOf": [
          {
            "if": {"properties": {"type": {"const": "apk"}}},
            "then": {"required": ["certificateSha256"]}
          }
        ]
      }
    }
  },
  "additionalProperties": false
}
