From e872862a91ac1fb132a6e6c804f2881dfaedfb67 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Sun, 28 Jun 2020 14:09:31 +0200 Subject: [PATCH] Added comment for why `\z`. --- rest_framework/schemas/openapi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 0f68cdfb5..9774a94c7 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -554,6 +554,8 @@ class AutoSchema(ViewInspector): if isinstance(v, URLValidator): schema['format'] = 'uri' if isinstance(v, RegexValidator): + # In Python, the token \Z does what \z does in other engines. + # https://stackoverflow.com/questions/53283160 schema['pattern'] = v.regex.pattern.replace('\\Z', '\\z') elif isinstance(v, MaxLengthValidator): attr_name = 'maxLength'