{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/anywork-automation-configuration/versions/1.0.json",
  "title": "AnyWork Automation config",
  "description": "AnyWork automation config schema",
  "x-lintel": {
    "source": "https://www.schemastore.org/anywork-ac-1.0.json",
    "sourceSha256": "907327d2d991978a18ff0171f472e25bd53c9db7d7c9f251210e420bf1968e0f",
    "fileMatch": [
      ".awc.yaml",
      ".awc.yml",
      ".awc.json",
      ".awc.jsonc",
      ".awc"
    ],
    "parsers": [
      "json",
      "jsonc",
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "ctype": {
      "description": "A configuration type",
      "type": "string"
    },
    "cversion": {
      "description": "A configuration version of configuration",
      "type": "integer",
      "default": 1,
      "minimum": 1
    }
  },
  "required": [
    "ctype",
    "cversion"
  ],
  "additionalProperties": true,
  "$defs": {
    "schema": {
      "description": "A Swagger endpoint name",
      "type": "string",
      "enum": [
        "authentication",
        "documentStorage",
        "shared"
      ]
    }
  },
  "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": {
                          "$ref": "https://catalog.lintel.tools/schemas/schemastore/anywork-automation-configuration/_shared/1.0--base.json#/$defs/path",
                          "description": "A path to repository including `node_modules` directory to install desired services"
                        },
                        "schema": {
                          "$ref": "#/$defs/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": "#/$defs/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
          }
        },
        "type": "object"
      }
    }
  ]
}
