Hi there,
I am trying to setup a custom context for tracking events related to A/B tests. In order to do this, I created the following self-describing json schema (company name changed to acme.com)
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Variation of a test on acme.com",
"self": {
"vendor": "com.acme",
"name": "testvariation",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"testId": {
"description": "Identifier of the test",
"type": "integer",
"minimum": 0,
"maximum": 2147483647
},
"variationId": {
"description": "Identifier of the variation of the test",
"type": "integer",
"minimum": 0,
"maximum": 2147483647
}
},
"required": ["testId", "variationId"],
"additionalProperties": false
}
I could verify that this is a valid self-describing json schema using
./igluctl lint schemas/com.acme/testvariation/jsonschema/1-0-0
My intent with this schema was to validate self-describing json like this one (as described in the documentation)
{
"schema": "iglu:com.acme/testvariation/jsonschema/1-0-0",
"data": {
"testId": 1234,
"variationId": 5678
}
}
I wanted to verify that it works, so I have setup an iglu-server instance, where I uploaded the json-schema.
curl -X POST 'http://192.168.99.100:30704/api/schemas/com.acme/testvariation/jsonschema/1-0-0?isPublic=true' -H 'apikey: my-write-key' -d @schemas/com.acme/testvariation/jsonschema/1-0-0
{
"status" : 201,
"message" : "Schema successfully added",
"location" : "/api/schemas/com.acme/testvariation/jsonschema/1-0-0"
}
Now when I try to validate my self-describing json, I get this:
curl http://192.168.99.100:30704/api/schemas/validate/com.acme/testvariation/jsonschema/1-0-0 -X POST -F 'instance={"schema": "iglu:com.acme/testvariation/jsonschema/1-0-0", "data": {"testId": 1234, "variationId": 5678}}}'
{
"status" : 400,
"message" : "The instance provided is not valid against the schema",
"report" : {
"level" : "error",
"schema" : {
"loadingURI" : "#",
"pointer" : ""
},
"instance" : {
"pointer" : ""
},
"domain" : "validation",
"keyword" : "additionalProperties",
"message" : "object instance has properties which are not allowed by the schema: [\"data\",\"schema\"]",
"unwanted" : [ "data", "schema" ]
}
}
However, if I try to validate against the embedded payload directly, I obtain this:
curl http://192.168.99.100:30704/api/schemas/validate/com.acme/testvariation/jsonschema/1-0-0 -X POST -F 'instance={"testId": 1234, "variationId": 5678}'
{
"status" : 200,
"message" : "The instance provided is valid against the schema"
}
I am utterly confused as to why this is happening. Why is my self-describing json not validating?
The documentation of custom contexts specifies that on the frontend side, the javascript should send the custom contexts as self describing json. Why is only the payload validating, then?