mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 01:20:02 +03:00
improvements to code
This commit is contained in:
parent
329bd57fd0
commit
8636f5d9df
|
@ -378,7 +378,7 @@ class AutoSchema(ViewInspector):
|
||||||
schema['default'] = field.default
|
schema['default'] = field.default
|
||||||
if field.help_text:
|
if field.help_text:
|
||||||
schema['description'] = str(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
|
properties[field.field_name] = schema
|
||||||
|
|
||||||
|
@ -390,13 +390,11 @@ class AutoSchema(ViewInspector):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _map_field_validators(self, field, validators, schema):
|
def _map_field_validators(self, field, schema):
|
||||||
"""
|
"""
|
||||||
map field validators
|
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."
|
# "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
|
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types
|
||||||
if isinstance(v, EmailValidator):
|
if isinstance(v, EmailValidator):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user