{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "StageTrace CLI schema response 1.0",
  "type": "object",
  "required": [
    "schemaVersion",
    "command",
    "status",
    "data",
    "errors",
    "warnings",
    "timingMs"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "command": {
      "const": "schema"
    },
    "status": {
      "type": "string",
      "enum": [
        "ok",
        "error"
      ]
    },
    "data": {
      "oneOf": [
        {
          "oneOf": [
            {
              "type": "object",
              "required": [
                "schemaVersion",
                "commands"
              ],
              "properties": {
                "schemaVersion": {
                  "const": "1.0"
                },
                "commands": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "additionalProperties": false
            },
            {
              "type": "object",
              "required": [
                "schemaVersion",
                "command",
                "schema"
              ],
              "properties": {
                "schemaVersion": {
                  "const": "1.0"
                },
                "command": {
                  "type": "string",
                  "enum": [
                    "compose",
                    "edit",
                    "explain",
                    "export",
                    "help",
                    "inspect",
                    "layers",
                    "plugins",
                    "project",
                    "schema",
                    "tree",
                    "validate",
                    "version",
                    "visibility",
                    "watch",
                    "why"
                  ]
                },
                "schema": {
                  "$ref": "https://json-schema.org/draft/2020-12/schema"
                }
              },
              "additionalProperties": false
            },
            {
              "type": "object",
              "required": [
                "schemaVersion",
                "commands",
                "schemas"
              ],
              "properties": {
                "schemaVersion": {
                  "const": "1.0"
                },
                "commands": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "schemas": {
                  "type": "object",
                  "required": [
                    "compose",
                    "edit",
                    "explain",
                    "export",
                    "help",
                    "inspect",
                    "layers",
                    "plugins",
                    "project",
                    "schema",
                    "tree",
                    "validate",
                    "version",
                    "visibility",
                    "watch",
                    "why"
                  ],
                  "properties": {
                    "compose": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "edit": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "explain": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "export": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "help": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "inspect": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "layers": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "plugins": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "project": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "schema": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "tree": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "validate": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "version": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "visibility": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "watch": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    },
                    "why": {
                      "$ref": "https://json-schema.org/draft/2020-12/schema"
                    }
                  },
                  "additionalProperties": false
                }
              },
              "additionalProperties": false
            }
          ]
        },
        {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      ]
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {"type": "string"},
          "message": {"type": "string"}
        },
        "additionalProperties": false
      }
    },
    "timingMs": {
      "type": "number"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "ok"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "schemaVersion",
                  "commands"
                ],
                "properties": {
                  "schemaVersion": {
                    "const": "1.0"
                  },
                  "commands": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "schemaVersion",
                  "command",
                  "schema"
                ],
                "properties": {
                  "schemaVersion": {
                    "const": "1.0"
                  },
                  "command": {
                    "type": "string",
                    "enum": [
                      "compose",
                      "edit",
                      "explain",
                      "export",
                      "help",
                      "inspect",
                      "layers",
                      "plugins",
                      "project",
                      "schema",
                      "tree",
                      "validate",
                      "version",
                      "visibility",
                      "watch",
                      "why"
                    ]
                  },
                  "schema": {
                    "$ref": "https://json-schema.org/draft/2020-12/schema"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "schemaVersion",
                  "commands",
                  "schemas"
                ],
                "properties": {
                  "schemaVersion": {
                    "const": "1.0"
                  },
                  "commands": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "schemas": {
                    "type": "object",
                    "required": [
                      "compose",
                      "edit",
                      "explain",
                      "export",
                      "help",
                      "inspect",
                      "layers",
                      "plugins",
                      "project",
                      "schema",
                      "tree",
                      "validate",
                      "version",
                      "visibility",
                      "watch",
                      "why"
                    ],
                    "properties": {
                      "compose": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "edit": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "explain": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "export": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "help": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "inspect": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "layers": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "plugins": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "project": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "schema": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "tree": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "validate": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "version": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "visibility": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "watch": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      },
                      "why": {
                        "$ref": "https://json-schema.org/draft/2020-12/schema"
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "errors": {
            "type": "array",
            "maxItems": 0
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "error"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "type": "object",
            "properties": {},
            "additionalProperties": false
          },
          "errors": {
            "type": "array",
            "minItems": 1
          }
        }
      }
    }
  ],
  "additionalProperties": false
}
