Guard against views that throw exceptions from __init__

openapi3 1.7.3
Cristi Vîjdea 2018-05-12 18:14:33 +03:00
parent 713c669e28
commit 23ebe2ff3e
2 changed files with 20 additions and 8 deletions

View File

@ -3,6 +3,15 @@ Changelog
#########
*********
**1.7.3**
*********
*Release date: May 12, 2018*
- **FIXED:** views whose ``__init__`` methods throw exceptions will now be ignored during endpoint enumeration
*********
**1.7.2**
*********

View File

@ -86,6 +86,7 @@ class EndpointEnumerator(_EndpointEnumerator):
for pattern in patterns:
path_regex = prefix + get_original_route(pattern)
if isinstance(pattern, URLPattern):
try:
path = self.get_path_from_regex(path_regex)
callback = pattern.callback
url_name = pattern.name
@ -94,6 +95,8 @@ class EndpointEnumerator(_EndpointEnumerator):
for method in self.get_allowed_methods(callback):
endpoint = (path, method, callback)
api_endpoints.append(endpoint)
except Exception:
logger.warning('failed to enumerate view', exc_info=True)
elif isinstance(pattern, URLResolver):
nested_endpoints = self.get_api_endpoints(