mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
This commit is contained in:
parent
1cc4be47b4
commit
b3f032fb8f
|
@ -111,7 +111,7 @@ class AutoSchema(ViewInspector):
|
||||||
"""
|
"""
|
||||||
method_name = getattr(self.view, 'action', method.lower())
|
method_name = getattr(self.view, 'action', method.lower())
|
||||||
if is_list_view(path, method, self.view):
|
if is_list_view(path, method, self.view):
|
||||||
action = 'List'
|
action = 'list'
|
||||||
elif method_name not in self.method_mapping:
|
elif method_name not in self.method_mapping:
|
||||||
action = method_name
|
action = method_name
|
||||||
else:
|
else:
|
||||||
|
@ -135,10 +135,13 @@ class AutoSchema(ViewInspector):
|
||||||
name = name[:-7]
|
name = name[:-7]
|
||||||
elif name.endswith('View'):
|
elif name.endswith('View'):
|
||||||
name = name[:-4]
|
name = name[:-4]
|
||||||
if name.endswith(action): # ListView, UpdateAPIView, ThingDelete ...
|
|
||||||
|
# Due to camel-casing of classes and `action` being lowercase, apply title in order to find if action truly
|
||||||
|
# comes at the end of the name
|
||||||
|
if name.endswith(action.title()): # ListView, UpdateAPIView, ThingDelete ...
|
||||||
name = name[:-len(action)]
|
name = name[:-len(action)]
|
||||||
|
|
||||||
if action == 'List' and not name.endswith('s'): # ListThings instead of ListThing
|
if action == 'list' and not name.endswith('s'): # listThings instead of listThing
|
||||||
name += 's'
|
name += 's'
|
||||||
|
|
||||||
return action + name
|
return action + name
|
||||||
|
|
|
@ -80,7 +80,7 @@ class TestOperationIntrospection(TestCase):
|
||||||
|
|
||||||
operation = inspector.get_operation(path, method)
|
operation = inspector.get_operation(path, method)
|
||||||
assert operation == {
|
assert operation == {
|
||||||
'operationId': 'ListExamples',
|
'operationId': 'listExamples',
|
||||||
'parameters': [],
|
'parameters': [],
|
||||||
'responses': {
|
'responses': {
|
||||||
'200': {
|
'200': {
|
||||||
|
@ -402,7 +402,7 @@ class TestOperationIntrospection(TestCase):
|
||||||
inspector.view = view
|
inspector.view = view
|
||||||
|
|
||||||
operationId = inspector._get_operation_id(path, method)
|
operationId = inspector._get_operation_id(path, method)
|
||||||
assert operationId == 'ListExamples'
|
assert operationId == 'listExamples'
|
||||||
|
|
||||||
def test_repeat_operation_ids(self):
|
def test_repeat_operation_ids(self):
|
||||||
router = routers.SimpleRouter()
|
router = routers.SimpleRouter()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user