Skip to content

Commit 67549c3

Browse files
committed
Inline unnecessary method in OpenAPI schema generator.
1 parent 1389545 commit 67549c3

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

rest_framework/schemas/openapi.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,30 @@ def get_info(self):
3232

3333
return info
3434

35-
def get_paths(self, request=None):
36-
result = {}
35+
def get_schema(self, request=None, public=False):
36+
"""
37+
Generate a OpenAPI schema.
38+
"""
39+
self._initialise_endpoints()
3740

38-
_, view_endpoints = self._get_paths_and_endpoints(request)
41+
# Iterate endpoints generating per method path operations.
42+
# TODO: …and reference components.
43+
paths = {}
44+
_, view_endpoints = self._get_paths_and_endpoints(None if public else request)
3945
for path, method, view in view_endpoints:
4046
if not self.has_view_permissions(path, method, view):
4147
continue
48+
4249
operation = view.schema.get_operation(path, method)
4350
# Normalise path for any provided mount url.
4451
if path.startswith('/'):
4552
path = path[1:]
4653
path = urljoin(self.url or '/', path)
4754

48-
result.setdefault(path, {})
49-
result[path][method.lower()] = operation
50-
51-
return result
52-
53-
def get_schema(self, request=None, public=False):
54-
"""
55-
Generate a OpenAPI schema.
56-
"""
57-
self._initialise_endpoints()
55+
paths.setdefault(path, {})
56+
paths[path][method.lower()] = operation
5857

59-
paths = self.get_paths(None if public else request)
58+
# Compile final schema.
6059
schema = {
6160
'openapi': '3.0.2',
6261
'info': self.get_info(),

0 commit comments

Comments
 (0)