diff --git a/app/routers/users.py b/app/routers/users.py index 77e93c1..48c3d83 100644 --- a/app/routers/users.py +++ b/app/routers/users.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter, Depends +from fastapi import APIRouter, Depends, HTTPException, status from ..dependencies import users_active, permissions_checker, database from ..models import users from typing import Annotated @@ -7,11 +7,11 @@ from typing import Annotated router = APIRouter() @router.get("/users", tags=["users"], response_model=list[users.UserOut]) -async def read_users(skip : int = 0, limit : int = 20, authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))]): - if limit < 1 or skip < 0: +async def read_users(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))], skip: int = 0, limit: int = 20): + if limit < 1 or skip < 0 or limit < skip: raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, - detail="skip should be greater than 0 and limit should be greater than 1" + detail="skip should be greater than 0 and limit should be greater than 1. Limit should be greater than skip" ) limit = limit + skip listUsers = []