Log regex compilation failure in find_regex

Closes #193.
This commit is contained in:
Cristi Vîjdea
2018-09-09 22:33:13 +03:00
parent 3ac6c9ec3a
commit c5c40e31c4
+6 -1
View File
@@ -262,7 +262,12 @@ def find_regex(regex_field):
regex_validator = validator
# regex_validator.regex should be a compiled re object...
pattern = getattr(getattr(regex_validator, 'regex', None), 'pattern', None)
try:
pattern = getattr(getattr(regex_validator, 'regex', None), 'pattern', None)
except Exception: # pragma: no cover
logger.warning('failed to compile regex validator of ' + str(regex_field), exc_info=True)
return None
if pattern:
# attempt some basic cleanup to remove regex constructs not supported by JavaScript
# -- swagger uses javascript-style regexes - see https://github.com/swagger-api/swagger-editor/issues/1601