Describe the bug
In v0.30, but not v0.29, a serializer EmailField(default="") generates an incorrect schema entry with redundant maxLength: 0 entries. A similar field with no default generates a valid schema.
# v0.29.0 schema
email:
oneOf:
- type: string
maxLength: 254
format: email
- type: string
maxLength: 254
default: ''
title: E-mail
# v0.30.0 schema
email:
oneOf:
- oneOf:
- type: string
maxLength: 254
format: email
- type: string
maxLength: 0
- oneOf:
- type: string
format: email
maxLength: 254
- type: string
maxLength: 0
default: ''
title: E-mail
The v0.30.0 schema fails validation by openapi_spec_validator:
openapi_spec_validator.validation.exceptions.OpenAPIValidationError: '' is valid under each of {'oneOf': [{'type': 'string', 'format': 'email', 'maxLength': 254}, {'type': 'string', 'maxLength': 0}]}, {'oneOf': [{'type': 'string', 'maxLength': 254, 'format': 'email'}, {'type': 'string', 'maxLength': 0}]}
To Reproduce
>>> ContactSerializer().fields["email"]
EmailField(allow_blank=True, default='', label='E-mail', max_length=254, required=False)
Expected behavior
A valid schema should be generated.
Describe the bug
In v0.30, but not v0.29, a serializer
EmailField(default="")generates an incorrect schema entry with redundantmaxLength: 0entries. A similar field with nodefaultgenerates a valid schema.The v0.30.0 schema fails validation by
openapi_spec_validator:To Reproduce
Expected behavior
A valid schema should be generated.