diff --git a/http-api/tests/test_auth.py b/http-api/tests/test_auth.py index a2b4ea0..52e6102 100644 --- a/http-api/tests/test_auth.py +++ b/http-api/tests/test_auth.py @@ -1,7 +1,9 @@ import auth as app +from .conftest import LambdaContext -def test_bearer_jwt(lambda_context): + +def test_bearer_jwt(lambda_context: LambdaContext): app.get_user = lambda *args, **kwargs: { 'sub': '58efed8d-d276-41a8-8502-4ab8b5a6415e', 'name': 'pytest', @@ -13,7 +15,7 @@ def test_bearer_jwt(lambda_context): }, } - assert app.lambda_handler(event, lambda_context) == { # type: ignore + assert app.lambda_handler(event, lambda_context) == { 'isAuthorized': True, 'context': { 'user': { diff --git a/layercake/layercake/extra_types.py b/layercake/layercake/extra_types.py index f9df46e..3e9f393 100644 --- a/layercake/layercake/extra_types.py +++ b/layercake/layercake/extra_types.py @@ -148,6 +148,17 @@ class CpfCnpj: return cpfcnpj_ + @classmethod + def __get_pydantic_json_schema__( + cls, core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler + ) -> JsonSchemaValue: + field_schema = handler(core_schema) + field_schema.update( + type='string', + format=cls.__name__.lower().removesuffix('str'), + ) + return field_schema + if TYPE_CHECKING: CpfStr = Annotated[str, ...]