diff --git a/lib/validations/booking.ts b/lib/validations/booking.ts index 31deb5cff5..9d70d4c6d5 100644 --- a/lib/validations/booking.ts +++ b/lib/validations/booking.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { _BookingModel as Booking } from "@calcom/prisma/zod"; +import { _BookingModel as Booking, _AttendeeModel, _UserModel } from "@calcom/prisma/zod"; import { extendedBookingCreateBody } from "@calcom/prisma/zod-utils"; import { schemaQueryUserId } from "./shared/queryUserId"; @@ -27,7 +27,22 @@ const schemaBookingEditParams = z export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingEditParams); -export const schemaBookingReadPublic = Booking.pick({ +export const schemaBookingReadPublic = Booking.extend({ + attendees: z.array( + _AttendeeModel.pick({ + email: true, + name: true, + timeZone: true, + locale: true, + }) + ), + user: _UserModel.pick({ + email: true, + name: true, + timeZone: true, + locale: true, + }), +}).pick({ id: true, userId: true, description: true, @@ -36,4 +51,8 @@ export const schemaBookingReadPublic = Booking.pick({ title: true, startTime: true, endTime: true, + timeZone: true, + attendees: true, + user: true, + metadata: true, }); diff --git a/pages/api/bookings/[id]/_get.ts b/pages/api/bookings/[id]/_get.ts index 567312261a..bcf74dc647 100644 --- a/pages/api/bookings/[id]/_get.ts +++ b/pages/api/bookings/[id]/_get.ts @@ -23,6 +23,10 @@ import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformP * responses: * 200: * description: OK + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/Booking" * 401: * description: Authorization information is missing or invalid. * 404: diff --git a/pages/api/bookings/_get.ts b/pages/api/bookings/_get.ts index 0a1b2e66c8..322d8161f1 100644 --- a/pages/api/bookings/_get.ts +++ b/pages/api/bookings/_get.ts @@ -17,6 +17,10 @@ import { schemaQuerySingleOrMultipleUserIds } from "@lib/validations/shared/quer * responses: * 200: * description: OK + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/ArrayOfBookings" * 401: * description: Authorization information is missing or invalid. * 404: diff --git a/pages/api/bookings/_post.ts b/pages/api/bookings/_post.ts index b76397d4a4..af3099dd85 100644 --- a/pages/api/bookings/_post.ts +++ b/pages/api/bookings/_post.ts @@ -26,7 +26,7 @@ import { defaultResponder } from "@calcom/lib/server"; * endTime: * type: string * example: 1970-01-01T17:00:00.000Z - * recurringCount: + * recurringCount: * type: number * example: 8 * tags: diff --git a/pages/api/docs.ts b/pages/api/docs.ts index d339043741..37fdddc06a 100644 --- a/pages/api/docs.ts +++ b/pages/api/docs.ts @@ -22,6 +22,87 @@ const swaggerHandler = withSwagger({ }, components: { securitySchemes: { ApiKeyAuth: { type: "apiKey", in: "query", name: "apiKey" } }, + schemas: { + ArrayOfBookings: { + type: "array", + items: { + $ref: "#/components/schemas/Booking", + }, + }, + Booking: { + properties: { + id: { + type: "number", + }, + description: { + type: "string", + }, + eventTypeId: { + type: "number", + }, + uid: { + type: "string", + format: "uuid", + }, + title: { + type: "string", + }, + startTime: { + type: "string", + format: "date-time", + }, + endTime: { + type: "string", + format: "date-time", + }, + timeZone: { + type: "string", + example: "Europe/London", + }, + attendees: { + type: "array", + items: { + properties: { + email: { + type: "string", + example: "example@cal.com", + }, + name: { + type: "string", + }, + timeZone: { + type: "string", + example: "Europe/London", + }, + locale: { + type: "string", + example: "en", + }, + }, + }, + }, + user: { + properties: { + email: { + type: "string", + example: "example@cal.com", + }, + name: { + type: "string", + }, + timeZone: { + type: "string", + example: "Europe/London", + }, + locale: { + type: "string", + example: "en", + }, + }, + }, + }, + }, + }, }, security: [{ ApiKeyAuth: [] }], tags: [