From 8fc4eedf5f8b0b36081049c217de17fbe3aa0e35 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Fri, 10 Mar 2023 22:33:41 +0530 Subject: [PATCH] Adds swagger for schedules (#247) This PR updates swagger documentation for the Schedules endpoint --- pages/api/schedules/[id]/_delete.ts | 6 ++++++ pages/api/schedules/[id]/_get.ts | 6 ++++++ pages/api/schedules/[id]/_patch.ts | 20 +++++++++++++++++++ pages/api/schedules/_get.ts | 7 +++++++ pages/api/schedules/_post.ts | 30 +++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) diff --git a/pages/api/schedules/[id]/_delete.ts b/pages/api/schedules/[id]/_delete.ts index 502ab7b029..e48c76c469 100644 --- a/pages/api/schedules/[id]/_delete.ts +++ b/pages/api/schedules/[id]/_delete.ts @@ -17,6 +17,12 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform * type: integer * required: true * description: ID of the schedule to delete + * - in: query + * name: apiKey + * schema: + * type: string + * required: true + * description: Your API Key * tags: * - schedules * responses: diff --git a/pages/api/schedules/[id]/_get.ts b/pages/api/schedules/[id]/_get.ts index 568cedcf57..27502833fd 100644 --- a/pages/api/schedules/[id]/_get.ts +++ b/pages/api/schedules/[id]/_get.ts @@ -18,6 +18,12 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform * type: integer * required: true * description: ID of the schedule to get + * - in: query + * name: apiKey + * schema: + * type: string + * required: true + * description: Your API Key * tags: * - schedules * responses: diff --git a/pages/api/schedules/[id]/_patch.ts b/pages/api/schedules/[id]/_patch.ts index e121eafa75..85c67e91c0 100644 --- a/pages/api/schedules/[id]/_patch.ts +++ b/pages/api/schedules/[id]/_patch.ts @@ -20,6 +20,26 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform * type: integer * required: true * description: ID of the schedule to edit + * - in: query + * name: apiKey + * schema: + * type: string + * required: true + * description: Your API Key + * requestBody: + * description: Create a new schedule + * required: true + * content: + * application/json: + * schema: + * type: object + * properties: + * name: + * type: string + * description: Name of the schedule + * timezone: + * type: string + * description: The timezone for this schedule * tags: * - schedules * responses: diff --git a/pages/api/schedules/_get.ts b/pages/api/schedules/_get.ts index d6ca98abd6..4790780835 100644 --- a/pages/api/schedules/_get.ts +++ b/pages/api/schedules/_get.ts @@ -18,6 +18,13 @@ export const schemaUserIds = z * get: * operationId: listSchedules * summary: Find all schedules + * parameters: + * - in: query + * name: apiKey + * schema: + * type: string + * required: true + * description: Your API Key * tags: * - schedules * responses: diff --git a/pages/api/schedules/_post.ts b/pages/api/schedules/_post.ts index 885b3cfa88..892d5c0cef 100644 --- a/pages/api/schedules/_post.ts +++ b/pages/api/schedules/_post.ts @@ -13,6 +13,30 @@ import { schemaCreateScheduleBodyParams, schemaSchedulePublic } from "~/lib/vali * post: * operationId: addSchedule * summary: Creates a new schedule + * parameters: + * - in: query + * name: apiKey + * schema: + * type: string + * required: true + * description: Your API Key + * requestBody: + * description: Create a new schedule + * required: true + * content: + * application/json: + * schema: + * type: object + * required: + * - name + * - timezone + * properties: + * name: + * type: string + * description: Name of the schedule + * timezone: + * type: string + * description: The timezone for this schedule * tags: * - schedules * responses: @@ -23,6 +47,12 @@ import { schemaCreateScheduleBodyParams, schemaSchedulePublic } from "~/lib/vali * 401: * description: Authorization information is missing or invalid. */ + + +eventType EventType[] +name String +timeZone String? +availability Availability[] async function postHandler(req: NextApiRequest) { const { userId, isAdmin, prisma } = req; const body = schemaCreateScheduleBodyParams.parse(req.body);