Write List in uppercase in OpenAPI

This commit is contained in:
Erwan Rouchet 2019-09-06 10:35:51 +02:00
parent 89ac0a1c7e
commit 799c7b1168
No known key found for this signature in database
GPG Key ID: FF629EE969FFE294
2 changed files with 4 additions and 4 deletions

View File

@ -111,7 +111,7 @@ class AutoSchema(ViewInspector):
"""
method_name = getattr(self.view, 'action', method.lower())
if is_list_view(path, method, self.view):
action = 'list'
action = 'List'
elif method_name not in self.method_mapping:
action = method_name
else:
@ -141,7 +141,7 @@ class AutoSchema(ViewInspector):
if name.endswith(action.title()): # ListView, UpdateAPIView, ThingDelete ...
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'
return action + name

View File

@ -80,7 +80,7 @@ class TestOperationIntrospection(TestCase):
operation = inspector.get_operation(path, method)
assert operation == {
'operationId': 'listExamples',
'operationId': 'ListExamples',
'parameters': [],
'responses': {
'200': {
@ -402,7 +402,7 @@ class TestOperationIntrospection(TestCase):
inspector.view = view
operationId = inspector._get_operation_id(path, method)
assert operationId == 'listExamples'
assert operationId == 'ListExamples'
def test_repeat_operation_ids(self):
router = routers.SimpleRouter()