Field with default value appears as optional in schema
Describe the bug
My code has the following model with a boolean field, published
, with a default value of false
class PublishableModel(models.Model):
"""Fields used to determine if and when something is published."""
published = models.BooleanField(default=False)
publish_date = models.DateTimeField(blank=True, null=True)
However, the schema that drf-spectacular produces shows published as optional.
For example:
/**
*
* @type {boolean}
* @memberof Article
*/
published?: boolean;
Expected behavior: Since there is a default value - all response types should appear in the required section of the model for methods that return an Article but optional for methods that are creating an Article.
Is there a way to distinguish between request and response values being required in the schema?