{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/architectfx.json",
  "title": "ArchitectFX Documents Schema",
  "type": "object",
  "properties": {
    ".controller": {
      "type": "string",
      "description": "A class which may hold injected fields to handle them"
    },
    ".deps": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "description": "Maven coordinates used for third-party libraries that are needed to load the document"
      }
    },
    ".imports": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "description": "Java imports for resolving commonly used classes in the Document"
      }
    },
    ".config": {
      "type": "array",
      "description": "A series of generic steps to configure global state or specific objects",
      "items": {
        "$ref": "#/definitions/config"
      }
    }
  },
  "patternProperties": {
    "^[A-Za-z_][A-Za-z0-9_]*$": {
      "$ref": "#/definitions/entity"
    }
  },
  "definitions": {
    "config": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            ".field": {
              "type": "string",
              "description": "Field configurations"
            },
            ".value": {
              "description": "Value to be assigned to the field"
            }
          },
          "required": [".field", ".value"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            ".method": {
              "type": "string",
              "description": "Name of the method to be invoked"
            },
            ".args": {
              "type": "array",
              "description": "Arguments for the method"
            },
            ".varargs": {
              "type": "array",
              "description": "Specifically to be used for method which use varargs"
            },
            ".transform": {
              "type": "boolean",
              "description": "Indicates whether the output of the method should be used as input for the next config or as the return type"
            }
          },
          "required": [".method"],
          "additionalProperties": false
        }
      ]
    },
    "entity": {
      "description": "Entity or tree node",
      "type": "object",
      "properties": {
        ".args": {
          "type": "array",
          "description": "Arguments for the constructor"
        },
        ".varargs": {
          "type": "array",
          "description": "Specifically to be used for constructors which use varargs"
        },
        ".factory": {
          "type": "array",
          "description": "Allows building this entity through the factory/builder pattern using configs",
          "items": {
            "$ref": "#/definitions/config"
          }
        },
        ".config": {
          "type": "array",
          "description": "A series of generic steps to configure global state or specific objects",
          "items": {
            "$ref": "#/definitions/config"
          }
        },
        "children": {
          "type": "array",
          "description": "Entities may or may not contain other entities inside them",
          "items": {
            "$ref": "#/definitions/entity"
          }
        }
      }
    }
  }
}
