{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "ScriptConfig": {
      "additionalProperties": false,
      "description": "Global execution settings for an automated test script.",
      "properties": {
        "abort_on_error": {
          "default": true,
          "title": "Abort On Error",
          "type": "boolean"
        },
        "default_timeout_ms": {
          "default": 1000,
          "title": "Default Timeout Ms",
          "type": "integer"
        },
        "inter_step_delay_ms": {
          "default": 0,
          "title": "Inter Step Delay Ms",
          "type": "integer"
        }
      },
      "title": "ScriptConfig",
      "type": "object"
    },
    "ScriptMeta": {
      "additionalProperties": false,
      "description": "Metadata block for an automation script.",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "protocol": {
          "title": "Protocol",
          "type": "string"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Description"
        },
        "author": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Author"
        }
      },
      "required": [
        "name",
        "protocol"
      ],
      "title": "ScriptMeta",
      "type": "object"
    },
    "ScriptStep": {
      "additionalProperties": false,
      "description": "Individual action step in an automated test sequence.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "command": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Command"
        },
        "params": {
          "additionalProperties": true,
          "title": "Params",
          "type": "object"
        },
        "expect_response": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Expect Response"
        },
        "timeout_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Timeout Ms"
        },
        "delay_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Delay Ms"
        },
        "log": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Log"
        },
        "assertions": {
          "items": {
            "$ref": "#/$defs/StepAssertion"
          },
          "title": "Assertions",
          "type": "array"
        },
        "save": {
          "additionalProperties": {
            "type": "string"
          },
          "title": "Save",
          "type": "object"
        }
      },
      "title": "ScriptStep",
      "type": "object"
    },
    "StepAssertion": {
      "additionalProperties": false,
      "description": "Condition asserted against response payload fields.",
      "properties": {
        "field": {
          "title": "Field",
          "type": "string"
        },
        "op": {
          "title": "Op",
          "type": "string"
        },
        "value": {
          "title": "Value"
        },
        "tolerance": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Tolerance"
        }
      },
      "required": [
        "field",
        "op",
        "value"
      ],
      "title": "StepAssertion",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Root model for an OmniUART automated test script.",
  "properties": {
    "version": {
      "default": "1.0.0",
      "title": "Version",
      "type": "string"
    },
    "meta": {
      "$ref": "#/$defs/ScriptMeta"
    },
    "config": {
      "$ref": "#/$defs/ScriptConfig"
    },
    "variables": {
      "additionalProperties": true,
      "title": "Variables",
      "type": "object"
    },
    "steps": {
      "items": {
        "$ref": "#/$defs/ScriptStep"
      },
      "title": "Steps",
      "type": "array"
    }
  },
  "required": [
    "meta"
  ],
  "title": "OmniUART Automation Script Schema",
  "type": "object"
}
