mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
remove support for dict tags
This commit is contained in:
parent
31a1eb14eb
commit
56178ed2a4
|
@ -44,8 +44,6 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
# Iterate endpoints generating per method path operations.
|
# Iterate endpoints generating per method path operations.
|
||||||
# TODO: …and reference components.
|
# TODO: …and reference components.
|
||||||
paths = {}
|
paths = {}
|
||||||
tags = []
|
|
||||||
processed_views_for_tags = set()
|
|
||||||
_, view_endpoints = self._get_paths_and_endpoints(None if public else request)
|
_, view_endpoints = self._get_paths_and_endpoints(None if public else request)
|
||||||
for path, method, view in view_endpoints:
|
for path, method, view in view_endpoints:
|
||||||
if not self.has_view_permissions(path, method, view):
|
if not self.has_view_permissions(path, method, view):
|
||||||
|
@ -60,16 +58,11 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
paths.setdefault(path, {})
|
paths.setdefault(path, {})
|
||||||
paths[path][method.lower()] = operation
|
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.
|
# Compile final schema.
|
||||||
schema = {
|
schema = {
|
||||||
'openapi': '3.0.2',
|
'openapi': '3.0.2',
|
||||||
'info': self.get_info(),
|
'info': self.get_info(),
|
||||||
'paths': paths,
|
'paths': paths,
|
||||||
'tags': tags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema
|
return schema
|
||||||
|
@ -80,10 +73,9 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
class AutoSchema(ViewInspector):
|
class AutoSchema(ViewInspector):
|
||||||
|
|
||||||
def __init__(self, tags=None):
|
def __init__(self, tags=None):
|
||||||
if tags is None:
|
if tags and not all(isinstance(tag, str) for tag in tags):
|
||||||
tags = []
|
raise ValueError('tags must be a list of string.')
|
||||||
self._tag_objects = list(filter(lambda tag: isinstance(tag, (dict, OrderedDict)), tags))
|
self._tags = tags
|
||||||
self._tags = list(map(lambda tag: tag['name'] if isinstance(tag, (dict, OrderedDict)) else tag, tags))
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
request_media_types = []
|
request_media_types = []
|
||||||
|
@ -117,9 +109,6 @@ class AutoSchema(ViewInspector):
|
||||||
|
|
||||||
return operation
|
return operation
|
||||||
|
|
||||||
def get_tag_objects(self):
|
|
||||||
return self._tag_objects
|
|
||||||
|
|
||||||
def _get_operation_id(self, path, method):
|
def _get_operation_id(self, path, method):
|
||||||
"""
|
"""
|
||||||
Compute an operation ID from the model, serializer or view name.
|
Compute an operation ID from the model, serializer or view name.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user