Structured Objects JSON Schema
(Moved from Structured Objects JSON Schema)
There is no formal specification of EntityJSON or attribute types. I propose that we use JSON Schema for this purpose.
Information about JSON Schema can be found at
https://spacetelescope.github.io/understanding-json-schema
and
and there is an online validator at
http://www.jsonschemavalidator.net/
The online validator is not perfect but useful for initial testing.
I propose that we should restrict ourselves to use of JSON Schema Draft 4 as this version is supported by the validator code which we might use.
The following schema defines both EntityJSON and a set of "core types".
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://json.schema.symphonyoss.org/structured-object-v0_1.json",
"title": "Symphony Structured Objects aka EntityJSON",
"coreTypes" : {
"org.symphonyoss.object.attribute.string": {
"description": "An unbounded Unicode string value.",
"type": "string"
},
"org.symphonyoss.object.attribute.int16": {
"description": "16 bit signed integer value.",
"type": "integer",
"minimum": -32768,
"maximum": 32767
},
"org.symphonyoss.object.attribute.int32": {
"description": "32 bit signed integer value.",
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
},
"org.symphonyoss.object.attribute.int54": {
"description": "54 bit signed integer value. This is the largest integer value which can be safely used in JavaScript",
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"org.symphonyoss.object.attribute.time.millis": {
"description": "Time in milliseconds from Jan 1st 1970 represented as a 54 bit signed integer value. This can represent dates up to the year 287396.",
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"org.symphonyoss.object.attribute.time.day": {
"description": "A date in the format YYYY-MM-DD. Intended for use when timezone precision is not required. Cases which require precision should use time.millis instead.",
"type": "string",
"pattern": "[0-9]{4}-((0[0-9])|1[0-2]))-(([0-2][0-9])|3[0-1]))"
},
"org.symphonyoss.object.attribute.time.month": {
"description": "A date in the format YYYY-MM. Intended for use when timezone precision is not required. Cases which require precision should use time.millis instead.",
"type": "string",
"pattern": "[0-9]{4}-((0[0-9])|1[0-2]))"
}
},
"definitions": {
"org.symphonyoss.object.attribute.type": {
"description": "An attribute type identifier.",
"type": "string",
"pattern": "(^[a-z]+(\\.[a-z]+)*$)|(^http://[a-z][a-z.]*$)"
},
"org.symphonyoss.object.id": {
"description": "An object type identifier.",
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/org.symphonyoss.object.attribute.type"
},
"value": {
"type": "string"
}
},
"required": [
"type",
"value"
],
"additionalProperties": false
}
},
"type": "object",
"properties": {
"$schema": {
"type": "string",
"format": "uri"
}
},
"patternProperties": {
"^\\$test-[a-zA-Z0-9_-]*$": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"org.symphonyoss.object.attribute.string": {
"$ref": "#/coreTypes/org.symphonyoss.object.attribute.string"
}
}
},
"^[a-zA-Z0-9].*$": {
"type": "object",
"description": "A Structured Object.",
"properties": {
"type": {
"description": "The identifier of the type of this object.",
"title": "Object Type",
"type": "string"
},
"version": {
"description": "The version of the type definition to which this object confirms.",
"title": "The type version",
"type": "string",
"pattern": "[0-9]+\\.[0-9]+"
},
"id": {
"description": "One or more identifiers for this object.",
"title": "The object Id",
"type": "array",
"items": {
"$ref": "#/definitions/org.symphonyoss.object.id"
}
}
},
"required": [
"type",
"version"
]
}
},
"additionalProperties": false
}
The following example includes some test values which are intended to fail validation.
{
"$schema": "http://json-schema.symphonyoss.org/object/draft-01/schema#",
"$test-ok":
{
"description": "good values",
"org.symphonyoss.object.attribute.string": "hello world!",
"org.symphonyoss.object.attribute.int32": 42
},
"$test-bad":
{
"description": "bad values",
"org.symphonyoss.object.attribute.string": 1,
"org.symphonyoss.object.attribute.int32": "42",
"org.symphonyoss.object.attribute.time.millis": "42"
"org.symphonyoss.object.attribute.time.day": "1992-21-90"
"org.symphonyoss.object.attribute.time.month": "1999-99"
},
"$test-too-big":
{
"description": "bad values",
"org.symphonyoss.object.attribute.string": 1,
"org.symphonyoss.object.attribute.int32": 2147483648
},
"badId":
{
"type": "org.symphonyoss.fin.security",
"version": "0.1",
"id":
[
{
"type": "org.symphonyoss.object.attribute.string",
"value": 22
},
{
"NOtype": "org.symphonyoss.fin.security.id.cusip",
"value": "037833100"
}
]
},
"apple":
{
"type": "org.symphonyoss.fin.security",
"version": "0.1",
"id":
[
{
"type": "org.symphonyoss.fin.security.id.isin",
"value": "US0378331005"
},
{
"type": "org.symphonyoss.fin.security.id.cusip",
"value": "037833100"
}
]
},
"jiraUpdated":
{
"type": "com.symphony.integration.jira.event.updated" ,
"version": "1.0",
"user":
{
"type": "com.symphony.integration.jira.user",
"version": "1.0",
"username": "test",
"emailAddress": "test@symphony.com",
"displayName": "Test User"
},
"labels":
[
"#production"
],
"issue":
{
"type": "com.symphony.integration.jira.issue",
"version": "1.0",
"project": "Sample 1",
"key": "SAM-24",
"subject": "Sample Bug Blocker",
"issueType": "Bug",
"link": "https://whiteam1.atlassian.net/browse/SAM-24",
"priority": "Highest",
"status": "Done",
"assignee":
{
"type": "com.symphony.integration.jira.user",
"version": "1.0",
"username": "test2",
"emailAddress": "test2@symphony.com",
"displayName": "Test2 User"
},
"changelog":
{
"type": "com.symphony.integration.jira.changelog",
"version": "1.0",
"change":
[
{
"type": "com.symphony.integration.jira.change",
"version": "1.0",
"fieldName": "resolution",
"oldValue": "null",
"newValue": "Done"
},
{
"type": "com.symphony.integration.jira.change",
"version": "1.0",
"fieldName": "status",
"oldValue": "To Do",
"newValue": "Done"
}
]
}
}
}
}
Need help? Email help@finos.org we'll get back to you.
Content on this page is licensed under the CC BY 4.0 license.
Code on this page is licensed under the Apache 2.0 license.