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'