{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md/",
    "$async": true,
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "log": {
            "$ref": "#/definitions/log"
        }
    },
    "required": ["log"],
    "definitions": {
        "log": {
            "description": "HTTP Archive structure.",
            "type": "object",
            "required": ["version", "creator", "entries"],
            "properties": {
                "version": {
                    "type": "string",
                    "default": "1.2"
                },
                "creator": {
                    "$ref": "#/definitions/creator"
                },
                "browser": {
                    "$ref": "#/definitions/creator"
                },
                "pages": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/page"
                    }
                },
                "entries": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/entry"
                    },
                    "minItems": 1
                },
                "comment": {
                    "type": "string"
                }
            }
        },
        "creator": {
            "description": "Name and version info of the log creator app.",
            "type": "object",
            "required": ["name", "version"],
            "properties": {
                "name": {
                    "type": "string"
                },
                "version": {
                    "type": "string"
                },
                "comment": {
                    "type": "string"
                }
            }
        },
        "page": {
            "description": "Exported web page",
            "required": ["startedDateTime", "id", "title", "pageTimings"],
            "properties": {
                "startedDateTime": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "title": {
                    "type": "string"
                },
                "pageTimings": {
                    "$ref": "#/definitions/pageTimings"
                },
                "comment": {
                    "type": "string"
                }
            }
        },
        "pageTimings": {
            "description": "Timing info about page load",
            "properties": {
                "onContentLoad": {
                    "type": ["number", "null"],
                    "default": -1
                },
                "onLoad": {
                    "type": ["number", "null"],
                    "default": -1
                },
                "comment": {
                    "type": "string"
                }
            }
        },
        "entry": {
            "description": "Request and Response related info",
            "required": ["startedDateTime", "time", "request", "response", "timings"],
            "properties": {
                "pageref": { "type": "string" },
                "startedDateTime": {
                    "type": "string"
                },
                "time": { "type": "number", "minimum": 0, "default": 0 },
                "request": { "$ref": "#/definitions/request" },
                "response": { "$ref": "#/definitions/response" },
                "cache": { "$ref": "#/definitions/cache" },
                "timings": { "$ref": "#/definitions/timings" },
                "serverIPAddress": {
                    "type": "string",
                    "if": {
                        "format": "ipv6"
                    },
                    "else": {
                        "if": {
                            "pattern": "^\\[([^\\]]+)\\](?::([0-9]+))?$"
                        },
                        "else": {
                            "if": {
                                "minLength": 1
                            },
                            "then": {
                                "format": "ipv4"
                            }
                        }
                    },
                    "errorMessage": "The property `serverIPAddress` must have a value that is either IPv4 or IPv6 format"
                },
                "connection": {
                    "type": "string"
                },
                "comment": { "type": "string" }
            }
        },
        "request": {
            "description": "Monitored request",
            "required": [
                "method",
                "url",
                "httpVersion",
                "cookies",
                "headers",
                "queryString"
            ],
            "properties": {
                "method": {
                    "type": "string",
                    "description": "The Standard HTTP method associated with this request.",
                    "enum": [
                        "GET",
                        "PUT",
                        "POST",
                        "PATCH",
                        "DELETE",
                        "COPY",
                        "HEAD",
                        "OPTIONS",
                        "LINK",
                        "UNLINK",
                        "PURGE",
                        "LOCK",
                        "UNLOCK",
                        "PROPFIND",
                        "VIEW"
                    ]
                },
                "url": { "type": "string" },
                "httpVersion": { "type": "string" },
                "cookies": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/cookie" }
                },
                "headers": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/record" }
                },
                "queryString": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/record" }
                },
                "postData": { "$ref": "#/definitions/postData" },
                "headersSize": { "type": ["integer", "null"], "default": -1 },
                "bodySize": { "type": ["integer", "null"], "default": -1 },
                "comment": { "type": "string" }
            }
        },
        "record": {
            "required": ["name", "value"],
            "description": "Helper name-value pair structure.",
            "properties": {
                "name": { "type": "string" },
                "value": { "type": "string" },
                "comment": { "type": "string" }
            }
        },
        "response": {
            "description": "Monitored Response.",
            "required": [
                "status",
                "statusText",
                "httpVersion",
                "cookies",
                "headers",
                "content",
                "redirectURL"
            ],
            "properties": {
                "status": { "type": "integer" },
                "statusText": { "type": "string" },
                "httpVersion": { "type": "string" },
                "cookies": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/cookie" }
                },
                "headers": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/record" }
                },
                "content": { "$ref": "#/definitions/content" },
                "redirectURL": { "type": "string" },
                "headersSize": { "type": ["integer", "null"], "default": -1 },
                "bodySize": { "type": ["integer", "null"], "default": -1 },
                "comment": { "type": "string" }
            }
        },
        "cookie": {
            "description": "Cookie description.",
            "required": ["name", "value"],
            "properties": {
                "name": { "type": "string" },
                "value": { "type": "string" },
                "path": { "type": "string" },
                "domain": { "type": "string" },
                "expires": {
                    "type": ["string", "null"]
                },
                "httpOnly": { "type": "boolean" },
                "secure": { "type": "boolean" },
                "comment": { "type": "string" }
            }
        },
        "postData": {
            "description": "Posted data info.",
            "required": ["mimeType"],
            "properties": {
                "mimeType": { "type": "string" },
                "text": { "type": "string" },
                "params": {
                    "type": "array",
                    "required": ["name"],
                    "properties": {
                        "name": { "type": "string" },
                        "value": { "type": "string" },
                        "fileName": { "type": "string" },
                        "content": { "type": "string" },
                        "comment": { "type": "string" }
                    }
                },
                "comment": { "type": "string" }
            }
        },
        "content": {
            "description": "Response content",
            "properties": {
                "size": { "type": "integer" },
                "compression": { "type": "integer" },
                "mimeType": { "type": "string" },
                "text": { "type": "string" },
                "encoding": { "type": "string" },
                "comment": { "type": "string" }
            }
        },
        "cache": {
            "description": "Info about a response coming from the cache.",
            "properties": {
                "beforeRequest": {
                    "if": {
                        "type": "null"
                    },
                    "else": {
                        "$ref": "#/definitions/cacheEntry"
                    }
                },
                "afterRequest": {
                    "if": {
                        "type": "null"
                    },
                    "else": {
                        "$ref": "#/definitions/cacheEntry"
                    }
                },
                "comment": { "type": "string" }
            }
        },
        "cacheEntry": {
            "description": "Info about cache entry.",
            "properties": {
                "expires": {
                    "type": ["string", "boolean"]
                },
                "lastAccess": {
                    "type": "string"
                },
                "eTag": { "type": "string" },
                "hitCount": { "type": "integer" },
                "comment": { "type": "string" }
            }
        },
        "timings": {
            "description": "Info about request-response timing.",
            "properties": {
                "dns": { "type": "number", "default": -1 },
                "connect": { "type": "number", "default": -1 },
                "blocked": { "type": "number", "default": -1 },
                "send": { "type": "number" },
                "wait": { "type": "number" },
                "receive": { "type": "number" },
                "ssl": { "type": "number", "default": -1 },
                "comment": { "type": "string" }
            }
        }
    }
}
