fix parameter path

This commit is contained in:
Valentin CZERYBA 2023-10-14 15:16:38 +02:00
parent 2dedf30095
commit 340b3e4b52

View File

@ -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 = []