♻️ Refactor rename ModelsOut to ModelsPublic (#1154)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -17,9 +17,9 @@ from app.models import (
|
||||
UpdatePassword,
|
||||
User,
|
||||
UserCreate,
|
||||
UserOut,
|
||||
UserPublic,
|
||||
UserRegister,
|
||||
UsersOut,
|
||||
UsersPublic,
|
||||
UserUpdate,
|
||||
UserUpdateMe,
|
||||
)
|
||||
@@ -29,7 +29,9 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.get(
|
||||
"/", dependencies=[Depends(get_current_active_superuser)], response_model=UsersOut
|
||||
"/",
|
||||
dependencies=[Depends(get_current_active_superuser)],
|
||||
response_model=UsersPublic,
|
||||
)
|
||||
def read_users(session: SessionDep, skip: int = 0, limit: int = 100) -> Any:
|
||||
"""
|
||||
@@ -42,11 +44,11 @@ def read_users(session: SessionDep, skip: int = 0, limit: int = 100) -> Any:
|
||||
statement = select(User).offset(skip).limit(limit)
|
||||
users = session.exec(statement).all()
|
||||
|
||||
return UsersOut(data=users, count=count)
|
||||
return UsersPublic(data=users, count=count)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/", dependencies=[Depends(get_current_active_superuser)], response_model=UserOut
|
||||
"/", dependencies=[Depends(get_current_active_superuser)], response_model=UserPublic
|
||||
)
|
||||
def create_user(*, session: SessionDep, user_in: UserCreate) -> Any:
|
||||
"""
|
||||
@@ -72,7 +74,7 @@ def create_user(*, session: SessionDep, user_in: UserCreate) -> Any:
|
||||
return user
|
||||
|
||||
|
||||
@router.patch("/me", response_model=UserOut)
|
||||
@router.patch("/me", response_model=UserPublic)
|
||||
def update_user_me(
|
||||
*, session: SessionDep, user_in: UserUpdateMe, current_user: CurrentUser
|
||||
) -> Any:
|
||||
@@ -114,7 +116,7 @@ def update_password_me(
|
||||
return Message(message="Password updated successfully")
|
||||
|
||||
|
||||
@router.get("/me", response_model=UserOut)
|
||||
@router.get("/me", response_model=UserPublic)
|
||||
def read_user_me(current_user: CurrentUser) -> Any:
|
||||
"""
|
||||
Get current user.
|
||||
@@ -122,7 +124,7 @@ def read_user_me(current_user: CurrentUser) -> Any:
|
||||
return current_user
|
||||
|
||||
|
||||
@router.post("/signup", response_model=UserOut)
|
||||
@router.post("/signup", response_model=UserPublic)
|
||||
def register_user(session: SessionDep, user_in: UserRegister) -> Any:
|
||||
"""
|
||||
Create new user without the need to be logged in.
|
||||
@@ -143,7 +145,7 @@ def register_user(session: SessionDep, user_in: UserRegister) -> Any:
|
||||
return user
|
||||
|
||||
|
||||
@router.get("/{user_id}", response_model=UserOut)
|
||||
@router.get("/{user_id}", response_model=UserPublic)
|
||||
def read_user_by_id(
|
||||
user_id: int, session: SessionDep, current_user: CurrentUser
|
||||
) -> Any:
|
||||
@@ -164,7 +166,7 @@ def read_user_by_id(
|
||||
@router.patch(
|
||||
"/{user_id}",
|
||||
dependencies=[Depends(get_current_active_superuser)],
|
||||
response_model=UserOut,
|
||||
response_model=UserPublic,
|
||||
)
|
||||
def update_user(
|
||||
*,
|
||||
|
Reference in New Issue
Block a user