{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "Test schema.",
    "type": "object",
    "definitions": {
        "port": {
            "description": "schema for a server port",
            "type": "integer",
            "minimum": 1024,
            "maximum": 65536,
            "messages": {
                "type": "invalid type. Must be an integer.",
                "minimum": "invalid value. Must be an integer greater than or equal to 1024.",
                "maximum": "invalid value. Must be an integer less than or equal to 65536."
            }
        },
        "address": {
            "description": "schema for a server host address",
            "type": "string",
            "format": "hostname",
            "messages": {
                "type": "invalid type. Must be a string.",
                "format": "invalid format. Must be a valid hostname."
            }
        },
        "loglevel": {
            "description": "schema for a log level",
            "type": "string",
            "enum": [
                "fatal",
                "error",
                "warn",
                "info",
                "debug",
                "trace"
            ],
            "messages": {
                "type": "invalid type. Must be a string.",
                "enum": "invalid value. Must be one of the following: ['fatal','error','warn','info','debug','trace']."
            }
        },
        "env": {
            "description": "schema for an environment name",
            "type": "string",
            "enum": [
                "local",
                "test",
                "dev",
                "production"
            ],
            "messages": {
                "type": "invalid type. Must be a string.",
                "enum": "invalid value. Must be one of the following: ['local','test','dev','production']."
            }
        }
    },
    "properties": {
        "server": {
            "description": "schema for server configuration",
            "type": "object",
            "properties": {
                "port": {
                    "$ref": "#/definitions/port"
                },
                "address": {
                    "$ref": "#/definitions/address"
                },
                "ssl": {
                    "description": "schema for SSL flag",
                    "type": "boolean",
                    "messages": {
                        "type": "invalid type. Must be a boolean."
                    }
                },
                "key": {
                    "description": "schema for private key",
                    "type": "string",
                    "messages": {
                        "type": "invalid type. Must be a string."
                    }
                },
                "cert": {
                    "description": "schema for public certificate",
                    "type": "string",
                    "messages": {
                        "type": "invalid type. Must be a string."
                    }
                }
            },
            "messages": {
                "type": "invalid type. Must be an object."
            }
        },
        "logger": {
            "description": "schema for logger configuration",
            "type": "object",
            "properties": {
                "level": {
                    "$ref": "#/definitions/loglevel"
                }
            },
            "messages": {
                "type": "invalid type. Must be an object."
            }
        },
        "env": {
            "$ref": "#/definitions/env"
        }
    },
    "messages": {
        "type": "invalid data type where an object is expected"
    }
}