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>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import type { Prisma } from "@prisma/client";
|
|
import type { NextApiRequest } from "next";
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference";
|
|
|
|
/**
|
|
* @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
|
|
* responses:
|
|
* 200:
|
|
* description: OK
|
|
* 401:
|
|
* description: Authorization information is missing or invalid.
|
|
* 404:
|
|
* description: No booking references were found
|
|
*/
|
|
async function getHandler(req: NextApiRequest) {
|
|
const { userId, isAdmin, prisma } = req;
|
|
const args: Prisma.BookingReferenceFindManyArgs = isAdmin ? {} : { where: { booking: { userId } } };
|
|
const data = await prisma.bookingReference.findMany(args);
|
|
return { booking_references: data.map((br) => schemaBookingReferenceReadPublic.parse(br)) };
|
|
}
|
|
|
|
export default defaultResponder(getHandler);
|