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' 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