diff --git a/changes/1424-atheuz.md b/changes/1424-atheuz.md index d02af90e26d..80302b69d51 100644 --- a/changes/1424-atheuz.md +++ b/changes/1424-atheuz.md @@ -1 +1 @@ -include format with secret types #546 \ No newline at end of file +include `format` with secret types to the schema \ No newline at end of file diff --git a/pydantic/types.py b/pydantic/types.py index e9247de53d3..01b300734e7 100644 --- a/pydantic/types.py +++ b/pydantic/types.py @@ -530,8 +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', format='password') + field_schema.update(type='string', writeOnly=True, format='password') @classmethod def __get_validators__(cls) -> 'CallableGenerator': @@ -567,8 +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', format='password') + field_schema.update(type='string', writeOnly=True, format='password') @classmethod def __get_validators__(cls) -> 'CallableGenerator':