# ZeroMQ Plugin message format as [json-schema][1] (inspired by
# [IPython messaging format][2]).
#
# [1]: https://python-jsonschema.readthedocs.org/en/latest/
# [2]: http://jupyter-client.readthedocs.org/en/latest/messaging.html#messaging

MESSAGE_SCHEMA = {
    'definitions':
    {'header' :
     {'type': 'object',
      'properties':
      {'msg_id': {'type': 'string',
                  'description': 'Typically UUID, must be unique per message'},
       'session' : {'type': 'string',
                    'description':
                    'Typically UUID, should be unique per session'},
       'date': {'type': 'string',
                'description':
                'ISO 8601 timestamp for when the message is created'},
       'msg_type' : {'type': 'string',
                     'description':
                     'All recognized message type strings are listed below.'},
       'version' : {'type': 'string',
                    'default': '0.1',
                    'enum': ['0.1'],
                    'description': 'The message protocol version'}},
      'required': ['msg_id', 'session', 'date', 'msg_type', 'version']}},

    'type': 'object',
    'properties':
    {'header': {r'$ref': '#/definitions/header'},
     # In a chain of messages, the header from the parent is copied so that
     # clients can track where messages come from.
     'parent_header': {r'$ref': '#/definitions/header'},
     'metadata': {'type': 'object',
                  'description': 'Any metadata associated with the message.'},

     'content': {'type': 'object',
                 'description': 'The actual content of the message must be a '
                 'dict, whose structure depends on the message type.'}},
    'required': ['header', 'content']}

@@ -269,32 +269,103 @@
 initions':%0A    %7B
+'unique_id': %7B'type': 'string', 'description': 'Typically UUID'%7D,%0A     
 'header' :%0A     
@@ -418,38 +418,55 @@
 'msg_id': %7B'
-type': 'string
+$ref': '#/definitions/unique_id
 ',%0A         
@@ -480,32 +480,50 @@
   'description':
+%0A                 
  'Typically UUID
@@ -524,20 +524,22 @@
 y UUID, 
-must
+should
  be uniq
@@ -574,36 +574,55 @@
 ssion' :
+ 
  %7B'
-type': 'string
+$ref': '#/definitions/unique_id
 ',%0A
+ 
         
@@ -640,32 +640,33 @@
  'description':%0A
+ 
                 
@@ -1261,20 +1261,157 @@
 rsion'%5D%7D
-%7D
 ,%0A
-%0A
+     'base_message':%0A     %7B'description': 'ZeroMQ Plugin message format as json-schema (inspired '%0A      'by IPython messaging format)',%0A  
     'typ
@@ -1424,24 +1424,26 @@
 bject',%0A    
+  
 'properties'
@@ -1440,24 +1440,26 @@
 roperties':%0A
+  
     %7B'header
@@ -1454,33 +1454,32 @@
     %7B'header': %7B
-r
 '$ref': '#/defin
@@ -1491,24 +1491,26 @@
 s/header'%7D,%0A
+  
      # In a 
@@ -1578,16 +1578,18 @@
 at%0A     
+  
 # client
@@ -1626,16 +1626,18 @@
 e from.%0A
+  
      'pa
@@ -1651,17 +1651,16 @@
 ader': %7B
-r
 '$ref': 
@@ -1680,24 +1680,26 @@
 s/header'%7D,%0A
+  
      'metada
@@ -1732,32 +1732,34 @@
                 
+  
 'description': '
@@ -1804,16 +1804,18 @@
 ge.'%7D,%0A%0A
+  
      'co
@@ -1850,32 +1850,34 @@
                 
+  
 'description': '
@@ -1939,16 +1939,18 @@
         
+ 
+ 
 'dict, w
@@ -1997,24 +1997,26 @@
 pe.'%7D%7D,%0A    
+  
 'required': 
@@ -2037,9 +2037,67 @@
 ntent'%5D%7D
+%7D,%0A%0A    'allOf': %5B%7B'$ref': '#/definitions/base_message'%7D%5D%7D
 %0A

Refactor common base message in schema