diff --git a/app/api/endpoints/user.py b/app/api/endpoints/user.py index 21f76ee..555104b 100644 --- a/app/api/endpoints/user.py +++ b/app/api/endpoints/user.py @@ -11,7 +11,7 @@ from app.core.db import get_async_session from app.core.user import auth_backend, fastapi_users from app.crud.user import user_crud -from app.schemas.user import UserCreate, UserRead, UserUpdate +from app.schemas.user import UserCreate, UserRead, UserReadRegister, UserUpdate from app.services.token_generator.tokens import token_generator router = APIRouter() @@ -24,7 +24,7 @@ router.include_router( register.get_register_router( - UserRead, + UserReadRegister, Annotated[UserCreate, Body(example=USER_VALUE)] ), prefix='/auth', diff --git a/app/api_docs_responses/register.py b/app/api_docs_responses/register.py index a401c36..cb0966c 100644 --- a/app/api_docs_responses/register.py +++ b/app/api_docs_responses/register.py @@ -11,7 +11,6 @@ 'is_active': True, 'is_superuser': True, 'is_verified': False, - 'role': 'user', 'username': 'Имя', 'tariff_id': 0 } diff --git a/app/schemas/user.py b/app/schemas/user.py index efa3173..9ddff31 100644 --- a/app/schemas/user.py +++ b/app/schemas/user.py @@ -8,11 +8,7 @@ from app.core.constants import Role -class UserRead(schemas.BaseUser[int]): - role: Annotated[ - Choice, - WithJsonSchema({'type': 'str'}) - ] +class UserReadRegister(schemas.BaseUser[int]): username: str tariff_id: Optional[int] @@ -20,6 +16,13 @@ class Config: from_attributes = True arbitrary_types_allowed = True + +class UserRead(UserReadRegister): + role: Annotated[ + Choice, + WithJsonSchema({'type': 'str'}) + ] + @field_serializer('role') def serialize_role(self, role: Choice, _info): return role.code