Skip to content

Commit

Permalink
Password format unmarshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
p1c2u committed Aug 17, 2023
1 parent 5a02484 commit 2fef9ca
Show file tree
Hide file tree
Showing 6 changed files with 502 additions and 484 deletions.
2 changes: 2 additions & 0 deletions openapi_core/unmarshalling/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from openapi_core.unmarshalling.schemas.unmarshallers import TypesUnmarshaller
from openapi_core.unmarshalling.schemas.util import format_byte
from openapi_core.unmarshalling.schemas.util import format_date
from openapi_core.unmarshalling.schemas.util import format_password
from openapi_core.unmarshalling.schemas.util import format_uuid
from openapi_core.validation.schemas import (
oas30_read_schema_validators_factory,
Expand Down Expand Up @@ -68,6 +69,7 @@
"binary": bytes,
"uuid": format_uuid,
"byte": format_byte,
"password": format_password,
}
oas31_format_unmarshallers = oas30_format_unmarshallers

Expand Down
6 changes: 6 additions & 0 deletions openapi_core/unmarshalling/schemas/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from typing import Union
from uuid import UUID

from pydantic import SecretStr


def format_date(value: str) -> date:
return datetime.strptime(value, "%Y-%m-%d").date()
Expand All @@ -26,3 +28,7 @@ def format_number(value: str) -> Union[int, float]:
return value

return float(value)


def format_password(value: str) -> SecretStr:
return SecretStr(value)
Loading

0 comments on commit 2fef9ca

Please sign in to comment.