mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Remove need for generator in get_description
This commit is contained in:
parent
61ce8bfe12
commit
f180397cb0
|
@ -288,7 +288,7 @@ class APIViewSchemaDescriptor(object):
|
||||||
else:
|
else:
|
||||||
encoding = None
|
encoding = None
|
||||||
|
|
||||||
description = self.get_description(path, method, generator)
|
description = self.get_description(path, method)
|
||||||
|
|
||||||
if generator.url and path.startswith('/'):
|
if generator.url and path.startswith('/'):
|
||||||
path = path[1:]
|
path = path[1:]
|
||||||
|
@ -301,7 +301,7 @@ class APIViewSchemaDescriptor(object):
|
||||||
description=description
|
description=description
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_description(self, path, method, generator):
|
def get_description(self, path, method):
|
||||||
"""
|
"""
|
||||||
Determine a link description.
|
Determine a link description.
|
||||||
|
|
||||||
|
@ -328,12 +328,16 @@ class APIViewSchemaDescriptor(object):
|
||||||
else:
|
else:
|
||||||
sections[current_section] += '\n' + line
|
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())
|
header = getattr(view, 'action', method.lower())
|
||||||
if header in sections:
|
if header in sections:
|
||||||
return sections[header].strip()
|
return sections[header].strip()
|
||||||
if header in generator.coerce_method_names:
|
if header in coerce_method_names:
|
||||||
if generator.coerce_method_names[header] in sections:
|
if coerce_method_names[header] in sections:
|
||||||
return sections[generator.coerce_method_names[header]].strip()
|
return sections[coerce_method_names[header]].strip()
|
||||||
return sections[''].strip()
|
return sections[''].strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user