Swagger definition general fixes (#237)

This PR addresses definition errors currently residing within our
swagger doc.
 
~DISCLAIMER: There is still an error for our DELETE booking call, as
open API standard doesn't expect the DELETE call to contain a request
body, but we are requiring it in the way it currently works. Perhaps we
should move those to Query Parameters instead. Thoughts @zomars @emrysal
?~

It was taken care of by @leog and the docs are now updated as per the
endpoint

<img width="247" alt="image"
src="https://user-images.githubusercontent.com/52925846/217799706-21b7c21d-696b-4e20-a682-c8a949694b61.png">
<img width="629" alt="image"
src="https://user-images.githubusercontent.com/52925846/217799842-c903c23a-0b0d-4208-a3e9-01a682eeff97.png">

---------

Co-authored-by: Leo Giovanetti <hello@leog.me>
Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
authored and GitHub committed 2023-02-13 12:52:11 +00:00
1 parent fdb45e3745
commit f02cfc9990
9 files changed
+101 -79

No files matched your search

@@ -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,
+7 -1
View File
@@ -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
+7 -1
View File
@@ -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
+18 -9
View File
@@ -23,16 +23,25 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* schema:
* type: object
* properties:
* days:
* type: array
* example: email@example.com
* 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:
+8 -1
View File
@@ -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
+22 -15
View File
@@ -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
* uid:
* type: string
* example: '123456789'
* type:
* type: string
* example: email@example.com
* bookingId:
* type: number
* example: 1
* uid:
* type: string
* meetingId:
* type: string
* example: 'meeting-id'
* meetingPassword:
* type: string
* meetingUrl:
* type: string
* bookingId:
* type: boolean
* externalCalendarId:
* type: string
* deleted:
* type: boolean
* credentialId:
* type: integer
* tags:
* - booking-references
* - booking-references
* responses:
* 201:
* description: OK, booking reference created
+26 -29
View File
@@ -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);
+9 -14
View File
@@ -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:
+1 -1
View File
@@ -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]