          """
          Return a dictionary containing all the links that should be
          included in the API schema.
          """
          links = LinkNode()
  
          # Generate (path, method, view) given (path, method, callback).
          paths = []
          view_endpoints = []
          for path, method, callback in self.endpoints:
              view = self.create_view(callback, method, request)
              path = self.coerce_path(path, method, view)
 
</s> remove         Return a dictionary containing all the links that should be
        included in the API schema.
 </s> add         Generate (path, method, view) given (path, method, callback) for paths. </s> remove         # Only generate the path prefix for paths that will be included
        if not paths:
            return None
        prefix = self.determine_path_prefix(paths)
 </s> add         return paths, view_endpoints </s> remove         links = self.get_links(None if public else request)
        if not links:
            return None

        url = self.url
        if not url and request is not None:
            url = request.build_absolute_uri()

        distribute_links(links)
        return coreapi.Document(
            title=self.title, description=self.description,
            url=url, content=links
        )

    def get_links(self, request=None):
 </s> add     def _get_paths_and_endpoints(self, request): </s> remove         for path, method, view in view_endpoints:
            if not self.has_view_permissions(path, method, view):
                continue
            link = view.schema.get_link(path, method, base_url=self.url)
            subpath = path[len(prefix):]
            keys = self.get_keys(subpath, method, view)
            insert_into(links, keys, link)
 </s> add     def create_view(self, callback, method, request=None):
        """
        Given a callback, return an actual view instance.
        """
        view = callback.cls(**getattr(callback, 'initkwargs', {}))
        view.args = ()
        view.kwargs = {}
        view.format_kwarg = None
        view.request = None
        view.action_map = getattr(callback, 'actions', None) </s> remove         return links
 </s> add         actions = getattr(callback, 'actions', None)
        if actions is not None:
            if method == 'OPTIONS':
                view.action = 'metadata'
            else:
                view.action = actions.get(method.lower())

        if request is not None:
            view.request = clone_request(request, method)

        return view

    def coerce_path(self, path, method, view):
        """
        Coerce {pk} path arguments into the name of the model field,
        where possible. This is cleaner for an external representation.
        (Ie. "this is an identifier", not "this is a database primary key")
        """
        if not self.coerce_path_pk or '{pk}' not in path:
            return path
        model = getattr(getattr(view, 'queryset', None), 'model', None)
        if model:
            field_name = get_pk_name(model)
        else:
            field_name = 'id'
        return path.replace('{pk}', '{%s}' % field_name)
          """
          Return a dictionary containing all the links that should be
          included in the API schema.
          """



          paths = []
          view_endpoints = []
          for path, method, callback in self.endpoints:
              view = self.create_view(callback, method, request)
              path = self.coerce_path(path, method, view)
keep keep keep keep replace replace replace keep keep keep keep keep
 Added OpenAPI Schema Generation. (#6532)

Co-authored-by: Lucidiot <lucidiot@protonmail.com>
Co-authored-by: dongfangtianyu <dongfangtianyu@qq.com> 
rest_framework/schemas/generators.py