@@ -32,31 +32,30 @@ def get_info(self):
32
32
33
33
return info
34
34
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 ()
37
40
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 )
39
45
for path , method , view in view_endpoints :
40
46
if not self .has_view_permissions (path , method , view ):
41
47
continue
48
+
42
49
operation = view .schema .get_operation (path , method )
43
50
# Normalise path for any provided mount url.
44
51
if path .startswith ('/' ):
45
52
path = path [1 :]
46
53
path = urljoin (self .url or '/' , path )
47
54
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
58
57
59
- paths = self . get_paths ( None if public else request )
58
+ # Compile final schema.
60
59
schema = {
61
60
'openapi' : '3.0.2' ,
62
61
'info' : self .get_info (),
0 commit comments