Skip to content

Add support for password string format #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openapi_core/schema/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Schema(object):

STRING_FORMAT_CALLABLE_GETTER = {
SchemaFormat.NONE: Format(text_type, TypeValidator(text_type)),
SchemaFormat.PASSWORD: Format(text_type, TypeValidator(text_type)),
SchemaFormat.DATE: Format(
format_date, TypeValidator(date, exclude=datetime)),
SchemaFormat.DATETIME: Format(format_datetime, TypeValidator(datetime)),
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/schema/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def test_string_format_uuid_uuid_quirks_valid(self):

assert result == value

def test_string_format_password(self):
schema = Schema(SchemaType.STRING, schema_format=SchemaFormat.PASSWORD)
value = 'password'

result = schema.unmarshal(value)

assert result == 'password'

def test_string_float_invalid(self):
schema = Schema('string')
value = 1.23
Expand Down