Skip to content

Commit

Permalink
include format with secret types (#1424)
Browse files Browse the repository at this point in the history
* include format with secret types

* fix: fix pr comments.

Co-authored-by: Lasse Gravesen <lasse.gravesen@falcon.io>
  • Loading branch information
Atheuz and LasseGravesen committed Apr 30, 2020
1 parent 833d33d commit 9238e3d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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 @@ -540,7 +540,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 @@ -576,7 +576,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 @@ -580,7 +580,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 9238e3d

Please sign in to comment.