Create JSON Schema for Base Message

This commit is contained in:
ChronosX88 2019-11-22 22:37:09 +04:00
parent 3b6e26f96c
commit 3592f10bb9

View File

@ -0,0 +1,75 @@
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/root.json",
"type": "object",
"title": "Base Message Schema",
"required": [
"id",
"type",
"from",
"to",
"payload"
],
"additionalProperties": false,
"properties": {
"id": {
"$id": "#/properties/id",
"type": "string",
"title": "id",
"description": "Message identifier (used to track the request-response chain)",
"examples": [
"abcd"
],
"pattern": "^(.*)$"
},
"type": {
"$id": "#/properties/type",
"type": "string",
"title": "type",
"description": "Type of message (used to determine which extension this message belongs to)",
"examples": [
"profile:register",
"profile:login",
"incorrectMessageType:error"
],
"pattern": "^(.*)$"
},
"from": {
"$id": "#/properties/from",
"type": "string",
"title": "from",
"description": "From which entity this message is send. May be set to \"anonymous\" value, if action doesn't require authorization. This is EntityID",
"examples": [
"396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf",
"@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf",
"#chpok@b9966d89028b120145dad38961bed0b3b2eac0a2915c0bb1665ffcc1586f6f59",
"anonymous"
],
"pattern": "^(.*)$"
},
"to": {
"$id": "#/properties/to",
"type": "string",
"title": "to",
"description": "Message recipient. This is Entity ID.",
"examples": [
"@juliet@02a6f23250868e903ff62e99e664a5717e945ca8153bf0ebc4f505cbe3a0860c",
"#white_house_garden@8baef2426dc6a92e16d39d79d90ae6d5a0080aaeccc5f02f1e83a959bc4d0be7",
"%phone:1234567890@6dfea40d98f71b3191f94c31af887a00eaeef2fe3501226e3fbb302fc5269eec",
"@romeo@cadmium.im"
],
"pattern": "^(.*)$"
},
"payload": {
"$id": "#/properties/payload",
"type": "object",
"title": "payload",
"description": "Message payload (used to store extra information in message, list of permissible fields in the payload depends on \"type\" field)",
"patternProperties": {
"^(.*)$": {}
}
}
}
}