From 5ce54822e27dbe3980d6895f9fc09c23c463778e Mon Sep 17 00:00:00 2001 From: peterfarrell Date: Mon, 19 Aug 2019 15:05:15 -0500 Subject: [PATCH] Fixes #6875 - OpenAPI Schema inconsistent operationId casing --- rest_framework/schemas/openapi.py | 4 ++-- tests/schemas/test_openapi.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 0af7510cdee..d9cf65a488b 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -111,7 +111,7 @@ def _get_operation_id(self, path, method): """ 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: @@ -138,7 +138,7 @@ def _get_operation_id(self, path, method): if name.endswith(action): # 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 diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index 78a5609dac4..3c6c77da68d 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -80,7 +80,7 @@ def test_path_without_parameters(self): operation = inspector.get_operation(path, method) assert operation == { - 'operationId': 'ListExamples', + 'operationId': 'listExamples', 'parameters': [], 'responses': { '200': { @@ -338,7 +338,7 @@ def test_operation_id_generation(self): 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()