      cls = getattr(callback, 'cls', None)
      return (cls is not None) and issubclass(cls, APIView)
  
  
  def insert_into(target, keys, item):
      """
      Insert `item` into the nested dictionary `target`.
  
      For example:
  
          target = {}
          insert_into(target, ('users', 'list'), Link(...))
          insert_into(target, ('users', 'detail'), Link(...))
          assert target == {'users': {'list': Link(...), 'detail': Link(...)}}
      """
      for key in keys[:1]:
          if key not in target:
              target[key] = {}
          target = target[key]
      target[keys[-1]] = item
  
  
  class SchemaGenerator(object):
      default_mapping = {
          'get': 'read',
          'post': 'create',
          'put': 'update',
 
</s> remove         if not link:
 </s> add         if not links: </s> remove         for key, link in links:
            insert_into(content, key, link)
 </s> add         for category, action, link in links:
            if category is None:
                content[action] = link
            elif category in content:
                content[category][action] = link
            else:
                content[category] = {action: link} </s> remove         category = None
        for item in path.strip('/').split('/'):
            if '{' in item:
                break
            category = item

 </s> add  </s> remove         # Generate the schema content structure, from the endpoints.
        # ('users', 'list'), Link -> {'users': {'list': Link()}}
 </s> add         # Generate the schema content structure, eg:
        # {'users': {'list': Link()}} </s> remove         action = actions[method.lower()]

        if category:
            return (category, action)
        return (action,)
 </s> add         return actions[method.lower()]

    def get_categories(self, paths):
        categories = set()
        split_paths = set([
            tuple(path.split("{")[0].strip('/').split('/'))
            for path in paths
        ])

        while split_paths:
            for split_path in list(split_paths):
                if len(split_path) == 0:
                    split_paths.remove(split_path)
                elif len(split_path) == 1:
                    categories.add(split_path[0])
                    split_paths.remove(split_path)
                elif split_path[0] in categories:
                    split_paths.remove(split_path)

        return categories

    def get_category(self, categories, path):
        path_components = path.split("{")[0].strip('/').split('/')
        for path_component in path_components:
            if path_component in categories:
                return path_component
        return None
      cls = getattr(callback, 'cls', None)
      return (cls is not None) and issubclass(cls, APIView)
  
  


















  class SchemaGenerator(object):
      default_mapping = {
          'get': 'read',
          'post': 'create',
          'put': 'update',
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Fix schema categories for custom list actions (#4386) 
rest_framework/schemas.py