Set min_length=1 when allow_blank=False (#112)

openapi3
Fabian Weisshaar 2018-04-27 12:02:26 +02:00 committed by Cristi Vîjdea
parent 209201b9a5
commit 5b225423ae
2 changed files with 24 additions and 0 deletions

View File

@ -281,6 +281,10 @@ def find_limits(field):
if attr not in limits or improves(limit_value, limits[attr]): if attr not in limits or improves(limit_value, limits[attr]):
limits[attr] = limit_value limits[attr] = limit_value
if hasattr(field, "allow_blank") and not field.allow_blank:
if limits.get('min_length', 0) < 1:
limits['min_length'] = 1
return OrderedDict(sorted(limits.items())) return OrderedDict(sorted(limits.items()))

View File

@ -202,6 +202,7 @@ paths:
type: string type: string
pattern: ^69$ pattern: ^69$
default: '69' default: '69'
minLength: 1
- name: image_styles - name: image_styles
in: formData in: formData
description: Parameter with Items description: Parameter with Items
@ -700,6 +701,7 @@ paths:
description: this field is generated from a query_serializer description: this field is generated from a query_serializer
required: false required: false
type: string type: string
minLength: 1
- name: is_staff - name: is_staff
in: query in: query
description: this one too! description: this one too!
@ -800,6 +802,7 @@ definitions:
description: title model help_text description: title model help_text
type: string type: string
maxLength: 255 maxLength: 255
minLength: 1
author: author:
description: The ID of the user that created this article; if none is provided, description: The ID of the user that created this article; if none is provided,
defaults to the currently logged in user. defaults to the currently logged in user.
@ -809,6 +812,7 @@ definitions:
description: body serializer help_text description: body serializer help_text
type: string type: string
maxLength: 5000 maxLength: 5000
minLength: 1
slug: slug:
description: slug model help_text description: slug model help_text
type: string type: string
@ -830,6 +834,7 @@ definitions:
description: but i needed to test these 2 fields somehow description: but i needed to test these 2 fields somehow
type: string type: string
format: uri format: uri
minLength: 1
readOnly: true readOnly: true
uuid: uuid:
description: should articles have UUIDs? description: should articles have UUIDs?
@ -872,10 +877,12 @@ definitions:
title: FirstName title: FirstName
type: string type: string
maxLength: 30 maxLength: 30
minLength: 1
lastName: lastName:
title: LastName title: LastName
type: string type: string
maxLength: 30 maxLength: 30
minLength: 1
Person: Person:
required: required:
- identity - identity
@ -897,10 +904,12 @@ definitions:
title: Project name title: Project name
description: Name of the project description: Name of the project
type: string type: string
minLength: 1
githubRepo: githubRepo:
title: Github repo title: Github repo
description: Github repository of the project description: Github repository of the project
type: string type: string
minLength: 1
Snippet: Snippet:
required: required:
- code - code
@ -922,6 +931,7 @@ definitions:
description: The ID of the user that created this snippet. description: The ID of the user that created this snippet.
type: string type: string
readOnly: true readOnly: true
minLength: 1
title: Owner as string title: Owner as string
title: title:
title: Title title: Title
@ -930,6 +940,7 @@ definitions:
code: code:
title: Code title: Code
type: string type: string
minLength: 1
linenos: linenos:
title: Linenos title: Linenos
type: boolean type: boolean
@ -1448,6 +1459,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
TodoAnother: TodoAnother:
required: required:
- title - title
@ -1458,6 +1470,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
todo: todo:
$ref: '#/definitions/Todo' $ref: '#/definitions/Todo'
TodoRecursive: TodoRecursive:
@ -1473,6 +1486,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
parent: parent:
$ref: '#/definitions/TodoRecursive' $ref: '#/definitions/TodoRecursive'
parent_id: parent_id:
@ -1492,6 +1506,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
children: children:
type: array type: array
items: items:
@ -1505,6 +1520,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
todo: todo:
required: required:
- title - title
@ -1518,6 +1534,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
todo: todo:
required: required:
- title - title
@ -1531,6 +1548,7 @@ definitions:
title: Title title: Title
type: string type: string
maxLength: 50 maxLength: 50
minLength: 1
readOnly: true readOnly: true
readOnly: true readOnly: true
UserSerializerrr: UserSerializerrr:
@ -1551,6 +1569,7 @@ definitions:
type: string type: string
pattern: ^[\w.@+-]+$ pattern: ^[\w.@+-]+$
maxLength: 150 maxLength: 150
minLength: 1
email: email:
title: Email address title: Email address
type: string type: string
@ -1572,6 +1591,7 @@ definitions:
type: string type: string
format: ipv4 format: ipv4
readOnly: true readOnly: true
minLength: 1
last_connected_at: last_connected_at:
title: Last connected at title: Last connected at
description: really? description: really?