{
  "$id": "https://json.schemastore.org/anywork-ac-1.0.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": true,
  "allOf": [
    {
      "if": {
        "properties": {
          "ctype": {
            "const": "swagger-codegen"
          }
        }
      },
      "then": {
        "required": ["swagger-codegen"],
        "properties": {
          "swagger-codegen": {
            "title": "swagger codegen options",
            "description": "swagger-codegen options",
            "type": "object",
            "required": ["actions"],
            "properties": {
              "actions": {
                "description": "Actions",
                "type": ["string", "array"],
                "default": "all",
                "minItems": 1,
                "uniqueItems": true,
                "items": {
                  "description": "An action",
                  "type": ["string", "object"],
                  "oneOf": [
                    {
                      "type": "string",
                      "enum": [
                        "all",
                        "download",
                        "generate",
                        "correction",
                        "build",
                        "publish"
                      ]
                    },
                    {
                      "title": "action",
                      "type": "object",
                      "required": ["target", "schema"],
                      "properties": {
                        "target": {
                          "description": "A path to repository including `node_modules` directory to install desired services",
                          "$ref": "https://json.schemastore.org/base.json#/definitions/path"
                        },
                        "schema": {
                          "$ref": "#/definitions/schema"
                        }
                      },
                      "additionalProperties": false
                    }
                  ]
                }
              },
              "npm": {
                "title": "NPM specifications",
                "description": "NPM repository specifications to publish",
                "type": "object",
                "required": ["server", "token"],
                "properties": {
                  "server": {
                    "description": "Packages registry address",
                    "type": "string",
                    "default": "http://verdaccio.anywork.local:4873"
                  },
                  "token": {
                    "description": "An access token to packages registry",
                    "type": "string"
                  },
                  "prefix": {
                    "description": "A prefix of package names starting with `@` character",
                    "type": "string",
                    "default": "@anywork",
                    "examples": ["@anywork", "@moduleOne"],
                    "pattern": "^@\\w+$"
                  }
                }
              },
              "schemas": {
                "title": "schemas",
                "description": "Schemas (microservices) to generate libraries",
                "type": "array",
                "items": {
                  "title": "schema",
                  "description": "A schema",
                  "type": "object",
                  "properties": {
                    "name": {
                      "$ref": "#/definitions/schema"
                    },
                    "lastVersion": {
                      "description": "A last published version",
                      "type": "string",
                      "pattern": "\\d{1,}\\.\\d{1,}\\.\\d{1,}"
                    },
                    "url": {
                      "description": "A url",
                      "type": "string",
                      "examples": ["http://somewhere/path/to/swagger.json"],
                      "pattern": "http[s]?:\\/\\/.*\\/swagger\\.json"
                    }
                  }
                }
              },
              "typescript": {
                "description": "TypeScript version to install on generated codes repository",
                "type": "string",
                "default": "^4.1.6",
                "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-]+)*))?$"
              }
            },
            "additionalProperties": false
          }
        }
      }
    }
  ],
  "definitions": {
    "schema": {
      "description": "A Swagger endpoint name",
      "type": "string",
      "enum": ["authentication", "documentStorage", "shared"]
    }
  },
  "description": "AnyWork automation config schema",
  "properties": {
    "ctype": {
      "description": "A configuration type",
      "type": "string"
    },
    "cversion": {
      "description": "A configuration version of configuration",
      "type": "integer",
      "default": 1,
      "minimum": 1
    }
  },
  "required": ["ctype", "cversion"],
  "title": "AnyWork Automation config",
  "type": "object"
}
