From f180397cb0135727ed6925c579c12c9f5fdebea8 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 23 Aug 2017 10:53:30 +0200 Subject: [PATCH] Remove need for generator in get_description --- rest_framework/schemas.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index 127a345fc..204343076 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -288,7 +288,7 @@ class APIViewSchemaDescriptor(object): else: encoding = None - description = self.get_description(path, method, generator) + description = self.get_description(path, method) if generator.url and path.startswith('/'): path = path[1:] @@ -301,7 +301,7 @@ class APIViewSchemaDescriptor(object): description=description ) - def get_description(self, path, method, generator): + def get_description(self, path, method): """ Determine a link description. @@ -328,12 +328,16 @@ class APIViewSchemaDescriptor(object): else: sections[current_section] += '\n' + line + # TODO: coerce_method_names is used both here and by SchemaGenerator in + # get_keys. It is read straight from the setting (i.e. it's not dynamic.) + # ???: Can it be a module level constant (or callable)? + coerce_method_names = api_settings.SCHEMA_COERCE_METHOD_NAMES header = getattr(view, 'action', method.lower()) if header in sections: return sections[header].strip() - if header in generator.coerce_method_names: - if generator.coerce_method_names[header] in sections: - return sections[generator.coerce_method_names[header]].strip() + if header in coerce_method_names: + if coerce_method_names[header] in sections: + return sections[coerce_method_names[header]].strip() return sections[''].strip()