{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://decisionmodelprotocol.io/schema/request.json",
  "title": "DMP Draft 0.1 request",
  "type": "object",
  "required": ["model", "state", "questions"],
  "additionalProperties": false,
  "properties": {
    "model": { "type": "string", "minLength": 1 },
    "state": { "$ref": "#/$defs/description" },
    "questions": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "oneOf": [
          { "$ref": "#/$defs/choice" },
          { "$ref": "#/$defs/score" },
          { "$ref": "#/$defs/noul" }
        ]
      }
    }
  },
  "$defs": {
    "description": { "type": ["string", "object", "array"] },
    "choice": {
      "type": "object",
      "required": ["type", "instructions", "criteria"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "choice" },
        "instructions": { "$ref": "#/$defs/description" },
        "criteria": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": { "anyOf": [{ "$ref": "#/$defs/description" }, { "type": "null" }] }
        }
      }
    },
    "score": {
      "type": "object",
      "required": ["type", "instructions", "criteria"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "score" },
        "instructions": { "$ref": "#/$defs/description" },
        "criteria": { "type": "array", "minItems": 2, "items": { "$ref": "#/$defs/description" } }
      }
    },
    "noul": {
      "type": "object",
      "required": ["type", "instructions"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "noul" },
        "instructions": { "$ref": "#/$defs/description" },
        "criteria": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "true": { "$ref": "#/$defs/description" },
            "false": { "$ref": "#/$defs/description" }
          }
        }
      }
    }
  }
}
