docs: def type_schema(
          type_name, inherits=None, rinherit=None,
          aliases=None, required=None, **props):
      """jsonschema generation helper
  
      params:
       - type_name: name of the type
       - inherits: list of document fragments that are required via anyOf[$ref]
       - rinherit: use another schema as a base for this, basically work around
                   inherits issues with additionalProperties and type enums.
       - aliases: additional names this type maybe called
       - required: list of required properties, by default 'type' is required
       - props: additional key value properties
      """
      if aliases:
          type_names = [type_name]
          type_names.extend(aliases)
      else:
          type_names = [type_name]
  
      if rinherit:
          s = copy.deepcopy(rinherit)
          s['properties']['type'] = {'enum': type_names}
      else:
          s = {
              'type': 'object',
              'properties': {
                  'type': {'enum': type_names}}}
  
      # Ref based inheritance and additional properties don't mix well.
      # https://stackoverflow.com/questions/22689900/json-schema-allof-with-additionalproperties
      if not inherits:
          s['additionalProperties'] = False
  
      s['properties'].update(props)
      if not required:
          required = []
      if isinstance(required, list):
          required.append('type')
      s['required'] = required
      if inherits:
          extended = s
          s = {'allOf': [{'$ref': i} for i in inherits]}
          s['allOf'].append(extended)
      return s