This commit is contained in:
William Sullivan 2017-09-14 08:45:18 +00:00 committed by GitHub
commit 6028f1e0c8

View File

@ -454,7 +454,10 @@ class SchemaGenerator(object):
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 @@ class SchemaGenerator(object):
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.