From 0f820d12e3ac0f2e518d8d13e1a002292ebf51e7 Mon Sep 17 00:00:00 2001 From: Peter Vacho Date: Tue, 31 Dec 2024 01:30:01 +0100 Subject: [PATCH] Fix some endpoint paths --- src/api/categories.py | 8 ++++---- src/api/events.py | 6 +++--- src/api/invitations.py | 8 ++++---- src/api/notifications.py | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/api/categories.py b/src/api/categories.py index abc2d84..98b10c4 100644 --- a/src/api/categories.py +++ b/src/api/categories.py @@ -141,7 +141,7 @@ async def get_event_categories(event_id: PydanticObjectId, user: CurrentUserDep) return [CategoryData.from_category(category) for category in cast(list[Category], event.categories)] -@categories_router.get("{category_id}") +@categories_router.get("/{category_id}") async def get_category(category_id: PydanticObjectId, user: CurrentUserDep) -> CategoryData: """Get a category by ID.""" category = await Category.get(category_id, fetch_links=True) @@ -156,7 +156,7 @@ async def get_category(category_id: PydanticObjectId, user: CurrentUserDep) -> C return CategoryData.from_category(category) -@categories_router.delete("{category_id}") +@categories_router.delete("/{category_id}") async def delete_category(category_id: PydanticObjectId, user: CurrentUserDep) -> Response: """Delete the given category. @@ -196,7 +196,7 @@ async def create_category( return CategoryData.from_category(category) -@categories_router.put("{category_id}") +@categories_router.put("/{category_id}") async def overwrite_category( category_id: PydanticObjectId, user: CurrentUserDep, @@ -216,7 +216,7 @@ async def overwrite_category( return CategoryData.from_category(category) -@categories_router.patch("{category_id}") +@categories_router.patch("/{category_id}") async def update_category( category_id: PydanticObjectId, user: CurrentUserDep, diff --git a/src/api/events.py b/src/api/events.py index 05a8add..aaff7da 100644 --- a/src/api/events.py +++ b/src/api/events.py @@ -235,7 +235,7 @@ async def get_user_invited_events( return [EventData.from_event(event) for event in events] -@events_router.get("{event_id}") +@events_router.get("/{event_id}") async def get_event(event_id: PydanticObjectId, user: CurrentUserDep) -> EventData: """Get an event by ID. @@ -260,7 +260,7 @@ async def get_event(event_id: PydanticObjectId, user: CurrentUserDep) -> EventDa return EventData.from_event(event) -@events_router.delete("{event_id}") +@events_router.delete("/{event_id}") async def delete_event(event_id: PydanticObjectId, user: CurrentUserDep) -> Response: """Delete an event by ID.""" event = await Event.get(event_id) @@ -287,7 +287,7 @@ async def create_event( return EventData.from_event(event) -@events_router.put("{event_id}") +@events_router.put("/{event_id}") async def overwrite_event( event_id: PydanticObjectId, user: CurrentUserDep, diff --git a/src/api/invitations.py b/src/api/invitations.py index 32ded97..a881b3c 100644 --- a/src/api/invitations.py +++ b/src/api/invitations.py @@ -174,7 +174,7 @@ async def get_user_incomming_invitatinos(user_id: PydanticObjectId, user: Curren return [InvitationData.from_invitation(invitation) for invitation in invitations] -@invitations_router.get("{invitation_id}") +@invitations_router.get("/{invitation_id}") async def get_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> InvitationData: """Get information about a specific invitation. @@ -201,7 +201,7 @@ async def create_invitation(data: InvitationCreateData, user: CurrentUserDep) -> return InvitationData.from_invitation(invitation) -@invitations_router.delete("{invitation_id}") +@invitations_router.delete("/{invitation_id}") async def delete_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> Response: """Delete an invitation.""" invitation = await Invitation.get(invitation_id, fetch_links=True) @@ -219,7 +219,7 @@ async def delete_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe return Response(status.HTTP_204_NO_CONTENT) -@invitations_router.post("{invitation_id}/accept") +@invitations_router.post("/{invitation_id}/accept") async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> Response: """Accept an invitation.""" invitation = await Invitation.get(invitation_id, fetch_links=True) @@ -261,7 +261,7 @@ async def accept_invitation(invitation_id: PydanticObjectId, user: CurrentUserDe return Response(status_code=status.HTTP_204_NO_CONTENT) -@invitations_router.post("{invitation_id}/decline") +@invitations_router.post("/{invitation_id}/decline") async def decline_invitation(invitation_id: PydanticObjectId, user: CurrentUserDep) -> Response: """Decline an invitation.""" invitation = await Invitation.get(invitation_id, fetch_links=True) diff --git a/src/api/notifications.py b/src/api/notifications.py index 0a0d500..38aeb00 100644 --- a/src/api/notifications.py +++ b/src/api/notifications.py @@ -72,7 +72,7 @@ async def get_user_notifications(user_id: PydanticObjectId, user: CurrentUserDep return [NotificationData.from_notification(notification) for notification in notifications] -@notifications_router.get("{notification_id}") +@notifications_router.get("/{notification_id}") async def get_notification(notification_id: PydanticObjectId, user: CurrentUserDep) -> NotificationData: """Get a single notification.""" notification = await Notification.get(notification_id, fetch_links=True) @@ -89,7 +89,7 @@ async def get_notification(notification_id: PydanticObjectId, user: CurrentUserD return NotificationData.from_notification(notification) -@notifications_router.get("{notification_id}/read") +@notifications_router.get("/{notification_id}/read") async def read_notification(notification_id: PydanticObjectId, user: CurrentUserDep) -> NotificationData: """Mark a notification as read.""" notification = await Notification.get(notification_id, fetch_links=True)