{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://capp.local/schemas/capp.server-contract.v1.schema.json",
  "title": "cApp server contract v1",
  "type": "object",
  "required": [
    "protocol",
    "serverId",
    "routes"
  ],
  "properties": {
    "protocol": {
      "const": "capp.server-contract.v1"
    },
    "serverId": {
      "type": "string",
      "minLength": 1
    },
    "origin": {
      "type": "string"
    },
    "sourceReconciled": {
      "type": "boolean"
    },
    "routeCount": {
      "type": "integer",
      "minimum": 0
    },
    "routes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "path",
          "methods"
        ],
        "properties": {
          "path": {
            "type": "string",
            "pattern": "^/"
          },
          "methods": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "provides": {
            "type": "string",
            "minLength": 1
          },
          "capability": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string"
          },
          "risk": {
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "group": {
            "type": "string"
          },
          "browserCallable": {
            "type": "boolean"
          },
          "auth": {
            "type": "string"
          },
          "mode": {
            "type": "string"
          },
          "approval": {
            "type": "string"
          },
          "receiptRequired": {
            "type": "boolean"
          },
          "defaultEnabled": {
            "type": "boolean"
          },
          "coldBehavior": {
            "type": "string"
          },
          "sourceRoute": {
            "type": [
              "object",
              "null"
            ]
          }
        },
        "additionalProperties": true
      }
    },
    "sourceReconciliation": {
      "type": "object"
    },
    "unresolvedFrontendRoutes": {
      "type": "array"
    },
    "sourceOnlyRoutes": {
      "type": "array"
    }
  },
  "additionalProperties": true
}
