Skip to content

Request: minLength if allow_blank=False #282

@HansAarneLiblik

Description

@HansAarneLiblik

Currently drf-yasg (from which were migrating) adds minLength: 1 to schema if field is not required and has default value, ie

depth = serializers.CharField(required=False, default='2')

and this generates schema

- name: depth
  in: query
  required: false
  type: string
  default: '2'
  minLength: 1

which means user CAN NOT make request api.foo.com?depth=''

drf-spectacular does not add minLength value for this

- in: query
  name: depth
  schema:
    type: string
    default: '2'

This minLength: 1 value should come from allow_blank attr that for CharField default to False

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfix confirmation pendingissue has been fixed and confirmation from issue reporter is pending

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions