Updates Availability and Attendees swagger docs, hotfixes Booking API doc (#241)

- Adds swagger definition and swagger fixes to /availability and
/attendees
- Also fixes Booking API endpoint definition (startTime -> start,
endTime -> end)
pull/9078/head
Syed Ali Shahbaz 2023-03-10 19:29:24 +05:30 committed by GitHub
parent 59c25d41fd
commit e54e1aa72e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 106 additions and 24 deletions

View File

@ -11,6 +11,12 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* operationId: removeAttendeeById * operationId: removeAttendeeById
* summary: Remove an existing attendee * summary: Remove an existing attendee
* parameters: * parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* - in: path * - in: path
* name: id * name: id
* schema: * schema:
@ -21,7 +27,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* - attendees * - attendees
* responses: * responses:
* 201: * 201:
* description: OK, attendee removed successfuly * description: OK, attendee removed successfully
* 400: * 400:
* description: Bad request. Attendee id is invalid. * description: Bad request. Attendee id is invalid.
* 401: * 401:

View File

@ -12,13 +12,18 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* operationId: getAttendeeById * operationId: getAttendeeById
* summary: Find an attendee * summary: Find an attendee
* parameters: * parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* - in: path * - in: path
* name: id * name: id
* schema: * schema:
* type: integer * type: integer
* required: true * required: true
* description: ID of the attendee to get * description: ID of the attendee to get
* example: 3
* tags: * tags:
* - attendees * - attendees
* responses: * responses:

View File

@ -11,8 +11,8 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* @swagger * @swagger
* /attendees/{id}: * /attendees/{id}:
* patch: * patch:
* summary: Edit an existing attendee
* operationId: editAttendeeById * operationId: editAttendeeById
* summary: Edit an existing attendee
* requestBody: * requestBody:
* description: Edit an existing attendee related to one of your bookings * description: Edit an existing attendee related to one of your bookings
* required: true * required: true
@ -23,31 +23,35 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* properties: * properties:
* email: * email:
* type: string * type: string
* example: email@example.com * format: email
* name: * name:
* type: string * type: string
* example: John Doe
* timeZone: * timeZone:
* type: string * type: string
* example: Europe/London
* parameters: * parameters:
* - in: path * - in: query
* name: id * name: apiKey
* schema: * required: true
* type: integer * schema:
* example: 3 * type: string
* required: true * description: Your API key
* description: ID of the attendee to edit * - in: path
* name: id
* schema:
* type: integer
* required: true
* description: ID of the attendee to get
* tags: * tags:
* - attendees * - attendees
* responses: * responses:
* 201: * 201:
* description: OK, attendee edited successfuly * description: OK, attendee edited successfully
* 400: * 400:
* description: Bad request. Attendee body is invalid. * description: Bad request. Attendee body is invalid.
* 401: * 401:
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function patchHandler(req: NextApiRequest) { export async function patchHandler(req: NextApiRequest) {
const { prisma, query, body } = req; const { prisma, query, body } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);

View File

@ -12,6 +12,13 @@ import { schemaAttendeeReadPublic } from "~/lib/validations/attendee";
* get: * get:
* operationId: listAttendees * operationId: listAttendees
* summary: Find all attendees * summary: Find all attendees
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* tags: * tags:
* - attendees * - attendees
* responses: * responses:

View File

@ -11,6 +11,13 @@ import { schemaAttendeeCreateBodyParams, schemaAttendeeReadPublic } from "~/lib/
* post: * post:
* operationId: addAttendee * operationId: addAttendee
* summary: Creates a new attendee * summary: Creates a new attendee
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* requestBody: * requestBody:
* description: Create a new attendee related to one of your bookings * description: Create a new attendee related to one of your bookings
* required: true * required: true
@ -26,16 +33,13 @@ import { schemaAttendeeCreateBodyParams, schemaAttendeeReadPublic } from "~/lib/
* properties: * properties:
* bookingId: * bookingId:
* type: number * type: number
* example: 1
* email: * email:
* type: string * type: string
* example: email@example.com * format: email
* name: * name:
* type: string * type: string
* example: John Doe
* timeZone: * timeZone:
* type: string * type: string
* example: Europe/London
* tags: * tags:
* - attendees * - attendees
* responses: * responses:

View File

@ -7,6 +7,62 @@ import { defaultResponder } from "@calcom/lib/server";
import { availabilityUserSelect } from "@calcom/prisma"; import { availabilityUserSelect } from "@calcom/prisma";
import { stringOrNumber } from "@calcom/prisma/zod-utils"; import { stringOrNumber } from "@calcom/prisma/zod-utils";
/**
* @swagger
* /availability:
* get:
* summary: Find user or team availability
* parameters:
* - in: query
* name: apiKey
* required: true
* schema:
* type: string
* description: Your API key
* - in: query
* name: userId
* schema:
* type: integer
* description: ID of the user to fetch the availability for
* - in: query
* name: teamId
* schema:
* type: integer
* description: ID of the team to fetch the availability for
* - in: query
* name: username
* schema:
* type: string
* description: username of the user to fetch the availability for
* - in: query
* name: dateFrom
* schema:
* type: string
* format: date
* description: Start Date of the availability query
* - in: query
* name: dateTo
* schema:
* type: string
* format: date
* description: End Date of the availability query
* - in: query
* name: eventTypeId
* schema:
* type: integer
* description: Event Type ID of the event type to fetch the availability for
* operationId: availability
* tags:
* - availability
* responses:
* 200:
* description: OK
* 401:
* description: Authorization information is missing or invalid.
* 404:
* description: User not found | Team not found | Team has no members
*/
const availabilitySchema = z const availabilitySchema = z
.object({ .object({
userId: stringOrNumber.optional(), userId: stringOrNumber.optional(),

View File

@ -24,11 +24,11 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* title: * title:
* type: string * type: string
* description: 'Booking event title' * description: 'Booking event title'
* startTime: * start:
* type: string * type: string
* format: date-time * format: date-time
* description: 'Start time of the Event' * description: 'Start time of the Event'
* endTime: * end:
* type: string * type: string
* format: date-time * format: date-time
* description: 'End time of the Event' * description: 'End time of the Event'

View File

@ -24,17 +24,17 @@ import { defaultResponder } from "@calcom/lib/server";
* schema: * schema:
* type: object * type: object
* required: * required:
* - startTime * - start
* - endTime * - end
* properties: * properties:
* title: * title:
* type: string * type: string
* description: 'Booking event title' * description: 'Booking event title'
* startTime: * start:
* type: string * type: string
* format: date-time * format: date-time
* description: 'Start time of the Event' * description: 'Start time of the Event'
* endTime: * end:
* type: string * type: string
* format: date-time * format: date-time
* description: 'End time of the Event' * description: 'End time of the Event'