Skip to content

Commit

Permalink
include format with secret types
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseGravesen committed Apr 23, 2020
1 parent f96c4dc commit e9e9cd7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/1424-atheuz.md
@@ -0,0 +1 @@
include format with secret types #546
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')

@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

0 comments on commit e9e9cd7

Please sign in to comment.