Skip to content

Scheduling infrastructure for absolutely everyone.

Swagger/booking req resp body (#256)

Syed Ali Shahbazd5db1e417129
diff --git a/pages/api/bookings/[id]/_get.ts b/pages/api/bookings/[id]/_get.ts
index 2d6ae07a647..5064ba2d78f 100644
--- a/pages/api/bookings/[id]/_get.ts
+++ b/pages/api/bookings/[id]/_get.ts
@@ -32,7 +32,29 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* content:
* application/json:
* schema:
- * $ref: "#/components/schemas/Booking"
+ * $ref: "#/components/schemas/ArrayOfBookings"
+ * examples:
+ * bookings:
+ * value: [
+ * {
+ * "id": 1,
+ * "description": "Meeting with John",
+ * "eventTypeId": 2,
+ * "uid": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8",
+ * "title": "Business Meeting",
+ * "startTime": "2023-04-20T10:00:00.000Z",
+ * "endTime": "2023-04-20T11:00:00.000Z",
+ * "timeZone": "Europe/London",
+ * "attendees": [
+ * {
+ * "email": "[email protected]",
+ * "name": "John Doe",
+ * "timeZone": "Europe/London",
+ * "locale": "en"
+ * }
+ * ]
+ * }
+ * ]
* 401:
* description: Authorization information is missing or invalid.
* 404:
diff --git a/pages/api/bookings/[id]/_patch.ts b/pages/api/bookings/[id]/_patch.ts
index 8c1638e2a49..74999ab13c9 100644
--- a/pages/api/bookings/[id]/_patch.ts
+++ b/pages/api/bookings/[id]/_patch.ts
@@ -35,6 +35,15 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* status:
* type: string
* description: 'Acceptable values one of ["ACCEPTED", "PENDING", "CANCELLED", "REJECTED"]'
+ * examples:
+ * editBooking:
+ * value:
+ * {
+ * "title": "Debugging between Syed Ali Shahbaz and Hello Hello",
+ * "start": "2023-05-24T13:00:00.000Z",
+ * "end": "2023-05-24T13:30:00.000Z",
+ * "status": "CANCELLED"
+ * }
*
* parameters:
* - in: query
@@ -52,8 +61,27 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* tags:
* - bookings
* responses:
- * 201:
+ * 200:
* description: OK, booking edited successfully
+ * content:
+ * application/json:
+ * examples:
+ * bookings:
+ * value:
+ * {
+ * "booking": {
+ * "id": 11223344,
+ * "userId": 182,
+ * "description": null,
+ * "eventTypeId": 2323232,
+ * "uid": "stoSJtnh83PEL4rZmqdHe2",
+ * "title": "Debugging between Syed Ali Shahbaz and Hello Hello",
+ * "startTime": "2023-05-24T13:00:00.000Z",
+ * "endTime": "2023-05-24T13:30:00.000Z",
+ * "metadata": {},
+ * "status": "CANCELLED"
+ * }
+ * }
* 400:
* description: Bad request. Booking body is invalid.
* 401:
diff --git a/pages/api/bookings/_get.ts b/pages/api/bookings/_get.ts
index e610f421038..006b39472e7 100644
--- a/pages/api/bookings/_get.ts
+++ b/pages/api/bookings/_get.ts
@@ -19,15 +19,18 @@ import { schemaQuerySingleOrMultipleUserIds } from "~/lib/validations/shared/que
* schema:
* type: string
* description: Your API key
+ * example: 123456789abcdefgh
* - in: query
* name: userId
* required: false
* schema:
* oneOf:
* - type: integer
+ * example: 1
* - type: array
* items:
* type: integer
+ * example: [2, 3, 4]
* operationId: listBookings
* tags:
* - bookings
@@ -38,11 +41,34 @@ import { schemaQuerySingleOrMultipleUserIds } from "~/lib/validations/shared/que
* application/json:
* schema:
* $ref: "#/components/schemas/ArrayOfBookings"
+ * examples:
+ * bookings:
+ * value: [
+ * {
+ * "id": 1,
+ * "description": "Meeting with John",
+ * "eventTypeId": 2,
+ * "uid": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8",
+ * "title": "Business Meeting",
+ * "startTime": "2023-04-20T10:00:00.000Z",
+ * "endTime": "2023-04-20T11:00:00.000Z",
+ * "timeZone": "Europe/London",
+ * "attendees": [
+ * {
+ * "email": "[email protected]",
+ * "name": "John Doe",
+ * "timeZone": "Europe/London",
+ * "locale": "en"
+ * }
+ * ]
+ * }
+ * ]
* 401:
- * description: Authorization information is missing or invalid.
+ * description: Authorization information is missing or invalid.
* 404:
* description: No bookings were found
*/
+
async function handler(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req;
const args: Prisma.BookingFindManyArgs = {};
diff --git a/pages/api/bookings/_post.ts b/pages/api/bookings/_post.ts
index 3f9c17978dd..d6baaa48918 100644
--- a/pages/api/bookings/_post.ts
+++ b/pages/api/bookings/_post.ts
@@ -90,27 +90,82 @@ import { defaultResponder } from "@calcom/lib/server";
* smsReminderNumber:
* type: number
* description: 'SMS reminder number'
- * examples:
- * New Booking example:
- * value:
- * {
- * "eventTypeId": 1,
- * "start": "2023-05-01T14:00:00Z",
- * "end": "2023-05-01T15:00:00Z",
- * "name": "John Doe",
- * "email": "[email protected]",
- * "timeZone": "America/New_York",
- * "language": "en-US",
- * "metadata": {},
- * "customInputs": [],
- * "location": "Conference Room A"
- * }
+ * examples:
+ * New Booking example:
+ * value:
+ * {
+ * "eventTypeId": 2323232,
+ * "start": "2023-05-24T13:00:00.000Z",
+ * "end": "2023-05-24T13:30:00.000Z",
+ * "name": "Hello Hello",
+ * "email": "[email protected]",
+ * "timeZone": "Europe/London",
+ * "language": "en",
+ * "metadata": {},
+ * "customInputs": [],
+ * "location": "Calcom HQ",
+ * "title": "Debugging between Syed Ali Shahbaz and Hello Hello",
+ * "description": null,
+ * "status": "PENDING",
+ * "smsReminderNumber": null
+ * }
*
* tags:
* - bookings
* responses:
- * 201:
+ * 200:
* description: Booking(s) created successfully.
+ * content:
+ * application/json:
+ * examples:
+ * bookings:
+ * value:
+ * {
+ * "id": 11223344,
+ * "uid": "5yUjmAYTDF6MXo98re8SkX",
+ * "userId": 123,
+ * "eventTypeId": 2323232,
+ * "title": "Debugging between Syed Ali Shahbaz and Hello Hello",
+ * "description": null,
+ * "customInputs": {},
+ * "responses": null,
+ * "startTime": "2023-05-24T13:00:00.000Z",
+ * "endTime": "2023-05-24T13:30:00.000Z",
+ * "location": "Calcom HQ",
+ * "createdAt": "2023-04-19T10:17:58.580Z",
+ * "updatedAt": null,
+ * "status": "PENDING",
+ * "paid": false,
+ * "destinationCalendarId": 2180,
+ * "cancellationReason": null,
+ * "rejectionReason": null,
+ * "dynamicEventSlugRef": null,
+ * "dynamicGroupSlugRef": null,
+ * "rescheduled": null,
+ * "fromReschedule": null,
+ * "recurringEventId": null,
+ * "smsReminderNumber": null,
+ * "scheduledJobs": [],
+ * "metadata": {},
+ * "isRecorded": false,
+ * "user": {
+ * "email": "[email protected]",
+ * "name": "Syed Ali Shahbaz",
+ * "timeZone": "Asia/Calcutta"
+ * },
+ * "attendees": [
+ * {
+ * "id": 12345,
+ * "email": "[email protected]",
+ * "name": "Hello Hello",
+ * "timeZone": "Europe/London",
+ * "locale": "en",
+ * "bookingId": 11223344
+ * }
+ * ],
+ * "payment": [],
+ * "references": []
+ * }
* 400:
* description: |
* Bad request