Skip to content

Commit 3e54ed0

Browse files
authored
First step to fix nested urls.py files.
This patch accumulates parent_regexps with the current one, but changes the ABI, so there's a second patch to come to fix `ApiEndpoint`
1 parent eef7e1b commit 3e54ed0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rest_framework_docs/api_docs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def __init__(self, drf_router=None):
2121
else:
2222
self.get_all_view_names(root_urlconf.urlpatterns)
2323

24-
def get_all_view_names(self, urlpatterns, parent_pattern=None):
24+
def get_all_view_names(self, urlpatterns, parent_regex=None):
2525
for pattern in urlpatterns:
2626
if isinstance(pattern, RegexURLResolver):
27-
parent_pattern = None if pattern._regex == "^" else pattern
28-
self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_pattern=parent_pattern)
27+
regex = '' if pattern._regex == "^" else pattern._regex
28+
self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_regex=parent_regex+regex)
2929
elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern) and not self._is_format_endpoint(pattern):
30-
api_endpoint = ApiEndpoint(pattern, parent_pattern, self.drf_router)
30+
api_endpoint = ApiEndpoint(pattern, parent_regex, self.drf_router)
3131
self.endpoints.append(api_endpoint)
3232

3333
def _is_drf_view(self, pattern):

0 commit comments

Comments
 (0)