From 6e89d94df80145aeb73cd546c7d89e142c908997 Mon Sep 17 00:00:00 2001 From: Patrick <116003638+patrick-medusajs@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:47:51 -0500 Subject: [PATCH] feat(oas): declare x-codegen on Store routes (#3074) ### What Declare `x-codegen` in OAS for Store routes. ### Why We are introducing a new `x-codegen` OpenApi extension, also known as _vendor extension_, in order to help with passing information down to code generators. In our case, we wish to declare the `method` name that we would expect to call on a client. This mimics our current JS client package. E.g. `medusaClient.product.list` where `product` is the tag of the route and `list` is the x-codegen.method value. We are also defining the name of a potential typed object for query parameters. OAS 3.0 does not allow to bundle query parameters under a single definition but it is not uncommon to see API clients handle all query parameters as a single typed object, like our JS client package. With x-codegen.queryParams, a code generator can create a named and typed object to bundle all query parameters for a given route. E.g. `medusaClient.customer.retrieve(id: string, queryParams: AdminGetCustomerParams)` ### How Declare `x-codegen` as an object with fields `method` and `queryParams` on all paths. Match method and queryParams values with equivalent ones from our current JS client package. ### Test * Ran OAS validator. * Ran docs build script. Expect no visible changes to the documentation. --- .../api/routes/store/auth/create-session.ts | 24 ++++++++++++++--- .../api/routes/store/auth/delete-session.ts | 2 ++ .../src/api/routes/store/auth/exists.ts | 2 ++ .../src/api/routes/store/auth/get-session.ts | 2 ++ .../routes/store/carts/add-shipping-method.ts | 22 +++++++++++++-- .../api/routes/store/carts/calculate-taxes.ts | 2 ++ .../api/routes/store/carts/complete-cart.ts | 2 ++ .../src/api/routes/store/carts/create-cart.ts | 2 ++ .../store/carts/create-line-item/index.ts | 27 ++++++++++++++++--- .../store/carts/create-payment-sessions.ts | 2 ++ .../api/routes/store/carts/delete-discount.ts | 2 ++ .../routes/store/carts/delete-line-item.ts | 2 ++ .../store/carts/delete-payment-session.ts | 2 ++ .../src/api/routes/store/carts/get-cart.ts | 2 ++ .../store/carts/refresh-payment-session.ts | 2 ++ .../routes/store/carts/set-payment-session.ts | 18 ++++++++++++- .../src/api/routes/store/carts/update-cart.ts | 2 ++ .../routes/store/carts/update-line-item.ts | 18 ++++++++++++- .../store/carts/update-payment-session.ts | 18 ++++++++++++- .../store/collections/get-collection.ts | 2 ++ .../store/collections/list-collections.ts | 3 +++ .../routes/store/customers/create-address.ts | 2 ++ .../routes/store/customers/create-customer.ts | 2 ++ .../routes/store/customers/delete-address.ts | 2 ++ .../routes/store/customers/get-customer.ts | 2 ++ .../store/customers/get-payment-methods.ts | 2 ++ .../api/routes/store/customers/list-orders.ts | 3 +++ .../store/customers/reset-password-token.ts | 2 ++ .../routes/store/customers/reset-password.ts | 2 ++ .../routes/store/customers/update-address.ts | 2 ++ .../routes/store/customers/update-customer.ts | 2 ++ .../routes/store/gift-cards/get-gift-card.ts | 2 ++ .../store/order-edits/complete-order-edit.ts | 2 ++ .../store/order-edits/decline-order-edit.ts | 2 ++ .../store/order-edits/get-order-edit.ts | 2 ++ .../store/orders/confirm-order-request.ts | 2 ++ .../routes/store/orders/get-order-by-cart.ts | 2 ++ .../src/api/routes/store/orders/get-order.ts | 2 ++ .../api/routes/store/orders/lookup-order.ts | 3 +++ .../api/routes/store/orders/request-order.ts | 2 ++ .../authorize-batch-payment-sessions.ts | 2 ++ .../authorize-payment-session.ts | 2 ++ .../get-payment-collection.ts | 3 +++ .../manage-batch-payment-sessions.ts | 2 ++ .../manage-payment-session.ts | 2 ++ .../refresh-payment-session.ts | 2 ++ .../get-product-category.ts | 3 +++ .../list-product-categories.ts | 12 ++++++--- .../store/product-types/list-product-types.ts | 3 +++ .../api/routes/store/products/get-product.ts | 7 ++++- .../routes/store/products/list-products.ts | 6 +++++ .../src/api/routes/store/products/search.ts | 3 +++ .../api/routes/store/regions/get-region.ts | 2 ++ .../api/routes/store/regions/list-regions.ts | 3 +++ .../routes/store/return-reasons/get-reason.ts | 2 ++ .../store/return-reasons/list-reasons.ts | 2 ++ .../api/routes/store/returns/create-return.ts | 2 ++ .../store/shipping-options/list-options.ts | 3 +++ .../shipping-options/list-shipping-options.ts | 2 ++ .../src/api/routes/store/swaps/create-swap.ts | 2 ++ .../routes/store/swaps/get-swap-by-cart.ts | 2 ++ .../api/routes/store/variants/get-variant.ts | 7 ++++- .../routes/store/variants/list-variants.ts | 6 +++++ 63 files changed, 262 insertions(+), 16 deletions(-) diff --git a/packages/medusa/src/api/routes/store/auth/create-session.ts b/packages/medusa/src/api/routes/store/auth/create-session.ts index cf5dd6a2f4..0adbe02e1c 100644 --- a/packages/medusa/src/api/routes/store/auth/create-session.ts +++ b/packages/medusa/src/api/routes/store/auth/create-session.ts @@ -10,9 +10,13 @@ import { validator } from "../../../../utils/validator" * operationId: "PostAuth" * summary: "Customer Login" * description: "Logs a Customer in and authorizes them to view their details. Successful authentication will set a session cookie in the Customer's browser." - * parameters: - * - (body) email=* {string} The Customer's email. - * - (body) password=* {string} The Customer's password. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostAuthReq" + * x-codegen: + * method: authenticate * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -93,6 +97,20 @@ export default async (req, res) => { res.json({ customer }) } +/** + * @schema StorePostAuthReq + * type: object + * required: + * - email + * - password + * properties: + * email: + * type: string + * description: The Customer's email. + * password: + * type: string + * description: The Customer's password. + */ export class StorePostAuthReq { @IsEmail() email: string diff --git a/packages/medusa/src/api/routes/store/auth/delete-session.ts b/packages/medusa/src/api/routes/store/auth/delete-session.ts index 8f4cc3b6f9..69f83b5d37 100644 --- a/packages/medusa/src/api/routes/store/auth/delete-session.ts +++ b/packages/medusa/src/api/routes/store/auth/delete-session.ts @@ -4,6 +4,8 @@ * summary: "Customer Log out" * description: "Destroys a Customer's authenticated session." * x-authenticated: true + * x-codegen: + * method: deleteSession * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/store/auth/exists.ts b/packages/medusa/src/api/routes/store/auth/exists.ts index 08ddf33fc9..74fedae868 100644 --- a/packages/medusa/src/api/routes/store/auth/exists.ts +++ b/packages/medusa/src/api/routes/store/auth/exists.ts @@ -13,6 +13,8 @@ import CustomerService from "../../../../services/customer" * format: email * required: true * description: The email to check if exists. + * x-codegen: + * method: exists * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/auth/get-session.ts b/packages/medusa/src/api/routes/store/auth/get-session.ts index 70d7c6600d..d70a78e4e2 100644 --- a/packages/medusa/src/api/routes/store/auth/get-session.ts +++ b/packages/medusa/src/api/routes/store/auth/get-session.ts @@ -6,6 +6,8 @@ import CustomerService from "../../../../services/customer" * summary: "Get Current Customer" * description: "Gets the currently logged in Customer." * x-authenticated: true + * x-codegen: + * method: getSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/add-shipping-method.ts b/packages/medusa/src/api/routes/store/carts/add-shipping-method.ts index 63cef5819b..1cb495b835 100644 --- a/packages/medusa/src/api/routes/store/carts/add-shipping-method.ts +++ b/packages/medusa/src/api/routes/store/carts/add-shipping-method.ts @@ -12,8 +12,13 @@ import { validator } from "../../../../utils/validator" * summary: "Add a Shipping Method" * parameters: * - (path) id=* {string} The cart ID. - * - (body) option_id=* {string} ID of the shipping option to create the method from - * - (body) data {Object} Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostCartsCartShippingMethodReq" + * x-codegen: + * method: addShippingMethod * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -91,6 +96,19 @@ export default async (req, res) => { res.status(200).json({ cart: data }) } +/** + * @schema StorePostCartsCartShippingMethodReq + * type: object + * required: + * - option_id + * properties: + * option_id: + * type: string + * description: ID of the shipping option to create the method from + * data: + * type: object + * description: Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send. + */ export class StorePostCartsCartShippingMethodReq { @IsString() option_id: string diff --git a/packages/medusa/src/api/routes/store/carts/calculate-taxes.ts b/packages/medusa/src/api/routes/store/carts/calculate-taxes.ts index e816376d95..d9dc4969fa 100644 --- a/packages/medusa/src/api/routes/store/carts/calculate-taxes.ts +++ b/packages/medusa/src/api/routes/store/carts/calculate-taxes.ts @@ -11,6 +11,8 @@ import { IdempotencyKey } from "../../../../models/idempotency-key" * this may involve making 3rd party API calls to a Tax Provider service." * parameters: * - (path) id=* {String} The Cart ID. + * x-codegen: + * method: calculateTaxes * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/store/carts/complete-cart.ts b/packages/medusa/src/api/routes/store/carts/complete-cart.ts index bb766f9131..ba4e945e3c 100644 --- a/packages/medusa/src/api/routes/store/carts/complete-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/complete-cart.ts @@ -15,6 +15,8 @@ import { IdempotencyKeyService } from "../../../../services" * will generate one for the request." * parameters: * - (path) id=* {String} The Cart id. + * x-codegen: + * method: complete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/create-cart.ts b/packages/medusa/src/api/routes/store/carts/create-cart.ts index 32ca7856fa..fb46d93646 100644 --- a/packages/medusa/src/api/routes/store/carts/create-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/create-cart.ts @@ -37,6 +37,8 @@ import PublishableAPIKeysFeatureFlag from "../../../../loaders/feature-flags/pub * application/json: * schema: * $ref: "#/components/schemas/StorePostCartReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/create-line-item/index.ts b/packages/medusa/src/api/routes/store/carts/create-line-item/index.ts index a3e062e856..ad866536a4 100644 --- a/packages/medusa/src/api/routes/store/carts/create-line-item/index.ts +++ b/packages/medusa/src/api/routes/store/carts/create-line-item/index.ts @@ -20,9 +20,13 @@ import { * to the Cart" * parameters: * - (path) id=* {string} The id of the Cart to add the Line Item to. - * - (body) variant_id=* {string} The id of the Product Variant to generate the Line Item from. - * - (body) quantity=* {integer} The quantity of the Product Variant to add to the Line Item. - * - (body) metadata {object} An optional key-value map with additional details about the Line Item. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostCartsCartLineItemsReq" + * x-codegen: + * method: createLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -129,6 +133,23 @@ export default async (req, res) => { res.status(idempotencyKey.response_code).json(idempotencyKey.response_body) } +/** + * @schema StorePostCartsCartLineItemsReq + * type: object + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * type: string + * description: The id of the Product Variant to generate the Line Item from. + * quantity: + * type: number + * description: The quantity of the Product Variant to add to the Line Item. + * metadata: + * type: object + * description: An optional key-value map with additional details about the Line Item. + */ export class StorePostCartsCartLineItemsReq { @IsString() variant_id: string diff --git a/packages/medusa/src/api/routes/store/carts/create-payment-sessions.ts b/packages/medusa/src/api/routes/store/carts/create-payment-sessions.ts index d85bec4cf7..73848816a6 100644 --- a/packages/medusa/src/api/routes/store/carts/create-payment-sessions.ts +++ b/packages/medusa/src/api/routes/store/carts/create-payment-sessions.ts @@ -10,6 +10,8 @@ import IdempotencyKeyService from "../../../../services/idempotency-key" * description: "Creates Payment Sessions for each of the available Payment Providers in the Cart's Region." * parameters: * - (path) id=* {string} The id of the Cart. + * x-codegen: + * method: createPaymentSessions * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/delete-discount.ts b/packages/medusa/src/api/routes/store/carts/delete-discount.ts index fcd40f6aa9..7d2614b00c 100644 --- a/packages/medusa/src/api/routes/store/carts/delete-discount.ts +++ b/packages/medusa/src/api/routes/store/carts/delete-discount.ts @@ -10,6 +10,8 @@ import { CartService } from "../../../../services" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) code=* {string} The unique Discount code. + * x-codegen: + * method: deleteDiscount * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/delete-line-item.ts b/packages/medusa/src/api/routes/store/carts/delete-line-item.ts index 616c929b9d..be0a4b09bf 100644 --- a/packages/medusa/src/api/routes/store/carts/delete-line-item.ts +++ b/packages/medusa/src/api/routes/store/carts/delete-line-item.ts @@ -10,6 +10,8 @@ import { CartService } from "../../../../services" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) line_id=* {string} The id of the Line Item. + * x-codegen: + * method: deleteLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/delete-payment-session.ts b/packages/medusa/src/api/routes/store/carts/delete-payment-session.ts index b52d89c660..85fe988305 100644 --- a/packages/medusa/src/api/routes/store/carts/delete-payment-session.ts +++ b/packages/medusa/src/api/routes/store/carts/delete-payment-session.ts @@ -10,6 +10,8 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) provider_id=* {string} The id of the Payment Provider used to create the Payment Session to be deleted. + * x-codegen: + * method: deletePaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/get-cart.ts b/packages/medusa/src/api/routes/store/carts/get-cart.ts index 84b1576ecd..ee1a3ed5ce 100644 --- a/packages/medusa/src/api/routes/store/carts/get-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/get-cart.ts @@ -7,6 +7,8 @@ import { CartService } from "../../../../services" * description: "Retrieves a Cart." * parameters: * - (path) id=* {string} The id of the Cart. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/refresh-payment-session.ts b/packages/medusa/src/api/routes/store/carts/refresh-payment-session.ts index e34955b096..17cc17e8a7 100644 --- a/packages/medusa/src/api/routes/store/carts/refresh-payment-session.ts +++ b/packages/medusa/src/api/routes/store/carts/refresh-payment-session.ts @@ -9,6 +9,8 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) provider_id=* {string} The id of the Payment Provider that created the Payment Session to be refreshed. + * x-codegen: + * method: refreshPaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/set-payment-session.ts b/packages/medusa/src/api/routes/store/carts/set-payment-session.ts index 2f48d4192d..cf80e04949 100644 --- a/packages/medusa/src/api/routes/store/carts/set-payment-session.ts +++ b/packages/medusa/src/api/routes/store/carts/set-payment-session.ts @@ -12,7 +12,13 @@ import { validator } from "../../../../utils/validator" * description: "Selects a Payment Session as the session intended to be used towards the completion of the Cart." * parameters: * - (path) id=* {string} The ID of the Cart. - * - (body) provider_id=* {string} The ID of the Payment Provider. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostCartsCartPaymentSessionReq" + * x-codegen: + * method: setPaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -78,6 +84,16 @@ export default async (req, res) => { res.status(200).json({ cart: data }) } +/** + * @schema StorePostCartsCartPaymentSessionReq + * type: object + * required: + * - provider_id + * properties: + * provider_id: + * type: string + * description: The ID of the Payment Provider. + */ export class StorePostCartsCartPaymentSessionReq { @IsString() provider_id: string diff --git a/packages/medusa/src/api/routes/store/carts/update-cart.ts b/packages/medusa/src/api/routes/store/carts/update-cart.ts index 97b7105588..a27a874000 100644 --- a/packages/medusa/src/api/routes/store/carts/update-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/update-cart.ts @@ -27,6 +27,8 @@ import { IsType } from "../../../../utils/validators/is-type" * application/json: * schema: * $ref: "#/components/schemas/StorePostCartsCartReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/carts/update-line-item.ts b/packages/medusa/src/api/routes/store/carts/update-line-item.ts index 133768b09a..d1a9d8d808 100644 --- a/packages/medusa/src/api/routes/store/carts/update-line-item.ts +++ b/packages/medusa/src/api/routes/store/carts/update-line-item.ts @@ -13,7 +13,13 @@ import { validator } from "../../../../utils/validator" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) line_id=* {string} The id of the Line Item. - * - (body) quantity=* {integer} The quantity to set the Line Item to. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostCartsCartLineItemsItemReq" + * x-codegen: + * method: updateLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -112,6 +118,16 @@ export default async (req, res) => { res.status(200).json({ cart: data }) } +/** + * @schema StorePostCartsCartLineItemsItemReq + * type: object + * required: + * - quantity + * properties: + * quantity: + * type: number + * description: The quantity to set the Line Item to. + */ export class StorePostCartsCartLineItemsItemReq { @IsInt() quantity: number diff --git a/packages/medusa/src/api/routes/store/carts/update-payment-session.ts b/packages/medusa/src/api/routes/store/carts/update-payment-session.ts index d9c9b2df69..e13d4290f0 100644 --- a/packages/medusa/src/api/routes/store/carts/update-payment-session.ts +++ b/packages/medusa/src/api/routes/store/carts/update-payment-session.ts @@ -12,7 +12,13 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The id of the Cart. * - (path) provider_id=* {string} The id of the payment provider. - * - (body) data=* {object} The data to update the payment session with. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostCartsCartPaymentSessionUpdateReq" + * x-codegen: + * method: updatePaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -83,6 +89,16 @@ export default async (req, res) => { res.status(200).json({ cart: data }) } +/** + * @schema StorePostCartsCartPaymentSessionUpdateReq + * type: object + * required: + * - data + * properties: + * data: + * type: object + * description: The data to update the payment session with. + */ export class StorePostCartsCartPaymentSessionUpdateReq { @IsObject() data: Record diff --git a/packages/medusa/src/api/routes/store/collections/get-collection.ts b/packages/medusa/src/api/routes/store/collections/get-collection.ts index 83b904405b..dc1f6e0262 100644 --- a/packages/medusa/src/api/routes/store/collections/get-collection.ts +++ b/packages/medusa/src/api/routes/store/collections/get-collection.ts @@ -7,6 +7,8 @@ import ProductCollectionService from "../../../../services/product-collection" * description: "Retrieves a Product Collection." * parameters: * - (path) id=* {string} The id of the Product Collection + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/collections/list-collections.ts b/packages/medusa/src/api/routes/store/collections/list-collections.ts index 5b681a981f..d59ac97243 100644 --- a/packages/medusa/src/api/routes/store/collections/list-collections.ts +++ b/packages/medusa/src/api/routes/store/collections/list-collections.ts @@ -56,6 +56,9 @@ import { Type } from "class-transformer" * type: string * description: filter by dates greater than or equal to this date * format: date + * x-codegen: + * method: list + * queryParams: StoreGetCollectionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/create-address.ts b/packages/medusa/src/api/routes/store/customers/create-address.ts index 4df3412e67..ad7b8c71ed 100644 --- a/packages/medusa/src/api/routes/store/customers/create-address.ts +++ b/packages/medusa/src/api/routes/store/customers/create-address.ts @@ -17,6 +17,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerAddressesReq" + * x-codegen: + * method: addAddress * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/create-customer.ts b/packages/medusa/src/api/routes/store/customers/create-customer.ts index 8708cd000b..d00e4f864a 100644 --- a/packages/medusa/src/api/routes/store/customers/create-customer.ts +++ b/packages/medusa/src/api/routes/store/customers/create-customer.ts @@ -17,6 +17,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/delete-address.ts b/packages/medusa/src/api/routes/store/customers/delete-address.ts index f7acac5e92..d411b22524 100644 --- a/packages/medusa/src/api/routes/store/customers/delete-address.ts +++ b/packages/medusa/src/api/routes/store/customers/delete-address.ts @@ -11,6 +11,8 @@ import CustomerService from "../../../../services/customer" * x-authenticated: true * parameters: * - (path) address_id=* {string} The id of the Address to remove. + * x-codegen: + * method: deleteAddress * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/get-customer.ts b/packages/medusa/src/api/routes/store/customers/get-customer.ts index d93c162258..5d1d2f3c17 100644 --- a/packages/medusa/src/api/routes/store/customers/get-customer.ts +++ b/packages/medusa/src/api/routes/store/customers/get-customer.ts @@ -7,6 +7,8 @@ import CustomerService from "../../../../services/customer" * summary: Get a Customer * description: "Retrieves a Customer - the Customer must be logged in to retrieve their details." * x-authenticated: true + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/get-payment-methods.ts b/packages/medusa/src/api/routes/store/customers/get-payment-methods.ts index 1b06bee70e..537582d8dd 100644 --- a/packages/medusa/src/api/routes/store/customers/get-payment-methods.ts +++ b/packages/medusa/src/api/routes/store/customers/get-payment-methods.ts @@ -9,6 +9,8 @@ import { PaymentProvider } from "../../../../models" * summary: Get Payment Methods * description: "Retrieves a list of a Customer's saved payment methods. Payment methods are saved with Payment Providers and it is their responsibility to fetch saved methods." * x-authenticated: true + * x-codegen: + * method: listPaymentMethods * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/list-orders.ts b/packages/medusa/src/api/routes/store/customers/list-orders.ts index 3688769803..e7cf793fff 100644 --- a/packages/medusa/src/api/routes/store/customers/list-orders.ts +++ b/packages/medusa/src/api/routes/store/customers/list-orders.ts @@ -137,6 +137,9 @@ import { DateComparisonOperator } from "../../../../types/common" * - (query) offset=0 {integer} The offset in the resulting orders. * - (query) fields {string} (Comma separated string) Which fields should be included in the resulting orders. * - (query) expand {string} (Comma separated string) Which relations should be expanded in the resulting orders. + * x-codegen: + * method: listOrders + * queryParams: StoreGetCustomersCustomerOrdersParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/reset-password-token.ts b/packages/medusa/src/api/routes/store/customers/reset-password-token.ts index fbca61cfdc..4bcbc0b1c1 100644 --- a/packages/medusa/src/api/routes/store/customers/reset-password-token.ts +++ b/packages/medusa/src/api/routes/store/customers/reset-password-token.ts @@ -13,6 +13,8 @@ import { EntityManager } from "typeorm" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerPasswordTokenReq" + * x-codegen: + * method: generatePasswordToken * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/reset-password.ts b/packages/medusa/src/api/routes/store/customers/reset-password.ts index bfc56466c3..3308e3bdde 100644 --- a/packages/medusa/src/api/routes/store/customers/reset-password.ts +++ b/packages/medusa/src/api/routes/store/customers/reset-password.ts @@ -15,6 +15,8 @@ import { EntityManager } from "typeorm" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersResetPasswordReq" + * x-codegen: + * method: resetPassword * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/update-address.ts b/packages/medusa/src/api/routes/store/customers/update-address.ts index 0505cf8e32..19cf92939c 100644 --- a/packages/medusa/src/api/routes/store/customers/update-address.ts +++ b/packages/medusa/src/api/routes/store/customers/update-address.ts @@ -18,6 +18,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerAddressesAddressReq" + * x-codegen: + * method: updateAddress * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/customers/update-customer.ts b/packages/medusa/src/api/routes/store/customers/update-customer.ts index 53a87f1ad9..29ed334a22 100644 --- a/packages/medusa/src/api/routes/store/customers/update-customer.ts +++ b/packages/medusa/src/api/routes/store/customers/update-customer.ts @@ -18,6 +18,8 @@ import { IsType } from "../../../../utils/validators/is-type" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.ts b/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.ts index 017c317261..7a8cf76107 100644 --- a/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.ts +++ b/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.ts @@ -9,6 +9,8 @@ import GiftCardService from "../../../../services/gift-card" * description: "Retrieves a Gift Card by its associated unqiue code." * parameters: * - (path) code=* {string} The unique Gift Card code. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/order-edits/complete-order-edit.ts b/packages/medusa/src/api/routes/store/order-edits/complete-order-edit.ts index 8c63ed201a..42705bc7bc 100644 --- a/packages/medusa/src/api/routes/store/order-edits/complete-order-edit.ts +++ b/packages/medusa/src/api/routes/store/order-edits/complete-order-edit.ts @@ -15,6 +15,8 @@ import { * description: "Completes an OrderEdit." * parameters: * - (path) id=* {string} The ID of the Order Edit. + * x-codegen: + * method: complete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/order-edits/decline-order-edit.ts b/packages/medusa/src/api/routes/store/order-edits/decline-order-edit.ts index f9eaeb1d0e..ca62cfedd9 100644 --- a/packages/medusa/src/api/routes/store/order-edits/decline-order-edit.ts +++ b/packages/medusa/src/api/routes/store/order-edits/decline-order-edit.ts @@ -19,6 +19,8 @@ import { * application/json: * schema: * $ref: "#/components/schemas/StorePostOrderEditsOrderEditDecline" + * x-codegen: + * method: decline * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/order-edits/get-order-edit.ts b/packages/medusa/src/api/routes/store/order-edits/get-order-edit.ts index 100ef8c819..130b571e10 100644 --- a/packages/medusa/src/api/routes/store/order-edits/get-order-edit.ts +++ b/packages/medusa/src/api/routes/store/order-edits/get-order-edit.ts @@ -8,6 +8,8 @@ import { OrderEditService } from "../../../../services" * description: "Retrieves a OrderEdit." * parameters: * - (path) id=* {string} The ID of the OrderEdit. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/orders/confirm-order-request.ts b/packages/medusa/src/api/routes/store/orders/confirm-order-request.ts index c941c84585..0050e09c6f 100644 --- a/packages/medusa/src/api/routes/store/orders/confirm-order-request.ts +++ b/packages/medusa/src/api/routes/store/orders/confirm-order-request.ts @@ -16,6 +16,8 @@ import { * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerAcceptClaimReq" + * x-codegen: + * method: confirmRequest * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/orders/get-order-by-cart.ts b/packages/medusa/src/api/routes/store/orders/get-order-by-cart.ts index a35e3a82e8..d97d7e64ee 100644 --- a/packages/medusa/src/api/routes/store/orders/get-order-by-cart.ts +++ b/packages/medusa/src/api/routes/store/orders/get-order-by-cart.ts @@ -9,6 +9,8 @@ import { OrderService } from "../../../../services" * description: "Retrieves an Order by the id of the Cart that was used to create the Order." * parameters: * - (path) cart_id=* {string} The ID of Cart. + * x-codegen: + * method: retrieveByCartId * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/orders/get-order.ts b/packages/medusa/src/api/routes/store/orders/get-order.ts index baac0c9540..3b62c3ea4f 100644 --- a/packages/medusa/src/api/routes/store/orders/get-order.ts +++ b/packages/medusa/src/api/routes/store/orders/get-order.ts @@ -9,6 +9,8 @@ import { OrderService } from "../../../../services" * description: "Retrieves an Order" * parameters: * - (path) id=* {string} The id of the Order. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/orders/lookup-order.ts b/packages/medusa/src/api/routes/store/orders/lookup-order.ts index eed57ce027..77b7bd3ae4 100644 --- a/packages/medusa/src/api/routes/store/orders/lookup-order.ts +++ b/packages/medusa/src/api/routes/store/orders/lookup-order.ts @@ -38,6 +38,9 @@ import { validator } from "../../../../utils/validator" * postal_code: * type: string * description: The postal code of the shipping address + * x-codegen: + * method: lookupOrder + * queryParams: StoreGetOrdersParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/orders/request-order.ts b/packages/medusa/src/api/routes/store/orders/request-order.ts index ab9f8f36da..fd5e4b8b0a 100644 --- a/packages/medusa/src/api/routes/store/orders/request-order.ts +++ b/packages/medusa/src/api/routes/store/orders/request-order.ts @@ -18,6 +18,8 @@ import { TokenEvents } from "../../../../types/token" * application/json: * schema: * $ref: "#/components/schemas/StorePostCustomersCustomerOrderClaimReq" + * x-codegen: + * method: requestCustomerOrders * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/authorize-batch-payment-sessions.ts b/packages/medusa/src/api/routes/store/payment-collections/authorize-batch-payment-sessions.ts index dc1cd82324..b13fc70ed4 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/authorize-batch-payment-sessions.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/authorize-batch-payment-sessions.ts @@ -14,6 +14,8 @@ import { PaymentCollectionService } from "../../../../services" * application/json: * schema: * $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsAuthorizeReq" + * x-codegen: + * method: authorizePaymentSessionsBatch * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/authorize-payment-session.ts b/packages/medusa/src/api/routes/store/payment-collections/authorize-payment-session.ts index 84006b8b49..5d5aa7be92 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/authorize-payment-session.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/authorize-payment-session.ts @@ -11,6 +11,8 @@ import { PaymentCollectionService } from "../../../../services" * parameters: * - (path) id=* {string} The ID of the Payment Collections. * - (path) session_id=* {string} The ID of the Payment Session. + * x-codegen: + * method: authorizePaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/get-payment-collection.ts b/packages/medusa/src/api/routes/store/payment-collections/get-payment-collection.ts index 2c64663cdd..fe266b166e 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/get-payment-collection.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/get-payment-collection.ts @@ -11,6 +11,9 @@ import { FindParams } from "../../../../types/common" * - (path) id=* {string} The ID of the PaymentCollection. * - (query) expand {string} Comma separated list of relations to include in the results. * - (query) fields {string} Comma separated list of fields to include in the results. + * x-codegen: + * method: retrieve + * queryParams: GetPaymentCollectionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/manage-batch-payment-sessions.ts b/packages/medusa/src/api/routes/store/payment-collections/manage-batch-payment-sessions.ts index 33723dbbb8..0563f94fa1 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/manage-batch-payment-sessions.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/manage-batch-payment-sessions.ts @@ -17,6 +17,8 @@ import { PaymentCollectionService } from "../../../../services" * application/json: * schema: * $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsReq" + * x-codegen: + * method: managePaymentSessionsBatch * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/manage-payment-session.ts b/packages/medusa/src/api/routes/store/payment-collections/manage-payment-session.ts index 347c1b36f8..c13ac82efe 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/manage-payment-session.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/manage-payment-session.ts @@ -16,6 +16,8 @@ import { PaymentCollectionService } from "../../../../services" * application/json: * schema: * $ref: "#/components/schemas/StorePaymentCollectionSessionsReq" + * x-codegen: + * method: managePaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/payment-collections/refresh-payment-session.ts b/packages/medusa/src/api/routes/store/payment-collections/refresh-payment-session.ts index 0f7e6a5cb1..a369d9a25a 100644 --- a/packages/medusa/src/api/routes/store/payment-collections/refresh-payment-session.ts +++ b/packages/medusa/src/api/routes/store/payment-collections/refresh-payment-session.ts @@ -10,6 +10,8 @@ import { PaymentCollectionService } from "../../../../services" * parameters: * - (path) id=* {string} The id of the PaymentCollection. * - (path) session_id=* {string} The id of the Payment Session to be refreshed. + * x-codegen: + * method: refreshPaymentSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/product-categories/get-product-category.ts b/packages/medusa/src/api/routes/store/product-categories/get-product-category.ts index 509b242fec..a8edb48304 100644 --- a/packages/medusa/src/api/routes/store/product-categories/get-product-category.ts +++ b/packages/medusa/src/api/routes/store/product-categories/get-product-category.ts @@ -15,6 +15,9 @@ import { defaultStoreScope } from "." * - (path) id=* {string} The ID of the Product Category * - (query) expand {string} (Comma separated) Which fields should be expanded in each product category. * - (query) fields {string} (Comma separated) Which fields should be retrieved in each product category. + * x-codegen: + * method: retrieve + * queryParams: StoreGetProductCategoryParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/product-categories/list-product-categories.ts b/packages/medusa/src/api/routes/store/product-categories/list-product-categories.ts index dc9ec365b1..615a70777f 100644 --- a/packages/medusa/src/api/routes/store/product-categories/list-product-categories.ts +++ b/packages/medusa/src/api/routes/store/product-categories/list-product-categories.ts @@ -1,6 +1,6 @@ -import { IsNumber, IsOptional, IsString } from "class-validator" +import { IsOptional, IsString } from "class-validator" import { Request, Response } from "express" -import { Type, Transform } from "class-transformer" +import { Transform } from "class-transformer" import { ProductCategoryService } from "../../../../services" import { extendedFindParamsMixin } from "../../../../types/common" @@ -17,6 +17,9 @@ import { defaultStoreScope } from "." * - (query) parent_category_id {string} Returns categories scoped by parent * - (query) offset=0 {integer} How many product categories to skip in the result. * - (query) limit=100 {integer} Limit the number of product categories returned. + * x-codegen: + * method: list + * queryParams: StoreGetProductCategoriesParams * x-codeSamples: * - lang: Shell * label: cURL @@ -67,7 +70,10 @@ export default async (req: Request, res: Response) => { "productCategoryService" ) - const selectors = Object.assign({ ...defaultStoreScope }, req.filterableFields) + const selectors = Object.assign( + { ...defaultStoreScope }, + req.filterableFields + ) const [data, count] = await productCategoryService.listAndCount( selectors, diff --git a/packages/medusa/src/api/routes/store/product-types/list-product-types.ts b/packages/medusa/src/api/routes/store/product-types/list-product-types.ts index a7451dcc2e..065a0dc960 100644 --- a/packages/medusa/src/api/routes/store/product-types/list-product-types.ts +++ b/packages/medusa/src/api/routes/store/product-types/list-product-types.ts @@ -82,6 +82,9 @@ import ProductTypeService from "../../../../services/product-type" * type: string * description: filter by dates greater than or equal to this date * format: date + * x-codegen: + * method: list + * queryParams: StoreGetProductTypesParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/products/get-product.ts b/packages/medusa/src/api/routes/store/products/get-product.ts index 456cd20865..89eb052cc8 100644 --- a/packages/medusa/src/api/routes/store/products/get-product.ts +++ b/packages/medusa/src/api/routes/store/products/get-product.ts @@ -27,6 +27,9 @@ import { validator } from "../../../../utils/validator" * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes * description: See a list of codes. + * x-codegen: + * method: retrieve + * queryParams: StoreGetProductsProductParams * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -64,7 +67,7 @@ import { validator } from "../../../../utils/validator" export default async (req, res) => { const { id } = req.params - const validated = await validator(PriceSelectionParams, req.query) + const validated = await validator(StoreGetProductsProductParams, req.query) const customer_id = req.user?.customer_id @@ -99,3 +102,5 @@ export default async (req, res) => { res.json({ product }) } + +export class StoreGetProductsProductParams extends PriceSelectionParams {} diff --git a/packages/medusa/src/api/routes/store/products/list-products.ts b/packages/medusa/src/api/routes/store/products/list-products.ts index 1c46d9cf97..32128d7d96 100644 --- a/packages/medusa/src/api/routes/store/products/list-products.ts +++ b/packages/medusa/src/api/routes/store/products/list-products.ts @@ -129,6 +129,12 @@ import PublishableAPIKeysFeatureFlag from "../../../../loaders/feature-flags/pub * - (query) expand {string} (Comma separated) Which fields should be expanded in each order of the result. * - (query) fields {string} (Comma separated) Which fields should be included in each order of the result. * - (query) order {string} the field used to order the products. + * - (query) cart_id {string} The id of the Cart to set prices based on. + * - (query) region_id {string} The id of the Region to set prices based on. + * - (query) currency_code {string} The currency code to use for price selection. + * x-codegen: + * method: list + * queryParams: StoreGetProductsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/products/search.ts b/packages/medusa/src/api/routes/store/products/search.ts index 42e390e624..6e0453a198 100644 --- a/packages/medusa/src/api/routes/store/products/search.ts +++ b/packages/medusa/src/api/routes/store/products/search.ts @@ -15,6 +15,9 @@ import { validator } from "../../../../utils/validator" * - (query) offset {integer} How many products to skip in the result. * - (query) limit {integer} Limit the number of products returned. * - (query) filter {} Filter based on the search engine. + * x-codegen: + * method: search + * queryParams: StorePostSearchReq * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/regions/get-region.ts b/packages/medusa/src/api/routes/store/regions/get-region.ts index fcff4d9081..5dc4eec489 100644 --- a/packages/medusa/src/api/routes/store/regions/get-region.ts +++ b/packages/medusa/src/api/routes/store/regions/get-region.ts @@ -7,6 +7,8 @@ import RegionService from "../../../../services/region" * description: "Retrieves a Region." * parameters: * - (path) id=* {string} The id of the Region. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/regions/list-regions.ts b/packages/medusa/src/api/routes/store/regions/list-regions.ts index 2b0a234312..3d30c9820f 100644 --- a/packages/medusa/src/api/routes/store/regions/list-regions.ts +++ b/packages/medusa/src/api/routes/store/regions/list-regions.ts @@ -58,6 +58,9 @@ import { validator } from "../../../../utils/validator" * type: string * description: filter by dates greater than or equal to this date * format: date + * x-codegen: + * method: list + * queryParams: StoreGetRegionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/return-reasons/get-reason.ts b/packages/medusa/src/api/routes/store/return-reasons/get-reason.ts index ec3570ad92..f97e3d34f6 100644 --- a/packages/medusa/src/api/routes/store/return-reasons/get-reason.ts +++ b/packages/medusa/src/api/routes/store/return-reasons/get-reason.ts @@ -11,6 +11,8 @@ import ReturnReasonService from "../../../../services/return-reason" * description: "Retrieves a Return Reason." * parameters: * - (path) id=* {string} The id of the Return Reason. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/return-reasons/list-reasons.ts b/packages/medusa/src/api/routes/store/return-reasons/list-reasons.ts index 9a3bfa8e98..d119a08b90 100644 --- a/packages/medusa/src/api/routes/store/return-reasons/list-reasons.ts +++ b/packages/medusa/src/api/routes/store/return-reasons/list-reasons.ts @@ -9,6 +9,8 @@ import ReturnReasonService from "../../../../services/return-reason" * operationId: "GetReturnReasons" * summary: "List Return Reasons" * description: "Retrieves a list of Return Reasons." + * x-codegen: + * method: list * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/returns/create-return.ts b/packages/medusa/src/api/routes/store/returns/create-return.ts index f73992acc5..a35bc39e63 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.ts +++ b/packages/medusa/src/api/routes/store/returns/create-return.ts @@ -26,6 +26,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/StorePostReturnsReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/shipping-options/list-options.ts b/packages/medusa/src/api/routes/store/shipping-options/list-options.ts index a2180d4950..f23959959a 100644 --- a/packages/medusa/src/api/routes/store/shipping-options/list-options.ts +++ b/packages/medusa/src/api/routes/store/shipping-options/list-options.ts @@ -12,6 +12,9 @@ import { validator } from "../../../../utils/validator" * - (query) is_return {boolean} Whether return Shipping Options should be included. By default all Shipping Options are returned. * - (query) product_ids {string} A comma separated list of Product ids to filter Shipping Options by. * - (query) region_id {string} the Region to retrieve Shipping Options from. + * x-codegen: + * method: list + * queryParams: StoreGetShippingOptionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/shipping-options/list-shipping-options.ts b/packages/medusa/src/api/routes/store/shipping-options/list-shipping-options.ts index 4ff7bc33ec..33c2f767a3 100644 --- a/packages/medusa/src/api/routes/store/shipping-options/list-shipping-options.ts +++ b/packages/medusa/src/api/routes/store/shipping-options/list-shipping-options.ts @@ -8,6 +8,8 @@ import ShippingProfileService from "../../../../services/shipping-profile" * description: "Retrieves a list of Shipping Options available to a cart." * parameters: * - (path) cart_id {string} The id of the Cart. + * x-codegen: + * method: listCartOptions * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/swaps/create-swap.ts b/packages/medusa/src/api/routes/store/swaps/create-swap.ts index 77be708ba2..f0197183ff 100644 --- a/packages/medusa/src/api/routes/store/swaps/create-swap.ts +++ b/packages/medusa/src/api/routes/store/swaps/create-swap.ts @@ -28,6 +28,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/StorePostSwapsReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/swaps/get-swap-by-cart.ts b/packages/medusa/src/api/routes/store/swaps/get-swap-by-cart.ts index 12716226ac..c270e7491d 100644 --- a/packages/medusa/src/api/routes/store/swaps/get-swap-by-cart.ts +++ b/packages/medusa/src/api/routes/store/swaps/get-swap-by-cart.ts @@ -7,6 +7,8 @@ import SwapService from "../../../../services/swap" * description: "Retrieves a Swap by the id of the Cart used to confirm the Swap." * parameters: * - (path) cart_id {string} The id of the Cart + * x-codegen: + * method: retrieveByCartId * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/store/variants/get-variant.ts b/packages/medusa/src/api/routes/store/variants/get-variant.ts index 99de63e62d..f6f5f8f797 100644 --- a/packages/medusa/src/api/routes/store/variants/get-variant.ts +++ b/packages/medusa/src/api/routes/store/variants/get-variant.ts @@ -28,6 +28,9 @@ import { validator } from "../../../../utils/validator" * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes * description: See a list of codes. + * x-codegen: + * method: retrieve + * queryParams: StoreGetVariantsVariantParams * x-codeSamples: * - lang: Shell * label: cURL @@ -56,7 +59,7 @@ import { validator } from "../../../../utils/validator" export default async (req, res) => { const { id } = req.params - const validated = await validator(PriceSelectionParams, req.query) + const validated = await validator(StoreGetVariantsVariantParams, req.query) const variantService: ProductVariantService = req.scope.resolve( "productVariantService" @@ -94,3 +97,5 @@ export default async (req, res) => { res.json({ variant }) } + +export class StoreGetVariantsVariantParams extends PriceSelectionParams {} diff --git a/packages/medusa/src/api/routes/store/variants/list-variants.ts b/packages/medusa/src/api/routes/store/variants/list-variants.ts index b6eb114b89..f50051f960 100644 --- a/packages/medusa/src/api/routes/store/variants/list-variants.ts +++ b/packages/medusa/src/api/routes/store/variants/list-variants.ts @@ -25,6 +25,9 @@ import { IsType } from "../../../../utils/validators/is-type" * - (query) expand {string} A comma separated list of Product Variant relations to load. * - (query) offset=0 {number} How many product variants to skip in the result. * - (query) limit=100 {number} Maximum number of Product Variants to return. + * - (query) cart_id {string} The id of the Cart to set prices based on. + * - (query) region_id {string} The id of the Region to set prices based on. + * - (query) currency_code {string} The currency code to use for price selection. * - in: query * name: title * style: form @@ -60,6 +63,9 @@ import { IsType } from "../../../../utils/validators/is-type" * gte: * type: number * description: filter by inventory quantity greater than or equal to this number + * x-codegen: + * method: list + * queryParams: StoreGetVariantsParams * x-codeSamples: * - lang: Shell * label: cURL