From ce14278adcb2506ae5f25553168df9f0b682f3d6 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Wed, 6 Nov 2024 17:50:53 +0530 Subject: [PATCH] api.main: fix delete user group endpoint Fix `DELETE /group/{group-id}` endpoint's response model by using `pagination_ctx`. Also return `HTTP 204` status code for successful delete operation as per the convention. Signed-off-by: Jeny Sadadia --- api/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/main.py b/api/main.py index 7c2b4b26..a426f618 100644 --- a/api/main.py +++ b/api/main.py @@ -25,7 +25,7 @@ ) from fastapi.responses import JSONResponse, PlainTextResponse, FileResponse from fastapi.security import OAuth2PasswordRequestForm -from fastapi_pagination import add_pagination +from fastapi_pagination import add_pagination, pagination_ctx from fastapi_versioning import VersionedFastAPI from bson import ObjectId, errors from pymongo.errors import DuplicateKeyError @@ -415,7 +415,9 @@ async def get_group(group_id: str): return await db.find_by_id(UserGroup, group_id) -@app.delete('/group/{group_id}', response_model=PageModel) +@app.delete('/group/{group_id}', + dependencies=[Depends(pagination_ctx(PageModel))], + status_code=status.HTTP_204_NO_CONTENT) async def delete_group(group_id: str, current_user: User = Depends(get_current_superuser)): """Delete user group matching the provided group id"""