From 56178ed2a47f1010a4f35d7587ff9d62710b1545 Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Wed, 19 Feb 2020 01:37:06 +0530 Subject: [PATCH] remove support for dict tags --- rest_framework/schemas/openapi.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index a577fe26c..b4aa658e5 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -44,8 +44,6 @@ class SchemaGenerator(BaseSchemaGenerator): # Iterate endpoints generating per method path operations. # TODO: …and reference components. paths = {} - tags = [] - processed_views_for_tags = set() _, view_endpoints = self._get_paths_and_endpoints(None if public else request) for path, method, view in view_endpoints: if not self.has_view_permissions(path, method, view): @@ -60,16 +58,11 @@ class SchemaGenerator(BaseSchemaGenerator): paths.setdefault(path, {}) paths[path][method.lower()] = operation - if view.__class__.__name__ not in processed_views_for_tags: - tags.extend(view.schema.get_tag_objects()) - processed_views_for_tags.add(view.__class__.__name__) - # Compile final schema. schema = { 'openapi': '3.0.2', 'info': self.get_info(), 'paths': paths, - 'tags': tags } return schema @@ -80,10 +73,9 @@ class SchemaGenerator(BaseSchemaGenerator): class AutoSchema(ViewInspector): def __init__(self, tags=None): - if tags is None: - tags = [] - self._tag_objects = list(filter(lambda tag: isinstance(tag, (dict, OrderedDict)), tags)) - self._tags = list(map(lambda tag: tag['name'] if isinstance(tag, (dict, OrderedDict)) else tag, tags)) + if tags and not all(isinstance(tag, str) for tag in tags): + raise ValueError('tags must be a list of string.') + self._tags = tags super().__init__() request_media_types = [] @@ -117,9 +109,6 @@ class AutoSchema(ViewInspector): return operation - def get_tag_objects(self): - return self._tag_objects - def _get_operation_id(self, path, method): """ Compute an operation ID from the model, serializer or view name.