{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "Type": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]*\\.[A-Za-z][A-Za-z0-9_-]*$"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "arrayOf"
          ],
          "properties": {
            "arrayOf": {
              "$ref": "#/$defs/Type"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "nullable"
          ],
          "properties": {
            "nullable": {
              "$ref": "#/$defs/Type"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "oneOf"
          ],
          "properties": {
            "oneOf": {
              "type": "array",
              "minItems": 2,
              "items": {
                "$ref": "#/$defs/Type"
              }
            }
          }
        }
      ]
    },
    "Parameter": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "required"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_]*$"
        },
        "type": {
          "$ref": "#/$defs/Type"
        },
        "required": {
          "type": "boolean"
        },
        "default": {},
        "variadic": {
          "type": "boolean"
        }
      }
    },
    "Function": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "parameters",
        "returns",
        "purpose"
      ],
      "properties": {
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Parameter"
          }
        },
        "returns": {
          "$ref": "#/$defs/Type"
        },
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "statementOnly": {
          "type": "boolean"
        }
      }
    }
  }
}
