{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.msadsnetwork.com/downloads/schemas/scl-report.schema.json",
  "title": "Supply-chain Linter Report v0.1 (public draft)",
  "type": "object",
  "required": [
    "ver",
    "linter",
    "checked_at",
    "target",
    "summary",
    "findings"
  ],
  "additionalProperties": false,
  "properties": {
    "ver": {
      "const": "0.1"
    },
    "linter": {
      "type": "object",
      "required": [
        "name",
        "version"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": false
    },
    "checked_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T"
    },
    "target": {
      "type": "object",
      "required": [
        "type",
        "url",
        "http_status"
      ],
      "properties": {
        "type": {
          "enum": [
            "ads.txt",
            "app-ads.txt",
            "sellers.json"
          ]
        },
        "url": {
          "type": "string",
          "pattern": "^https?://"
        },
        "final_url": {
          "type": "string"
        },
        "http_status": {
          "type": "integer",
          "minimum": 0,
          "maximum": 599
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "summary": {
      "type": "object",
      "required": [
        "records",
        "errors",
        "warnings",
        "notes"
      ],
      "properties": {
        "records": {
          "type": "integer",
          "minimum": 0
        },
        "errors": {
          "type": "integer",
          "minimum": 0
        },
        "warnings": {
          "type": "integer",
          "minimum": 0
        },
        "notes": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "lang": {
      "type": "array",
      "items": {
        "enum": [
          "en",
          "ur",
          "ar"
        ]
      },
      "uniqueItems": true
    },
    "findings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/finding"
      }
    }
  },
  "$defs": {
    "finding": {
      "type": "object",
      "required": [
        "code",
        "severity",
        "message"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^(SCL-(FETCH|SYNTAX|XCHK|SJ)-[0-9]{3}|X-[A-Za-z0-9-]+)$"
        },
        "severity": {
          "enum": [
            "error",
            "warning",
            "note"
          ]
        },
        "line": {
          "type": "integer",
          "minimum": 1
        },
        "pointer": {
          "type": "string",
          "pattern": "^(/.*)?$"
        },
        "record": {
          "type": "string",
          "maxLength": 300
        },
        "message": {
          "type": "object",
          "required": [
            "en"
          ],
          "properties": {
            "en": {
              "type": "string",
              "minLength": 1,
              "maxLength": 400
            },
            "ur": {
              "type": "string",
              "minLength": 1,
              "maxLength": 400
            },
            "ar": {
              "type": "string",
              "minLength": 1,
              "maxLength": 400
            }
          },
          "additionalProperties": false
        },
        "fix": {
          "type": "string",
          "maxLength": 400
        },
        "related": {
          "type": "object",
          "properties": {
            "system_domain": {
              "type": "string"
            },
            "seller_id": {
              "type": "string"
            },
            "sellers_json_type": {
              "enum": [
                "PUBLISHER",
                "INTERMEDIARY",
                "BOTH"
              ]
            }
          },
          "additionalProperties": false
        }
      }
    }
  }
}