mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
renderer: Handle deeper nesting
Deeper nesting, such as nesting under and API version, breaks the openapi renderer. Resolve this by recursively parsing the nested sections in the coreapi document. Signed-off-by: Stephen Finucane <stephen@that.guru>
This commit is contained in:
parent
9d001cd84c
commit
06f1d0114a
|
@ -989,10 +989,9 @@ class _BaseOpenAPIRenderer:
|
|||
operation['tags'] = [tag]
|
||||
return operation
|
||||
|
||||
def get_paths(self, document):
|
||||
def get_paths(self, document, tag=None):
|
||||
paths = {}
|
||||
|
||||
tag = None
|
||||
for name, link in document.links.items():
|
||||
path = urlparse.urlparse(link.url).path
|
||||
method = link.action.lower()
|
||||
|
@ -1000,11 +999,7 @@ class _BaseOpenAPIRenderer:
|
|||
paths[path][method] = self.get_operation(link, name, tag=tag)
|
||||
|
||||
for tag, section in document.data.items():
|
||||
for name, link in section.links.items():
|
||||
path = urlparse.urlparse(link.url).path
|
||||
method = link.action.lower()
|
||||
paths.setdefault(path, {})
|
||||
paths[path][method] = self.get_operation(link, name, tag=tag)
|
||||
paths.update(self.get_paths(section, tag))
|
||||
|
||||
return paths
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user