Skip to content

Commit dadf075

Browse files
author
Diogo Baeder de Paula Pinto
committed
Accepting uuid string format and validating accordingly.
1 parent 922fce4 commit dadf075

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

openapi_core/schema/schemas/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ class SchemaFormat(Enum):
2525
DATE = 'date'
2626
DATETIME = 'date-time'
2727
PASSWORD = 'password'
28+
UUID = 'uuid'

openapi_core/schema/schemas/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import warnings
99

1010
from six import iteritems, integer_types, binary_type, text_type
11+
from uuid import UUID
1112

1213
from openapi_core.extensions.models.factories import ModelFactory
1314
from openapi_core.schema.schemas.enums import SchemaFormat, SchemaType
@@ -46,6 +47,7 @@ class Schema(object):
4647
SchemaFormat.DATE: Format(format_date, TypeValidator(date, exclude=datetime)),
4748
SchemaFormat.DATETIME: Format(format_datetime, TypeValidator(datetime)),
4849
SchemaFormat.BINARY: Format(binary_type, TypeValidator(binary_type)),
50+
SchemaFormat.UUID: Format(UUID, TypeValidator(UUID)),
4951
}
5052

5153
TYPE_VALIDATOR_CALLABLE_GETTER = {
@@ -54,7 +56,7 @@ class Schema(object):
5456
SchemaType.INTEGER: TypeValidator(integer_types, exclude=bool),
5557
SchemaType.NUMBER: TypeValidator(integer_types, float, exclude=bool),
5658
SchemaType.STRING: TypeValidator(
57-
text_type, date, datetime, binary_type),
59+
text_type, date, datetime, binary_type, UUID),
5860
SchemaType.ARRAY: TypeValidator(list, tuple),
5961
SchemaType.OBJECT: AttributeValidator('__dict__'),
6062
}

0 commit comments

Comments
 (0)