Check for None before calling to_representation
Django REST Framework also does this in serializers.
https://github.com/encode/django-rest-framework/issues/2299
4d57d46bf8/rest_framework/serializers.py (L518)
Fixes #203.
openapi3
parent
f9b215deab
commit
5fa35d5b81
|
|
@ -404,7 +404,7 @@ def get_field_default(field):
|
|||
"called; 'default' will not be set on schema", field, exc_info=True)
|
||||
default = serializers.empty
|
||||
|
||||
if default is not serializers.empty:
|
||||
if default is not serializers.empty and default is not None:
|
||||
try:
|
||||
default = field.to_representation(default)
|
||||
# JSON roundtrip ensures that the value is valid JSON;
|
||||
|
|
|
|||
Loading…
Reference in New Issue