Skip to content

Scheduling infrastructure for absolutely everyone.

Swagger definition general fixes (#237)

Syed Ali Shahbazf02cfc99906c
diff --git a/lib/validations/shared/queryIdTransformParseInt.ts b/lib/validations/shared/queryIdTransformParseInt.ts
index b97d126d43f..b9ec495f47b 100644
--- a/lib/validations/shared/queryIdTransformParseInt.ts
+++ b/lib/validations/shared/queryIdTransformParseInt.ts
@@ -5,14 +5,9 @@ import { baseApiParams } from "./baseApiParams";
// Extracted out as utility function so can be reused
// at different endpoints that require this validation.
-export const schemaQueryIdParseInt = baseApiParams
- .extend({
- id: z
- .string()
- .regex(/^\d+$/)
- .transform((id) => parseInt(id)),
- })
- .strict();
+export const schemaQueryIdParseInt = baseApiParams.extend({
+ id: z.coerce.number(),
+});
export const withValidQueryIdTransformParseInt = withValidation({
schema: schemaQueryIdParseInt,
diff --git a/pages/api/booking-references/[id]/_delete.ts b/pages/api/booking-references/[id]/_delete.ts
index 54160b01240..23a83ce311d 100644
--- a/pages/api/booking-references/[id]/_delete.ts
+++ b/pages/api/booking-references/[id]/_delete.ts
@@ -17,8 +17,14 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* type: integer
* required: true
* description: ID of the booking reference to delete
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
* tags:
- * - booking-references
+ * - booking-references
* responses:
* 201:
* description: OK, bookingReference removed successfully
diff --git a/pages/api/booking-references/[id]/_get.ts b/pages/api/booking-references/[id]/_get.ts
index 2ea3bd68c5e..6baf71a550d 100644
--- a/pages/api/booking-references/[id]/_get.ts
+++ b/pages/api/booking-references/[id]/_get.ts
@@ -18,8 +18,14 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* type: integer
* required: true
* description: ID of the booking reference to get
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
* tags:
- * - booking-references
+ * - booking-references
* responses:
* 200:
* description: OK
diff --git a/pages/api/booking-references/[id]/_patch.ts b/pages/api/booking-references/[id]/_patch.ts
index c2353702554..37e17e2e00b 100644
--- a/pages/api/booking-references/[id]/_patch.ts
+++ b/pages/api/booking-references/[id]/_patch.ts
@@ -23,16 +23,25 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* schema:
* type: object
* properties:
- * days:
- * type: array
- * example: [email protected]
- * startTime:
+ * type:
* type: string
- * example: 1970-01-01T17:00:00.000Z
- * endTime:
+ * meetingId:
* type: string
- * example: 1970-01-01T17:00:00.000Z
+ * meetingPassword:
+ * type: string
+ * externalCalendarId:
+ * type: string
+ * deleted:
+ * type: boolean
+ * credentialId:
+ * type: integer
* parameters:
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
* - in: path
* name: id
* schema:
@@ -40,10 +49,10 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* required: true
* description: ID of the booking reference to edit
* tags:
- * - booking-references
+ * - booking-references
* responses:
* 201:
- * description: OK, safeBody.data edited successfully
+ * description: OK, BookingReference edited successfully
* 400:
* description: Bad request. BookingReference body is invalid.
* 401:
diff --git a/pages/api/booking-references/_get.ts b/pages/api/booking-references/_get.ts
index 5934d4ef032..c3b81a46222 100644
--- a/pages/api/booking-references/_get.ts
+++ b/pages/api/booking-references/_get.ts
@@ -9,10 +9,17 @@ import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-refe
* @swagger
* /booking-references:
* get:
+ * parameters:
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
* operationId: listBookingReferences
* summary: Find all booking references
* tags:
- * - booking-references
+ * - booking-references
* responses:
* 200:
* description: OK
diff --git a/pages/api/booking-references/_post.ts b/pages/api/booking-references/_post.ts
index ff9f0109aa4..b3b8b713cff 100644
--- a/pages/api/booking-references/_post.ts
+++ b/pages/api/booking-references/_post.ts
@@ -12,6 +12,13 @@ import {
* @swagger
* /booking-references:
* post:
+ * parameters:
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
* operationId: addBookingReference
* summary: Creates a new booking reference
* requestBody:
@@ -24,27 +31,27 @@ import {
* required:
* - type
* - uid
- * - meetingId
- * - bookingId
- * - deleted
* properties:
- * deleted:
- * type: boolean
- * example: false
+ * type:
+ * type: string
* uid:
* type: string
- * example: '123456789'
- * type:
+ * meetingId:
+ * type: string
+ * meetingPassword:
+ * type: string
+ * meetingUrl:
* type: string
- * example: [email protected]
* bookingId:
- * type: number
- * example: 1
- * meetingId:
+ * type: boolean
+ * externalCalendarId:
* type: string
- * example: 'meeting-id'
+ * deleted:
+ * type: boolean
+ * credentialId:
+ * type: integer
* tags:
- * - booking-references
+ * - booking-references
* responses:
* 201:
* description: OK, booking reference created
diff --git a/pages/api/bookings/[id]/_delete.ts b/pages/api/bookings/[id]/_delete.ts
index c2bc3cf5d97..a1cdbc9c3ee 100644
--- a/pages/api/bookings/[id]/_delete.ts
+++ b/pages/api/bookings/[id]/_delete.ts
@@ -12,16 +12,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* delete:
* summary: Booking cancellation
* operationId: cancelBookingById
- * requestBody:
- * content:
- * application/json:
- * schema:
- * type: object
- * properties:
- * allRemainingBookings:
- * type: boolean
- * reason:
- * type: string
+ *
* parameters:
* - in: path
* name: id
@@ -29,24 +20,29 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* type: integer
* required: true
* description: ID of the booking to cancel
- * parameters:
- * - in: path
- * name: id
- * schema:
- * type: integer
- * required: true
- * description: ID of the booking to get
- * - in: query
- * name: apiKey
- * required: true
- * schema:
- * type: string
- * description: Your API key
+ * - in: query
+ * name: apiKey
+ * required: true
+ * schema:
+ * type: string
+ * description: Your API key
+ * - in: query
+ * name: allRemainingBookings
+ * required: false
+ * schema:
+ * type: boolean
+ * description: Delete all remaining bookings
+ * - in: query
+ * name: reason
+ * required: false
+ * schema:
+ * type: string
+ * description: The reason for cancellation of the booking
* tags:
* - bookings
* responses:
* 200:
- * description: OK, booking cancelled successfuly
+ * description: OK, booking cancelled successfully
* 400:
* description: |
* Bad request
@@ -72,11 +68,12 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: User not found
*/
async function handler(req: NextApiRequest) {
- const { id } = schemaQueryIdParseInt.parse(req.query);
- const { allRemainingBookings, cancellationReason } = schemaBookingCancelParams.parse({
- ...req.body,
- cancellationReason: req.body.reason,
- });
+ const { id, allRemainingBookings, cancellationReason } = schemaQueryIdParseInt
+ .merge(schemaBookingCancelParams.pick({ allRemainingBookings: true, cancellationReason: true }))
+ .parse({
+ ...req.query,
+ allRemainingBookings: req.query.allRemainingBookings === "true",
+ });
// Normalizing for universal handler
req.body = { id, allRemainingBookings, cancellationReason };
return await handleCancelBooking(req);
diff --git a/pages/api/bookings/_get.ts b/pages/api/bookings/_get.ts
index 9476d07e09f..a9158c22b38 100644
--- a/pages/api/bookings/_get.ts
+++ b/pages/api/bookings/_get.ts
@@ -19,21 +19,16 @@ import { schemaQuerySingleOrMultipleUserIds } from "~/lib/validations/shared/que
* schema:
* type: string
* description: Your API key
+ * - in: query
+ * name: userId
+ * required: false
+ * schema:
+ * oneOf:
+ * - type: integer
+ * - type: array
+ * items:
+ * type: integer
* operationId: listBookings
- * requestBody:
- * description: Find all bookings
- * content:
- * application/json:
- * schema:
- * type: object
- * properties:
- * userId:
- * description: 'The user(s) to get the booking for, if the request is by an Admin'
- * oneOf:
- * - type: integer
- * - type: array
- * items:
- * type: integer
* tags:
* - bookings
* responses:
diff --git a/pages/api/users/_post.ts b/pages/api/users/_post.ts
index 3ee8c222d5f..7c945399d00 100644
--- a/pages/api/users/_post.ts
+++ b/pages/api/users/_post.ts
@@ -46,7 +46,7 @@ import { schemaUserCreateBodyParams } from "~/lib/validations/user";
* description: Start of the week. Acceptable values are one of [SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY]
* type: string
* timeZone:
- * description: The new user's time zone. Eg: 'EUROPE/PARIS'
+ * description: The new user's time zone. Eg- 'EUROPE/PARIS'
* type: string
* theme:
* description: Default theme for the new user. Acceptable values are one of [DARK, LIGHT]