Skip to content

Instantly share code, notes, and snippets.

@israelshirk
Created May 10, 2017 22:11
Show Gist options
  • Save israelshirk/b5a0e74696d3e266f600f1752d6ef6b6 to your computer and use it in GitHub Desktop.
Save israelshirk/b5a0e74696d3e266f600f1752d6ef6b6 to your computer and use it in GitHub Desktop.
HAR JSON schema. For use with my branch of tv4.
{
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"name": "HAR format",
"description": "JSON Schema structuring of HAR, based on https://github.com/jarib/har/blob/master/schema.json",
"type": "object",
"properties": { "$ref": "#logType" },
"logType": {
"id": "logType",
"description": "HTTP Archive structure.",
"type": "object",
"properties": {
"log": {
"type": "object",
"properties": {
"version": {"type": "string", "required": true},
"creator": {"$ref": "#creatorType", "required": true},
"browser": {"$ref": "#browserType", "required": true},
"pages": {"type": "array", "items": {"$ref": "#pageType"}},
"entries": {"type": "array", "items": {"$ref": "#entryType"}, "required": true},
"comment": {"type": "string"}
}
}
}
},
"creatorType": {
"id": "creatorType",
"description": "Name and version info of the log creator app.",
"type": "object",
"properties": {
"name": {"type": "string", "required": true},
"version": {"type": "string", "required": true},
"comment": {"type": "string"}
}
},
"browserType": {
"id": "browserType",
"description": "Name and version info of used browser.",
"type": "object",
"optional": true,
"properties": {
"name": {"type": "string", "required": true},
"version": {"type": "string", "required": true},
"comment": {"type": "string"}
}
},
"pageType": {
"id": "pageType",
"description": "Exported web page",
"optional": true,
"properties": {
"startedDateTime": {"type": "string", "format": "date-time", "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))", "required": true},
"id": {"type": "string", "unique": true, "required": true},
"title": {"type": "string", "required": true},
"pageTimings": {"$ref": "#pageTimingsType", "required": true},
"comment": {"type": "string"}
}
},
"pageTimingsType": {
"id": "pageTimingsType",
"description": "Timing info about page load",
"properties": {
"onContentLoad": {"type": "number", "min": -1},
"onLoad": {"type": "number", "min": -1},
"comment": {"type": "string"}
}
},
"entryType": {
"id": "entryType",
"description": "Request and Response related info",
"optional": true,
"properties": {
"pageref": {"type": "string"},
"startedDateTime": {"type": "string", "format": "date-time", "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))", "required": true},
"time": {"type": "integer", "min": 0, "required": true},
"request" : {"$ref": "#requestType", "required": true},
"response" : {"$ref": "#responseType", "required": true},
"cache" : {"$ref": "#cacheType", "required": true},
"timings" : {"$ref": "#timingsType", "required": true},
"serverIPAddress" : {"type": "string"},
"connection" : {"type": "string"},
"comment": {"type": "string"}
}
},
"requestType": {
"id": "requestType",
"description": "Monitored request",
"properties": {
"method": {"type": "string", "required": true},
"url": {"type": "string", "required": true},
"httpVersion": {"type" : "string", "required": true},
"cookies" : {"type": "array", "items": {"$ref": "#cookieType"}, "required": true},
"headers" : {"type": "array", "items": {"$ref": "#recordType"}, "required": true},
"queryString" : {"type": "array", "items": {"$ref": "#recordType"}, "required": true},
"postData" : {"$ref": "#postDataType"},
"headersSize" : {"type": "integer", "required": true},
"bodySize" : {"type": "integer", "required": true},
"comment": {"type": "string"}
}
},
"recordType": {
"id": "recordType",
"description": "Helper name-value pair structure.",
"properties": {
"name": {"type": "string", "required": true},
"value": {"type": "string", "required": true},
"comment": {"type": "string"}
}
},
"responseType": {
"id": "responseType",
"description": "Monitored Response.",
"properties": {
"status": {"type": "integer", "required": true},
"statusText": {"type": "string", "required": true},
"httpVersion": {"type": "string", "required": true},
"cookies" : {"type": "array", "items": {"$ref": "#cookieType"}, "required": true},
"headers" : {"type": "array", "items": {"$ref": "#recordType"}, "required": true},
"content" : {"$ref": "#contentType", "required": true},
"redirectURL" : {"type": "string", "required": true},
"headersSize" : {"type": "integer", "required": true},
"bodySize" : {"type": "integer", "required": true},
"comment": {"type": "string"}
}
},
"cookieType": {
"id": "cookieType",
"description": "Cookie description.",
"properties": {
"name": {"type": "string", "required": true},
"value": {"type": "string", "required": true},
"path": {"type": "string"},
"domain" : {"type": "string"},
"expires" : {"type": "string"},
"httpOnly" : {"type": "boolean"},
"secure" : {"type": "boolean"},
"comment": {"type": "string"}
}
},
"postDataType": {
"id": "postDataType",
"description": "Posted data info.",
"optional": true,
"properties": {
"mimeType": {"type": "string", "required": true},
"text": {"type": "string"},
"params": {
"type": "array",
"properties": {
"name": {"type": "string", "required": true},
"value": {"type": "string"},
"fileName": {"type": "string"},
"contentType": {"type": "string"},
"comment": {"type": "string"}
}
},
"comment": {"type": "string"}
}
},
"contentType": {
"id": "contentType",
"description": "Response content",
"properties": {
"size": {"type": "integer", "required": true},
"compression": {"type": "integer"},
"mimeType": {"type": "string", "required": true},
"text": {"type": "string"},
"encoding": {"type": "string"},
"comment": {"type": "string"}
}
},
"cacheType": {
"id": "cacheType",
"description": "Info about a response coming from the cache.",
"properties": {
"beforeRequest": {"$ref": "#cacheEntryType"},
"afterRequest": {"$ref": "#cacheEntryType"},
"comment": {"type": "string"}
}
},
"cacheEntryType": {
"id": "cacheEntryType",
"optional": true,
"description": "Info about cache entry.",
"properties": {
"expires": {"type": "string"},
"lastAccess": {"type": "string", "required": true},
"eTag": {"type": "string", "required": true},
"hitCount": {"type": "integer", "required": true},
"comment": {"type": "string"}
}
},
"timingsType": {
"id": "timingsType",
"description": "Info about request-response timing.",
"properties": {
"dns": {"type": "integer", "min": -1, "required": true},
"connect": {"type": "integer", "min": -1, "required": true},
"blocked": {"type": "integer", "min": -1, "required": true},
"send": {"type": "integer", "min": -1, "required": true},
"wait": {"type": "integer", "min": -1, "required": true},
"receive": {"type": "integer", "min": -1, "required": true},
"ssl": {"type": "integer", "min": -1},
"comment": {"type": "string"}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment