{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["config"],
  "properties": {
    "config": {
      "type": "object",
      "required": ["general"],
      "properties": {
        "general": {
          "type": "object",
          "properties": {
            "planFilePath": {
              "type": "string"
            },
            "plan": {
              "type": "object"
            },
            "executorsPath": {
              "type": "string"
            },
            "notifiersPath": {
              "type": "string"
            },
            "triggersPath": {
              "type": "string"
            },
            "modulesPath": {
              "type": "string"
            },
            "crypto": {
              "type": "object",
              "properties": {
                "algorithm": {
                  "type": "string"
                },
                "iv": {
                  "type": "string"
                }
              }
            },
            "calendars": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "calendarsFolder": {
              "type": "string"
            },
            "api": {
              "type": "object",
              "anyOf": [
                {
                  "required": ["port"],
                  "properties": {
                    "port": {
                      "type": ["number"]
                    },
                    "users": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "user": {
                            "type": "string"
                          },
                          "password": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "secret": {
                      "type": "string"
                    },
                    "basePath": {
                      "type": "string"
                    },
                    "limit_req": {
                      "type": "string"
                    },
                    "token_expiration_time": {
                      "type": "number"
                    },
                    "log_display_level": {
                      "type": "string",
                      "pattern": "(combined|common|dev|short|tiny|silent)"
                    },
                    "chainsFieldsResponse": {
                      "type": "array"
                    },
                    "processFieldsResponse": {
                      "type": "array"
                    },
                    "cors": {
                      "type": "object",
                      "properties": {
                        "origin": {
                          "type": ["boolean", "string", "array", "object"]
                        },
                        "methods": {
                          "type": ["array", "string"]
                        },
                        "allowedHeaders": {
                          "type": ["array", "string"]
                        },
                        "exposedHeaders": {
                          "type": ["array", "string"]
                        },
                        "credentials": {
                          "type": "boolean"
                        },
                        "maxAge": {
                          "type": "number"
                        },
                        "preflightContinue": {
                          "type": "boolean"
                        },
                        "optionsSuccessStatus": {
                          "type": "number"
                        }
                      }
                    }
                  }
                },
                {
                  "required": ["unix_socket"],
                  "properties": {
                    "unix_socket": {
                      "type": "string"
                    },
                    "users": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "user": {
                            "type": "string"
                          },
                          "password": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "secret": {
                      "type": "string"
                    },
                    "basePath": {
                      "type": "string"
                    },
                    "limit_req": {
                      "type": "string"
                    },
                    "token_expiration_time": {
                      "type": "number"
                    },
                    "log_display_level": {
                      "type": "string",
                      "pattern": "(combined|common|dev|short|tiny|silent)"
                    },
                    "chainsFieldsResponse": {
                      "type": "array"
                    },
                    "processFieldsResponse": {
                      "type": "array"
                    },
                    "cors": {
                      "type": "object",
                      "properties": {
                        "origin": {
                          "type": ["boolean", "string", "array", "object"]
                        },
                        "methods": {
                          "type": ["array", "string"]
                        },
                        "allowedHeaders": {
                          "type": ["array", "string"]
                        },
                        "exposedHeaders": {
                          "type": ["array", "string"]
                        },
                        "credentials": {
                          "type": "boolean"
                        },
                        "maxAge": {
                          "type": "number"
                        },
                        "preflightContinue": {
                          "type": "boolean"
                        },
                        "optionsSuccessStatus": {
                          "type": "number"
                        }
                      }
                    }
                  }
                },
                {
                  "required": ["port", "ssl"],
                  "properties": {
                    "port": {
                      "type": ["string"]
                    },
                    "ssl": {
                      "type": "boolean"
                    },
                    "key": {
                      "type": "string"
                    },
                    "cert": {
                      "type": "string"
                    },
                    "users": {
                      "type": "array"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "basePath": {
                      "type": "string"
                    },
                    "limit_req": {
                      "type": "string"
                    },
                    "token_expiration_time": {
                      "type": "number"
                    },
                    "log_display_level": {
                      "type": "string",
                      "pattern": "(combined|common|dev|short|tiny|silent)"
                    },
                    "chainsFieldsResponse": {
                      "type": "array"
                    },
                    "processFieldsResponse": {
                      "type": "array"
                    },
                    "cors": {
                      "type": "object",
                      "properties": {
                        "origin": {
                          "type": ["boolean", "string", "array", "object"]
                        },
                        "methods": {
                          "type": ["array", "string"]
                        },
                        "allowedHeaders": {
                          "type": ["array", "string"]
                        },
                        "exposedHeaders": {
                          "type": ["array", "string"]
                        },
                        "credentials": {
                          "type": "boolean"
                        },
                        "maxAge": {
                          "type": "number"
                        },
                        "preflightContinue": {
                          "type": "boolean"
                        },
                        "optionsSuccessStatus": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              ]
            },
            "servers": {
              "type": "array",
              "items": {
                "type": "object",
                "anyOf": [
                  {
                    "required": ["id", "endpoint", "port"],
                    "properties": {
                      "id": {
                        "type": ["string"]
                      },
                      "endpoint": {
                        "type": ["string"]
                      },
                      "port": {
                        "type": ["number"]
                      },
                      "users": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "user": {
                              "type": "string"
                            },
                            "password": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "apikey": {
                        "type": "string"
                      },
                      "limit_req": {
                        "type": "string"
                      },
                      "log_display_level": {
                        "type": "string",
                        "pattern": "(combined|common|dev|short|tiny|silent)"
                      }
                    }
                  },
                  {
                    "required": ["id", "endpoint", "unix_socket"],
                    "properties": {
                      "id": {
                        "type": ["string"]
                      },
                      "endpoint": {
                        "type": ["string"]
                      },
                      "unix_socket": {
                        "type": "string"
                      },
                      "users": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "user": {
                              "type": "string"
                            },
                            "password": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "apikey": {
                        "type": "string"
                      },
                      "limit_req": {
                        "type": "string"
                      },
                      "log_display_level": {
                        "type": "string",
                        "pattern": "(combined|common|dev|short|tiny|silent)"
                      }
                    }
                  },
                  {
                    "required": ["id", "endpoint", "port", "ssl"],
                    "properties": {
                      "id": {
                        "type": ["string"]
                      },
                      "endpoint": {
                        "type": ["string"]
                      },
                      "port": {
                        "type": ["string"]
                      },
                      "ssl": {
                        "type": "boolean"
                      },
                      "key": {
                        "type": "string"
                      },
                      "cert": {
                        "type": "string"
                      },
                      "users": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "user": {
                              "type": "string"
                            },
                            "password": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "apikey": {
                        "type": "string"
                      },
                      "limit_req": {
                        "type": "string"
                      },
                      "log_display_level": {
                        "type": "string",
                        "pattern": "(combined|common|dev|short|tiny|silent)"
                      }
                    }
                  }
                ]
              }
            },
            "queues": {
              "type": "object",
              "properties": {
                "refreshInterval": {
                  "type": "number"
                }
              }
            },
            "runnerty.io": {
              "type": "object",
              "required": ["apikey"],
              "properties": {
                "apikey": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "disable": {
                  "type": "boolean"
                },
                "host": {
                  "type": "string"
                },
                "healthChecker": {
                  "type": "boolean"
                },
                "remoteControl": {
                  "type": "boolean"
                },
                "syncPlan": {
                  "type": "boolean"
                },
                "debug": {
                  "type": "boolean"
                }
              }
            }
          }
        },
        "triggers": {
          "type": "array"
        },
        "executors": {
          "type": "array"
        },
        "notifiers": {
          "type": "array"
        },
        "global_values": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "defaults": {
          "type": "object",
          "properties": {
            "chain": {
              "type": "object",
              "properties": {
                "notifications": {
                  "$ref": "chainSchema#/definitions/notifications_chain"
                }
              }
            },
            "process": {
              "type": "object",
              "properties": {
                "notifications": {
                  "$ref": "processSchema#/definitions/notifications_process"
                },
                "chain_action_on_fail": {
                  "$ref": "processSchema#/definitions/chain_action_on_fail_process"
                },
                "ignore_in_final_chain_status": {
                  "type": "boolean"
                },
                "output": { "$ref": "processSchema#/definitions/output_process" }
              }
            }
          }
        }
      }
    }
  }
}
