  
          # Generate the schema content structure, from the endpoints.
          # ('users', 'list'), Link -> {'users': {'list': Link()}}
          content = {}
          for key, link in links:
              insert_into(content, key, link)
  
          # Return the schema document.
          return coreapi.Document(title=self.title, content=content, url=self.url)
  
      def get_api_endpoints(self, patterns, prefix=''):
 
</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         if not link:
 </s> add         if not links: </s> remove             links.append((key, link))
 </s> add             links.append((category, action, link)) </s> remove         return api_endpoints
 </s> add         return self.add_categories(api_endpoints)

    def add_categories(self, api_endpoints):
        """
        (path, method, action, callback) -> (path, method, category, action, callback)
        """
        # Determine the top level categories for the schema content,
        # based on the URLs of the endpoints. Eg `set(['users', 'organisations'])`
        paths = [endpoint[0] for endpoint in api_endpoints]
        categories = self.get_categories(paths)

        return [
            (path, method, self.get_category(categories, path), action, callback)
            for (path, method, action, callback) in api_endpoints
        ] </s> remove 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


 </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}
  
          # Generate the schema content structure, from the endpoints.
          # ('users', 'list'), Link -> {'users': {'list': Link()}}
          content = {}
        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}
        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}
  
          # Return the schema document.
          return coreapi.Document(title=self.title, content=content, url=self.url)
  
      def get_api_endpoints(self, patterns, prefix=''):
keep keep keep keep replace replace keep keep keep keep keep
 Fix schema categories for custom list actions (#4386) 
rest_framework/schemas.py