{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:shiin:schema:local-api:v1",
  "title": "Shiin local API JSON-RPC request",
  "type": "object",
  "required": ["jsonrpc", "id", "method", "params"],
  "properties": {
    "jsonrpc": { "type": "string", "const": "2.0" },
    "id": { "type": "string" },
    "method": {
      "type": "string",
      "enum": [
        "shiin.evaluate",
        "shiin.evaluate.unattended",
        "shiin.policy.validate",
        "shiin.approve.resolve",
        "shiin.pending",
        "shiin.grants",
        "shiin.revoke"
      ]
    },
    "params": { "type": "object" }
  },
  "additionalProperties": false,
  "allOf": [
    {
      "if": { "properties": { "method": { "enum": ["shiin.evaluate", "shiin.evaluate.unattended"] } } },
      "then": { "properties": { "params": { "$ref": "urn:shiin:schema:action-request:v1" } } }
    },
    {
      "if": { "properties": { "method": { "const": "shiin.policy.validate" } } },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "required": ["source", "workspace"],
            "properties": {
              "source": { "type": "string", "minLength": 1 },
              "workspace": { "type": "string", "minLength": 1 }
            },
            "additionalProperties": false
          }
        }
      }
    }
  ]
}
