diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index 875f9454b3..7106afc414 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -454,7 +454,10 @@ def get_link(self, path, method, view): if self.url and path.startswith('/'): path = path[1:] + title = self.get_title(view) + return coreapi.Link( + title=title, url=urlparse.urljoin(self.url, path), action=method.lower(), encoding=encoding, @@ -462,6 +465,14 @@ def get_link(self, path, method, view): description=description ) + def get_title(self, view): + """ + Determine a title from a view instance. + + If the 'title' attribute is not set on the view, then an empty title is returned. + """ + return getattr(view, 'title', '') + def get_description(self, path, method, view): """ Determine a link description.