{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "Schema for the xAPI Statements endpoint",
    "getParameters": {
        "type": [
            "object",
            "array"
        ],
        "anyOf": [
            {
                "type": "array",
                "maxItems": 0
            },
            {
                "type": "object",
                "additionalProperties": false,
                "not": {
                    "anyOf": [
                        {
                            "required": [
                                "statementId",
                                "voidedStatementId"
                            ]
                        }
                    ]
                },
                "properties": {
                    "statementId": {
                        "$ref": "#/definitions/uuid"
                    },
                    "voidedStatementId": {
                        "$ref": "#/definitions/uuid"
                    },
                    "agent": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/agent"
                            },
                            {
                                "$ref": "#/definitions/group"
                            }
                        ]
                    },
                    "verb": {
                        "type": "string",
                        "format": "iri"
                    },
                    "activity": {
                        "type": "string",
                        "format": "iri"
                    },
                    "registration": {
                        "type": "string",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/uuid"
                            }
                        ]
                    },
                    "related_activities": {
                        "type": "boolean"
                    },
                    "related_agents": {
                        "type": "boolean"
                    },
                    "since": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "until": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "until_id": {
                        "type": "string"
                    },
                    "since_id": {
                        "type": "string"
                    },
                    "limit": {
                        "type": "number",
                        "minimum": 0
                    },
                    "format": {
                        "enum": [
                            "ids",
                            "exact",
                            "canonical"
                        ]
                    },
                    "attachments": {
                        "type": "boolean"
                    },
                    "ascending": {
                        "type": "boolean"
                    }
                }
            }
        ]
    },
    "postBody": {
        "type": [
            "object",
            "array"
        ],
        "oneOf": [
            {
                "$ref": "#/definitions/statement"
            },
            {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/statement"
                }
            }
        ]
    },
    "putParameters": {
        "type": [
            "object",
            "array"
        ],
        "required": [
            "statementId"
        ],
        "properties": {
            "statementId": {
                "$ref": "#/definitions/uuid"
            }
        }
    },
    "putBody": {
        "type": "object",
        "oneOf": [
            {
                "$ref": "#/definitions/statement"
            }
        ]
    },
    "definitions": {
        "statement": {
            "type": "object",
            "required": [
                "actor",
                "verb",
                "object"
            ],
            "properties": {
                "id": {
                    "$ref": "#/definitions/uuid"
                },
                "version": {
                    "type": "string",
                    "enum": [
                        "1.0.0"
                    ]
                },
                "actor": {
                    "type": "object",
                    "oneOf": [
                        {
                            "$ref": "#/definitions/agent"
                        },
                        {
                            "$ref": "#/definitions/group"
                        }
                    ]
                },
                "verb": {
                    "type": "object",
                    "required": [
                        "id"
                    ],
                    "properties": {
                        "id": {
                            "type": "string",
                            "format": "iri"
                        },
                        "display": {
                            "$ref": "#/definitions/languagemap"
                        }
                    },
                    "additionalProperties": false
                },
                "object": {
                    "type": "object",
                    "oneOf": [
                        {
                            "$ref": "#/definitions/activity"
                        },
                        {
                            "$ref": "#/definitions/objectagent"
                        },
                        {
                            "$ref": "#/definitions/group"
                        },
                        {
                            "$ref": "#/definitions/statementref"
                        },
                        {
                            "$ref": "#/definitions/substatement"
                        }
                    ]
                },
                "objectType": {},
                "result": {
                    "type": "object",
                    "properties": {
                        "score": {
                            "type": "object",
                            "properties": {
                                "scaled": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 1
                                },
                                "raw": {
                                    "type": "number"
                                },
                                "min": {
                                    "type": "number"
                                },
                                "max": {
                                    "type": "number"
                                }
                            }
                        },
                        "success": {
                            "type": "boolean"
                        },
                        "completion": {
                            "type": "boolean"
                        },
                        "response": {
                            "type": "string"
                        },
                        "duration": {
                            "type": "string"
                        },
                        "extensions": {
                            "$ref": "#/definitions/extensions"
                        }
                    },
                    "additionalProperties": false
                },
                "context": {
                    "type": "object",
                    "properties": {
                        "registration": {
                            "type": "string",
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/uuid"
                                }
                            ]
                        },
                        "instructor": {
                            "type": "object",
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/agent"
                                },
                                {
                                    "$ref": "#/definitions/group"
                                }
                            ]
                        },
                        "team": {
                            "type": "object",
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/agent"
                                },
                                {
                                    "$ref": "#/definitions/group"
                                }
                            ]
                        },
                        "contextActivities": {
                            "type": "object",
                            "properties": {
                                "parent": {
                                    "type": [
                                        "object",
                                        "array"
                                    ],
                                    "oneOf": [
                                        {
                                            "$ref": "#/definitions/activity"
                                        },
                                        {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/activity"
                                            }
                                        }
                                    ]
                                },
                                "grouping": {
                                    "type": [
                                        "object",
                                        "array"
                                    ],
                                    "oneOf": [
                                        {
                                            "$ref": "#/definitions/activity"
                                        },
                                        {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/activity"
                                            }
                                        }
                                    ]
                                },
                                "category": {
                                    "type": [
                                        "object",
                                        "array"
                                    ],
                                    "oneOf": [
                                        {
                                            "$ref": "#/definitions/activity"
                                        },
                                        {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/activity"
                                            }
                                        }
                                    ]
                                },
                                "other": {
                                    "type": [
                                        "object",
                                        "array"
                                    ],
                                    "oneOf": [
                                        {
                                            "$ref": "#/definitions/activity"
                                        },
                                        {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/activity"
                                            }
                                        }
                                    ]
                                }
                            },
                            "additionalProperties": false
                        },
                        "revision": {
                            "type": "string"
                        },
                        "platform": {
                            "type": "string"
                        },
                        "language": {
                            "type": "string"
                        },
                        "statement": {
                            "$ref": "#/definitions/statementref"
                        },
                        "extensions": {
                            "$ref": "#/definitions/extensions"
                        }
                    },
                    "additionalProperties": false
                },
                "timestamp": {
                    "type": "string"
                },
                "stored": {
                    "type": "string"
                },
                "authority": {
                    "type": "object",
                    "oneOf": [
                        {
                            "$ref": "#/definitions/agent"
                        },
                        {
                            "type": "object",
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/anonymousgroup"
                                }
                            ],
                            "properties": {
                                "member": {
                                    "type": "array",
                                    "minItems": 2,
                                    "maxItems": 2
                                }
                            }
                        }
                    ]
                },
                "voided": {
                    "type": "boolean"
                },
                "attachments": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/attachment"
                    }
                }
            },
            "additionalProperties": false
        },
        "statementref": {
            "type": "object",
            "required": [
                "objectType",
                "id"
            ],
            "properties": {
                "objectType": {
                    "enum": [
                        "StatementRef"
                    ]
                },
                "id": {
                    "$ref": "#/definitions/uuid"
                }
            },
            "additionalProperties": false
        },
        "substatement": {
            "type": "object",
            "oneOf": [
                {
                    "$ref": "#/definitions/statement"
                }
            ],
            "required": [
                "objectType"
            ],
            "properties": {
                "objectType": {
                    "enum": [
                        "SubStatement"
                    ]
                },
                "object": {
                    "type": "object",
                    "properties": {
                        "objectType": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "type": "string",
                                    "enum": [
                                        "Activity",
                                        "Agent",
                                        "Group",
                                        "StatementRef"
                                    ]
                                }
                            ]
                        }
                    }
                }
            },
            "patternProperties": {
                "^(id|stored|authority|voided|version)$": {
                    "type": "null"
                }
            }
        },
        "activity": {
            "type": "object",
            "required": [
                "id"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "format": "iri"
                },
                "objectType": {
                    "enum": [
                        "Activity"
                    ]
                },
                "definition": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "$ref": "#/definitions/languagemap"
                        },
                        "description": {
                            "$ref": "#/definitions/languagemap"
                        },
                        "type": {
                            "type": "string",
                            "format": "iri"
                        },
                        "moreInfo": {
                            "type": "string",
                            "format": "uri"
                        },
                        "interactionType": {
                            "enum": [
                                "true-false",
                                "choice",
                                "fill-in",
                                "long-fill-in",
                                "matching",
                                "performance",
                                "sequencing",
                                "likert",
                                "numeric",
                                "other"
                            ]
                        },
                        "correctResponsesPattern": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "extensions": {
                            "$ref": "#/definitions/extensions"
                        }
                    },
                    "patternProperties": {
                        "^(choices|scale|source|target|steps)$": {
                            "type": [
                                "object",
                                "array"
                            ],
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/interaction"
                                },
                                {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/definitions/interaction"
                                    }
                                }
                            ]
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "extensions": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z][a-zA-Z+.-]*:": {}
            },
            "additionalProperties": false
        },
        "languagemap": {
            "type": "object",
            "patternProperties": {
                "^(([a-zA-Z]{2,8}((-[a-zA-Z]{3}){0,3})(-[a-zA-Z]{4})?((-[a-zA-Z]{2})|(-\\d{3}))?(-[a-zA-Z\\d]{4,8})*(-[a-zA-Z\\d](-[a-zA-Z\\d]{1,8})+)*)|x(-[a-zA-Z\\d]{1,8})+|en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tsu|i-tay|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)$": {
                    "type": "string"
                }
            },
            "additionalProperties": false
        },
        "mbox": {
            "type": "object",
            "required": [
                "mbox"
            ],
            "properties": {
                "mbox": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^mailto:"
                }
            },
            "patternProperties": {
                "^(mbox_sha1sum|account|openid)$": {
                    "type": "null"
                }
            }
        },
        "mbox_sha1sum": {
            "type": "object",
            "required": [
                "mbox_sha1sum"
            ],
            "properties": {
                "mbox_sha1sum": {
                    "type": "string",
                    "pattern": "^[a-fA-F0-9]{40}$"
                }
            },
            "patternProperties": {
                "^(mbox|account|openid)$": {
                    "type": "null"
                }
            }
        },
        "account": {
            "type": "object",
            "required": [
                "account"
            ],
            "properties": {
                "account": {
                    "type": "object",
                    "required": [
                        "homePage",
                        "name"
                    ],
                    "properties": {
                        "homePage": {
                            "type": "string",
                            "format": "uri"
                        },
                        "name": {
                            "type": "string"
                        }
                    },
                    "additionalProperties": false
                }
            },
            "patternProperties": {
                "^(mbox_sha1sum|mbox|openid)$": {
                    "type": "null"
                }
            }
        },
        "openid": {
            "type": "object",
            "required": [
                "openid"
            ],
            "properties": {
                "openid": {
                    "type": "string",
                    "format": "uri"
                }
            },
            "patternProperties": {
                "^(mbox_sha1sum|account|mbox)$": {
                    "type": "null"
                }
            }
        },
        "inversefunctional": {
            "type": "object",
            "oneOf": [
                {
                    "$ref": "#/definitions/mbox"
                },
                {
                    "$ref": "#/definitions/mbox_sha1sum"
                },
                {
                    "$ref": "#/definitions/account"
                },
                {
                    "$ref": "#/definitions/openid"
                }
            ]
        },
        "objectagent": {
            "type": "object",
            "oneOf": [
                {
                    "$ref": "#/definitions/agent"
                }
            ],
            "required": [
                "objectType"
            ],
            "properties": {
                "objectType": {
                    "type": "string"
                }
            }
        },
        "agent": {
            "type": "object",
            "allOf": [
                {
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "objectType": {
                            "enum": [
                                "Agent"
                            ]
                        },
                        "mbox": {},
                        "mbox_sha1sum": {},
                        "account": {},
                        "openid": {}
                    },
                    "additionalProperties": false
                },
                {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/mbox"
                        },
                        {
                            "$ref": "#/definitions/mbox_sha1sum"
                        },
                        {
                            "$ref": "#/definitions/account"
                        },
                        {
                            "$ref": "#/definitions/openid"
                        }
                    ],
                    "additionalProperties": true
                }
            ]
        },
        "group": {
            "type": "object",
            "oneOf": [
                {
                    "$ref": "#/definitions/anonymousgroup"
                },
                {
                    "$ref": "#/definitions/identifiedgroup"
                }
            ]
        },
        "anonymousgroup": {
            "required": [
                "objectType",
                "member"
            ],
            "properties": {
                "name": {
                    "type": "string"
                },
                "objectType": {
                    "enum": [
                        "Group"
                    ]
                },
                "member": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "$ref": "#/definitions/agent"
                    }
                }
            },
            "additionalProperties": false
        },
        "identifiedgroup": {
            "required": [
                "objectType"
            ],
            "allOf": [
                {
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "objectType": {
                            "enum": [
                                "Group"
                            ]
                        },
                        "member": {
                            "type": "array",
                            "minItems": 1,
                            "items": {
                                "$ref": "#/definitions/agent"
                            }
                        },
                        "mbox": {},
                        "mbox_sha1sum": {},
                        "account": {},
                        "openid": {}
                    },
                    "additionalProperties": false
                },
                {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/mbox"
                        },
                        {
                            "$ref": "#/definitions/mbox_sha1sum"
                        },
                        {
                            "$ref": "#/definitions/account"
                        },
                        {
                            "$ref": "#/definitions/openid"
                        }
                    ],
                    "additionalProperties": true
                }
            ]
        },
        "uuid": {
            "type": "string",
            "format": "uuid"
        },
        "attachment": {
            "type": "object",
            "required": [
                "usageType",
                "display",
                "contentType",
                "length",
                "sha2"
            ],
            "properties": {
                "usageType": {
                    "type": "string",
                    "format": "iri"
                },
                "display": {
                    "$ref": "#/definitions/languagemap"
                },
                "description": {
                    "$ref": "#/definitions/languagemap"
                },
                "contentType": {
                    "type": "string"
                },
                "length": {
                    "type": "number",
                    "minimum": 0
                },
                "sha2": {
                    "type": "string"
                },
                "fileUrl": {
                    "type": "string",
                    "format": "uri"
                }
            }
        },
        "interaction": {
            "type": "object",
            "required": [
                "id"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "description": {
                    "$ref": "#/definitions/languagemap"
                }
            },
            "additionalProperties": false
        }
    },
    "properties": {
        "getParameters": {
            "$ref": "#/getParameters"
        },
        "postBody": {
            "$ref": "#/postBody"
        },
        "putParameters": {
            "$ref": "#/putParameters"
        },
        "putBody": {
            "$ref": "#/putBody"
        },
        "statement": {
            "$ref": "#/definitions/statement"
        },
        "statementref": {
            "$ref": "#/definitions/statementref"
        },
        "substatement": {
            "$ref": "#/definitions/substatement"
        },
        "activity": {
            "$ref": "#/definitions/activity"
        },
        "extensions": {
            "$ref": "#/definitions/extensions"
        },
        "languagemap": {
            "$ref": "#/definitions/languagemap"
        },
        "mbox": {
            "$ref": "#/definitions/mbox"
        },
        "mbox_sha1sum": {
            "$ref": "#/definitions/mbox_sha1sum"
        },
        "account": {
            "$ref": "#/definitions/account"
        },
        "openid": {
            "$ref": "#/definitions/openid"
        },
        "inversefunctional": {
            "$ref": "#/definitions/inversefunctional"
        },
        "objectagent": {
            "$ref": "#/definitions/objectagent"
        },
        "agent": {
            "$ref": "#/definitions/agent"
        },
        "group": {
            "$ref": "#/definitions/group"
        },
        "anonymousgroup": {
            "$ref": "#/definitions/anonymousgroup"
        },
        "identifiedgroup": {
            "$ref": "#/definitions/identifiedgroup"
        },
        "uuid": {
            "$ref": "#/definitions/uuid"
        },
        "attachment": {
            "$ref": "#/definitions/attachment"
        },
        "interaction": {
            "$ref": "#/definitions/interaction"
        }
    },
    "required": [
        "getParameters",
        "postBody",
        "putParameters",
        "putBody",
        "statement",
        "statementref",
        "substatement",
        "activity",
        "extensions",
        "languagemap",
        "mbox",
        "mbox_sha1sum",
        "account",
        "openid",
        "inversefunctional",
        "objectagent",
        "agent",
        "group",
        "anonymousgroup",
        "identifiedgroup",
        "uuid",
        "attachment",
        "interaction"
    ]
}