Skip to content

Schema Generator: serializer field from models.DurationField with MinValueValidator produces invalid outputΒ #8063

@peterthomassen

Description

@peterthomassen

I have a model with the following field:

max_age = models.DurationField(null=True, default=None, validators=[MinValueValidator(timedelta(0))])

The schema contains the following output:

        max_age:
          type: string
          nullable: true
          minimum: !!python/object/apply:datetime.timedelta
          - 0
          - 0
          - 0

This cannot be rendered by Swagger / ReDoc, leading to failures when loading the schema.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions