mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Inline unnecessary method in OpenAPI schema generator.
This commit is contained in:
parent
3b88312c33
commit
496947be3a
|
@ -32,31 +32,30 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def get_paths(self, request=None):
|
|
||||||
result = {}
|
|
||||||
|
|
||||||
_, view_endpoints = self._get_paths_and_endpoints(request)
|
|
||||||
for path, method, view in view_endpoints:
|
|
||||||
if not self.has_view_permissions(path, method, view):
|
|
||||||
continue
|
|
||||||
operation = view.schema.get_operation(path, method)
|
|
||||||
# Normalise path for any provided mount url.
|
|
||||||
if path.startswith('/'):
|
|
||||||
path = path[1:]
|
|
||||||
path = urljoin(self.url or '/', path)
|
|
||||||
|
|
||||||
result.setdefault(path, {})
|
|
||||||
result[path][method.lower()] = operation
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_schema(self, request=None, public=False):
|
def get_schema(self, request=None, public=False):
|
||||||
"""
|
"""
|
||||||
Generate a OpenAPI schema.
|
Generate a OpenAPI schema.
|
||||||
"""
|
"""
|
||||||
self._initialise_endpoints()
|
self._initialise_endpoints()
|
||||||
|
|
||||||
paths = self.get_paths(None if public else request)
|
# Iterate endpoints generating per method path operations.
|
||||||
|
# TODO: …and reference components.
|
||||||
|
paths = {}
|
||||||
|
_, 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):
|
||||||
|
continue
|
||||||
|
|
||||||
|
operation = view.schema.get_operation(path, method)
|
||||||
|
# Normalise path for any provided mount url.
|
||||||
|
if path.startswith('/'):
|
||||||
|
path = path[1:]
|
||||||
|
path = urljoin(self.url or '/', path)
|
||||||
|
|
||||||
|
paths.setdefault(path, {})
|
||||||
|
paths[path][method.lower()] = operation
|
||||||
|
|
||||||
|
# Compile final schema.
|
||||||
schema = {
|
schema = {
|
||||||
'openapi': '3.0.2',
|
'openapi': '3.0.2',
|
||||||
'info': self.get_info(),
|
'info': self.get_info(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user