From b85a92df83563e38b84340574cde2f9dc06b563c Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Thu, 25 Feb 2016 21:47:04 +0000 Subject: [PATCH 1/2] Exclude Endpoints with a parameter --- rest_framework_docs/api_docs.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rest_framework_docs/api_docs.py b/rest_framework_docs/api_docs.py index ce618b0..01e913d 100644 --- a/rest_framework_docs/api_docs.py +++ b/rest_framework_docs/api_docs.py @@ -20,13 +20,21 @@ def get_all_view_names(self, urlpatterns, parent_pattern=None): if isinstance(pattern, RegexURLResolver): parent_pattern = None if pattern._regex == "^" else pattern self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_pattern=parent_pattern) - elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern): + elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern) and not self._is_format_endpoint(pattern): api_endpoint = ApiEndpoint(pattern, parent_pattern) self.endpoints.append(api_endpoint) def _is_drf_view(self, pattern): - # Should check whether a pattern inherits from DRF's APIView + """ + Should check whether a pattern inherits from DRF's APIView + """ return hasattr(pattern.callback, 'cls') and issubclass(pattern.callback.cls, APIView) + def _is_format_endpoint(self, pattern): + """ + Exclude endpoints with a "format" parameter + """ + return '?P' in pattern._regex + def get_endpoints(self): return self.endpoints From bdef22acee958e4a1cf02eb5fab85d8d95714fd5 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Thu, 25 Feb 2016 21:56:22 +0000 Subject: [PATCH 2/2] Bump 0.0.7 --- rest_framework_docs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_docs/__init__.py b/rest_framework_docs/__init__.py index fa9c4ec..2792152 100644 --- a/rest_framework_docs/__init__.py +++ b/rest_framework_docs/__init__.py @@ -1 +1 @@ -__version__ = '0.0.6' +__version__ = '0.0.7'