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 all commits
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': 'password'` in the schema for secret types
4 changes: 2 additions & 2 deletions pydantic/types.py
Expand Up @@ -530,7 +530,7 @@ def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
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', writeOnly=True, format='password')

@classmethod
def __get_validators__(cls) -> 'CallableGenerator':
Expand Down Expand Up @@ -566,7 +566,7 @@ def get_secret_value(self) -> str:
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', writeOnly=True, 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