From 8636f5d9dfc3dd31992f1ba012529a99dae0a508 Mon Sep 17 00:00:00 2001 From: Dima Knivets Date: Sun, 11 Aug 2019 16:11:27 +0300 Subject: [PATCH] improvements to code --- rest_framework/schemas/openapi.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index bdcf3225c..fdaad5cb1 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -378,7 +378,7 @@ class AutoSchema(ViewInspector): schema['default'] = field.default if field.help_text: schema['description'] = str(field.help_text) - self._map_field_validators(field, field.validators, schema) + self._map_field_validators(field, schema) properties[field.field_name] = schema @@ -390,13 +390,11 @@ class AutoSchema(ViewInspector): return result - def _map_field_validators(self, field, validators, schema): + def _map_field_validators(self, field, schema): """ map field validators - :param list:validators: list of field validators - :param dict:schema: schema that the validators get added to """ - for v in validators: + for v in field.validators: # "Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification." # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types if isinstance(v, EmailValidator):