From 5e9f8b59a419e8d52af54c0796b07e8f7436caa3 Mon Sep 17 00:00:00 2001 From: Dominik Stahl Date: Thu, 19 Jun 2025 20:29:04 +0200 Subject: [PATCH] fix(api): update paths in Swagger documentation to include '/api' prefix --- .../[eventID]/participant/[user]/swagger.ts | 6 +-- .../event/[eventID]/participant/swagger.ts | 4 +- src/app/api/event/[eventID]/route.ts | 38 ++++++++++++++++++- src/app/api/event/[eventID]/swagger.ts | 6 +-- src/app/api/event/validation.ts | 1 - 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/app/api/event/[eventID]/participant/[user]/swagger.ts b/src/app/api/event/[eventID]/participant/[user]/swagger.ts index aaf0f5a..b08bd74 100644 --- a/src/app/api/event/[eventID]/participant/[user]/swagger.ts +++ b/src/app/api/event/[eventID]/participant/[user]/swagger.ts @@ -19,7 +19,7 @@ import { export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'get', - path: '/event/{eventID}/participant/{user}', + path: '/api/event/{eventID}/participant/{user}', request: { params: zod.object({ eventID: EventIdParamSchema, @@ -44,7 +44,7 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'delete', - path: '/event/{eventID}/participant/{user}', + path: '/api/event/{eventID}/participant/{user}', request: { params: zod.object({ eventID: EventIdParamSchema, @@ -69,7 +69,7 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'patch', - path: '/event/{eventID}/participant/{user}', + path: '/api/event/{eventID}/participant/{user}', request: { params: zod.object({ eventID: EventIdParamSchema, diff --git a/src/app/api/event/[eventID]/participant/swagger.ts b/src/app/api/event/[eventID]/participant/swagger.ts index 919cfda..38dfd58 100644 --- a/src/app/api/event/[eventID]/participant/swagger.ts +++ b/src/app/api/event/[eventID]/participant/swagger.ts @@ -16,7 +16,7 @@ import { EventIdParamSchema } from '@/app/api/validation'; export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'get', - path: '/event/{eventID}/participant', + path: '/api/event/{eventID}/participant', request: { params: zod.object({ eventID: EventIdParamSchema, @@ -40,7 +40,7 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'post', - path: '/event/{eventID}/participant', + path: '/api/event/{eventID}/participant', request: { params: zod.object({ eventID: EventIdParamSchema, diff --git a/src/app/api/event/[eventID]/route.ts b/src/app/api/event/[eventID]/route.ts index 807c31b..8c06b64 100644 --- a/src/app/api/event/[eventID]/route.ts +++ b/src/app/api/event/[eventID]/route.ts @@ -219,8 +219,32 @@ export const PATCH = auth(async (req, { params }) => { { status: 400 }, ); } - const { title, description, start_time, end_time, location, status } = - data.data; + const { + title, + description, + start_time, + end_time, + location, + status, + participants, + } = data.data; + + if (participants !== undefined) + for (const participant of participants) { + await prisma.meetingParticipant.upsert({ + where: { + meeting_id_user_id: { + user_id: participant, + meeting_id: eventID, + }, + }, + create: { + user_id: participant, + meeting_id: eventID, + }, + update: {}, + }); + } const updatedEvent = await prisma.meeting.update({ where: { @@ -233,6 +257,16 @@ export const PATCH = auth(async (req, { params }) => { end_time, location, status, + participants: + participants !== undefined + ? { + deleteMany: { + user_id: { + notIn: participants || [], + }, + }, + } + : {}, }, select: { id: true, diff --git a/src/app/api/event/[eventID]/swagger.ts b/src/app/api/event/[eventID]/swagger.ts index a293775..4703556 100644 --- a/src/app/api/event/[eventID]/swagger.ts +++ b/src/app/api/event/[eventID]/swagger.ts @@ -15,7 +15,7 @@ import zod from 'zod/v4'; export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'get', - path: '/event/{eventID}', + path: '/api/event/{eventID}', request: { params: zod.object({ eventID: EventIdParamSchema, @@ -38,7 +38,7 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'delete', - path: '/event/{eventID}', + path: '/api/event/{eventID}', request: { params: zod.object({ eventID: EventIdParamSchema, @@ -62,7 +62,7 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) { registry.registerPath({ method: 'patch', - path: '/event/{eventID}', + path: '/api/event/{eventID}', request: { params: zod.object({ eventID: EventIdParamSchema, diff --git a/src/app/api/event/validation.ts b/src/app/api/event/validation.ts index da5912f..b8e176b 100644 --- a/src/app/api/event/validation.ts +++ b/src/app/api/event/validation.ts @@ -113,7 +113,6 @@ export const createEventSchema = zod // ---------------------------------------- export const updateEventSchema = zod .object({ - id: eventIdSchema, title: eventTitleSchema.optional(), description: eventDescriptionSchema.optional(), start_time: eventStartTimeSchema.optional(),