Skip to content
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

include format with secret types #1424

Merged
merged 2 commits into from Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1424-atheuz.md
@@ -0,0 +1 @@
include format with secret types #546
Atheuz marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions pydantic/types.py
Expand Up @@ -531,6 +531,7 @@ class SecretStr:
@classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
field_schema.update(type='string', writeOnly=True)
field_schema.update(type='string', format='password')
Atheuz marked this conversation as resolved.
Show resolved Hide resolved

@classmethod
def __get_validators__(cls) -> 'CallableGenerator':
Expand Down Expand Up @@ -567,6 +568,7 @@ class SecretBytes:
@classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
field_schema.update(type='string', writeOnly=True)
field_schema.update(type='string', format='password')

@classmethod
def __get_validators__(cls) -> 'CallableGenerator':
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Expand Up @@ -579,7 +579,7 @@ class Model(BaseModel):
base_schema = {
'title': 'Model',
'type': 'object',
'properties': {'a': {'title': 'A', 'type': inner_type, 'writeOnly': True}},
'properties': {'a': {'title': 'A', 'type': inner_type, 'writeOnly': True, 'format': 'password'}},
'required': ['a'],
}

Expand Down