Sebastien Dionne
unread,Jan 31, 2012, 7:19:29 PM1/31/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to JSON Schema
Hello. I'm playing with the json validator for few days, and I'm
stuck when I try to validate a schema that use $ref.
My Unittest failed when I try to validate : "logType".
@Test
public void testLogType() throws JsonValidationFailureException
{
testOne("logType");
}
if I validate all the others structure it passed fine. What I'm
missing here ?
Here the error that I have in my console :
org.eel.kitchen.jsonschema.main.JsonValidationFailureException: no
match in schema for path #/log/browserType
at
org.eel.kitchen.jsonschema.main.SchemaProvider.atPoint(SchemaProvider.java:
138)
at
org.eel.kitchen.jsonschema.main.ValidationContext.getValidator(ValidationContext.java:
254)
at
org.eel.kitchen.jsonschema.keyword.common.RefKeywordValidator.validate(RefKeywordValidator.java:
118)
at
org.eel.kitchen.jsonschema.container.ContainerValidator.validate(ContainerValidator.java:
74)
at
org.eel.kitchen.jsonschema.container.ObjectValidator.validateChildren(ObjectValidator.java:
66)
at
org.eel.kitchen.jsonschema.container.ContainerValidator.validate(ContainerValidator.java:
79)
If I change #/log/... And use directly the id.
I obtain : illegalArgumentException : invalid URI :.... URL is not
absolute...
here my SCHEMA
{
"logType": {
"id": "logType",
"description": "HTTP Archive structure.",
"type": "object",
"properties": {
"log": {
"type": "object",
"properties": {
"version": {"type": "string"},
"creator": {"$ref": "#/log/creatorType"},
"browser": {"$ref": "#/log/browserType"},
"pages": {"type": "array", "required": false,
"items": {"$ref": "#/log/pageType"}},
"entries": {"type": "array", "items": {"$ref": "#/
log/entryType"}},
"comment": {"type": "string", "required":
false}
}
}
}
},
"creatorType": {
"id": "creatorType",
"description": "Name and version info of the log creator
app.",
"type": "object",
"properties": {
"name": {"type": "string"},
"version": {"type": "string"},
"comment": {"type": "string", "required": false}
}
},
"browserType": {
"id": "browserType",
"description": "Name and version info of used browser.",
"type": "object",
"required": false,
"properties": {
"name": {"type": "string"},
"version": {"type": "string"},
"comment": {"type": "string", "required": false}
}
},
"pageType": {
"id": "pageType",
"description": "Exported web page",
"required": false,
"properties": {
"startedDateTime": {"type": "string", "format": "date-
time", "pattern": "dateTimePattern"},
"id": {"type": "string", "unique": true},
"title": {"type": "string"},
"pageTimings": {"$ref": "pageTimingsType"},
"comment": {"type": "string", "required": false}
}
},
"pageTimingsType": {
"id": "pageTimingsType",
"description": "Timing info about page load",
"properties": {
"onContentLoad": {"type": "number", "required": false,
"min": -1},
"onLoad": {"type": "number", "required": false, "min":
-1},
"comment": {"type": "string", "required": false}
}
},
"entryType": {
"id": "entryType",
"description": "Request and Response related info",
"required": false,
"properties": {
"pageref": {"type": "string", "required": false},
"startedDateTime": {"type": "string", "format": "date-
time", "pattern": "dateTimePattern"},
"time": {"type": "integer", "min": 0},
"request" : {"$ref": "requestType"},
"response" : {"$ref": "responseType"},
"cache" : {"$ref": "cacheType"},
"timings" : {"$ref": "timingsType"},
"serverIPAddress" : {"type": "string", "required":
false},
"connection" : {"type": "string", "required": false},
"comment": {"type": "string", "required": false}
}
},
"requestType": {
"id": "requestType",
"description": "Monitored request",
"properties": {
"method": {"type": "string"},
"url": {"type": "string"},
"httpVersion": {"type" : "string"},
"cookies" : {"type": "array", "items": {"$ref":
"cookieType"}},
"headers" : {"type": "array", "items": {"$ref":
"recordType"}},
"queryString" : {"type": "array", "items": {"$ref":
"recordType"}},
"postData" : {"$ref": "postDataType"},
"headersSize" : {"type": "integer"},
"bodySize" : {"type": "integer"},
"comment": {"type": "string", "required": false}
}
},
"recordType": {
"id": "recordType",
"description": "Helper name-value pair structure.",
"properties": {
"name": {"type": "string"},
"value": {"type": "string"},
"comment": {"type": "string", "required": false}
}
},
"responseType": {
"id": "responseType",
"description": "Monitored Response.",
"properties": {
"status": {"type": "integer"},
"statusText": {"type": "string"},
"httpVersion": {"type": "string"},
"cookies" : {"type": "array", "items": {"$ref":
"cookieType"}},
"headers" : {"type": "array", "items": {"$ref":
"recordType"}},
"content" : {"$ref": "contentType"},
"redirectURL" : {"type": "string"},
"headersSize" : {"type": "integer"},
"bodySize" : {"type": "integer"},
"comment": {"type": "string", "required": false}
}
},
"cookieType": {
"id": "cookieType",
"description": "Cookie description.",
"properties": {
"name": {"type": "string"},
"value": {"type": "string"},
"path": {"type": "string", "required": false},
"domain" : {"type": "string", "required": false},
"expires" : {"type": "string", "required": false},
"httpOnly" : {"type": "boolean", "required": false},
"secure" : {"type": "boolean", "required": false},
"comment": {"type": "string", "required": false}
}
},
"postDataType": {
"id": "postDataType",
"description": "Posted data info.",
"required": false,
"properties": {
"mimeType": {"type": "string"},
"text": {"type": "string", "required": false},
"params": {
"type": "array",
"required": false,
"properties": {
"name": {"type": "string"},
"value": {"type": "string", "required": false},
"fileName": {"type": "string", "required":
false},
"contentType": {"type": "string", "required":
false},
"comment": {"type": "string", "required":
false}
}
},
"comment": {"type": "string", "required": false}
}
},
"contentType": {
"id": "contentType",
"description": "Response content",
"properties": {
"size": {"type": "integer"},
"compression": {"type": "integer", "required": false},
"mimeType": {"type": "string"},
"text": {"type": "string", "required": false},
"encoding": {"type": "string", "required": false},
"comment": {"type": "string", "required": false}
}
},
"cacheType": {
"id": "cacheType",
"description": "Info about a response coming from the
cache.",
"properties": {
"beforeRequest": {"$ref": "cacheEntryType"},
"afterRequest": {"$ref": "cacheEntryType"},
"comment": {"type": "string", "required": false}
}
},
"cacheEntryType": {
"id": "cacheEntryType",
"required": false,
"description": "Info about cache entry.",
"properties": {
"expires": {"type": "string", "required": false},
"lastAccess": {"type": "string"},
"eTag": {"type": "string"},
"hitCount": {"type": "integer"},
"comment": {"type": "string", "required": false}
}
},
"timingsType": {
"id": "timingsType",
"description": "Info about request-response timing.",
"properties": {
"dns": {"type": "integer", "required": false, "min":
-1},
"connect": {"type": "integer", "required": false, "min":
-1},
"blocked": {"type": "integer", "required": false, "min":
-1},
"send": {"type": "integer", "min": -1},
"wait": {"type": "integer", "min": -1},
"receive": {"type": "integer", "min": -1},
"ssl": {"type": "integer", "required": false, "min":
-1},
"comment": {"type": "string", "required": false}
}
}
}
HERE A SUBSET OF DATA
{
"log": {
"version": "1.1",
"creator": {
"name": "Firebug",
"version": "1.8"
},
"browser": {
"name": "Firefox",
"version": "8.0"
}
}
}