{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "additionalProperties": true,
    "definitions": {
        "acl": {
            "oneOf": [
                {
                    "$ref": "#/definitions/aclSimple"
                },
                {
                    "properties": {
                        "create": {
                            "$ref": "#/definitions/aclSimple"
                        },
                        "delete": {
                            "$ref": "#/definitions/aclSimple"
                        },
                        "read": {
                            "$ref": "#/definitions/aclSimple"
                        },
                        "update": {
                            "$ref": "#/definitions/aclSimple"
                        }
                    },
                    "type": "object"
                }
            ]
        },
        "aclSimple": {
            "items": {
                "$ref": "#/definitions/basicName"
            },
            "minItems": 0,
            "type": "array",
            "_uniqueItems": true
        },
        "basicName": {
            "pattern": "^[a-zA-Z_$][a-zA-Z_$0-9]*$",
            "type": "string"
        },
        "check": {
            "type": "string"
        },
        "field": {
            "properties": {
                "autoIncrement": {
                    "type": "boolean"
                },
                "default": {},
                "description": {
                    "type": "string"
                },
                "encrypted": {
                    "type": "boolean"
                },
                "enum": {
                    "minItems": 1,
                    "type": "array",
                    "_uniqueItems": true
                },
                "filterable": {
                    "type": "boolean"
                },
                "max": {
                    "oneOf": [
                        {
                            "type": "number"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "min": {
                    "oneOf": [
                        {
                            "type": "number"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "name": {
                    "$ref": "#/definitions/basicName"
                },
                "onUpdate": {
                    "type": "string"
                },
                "pattern": {
                    "type": "string"
                },
                "patternOptions": {
                    "items": {
                        "type": "string"
                    },
                    "minItems": 1,
                    "type": "array",
                    "_uniqueItems": true
                },
                "precision": {
                    "items": {
                        "type": "integer"
                    },
                    "maxItems": 2,
                    "minItems": 2,
                    "type": "array",
                    "_uniqueItems": false
                },
                "readOnly": {
                    "type": "boolean"
                },
                "required": {
                    "type": "boolean"
                },
                "sortable": {
                    "type": "boolean"
                },
                "type": {
                    "enum": [
                        "int",
                        "float",
                        "decimal",
                        "string",
                        "bool",
                        "date",
                        "time",
                        "datetime",
                        "file"
                    ],
                    "type": "string"
                },
                "unique": {
                    "type": "boolean"
                },
                "writeOnly": {
                    "type": "boolean"
                }
            },
            "required": [
                "name",
                "type"
            ],
            "type": "object"
        },
        "index": {
            "items": {
                "type": "string"
            },
            "minItems": 0,
            "type": "array",
            "_uniqueItems": true
        },
        "relation": {
            "properties": {
                "check": {
                    "$ref": "#/definitions/check"
                },
                "description": {
                    "type": "string"
                },
                "embed": {
                    "type": "boolean"
                },
                "fields": {
                    "items": {
                        "$ref": "#/definitions/field"
                    },
                    "minItems": 0,
                    "type": "array",
                    "_uniqueItems": true
                },
                "index": {
                    "$ref": "#/definitions/index"
                },
                "max": {
                    "type": "integer"
                },
                "min": {
                    "type": "integer"
                },
                "onDelete": {
                    "type": "string"
                },
                "onUpdate": {
                    "type": "string"
                },
                "type": {
                    "enum": [
                        "hasOne",
                        "hasMany"
                    ],
                    "type": "string"
                },
                "with": {
                    "$ref": "#/definitions/basicName"
                }
            },
            "required": [
                "with",
                "type"
            ],
            "type": "object"
        },
        "resource": {
            "properties": {
                "abstract": {
                    "type": "boolean"
                },
                "acceptExtraFields": {
                    "type": "boolean"
                },
                "acl": {
                    "$ref": "#/definitions/acl"
                },
                "base": {
                    "$ref": "#/definitions/basicName"
                },
                "check": {
                    "$ref": "#/definitions/check"
                },
                "description": {
                    "type": "string"
                },
                "fields": {
                    "items": {
                        "$ref": "#/definitions/field"
                    },
                    "minItems": 1,
                    "type": "array",
                    "_uniqueItems": true
                },
                "idInjection": {
                    "type": "boolean"
                },
                "index": {
                    "$ref": "#/definitions/index"
                },
                "inheritanceStrategy": {
                    "type": "string"
                },
                "isUser": {
                    "type": "boolean"
                },
                "name": {
                    "$ref": "#/definitions/basicName"
                },
                "paginable": {
                    "type": "boolean"
                },
                "plural": {
                    "$ref": "#/definitions/basicName"
                },
                "relations": {
                    "items": {
                        "$ref": "#/definitions/relation"
                    },
                    "minItems": 0,
                    "type": "array",
                    "_uniqueItems": true
                }
            },
            "required": [
                "name",
                "fields"
            ],
            "type": "object"
        },
        "role": {
            "properties": {
                "isA": {
                    "type": "string"
                },
                "isAdmin": {
                    "type": "boolean"
                },
                "isGuest": {
                    "type": "boolean"
                },
                "name": {
                    "$ref": "#/definitions/basicName"
                },
                "rateLimit": {
                    "properties": {
                        "numOfRequests": {
                            "minimum": 0,
                            "type": "integer"
                        },
                        "refreshTime": {
                            "minimum": 0,
                            "type": "integer"
                        }
                    },
                    "required": [
                        "numOfRequests",
                        "refreshTime"
                    ],
                    "type": "object"
                }
            },
            "required": [
                "name"
            ],
            "type": "object"
        }
    },
    "properties": {
        "authenticationMechanism": {
            "type": "string"
        },
        "baseUrl": {
            "pattern": "^(http(s)?\\:\\/\\/(([a-zA-Z0-9]+((\\.|\\-)[a-zA-Z0-9]+)+)|(localhost))(\\:\\d+)?(\\/[\\w\\-]+)*(\\/?|\\/\\w+\\.[a-zA-Z]{2,4}(\\?[\\w]+\\=[\\w\\-]+)?)?(\\&[\\w]+\\=[\\w\\-]+)*)$",
            "type": "string"
        },
        "dataFormats": {
            "items": {
                "pattern": "^([\\w.+-]+/[\\w.+-]+)$",
                "type": "string"
            },
            "minItems": 1,
            "type": "array",
            "_uniqueItems": true
        },
        "database": {
            "properties": {
                "admin": {
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "password": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "name",
                        "password"
                    ],
                    "type": "object"
                },
                "dbms": {
                    "type": "string"
                },
                "host": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "port": {
                    "type": "integer"
                },
                "prefix": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "dateFormat": {
            "type": "string"
        },
        "description": {
            "type": "string"
        },
        "encoding": {
            "type": "string"
        },
        "resources": {
            "items": {
                "$ref": "#/definitions/resource"
            },
            "minItems": 1,
            "type": "array",
            "_uniqueItems": true
        },
        "roles": {
            "items": {
                "$ref": "#/definitions/role"
            },
            "minItems": 0,
            "type": "array",
            "_uniqueItems": true
        },
        "timeZone": {
            "type": "string"
        },
        "title": {
            "type": "string"
        },
        "types": {
            "items": {
                "$ref": "#/definitions/field"
            },
            "minItems": 0,
            "type": "array",
            "_uniqueItems": true
        },
        "version": {
            "type": "string"
        }
    },
    "required": [
        "baseUrl",
        "dataFormats",
        "database",
        "resources"
    ],
    "type": "object"
}