{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/anywork-ac-1.0.json",
  "additionalProperties": true,
  "allOf": [
    {
      "if": {
        "properties": {
          "ctype": {
            "const": "swagger-codegen"
          }
        }
      },
      "then": {
        "required": ["swagger-codegen"],
        "properties": {
          "swagger-codegen": {
            "title": "swagger codegen",
            "type": "object",
            "description": "swagger-codegen Configuration",
            "additionalProperties": false,
            "required": ["schemas"],
            "properties": {
              "schemas": {
                "type": "array",
                "description": "List of schemas (microservices) to generate it's libraries.",
                "items": {
                  "title": "schema",
                  "type": "object",
                  "additionalProperties": false,
                  "required": ["name", "actions"],
                  "properties": {
                    "name": {
                      "type": "string",
                      "pattern": "[a-zA-Z]+",
                      "description": "Name of schema. This will be used to generate codes, only `[a-zA-Z]+` is accepted.",
                      "examples": ["authorization"]
                    },
                    "disable": {
                      "type": "boolean",
                      "default": true,
                      "description": "Disables all actions over this schema."
                    },
                    "actions": {
                      "type": "array",
                      "description": "Determines the actions should be applied over this schema.",
                      "uniqueItems": true,
                      "items": {
                        "anyOf": [
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": false,
                            "description": "Defines a download schema task.",
                            "required": ["type", "sourceUrl", "id"],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "download",
                                "description": "Type of action to apply."
                              },
                              "sourceUrl": {
                                "type": "string",
                                "examples": [
                                  "http://somewhere/path/to/swagger.json"
                                ],
                                "pattern": "http[s]?:\\/\\/.*\\/swagger\\.json",
                                "description": "Source of `swagger.json` schema to download"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this download to be referenced (`DOWNLOAD_ID`).",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": true,
                            "description": "Defines a TS code generator task.",
                            "required": [
                              "type",
                              "ngVersion",
                              "id",
                              "downloadId"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "generate",
                                "description": "Type of action to apply."
                              },
                              "ngVersion": {
                                "$ref": "#/definitions/version",
                                "description": "Specifies Angular version which codes will be generated for.",
                                "default": "12.2.14"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this generation to be referenced (`GENERATE_ID`).",
                                "default": 0
                              },
                              "downloadId": {
                                "type": "number",
                                "description": "The `DOWNLOAD_ID` of downloaded schema to generate codes based on.",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": false,
                            "description": "Defines a code correction task.",
                            "required": ["type", "generateId"],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "correction",
                                "description": "Type of action to apply."
                              },
                              "generateId": {
                                "$ref": "#/definitions/generateId"
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": false,
                            "description": "Defines a TS code builder task.",
                            "required": [
                              "type",
                              "typescriptVersion",
                              "id",
                              "generateId"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "build",
                                "description": "Type of action to apply."
                              },
                              "typescriptVersion": {
                                "$ref": "#/definitions/version",
                                "description": "Specifies TypeScript version to install before build.",
                                "default": "4.3.5"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this build to be referenced (`BUILD_ID`)."
                              },
                              "generateId": {
                                "$ref": "#/definitions/generateId"
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": false,
                            "description": "Defines a `npm publish` task.",
                            "required": ["type", "registryUrl", "token", "id"],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "publish",
                                "description": "Type of action to apply."
                              },
                              "registryUrl": {
                                "type": "string",
                                "description": "The Url of registry accepting this repository.",
                                "pattern": "http[s]?://.*",
                                "default": "http://verdaccio.anywork.local:4873"
                              },
                              "token": {
                                "type": "string",
                                "description": "Token to use access registry.",
                                "default": "bzKaK7hK2OAoCK9d72S0UevXGZEjj8rZpv8AFoaZ+/w=",
                                "examples": [
                                  "bzKaK7hK2OAoCK9d72S0UevXGZEjj8rZpv8AFoaZ+/w="
                                ]
                              },
                              "buildId": {
                                "$ref": "#/definitions/buildId"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this publish to be referenced (`PUBLISH_ID`).",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "additionalProperties": false,
                            "description": "Defines a Api install task.",
                            "required": ["type", "targetPath", "publishId"],
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "install",
                                "description": "Type of action to apply."
                              },
                              "publishId": {
                                "type": "number",
                                "description": "The `PUBLISH_ID` to use for this task.",
                                "default": 0
                              },
                              "targetPath": {
                                "type": "string",
                                "description": "The relative or absolute physical path of directory containing `packages.json` to install specified"
                              },
                              "disable": {
                                "$ref": "#/definitions/disable"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  ],
  "definitions": {
    "version": {
      "pattern": "^[\\^~]?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
    },
    "buildId": {
      "type": "number",
      "description": "The `BUILD_ID` to use for this task.",
      "default": 0
    },
    "generateId": {
      "type": "number",
      "description": "The `GENERATE_ID` to use for this task.",
      "default": 0
    },
    "disable": {
      "type": "boolean",
      "description": "Determines if this task is disabled.",
      "default": true
    }
  },
  "description": "Used to configure any part of AnyWork automation.",
  "properties": {
    "ctype": {
      "type": "string",
      "description": "type of configuration, means who will use this configuration."
    },
    "cversion": {
      "type": "integer",
      "default": 1,
      "description": "Version of configuration. The reader will parse configuration based on this."
    }
  },
  "required": ["ctype", "cversion"],
  "title": "AnyWork Automation Configuration schema",
  "type": "object"
}
