diff --git a/packages/medusa/src/api/routes/admin/discounts/add-region.ts b/packages/medusa/src/api/routes/admin/discounts/add-region.ts index 2a2ba418ee..75e00408db 100644 --- a/packages/medusa/src/api/routes/admin/discounts/add-region.ts +++ b/packages/medusa/src/api/routes/admin/discounts/add-region.ts @@ -40,10 +40,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts b/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts index b500deadac..8c6775bd2b 100644 --- a/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts +++ b/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts @@ -58,10 +58,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/create-condition.ts b/packages/medusa/src/api/routes/admin/discounts/create-condition.ts index b2fe4c28aa..b42785d859 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-condition.ts @@ -57,10 +57,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/create-discount.ts b/packages/medusa/src/api/routes/admin/discounts/create-discount.ts index cc7d53fd7e..7e8a13fbb6 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-discount.ts @@ -87,10 +87,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts b/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts index 8ddd5d5df8..b152e4867a 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts @@ -56,10 +56,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts b/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts index 1877be1fb2..a61af2418d 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts @@ -42,22 +42,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted DiscountCondition - * object: - * type: string - * description: The type of the object that was deleted. - * default: discount-condition - * deleted: - * type: boolean - * description: Whether the discount condition was deleted successfully or not. - * default: true - * discount: - * description: The Discount to which the condition used to belong - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountConditionsDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts b/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts index d6fda3fad1..d67e37157a 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts @@ -36,19 +36,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted Discount - * object: - * type: string - * description: The type of the object that was deleted. - * default: discount - * deleted: - * type: boolean - * description: Whether the discount was deleted successfully or not. - * default: true + * $ref: "#/components/schemas/AdminDiscountsDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts b/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts index 798fa81b0e..972e72d963 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts @@ -39,10 +39,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts b/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts index a2064606db..21c5d4826f 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts @@ -57,10 +57,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/get-condition.ts b/packages/medusa/src/api/routes/admin/discounts/get-condition.ts index b16837e066..76ea22dfad 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-condition.ts @@ -40,10 +40,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount_condition: - * $ref: "#/components/schemas/DiscountCondition" + * $ref: "#/components/schemas/AdminDiscountConditionsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts b/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts index 244fdef28a..83f1dae940 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts @@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/get-discount.ts b/packages/medusa/src/api/routes/admin/discounts/get-discount.ts index 410d8154cf..24b413d55a 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-discount.ts @@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/index.ts b/packages/medusa/src/api/routes/admin/discounts/index.ts index b47dee753d..890a010db9 100644 --- a/packages/medusa/src/api/routes/admin/discounts/index.ts +++ b/packages/medusa/src/api/routes/admin/discounts/index.ts @@ -220,16 +220,87 @@ export const defaultAdminDiscountConditionFields: (keyof DiscountCondition)[] = export const defaultAdminDiscountConditionRelations = ["discount_rule"] +/** + * @schema AdminDiscountsRes + * type: object + * properties: + * discount: + * $ref: "#/components/schemas/Discount" + */ export type AdminDiscountsRes = { discount: Discount } +/** + * @schema AdminDiscountConditionsRes + * type: object + * properties: + * discount_condition: + * $ref: "#/components/schemas/DiscountCondition" + */ export type AdminDiscountConditionsRes = { discount_condition: DiscountCondition } +/** + * @schema AdminDiscountsDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted Discount + * object: + * type: string + * description: The type of the object that was deleted. + * default: discount + * deleted: + * type: boolean + * description: Whether the discount was deleted successfully or not. + * default: true + */ export type AdminDiscountsDeleteRes = DeleteResponse +/** + * @schema AdminDiscountConditionsDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted DiscountCondition + * object: + * type: string + * description: The type of the object that was deleted. + * default: discount-condition + * deleted: + * type: boolean + * description: Whether the discount condition was deleted successfully or not. + * default: true + * discount: + * description: The Discount to which the condition used to belong + * $ref: "#/components/schemas/Discount" + */ +export type AdminDiscountConditionsDeleteRes = DeleteResponse & { + discount: Discount +} + +/** + * @schema AdminDiscountsListRes + * type: object + * properties: + * discounts: + * type: array + * items: + * $ref: "#/components/schemas/Discount" + * count: + * type: integer + * description: The total number of items available + * offset: + * type: integer + * description: The number of items skipped before these items + * limit: + * type: integer + * description: The number of items per page + */ export type AdminDiscountsListRes = PaginatedResponse & { discounts: Discount[] } diff --git a/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts b/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts index 3dba4001db..39cdddcbc0 100644 --- a/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts +++ b/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts @@ -66,21 +66,7 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean" * content: * application/json: * schema: - * type: object - * properties: - * discounts: - * type: array - * items: - * $ref: "#/components/schemas/Discount" - * count: - * type: integer - * description: The total number of items available - * offset: - * type: integer - * description: The number of items skipped before these items - * limit: - * type: integer - * description: The number of items per page + * $ref: "#/components/schemas/AdminDiscountsListRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/remove-region.ts b/packages/medusa/src/api/routes/admin/discounts/remove-region.ts index 15b5b2ca78..402fbb3d1e 100644 --- a/packages/medusa/src/api/routes/admin/discounts/remove-region.ts +++ b/packages/medusa/src/api/routes/admin/discounts/remove-region.ts @@ -39,10 +39,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/update-condition.ts b/packages/medusa/src/api/routes/admin/discounts/update-condition.ts index ff13b3fd77..b772a4805d 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-condition.ts @@ -58,10 +58,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/discounts/update-discount.ts b/packages/medusa/src/api/routes/admin/discounts/update-discount.ts index 7cbe9dda79..c1a8896759 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-discount.ts @@ -70,10 +70,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * discount: - * $ref: "#/components/schemas/Discount" + * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts index 0e8c6d88de..353c002130 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts @@ -92,10 +92,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts index 81604a1a3f..b5603fef6e 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts @@ -60,10 +60,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts index 29dad814d4..665ed0abca 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts @@ -1,5 +1,6 @@ import { DraftOrderService } from "../../../../services" import { EntityManager } from "typeorm" + /** * @oas [delete] /draft-orders/{id} * operationId: DeleteDraftOrdersDraftOrder @@ -35,19 +36,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted Draft Order. - * object: - * type: string - * description: The type of the object that was deleted. - * default: draft-order - * deleted: - * type: boolean - * description: Whether the draft order was deleted successfully or not. - * default: true + * $ref: "#/components/schemas/AdminDraftOrdersDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts index aa9dc5dc59..52c1e0d7c6 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts @@ -45,10 +45,7 @@ import { MedusaError } from "medusa-core-utils" * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts index f4936f4d7c..e07c96e246 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts @@ -43,10 +43,7 @@ import { DraftOrder } from "../../../.." * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/index.ts b/packages/medusa/src/api/routes/admin/draft-orders/index.ts index 28cc344189..e518b20322 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/index.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/index.ts @@ -91,16 +91,64 @@ export const defaultAdminDraftOrdersFields: (keyof DraftOrder)[] = [ "no_notification_order", ] +/** + * @schema AdminPostDraftOrdersDraftOrderRegisterPaymentRes + * type: object + * properties: + * order: + * $ref: "#/components/schemas/Order" + */ export type AdminPostDraftOrdersDraftOrderRegisterPaymentRes = { order: Order } +/** + * @schema AdminDraftOrdersRes + * type: object + * properties: + * draft_order: + * $ref: "#/components/schemas/DraftOrder" + */ export type AdminDraftOrdersRes = { draft_order: DraftOrder } +/** + * @schema AdminDraftOrdersDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted Draft Order. + * object: + * type: string + * description: The type of the object that was deleted. + * default: draft-order + * deleted: + * type: boolean + * description: Whether the draft order was deleted successfully or not. + * default: true + */ export type AdminDraftOrdersDeleteRes = DeleteResponse +/** + * @schema AdminDraftOrdersListRes + * type: object + * properties: + * draft_orders: + * type: array + * items: + * $ref: "#/components/schemas/DraftOrder" + * count: + * type: integer + * description: The total number of items available + * offset: + * type: integer + * description: The number of items skipped before these items + * limit: + * type: integer + * description: The number of items per page + */ export type AdminDraftOrdersListRes = PaginatedResponse & { draft_orders: DraftOrder[] } diff --git a/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts b/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts index c3e5d194de..8f0874e24d 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts @@ -48,21 +48,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * draft_orders: - * type: array - * items: - * $ref: "#/components/schemas/DraftOrder" - * count: - * type: integer - * description: The total number of items available - * offset: - * type: integer - * description: The number of items skipped before these items - * limit: - * type: integer - * description: The number of items per page + * $ref: "#/components/schemas/AdminDraftOrdersListRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts b/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts index bbf6f95150..88509b5751 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts @@ -46,10 +46,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderRegisterPaymentRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts index 31df2b1732..abe861d379 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts @@ -66,10 +66,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts index 720c22c6eb..db4d83ab7f 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts @@ -59,10 +59,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * draft_order: - * $ref: "#/components/schemas/DraftOrder" + * $ref: "#/components/schemas/AdminDraftOrdersRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/gift-cards/create-gift-card.ts b/packages/medusa/src/api/routes/admin/gift-cards/create-gift-card.ts index dfbb06e7b5..b68b704521 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/create-gift-card.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/create-gift-card.ts @@ -49,10 +49,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * gift_card: - * $ref: "#/components/schemas/GiftCard" + * $ref: "#/components/schemas/AdminGiftCardsRes" * "400": * $ref: "#/components/responses/400_error" * "401": @@ -67,13 +64,16 @@ import { EntityManager } from "typeorm" * $ref: "#/components/responses/500_error" */ export default async (req, res) => { - const validatedBody: AdminPostGiftCardsReq & { balance?: number } = req.validatedBody + const validatedBody: AdminPostGiftCardsReq & { balance?: number } = + req.validatedBody validatedBody.balance = validatedBody.value const giftCardService: GiftCardService = req.scope.resolve("giftCardService") const manager: EntityManager = req.scope.resolve("manager") const newly = await manager.transaction(async (transactionManager) => { - return await giftCardService.withTransaction(transactionManager).create(validatedBody) + return await giftCardService + .withTransaction(transactionManager) + .create(validatedBody) }) const giftCard = await giftCardService.retrieve(newly.id, { diff --git a/packages/medusa/src/api/routes/admin/gift-cards/delete-gift-card.ts b/packages/medusa/src/api/routes/admin/gift-cards/delete-gift-card.ts index cf9dade9f3..899fceb9bb 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/delete-gift-card.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/delete-gift-card.ts @@ -35,19 +35,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted Gift Card - * object: - * type: string - * description: The type of the object that was deleted. - * default: gift-card - * deleted: - * type: boolean - * description: Whether the gift card was deleted successfully or not. - * default: true + * $ref: "#/components/schemas/AdminGiftCardsDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/gift-cards/get-gift-card.ts b/packages/medusa/src/api/routes/admin/gift-cards/get-gift-card.ts index 356fdb5761..266f9b6d2a 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/get-gift-card.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/get-gift-card.ts @@ -35,10 +35,7 @@ import { defaultAdminGiftCardFields, defaultAdminGiftCardRelations } from "./" * content: * application/json: * schema: - * type: object - * properties: - * gift_card: - * $ref: "#/components/schemas/GiftCard" + * $ref: "#/components/schemas/AdminGiftCardsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/gift-cards/index.ts b/packages/medusa/src/api/routes/admin/gift-cards/index.ts index 10b284d576..bba23875ef 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/index.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/index.ts @@ -2,9 +2,12 @@ import { Router } from "express" import "reflect-metadata" import { GiftCard } from "../../../.." import { DeleteResponse, PaginatedResponse } from "../../../../types/common" -import middlewares, { transformQuery, transformBody } from "../../../middlewares" +import middlewares, { + transformBody, + transformQuery, +} from "../../../middlewares" import { AdminGetGiftCardsParams } from "./list-gift-cards" -import { AdminPostGiftCardsReq } from './create-gift-card' +import { AdminPostGiftCardsReq } from "./create-gift-card" const route = Router() @@ -53,12 +56,53 @@ export const defaultAdminGiftCardFields: (keyof GiftCard)[] = [ export const defaultAdminGiftCardRelations = ["region", "order"] +/** + * @schema AdminGiftCardsRes + * type: object + * properties: + * gift_card: + * $ref: "#/components/schemas/GiftCard" + */ export type AdminGiftCardsRes = { gift_card: GiftCard } +/** + * @schema AdminGiftCardsDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted Gift Card + * object: + * type: string + * description: The type of the object that was deleted. + * default: gift-card + * deleted: + * type: boolean + * description: Whether the gift card was deleted successfully or not. + * default: true + */ export type AdminGiftCardsDeleteRes = DeleteResponse +/** + * @schema AdminGiftCardsListRes + * type: object + * properties: + * gift_cards: + * type: array + * items: + * $ref: "#/components/schemas/GiftCard" + * count: + * type: integer + * description: The total number of items available + * offset: + * type: integer + * description: The number of items skipped before these items + * limit: + * type: integer + * description: The number of items per page + */ export type AdminGiftCardsListRes = PaginatedResponse & { gift_cards: GiftCard[] } diff --git a/packages/medusa/src/api/routes/admin/gift-cards/list-gift-cards.ts b/packages/medusa/src/api/routes/admin/gift-cards/list-gift-cards.ts index 0d057b120c..696a94bd4a 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/list-gift-cards.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/list-gift-cards.ts @@ -43,21 +43,7 @@ import { isDefined } from "medusa-core-utils" * content: * application/json: * schema: - * type: object - * properties: - * gift_cards: - * type: array - * items: - * $ref: "#/components/schemas/GiftCard" - * count: - * type: integer - * description: The total number of items available - * offset: - * type: integer - * description: The number of items skipped before these items - * limit: - * type: integer - * description: The number of items per page + * $ref: "#/components/schemas/AdminGiftCardsListRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.ts b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.ts index 771a8dc50a..04f2d010c0 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.ts +++ b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.ts @@ -52,10 +52,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * gift_card: - * $ref: "#/components/schemas/GiftCard" + * $ref: "#/components/schemas/AdminGiftCardsRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/invites/delete-invite.ts b/packages/medusa/src/api/routes/admin/invites/delete-invite.ts index 6eb4ef3433..e6af121cca 100644 --- a/packages/medusa/src/api/routes/admin/invites/delete-invite.ts +++ b/packages/medusa/src/api/routes/admin/invites/delete-invite.ts @@ -4,8 +4,8 @@ import InviteService from "../../../../services/invite" /** * @oas [delete] /invites/{invite_id} * operationId: "DeleteInvitesInvite" - * summary: "Create an Invite" - * description: "Creates an Invite and triggers an 'invite' created event" + * summary: "Delete an Invite" + * description: "Deletes an Invite" * x-authenticated: true * parameters: * - (path) invite_id=* {string} The ID of the Invite @@ -36,19 +36,7 @@ import InviteService from "../../../../services/invite" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted Invite. - * object: - * type: string - * description: The type of the object that was deleted. - * format: invite - * deleted: - * type: boolean - * description: Whether or not the Invite was deleted. - * default: true + * $ref: "#/components/schemas/AdminInviteDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/invites/index.ts b/packages/medusa/src/api/routes/admin/invites/index.ts index b72bbc1ab9..74581b0057 100644 --- a/packages/medusa/src/api/routes/admin/invites/index.ts +++ b/packages/medusa/src/api/routes/admin/invites/index.ts @@ -32,8 +32,33 @@ export default (app) => { return app } +/** + * @schema AdminInviteDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted Invite. + * object: + * type: string + * description: The type of the object that was deleted. + * default: invite + * deleted: + * type: boolean + * description: Whether or not the Invite was deleted. + * default: true + */ export type AdminInviteDeleteRes = DeleteResponse +/** + * @schema AdminListInvitesRes + * type: object + * properties: + * invites: + * type: array + * items: + * $ref: "#/components/schemas/Invite" + */ export type AdminListInvitesRes = { invites: Invite[] } diff --git a/packages/medusa/src/api/routes/admin/invites/list-invites.ts b/packages/medusa/src/api/routes/admin/invites/list-invites.ts index 572e65e657..4d7a3188ce 100644 --- a/packages/medusa/src/api/routes/admin/invites/list-invites.ts +++ b/packages/medusa/src/api/routes/admin/invites/list-invites.ts @@ -33,12 +33,7 @@ import InviteService from "../../../../services/invite" * content: * application/json: * schema: - * type: object - * properties: - * invites: - * type: array - * items: - * $ref: "#/components/schemas/Invite" + * $ref: "#/components/schemas/AdminListInvitesRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notes/create-note.ts b/packages/medusa/src/api/routes/admin/notes/create-note.ts index 523100bc52..bf3f54879e 100644 --- a/packages/medusa/src/api/routes/admin/notes/create-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/create-note.ts @@ -52,10 +52,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * note: - * $ref: "#/components/schemas/Note" + * $ref: "#/components/schemas/AdminNotesRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notes/delete-note.ts b/packages/medusa/src/api/routes/admin/notes/delete-note.ts index 5a23b3da09..ecac0f42e2 100644 --- a/packages/medusa/src/api/routes/admin/notes/delete-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/delete-note.ts @@ -36,19 +36,7 @@ import NoteService from "../../../../services/note" * content: * application/json: * schema: - * type: object - * properties: - * id: - * type: string - * description: The ID of the deleted Note. - * object: - * type: string - * description: The type of the object that was deleted. - * default: note - * deleted: - * type: boolean - * description: Whether or not the Note was deleted. - * default: true + * $ref: "#/components/schemas/AdminNotesDeleteRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notes/get-note.ts b/packages/medusa/src/api/routes/admin/notes/get-note.ts index 4705a62a8c..af78c2ec79 100644 --- a/packages/medusa/src/api/routes/admin/notes/get-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/get-note.ts @@ -35,10 +35,7 @@ import NoteService from "../../../../services/note" * content: * application/json: * schema: - * type: object - * properties: - * note: - * $ref: "#/components/schemas/Note" + * $ref: "#/components/schemas/AdminNotesRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notes/index.ts b/packages/medusa/src/api/routes/admin/notes/index.ts index 7bd7de88a0..dec875734f 100644 --- a/packages/medusa/src/api/routes/admin/notes/index.ts +++ b/packages/medusa/src/api/routes/admin/notes/index.ts @@ -22,12 +22,53 @@ export default (app) => { return app } +/** + * @schema AdminNotesRes + * type: object + * properties: + * note: + * $ref: "#/components/schemas/Note" + */ export type AdminNotesRes = { note: Note } +/** + * @schema AdminNotesDeleteRes + * type: object + * properties: + * id: + * type: string + * description: The ID of the deleted Note. + * object: + * type: string + * description: The type of the object that was deleted. + * default: note + * deleted: + * type: boolean + * description: Whether or not the Note was deleted. + * default: true + */ export type AdminNotesDeleteRes = DeleteResponse +/** + * @schema AdminNotesListRes + * type: object + * properties: + * notes: + * type: array + * items: + * $ref: "#/components/schemas/Note" + * count: + * type: integer + * description: The total number of items available + * offset: + * type: integer + * description: The number of items skipped before these items + * limit: + * type: integer + * description: The number of items per page + */ export type AdminNotesListRes = PaginatedResponse & { notes: Note[] } diff --git a/packages/medusa/src/api/routes/admin/notes/list-notes.ts b/packages/medusa/src/api/routes/admin/notes/list-notes.ts index ea77cfa9d1..33acf8ef1c 100644 --- a/packages/medusa/src/api/routes/admin/notes/list-notes.ts +++ b/packages/medusa/src/api/routes/admin/notes/list-notes.ts @@ -42,21 +42,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * notes: - * type: array - * items: - * $ref: "#/components/schemas/Note" - * count: - * type: integer - * description: The total number of items available - * offset: - * type: integer - * description: The number of items skipped before these items - * limit: - * type: integer - * description: The number of items per page + * $ref: "#/components/schemas/AdminNotesListRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notes/update-note.ts b/packages/medusa/src/api/routes/admin/notes/update-note.ts index 56b37935c6..3adbdb0b7c 100644 --- a/packages/medusa/src/api/routes/admin/notes/update-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/update-note.ts @@ -49,10 +49,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * note: - * $ref: "#/components/schemas/Note" + * $ref: "#/components/schemas/AdminNotesRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notifications/index.ts b/packages/medusa/src/api/routes/admin/notifications/index.ts index 67d158faaf..beafbd8fd0 100644 --- a/packages/medusa/src/api/routes/admin/notifications/index.ts +++ b/packages/medusa/src/api/routes/admin/notifications/index.ts @@ -36,10 +36,26 @@ export const defaultAdminNotificationsFields = [ "updated_at", ] +/** + * @schema AdminNotificationsListRes + * type: object + * properties: + * notifications: + * type: array + * items: + * $ref: "#/components/schemas/Notification" + */ export type AdminNotificationsListRes = { notifications: Notification[] } +/** + * @schema AdminNotificationsRes + * type: object + * properties: + * notification: + * $ref: "#/components/schemas/Notification" + */ export type AdminNotificationsRes = { notification: Notification } diff --git a/packages/medusa/src/api/routes/admin/notifications/list-notifications.ts b/packages/medusa/src/api/routes/admin/notifications/list-notifications.ts index 01cf9f925a..7281d68979 100644 --- a/packages/medusa/src/api/routes/admin/notifications/list-notifications.ts +++ b/packages/medusa/src/api/routes/admin/notifications/list-notifications.ts @@ -54,12 +54,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * notifications: - * type: array - * items: - * $ref: "#/components/schemas/Notification" + * $ref: "#/components/schemas/AdminNotificationsListRes" * "400": * $ref: "#/components/responses/400_error" * "401": diff --git a/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts b/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts index 66ab7d08d9..7fb8ecdd5a 100644 --- a/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts +++ b/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts @@ -49,10 +49,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * notification: - * $ref: "#/components/schemas/Notification" + * $ref: "#/components/schemas/AdminNotificationsRes" * "400": * $ref: "#/components/responses/400_error" * "401":