mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00: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]
|
operation['tags'] = [tag]
|
||||||
return operation
|
return operation
|
||||||
|
|
||||||
def get_paths(self, document):
|
def get_paths(self, document, tag=None):
|
||||||
paths = {}
|
paths = {}
|
||||||
|
|
||||||
tag = None
|
|
||||||
for name, link in document.links.items():
|
for name, link in document.links.items():
|
||||||
path = urlparse.urlparse(link.url).path
|
path = urlparse.urlparse(link.url).path
|
||||||
method = link.action.lower()
|
method = link.action.lower()
|
||||||
|
@ -1000,11 +999,7 @@ class _BaseOpenAPIRenderer:
|
||||||
paths[path][method] = self.get_operation(link, name, tag=tag)
|
paths[path][method] = self.get_operation(link, name, tag=tag)
|
||||||
|
|
||||||
for tag, section in document.data.items():
|
for tag, section in document.data.items():
|
||||||
for name, link in section.links.items():
|
paths.update(self.get_paths(section, tag))
|
||||||
path = urlparse.urlparse(link.url).path
|
|
||||||
method = link.action.lower()
|
|
||||||
paths.setdefault(path, {})
|
|
||||||
paths[path][method] = self.get_operation(link, name, tag=tag)
|
|
||||||
|
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user