Improves Booking docs in swagger (#219)

Adds definition to booking swagger definition, and fixes user _post
definition example
pull/9078/head
Syed Ali Shahbaz 2023-02-07 21:11:08 +05:30 committed by GitHub
parent 3517ef6adc
commit 279c3da21f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 183 additions and 33 deletions

View File

@ -29,6 +29,19 @@ 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
* tags:
* - bookings
* responses:
@ -36,11 +49,25 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: OK, booking cancelled successfuly
* 400:
* description: |
* Message | Cause
* :--|:--
* Booking not found| The provided id didn't correspond to any existing booking.
* Cannot cancel past events| The provided id matched an existing booking with a past startDate.
* User not found| The userId did not matched an existing user.
* Bad request
* <table>
* <tr>
* <td>Message</td>
* <td>Cause</td>
* </tr>
* <tr>
* <td>Booking not found</td>
* <td>The provided id didn't correspond to any existing booking.</td>
* </tr>
* <tr>
* <td>Cannot cancel past events</td>
* <td>The provided id matched an existing booking with a past startDate.</td>
* </tr>
* <tr>
* <td>User not found</td>
* <td>The userId did not matched an existing user.</td>
* </tr>
* </table>
* 404:
* description: User not found
*/

View File

@ -18,6 +18,12 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* type: integer
* required: true
* description: ID of the booking to get
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* tags:
* - bookings
* responses:

View File

@ -23,14 +23,53 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* properties:
* title:
* type: string
* example: 15min
* description: 'Booking event title'
* startTime:
* type: string
* example: 1970-01-01T17:00:00.000Z
* format: date-time
* description: 'Start time of the Event'
* endTime:
* type: string
* example: 1970-01-01T17:00:00.000Z
* format: date-time
* description: 'End time of the Event'
* recurringEventId:
* type: integer
* description: 'Recurring event ID if the event is recurring'
* description:
* type: string
* description: 'Event description'
* status:
* type: string
* description: 'Acceptable values one of ["ACCEPTED", "PENDING", "CANCELLED", "REJECTED"]'
* location:
* type: string
* description: 'Meeting location'
* smsReminderNumber:
* type: number
* description: 'SMS reminder number'
* attendees:
* type: array
* description: 'List of attendees of the booking'
* items:
* type: object
* properties:
* name:
* type: string
* email:
* type: string
* format: email
* timeZone:
* type: string
* locale:
* type: string
*
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* - in: path
* name: id
* schema:

View File

@ -12,7 +12,28 @@ import { schemaQuerySingleOrMultipleUserIds } from "~/lib/validations/shared/que
* /bookings:
* get:
* summary: Find all bookings
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* 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:

View File

@ -8,42 +8,99 @@ import { defaultResponder } from "@calcom/lib/server";
* /bookings:
* post:
* summary: Creates a new booking
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* operationId: addBooking
* requestBody:
* description: Edit an existing booking related to one of your event-types
* description: Create a new booking related to one of your event-types
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - startTime
* - endTime
* properties:
* title:
* type: string
* example: 15min
* description: 'Booking event title'
* startTime:
* type: string
* example: 1970-01-01T17:00:00.000Z
* format: date-time
* description: 'Start time of the Event'
* endTime:
* type: string
* example: 1970-01-01T17:00:00.000Z
* recurringCount:
* format: date-time
* description: 'End time of the Event'
* recurringEventId:
* type: integer
* description: 'Recurring event ID if the event is recurring'
* description:
* type: string
* description: 'Event description'
* status:
* type: string
* description: 'Acceptable values one of ["ACCEPTED", "PENDING", "CANCELLED", "REJECTED"]'
* location:
* type: string
* description: 'Meeting location'
* smsReminderNumber:
* type: number
* example: 8
* description: 'SMS reminder number'
* attendees:
* type: array
* description: 'List of attendees of the booking'
* items:
* type: object
* properties:
* name:
* type: string
* email:
* type: string
* format: email
* timeZone:
* type: string
* locale:
* type: string
*
* tags:
* - bookings
* - bookings
* responses:
* 201:
* description: Booking(s) created successfully.
* 400:
* description: |
* Message | Cause
* :--|:--
* Booking body is invalid| Missing property on booking entity.
* Invalid eventTypeId| The provided eventTypeId does not exist.
* Missing recurringCount| The eventType is recurring, and no recurringCount was passed.
* Invalid recurringCount| The provided recurringCount is greater than the eventType recurring config
* description: |
* Bad request
* <table>
* <tr>
* <td>Message</td>
* <td>Cause</td>
* </tr>
* <tr>
* <td>Booking body is invalid</td>
* <td>Missing property on booking entity.</td>
* </tr>
* <tr>
* <td>Invalid eventTypeId</td>
* <td>The provided eventTypeId does not exist.</td>
* </tr>
* <tr>
* <td>Missing recurringCount</td>
* <td>The eventType is recurring, and no recurringCount was passed.</td>
* </tr>
* <tr>
* <td>Invalid recurringCount</td>
* <td>The provided recurringCount is greater than the eventType recurring config</td>
* </tr>
* </table>
* 401:
* description: Authorization information is missing or invalid.
* description: Authorization information is missing or invalid.
*/
async function handler(req: NextApiRequest) {
const { userId, isAdmin } = req;

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
* 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]
@ -61,15 +61,15 @@ import { schemaUserCreateBodyParams } from "~/lib/validations/user";
* user:
* summary: An example of USER
* value:
* email: email@example.com
* username: johndoe
* weekStart: MONDAY
* brandColor: #555555
* darkBrandColor: #111111
* timeZone: EUROPE/PARIS
* theme: LIGHT
* timeFormat: TWELVE
* locale: FR
* email: 'email@example.com'
* username: 'johndoe'
* weekStart: 'MONDAY'
* brandColor: '#555555'
* darkBrandColor: '#111111'
* timeZone: 'EUROPE/PARIS'
* theme: 'LIGHT'
* timeFormat: 'TWELVE'
* locale: 'FR'
* tags:
* - users
* responses: