diff --git a/.changeset/rich-laws-guess.md b/.changeset/rich-laws-guess.md new file mode 100644 index 0000000000..e0f19cdd51 --- /dev/null +++ b/.changeset/rich-laws-guess.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +chore(oas): replace requestBody with $ref to req class JSDoc OAS diff --git a/packages/medusa/src/api/routes/admin/apps/authorize-app.ts b/packages/medusa/src/api/routes/admin/apps/authorize-app.ts index 3a323c0bf0..75c928c1c1 100644 --- a/packages/medusa/src/api/routes/admin/apps/authorize-app.ts +++ b/packages/medusa/src/api/routes/admin/apps/authorize-app.ts @@ -13,21 +13,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - application_name - * - state - * - code - * properties: - * application_name: - * type: string - * description: Name of the application for the token to be generated for. - * state: - * type: string - * description: State of the application. - * code: - * type: string - * description: The code for the generated token. + * $ref: "#/components/schemas/AdminPostAppsReq" * x-codeSamples: * - lang: Shell * label: cURL @@ -79,6 +65,24 @@ export default async (req, res) => { res.status(200).json({ apps: data }) } +/** + * @schema AdminPostAppsReq + * type: object + * required: + * - application_name + * - state + * - code + * properties: + * application_name: + * type: string + * description: Name of the application for the token to be generated for. + * state: + * type: string + * description: State of the application. + * code: + * type: string + * description: The code for the generated token. + */ export class AdminPostAppsReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/auth/create-session.ts b/packages/medusa/src/api/routes/admin/auth/create-session.ts index 49dfc11f83..7d9e664c3d 100644 --- a/packages/medusa/src/api/routes/admin/auth/create-session.ts +++ b/packages/medusa/src/api/routes/admin/auth/create-session.ts @@ -20,19 +20,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - email - * - password - * properties: - * email: - * type: string - * description: The User's email. - * format: email - * password: - * type: string - * description: The User's password. - * format: password + * $ref: "#/components/schemas/AdminPostAuthReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -113,6 +101,22 @@ export default async (req, res) => { } } +/** + * @schema AdminPostAuthReq + * type: object + * required: + * - email + * - password + * properties: + * email: + * type: string + * description: The User's email. + * format: email + * password: + * type: string + * description: The User's password. + * format: password + */ export class AdminPostAuthReq { @IsEmail() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts b/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts index 42400caf74..783334101b 100644 --- a/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts +++ b/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts @@ -15,38 +15,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - type - * - context - * properties: - * type: - * type: string - * description: The type of batch job to start. - * example: product-export - * context: - * type: object - * description: Additional infomration regarding the batch to be used for processing. - * example: - * shape: - * prices: - * - region: null - * currency_code: "eur" - * dynamicImageColumnCount: 4 - * dynamicOptionColumnCount: 2 - * list_config: - * skip: 0 - * take: 50 - * order: - * created_at: "DESC" - * relations: - * - variants - * - variant.prices - * - images - * dry_run: - * type: boolean - * description: Set a batch job in dry_run mode to get some information on what will be done without applying any modifications. - * default: false + * $ref: "#/components/schemas/AdminPostBatchesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -120,6 +89,41 @@ export default async (req, res) => { res.status(201).json({ batch_job }) } +/** + * @schema AdminPostBatchesReq + * type: object + * required: + * - type + * - context + * properties: + * type: + * type: string + * description: The type of batch job to start. + * example: product-export + * context: + * type: object + * description: Additional infomration regarding the batch to be used for processing. + * example: + * shape: + * prices: + * - region: null + * currency_code: "eur" + * dynamicImageColumnCount: 4 + * dynamicOptionColumnCount: 2 + * list_config: + * skip: 0 + * take: 50 + * order: + * created_at: "DESC" + * relations: + * - variants + * - variant.prices + * - images + * dry_run: + * type: boolean + * description: Set a batch job in dry_run mode to get some information on what will be done without applying any modifications. + * default: false + */ export class AdminPostBatchesReq { @IsString() type: string diff --git a/packages/medusa/src/api/routes/admin/collections/add-products.ts b/packages/medusa/src/api/routes/admin/collections/add-products.ts index 104a8d61c7..678d3deddf 100644 --- a/packages/medusa/src/api/routes/admin/collections/add-products.ts +++ b/packages/medusa/src/api/routes/admin/collections/add-products.ts @@ -16,16 +16,7 @@ import ProductCollectionService from "../../../../services/product-collection" * content: * application/json: * schema: - * type: object - * required: - * - product_ids - * properties: - * product_ids: - * description: "An array of Product IDs to add to the Product Collection." - * type: array - * items: - * description: "The ID of a Product to add to the Product Collection." - * type: string + * $ref: "#/components/schemas/AdminPostProductsToCollectionReq" * x-codeSamples: * - lang: Shell * label: cURL @@ -86,6 +77,19 @@ export default async (req: Request, res: Response) => { res.status(200).json({ collection }) } +/** + * @schema AdminPostProductsToCollectionReq + * type: object + * required: + * - product_ids + * properties: + * product_ids: + * description: "An array of Product IDs to add to the Product Collection." + * type: array + * items: + * description: "The ID of a Product to add to the Product Collection." + * type: string + */ export class AdminPostProductsToCollectionReq { @ArrayNotEmpty() @IsString({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/collections/create-collection.ts b/packages/medusa/src/api/routes/admin/collections/create-collection.ts index c24be158b8..b2e9b8afb7 100644 --- a/packages/medusa/src/api/routes/admin/collections/create-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/create-collection.ts @@ -13,19 +13,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - title - * properties: - * title: - * type: string - * description: The title to identify the Collection by. - * handle: - * type: string - * description: An optional handle to be used in slugs, if none is provided we will kebab-case the title. - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostCollectionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -95,6 +83,22 @@ export default async (req: Request, res: Response) => { res.status(200).json({ collection }) } +/** + * @schema AdminPostCollectionsReq + * type: object + * required: + * - title + * properties: + * title: + * type: string + * description: The title to identify the Collection by. + * handle: + * type: string + * description: An optional handle to be used in slugs, if none is provided we will kebab-case the title. + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostCollectionsReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/collections/remove-products.ts b/packages/medusa/src/api/routes/admin/collections/remove-products.ts index 6df316ee91..3f75f60951 100644 --- a/packages/medusa/src/api/routes/admin/collections/remove-products.ts +++ b/packages/medusa/src/api/routes/admin/collections/remove-products.ts @@ -16,16 +16,7 @@ import ProductCollectionService from "../../../../services/product-collection" * content: * application/json: * schema: - * type: object - * required: - * - product_ids - * properties: - * product_ids: - * description: "An array of Product IDs to remove from the Product Collection." - * type: array - * items: - * description: "The ID of a Product to add to the Product Collection." - * type: string + * $ref: "#/components/schemas/AdminDeleteProductsFromCollectionReq" * x-codeSamples: * - lang: Shell * label: cURL @@ -101,6 +92,19 @@ export default async (req: Request, res: Response) => { }) } +/** + * @schema AdminDeleteProductsFromCollectionReq + * type: object + * required: + * - product_ids + * properties: + * product_ids: + * description: "An array of Product IDs to remove from the Product Collection." + * type: array + * items: + * description: "The ID of a Product to add to the Product Collection." + * type: string + */ export class AdminDeleteProductsFromCollectionReq { @ArrayNotEmpty() @IsString({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/collections/update-collection.ts b/packages/medusa/src/api/routes/admin/collections/update-collection.ts index 105ae7e1a5..485879abe3 100644 --- a/packages/medusa/src/api/routes/admin/collections/update-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/update-collection.ts @@ -15,17 +15,7 @@ import ProductCollectionService from "../../../../services/product-collection" * content: * application/json: * schema: - * type: object - * properties: - * title: - * type: string - * description: The title to identify the Collection by. - * handle: - * type: string - * description: An optional handle to be used in slugs, if none is provided we will kebab-case the title. - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostCollectionsCollectionReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -98,6 +88,20 @@ export default async (req: Request, res: Response) => { res.status(200).json({ collection }) } +/** + * @schema AdminPostCollectionsCollectionReq + * type: object + * properties: + * title: + * type: string + * description: The title to identify the Collection by. + * handle: + * type: string + * description: An optional handle to be used in slugs, if none is provided we will kebab-case the title. + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostCollectionsCollectionReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/currencies/update-currency.ts b/packages/medusa/src/api/routes/admin/currencies/update-currency.ts index fd9e2ab34b..871c466d95 100644 --- a/packages/medusa/src/api/routes/admin/currencies/update-currency.ts +++ b/packages/medusa/src/api/routes/admin/currencies/update-currency.ts @@ -17,11 +17,7 @@ import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/ta * content: * application/json: * schema: - * type: object - * properties: - * includes_tax: - * type: boolean - * description: "[EXPERIMENTAL] Tax included in prices of currency." + * $ref: "#/components/schemas/AdminPostCurrenciesCurrencyReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -67,6 +63,14 @@ export default async (req: ExtendedRequest, res) => { res.json({ currency }) } +/** + * @schema AdminPostCurrenciesCurrencyReq + * type: object + * properties: + * includes_tax: + * type: boolean + * description: "[EXPERIMENTAL] Tax included in prices of currency." + */ export class AdminPostCurrenciesCurrencyReq { @FeatureFlagDecorators(TaxInclusivePricingFeatureFlag.key, [ IsOptional(), diff --git a/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts b/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts index ff0c06de89..afe7a951be 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts @@ -19,20 +19,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - customer_ids - * properties: - * customer_ids: - * description: "The ids of the customers to add" - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: ID of the customer - * type: string + * $ref: "#/components/schemas/AdminPostCustomerGroupsGroupCustomersBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -118,6 +105,23 @@ export default async (req: Request, res: Response) => { res.status(200).json({ customer_group }) } +/** + * @schema AdminPostCustomerGroupsGroupCustomersBatchReq + * type: object + * required: + * - customer_ids + * properties: + * customer_ids: + * description: "The ids of the customers to add" + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: ID of the customer + * type: string + */ export class AdminPostCustomerGroupsGroupCustomersBatchReq { @ValidateNested({ each: true }) @Type(() => CustomerGroupsBatchCustomer) diff --git a/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts b/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts index 7f9aede0a6..1983ce568b 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts @@ -19,20 +19,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - customer_ids - * properties: - * customer_ids: - * description: "The ids of the customers to remove" - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: ID of the customer - * type: string + * $ref: "#/components/schemas/AdminDeleteCustomerGroupsGroupCustomerBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -118,6 +105,23 @@ export default async (req: Request, res: Response) => { res.status(200).json({ customer_group }) } +/** + * @schema AdminDeleteCustomerGroupsGroupCustomerBatchReq + * type: object + * required: + * - customer_ids + * properties: + * customer_ids: + * description: "The ids of the customers to remove" + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: ID of the customer + * type: string + */ export class AdminDeleteCustomerGroupsGroupCustomerBatchReq { @ValidateNested({ each: true }) @Type(() => CustomerGroupsBatchCustomer) diff --git a/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts b/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts index e8ff1924f6..f7376c6235 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts @@ -19,14 +19,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * name: - * description: "Name of the customer group" - * type: string - * metadata: - * description: "Metadata for the customer." - * type: object + * $ref: "#/components/schemas/AdminPostCustomerGroupsGroupReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -114,6 +107,17 @@ export default async (req: Request, res: Response) => { res.json({ customer_group: customerGroup }) } +/** + * @schema AdminPostCustomerGroupsGroupReq + * type: object + * properties: + * name: + * description: "Name of the customer group" + * type: string + * metadata: + * description: "Metadata for the customer." + * type: object + */ export class AdminPostCustomerGroupsGroupReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/customers/create-customer.ts b/packages/medusa/src/api/routes/admin/customers/create-customer.ts index ecaf2eadc7..3803c93554 100644 --- a/packages/medusa/src/api/routes/admin/customers/create-customer.ts +++ b/packages/medusa/src/api/routes/admin/customers/create-customer.ts @@ -14,33 +14,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - email - * - first_name - * - last_name - * - password - * properties: - * email: - * type: string - * description: The customer's email. - * format: email - * first_name: - * type: string - * description: The customer's first name. - * last_name: - * type: string - * description: The customer's last name. - * password: - * type: string - * description: The customer's password. - * format: password - * phone: - * type: string - * description: The customer's phone number. - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostCustomersReq" * tags: * - Customer * x-codeSamples: @@ -110,6 +84,36 @@ export default async (req, res) => { res.status(201).json({ customer }) } +/** + * @schema AdminPostCustomersReq + * type: object + * required: + * - email + * - first_name + * - last_name + * - password + * properties: + * email: + * type: string + * description: The customer's email. + * format: email + * first_name: + * type: string + * description: The customer's first name. + * last_name: + * type: string + * description: The customer's last name. + * password: + * type: string + * description: The customer's password. + * format: password + * phone: + * type: string + * description: The customer's phone number. + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostCustomersReq { @IsEmail() email: string diff --git a/packages/medusa/src/api/routes/admin/customers/update-customer.ts b/packages/medusa/src/api/routes/admin/customers/update-customer.ts index 105c73401b..0e8ec3c0fc 100644 --- a/packages/medusa/src/api/routes/admin/customers/update-customer.ts +++ b/packages/medusa/src/api/routes/admin/customers/update-customer.ts @@ -29,38 +29,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * email: - * type: string - * description: The Customer's email. - * format: email - * first_name: - * type: string - * description: The Customer's first name. - * last_name: - * type: string - * description: The Customer's last name. - * phone: - * type: string - * description: The Customer's phone number. - * password: - * type: string - * description: The Customer's password. - * format: password - * groups: - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: The ID of a customer group - * type: string - * description: A list of customer groups to which the customer belongs. - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostCustomersCustomerReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -156,6 +125,41 @@ class Group { id: string } +/** + * @schema AdminPostCustomersCustomerReq + * type: object + * properties: + * email: + * type: string + * description: The Customer's email. + * format: email + * first_name: + * type: string + * description: The Customer's first name. + * last_name: + * type: string + * description: The Customer's last name. + * phone: + * type: string + * description: The Customer's phone number. + * password: + * type: string + * description: The Customer's password. + * format: password + * groups: + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: The ID of a customer group + * type: string + * description: A list of customer groups to which the customer belongs. + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostCustomersCustomerReq { @IsEmail() @IsOptional() 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 bdd3093a1c..6d17a87f5b 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 @@ -24,20 +24,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * required: - * - resources - * properties: - * resources: - * description: The resources to be added to the discount condition - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: The id of the item - * type: string + * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsConditionBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -124,9 +111,27 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsDiscountConditionsConditionBatchReq + * type: object + * required: + * - resources + * properties: + * resources: + * description: The resources to be added to the discount condition + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: The id of the item + * type: string + */ export class AdminPostDiscountsDiscountConditionsConditionBatchReq { @IsArray() resources: { id: string }[] } +// eslint-disable-next-line max-len export class AdminPostDiscountsDiscountConditionsConditionBatchParams extends FindParams {} 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 41c90dd8e4..b2fe4c28aa 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-condition.ts @@ -22,39 +22,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * required: - * - operator - * properties: - * operator: - * description: Operator of the condition - * type: string - * enum: [in, not_in] - * products: - * type: array - * description: list of product IDs if the condition is applied on products. - * items: - * type: string - * product_types: - * type: array - * description: list of product type IDs if the condition is applied on product types. - * items: - * type: string - * product_collections: - * type: array - * description: list of product collection IDs if the condition is applied on product collections. - * items: - * type: string - * product_tags: - * type: array - * description: list of product tag IDs if the condition is applied on product tags. - * items: - * type: string - * customer_groups: - * type: array - * description: list of customer group IDs if the condition is applied on customer groups. - * items: - * type: string + * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditions" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -130,6 +98,42 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsDiscountConditions + * type: object + * required: + * - operator + * properties: + * operator: + * description: Operator of the condition + * type: string + * enum: [in, not_in] + * products: + * type: array + * description: list of product IDs if the condition is applied on products. + * items: + * type: string + * product_types: + * type: array + * description: list of product type IDs if the condition is applied on product types. + * items: + * type: string + * product_collections: + * type: array + * description: list of product collection IDs if the condition is applied on product collections. + * items: + * type: string + * product_tags: + * type: array + * description: list of product tag IDs if the condition is applied on product tags. + * items: + * type: string + * customer_groups: + * type: array + * description: list of customer group IDs if the condition is applied on customer groups. + * items: + * type: string + */ // eslint-disable-next-line max-len export class AdminPostDiscountsDiscountConditions extends AdminUpsertConditionsReq { @IsString() 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 f55f0ef039..cc7d53fd7e 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-discount.ts @@ -38,105 +38,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * required: - * - code - * - rule - * - regions - * properties: - * code: - * type: string - * description: A unique code that will be used to redeem the Discount - * is_dynamic: - * type: boolean - * description: Whether the Discount should have multiple instances of itself, each with a different code. This can be useful for automatically generated codes that all have to follow a common set of rules. - * default: false - * rule: - * description: The Discount Rule that defines how Discounts are calculated - * type: object - * required: - * - type - * - value - * - allocation - * properties: - * description: - * type: string - * description: "A short description of the discount" - * type: - * type: string - * description: "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers." - * enum: [fixed, percentage, free_shipping] - * value: - * type: number - * description: "The value that the discount represents; this will depend on the type of the discount" - * allocation: - * type: string - * description: "The scope that the discount should apply to." - * enum: [total, item] - * conditions: - * type: array - * description: "A set of conditions that can be used to limit when the discount can be used. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided." - * items: - * type: object - * required: - * - operator - * properties: - * operator: - * type: string - * description: Operator of the condition - * enum: [in, not_in] - * products: - * type: array - * description: list of product IDs if the condition is applied on products. - * items: - * type: string - * product_types: - * type: array - * description: list of product type IDs if the condition is applied on product types. - * items: - * type: string - * product_collections: - * type: array - * description: list of product collection IDs if the condition is applied on product collections. - * items: - * type: string - * product_tags: - * type: array - * description: list of product tag IDs if the condition is applied on product tags. - * items: - * type: string - * customer_groups: - * type: array - * description: list of customer group IDs if the condition is applied on customer groups. - * items: - * type: string - * is_disabled: - * type: boolean - * description: Whether the Discount code is disabled on creation. You will have to enable it later to make it available to Customers. - * default: false - * starts_at: - * type: string - * format: date-time - * description: The time at which the Discount should be available. - * ends_at: - * type: string - * format: date-time - * description: The time at which the Discount should no longer be available. - * valid_duration: - * type: string - * description: Duration the discount runs between - * example: P3Y6M4DT12H30M5S - * regions: - * description: A list of Region ids representing the Regions in which the Discount can be used. - * type: array - * items: - * type: string - * usage_limit: - * type: number - * description: Maximum times the discount can be used - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostDiscountsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -221,6 +123,108 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsReq + * type: object + * required: + * - code + * - rule + * - regions + * properties: + * code: + * type: string + * description: A unique code that will be used to redeem the Discount + * is_dynamic: + * type: boolean + * description: Whether the Discount should have multiple instances of itself, each with a different code. This can be useful for automatically generated codes that all have to follow a common set of rules. + * default: false + * rule: + * description: The Discount Rule that defines how Discounts are calculated + * type: object + * required: + * - type + * - value + * - allocation + * properties: + * description: + * type: string + * description: "A short description of the discount" + * type: + * type: string + * description: "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers." + * enum: [fixed, percentage, free_shipping] + * value: + * type: number + * description: "The value that the discount represents; this will depend on the type of the discount" + * allocation: + * type: string + * description: "The scope that the discount should apply to." + * enum: [total, item] + * conditions: + * type: array + * description: "A set of conditions that can be used to limit when the discount can be used. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided." + * items: + * type: object + * required: + * - operator + * properties: + * operator: + * type: string + * description: Operator of the condition + * enum: [in, not_in] + * products: + * type: array + * description: list of product IDs if the condition is applied on products. + * items: + * type: string + * product_types: + * type: array + * description: list of product type IDs if the condition is applied on product types. + * items: + * type: string + * product_collections: + * type: array + * description: list of product collection IDs if the condition is applied on product collections. + * items: + * type: string + * product_tags: + * type: array + * description: list of product tag IDs if the condition is applied on product tags. + * items: + * type: string + * customer_groups: + * type: array + * description: list of customer group IDs if the condition is applied on customer groups. + * items: + * type: string + * is_disabled: + * type: boolean + * description: Whether the Discount code is disabled on creation. You will have to enable it later to make it available to Customers. + * default: false + * starts_at: + * type: string + * format: date-time + * description: The time at which the Discount should be available. + * ends_at: + * type: string + * format: date-time + * description: The time at which the Discount should no longer be available. + * valid_duration: + * type: string + * description: Duration the discount runs between + * example: P3Y6M4DT12H30M5S + * regions: + * description: A list of Region ids representing the Regions in which the Discount can be used. + * type: array + * items: + * type: string + * usage_limit: + * type: number + * description: Maximum times the discount can be used + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostDiscountsReq { @IsString() @IsNotEmpty() 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 1ca06d4662..9e3bf68d17 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 @@ -23,20 +23,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * required: - * - resources - * properties: - * resources: - * description: The resources to be deleted from the discount condition - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: The id of the item - * type: string + * $ref: "#/components/schemas/AdminDeleteDiscountsDiscountConditionsConditionBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -123,8 +110,26 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +// eslint-disable-next-line max-len export class AdminDeleteDiscountsDiscountConditionsConditionBatchParams extends FindParams {} +/** + * @schema AdminDeleteDiscountsDiscountConditionsConditionBatchReq + * type: object + * required: + * - resources + * properties: + * resources: + * description: The resources to be deleted from the discount condition + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: The id of the item + * type: string + */ export class AdminDeleteDiscountsDiscountConditionsConditionBatchReq { @IsArray() resources: { id: string }[] 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 83c5e8831d..ff13b3fd77 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-condition.ts @@ -20,33 +20,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * products: - * type: array - * description: list of product IDs if the condition is applied on products. - * items: - * type: string - * product_types: - * type: array - * description: list of product type IDs if the condition is applied on product types. - * items: - * type: string - * product_collections: - * type: array - * description: list of product collection IDs if the condition is applied on product collections. - * items: - * type: string - * product_tags: - * type: array - * description: list of product tag IDs if the condition is applied on product tags. - * items: - * type: string - * customer_groups: - * type: array - * description: list of customer group IDs if the condition is applied on customer groups. - * items: - * type: string + * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsCondition" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -133,7 +107,38 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsDiscountConditionsCondition + * type: object + * properties: + * products: + * type: array + * description: list of product IDs if the condition is applied on products. + * items: + * type: string + * product_types: + * type: array + * description: list of product type IDs if the condition is applied on product types. + * items: + * type: string + * product_collections: + * type: array + * description: list of product collection IDs if the condition is applied on product collections. + * items: + * type: string + * product_tags: + * type: array + * description: list of product tag IDs if the condition is applied on product tags. + * items: + * type: string + * customer_groups: + * type: array + * description: list of customer group IDs if the condition is applied on customer groups. + * items: + * type: string + */ // eslint-disable-next-line max-len export class AdminPostDiscountsDiscountConditionsCondition extends AdminUpsertConditionsReq {} +// eslint-disable-next-line max-len export class AdminPostDiscountsDiscountConditionsConditionParams extends FindParams {} 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 36ee4f9983..7cbe9dda79 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-discount.ts @@ -36,96 +36,7 @@ import { FindParams } from "../../../../types/common" * content: * application/json: * schema: - * type: object - * properties: - * code: - * type: string - * description: A unique code that will be used to redeem the Discount - * rule: - * description: The Discount Rule that defines how Discounts are calculated - * type: object - * required: - * - id - * properties: - * id: - * type: string - * description: "The ID of the Rule" - * description: - * type: string - * description: "A short description of the discount" - * value: - * type: number - * description: "The value that the discount represents; this will depend on the type of the discount" - * allocation: - * type: string - * description: "The scope that the discount should apply to." - * enum: [total, item] - * conditions: - * type: array - * description: "A set of conditions that can be used to limit when the discount can be used. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided." - * items: - * type: object - * required: - * - operator - * properties: - * id: - * type: string - * description: "The ID of the Rule" - * operator: - * type: string - * description: Operator of the condition - * enum: [in, not_in] - * products: - * type: array - * description: list of product IDs if the condition is applied on products. - * items: - * type: string - * product_types: - * type: array - * description: list of product type IDs if the condition is applied on product types. - * items: - * type: string - * product_collections: - * type: array - * description: list of product collection IDs if the condition is applied on product collections. - * items: - * type: string - * product_tags: - * type: array - * description: list of product tag IDs if the condition is applied on product tags. - * items: - * type: string - * customer_groups: - * type: array - * description: list of customer group IDs if the condition is applied on customer groups. - * items: - * type: string - * is_disabled: - * type: boolean - * description: Whether the Discount code is disabled on creation. You will have to enable it later to make it available to Customers. - * starts_at: - * type: string - * format: date-time - * description: The time at which the Discount should be available. - * ends_at: - * type: string - * format: date-time - * description: The time at which the Discount should no longer be available. - * valid_duration: - * type: string - * description: Duration the discount runs between - * example: P3Y6M4DT12H30M5S - * usage_limit: - * type: number - * description: Maximum times the discount can be used - * regions: - * description: A list of Region ids representing the Regions in which the Discount can be used. - * type: array - * items: - * type: string - * metadata: - * description: An object containing metadata of the discount - * type: object + * $ref: "#/components/schemas/AdminPostDiscountsDiscountReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -196,6 +107,99 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsDiscountReq + * type: object + * properties: + * code: + * type: string + * description: A unique code that will be used to redeem the Discount + * rule: + * description: The Discount Rule that defines how Discounts are calculated + * type: object + * required: + * - id + * properties: + * id: + * type: string + * description: "The ID of the Rule" + * description: + * type: string + * description: "A short description of the discount" + * value: + * type: number + * description: "The value that the discount represents; this will depend on the type of the discount" + * allocation: + * type: string + * description: "The scope that the discount should apply to." + * enum: [total, item] + * conditions: + * type: array + * description: "A set of conditions that can be used to limit when the discount can be used. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided." + * items: + * type: object + * required: + * - operator + * properties: + * id: + * type: string + * description: "The ID of the Rule" + * operator: + * type: string + * description: Operator of the condition + * enum: [in, not_in] + * products: + * type: array + * description: list of product IDs if the condition is applied on products. + * items: + * type: string + * product_types: + * type: array + * description: list of product type IDs if the condition is applied on product types. + * items: + * type: string + * product_collections: + * type: array + * description: list of product collection IDs if the condition is applied on product collections. + * items: + * type: string + * product_tags: + * type: array + * description: list of product tag IDs if the condition is applied on product tags. + * items: + * type: string + * customer_groups: + * type: array + * description: list of customer group IDs if the condition is applied on customer groups. + * items: + * type: string + * is_disabled: + * type: boolean + * description: Whether the Discount code is disabled on creation. You will have to enable it later to make it available to Customers. + * starts_at: + * type: string + * format: date-time + * description: The time at which the Discount should be available. + * ends_at: + * type: string + * format: date-time + * description: The time at which the Discount should no longer be available. + * valid_duration: + * type: string + * description: Duration the discount runs between + * example: P3Y6M4DT12H30M5S + * usage_limit: + * type: number + * description: Maximum times the discount can be used + * regions: + * description: A list of Region ids representing the Regions in which the Discount can be used. + * type: array + * items: + * type: string + * metadata: + * description: An object containing metadata of the discount + * type: object + */ export class AdminPostDiscountsDiscountReq { @IsString() @IsOptional() 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 f80521f24a..0e8c6d88de 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 @@ -36,93 +36,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * required: - * - email - * - region_id - * - shipping_methods - * properties: - * status: - * description: "The status of the draft order" - * type: string - * enum: [open, completed] - * email: - * description: "The email of the customer of the draft order" - * type: string - * format: email - * billing_address: - * description: "The Address to be used for billing purposes." - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * - type: string - * shipping_address: - * description: "The Address to be used for shipping." - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * - type: string - * items: - * description: The Line Items that have been received. - * type: array - * items: - * type: object - * required: - * - quantity - * properties: - * variant_id: - * description: The ID of the Product Variant to generate the Line Item from. - * type: string - * unit_price: - * description: The potential custom price of the item. - * type: integer - * title: - * description: The potential custom title of the item. - * type: string - * quantity: - * description: The quantity of the Line Item. - * type: integer - * metadata: - * description: The optional key-value map with additional details about the Line Item. - * type: object - * region_id: - * description: The ID of the region for the draft order - * type: string - * discounts: - * description: The discounts to add on the draft order - * type: array - * items: - * type: object - * required: - * - code - * properties: - * code: - * description: The code of the discount to apply - * type: string - * customer_id: - * description: The ID of the customer to add on the draft order - * type: string - * no_notification_order: - * description: An optional flag passed to the resulting order to determine use of notifications. - * type: boolean - * shipping_methods: - * description: The shipping methods for the draft order - * type: array - * items: - * type: object - * required: - * - option_id - * properties: - * option_id: - * description: The ID of the shipping option in use - * type: string - * data: - * description: The optional additional data needed for the shipping method - * type: object - * price: - * description: The potential custom price of the shipping - * type: integer - * metadata: - * description: The optional key-value map with additional details about the Draft Order. - * type: object + * $ref: "#/components/schemas/AdminPostDraftOrdersReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -249,6 +163,96 @@ enum Status { completed = "completed", } +/** + * @schema AdminPostDraftOrdersReq + * type: object + * required: + * - email + * - region_id + * - shipping_methods + * properties: + * status: + * description: "The status of the draft order" + * type: string + * enum: [open, completed] + * email: + * description: "The email of the customer of the draft order" + * type: string + * format: email + * billing_address: + * description: "The Address to be used for billing purposes." + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * - type: string + * shipping_address: + * description: "The Address to be used for shipping." + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * - type: string + * items: + * description: The Line Items that have been received. + * type: array + * items: + * type: object + * required: + * - quantity + * properties: + * variant_id: + * description: The ID of the Product Variant to generate the Line Item from. + * type: string + * unit_price: + * description: The potential custom price of the item. + * type: integer + * title: + * description: The potential custom title of the item. + * type: string + * quantity: + * description: The quantity of the Line Item. + * type: integer + * metadata: + * description: The optional key-value map with additional details about the Line Item. + * type: object + * region_id: + * description: The ID of the region for the draft order + * type: string + * discounts: + * description: The discounts to add on the draft order + * type: array + * items: + * type: object + * required: + * - code + * properties: + * code: + * description: The code of the discount to apply + * type: string + * customer_id: + * description: The ID of the customer to add on the draft order + * type: string + * no_notification_order: + * description: An optional flag passed to the resulting order to determine use of notifications. + * type: boolean + * shipping_methods: + * description: The shipping methods for the draft order + * type: array + * items: + * type: object + * required: + * - option_id + * properties: + * option_id: + * description: The ID of the shipping option in use + * type: string + * data: + * description: The optional additional data needed for the shipping method + * type: object + * price: + * description: The potential custom price of the shipping + * type: integer + * metadata: + * description: The optional key-value map with additional details about the Draft Order. + * type: object + */ export class AdminPostDraftOrdersReq { @IsEnum(Status) @IsOptional() 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 d3f538f5fb..81604a1a3f 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 @@ -26,26 +26,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - quantity - * properties: - * variant_id: - * description: The ID of the Product Variant to generate the Line Item from. - * type: string - * unit_price: - * description: The potential custom price of the item. - * type: integer - * title: - * description: The potential custom title of the item. - * type: string - * default: "Custom item" - * quantity: - * description: The quantity of the Line Item. - * type: integer - * metadata: - * description: The optional key-value map with additional details about the Line Item. - * type: object + * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -162,6 +143,29 @@ export default async (req, res) => { }) } +/** + * @schema AdminPostDraftOrdersDraftOrderLineItemsReq + * type: object + * required: + * - quantity + * properties: + * variant_id: + * description: The ID of the Product Variant to generate the Line Item from. + * type: string + * unit_price: + * description: The potential custom price of the item. + * type: integer + * title: + * description: The potential custom title of the item. + * type: string + * default: "Custom item" + * quantity: + * description: The quantity of the Line Item. + * type: integer + * metadata: + * description: The optional key-value map with additional details about the Line Item. + * type: object + */ export class AdminPostDraftOrdersDraftOrderLineItemsReq { @IsString() @IsOptional() 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 eefd2e1c66..31df2b1732 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 @@ -32,48 +32,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * properties: - * region_id: - * type: string - * description: The ID of the Region to create the Draft Order in. - * country_code: - * type: string - * description: "The 2 character ISO code for the Country." - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements - * description: See a list of codes. - * email: - * type: string - * description: "An email to be used on the Draft Order." - * format: email - * billing_address: - * description: "The Address to be used for billing purposes." - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * - type: string - * shipping_address: - * description: "The Address to be used for shipping." - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * - type: string - * discounts: - * description: "An array of Discount codes to add to the Draft Order." - * type: array - * items: - * type: object - * required: - * - code - * properties: - * code: - * description: "The code that a Discount is identifed by." - * type: string - * no_notification_order: - * description: "An optional flag passed to the resulting order to determine use of notifications." - * type: boolean - * customer_id: - * description: "The ID of the Customer to associate the Draft Order with." - * type: string + * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -182,6 +141,51 @@ export default async (req, res) => { res.status(200).json({ draft_order: draftOrder }) } +/** + * @schema AdminPostDraftOrdersDraftOrderReq + * type: object + * properties: + * region_id: + * type: string + * description: The ID of the Region to create the Draft Order in. + * country_code: + * type: string + * description: "The 2 character ISO code for the Country." + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements + * description: See a list of codes. + * email: + * type: string + * description: "An email to be used on the Draft Order." + * format: email + * billing_address: + * description: "The Address to be used for billing purposes." + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * - type: string + * shipping_address: + * description: "The Address to be used for shipping." + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * - type: string + * discounts: + * description: "An array of Discount codes to add to the Draft Order." + * type: array + * items: + * type: object + * required: + * - code + * properties: + * code: + * description: "The code that a Discount is identifed by." + * type: string + * no_notification_order: + * description: "An optional flag passed to the resulting order to determine use of notifications." + * type: boolean + * customer_id: + * description: "The ID of the Customer to associate the Draft Order with." + * type: string + */ export class AdminPostDraftOrdersDraftOrderReq { @IsString() @IsOptional() 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 d678d0d235..720c22c6eb 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 @@ -25,20 +25,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * unit_price: - * description: The potential custom price of the item. - * type: integer - * title: - * description: The potential custom title of the item. - * type: string - * quantity: - * description: The quantity of the Line Item. - * type: integer - * metadata: - * description: The optional key-value map with additional details about the Line Item. - * type: object + * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsItemReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -157,6 +144,23 @@ export default async (req, res) => { }) } +/** + * @schema AdminPostDraftOrdersDraftOrderLineItemsItemReq + * type: object + * properties: + * unit_price: + * description: The potential custom price of the item. + * type: integer + * title: + * description: The potential custom title of the item. + * type: string + * quantity: + * description: The quantity of the Line Item. + * type: integer + * metadata: + * description: The optional key-value map with additional details about the Line Item. + * type: object + */ export class AdminPostDraftOrdersDraftOrderLineItemsItemReq { @IsString() @IsOptional() 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 affd3eda9a..dfbb06e7b5 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 @@ -15,26 +15,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - region_id - * properties: - * value: - * type: integer - * description: The value (excluding VAT) that the Gift Card should represent. - * is_disabled: - * type: boolean - * description: Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers. - * ends_at: - * type: string - * format: date-time - * description: The time at which the Gift Card should no longer be available. - * region_id: - * description: The ID of the Region in which the Gift Card can be used. - * type: string - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostGiftCardsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -103,6 +84,29 @@ export default async (req, res) => { res.status(200).json({ gift_card: giftCard }) } +/** + * @schema AdminPostGiftCardsReq + * type: object + * required: + * - region_id + * properties: + * value: + * type: integer + * description: The value (excluding VAT) that the Gift Card should represent. + * is_disabled: + * type: boolean + * description: Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers. + * ends_at: + * type: string + * format: date-time + * description: The time at which the Gift Card should no longer be available. + * region_id: + * description: The ID of the Region in which the Gift Card can be used. + * type: string + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostGiftCardsReq { @IsOptional() @IsInt() 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 f56bb33152..771a8dc50a 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 @@ -18,24 +18,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * balance: - * type: integer - * description: The value (excluding VAT) that the Gift Card should represent. - * is_disabled: - * type: boolean - * description: Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers. - * ends_at: - * type: string - * format: date-time - * description: The time at which the Gift Card should no longer be available. - * region_id: - * description: The ID of the Region in which the Gift Card can be used. - * type: string - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostGiftCardsGiftCardReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -108,6 +91,27 @@ export default async (req, res) => { res.status(200).json({ gift_card: giftCard }) } +/** + * @schema AdminPostGiftCardsGiftCardReq + * type: object + * properties: + * balance: + * type: integer + * description: The value (excluding VAT) that the Gift Card should represent. + * is_disabled: + * type: boolean + * description: Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers. + * ends_at: + * type: string + * format: date-time + * description: The time at which the Gift Card should no longer be available. + * region_id: + * description: The ID of the Region in which the Gift Card can be used. + * type: string + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostGiftCardsGiftCardReq { @IsOptional() @IsInt() diff --git a/packages/medusa/src/api/routes/admin/invites/accept-invite.ts b/packages/medusa/src/api/routes/admin/invites/accept-invite.ts index 32aef67bd1..cc9c169da5 100644 --- a/packages/medusa/src/api/routes/admin/invites/accept-invite.ts +++ b/packages/medusa/src/api/routes/admin/invites/accept-invite.ts @@ -14,32 +14,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - token - * - user - * properties: - * token: - * description: "The invite token provided by the admin." - * type: string - * user: - * description: "The User to create." - * type: object - * required: - * - first_name - * - last_name - * - password - * properties: - * first_name: - * type: string - * description: the first name of the User - * last_name: - * type: string - * description: the last name of the User - * password: - * description: The desired password for the User - * type: string - * format: password + * $ref: "#/components/schemas/AdminPostInvitesInviteAcceptReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -122,6 +97,35 @@ export class AdminPostInvitesInviteAcceptUserReq { password: string } +/** + * @schema AdminPostInvitesInviteAcceptReq + * type: object + * required: + * - token + * - user + * properties: + * token: + * description: "The invite token provided by the admin." + * type: string + * user: + * description: "The User to create." + * type: object + * required: + * - first_name + * - last_name + * - password + * properties: + * first_name: + * type: string + * description: the first name of the User + * last_name: + * type: string + * description: the last name of the User + * password: + * description: The desired password for the User + * type: string + * format: password + */ export class AdminPostInvitesInviteAcceptReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/invites/create-invite.ts b/packages/medusa/src/api/routes/admin/invites/create-invite.ts index 31c55798d3..280622d7f0 100644 --- a/packages/medusa/src/api/routes/admin/invites/create-invite.ts +++ b/packages/medusa/src/api/routes/admin/invites/create-invite.ts @@ -15,19 +15,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - user - * - role - * properties: - * user: - * description: "The email for the user to be created." - * type: string - * format: email - * role: - * description: "The role of the user to be created." - * type: string - * enum: [admin, member, developer] + * $ref: "#/components/schemas/AdminPostInvitesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -90,6 +78,23 @@ export default async (req, res) => { res.sendStatus(200) } + +/** + * @schema AdminPostInvitesReq + * type: object + * required: + * - user + * - role + * properties: + * user: + * description: "The email for the user to be created." + * type: string + * format: email + * role: + * description: "The role of the user to be created." + * type: string + * enum: [admin, member, developer] + */ export class AdminPostInvitesReq { @IsEmail() user: string 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 b57f4405a3..523100bc52 100644 --- a/packages/medusa/src/api/routes/admin/notes/create-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/create-note.ts @@ -14,21 +14,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - resource_id - * - resource_type - * - value - * properties: - * resource_id: - * type: string - * description: The ID of the resource which the Note relates to. - * resource_type: - * type: string - * description: The type of resource which the Note relates to. - * value: - * type: string - * description: The content of the Note to create. + * $ref: "#/components/schemas/AdminPostNotesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -104,6 +90,24 @@ export default async (req, res) => { res.status(200).json({ note: result }) } +/** + * @schema AdminPostNotesReq + * type: object + * required: + * - resource_id + * - resource_type + * - value + * properties: + * resource_id: + * type: string + * description: The ID of the resource which the Note relates to. + * resource_type: + * type: string + * description: The type of resource which the Note relates to. + * value: + * type: string + * description: The content of the Note to create. + */ export class AdminPostNotesReq { @IsString() @IsNotEmpty() 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 584dbf363e..56b37935c6 100644 --- a/packages/medusa/src/api/routes/admin/notes/update-note.ts +++ b/packages/medusa/src/api/routes/admin/notes/update-note.ts @@ -15,13 +15,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - value - * properties: - * value: - * type: string - * description: The updated description of the Note. + * $ref: "#/components/schemas/AdminPostNotesNoteReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -88,6 +82,16 @@ export default async (req, res) => { res.status(200).json({ note }) } +/** + * @schema AdminPostNotesNoteReq + * type: object + * required: + * - value + * properties: + * value: + * type: string + * description: The updated description of the Note. + */ export class AdminPostNotesNoteReq { @IsString() value: string 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 bfb5e1a3b5..66ab7d08d9 100644 --- a/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts +++ b/packages/medusa/src/api/routes/admin/notifications/resend-notification.ts @@ -21,11 +21,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * to: - * description: "A new address or user identifier that the Notification should be sent to" - * type: string + * $ref: "#/components/schemas/AdminPostNotificationsNotificationResendReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -103,6 +99,14 @@ export default async (req, res) => { res.json({ notification }) } +/** + * @schema AdminPostNotificationsNotificationResendReq + * type: object + * properties: + * to: + * description: "A new address or user identifier that the Notification should be sent to" + * type: string + */ export class AdminPostNotificationsNotificationResendReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/order-edits/add-line-item.ts b/packages/medusa/src/api/routes/admin/order-edits/add-line-item.ts index 27cb045566..1aff36ecb6 100644 --- a/packages/medusa/src/api/routes/admin/order-edits/add-line-item.ts +++ b/packages/medusa/src/api/routes/admin/order-edits/add-line-item.ts @@ -19,20 +19,7 @@ import { * content: * application/json: * schema: - * type: object - * required: - * - variant_id - * - quantity - * properties: - * variant_id: - * description: The ID of the variant ID to add - * type: string - * quantity: - * description: The quantity to add - * type: number - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostOrderEditsEditLineItemsReq" * x-authenticated: true * x-codeSamples: * - lang: JavaScript @@ -112,6 +99,23 @@ export default async (req: Request, res: Response) => { }) } +/** + * @schema AdminPostOrderEditsEditLineItemsReq + * type: object + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * description: The ID of the variant ID to add + * type: string + * quantity: + * description: The quantity to add + * type: number + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostOrderEditsEditLineItemsReq { @IsString() variant_id: string diff --git a/packages/medusa/src/api/routes/admin/order-edits/create-order-edit.ts b/packages/medusa/src/api/routes/admin/order-edits/create-order-edit.ts index e1e1749361..adc9a58af1 100644 --- a/packages/medusa/src/api/routes/admin/order-edits/create-order-edit.ts +++ b/packages/medusa/src/api/routes/admin/order-edits/create-order-edit.ts @@ -16,16 +16,7 @@ import { * content: * application/json: * schema: - * type: object - * required: - * - order_id - * properties: - * order_id: - * description: The ID of the order to create the edit for. - * type: string - * internal_note: - * description: An optional note to create for the order edit. - * type: string + * $ref: "#/components/schemas/AdminPostOrderEditsReq" * x-authenticated: true * x-codeSamples: * - lang: JavaScript @@ -99,6 +90,19 @@ export default async (req: Request, res: Response) => { return res.json({ order_edit: orderEdit }) } +/** + * @schema AdminPostOrderEditsReq + * type: object + * required: + * - order_id + * properties: + * order_id: + * description: The ID of the order to create the edit for. + * type: string + * internal_note: + * description: An optional note to create for the order edit. + * type: string + */ export class AdminPostOrderEditsReq { @IsString() order_id: string diff --git a/packages/medusa/src/api/routes/admin/order-edits/update-order-edit-line-item.ts b/packages/medusa/src/api/routes/admin/order-edits/update-order-edit-line-item.ts index 02126d71e9..92c7043ae4 100644 --- a/packages/medusa/src/api/routes/admin/order-edits/update-order-edit-line-item.ts +++ b/packages/medusa/src/api/routes/admin/order-edits/update-order-edit-line-item.ts @@ -20,13 +20,7 @@ import { * content: * application/json: * schema: - * type: object - * required: - * - quantity - * properties: - * quantity: - * description: The quantity to update - * type: number + * $ref: "#/components/schemas/AdminPostOrderEditsEditLineItemsLineItemReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -103,6 +97,16 @@ export default async (req: Request, res: Response) => { }) } +/** + * @schema AdminPostOrderEditsEditLineItemsLineItemReq + * type: object + * required: + * - quantity + * properties: + * quantity: + * description: The quantity to update + * type: number + */ export class AdminPostOrderEditsEditLineItemsLineItemReq { @IsNumber() quantity: number diff --git a/packages/medusa/src/api/routes/admin/order-edits/update-order-edit.ts b/packages/medusa/src/api/routes/admin/order-edits/update-order-edit.ts index 70cd0c457a..43f440be4b 100644 --- a/packages/medusa/src/api/routes/admin/order-edits/update-order-edit.ts +++ b/packages/medusa/src/api/routes/admin/order-edits/update-order-edit.ts @@ -20,11 +20,7 @@ import { * content: * application/json: * schema: - * type: object - * properties: - * internal_note: - * description: An optional note to create or update for the order edit. - * type: string + * $ref: "#/components/schemas/AdminPostOrderEditsOrderEditReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -103,6 +99,14 @@ export default async (req: Request, res: Response) => { res.status(200).json({ order_edit: orderEdit }) } +/** + * @schema AdminPostOrderEditsOrderEditReq + * type: object + * properties: + * internal_note: + * description: An optional note to create or update for the order edit. + * type: string + */ export class AdminPostOrderEditsOrderEditReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim-shipment.ts b/packages/medusa/src/api/routes/admin/orders/create-claim-shipment.ts index 1f1f45990e..3db9de13ca 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim-shipment.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-claim-shipment.ts @@ -18,18 +18,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - fulfillment_id - * properties: - * fulfillment_id: - * description: The ID of the Fulfillment. - * type: string - * tracking_numbers: - * description: The tracking numbers for the shipment. - * type: array - * items: - * type: string + * $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimShipmentsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -110,6 +99,21 @@ export default async (req, res) => { res.json({ order }) } +/** + * @schema AdminPostOrdersOrderClaimsClaimShipmentsReq + * type: object + * required: + * - fulfillment_id + * properties: + * fulfillment_id: + * description: The ID of the Fulfillment. + * type: string + * tracking_numbers: + * description: The tracking numbers for the shipment. + * type: array + * items: + * type: string + */ export class AdminPostOrdersOrderClaimsClaimShipmentsReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.ts b/packages/medusa/src/api/routes/admin/orders/create-claim.ts index c44e7ecc6e..34ce43ecc2 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.ts @@ -31,102 +31,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - type - * - claim_items - * properties: - * type: - * description: "The type of the Claim. This will determine how the Claim is treated: `replace` Claims will result in a Fulfillment with new items being created, while a `refund` Claim will refund the amount paid for the claimed items." - * type: string - * enum: - * - replace - * - refund - * claim_items: - * description: The Claim Items that the Claim will consist of. - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item that will be claimed. - * type: string - * quantity: - * description: The number of items that will be returned - * type: integer - * note: - * description: Short text describing the Claim Item in further detail. - * type: string - * reason: - * description: The reason for the Claim - * type: string - * enum: - * - missing_item - * - wrong_item - * - production_failure - * - other - * tags: - * description: A list o tags to add to the Claim Item - * type: array - * items: - * type: string - * images: - * description: A list of image URL's that will be associated with the Claim - * items: - * type: string - * return_shipping: - * description: Optional details for the Return Shipping Method, if the items are to be sent back. - * type: object - * properties: - * option_id: - * type: string - * description: The ID of the Shipping Option to create the Shipping Method from. - * price: - * type: integer - * description: The price to charge for the Shipping Method. - * additional_items: - * description: The new items to send to the Customer when the Claim type is Replace. - * type: array - * items: - * required: - * - variant_id - * - quantity - * properties: - * variant_id: - * description: The ID of the Product Variant to ship. - * type: string - * quantity: - * description: The quantity of the Product Variant to ship. - * type: integer - * shipping_methods: - * description: The Shipping Methods to send the additional Line Items with. - * type: array - * items: - * properties: - * id: - * description: The ID of an existing Shipping Method - * type: string - * option_id: - * description: The ID of the Shipping Option to create a Shipping Method from - * type: string - * price: - * description: The price to charge for the Shipping Method - * type: integer - * shipping_address: - * type: object - * description: "An optional shipping address to send the claim to. Defaults to the parent order's shipping address" - * $ref: "#/components/schemas/Address" - * refund_amount: - * description: The amount to refund the Customer when the Claim type is `refund`. - * type: integer - * no_notification: - * description: If set to true no notification will be send related to this Claim. - * type: boolean - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostOrdersOrderClaimsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -394,6 +299,105 @@ export default async (req, res) => { res.status(idempotencyKey.response_code).json(idempotencyKey.response_body) } +/** + * @schema AdminPostOrdersOrderClaimsReq + * type: object + * required: + * - type + * - claim_items + * properties: + * type: + * description: "The type of the Claim. This will determine how the Claim is treated: `replace` Claims will result in a Fulfillment with new items being created, while a `refund` Claim will refund the amount paid for the claimed items." + * type: string + * enum: + * - replace + * - refund + * claim_items: + * description: The Claim Items that the Claim will consist of. + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item that will be claimed. + * type: string + * quantity: + * description: The number of items that will be returned + * type: integer + * note: + * description: Short text describing the Claim Item in further detail. + * type: string + * reason: + * description: The reason for the Claim + * type: string + * enum: + * - missing_item + * - wrong_item + * - production_failure + * - other + * tags: + * description: A list o tags to add to the Claim Item + * type: array + * items: + * type: string + * images: + * description: A list of image URL's that will be associated with the Claim + * items: + * type: string + * return_shipping: + * description: Optional details for the Return Shipping Method, if the items are to be sent back. + * type: object + * properties: + * option_id: + * type: string + * description: The ID of the Shipping Option to create the Shipping Method from. + * price: + * type: integer + * description: The price to charge for the Shipping Method. + * additional_items: + * description: The new items to send to the Customer when the Claim type is Replace. + * type: array + * items: + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * description: The ID of the Product Variant to ship. + * type: string + * quantity: + * description: The quantity of the Product Variant to ship. + * type: integer + * shipping_methods: + * description: The Shipping Methods to send the additional Line Items with. + * type: array + * items: + * properties: + * id: + * description: The ID of an existing Shipping Method + * type: string + * option_id: + * description: The ID of the Shipping Option to create a Shipping Method from + * type: string + * price: + * description: The price to charge for the Shipping Method + * type: integer + * shipping_address: + * type: object + * description: "An optional shipping address to send the claim to. Defaults to the parent order's shipping address" + * $ref: "#/components/schemas/Address" + * refund_amount: + * description: The amount to refund the Customer when the Claim type is `refund`. + * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostOrdersOrderClaimsReq { @IsEnum(ClaimType) @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.ts b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.ts index 2feb371d79..b661509de2 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.ts @@ -28,30 +28,7 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean" * content: * application/json: * schema: - * type: object - * required: - * - items - * properties: - * items: - * description: The Line Items to include in the Fulfillment. - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of Line Item to fulfill. - * type: string - * quantity: - * description: The quantity of the Line Item to fulfill. - * type: integer - * no_notification: - * description: If set to true no notification will be send related to this Swap. - * type: boolean - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostOrdersOrderFulfillmentsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -140,6 +117,33 @@ export default async (req, res) => { res.json({ order }) } +/** + * @schema AdminPostOrdersOrderFulfillmentsReq + * type: object + * required: + * - items + * properties: + * items: + * description: The Line Items to include in the Fulfillment. + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of Line Item to fulfill. + * type: string + * quantity: + * description: The quantity of the Line Item to fulfill. + * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostOrdersOrderFulfillmentsReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-shipment.ts b/packages/medusa/src/api/routes/admin/orders/create-shipment.ts index 5e037ac51f..4c8e83bcf5 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-shipment.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-shipment.ts @@ -24,21 +24,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - fulfillment_id - * properties: - * fulfillment_id: - * description: The ID of the Fulfillment. - * type: string - * tracking_numbers: - * description: The tracking numbers for the shipment. - * type: array - * items: - * type: string - * no_notification: - * description: If set to true no notification will be send related to this Shipment. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderShipmentReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -121,6 +107,24 @@ export default async (req, res) => { res.json({ order }) } +/** + * @schema AdminPostOrdersOrderShipmentReq + * type: object + * required: + * - fulfillment_id + * properties: + * fulfillment_id: + * description: The ID of the Fulfillment. + * type: string + * tracking_numbers: + * description: The tracking numbers for the shipment. + * type: array + * items: + * type: string + * no_notification: + * description: If set to true no notification will be send related to this Shipment. + * type: boolean + */ export class AdminPostOrdersOrderShipmentReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.ts b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.ts index f8f6f80b4b..5064acf071 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.ts @@ -24,21 +24,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - fulfillment_id - * properties: - * fulfillment_id: - * description: The ID of the Fulfillment. - * type: string - * tracking_numbers: - * description: The tracking numbers for the shipment. - * type: array - * items: - * type: string - * no_notification: - * description: If set to true no notification will be sent related to this Claim. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderSwapsSwapShipmentsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -118,6 +104,24 @@ export default async (req, res) => { res.json({ order }) } +/** + * @schema AdminPostOrdersOrderSwapsSwapShipmentsReq + * type: object + * required: + * - fulfillment_id + * properties: + * fulfillment_id: + * description: The ID of the Fulfillment. + * type: string + * tracking_numbers: + * description: The tracking numbers for the shipment. + * type: array + * items: + * type: string + * no_notification: + * description: If set to true no notification will be sent related to this Claim. + * type: boolean + */ export class AdminPostOrdersOrderSwapsSwapShipmentsReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.ts b/packages/medusa/src/api/routes/admin/orders/create-swap.ts index cea46c2ce0..06e7fb45ff 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.ts +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.ts @@ -35,77 +35,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - return_items - * properties: - * return_items: - * description: The Line Items to return as part of the Swap. - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item that will be claimed. - * type: string - * quantity: - * description: The number of items that will be returned - * type: integer - * reason_id: - * description: The ID of the Return Reason to use. - * type: string - * note: - * description: An optional note with information about the Return. - * type: string - * return_shipping: - * description: How the Swap will be returned. - * type: object - * required: - * - option_id - * properties: - * option_id: - * type: string - * description: The ID of the Shipping Option to create the Shipping Method from. - * price: - * type: integer - * description: The price to charge for the Shipping Method. - * additional_items: - * description: The new items to send to the Customer. - * type: array - * items: - * required: - * - variant_id - * - quantity - * properties: - * variant_id: - * description: The ID of the Product Variant to ship. - * type: string - * quantity: - * description: The quantity of the Product Variant to ship. - * type: integer - * custom_shipping_options: - * description: The custom shipping options to potentially create a Shipping Method from. - * type: array - * items: - * required: - * - option_id - * - price - * properties: - * option_id: - * description: The ID of the Shipping Option to override with a custom price. - * type: string - * price: - * description: The custom price of the Shipping Option. - * type: integer - * no_notification: - * description: If set to true no notification will be send related to this Swap. - * type: boolean - * allow_backorder: - * description: If true, swaps can be completed with items out of stock - * type: boolean - * default: true + * $ref: "#/components/schemas/AdminPostOrdersOrderSwapsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -323,6 +253,80 @@ export default async (req, res) => { res.status(idempotencyKey.response_code).json(idempotencyKey.response_body) } +/** + * @schema AdminPostOrdersOrderSwapsReq + * type: object + * required: + * - return_items + * properties: + * return_items: + * description: The Line Items to return as part of the Swap. + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item that will be claimed. + * type: string + * quantity: + * description: The number of items that will be returned + * type: integer + * reason_id: + * description: The ID of the Return Reason to use. + * type: string + * note: + * description: An optional note with information about the Return. + * type: string + * return_shipping: + * description: How the Swap will be returned. + * type: object + * required: + * - option_id + * properties: + * option_id: + * type: string + * description: The ID of the Shipping Option to create the Shipping Method from. + * price: + * type: integer + * description: The price to charge for the Shipping Method. + * additional_items: + * description: The new items to send to the Customer. + * type: array + * items: + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * description: The ID of the Product Variant to ship. + * type: string + * quantity: + * description: The quantity of the Product Variant to ship. + * type: integer + * custom_shipping_options: + * description: The custom shipping options to potentially create a Shipping Method from. + * type: array + * items: + * required: + * - option_id + * - price + * properties: + * option_id: + * description: The ID of the Shipping Option to override with a custom price. + * type: string + * price: + * description: The custom price of the Shipping Option. + * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean + * allow_backorder: + * description: If true, swaps can be completed with items out of stock + * type: boolean + * default: true + */ export class AdminPostOrdersOrderSwapsReq { @IsArray() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.ts b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.ts index 0536b1a1da..e1341a615f 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.ts +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.ts @@ -18,14 +18,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object - * no_notification: - * description: If set to true no notification will be send related to this Claim. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimFulfillmentsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -97,6 +90,17 @@ export default async (req, res) => { res.status(200).json({ order }) } +/** + * @schema AdminPostOrdersOrderClaimsClaimFulfillmentsReq + * type: object + * properties: + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean + */ export class AdminPostOrdersOrderClaimsClaimFulfillmentsReq { @IsObject() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.ts b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.ts index 57b150fc5e..d7b8cea002 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.ts +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.ts @@ -18,14 +18,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object - * no_notification: - * description: If set to true no notification will be send related to this Claim. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderSwapsSwapFulfillmentsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -97,6 +90,17 @@ export default async (req, res) => { res.status(200).json({ order }) } +/** + * @schema AdminPostOrdersOrderSwapsSwapFulfillmentsReq + * type: object + * properties: + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean + */ export class AdminPostOrdersOrderSwapsSwapFulfillmentsReq { @IsObject() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.ts b/packages/medusa/src/api/routes/admin/orders/refund-payment.ts index 8c1e57e398..71d0aaeb2e 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.ts +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.ts @@ -23,23 +23,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - amount - * - reason - * properties: - * amount: - * description: The amount to refund. - * type: integer - * reason: - * description: The reason for the Refund. - * type: string - * note: - * description: A note with additional details about the Refund. - * type: string - * no_notification: - * description: If set to true no notification will be send related to this Refund. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderRefundsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -116,6 +100,26 @@ export default async (req, res) => { res.status(200).json({ order }) } +/** + * @schema AdminPostOrdersOrderRefundsReq + * type: object + * required: + * - amount + * - reason + * properties: + * amount: + * description: The amount to refund. + * type: integer + * reason: + * description: The reason for the Refund. + * type: string + * note: + * description: A note with additional details about the Refund. + * type: string + * no_notification: + * description: If set to true no notification will be send related to this Refund. + * type: boolean + */ export class AdminPostOrdersOrderRefundsReq { @IsInt() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/orders/request-return.ts b/packages/medusa/src/api/routes/admin/orders/request-return.ts index 6cc76e22e1..071c8c0330 100644 --- a/packages/medusa/src/api/routes/admin/orders/request-return.ts +++ b/packages/medusa/src/api/routes/admin/orders/request-return.ts @@ -32,53 +32,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - items - * properties: - * items: - * description: The Line Items that will be returned. - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item. - * type: string - * reason_id: - * description: The ID of the Return Reason to use. - * type: string - * note: - * description: An optional note with information about the Return. - * type: string - * quantity: - * description: The quantity of the Line Item. - * type: integer - * return_shipping: - * description: The Shipping Method to be used to handle the return shipment. - * type: object - * properties: - * option_id: - * type: string - * description: The ID of the Shipping Option to create the Shipping Method from. - * price: - * type: integer - * description: The price to charge for the Shipping Method. - * note: - * description: An optional note with information about the Return. - * type: string - * receive_now: - * description: A flag to indicate if the Return should be registerd as received immediately. - * type: boolean - * default: false - * no_notification: - * description: A flag to indicate if no notifications should be emitted related to the requested Return. - * type: boolean - * refund: - * description: The amount to refund. - * type: integer + * $ref: "#/components/schemas/AdminPostOrdersOrderReturnsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -333,6 +287,56 @@ type ReturnObj = { no_notification?: boolean } +/** + * @schema AdminPostOrdersOrderReturnsReq + * type: object + * required: + * - items + * properties: + * items: + * description: The Line Items that will be returned. + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item. + * type: string + * reason_id: + * description: The ID of the Return Reason to use. + * type: string + * note: + * description: An optional note with information about the Return. + * type: string + * quantity: + * description: The quantity of the Line Item. + * type: integer + * return_shipping: + * description: The Shipping Method to be used to handle the return shipment. + * type: object + * properties: + * option_id: + * type: string + * description: The ID of the Shipping Option to create the Shipping Method from. + * price: + * type: integer + * description: The price to charge for the Shipping Method. + * note: + * description: An optional note with information about the Return. + * type: string + * receive_now: + * description: A flag to indicate if the Return should be registerd as received immediately. + * type: boolean + * default: false + * no_notification: + * description: A flag to indicate if no notifications should be emitted related to the requested Return. + * type: boolean + * refund: + * description: The amount to refund. + * type: integer + */ export class AdminPostOrdersOrderReturnsReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/orders/update-claim.ts b/packages/medusa/src/api/routes/admin/orders/update-claim.ts index daf277db6a..17850db22b 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-claim.ts +++ b/packages/medusa/src/api/routes/admin/orders/update-claim.ts @@ -28,84 +28,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * claim_items: - * description: The Claim Items that the Claim will consist of. - * type: array - * items: - * required: - * - id - * - images - * - tags - * properties: - * id: - * description: The ID of the Claim Item. - * type: string - * item_id: - * description: The ID of the Line Item that will be claimed. - * type: string - * quantity: - * description: The number of items that will be returned - * type: integer - * note: - * description: Short text describing the Claim Item in further detail. - * type: string - * reason: - * description: The reason for the Claim - * type: string - * enum: - * - missing_item - * - wrong_item - * - production_failure - * - other - * tags: - * description: A list o tags to add to the Claim Item - * type: array - * items: - * type: object - * properties: - * id: - * type: string - * description: Tag ID - * value: - * type: string - * description: Tag value - * images: - * description: A list of image URL's that will be associated with the Claim - * type: array - * items: - * type: object - * properties: - * id: - * type: string - * description: Image ID - * url: - * type: string - * description: Image URL - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object - * shipping_methods: - * description: The Shipping Methods to send the additional Line Items with. - * type: array - * items: - * properties: - * id: - * description: The ID of an existing Shipping Method - * type: string - * option_id: - * description: The ID of the Shipping Option to create a Shipping Method from - * type: string - * price: - * description: The price to charge for the Shipping Method - * type: integer - * no_notification: - * description: If set to true no notification will be send related to this Swap. - * type: boolean - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminPostOrdersOrderClaimsClaimReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -182,6 +105,87 @@ export default async (req, res) => { res.json({ order: data }) } +/** + * @schema AdminPostOrdersOrderClaimsClaimReq + * type: object + * properties: + * claim_items: + * description: The Claim Items that the Claim will consist of. + * type: array + * items: + * required: + * - id + * - images + * - tags + * properties: + * id: + * description: The ID of the Claim Item. + * type: string + * item_id: + * description: The ID of the Line Item that will be claimed. + * type: string + * quantity: + * description: The number of items that will be returned + * type: integer + * note: + * description: Short text describing the Claim Item in further detail. + * type: string + * reason: + * description: The reason for the Claim + * type: string + * enum: + * - missing_item + * - wrong_item + * - production_failure + * - other + * tags: + * description: A list o tags to add to the Claim Item + * type: array + * items: + * type: object + * properties: + * id: + * type: string + * description: Tag ID + * value: + * type: string + * description: Tag value + * images: + * description: A list of image URL's that will be associated with the Claim + * type: array + * items: + * type: object + * properties: + * id: + * type: string + * description: Image ID + * url: + * type: string + * description: Image URL + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + * shipping_methods: + * description: The Shipping Methods to send the additional Line Items with. + * type: array + * items: + * properties: + * id: + * description: The ID of an existing Shipping Method + * type: string + * option_id: + * description: The ID of the Shipping Option to create a Shipping Method from + * type: string + * price: + * description: The price to charge for the Shipping Method + * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminPostOrdersOrderClaimsClaimReq { @IsArray() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.ts b/packages/medusa/src/api/routes/admin/orders/update-order.ts index 56f45e72e1..45b6febf2d 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.ts +++ b/packages/medusa/src/api/routes/admin/orders/update-order.ts @@ -28,69 +28,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * email: - * description: the email for the order - * type: string - * billing_address: - * description: Billing address - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * shipping_address: - * description: Shipping address - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * items: - * description: The Line Items for the order - * type: array - * items: - * $ref: "#/components/schemas/LineItem" - * region: - * description: ID of the region where the order belongs - * type: string - * discounts: - * description: Discounts applied to the order - * type: array - * items: - * $ref: "#/components/schemas/Discount" - * customer_id: - * description: ID of the customer - * type: string - * payment_method: - * description: payment method chosen for the order - * type: object - * properties: - * provider_id: - * type: string - * description: ID of the payment provider - * data: - * description: Data relevant for the given payment method - * type: object - * shipping_method: - * description: The Shipping Method used for shipping the order. - * type: object - * properties: - * provider_id: - * type: string - * description: The ID of the shipping provider. - * profile_id: - * type: string - * description: The ID of the shipping profile. - * price: - * type: integer - * description: The price of the shipping. - * data: - * type: object - * description: Data relevant to the specific shipping method. - * items: - * type: array - * items: - * $ref: "#/components/schemas/LineItem" - * description: Items to ship - * no_notification: - * description: A flag to indicate if no notifications should be emitted related to the updated order. - * type: boolean + * $ref: "#/components/schemas/AdminPostOrdersOrderReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -164,6 +102,72 @@ export default async (req, res) => { res.status(200).json({ order }) } +/** + * @schema AdminPostOrdersOrderReq + * type: object + * properties: + * email: + * description: the email for the order + * type: string + * billing_address: + * description: Billing address + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * shipping_address: + * description: Shipping address + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * items: + * description: The Line Items for the order + * type: array + * items: + * $ref: "#/components/schemas/LineItem" + * region: + * description: ID of the region where the order belongs + * type: string + * discounts: + * description: Discounts applied to the order + * type: array + * items: + * $ref: "#/components/schemas/Discount" + * customer_id: + * description: ID of the customer + * type: string + * payment_method: + * description: payment method chosen for the order + * type: object + * properties: + * provider_id: + * type: string + * description: ID of the payment provider + * data: + * description: Data relevant for the given payment method + * type: object + * shipping_method: + * description: The Shipping Method used for shipping the order. + * type: object + * properties: + * provider_id: + * type: string + * description: The ID of the shipping provider. + * profile_id: + * type: string + * description: The ID of the shipping profile. + * price: + * type: integer + * description: The price of the shipping. + * data: + * type: object + * description: Data relevant to the specific shipping method. + * items: + * type: array + * items: + * $ref: "#/components/schemas/LineItem" + * description: Items to ship + * no_notification: + * description: A flag to indicate if no notifications should be emitted related to the updated order. + * type: boolean + */ export class AdminPostOrdersOrderReq { @IsEmail() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/payment-collections/update-payment-collection.ts b/packages/medusa/src/api/routes/admin/payment-collections/update-payment-collection.ts index 6a6c8eefc9..40adb2aed9 100644 --- a/packages/medusa/src/api/routes/admin/payment-collections/update-payment-collection.ts +++ b/packages/medusa/src/api/routes/admin/payment-collections/update-payment-collection.ts @@ -15,14 +15,7 @@ import { PaymentCollectionService } from "../../../../services" * content: * application/json: * schema: - * type: object - * properties: - * description: - * description: An optional description to create or update the payment collection. - * type: string - * metadata: - * description: An optional set of key-value pairs to hold additional information. - * type: object + * $ref: "#/components/schemas/AdminUpdatePaymentCollectionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -93,6 +86,17 @@ export default async (req, res) => { res.status(200).json({ payment_collection: paymentCollection }) } +/** + * @schema AdminUpdatePaymentCollectionsReq + * type: object + * properties: + * description: + * description: An optional description to create or update the payment collection. + * type: string + * metadata: + * description: An optional set of key-value pairs to hold additional information. + * type: object + */ export class AdminUpdatePaymentCollectionsReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/payments/refund-payment.ts b/packages/medusa/src/api/routes/admin/payments/refund-payment.ts index 3439ab8abf..3469adfd3b 100644 --- a/packages/medusa/src/api/routes/admin/payments/refund-payment.ts +++ b/packages/medusa/src/api/routes/admin/payments/refund-payment.ts @@ -21,20 +21,7 @@ import { PaymentService } from "../../../../services" * content: * application/json: * schema: - * type: object - * required: - * - amount - * - reason - * properties: - * amount: - * description: The amount to refund. - * type: integer - * reason: - * description: The reason for the Refund. - * type: string - * note: - * description: A note with additional details about the Refund. - * type: string + * $ref: "#/components/schemas/AdminPostPaymentRefundsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -106,6 +93,23 @@ export default async (req, res) => { res.status(200).json({ refund }) } +/** + * @schema AdminPostPaymentRefundsReq + * type: object + * required: + * - amount + * - reason + * properties: + * amount: + * description: The amount to refund. + * type: integer + * reason: + * description: The reason for the Refund. + * type: string + * note: + * description: A note with additional details about the Refund. + * type: string + */ export class AdminPostPaymentRefundsReq { @IsInt() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/price-lists/add-prices-batch.ts b/packages/medusa/src/api/routes/admin/price-lists/add-prices-batch.ts index 25eda69b3e..f74f2b2e05 100644 --- a/packages/medusa/src/api/routes/admin/price-lists/add-prices-batch.ts +++ b/packages/medusa/src/api/routes/admin/price-lists/add-prices-batch.ts @@ -20,43 +20,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * prices: - * description: The prices to update or add. - * type: array - * items: - * required: - * - amount - * - variant_id - * properties: - * id: - * description: The ID of the price. - * type: string - * region_id: - * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * variant_id: - * description: The ID of the Variant for which the price is used. - * type: string - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * override: - * description: "If true the prices will replace all existing prices associated with the Price List." - * type: boolean + * $ref: "#/components/schemas/AdminPostPriceListPricesPricesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -142,6 +106,46 @@ export default async (req, res) => { res.json({ price_list: priceList }) } +/** + * @schema AdminPostPriceListPricesPricesReq + * type: object + * properties: + * prices: + * description: The prices to update or add. + * type: array + * items: + * required: + * - amount + * - variant_id + * properties: + * id: + * description: The ID of the price. + * type: string + * region_id: + * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * variant_id: + * description: The ID of the Variant for which the price is used. + * type: string + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * override: + * description: "If true the prices will replace all existing prices associated with the Price List." + * type: boolean + */ export class AdminPostPriceListPricesPricesReq { @IsArray() @Type(() => AdminPriceListPricesUpdateReq) diff --git a/packages/medusa/src/api/routes/admin/price-lists/create-price-list.ts b/packages/medusa/src/api/routes/admin/price-lists/create-price-list.ts index 6e5c6cae95..9de22ab2e3 100644 --- a/packages/medusa/src/api/routes/admin/price-lists/create-price-list.ts +++ b/packages/medusa/src/api/routes/admin/price-lists/create-price-list.ts @@ -30,81 +30,7 @@ import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators * content: * application/json: * schema: - * type: object - * required: - * - name - * - description - * - type - * - prices - * properties: - * name: - * description: "The name of the Price List" - * type: string - * description: - * description: "A description of the Price List." - * type: string - * starts_at: - * description: "The date with timezone that the Price List starts being valid." - * type: string - * format: date - * ends_at: - * description: "The date with timezone that the Price List ends being valid." - * type: string - * format: date - * type: - * description: The type of the Price List. - * type: string - * enum: - * - sale - * - override - * status: - * description: The status of the Price List. - * type: string - * enum: - * - active - * - draft - * prices: - * description: The prices of the Price List. - * type: array - * items: - * required: - * - amount - * - variant_id - * properties: - * region_id: - * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * variant_id: - * description: The ID of the Variant for which the price is used. - * type: string - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * customer_groups: - * type: array - * description: A list of customer groups that the Price List applies to. - * items: - * required: - * - id - * properties: - * id: - * description: The ID of a customer group - * type: string - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of price list" - * type: boolean + * $ref: "#/components/schemas/AdminPostPriceListsPriceListReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -193,6 +119,84 @@ class CustomerGroup { id: string } +/** + * @schema AdminPostPriceListsPriceListReq + * type: object + * required: + * - name + * - description + * - type + * - prices + * properties: + * name: + * description: "The name of the Price List" + * type: string + * description: + * description: "A description of the Price List." + * type: string + * starts_at: + * description: "The date with timezone that the Price List starts being valid." + * type: string + * format: date + * ends_at: + * description: "The date with timezone that the Price List ends being valid." + * type: string + * format: date + * type: + * description: The type of the Price List. + * type: string + * enum: + * - sale + * - override + * status: + * description: The status of the Price List. + * type: string + * enum: + * - active + * - draft + * prices: + * description: The prices of the Price List. + * type: array + * items: + * required: + * - amount + * - variant_id + * properties: + * region_id: + * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * variant_id: + * description: The ID of the Variant for which the price is used. + * type: string + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * customer_groups: + * type: array + * description: A list of customer groups that the Price List applies to. + * items: + * required: + * - id + * properties: + * id: + * description: The ID of a customer group + * type: string + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of price list" + * type: boolean + */ export class AdminPostPriceListsPriceListReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/price-lists/delete-prices-batch.ts b/packages/medusa/src/api/routes/admin/price-lists/delete-prices-batch.ts index e2e5a3d1ba..bac74cba33 100644 --- a/packages/medusa/src/api/routes/admin/price-lists/delete-prices-batch.ts +++ b/packages/medusa/src/api/routes/admin/price-lists/delete-prices-batch.ts @@ -16,13 +16,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * price_ids: - * description: The price id's of the Money Amounts to delete. - * type: array - * items: - * type: string + * $ref: "#/components/schemas/AdminDeletePriceListPricesPricesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -109,6 +103,16 @@ export default async (req, res) => { res.json({ ids: validated.price_ids, object: "money-amount", deleted: true }) } +/** + * @schema AdminDeletePriceListPricesPricesReq + * type: object + * properties: + * price_ids: + * description: The price id's of the Money Amounts to delete. + * type: array + * items: + * type: string + */ export class AdminDeletePriceListPricesPricesReq { @ArrayNotEmpty() @IsString({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/price-lists/update-price-list.ts b/packages/medusa/src/api/routes/admin/price-lists/update-price-list.ts index b5140b4448..5b89f4fb2e 100644 --- a/packages/medusa/src/api/routes/admin/price-lists/update-price-list.ts +++ b/packages/medusa/src/api/routes/admin/price-lists/update-price-list.ts @@ -33,79 +33,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * name: - * description: "The name of the Price List" - * type: string - * description: - * description: "A description of the Price List." - * type: string - * starts_at: - * description: "The date with timezone that the Price List starts being valid." - * type: string - * format: date - * ends_at: - * description: "The date with timezone that the Price List ends being valid." - * type: string - * format: date - * type: - * description: The type of the Price List. - * type: string - * enum: - * - sale - * - override - * status: - * description: The status of the Price List. - * type: string - * enum: - * - active - * - draft - * prices: - * description: The prices of the Price List. - * type: array - * items: - * required: - * - amount - * - variant_id - * properties: - * id: - * description: The ID of the price. - * type: string - * region_id: - * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * variant_id: - * description: The ID of the Variant for which the price is used. - * type: string - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * customer_groups: - * type: array - * description: A list of customer groups that the Price List applies to. - * items: - * required: - * - id - * properties: - * id: - * description: The ID of a customer group - * type: string - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of price list" - * type: boolean + * $ref: "#/components/schemas/AdminPostPriceListsPriceListPriceListReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -187,6 +115,82 @@ class CustomerGroup { id: string } +/** + * @schema AdminPostPriceListsPriceListPriceListReq + * type: object + * properties: + * name: + * description: "The name of the Price List" + * type: string + * description: + * description: "A description of the Price List." + * type: string + * starts_at: + * description: "The date with timezone that the Price List starts being valid." + * type: string + * format: date + * ends_at: + * description: "The date with timezone that the Price List ends being valid." + * type: string + * format: date + * type: + * description: The type of the Price List. + * type: string + * enum: + * - sale + * - override + * status: + * description: The status of the Price List. + * type: string + * enum: + * - active + * - draft + * prices: + * description: The prices of the Price List. + * type: array + * items: + * required: + * - amount + * - variant_id + * properties: + * id: + * description: The ID of the price. + * type: string + * region_id: + * description: The ID of the Region for which the price is used. Only required if currecny_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * variant_id: + * description: The ID of the Variant for which the price is used. + * type: string + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * customer_groups: + * type: array + * description: A list of customer groups that the Price List applies to. + * items: + * required: + * - id + * properties: + * id: + * description: The ID of a customer group + * type: string + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of price list" + * type: boolean + */ export class AdminPostPriceListsPriceListPriceListReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/products/add-option.ts b/packages/medusa/src/api/routes/admin/products/add-option.ts index f734392b66..a9961da027 100644 --- a/packages/medusa/src/api/routes/admin/products/add-option.ts +++ b/packages/medusa/src/api/routes/admin/products/add-option.ts @@ -17,13 +17,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - title - * properties: - * title: - * description: "The title the Product Option will be identified by i.e. \"Size\"" - * type: string + * $ref: "#/components/schemas/AdminPostProductsProductOptionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -102,6 +96,16 @@ export default async (req, res) => { res.json({ product }) } +/** + * @schema AdminPostProductsProductOptionsReq + * type: object + * required: + * - title + * properties: + * title: + * description: "The title the Product Option will be identified by i.e. \"Size\"" + * type: string + */ export class AdminPostProductsProductOptionsReq { @IsString() title: string diff --git a/packages/medusa/src/api/routes/admin/products/create-product.ts b/packages/medusa/src/api/routes/admin/products/create-product.ts index 6f261faac9..b31cbe9de3 100644 --- a/packages/medusa/src/api/routes/admin/products/create-product.ts +++ b/packages/medusa/src/api/routes/admin/products/create-product.ts @@ -42,210 +42,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - title - * properties: - * title: - * description: "The title of the Product" - * type: string - * subtitle: - * description: "The subtitle of the Product" - * type: string - * description: - * description: "A description of the Product." - * type: string - * is_giftcard: - * description: A flag to indicate if the Product represents a Gift Card. Purchasing Products with this flag set to `true` will result in a Gift Card being created. - * type: boolean - * default: false - * discountable: - * description: A flag to indicate if discounts can be applied to the LineItems generated from this Product - * type: boolean - * default: true - * images: - * description: Images of the Product. - * type: array - * items: - * type: string - * thumbnail: - * description: The thumbnail to use for the Product. - * type: string - * handle: - * description: A unique handle to identify the Product by. - * type: string - * status: - * description: The status of the product. - * type: string - * enum: [draft, proposed, published, rejected] - * default: draft - * type: - * description: The Product Type to associate the Product with. - * type: object - * required: - * - value - * properties: - * id: - * description: The ID of the Product Type. - * type: string - * value: - * description: The value of the Product Type. - * type: string - * collection_id: - * description: The ID of the Collection the Product should belong to. - * type: string - * tags: - * description: Tags to associate the Product with. - * type: array - * items: - * required: - * - value - * properties: - * id: - * description: The ID of an existing Tag. - * type: string - * value: - * description: The value of the Tag, these will be upserted. - * type: string - * sales_channels: - * description: "[EXPERIMENTAL] Sales channels to associate the Product with." - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: The ID of an existing Sales channel. - * type: string - * options: - * description: The Options that the Product should have. These define on which properties the Product's Product Variants will differ. - * type: array - * items: - * required: - * - title - * properties: - * title: - * description: The title to identify the Product Option by. - * type: string - * variants: - * description: A list of Product Variants to create with the Product. - * type: array - * items: - * required: - * - title - * properties: - * title: - * description: The title to identify the Product Variant by. - * type: string - * sku: - * description: The unique SKU for the Product Variant. - * type: string - * ean: - * description: The EAN number of the item. - * type: string - * upc: - * description: The UPC number of the item. - * type: string - * barcode: - * description: A generic GTIN field for the Product Variant. - * type: string - * hs_code: - * description: The Harmonized System code for the Product Variant. - * type: string - * inventory_quantity: - * description: The amount of stock kept for the Product Variant. - * type: integer - * default: 0 - * allow_backorder: - * description: Whether the Product Variant can be purchased when out of stock. - * type: boolean - * manage_inventory: - * description: Whether Medusa should keep track of the inventory for this Product Variant. - * type: boolean - * weight: - * description: The wieght of the Product Variant. - * type: number - * length: - * description: The length of the Product Variant. - * type: number - * height: - * description: The height of the Product Variant. - * type: number - * width: - * description: The width of the Product Variant. - * type: number - * origin_country: - * description: The country of origin of the Product Variant. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product Variant. - * type: string - * material: - * description: The material composition of the Product Variant. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object - * prices: - * type: array - * items: - * required: - * - amount - * properties: - * region_id: - * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * options: - * type: array - * items: - * required: - * - value - * properties: - * value: - * description: The value to give for the Product Option at the same index in the Product's `options` field. - * type: string - * weight: - * description: The weight of the Product. - * type: number - * length: - * description: The length of the Product. - * type: number - * height: - * description: The height of the Product. - * type: number - * width: - * description: The width of the Product. - * type: number - * hs_code: - * description: The Harmonized System code for the Product Variant. - * type: string - * origin_country: - * description: The country of origin of the Product. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product. - * type: string - * material: - * description: The material composition of the Product. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object + * $ref: "#/components/schemas/AdminPostProductsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -467,6 +264,213 @@ class ProductVariantReq { options?: ProductVariantOptionReq[] = [] } +/** + * @schema AdminPostProductsReq + * type: object + * required: + * - title + * properties: + * title: + * description: "The title of the Product" + * type: string + * subtitle: + * description: "The subtitle of the Product" + * type: string + * description: + * description: "A description of the Product." + * type: string + * is_giftcard: + * description: A flag to indicate if the Product represents a Gift Card. Purchasing Products with this flag set to `true` will result in a Gift Card being created. + * type: boolean + * default: false + * discountable: + * description: A flag to indicate if discounts can be applied to the LineItems generated from this Product + * type: boolean + * default: true + * images: + * description: Images of the Product. + * type: array + * items: + * type: string + * thumbnail: + * description: The thumbnail to use for the Product. + * type: string + * handle: + * description: A unique handle to identify the Product by. + * type: string + * status: + * description: The status of the product. + * type: string + * enum: [draft, proposed, published, rejected] + * default: draft + * type: + * description: The Product Type to associate the Product with. + * type: object + * required: + * - value + * properties: + * id: + * description: The ID of the Product Type. + * type: string + * value: + * description: The value of the Product Type. + * type: string + * collection_id: + * description: The ID of the Collection the Product should belong to. + * type: string + * tags: + * description: Tags to associate the Product with. + * type: array + * items: + * required: + * - value + * properties: + * id: + * description: The ID of an existing Tag. + * type: string + * value: + * description: The value of the Tag, these will be upserted. + * type: string + * sales_channels: + * description: "[EXPERIMENTAL] Sales channels to associate the Product with." + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: The ID of an existing Sales channel. + * type: string + * options: + * description: The Options that the Product should have. These define on which properties the Product's Product Variants will differ. + * type: array + * items: + * required: + * - title + * properties: + * title: + * description: The title to identify the Product Option by. + * type: string + * variants: + * description: A list of Product Variants to create with the Product. + * type: array + * items: + * required: + * - title + * properties: + * title: + * description: The title to identify the Product Variant by. + * type: string + * sku: + * description: The unique SKU for the Product Variant. + * type: string + * ean: + * description: The EAN number of the item. + * type: string + * upc: + * description: The UPC number of the item. + * type: string + * barcode: + * description: A generic GTIN field for the Product Variant. + * type: string + * hs_code: + * description: The Harmonized System code for the Product Variant. + * type: string + * inventory_quantity: + * description: The amount of stock kept for the Product Variant. + * type: integer + * default: 0 + * allow_backorder: + * description: Whether the Product Variant can be purchased when out of stock. + * type: boolean + * manage_inventory: + * description: Whether Medusa should keep track of the inventory for this Product Variant. + * type: boolean + * weight: + * description: The wieght of the Product Variant. + * type: number + * length: + * description: The length of the Product Variant. + * type: number + * height: + * description: The height of the Product Variant. + * type: number + * width: + * description: The width of the Product Variant. + * type: number + * origin_country: + * description: The country of origin of the Product Variant. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product Variant. + * type: string + * material: + * description: The material composition of the Product Variant. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + * prices: + * type: array + * items: + * required: + * - amount + * properties: + * region_id: + * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * options: + * type: array + * items: + * required: + * - value + * properties: + * value: + * description: The value to give for the Product Option at the same index in the Product's `options` field. + * type: string + * weight: + * description: The weight of the Product. + * type: number + * length: + * description: The length of the Product. + * type: number + * height: + * description: The height of the Product. + * type: number + * width: + * description: The width of the Product. + * type: number + * hs_code: + * description: The Harmonized System code for the Product Variant. + * type: string + * origin_country: + * description: The country of origin of the Product. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product. + * type: string + * material: + * description: The material composition of the Product. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + */ export class AdminPostProductsReq { @IsString() title: string diff --git a/packages/medusa/src/api/routes/admin/products/create-variant.ts b/packages/medusa/src/api/routes/admin/products/create-variant.ts index 66baa3c6bb..9d3b3e513b 100644 --- a/packages/medusa/src/api/routes/admin/products/create-variant.ts +++ b/packages/medusa/src/api/routes/admin/products/create-variant.ts @@ -30,104 +30,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - title - * - prices - * - options - * properties: - * title: - * description: The title to identify the Product Variant by. - * type: string - * sku: - * description: The unique SKU for the Product Variant. - * type: string - * ean: - * description: The EAN number of the item. - * type: string - * upc: - * description: The UPC number of the item. - * type: string - * barcode: - * description: A generic GTIN field for the Product Variant. - * type: string - * hs_code: - * description: The Harmonized System code for the Product Variant. - * type: string - * inventory_quantity: - * description: The amount of stock kept for the Product Variant. - * type: integer - * default: 0 - * allow_backorder: - * description: Whether the Product Variant can be purchased when out of stock. - * type: boolean - * manage_inventory: - * description: Whether Medusa should keep track of the inventory for this Product Variant. - * type: boolean - * weight: - * description: The wieght of the Product Variant. - * type: number - * length: - * description: The length of the Product Variant. - * type: number - * height: - * description: The height of the Product Variant. - * type: number - * width: - * description: The width of the Product Variant. - * type: number - * origin_country: - * description: The country of origin of the Product Variant. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product Variant. - * type: string - * material: - * description: The material composition of the Product Variant. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object - * prices: - * type: array - * items: - * required: - * - amount - * properties: - * id: - * description: The ID of the price. - * type: string - * region_id: - * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * options: - * type: array - * items: - * required: - * - option_id - * - value - * properties: - * option_id: - * description: The ID of the Product Option to set the value for. - * type: string - * value: - * description: The value to give for the Product Option. - * type: string + * $ref: "#/components/schemas/AdminPostProductsProductVariantsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -239,6 +142,107 @@ class ProductVariantOptionReq { option_id: string } +/** + * @schema AdminPostProductsProductVariantsReq + * type: object + * required: + * - title + * - prices + * - options + * properties: + * title: + * description: The title to identify the Product Variant by. + * type: string + * sku: + * description: The unique SKU for the Product Variant. + * type: string + * ean: + * description: The EAN number of the item. + * type: string + * upc: + * description: The UPC number of the item. + * type: string + * barcode: + * description: A generic GTIN field for the Product Variant. + * type: string + * hs_code: + * description: The Harmonized System code for the Product Variant. + * type: string + * inventory_quantity: + * description: The amount of stock kept for the Product Variant. + * type: integer + * default: 0 + * allow_backorder: + * description: Whether the Product Variant can be purchased when out of stock. + * type: boolean + * manage_inventory: + * description: Whether Medusa should keep track of the inventory for this Product Variant. + * type: boolean + * weight: + * description: The wieght of the Product Variant. + * type: number + * length: + * description: The length of the Product Variant. + * type: number + * height: + * description: The height of the Product Variant. + * type: number + * width: + * description: The width of the Product Variant. + * type: number + * origin_country: + * description: The country of origin of the Product Variant. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product Variant. + * type: string + * material: + * description: The material composition of the Product Variant. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + * prices: + * type: array + * items: + * required: + * - amount + * properties: + * id: + * description: The ID of the price. + * type: string + * region_id: + * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * options: + * type: array + * items: + * required: + * - option_id + * - value + * properties: + * option_id: + * description: The ID of the Product Option to set the value for. + * type: string + * value: + * description: The value to give for the Product Option. + * type: string + */ export class AdminPostProductsProductVariantsReq { @IsString() title: string diff --git a/packages/medusa/src/api/routes/admin/products/set-metadata.ts b/packages/medusa/src/api/routes/admin/products/set-metadata.ts index 4db9859bc6..f1aa54a758 100644 --- a/packages/medusa/src/api/routes/admin/products/set-metadata.ts +++ b/packages/medusa/src/api/routes/admin/products/set-metadata.ts @@ -16,17 +16,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - key - * - value - * properties: - * key: - * description: The metadata key - * type: string - * value: - * description: The metadata value - * type: string + * $ref: "#/components/schemas/AdminPostProductsProductMetadataReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -103,6 +93,20 @@ export default async (req, res) => { res.status(200).json({ product }) } +/** + * @schema AdminPostProductsProductMetadataReq + * type: object + * required: + * - key + * - value + * properties: + * key: + * description: The metadata key + * type: string + * value: + * description: The metadata value + * type: string + */ export class AdminPostProductsProductMetadataReq { @IsString() key: string diff --git a/packages/medusa/src/api/routes/admin/products/update-option.ts b/packages/medusa/src/api/routes/admin/products/update-option.ts index a92ad184e8..3cb1480ad2 100644 --- a/packages/medusa/src/api/routes/admin/products/update-option.ts +++ b/packages/medusa/src/api/routes/admin/products/update-option.ts @@ -18,13 +18,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - title - * properties: - * title: - * description: "The title of the Product Option" - * type: string + * $ref: "#/components/schemas/AdminPostProductsProductOptionsOption" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -100,6 +94,16 @@ export default async (req, res) => { res.json({ product }) } +/** + * @schema AdminPostProductsProductOptionsOption + * type: object + * required: + * - title + * properties: + * title: + * description: "The title of the Product Option" + * type: string + */ export class AdminPostProductsProductOptionsOption { @IsString() title: string diff --git a/packages/medusa/src/api/routes/admin/products/update-product.ts b/packages/medusa/src/api/routes/admin/products/update-product.ts index c5dccabc92..1c629d43ba 100644 --- a/packages/medusa/src/api/routes/admin/products/update-product.ts +++ b/packages/medusa/src/api/routes/admin/products/update-product.ts @@ -39,196 +39,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * title: - * description: "The title of the Product" - * type: string - * subtitle: - * description: "The subtitle of the Product" - * type: string - * description: - * description: "A description of the Product." - * type: string - * discountable: - * description: A flag to indicate if discounts can be applied to the LineItems generated from this Product - * type: boolean - * images: - * description: Images of the Product. - * type: array - * items: - * type: string - * thumbnail: - * description: The thumbnail to use for the Product. - * type: string - * handle: - * description: A unique handle to identify the Product by. - * type: string - * status: - * description: The status of the product. - * type: string - * enum: [draft, proposed, published, rejected] - * type: - * description: The Product Type to associate the Product with. - * type: object - * required: - * - value - * properties: - * id: - * description: The ID of the Product Type. - * type: string - * value: - * description: The value of the Product Type. - * type: string - * collection_id: - * description: The ID of the Collection the Product should belong to. - * type: string - * tags: - * description: Tags to associate the Product with. - * type: array - * items: - * required: - * - value - * properties: - * id: - * description: The ID of an existing Tag. - * type: string - * value: - * description: The value of the Tag, these will be upserted. - * type: string - * sales_channels: - * description: "[EXPERIMENTAL] Sales channels to associate the Product with." - * type: array - * items: - * required: - * - id - * properties: - * id: - * description: The ID of an existing Sales channel. - * type: string - * variants: - * description: A list of Product Variants to create with the Product. - * type: array - * items: - * properties: - * id: - * description: The ID of the Product Variant. - * type: string - * title: - * description: The title to identify the Product Variant by. - * type: string - * sku: - * description: The unique SKU for the Product Variant. - * type: string - * ean: - * description: The EAN number of the item. - * type: string - * upc: - * description: The UPC number of the item. - * type: string - * barcode: - * description: A generic GTIN field for the Product Variant. - * type: string - * hs_code: - * description: The Harmonized System code for the Product Variant. - * type: string - * inventory_quantity: - * description: The amount of stock kept for the Product Variant. - * type: integer - * allow_backorder: - * description: Whether the Product Variant can be purchased when out of stock. - * type: boolean - * manage_inventory: - * description: Whether Medusa should keep track of the inventory for this Product Variant. - * type: boolean - * weight: - * description: The wieght of the Product Variant. - * type: number - * length: - * description: The length of the Product Variant. - * type: number - * height: - * description: The height of the Product Variant. - * type: number - * width: - * description: The width of the Product Variant. - * type: number - * origin_country: - * description: The country of origin of the Product Variant. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product Variant. - * type: string - * material: - * description: The material composition of the Product Variant. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object - * prices: - * type: array - * items: - * required: - * - amount - * properties: - * id: - * description: The ID of the Price. - * type: string - * region_id: - * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * options: - * type: array - * items: - * required: - * - option_id - * - value - * properties: - * option_id: - * description: The ID of the Option. - * type: string - * value: - * description: The value to give for the Product Option at the same index in the Product's `options` field. - * type: string - * weight: - * description: The wieght of the Product. - * type: number - * length: - * description: The length of the Product. - * type: number - * height: - * description: The height of the Product. - * type: number - * width: - * description: The width of the Product. - * type: number - * origin_country: - * description: The country of origin of the Product. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product. - * type: string - * material: - * description: The material composition of the Product. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object + * $ref: "#/components/schemas/AdminPostProductsProductReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -399,6 +210,199 @@ class ProductVariantReq { options?: ProductVariantOptionReq[] = [] } +/** + * @schema AdminPostProductsProductReq + * type: object + * properties: + * title: + * description: "The title of the Product" + * type: string + * subtitle: + * description: "The subtitle of the Product" + * type: string + * description: + * description: "A description of the Product." + * type: string + * discountable: + * description: A flag to indicate if discounts can be applied to the LineItems generated from this Product + * type: boolean + * images: + * description: Images of the Product. + * type: array + * items: + * type: string + * thumbnail: + * description: The thumbnail to use for the Product. + * type: string + * handle: + * description: A unique handle to identify the Product by. + * type: string + * status: + * description: The status of the product. + * type: string + * enum: [draft, proposed, published, rejected] + * type: + * description: The Product Type to associate the Product with. + * type: object + * required: + * - value + * properties: + * id: + * description: The ID of the Product Type. + * type: string + * value: + * description: The value of the Product Type. + * type: string + * collection_id: + * description: The ID of the Collection the Product should belong to. + * type: string + * tags: + * description: Tags to associate the Product with. + * type: array + * items: + * required: + * - value + * properties: + * id: + * description: The ID of an existing Tag. + * type: string + * value: + * description: The value of the Tag, these will be upserted. + * type: string + * sales_channels: + * description: "[EXPERIMENTAL] Sales channels to associate the Product with." + * type: array + * items: + * required: + * - id + * properties: + * id: + * description: The ID of an existing Sales channel. + * type: string + * variants: + * description: A list of Product Variants to create with the Product. + * type: array + * items: + * properties: + * id: + * description: The ID of the Product Variant. + * type: string + * title: + * description: The title to identify the Product Variant by. + * type: string + * sku: + * description: The unique SKU for the Product Variant. + * type: string + * ean: + * description: The EAN number of the item. + * type: string + * upc: + * description: The UPC number of the item. + * type: string + * barcode: + * description: A generic GTIN field for the Product Variant. + * type: string + * hs_code: + * description: The Harmonized System code for the Product Variant. + * type: string + * inventory_quantity: + * description: The amount of stock kept for the Product Variant. + * type: integer + * allow_backorder: + * description: Whether the Product Variant can be purchased when out of stock. + * type: boolean + * manage_inventory: + * description: Whether Medusa should keep track of the inventory for this Product Variant. + * type: boolean + * weight: + * description: The wieght of the Product Variant. + * type: number + * length: + * description: The length of the Product Variant. + * type: number + * height: + * description: The height of the Product Variant. + * type: number + * width: + * description: The width of the Product Variant. + * type: number + * origin_country: + * description: The country of origin of the Product Variant. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product Variant. + * type: string + * material: + * description: The material composition of the Product Variant. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + * prices: + * type: array + * items: + * required: + * - amount + * properties: + * id: + * description: The ID of the Price. + * type: string + * region_id: + * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * options: + * type: array + * items: + * required: + * - option_id + * - value + * properties: + * option_id: + * description: The ID of the Option. + * type: string + * value: + * description: The value to give for the Product Option at the same index in the Product's `options` field. + * type: string + * weight: + * description: The wieght of the Product. + * type: number + * length: + * description: The length of the Product. + * type: number + * height: + * description: The height of the Product. + * type: number + * width: + * description: The width of the Product. + * type: number + * origin_country: + * description: The country of origin of the Product. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product. + * type: string + * material: + * description: The material composition of the Product. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + */ export class AdminPostProductsProductReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/products/update-variant.ts b/packages/medusa/src/api/routes/admin/products/update-variant.ts index 0ef7c14ec3..b946142e68 100644 --- a/packages/medusa/src/api/routes/admin/products/update-variant.ts +++ b/packages/medusa/src/api/routes/admin/products/update-variant.ts @@ -33,101 +33,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - prices - * properties: - * title: - * description: The title to identify the Product Variant by. - * type: string - * sku: - * description: The unique SKU for the Product Variant. - * type: string - * ean: - * description: The EAN number of the item. - * type: string - * upc: - * description: The UPC number of the item. - * type: string - * barcode: - * description: A generic GTIN field for the Product Variant. - * type: string - * hs_code: - * description: The Harmonized System code for the Product Variant. - * type: string - * inventory_quantity: - * description: The amount of stock kept for the Product Variant. - * type: integer - * allow_backorder: - * description: Whether the Product Variant can be purchased when out of stock. - * type: boolean - * manage_inventory: - * description: Whether Medusa should keep track of the inventory for this Product Variant. - * type: boolean - * weight: - * description: The weight of the Product Variant. - * type: number - * length: - * description: The length of the Product Variant. - * type: number - * height: - * description: The height of the Product Variant. - * type: number - * width: - * description: The width of the Product Variant. - * type: number - * origin_country: - * description: The country of origin of the Product Variant. - * type: string - * mid_code: - * description: The Manufacturer Identification code for the Product Variant. - * type: string - * material: - * description: The material composition of the Product Variant. - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object - * prices: - * type: array - * items: - * required: - * - amount - * properties: - * id: - * description: The ID of the price. - * type: string - * region_id: - * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. - * type: string - * currency_code: - * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * amount: - * description: The amount to charge for the Product Variant. - * type: integer - * min_quantity: - * description: The minimum quantity for which the price will be used. - * type: integer - * max_quantity: - * description: The maximum quantity for which the price will be used. - * type: integer - * options: - * type: array - * items: - * required: - * - option_id - * - value - * properties: - * option_id: - * description: The ID of the Product Option to set the value for. - * type: string - * value: - * description: The value to give for the Product Option. - * type: string + * $ref: "#/components/schemas/AdminPostProductsProductVariantsVariantReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -242,6 +148,104 @@ class ProductVariantOptionReq { option_id: string } +/** + * @schema AdminPostProductsProductVariantsVariantReq + * type: object + * required: + * - prices + * properties: + * title: + * description: The title to identify the Product Variant by. + * type: string + * sku: + * description: The unique SKU for the Product Variant. + * type: string + * ean: + * description: The EAN number of the item. + * type: string + * upc: + * description: The UPC number of the item. + * type: string + * barcode: + * description: A generic GTIN field for the Product Variant. + * type: string + * hs_code: + * description: The Harmonized System code for the Product Variant. + * type: string + * inventory_quantity: + * description: The amount of stock kept for the Product Variant. + * type: integer + * allow_backorder: + * description: Whether the Product Variant can be purchased when out of stock. + * type: boolean + * manage_inventory: + * description: Whether Medusa should keep track of the inventory for this Product Variant. + * type: boolean + * weight: + * description: The weight of the Product Variant. + * type: number + * length: + * description: The length of the Product Variant. + * type: number + * height: + * description: The height of the Product Variant. + * type: number + * width: + * description: The width of the Product Variant. + * type: number + * origin_country: + * description: The country of origin of the Product Variant. + * type: string + * mid_code: + * description: The Manufacturer Identification code for the Product Variant. + * type: string + * material: + * description: The material composition of the Product Variant. + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + * prices: + * type: array + * items: + * required: + * - amount + * properties: + * id: + * description: The ID of the price. + * type: string + * region_id: + * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. + * type: string + * currency_code: + * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * amount: + * description: The amount to charge for the Product Variant. + * type: integer + * min_quantity: + * description: The minimum quantity for which the price will be used. + * type: integer + * max_quantity: + * description: The maximum quantity for which the price will be used. + * type: integer + * options: + * type: array + * items: + * required: + * - option_id + * - value + * properties: + * option_id: + * description: The ID of the Product Option to set the value for. + * type: string + * value: + * description: The value to give for the Product Option. + * type: string + */ export class AdminPostProductsProductVariantsVariantReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/publishable-api-keys/add-channels-batch.ts b/packages/medusa/src/api/routes/admin/publishable-api-keys/add-channels-batch.ts index 02576c5f3b..0148df84ef 100644 --- a/packages/medusa/src/api/routes/admin/publishable-api-keys/add-channels-batch.ts +++ b/packages/medusa/src/api/routes/admin/publishable-api-keys/add-channels-batch.ts @@ -18,20 +18,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key" * content: * application/json: * schema: - * required: - * - sales_channel_ids - * properties: - * sales_channel_ids: - * description: The IDs of the sales channels to add to the publishable api key - * type: array - * items: - * type: object - * required: - * - id - * properties: - * id: - * type: string - * description: The ID of the sales channel + * $ref: "#/components/schemas/AdminPostPublishableApiKeySalesChannelsBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -116,6 +103,24 @@ export default async (req: Request, res: Response): Promise => { res.status(200).json({ publishable_api_key: publishableApiKey }) } +/** + * @schema AdminPostPublishableApiKeySalesChannelsBatchReq + * type: object + * required: + * - sales_channel_ids + * properties: + * sales_channel_ids: + * description: The IDs of the sales channels to add to the publishable api key + * type: array + * items: + * type: object + * required: + * - id + * properties: + * id: + * type: string + * description: The ID of the sales channel + */ export class AdminPostPublishableApiKeySalesChannelsBatchReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/publishable-api-keys/create-publishable-api-key.ts b/packages/medusa/src/api/routes/admin/publishable-api-keys/create-publishable-api-key.ts index 715ecd0d3d..a0c08a2cda 100644 --- a/packages/medusa/src/api/routes/admin/publishable-api-keys/create-publishable-api-key.ts +++ b/packages/medusa/src/api/routes/admin/publishable-api-keys/create-publishable-api-key.ts @@ -13,13 +13,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key" * content: * application/json: * schema: - * type: object - * required: - * - title - * properties: - * title: - * description: A title for the publishable api key - * type: string + * $ref: "#/components/schemas/AdminPostPublishableApiKeysReq" * x-authenticated: true * x-codeSamples: * - lang: JavaScript @@ -85,6 +79,16 @@ export default async (req: Request, res: Response) => { return res.status(200).json({ publishable_api_key: pubKey }) } +/** + * @schema AdminPostPublishableApiKeysReq + * type: object + * required: + * - title + * properties: + * title: + * description: A title for the publishable api key + * type: string + */ export class AdminPostPublishableApiKeysReq { @IsString() title: string diff --git a/packages/medusa/src/api/routes/admin/publishable-api-keys/delete-channels-batch.ts b/packages/medusa/src/api/routes/admin/publishable-api-keys/delete-channels-batch.ts index c8e5a87c2b..b29b6de0fa 100644 --- a/packages/medusa/src/api/routes/admin/publishable-api-keys/delete-channels-batch.ts +++ b/packages/medusa/src/api/routes/admin/publishable-api-keys/delete-channels-batch.ts @@ -18,20 +18,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key" * content: * application/json: * schema: - * required: - * - sales_channel_ids - * properties: - * sales_channel_ids: - * description: The IDs of the sales channels to delete from the publishable api key - * type: array - * items: - * type: object - * required: - * - id - * properties: - * id: - * type: string - * description: The ID of the sales channel + * $ref: "#/components/schemas/AdminDeletePublishableApiKeySalesChannelsBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -116,6 +103,24 @@ export default async (req: Request, res: Response): Promise => { res.status(200).json({ publishable_api_key: publishableApiKey }) } +/** + * @schema AdminDeletePublishableApiKeySalesChannelsBatchReq + * type: object + * required: + * - sales_channel_ids + * properties: + * sales_channel_ids: + * description: The IDs of the sales channels to delete from the publishable api key + * type: array + * items: + * type: object + * required: + * - id + * properties: + * id: + * type: string + * description: The ID of the sales channel + */ export class AdminDeletePublishableApiKeySalesChannelsBatchReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/publishable-api-keys/update-publishable-api-key.ts b/packages/medusa/src/api/routes/admin/publishable-api-keys/update-publishable-api-key.ts index 724d87ae2d..1b271cfca7 100644 --- a/packages/medusa/src/api/routes/admin/publishable-api-keys/update-publishable-api-key.ts +++ b/packages/medusa/src/api/routes/admin/publishable-api-keys/update-publishable-api-key.ts @@ -16,11 +16,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key" * content: * application/json: * schema: - * type: object - * properties: - * title: - * description: A title to update for the key. - * type: string + * $ref: "#/components/schemas/AdminPostPublishableApiKeysPublishableApiKeyReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -92,6 +88,14 @@ export default async (req: Request, res: Response) => { res.status(200).json({ publishable_api_key: updatedKey }) } +/** + * @schema AdminPostPublishableApiKeysPublishableApiKeyReq + * type: object + * properties: + * title: + * description: A title to update for the key. + * type: string + */ export class AdminPostPublishableApiKeysPublishableApiKeyReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/regions/add-country.ts b/packages/medusa/src/api/routes/admin/regions/add-country.ts index cfaf4f13a3..6858cd51b3 100644 --- a/packages/medusa/src/api/routes/admin/regions/add-country.ts +++ b/packages/medusa/src/api/routes/admin/regions/add-country.ts @@ -18,16 +18,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - country_code - * properties: - * country_code: - * description: "The 2 character ISO code for the Country." - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements - * description: See a list of codes. + * $ref: "#/components/schemas/AdminPostRegionsRegionCountriesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -101,6 +92,19 @@ export default async (req, res) => { res.status(200).json({ region }) } +/** + * @schema AdminPostRegionsRegionCountriesReq + * type: object + * required: + * - country_code + * properties: + * country_code: + * description: "The 2 character ISO code for the Country." + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements + * description: See a list of codes. + */ export class AdminPostRegionsRegionCountriesReq { @IsString() country_code: string diff --git a/packages/medusa/src/api/routes/admin/regions/add-fulfillment-provider.ts b/packages/medusa/src/api/routes/admin/regions/add-fulfillment-provider.ts index 6a3408245a..ba5e27e66b 100644 --- a/packages/medusa/src/api/routes/admin/regions/add-fulfillment-provider.ts +++ b/packages/medusa/src/api/routes/admin/regions/add-fulfillment-provider.ts @@ -18,13 +18,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - provider_id - * properties: - * provider_id: - * description: "The ID of the Fulfillment Provider to add." - * type: string + * $ref: "#/components/schemas/AdminPostRegionsRegionFulfillmentProvidersReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -97,6 +91,16 @@ export default async (req, res) => { res.status(200).json({ region }) } +/** + * @schema AdminPostRegionsRegionFulfillmentProvidersReq + * type: object + * required: + * - provider_id + * properties: + * provider_id: + * description: "The ID of the Fulfillment Provider to add." + * type: string + */ export class AdminPostRegionsRegionFulfillmentProvidersReq { @IsString() provider_id: string diff --git a/packages/medusa/src/api/routes/admin/regions/add-payment-provider.ts b/packages/medusa/src/api/routes/admin/regions/add-payment-provider.ts index fb98d424b9..37a359b9f5 100644 --- a/packages/medusa/src/api/routes/admin/regions/add-payment-provider.ts +++ b/packages/medusa/src/api/routes/admin/regions/add-payment-provider.ts @@ -18,13 +18,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - provider_id - * properties: - * provider_id: - * description: "The ID of the Payment Provider to add." - * type: string + * $ref: "#/components/schemas/AdminPostRegionsRegionPaymentProvidersReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -97,6 +91,16 @@ export default async (req, res) => { res.status(200).json({ region }) } +/** + * @schema AdminPostRegionsRegionPaymentProvidersReq + * type: object + * required: + * - provider_id + * properties: + * provider_id: + * description: "The ID of the Payment Provider to add." + * type: string + */ export class AdminPostRegionsRegionPaymentProvidersReq { @IsString() provider_id: string diff --git a/packages/medusa/src/api/routes/admin/regions/create-region.ts b/packages/medusa/src/api/routes/admin/regions/create-region.ts index a509928f37..e11b7f33e8 100644 --- a/packages/medusa/src/api/routes/admin/regions/create-region.ts +++ b/packages/medusa/src/api/routes/admin/regions/create-region.ts @@ -24,49 +24,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - name - * - currency_code - * - tax_rate - * - payment_providers - * - fulfillment_providers - * - countries - * properties: - * name: - * description: "The name of the Region" - * type: string - * currency_code: - * description: "The 3 character ISO currency code to use for the Region." - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * tax_code: - * description: "An optional tax code the Region." - * type: string - * tax_rate: - * description: "The tax rate to use on Orders in the Region." - * type: number - * payment_providers: - * description: "A list of Payment Provider IDs that should be enabled for the Region" - * type: array - * items: - * type: string - * fulfillment_providers: - * description: "A list of Fulfillment Provider IDs that should be enabled for the Region" - * type: array - * items: - * type: string - * countries: - * description: "A list of countries' 2 ISO Characters that should be included in the Region." - * example: ["US"] - * type: array - * items: - * type: string - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of region" - * type: boolean + * $ref: "#/components/schemas/AdminPostRegionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -160,6 +118,52 @@ export default async (req, res) => { res.status(200).json({ region }) } +/** + * @schema AdminPostRegionsReq + * type: object + * required: + * - name + * - currency_code + * - tax_rate + * - payment_providers + * - fulfillment_providers + * - countries + * properties: + * name: + * description: "The name of the Region" + * type: string + * currency_code: + * description: "The 3 character ISO currency code to use for the Region." + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * tax_code: + * description: "An optional tax code the Region." + * type: string + * tax_rate: + * description: "The tax rate to use on Orders in the Region." + * type: number + * payment_providers: + * description: "A list of Payment Provider IDs that should be enabled for the Region" + * type: array + * items: + * type: string + * fulfillment_providers: + * description: "A list of Fulfillment Provider IDs that should be enabled for the Region" + * type: array + * items: + * type: string + * countries: + * description: "A list of countries' 2 ISO Characters that should be included in the Region." + * example: ["US"] + * type: array + * items: + * type: string + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of region" + * type: boolean + */ export class AdminPostRegionsReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/regions/update-region.ts b/packages/medusa/src/api/routes/admin/regions/update-region.ts index b8c4e3d477..c0ca411b01 100644 --- a/packages/medusa/src/api/routes/admin/regions/update-region.ts +++ b/packages/medusa/src/api/routes/admin/regions/update-region.ts @@ -26,50 +26,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * properties: - * name: - * description: "The name of the Region" - * type: string - * currency_code: - * description: "The 3 character ISO currency code to use for the Region." - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * automatic_taxes: - * description: "If true Medusa will automatically calculate taxes for carts in this region. If false you have to manually call POST /carts/:id/taxes." - * type: boolean - * gift_cards_taxable: - * description: "Whether gift cards in this region should be applied sales tax when purchasing a gift card" - * type: boolean - * tax_provider_id: - * description: "The ID of the tax provider to use; if null the system tax provider is used" - * type: string - * tax_code: - * description: "An optional tax code the Region." - * type: string - * tax_rate: - * description: "The tax rate to use on Orders in the Region." - * type: number - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of region" - * type: boolean - * payment_providers: - * description: "A list of Payment Provider IDs that should be enabled for the Region" - * type: array - * items: - * type: string - * fulfillment_providers: - * description: "A list of Fulfillment Provider IDs that should be enabled for the Region" - * type: array - * items: - * type: string - * countries: - * description: "A list of countries' 2 ISO Characters that should be included in the Region." - * type: array - * items: - * type: string + * $ref: "#/components/schemas/AdminPostRegionsRegionReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -140,6 +97,53 @@ export default async (req, res) => { res.status(200).json({ region }) } +/** + * @schema AdminPostRegionsRegionReq + * type: object + * properties: + * name: + * description: "The name of the Region" + * type: string + * currency_code: + * description: "The 3 character ISO currency code to use for the Region." + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * automatic_taxes: + * description: "If true Medusa will automatically calculate taxes for carts in this region. If false you have to manually call POST /carts/:id/taxes." + * type: boolean + * gift_cards_taxable: + * description: "Whether gift cards in this region should be applied sales tax when purchasing a gift card" + * type: boolean + * tax_provider_id: + * description: "The ID of the tax provider to use; if null the system tax provider is used" + * type: string + * tax_code: + * description: "An optional tax code the Region." + * type: string + * tax_rate: + * description: "The tax rate to use on Orders in the Region." + * type: number + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of region" + * type: boolean + * payment_providers: + * description: "A list of Payment Provider IDs that should be enabled for the Region" + * type: array + * items: + * type: string + * fulfillment_providers: + * description: "A list of Fulfillment Provider IDs that should be enabled for the Region" + * type: array + * items: + * type: string + * countries: + * description: "A list of countries' 2 ISO Characters that should be included in the Region." + * type: array + * items: + * type: string + */ export class AdminPostRegionsRegionReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/return-reasons/create-reason.ts b/packages/medusa/src/api/routes/admin/return-reasons/create-reason.ts index a14915bae2..f6c9a0967c 100644 --- a/packages/medusa/src/api/routes/admin/return-reasons/create-reason.ts +++ b/packages/medusa/src/api/routes/admin/return-reasons/create-reason.ts @@ -18,26 +18,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - label - * - value - * properties: - * label: - * description: "The label to display to the Customer." - * type: string - * value: - * description: "The value that the Return Reason will be identified by. Must be unique." - * type: string - * parent_return_reason_id: - * description: "The ID of the parent return reason." - * type: string - * description: - * description: "An optional description to for the Reason." - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object + * $ref: "#/components/schemas/AdminPostReturnReasonsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -111,6 +92,29 @@ export default async (req, res) => { res.status(200).json({ return_reason: reason }) } +/** + * @schema AdminPostReturnReasonsReq + * type: object + * required: + * - label + * - value + * properties: + * label: + * description: "The label to display to the Customer." + * type: string + * value: + * description: "The value that the Return Reason will be identified by. Must be unique." + * type: string + * parent_return_reason_id: + * description: "The ID of the parent return reason." + * type: string + * description: + * description: "An optional description to for the Reason." + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + */ export class AdminPostReturnReasonsReq { @IsString() value: string diff --git a/packages/medusa/src/api/routes/admin/return-reasons/update-reason.ts b/packages/medusa/src/api/routes/admin/return-reasons/update-reason.ts index 059528eadf..697512fae2 100644 --- a/packages/medusa/src/api/routes/admin/return-reasons/update-reason.ts +++ b/packages/medusa/src/api/routes/admin/return-reasons/update-reason.ts @@ -20,20 +20,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * label: - * description: "The label to display to the Customer." - * type: string - * value: - * description: "The value that the Return Reason will be identified by. Must be unique." - * type: string - * description: - * description: "An optional description to for the Reason." - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object + * $ref: "#/components/schemas/AdminPostReturnReasonsReasonReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -108,6 +95,23 @@ export default async (req, res) => { res.status(200).json({ return_reason: reason }) } +/** + * @schema AdminPostReturnReasonsReasonReq + * type: object + * properties: + * label: + * description: "The label to display to the Customer." + * type: string + * value: + * description: "The value that the Return Reason will be identified by. Must be unique." + * type: string + * description: + * description: "An optional description to for the Reason." + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + */ export class AdminPostReturnReasonsReasonReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/returns/receive-return.ts b/packages/medusa/src/api/routes/admin/returns/receive-return.ts index 22c2a26c24..76198c7357 100644 --- a/packages/medusa/src/api/routes/admin/returns/receive-return.ts +++ b/packages/medusa/src/api/routes/admin/returns/receive-return.ts @@ -23,27 +23,7 @@ import { isDefined } from "medusa-core-utils" * content: * application/json: * schema: - * type: object - * required: - * - items - * properties: - * items: - * description: The Line Items that have been received. - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item. - * type: string - * quantity: - * description: The quantity of the Line Item. - * type: integer - * refund: - * description: The amount to refund. - * type: number + * $ref: "#/components/schemas/AdminPostReturnsReturnReceiveReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -156,6 +136,30 @@ class Item { quantity: number } +/** + * @schema AdminPostReturnsReturnReceiveReq + * type: object + * required: + * - items + * properties: + * items: + * description: The Line Items that have been received. + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item. + * type: string + * quantity: + * description: The quantity of the Line Item. + * type: integer + * refund: + * description: The amount to refund. + * type: number + */ export class AdminPostReturnsReturnReceiveReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/sales-channels/add-product-batch.ts b/packages/medusa/src/api/routes/admin/sales-channels/add-product-batch.ts index 1e5c866985..1918407dbd 100644 --- a/packages/medusa/src/api/routes/admin/sales-channels/add-product-batch.ts +++ b/packages/medusa/src/api/routes/admin/sales-channels/add-product-batch.ts @@ -18,21 +18,7 @@ import { Type } from "class-transformer" * content: * application/json: * schema: - * type: object - * required: - * - product_ids - * properties: - * product_ids: - * description: The IDs of the products to add to the Sales Channel - * type: array - * items: - * type: object - * required: - * - id - * properties: - * id: - * type: string - * description: The ID of the product + * $ref: "#/components/schemas/AdminPostSalesChannelsChannelProductsBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -114,6 +100,24 @@ export default async (req: Request, res: Response): Promise => { res.status(200).json({ sales_channel: salesChannel }) } +/** + * @schema AdminPostSalesChannelsChannelProductsBatchReq + * type: object + * required: + * - product_ids + * properties: + * product_ids: + * description: The IDs of the products to add to the Sales Channel + * type: array + * items: + * type: object + * required: + * - id + * properties: + * id: + * type: string + * description: The ID of the product + */ export class AdminPostSalesChannelsChannelProductsBatchReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/sales-channels/create-sales-channel.ts b/packages/medusa/src/api/routes/admin/sales-channels/create-sales-channel.ts index b83ce78c4a..bd8cb922fe 100644 --- a/packages/medusa/src/api/routes/admin/sales-channels/create-sales-channel.ts +++ b/packages/medusa/src/api/routes/admin/sales-channels/create-sales-channel.ts @@ -15,19 +15,7 @@ import SalesChannelService from "../../../../services/sales-channel" * content: * application/json: * schema: - * type: object - * required: - * - name - * properties: - * name: - * description: The name of the Sales Channel - * type: string - * description: - * description: The description of the Sales Channel - * type: string - * is_disabled: - * description: Whether the Sales Channel is disabled or not. - * type: boolean + * $ref: "#/components/schemas/AdminPostSalesChannelsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -96,6 +84,22 @@ export default async (req: Request, res: Response) => { res.status(200).json({ sales_channel: salesChannel }) } +/** + * @schema AdminPostSalesChannelsReq + * type: object + * required: + * - name + * properties: + * name: + * description: The name of the Sales Channel + * type: string + * description: + * description: The description of the Sales Channel + * type: string + * is_disabled: + * description: Whether the Sales Channel is disabled or not. + * type: boolean + */ export class AdminPostSalesChannelsReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/sales-channels/delete-products-batch.ts b/packages/medusa/src/api/routes/admin/sales-channels/delete-products-batch.ts index a586c51814..96c594f506 100644 --- a/packages/medusa/src/api/routes/admin/sales-channels/delete-products-batch.ts +++ b/packages/medusa/src/api/routes/admin/sales-channels/delete-products-batch.ts @@ -18,21 +18,7 @@ import { Type } from "class-transformer" * content: * application/json: * schema: - * type: object - * required: - * - product_ids - * properties: - * product_ids: - * description: The IDs of the products to delete from the Sales Channel. - * type: array - * items: - * type: object - * required: - * - id - * properties: - * id: - * description: The ID of a product - * type: string + * $ref: "#/components/schemas/AdminDeleteSalesChannelsChannelProductsBatchReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -114,6 +100,24 @@ export default async (req: Request, res: Response) => { res.status(200).json({ sales_channel: salesChannel }) } +/** + * @schema AdminDeleteSalesChannelsChannelProductsBatchReq + * type: object + * required: + * - product_ids + * properties: + * product_ids: + * description: The IDs of the products to delete from the Sales Channel. + * type: array + * items: + * type: object + * required: + * - id + * properties: + * id: + * description: The ID of a product + * type: string + */ export class AdminDeleteSalesChannelsChannelProductsBatchReq { @IsArray() @ValidateNested({ each: true }) diff --git a/packages/medusa/src/api/routes/admin/sales-channels/update-sales-channel.ts b/packages/medusa/src/api/routes/admin/sales-channels/update-sales-channel.ts index da1ae7ae73..4f03cbb602 100644 --- a/packages/medusa/src/api/routes/admin/sales-channels/update-sales-channel.ts +++ b/packages/medusa/src/api/routes/admin/sales-channels/update-sales-channel.ts @@ -16,17 +16,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * name: - * type: string - * description: Name of the sales channel. - * description: - * type: string - * description: Sales Channel description. - * is_disabled: - * type: boolean - * description: Indication of if the sales channel is active. + * $ref: "#/components/schemas/AdminPostSalesChannelsSalesChannelReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -98,6 +88,20 @@ export default async (req: Request, res: Response) => { res.status(200).json({ sales_channel }) } +/** + * @schema AdminPostSalesChannelsSalesChannelReq + * type: object + * properties: + * name: + * type: string + * description: Name of the sales channel. + * description: + * type: string + * description: Sales Channel description. + * is_disabled: + * type: boolean + * description: Indication of if the sales channel is active. + */ export class AdminPostSalesChannelsSalesChannelReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/shipping-options/create-shipping-option.ts b/packages/medusa/src/api/routes/admin/shipping-options/create-shipping-option.ts index ce57ac396c..89e52110d6 100644 --- a/packages/medusa/src/api/routes/admin/shipping-options/create-shipping-option.ts +++ b/packages/medusa/src/api/routes/admin/shipping-options/create-shipping-option.ts @@ -25,69 +25,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - name - * - region_id - * - provider_id - * - data - * - price_type - * properties: - * name: - * description: "The name of the Shipping Option" - * type: string - * region_id: - * description: "The ID of the Region in which the Shipping Option will be available." - * type: string - * provider_id: - * description: "The ID of the Fulfillment Provider that handles the Shipping Option." - * type: string - * profile_id: - * description: "The ID of the Shipping Profile to add the Shipping Option to." - * type: number - * data: - * description: "The data needed for the Fulfillment Provider to handle shipping with this Shipping Option." - * type: object - * price_type: - * description: "The type of the Shipping Option price." - * type: string - * enum: - * - flat_rate - * - calculated - * amount: - * description: "The amount to charge for the Shipping Option." - * type: integer - * requirements: - * description: "The requirements that must be satisfied for the Shipping Option to be available." - * type: array - * items: - * required: - * - type - * - amount - * properties: - * type: - * description: The type of the requirement - * type: string - * enum: - * - max_subtotal - * - min_subtotal - * amount: - * description: The amount to compare with. - * type: integer - * is_return: - * description: Whether the Shipping Option defines a return shipment. - * type: boolean - * default: false - * admin_only: - * description: If true, the option can be used for draft orders - * type: boolean - * default: false - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of shipping option" - * type: boolean + * $ref: "#/components/schemas/AdminPostShippingOptionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -181,6 +119,72 @@ class OptionRequirement { amount: number } +/** + * @schema AdminPostShippingOptionsReq + * type: object + * required: + * - name + * - region_id + * - provider_id + * - data + * - price_type + * properties: + * name: + * description: "The name of the Shipping Option" + * type: string + * region_id: + * description: "The ID of the Region in which the Shipping Option will be available." + * type: string + * provider_id: + * description: "The ID of the Fulfillment Provider that handles the Shipping Option." + * type: string + * profile_id: + * description: "The ID of the Shipping Profile to add the Shipping Option to." + * type: number + * data: + * description: "The data needed for the Fulfillment Provider to handle shipping with this Shipping Option." + * type: object + * price_type: + * description: "The type of the Shipping Option price." + * type: string + * enum: + * - flat_rate + * - calculated + * amount: + * description: "The amount to charge for the Shipping Option." + * type: integer + * requirements: + * description: "The requirements that must be satisfied for the Shipping Option to be available." + * type: array + * items: + * required: + * - type + * - amount + * properties: + * type: + * description: The type of the requirement + * type: string + * enum: + * - max_subtotal + * - min_subtotal + * amount: + * description: The amount to compare with. + * type: integer + * is_return: + * description: Whether the Shipping Option defines a return shipment. + * type: boolean + * default: false + * admin_only: + * description: If true, the option can be used for draft orders + * type: boolean + * default: false + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of shipping option" + * type: boolean + */ export class AdminPostShippingOptionsReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/shipping-options/update-shipping-option.ts b/packages/medusa/src/api/routes/admin/shipping-options/update-shipping-option.ts index 9b0426b77d..e156ef8f67 100644 --- a/packages/medusa/src/api/routes/admin/shipping-options/update-shipping-option.ts +++ b/packages/medusa/src/api/routes/admin/shipping-options/update-shipping-option.ts @@ -27,45 +27,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - requirements - * properties: - * name: - * description: "The name of the Shipping Option" - * type: string - * amount: - * description: "The amount to charge for the Shipping Option." - * type: integer - * admin_only: - * description: "If true, the option can be used for draft orders" - * type: boolean - * metadata: - * description: "An optional set of key-value pairs with additional information." - * type: object - * requirements: - * description: "The requirements that must be satisfied for the Shipping Option to be available." - * type: array - * items: - * required: - * - type - * - amount - * properties: - * id: - * description: The ID of the requirement - * type: string - * type: - * description: The type of the requirement - * type: string - * enum: - * - max_subtotal - * - min_subtotal - * amount: - * description: The amount to compare with. - * type: integer - * includes_tax: - * description: "[EXPERIMENTAL] Tax included in prices of shipping option" - * type: boolean + * $ref: "#/components/schemas/AdminPostShippingOptionsOptionReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -160,6 +122,48 @@ class OptionRequirement { amount: number } +/** + * @schema AdminPostShippingOptionsOptionReq + * type: object + * required: + * - requirements + * properties: + * name: + * description: "The name of the Shipping Option" + * type: string + * amount: + * description: "The amount to charge for the Shipping Option." + * type: integer + * admin_only: + * description: "If true, the option can be used for draft orders" + * type: boolean + * metadata: + * description: "An optional set of key-value pairs with additional information." + * type: object + * requirements: + * description: "The requirements that must be satisfied for the Shipping Option to be available." + * type: array + * items: + * required: + * - type + * - amount + * properties: + * id: + * description: The ID of the requirement + * type: string + * type: + * description: The type of the requirement + * type: string + * enum: + * - max_subtotal + * - min_subtotal + * amount: + * description: The amount to compare with. + * type: integer + * includes_tax: + * description: "[EXPERIMENTAL] Tax included in prices of shipping option" + * type: boolean + */ export class AdminPostShippingOptionsOptionReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/shipping-profiles/create-shipping-profile.ts b/packages/medusa/src/api/routes/admin/shipping-profiles/create-shipping-profile.ts index de6d7718bd..4551719493 100644 --- a/packages/medusa/src/api/routes/admin/shipping-profiles/create-shipping-profile.ts +++ b/packages/medusa/src/api/routes/admin/shipping-profiles/create-shipping-profile.ts @@ -13,13 +13,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - name - * properties: - * name: - * description: "The name of the Shipping Profile" - * type: string + * $ref: "#/components/schemas/AdminPostShippingProfilesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -86,6 +80,16 @@ export default async (req, res) => { res.status(200).json({ shipping_profile: data }) } +/** + * @schema AdminPostShippingProfilesReq + * type: object + * required: + * - name + * properties: + * name: + * description: "The name of the Shipping Profile" + * type: string + */ export class AdminPostShippingProfilesReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/shipping-profiles/update-shipping-profile.ts b/packages/medusa/src/api/routes/admin/shipping-profiles/update-shipping-profile.ts index 9a352a6b2b..bf00e6e754 100644 --- a/packages/medusa/src/api/routes/admin/shipping-profiles/update-shipping-profile.ts +++ b/packages/medusa/src/api/routes/admin/shipping-profiles/update-shipping-profile.ts @@ -15,11 +15,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * name: - * description: "The name of the Shipping Profile" - * type: string + * $ref: "#/components/schemas/AdminPostShippingProfilesProfileReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -93,6 +89,14 @@ export default async (req, res) => { res.status(200).json({ shipping_profile: data }) } +/** + * @schema AdminPostShippingProfilesProfileReq + * type: object + * properties: + * name: + * description: "The name of the Shipping Profile" + * type: string + */ export class AdminPostShippingProfilesProfileReq { @IsString() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/store/update-store.ts b/packages/medusa/src/api/routes/admin/store/update-store.ts index fd959f5cce..8a5dc11a92 100644 --- a/packages/medusa/src/api/routes/admin/store/update-store.ts +++ b/packages/medusa/src/api/routes/admin/store/update-store.ts @@ -14,34 +14,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * name: - * description: "The name of the Store" - * type: string - * swap_link_template: - * description: "A template for Swap links - use `{{cart_id}}` to insert the Swap Cart id" - * type: string - * payment_link_template: - * description: "A template for payment links links - use `{{cart_id}}` to insert the Cart id" - * type: string - * invite_link_template: - * description: "A template for invite links - use `{{invite_token}}` to insert the invite token" - * type: string - * default_currency_code: - * description: "The default currency code for the Store." - * type: string - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes - * description: See a list of codes. - * currencies: - * description: "Array of currencies in 2 character ISO code format." - * type: array - * items: - * type: string - * metadata: - * description: "An optional set of key-value pairs with additional information." - * type: object + * $ref: "#/components/schemas/AdminPostStoreReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -107,6 +80,37 @@ export default async (req, res) => { res.status(200).json({ store }) } +/** + * @schema AdminPostStoreReq + * type: object + * properties: + * name: + * description: "The name of the Store" + * type: string + * swap_link_template: + * description: "A template for Swap links - use `{{cart_id}}` to insert the Swap Cart id" + * type: string + * payment_link_template: + * description: "A template for payment links links - use `{{cart_id}}` to insert the Cart id" + * type: string + * invite_link_template: + * description: "A template for invite links - use `{{invite_token}}` to insert the invite token" + * type: string + * default_currency_code: + * description: "The default currency code for the Store." + * type: string + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes + * description: See a list of codes. + * currencies: + * description: "Array of currencies in 2 character ISO code format." + * type: array + * items: + * type: string + * metadata: + * description: "An optional set of key-value pairs with additional information." + * type: object + */ export class AdminPostStoreReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/tax-rates/add-to-product-types.ts b/packages/medusa/src/api/routes/admin/tax-rates/add-to-product-types.ts index 916ad9854e..b7d275785a 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/add-to-product-types.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/add-to-product-types.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - product_types - * properties: - * product_types: - * type: array - * description: "The IDs of the types of products to associate with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminPostTaxRatesTaxRateProductTypesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -129,6 +121,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminPostTaxRatesTaxRateProductTypesReq + * type: object + * required: + * - product_types + * properties: + * product_types: + * type: array + * description: "The IDs of the types of products to associate with this tax rate" + * items: + * type: string + */ export class AdminPostTaxRatesTaxRateProductTypesReq { @IsArray() product_types: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/add-to-products.ts b/packages/medusa/src/api/routes/admin/tax-rates/add-to-products.ts index 8d7d68d127..043c115f10 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/add-to-products.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/add-to-products.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - products - * properties: - * products: - * type: array - * description: "The IDs of the products to associate with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminPostTaxRatesTaxRateProductsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -126,6 +118,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminPostTaxRatesTaxRateProductsReq + * type: object + * required: + * - products + * properties: + * products: + * type: array + * description: "The IDs of the products to associate with this tax rate" + * items: + * type: string + */ export class AdminPostTaxRatesTaxRateProductsReq { @IsArray() products: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/add-to-shipping-options.ts b/packages/medusa/src/api/routes/admin/tax-rates/add-to-shipping-options.ts index 711d34817f..02fcbf583f 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/add-to-shipping-options.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/add-to-shipping-options.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - shipping_options - * properties: - * shipping_options: - * type: array - * description: "The IDs of the shipping options to associate with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminPostTaxRatesTaxRateShippingOptionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -128,6 +120,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminPostTaxRatesTaxRateShippingOptionsReq + * type: object + * required: + * - shipping_options + * properties: + * shipping_options: + * type: array + * description: "The IDs of the shipping options to associate with this tax rate" + * items: + * type: string + */ export class AdminPostTaxRatesTaxRateShippingOptionsReq { @IsArray() shipping_options: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/create-tax-rate.ts b/packages/medusa/src/api/routes/admin/tax-rates/create-tax-rate.ts index ca5651946b..46106584f0 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/create-tax-rate.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/create-tax-rate.ts @@ -38,39 +38,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - code - * - name - * - region_id - * properties: - * code: - * type: string - * description: "A code to identify the tax type by" - * name: - * type: string - * description: "A human friendly name for the tax" - * region_id: - * type: string - * description: "The ID of the Region that the rate belongs to" - * rate: - * type: number - * description: "The numeric rate to charge" - * products: - * type: array - * description: "The IDs of the products associated with this tax rate" - * items: - * type: string - * shipping_options: - * type: array - * description: "The IDs of the shipping options associated with this tax rate" - * items: - * type: string - * product_types: - * type: array - * description: "The IDs of the types of products associated with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminPostTaxRatesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -172,6 +140,42 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminPostTaxRatesReq + * type: object + * required: + * - code + * - name + * - region_id + * properties: + * code: + * type: string + * description: "A code to identify the tax type by" + * name: + * type: string + * description: "A human friendly name for the tax" + * region_id: + * type: string + * description: "The ID of the Region that the rate belongs to" + * rate: + * type: number + * description: "The numeric rate to charge" + * products: + * type: array + * description: "The IDs of the products associated with this tax rate" + * items: + * type: string + * shipping_options: + * type: array + * description: "The IDs of the shipping options associated with this tax rate" + * items: + * type: string + * product_types: + * type: array + * description: "The IDs of the types of products associated with this tax rate" + * items: + * type: string + */ export class AdminPostTaxRatesReq { @IsString() code: string diff --git a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-product-types.ts b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-product-types.ts index 194490e9ef..37091f303f 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-product-types.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-product-types.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - product_types - * properties: - * product_types: - * type: array - * description: "The IDs of the types of products to remove association with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateProductTypesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -129,6 +121,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminDeleteTaxRatesTaxRateProductTypesReq + * type: object + * required: + * - product_types + * properties: + * product_types: + * type: array + * description: "The IDs of the types of products to remove association with this tax rate" + * items: + * type: string + */ export class AdminDeleteTaxRatesTaxRateProductTypesReq { @IsArray() product_types: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-products.ts b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-products.ts index 71a59a4230..e2f11ff456 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-products.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-products.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - products - * properties: - * products: - * type: array - * description: "The IDs of the products to remove association with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateProductsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -126,6 +118,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminDeleteTaxRatesTaxRateProductsReq + * type: object + * required: + * - products + * properties: + * products: + * type: array + * description: "The IDs of the products to remove association with this tax rate" + * items: + * type: string + */ export class AdminDeleteTaxRatesTaxRateProductsReq { @IsArray() products: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-shipping-options.ts b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-shipping-options.ts index e754198511..6638898606 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/remove-from-shipping-options.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/remove-from-shipping-options.ts @@ -36,15 +36,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - shipping_options - * properties: - * shipping_options: - * type: array - * description: "The IDs of the shipping options to remove association with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminDeleteTaxRatesTaxRateShippingOptionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -129,6 +121,18 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminDeleteTaxRatesTaxRateShippingOptionsReq + * type: object + * required: + * - shipping_options + * properties: + * shipping_options: + * type: array + * description: "The IDs of the shipping options to remove association with this tax rate" + * items: + * type: string + */ export class AdminDeleteTaxRatesTaxRateShippingOptionsReq { @IsArray() shipping_options: string[] diff --git a/packages/medusa/src/api/routes/admin/tax-rates/update-tax-rate.ts b/packages/medusa/src/api/routes/admin/tax-rates/update-tax-rate.ts index cc1863679c..83d9c93a38 100644 --- a/packages/medusa/src/api/routes/admin/tax-rates/update-tax-rate.ts +++ b/packages/medusa/src/api/routes/admin/tax-rates/update-tax-rate.ts @@ -39,35 +39,7 @@ import { isDefined } from "medusa-core-utils" * content: * application/json: * schema: - * type: object - * properties: - * code: - * type: string - * description: "A code to identify the tax type by" - * name: - * type: string - * description: "A human friendly name for the tax" - * region_id: - * type: string - * description: "The ID of the Region that the rate belongs to" - * rate: - * type: number - * description: "The numeric rate to charge" - * products: - * type: array - * description: "The IDs of the products associated with this tax rate" - * items: - * type: string - * shipping_options: - * type: array - * description: "The IDs of the shipping options associated with this tax rate" - * items: - * type: string - * product_types: - * type: array - * description: "The IDs of the types of products associated with this tax rate" - * items: - * type: string + * $ref: "#/components/schemas/AdminPostTaxRatesTaxRateReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -165,6 +137,38 @@ export default async (req, res) => { res.json({ tax_rate: data }) } +/** + * @schema AdminPostTaxRatesTaxRateReq + * type: object + * properties: + * code: + * type: string + * description: "A code to identify the tax type by" + * name: + * type: string + * description: "A human friendly name for the tax" + * region_id: + * type: string + * description: "The ID of the Region that the rate belongs to" + * rate: + * type: number + * description: "The numeric rate to charge" + * products: + * type: array + * description: "The IDs of the products associated with this tax rate" + * items: + * type: string + * shipping_options: + * type: array + * description: "The IDs of the shipping options associated with this tax rate" + * items: + * type: string + * product_types: + * type: array + * description: "The IDs of the types of products associated with this tax rate" + * items: + * type: string + */ export class AdminPostTaxRatesTaxRateReq { @IsOptional() @IsString() diff --git a/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts b/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts index 8eef456f5d..6d5f77049d 100644 --- a/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts +++ b/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts @@ -10,13 +10,7 @@ import { IsString } from "class-validator" * content: * application/json: * schema: - * type: object - * required: - * - file_key - * properties: - * file_key: - * description: "key of the file to delete" - * type: string + * $ref: "#/components/schemas/AdminDeleteUploadsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -88,6 +82,16 @@ export default async (req, res) => { .send({ id: validated.file_key, object: "file", deleted: true }) } +/** + * @schema AdminDeleteUploadsReq + * type: object + * required: + * - file_key + * properties: + * file_key: + * description: "key of the file to delete" + * type: string + */ export class AdminDeleteUploadsReq { @IsString() file_key: string diff --git a/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts b/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts index 3febe7b91a..e3aab51e12 100644 --- a/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts +++ b/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts @@ -11,13 +11,7 @@ import { IsString } from "class-validator" * content: * application/json: * schema: - * type: object - * required: - * - file_key - * properties: - * file_key: - * description: "key of the file to obtain the download link for" - * type: string + * $ref: "#/components/schemas/AdminPostUploadsDownloadUrlReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -79,6 +73,16 @@ export default async (req, res) => { res.status(200).send({ download_url: url }) } +/** + * @schema AdminPostUploadsDownloadUrlReq + * type: object + * required: + * - file_key + * properties: + * file_key: + * description: "key of the file to obtain the download link for" + * type: string + */ export class AdminPostUploadsDownloadUrlReq { @IsString() file_key: string diff --git a/packages/medusa/src/api/routes/admin/users/create-user.ts b/packages/medusa/src/api/routes/admin/users/create-user.ts index ca9410d988..1679014106 100644 --- a/packages/medusa/src/api/routes/admin/users/create-user.ts +++ b/packages/medusa/src/api/routes/admin/users/create-user.ts @@ -16,29 +16,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - email - * - password - * properties: - * email: - * description: "The Users email." - * type: string - * format: email - * first_name: - * description: "The name of the User." - * type: string - * last_name: - * description: "The name of the User." - * type: string - * role: - * description: "Userrole assigned to the user." - * type: string - * enum: [admin, member, developer] - * password: - * description: "The Users password." - * type: string - * format: password + * $ref: "#/components/schemas/AdminCreateUserRequest" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -107,6 +85,32 @@ export default async (req, res) => { res.status(200).json({ user: _.omit(user, ["password_hash"]) }) } +/** + * @schema AdminCreateUserRequest + * type: object + * required: + * - email + * - password + * properties: + * email: + * description: "The Users email." + * type: string + * format: email + * first_name: + * description: "The name of the User." + * type: string + * last_name: + * description: "The name of the User." + * type: string + * role: + * description: "Userrole assigned to the user." + * type: string + * enum: [admin, member, developer] + * password: + * description: "The Users password." + * type: string + * format: password + */ export class AdminCreateUserRequest { @IsEmail() email: string diff --git a/packages/medusa/src/api/routes/admin/users/reset-password-token.ts b/packages/medusa/src/api/routes/admin/users/reset-password-token.ts index a659668b16..fb7275e12f 100644 --- a/packages/medusa/src/api/routes/admin/users/reset-password-token.ts +++ b/packages/medusa/src/api/routes/admin/users/reset-password-token.ts @@ -13,14 +13,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - email - * properties: - * email: - * description: "The Users email." - * type: string - * format: email + * $ref: "#/components/schemas/AdminResetPasswordTokenRequest" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -84,6 +77,17 @@ export default async (req, res) => { res.sendStatus(204) } +/** + * @schema AdminResetPasswordTokenRequest + * type: object + * required: + * - email + * properties: + * email: + * description: "The Users email." + * type: string + * format: email + */ export class AdminResetPasswordTokenRequest { @IsEmail() email: string diff --git a/packages/medusa/src/api/routes/admin/users/reset-password.ts b/packages/medusa/src/api/routes/admin/users/reset-password.ts index b1bbcac646..ea15d734ae 100644 --- a/packages/medusa/src/api/routes/admin/users/reset-password.ts +++ b/packages/medusa/src/api/routes/admin/users/reset-password.ts @@ -18,22 +18,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - token - * - password - * properties: - * email: - * description: "The Users email." - * type: string - * format: email - * token: - * description: "The token generated from the 'password-token' endpoint." - * type: string - * password: - * description: "The Users new password." - * type: string - * format: password + * $ref: "#/components/schemas/AdminResetPasswordRequest" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -137,6 +122,25 @@ export type payload = { password: string } +/** + * @schema AdminResetPasswordRequest + * type: object + * required: + * - token + * - password + * properties: + * email: + * description: "The Users email." + * type: string + * format: email + * token: + * description: "The token generated from the 'password-token' endpoint." + * type: string + * password: + * description: "The Users new password." + * type: string + * format: password + */ export class AdminResetPasswordRequest { @IsEmail() @IsOptional() diff --git a/packages/medusa/src/api/routes/admin/users/update-user.ts b/packages/medusa/src/api/routes/admin/users/update-user.ts index a34e2c04ee..86d7b2fc69 100644 --- a/packages/medusa/src/api/routes/admin/users/update-user.ts +++ b/packages/medusa/src/api/routes/admin/users/update-user.ts @@ -17,24 +17,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * properties: - * first_name: - * description: "The name of the User." - * type: string - * last_name: - * description: "The name of the User." - * type: string - * role: - * description: "Userrole assigned to the user." - * type: string - * enum: [admin, member, developer] - * api_token: - * description: "The api token of the User." - * type: string - * metadata: - * description: An optional set of key-value pairs with additional information. - * type: object + * $ref: "#/components/schemas/AdminUpdateUserRequest" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -101,6 +84,27 @@ export default async (req, res) => { res.status(200).json({ user: data }) } +/** + * @schema AdminUpdateUserRequest + * type: object + * properties: + * first_name: + * description: "The name of the User." + * type: string + * last_name: + * description: "The name of the User." + * type: string + * role: + * description: "Userrole assigned to the user." + * type: string + * enum: [admin, member, developer] + * api_token: + * description: "The api token of the User." + * type: string + * metadata: + * description: An optional set of key-value pairs with additional information. + * type: object + */ export class AdminUpdateUserRequest { @IsString() @IsOptional() 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 f38196e38c..df1f33e429 100644 --- a/packages/medusa/src/api/routes/store/carts/create-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/create-cart.ts @@ -36,40 +36,7 @@ import PublishableAPIKeysFeatureFlag from "../../../../loaders/feature-flags/pub * content: * application/json: * schema: - * type: object - * properties: - * region_id: - * type: string - * description: The ID of the Region to create the Cart in. - * sales_channel_id: - * type: string - * description: "[EXPERIMENTAL] The ID of the Sales channel to create the Cart in." - * country_code: - * type: string - * description: "The 2 character ISO country code to create the Cart in." - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements - * description: See a list of codes. - * items: - * description: "An optional array of `variant_id`, `quantity` pairs to generate Line Items from." - * type: array - * items: - * required: - * - variant_id - * - quantity - * properties: - * variant_id: - * description: The id of the Product Variant to generate a Line Item from. - * type: string - * quantity: - * description: The quantity of the Product Variant to add - * type: integer - * context: - * description: "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`" - * type: object - * example: - * ip: "::1" - * user_agent: "Chrome" + * $ref: "#/components/schemas/StorePostCartReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -223,6 +190,43 @@ export class Item { quantity: number } +/** + * @schema StorePostCartReq + * type: object + * properties: + * region_id: + * type: string + * description: The ID of the Region to create the Cart in. + * sales_channel_id: + * type: string + * description: "[EXPERIMENTAL] The ID of the Sales channel to create the Cart in." + * country_code: + * type: string + * description: "The 2 character ISO country code to create the Cart in." + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements + * description: See a list of codes. + * items: + * description: "An optional array of `variant_id`, `quantity` pairs to generate Line Items from." + * type: array + * items: + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * description: The id of the Product Variant to generate a Line Item from. + * type: string + * quantity: + * description: The quantity of the Product Variant to add + * type: integer + * context: + * description: "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`" + * type: object + * example: + * ip: "::1" + * user_agent: "Chrome" + */ export class StorePostCartReq { @IsOptional() @IsString() 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 6a43fe0761..eaff7ce95c 100644 --- a/packages/medusa/src/api/routes/store/carts/update-cart.ts +++ b/packages/medusa/src/api/routes/store/carts/update-cart.ts @@ -26,67 +26,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * properties: - * region_id: - * type: string - * description: The id of the Region to create the Cart in. - * country_code: - * type: string - * description: "The 2 character ISO country code to create the Cart in." - * externalDocs: - * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements - * description: See a list of codes. - * email: - * type: string - * description: "An email to be used on the Cart." - * format: email - * sales_channel_id: - * type: string - * description: The ID of the Sales channel to update the Cart with. - * billing_address: - * description: "The Address to be used for billing purposes." - * anyOf: - * - $ref: "#/components/schemas/Address" - * description: A full billing address object. - * - type: string - * description: The billing address ID - * shipping_address: - * description: "The Address to be used for shipping." - * anyOf: - * - $ref: "#/components/schemas/Address" - * description: A full shipping address object. - * - type: string - * description: The shipping address ID - * gift_cards: - * description: "An array of Gift Card codes to add to the Cart." - * type: array - * items: - * required: - * - code - * properties: - * code: - * description: "The code that a Gift Card is identified by." - * type: string - * discounts: - * description: "An array of Discount codes to add to the Cart." - * type: array - * items: - * required: - * - code - * properties: - * code: - * description: "The code that a Discount is identifed by." - * type: string - * customer_id: - * description: "The ID of the Customer to associate the Cart with." - * type: string - * context: - * description: "An optional object to provide context to the Cart." - * type: object - * example: - * ip: "::1" - * user_agent: "Chrome" + * $ref: "#/components/schemas/StorePostCartsCartReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -174,6 +114,70 @@ class Discount { code: string } +/** + * @schema StorePostCartsCartReq + * type: object + * properties: + * region_id: + * type: string + * description: The id of the Region to create the Cart in. + * country_code: + * type: string + * description: "The 2 character ISO country code to create the Cart in." + * externalDocs: + * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements + * description: See a list of codes. + * email: + * type: string + * description: "An email to be used on the Cart." + * format: email + * sales_channel_id: + * type: string + * description: The ID of the Sales channel to update the Cart with. + * billing_address: + * description: "The Address to be used for billing purposes." + * anyOf: + * - $ref: "#/components/schemas/Address" + * description: A full billing address object. + * - type: string + * description: The billing address ID + * shipping_address: + * description: "The Address to be used for shipping." + * anyOf: + * - $ref: "#/components/schemas/Address" + * description: A full shipping address object. + * - type: string + * description: The shipping address ID + * gift_cards: + * description: "An array of Gift Card codes to add to the Cart." + * type: array + * items: + * required: + * - code + * properties: + * code: + * description: "The code that a Gift Card is identified by." + * type: string + * discounts: + * description: "An array of Discount codes to add to the Cart." + * type: array + * items: + * required: + * - code + * properties: + * code: + * description: "The code that a Discount is identifed by." + * type: string + * customer_id: + * description: "The ID of the Customer to associate the Cart with." + * type: string + * context: + * description: "An optional object to provide context to the Cart." + * type: object + * example: + * ip: "::1" + * user_agent: "Chrome" + */ export class StorePostCartsCartReq { @IsOptional() @IsString() 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 79d2f61111..8130252238 100644 --- a/packages/medusa/src/api/routes/store/customers/create-address.ts +++ b/packages/medusa/src/api/routes/store/customers/create-address.ts @@ -16,22 +16,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - address - * properties: - * address: - * description: "The Address to add to the Customer." - * allOf: - * - $ref: "#/components/schemas/AddressFields" - * - type: object - * required: - * - first_name - * - last_name - * - address_1 - * - city - * - country_code - * - postal_code + * $ref: "#/components/schemas/StorePostCustomersCustomerAddressesReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -125,6 +110,25 @@ export default async (req, res) => { res.status(200).json({ customer }) } +/** + * @schema StorePostCustomersCustomerAddressesReq + * type: object + * required: + * - address + * properties: + * address: + * description: "The Address to add to the Customer." + * allOf: + * - $ref: "#/components/schemas/AddressFields" + * - type: object + * required: + * - first_name + * - last_name + * - address_1 + * - city + * - country_code + * - postal_code + */ export class StorePostCustomersCustomerAddressesReq { @ValidateNested() @Type(() => AddressCreatePayload) 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 50426677fa..e943ed8543 100644 --- a/packages/medusa/src/api/routes/store/customers/create-customer.ts +++ b/packages/medusa/src/api/routes/store/customers/create-customer.ts @@ -16,30 +16,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - first_name - * - last_name - * - email - * - password - * properties: - * first_name: - * description: "The Customer's first name." - * type: string - * last_name: - * description: "The Customer's last name." - * type: string - * email: - * description: "The email of the customer." - * type: string - * format: email - * password: - * description: "The Customer's password." - * type: string - * format: password - * phone: - * description: "The Customer's phone number." - * type: string + * $ref: "#/components/schemas/StorePostCustomersReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -136,6 +113,33 @@ export default async (req, res) => { res.status(200).json({ customer }) } +/** + * @schema StorePostCustomersReq + * type: object + * required: + * - first_name + * - last_name + * - email + * - password + * properties: + * first_name: + * description: "The Customer's first name." + * type: string + * last_name: + * description: "The Customer's last name." + * type: string + * email: + * description: "The email of the customer." + * type: string + * format: email + * password: + * description: "The Customer's password." + * type: string + * format: password + * phone: + * description: "The Customer's phone number." + * type: string + */ export class StorePostCustomersReq { @IsString() @IsOptional() 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 77777ee30b..fbca61cfdc 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 @@ -12,14 +12,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - email - * properties: - * email: - * description: "The email of the customer." - * type: string - * format: email + * $ref: "#/components/schemas/StorePostCustomersCustomerPasswordTokenReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -86,6 +79,17 @@ export default async (req, res) => { res.sendStatus(204) } +/** + * @schema StorePostCustomersCustomerPasswordTokenReq + * type: object + * required: + * - email + * properties: + * email: + * description: "The email of the customer." + * type: string + * format: email + */ export class StorePostCustomersCustomerPasswordTokenReq { @IsEmail() email: string 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 d11ef59a2c..9efee524ef 100644 --- a/packages/medusa/src/api/routes/store/customers/reset-password.ts +++ b/packages/medusa/src/api/routes/store/customers/reset-password.ts @@ -14,23 +14,7 @@ import { EntityManager } from "typeorm" * content: * application/json: * schema: - * type: object - * required: - * - email - * - password - * - token - * properties: - * email: - * description: "The email of the customer." - * type: string - * format: email - * password: - * description: "The Customer's password." - * type: string - * format: password - * token: - * description: "The reset password token" - * type: string + * $ref: "#/components/schemas/StorePostCustomersResetPasswordReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -116,6 +100,26 @@ export default async (req, res) => { res.status(200).json({ customer }) } +/** + * @schema StorePostCustomersResetPasswordReq + * type: object + * required: + * - email + * - password + * - token + * properties: + * email: + * description: "The email of the customer." + * type: string + * format: email + * password: + * description: "The Customer's password." + * type: string + * format: password + * token: + * description: "The reset password token" + * type: string + */ export class StorePostCustomersResetPasswordReq { @IsEmail() email: string 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 4cd01f7887..f7d927a610 100644 --- a/packages/medusa/src/api/routes/store/customers/update-address.ts +++ b/packages/medusa/src/api/routes/store/customers/update-address.ts @@ -17,8 +17,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * anyOf: - * - $ref: "#/components/schemas/AddressFields" + * $ref: "#/components/schemas/StorePostCustomersCustomerAddressesAddressReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -97,5 +96,10 @@ export default async (req, res) => { res.json({ customer }) } +/** + * @schema StorePostCustomersCustomerAddressesAddressReq + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + */ // eslint-disable-next-line max-len export class StorePostCustomersCustomerAddressesAddressReq extends AddressPayload {} 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 0d396a6d0a..8d4721970a 100644 --- a/packages/medusa/src/api/routes/store/customers/update-customer.ts +++ b/packages/medusa/src/api/routes/store/customers/update-customer.ts @@ -17,33 +17,7 @@ import { IsType } from "../../../../utils/validators/is-type" * content: * application/json: * schema: - * type: object - * properties: - * first_name: - * description: "The Customer's first name." - * type: string - * last_name: - * description: "The Customer's last name." - * type: string - * billing_address: - * description: "The Address to be used for billing purposes." - * anyOf: - * - $ref: "#/components/schemas/AddressFields" - * description: The full billing address object - * - type: string - * description: The ID of an existing billing address - * password: - * description: "The Customer's password." - * type: string - * phone: - * description: "The Customer's phone number." - * type: string - * email: - * description: "The email of the customer." - * type: string - * metadata: - * description: "Metadata about the customer." - * type: object + * $ref: "#/components/schemas/StorePostCustomersCustomerReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -114,6 +88,36 @@ export default async (req, res) => { res.status(200).json({ customer }) } +/** + * @schema StorePostCustomersCustomerReq + * type: object + * properties: + * first_name: + * description: "The Customer's first name." + * type: string + * last_name: + * description: "The Customer's last name." + * type: string + * billing_address: + * description: "The Address to be used for billing purposes." + * anyOf: + * - $ref: "#/components/schemas/AddressFields" + * description: The full billing address object + * - type: string + * description: The ID of an existing billing address + * password: + * description: "The Customer's password." + * type: string + * phone: + * description: "The Customer's phone number." + * type: string + * email: + * description: "The email of the customer." + * type: string + * metadata: + * description: "Metadata about the customer." + * type: object + */ export class StorePostCustomersCustomerReq { @IsOptional() @IsType([AddressPayload, String]) 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 2da914c89b..7dc4d689ec 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 @@ -18,11 +18,7 @@ import { * content: * application/json: * schema: - * type: object - * properties: - * declined_reason: - * type: string - * description: The reason for declining the OrderEdit. + * $ref: "#/components/schemas/StorePostOrderEditsOrderEditDecline" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -87,6 +83,14 @@ export default async (req: Request, res: Response) => { res.status(200).json({ order_edit: orderEdit }) } +/** + * @schema StorePostOrderEditsOrderEditDecline + * type: object + * properties: + * declined_reason: + * type: string + * description: The reason for declining the OrderEdit. + */ export class StorePostOrderEditsOrderEditDecline { @IsOptional() @IsString() 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 1c8e426e45..d41dab78c5 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 @@ -15,12 +15,7 @@ import { * content: * application/json: * schema: - * required: - * - token - * properties: - * token: - * description: "The invite token provided by the admin." - * type: string + * $ref: "#/components/schemas/StorePostCustomersCustomerAcceptClaimReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -110,6 +105,16 @@ export default async (req, res) => { res.sendStatus(200) } +/** + * @schema StorePostCustomersCustomerAcceptClaimReq + * type: object + * required: + * - token + * properties: + * token: + * description: "The invite token provided by the admin." + * type: string + */ export class StorePostCustomersCustomerAcceptClaimReq { @IsNotEmpty() @IsJWT() 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 6ea7b3a007..39439fa648 100644 --- a/packages/medusa/src/api/routes/store/orders/request-order.ts +++ b/packages/medusa/src/api/routes/store/orders/request-order.ts @@ -17,14 +17,7 @@ import { TokenEvents } from "../../../../types/token" * content: * application/json: * schema: - * required: - * - order_ids - * properties: - * order_ids: - * description: "The ids of the orders to claim" - * type: array - * items: - * type: string + * $ref: "#/components/schemas/StorePostCustomersCustomerOrderClaimReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -125,6 +118,18 @@ export default async (req, res) => { res.sendStatus(200) } +/** + * @schema StorePostCustomersCustomerOrderClaimReq + * type: object + * required: + * - order_ids + * properties: + * order_ids: + * description: "The ids of the orders to claim" + * type: array + * items: + * type: string + */ export class StorePostCustomersCustomerOrderClaimReq { @IsNotEmpty({ each: true }) @IsString({ each: true }) 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 d379f8ab24..b5a6ff4c98 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 @@ -13,12 +13,7 @@ import { PaymentCollectionService } from "../../../../services" * content: * application/json: * schema: - * properties: - * session_ids: - * description: "List of Payment Session IDs to authorize." - * type: array - * items: - * type: string + * $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsAuthorizeReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -80,6 +75,18 @@ export default async (req, res) => { res.status(207).json({ payment_collection }) } +/** + * @schema StorePostPaymentCollectionsBatchSessionsAuthorizeReq + * type: object + * required: + * - session_ids + * properties: + * session_ids: + * description: "List of Payment Session IDs to authorize." + * type: array + * items: + * type: string + */ export class StorePostPaymentCollectionsBatchSessionsAuthorizeReq { @IsArray() @IsString({ each: true }) 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 b7d13850be..549ddd4751 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 @@ -16,24 +16,7 @@ import { PaymentCollectionService } from "../../../../services" * content: * application/json: * schema: - * properties: - * sessions: - * description: "An array of payment sessions related to the Payment Collection. If the session_id is not provided, existing sessions not present will be deleted and the provided ones will be created." - * type: array - * items: - * required: - * - provider_id - * - amount - * properties: - * provider_id: - * type: string - * description: The ID of the Payment Provider. - * amount: - * type: integer - * description: "The amount ." - * session_id: - * type: string - * description: "The ID of the Payment Session to be updated." + * $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -136,6 +119,30 @@ export class StorePostPaymentCollectionsSessionsReq { session_id?: string } +/** + * @schema StorePostPaymentCollectionsBatchSessionsReq + * type: object + * required: + * - sessions + * properties: + * sessions: + * description: "An array of payment sessions related to the Payment Collection. If the session_id is not provided, existing sessions not present will be deleted and the provided ones will be created." + * type: array + * items: + * required: + * - provider_id + * - amount + * properties: + * provider_id: + * type: string + * description: The ID of the Payment Provider. + * amount: + * type: integer + * description: "The amount ." + * session_id: + * type: string + * description: "The ID of the Payment Session to be updated." + */ export class StorePostPaymentCollectionsBatchSessionsReq { @IsType([[StorePostPaymentCollectionsSessionsReq]]) sessions: StorePostPaymentCollectionsSessionsReq[] 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 380c002443..cc99e80093 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 @@ -15,12 +15,7 @@ import { PaymentCollectionService } from "../../../../services" * content: * application/json: * schema: - * required: - * - provider_id - * properties: - * provider_id: - * type: string - * description: The ID of the Payment Provider. + * $ref: "#/components/schemas/StorePaymentCollectionSessionsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -91,6 +86,16 @@ export default async (req, res) => { res.status(200).json({ payment_collection: paymentCollection }) } +/** + * @schema StorePaymentCollectionSessionsReq + * type: object + * required: + * - provider_id + * properties: + * provider_id: + * type: string + * description: The ID of the Payment Provider. + */ export class StorePaymentCollectionSessionsReq { @IsString() provider_id: string 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 ee2d771e37..f7294588f7 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,28 +10,13 @@ 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. - * requestBody: - * content: - * application/json: - * schema: - * type: object - * required: - * - provider_id - * - customer_id - * properties: - * provider_id: - * description: The Payment Provider id. - * type: string - * customer_id: - * description: The Customer id. - * type: string * x-codeSamples: * - lang: JavaScript * label: JS Client * source: | * import Medusa from "@medusajs/medusa-js" * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * medusa.paymentCollections.refreshPaymentSession(payment_collection_id, session_id, payload) + * medusa.paymentCollections.refreshPaymentSession(payment_collection_id, session_id) * .then(({ payment_session }) => { * console.log(payment_session.id); * }); 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 0f9152f61f..ce5a7f1821 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.ts +++ b/packages/medusa/src/api/routes/store/returns/create-return.ts @@ -25,43 +25,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - order_id - * - items - * properties: - * order_id: - * type: string - * description: The ID of the Order to create the Return from. - * items: - * description: "The items to include in the Return." - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item from the Order. - * type: string - * quantity: - * description: The quantity to return. - * type: integer - * reason_id: - * description: The ID of the return reason. - * type: string - * note: - * description: A note to add to the item returned. - * type: string - * return_shipping: - * description: If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves. - * type: object - * required: - * - option_id - * properties: - * option_id: - * type: string - * description: The ID of the Shipping Option to create the Shipping Method from. + * $ref: "#/components/schemas/StorePostReturnsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -287,6 +251,46 @@ class Item { note?: string } +/** + * @schema StorePostReturnsReq + * type: object + * required: + * - order_id + * - items + * properties: + * order_id: + * type: string + * description: The ID of the Order to create the Return from. + * items: + * description: "The items to include in the Return." + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item from the Order. + * type: string + * quantity: + * description: The quantity to return. + * type: integer + * reason_id: + * description: The ID of the return reason. + * type: string + * note: + * description: A note to add to the item returned. + * type: string + * return_shipping: + * description: If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves. + * type: object + * required: + * - option_id + * properties: + * option_id: + * type: string + * description: The ID of the Shipping Option to create the Shipping Method from. + */ export class StorePostReturnsReq { @IsString() @IsNotEmpty() 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 847572900c..146ed54825 100644 --- a/packages/medusa/src/api/routes/store/swaps/create-swap.ts +++ b/packages/medusa/src/api/routes/store/swaps/create-swap.ts @@ -27,52 +27,7 @@ import { validator } from "../../../../utils/validator" * content: * application/json: * schema: - * type: object - * required: - * - order_id - * - return_items - * - additional_items - * properties: - * order_id: - * type: string - * description: The ID of the Order to create the Swap for. - * return_items: - * description: "The items to include in the Return." - * type: array - * items: - * required: - * - item_id - * - quantity - * properties: - * item_id: - * description: The ID of the Line Item from the Order. - * type: string - * quantity: - * description: The quantity to swap. - * type: integer - * reason_id: - * description: The ID of the reason of this return. - * type: string - * note: - * description: The note to add to the item being swapped. - * type: string - * return_shipping_option: - * type: string - * description: The ID of the Shipping Option to create the Shipping Method from. - * additional_items: - * description: "The items to exchange the returned items to." - * type: array - * items: - * required: - * - variant_id - * - quantity - * properties: - * variant_id: - * description: The ID of the Product Variant to send. - * type: string - * quantity: - * description: The quantity to send of the variant. - * type: integer + * $ref: "#/components/schemas/StorePostSwapsReq" * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -327,6 +282,55 @@ class AdditionalItem { quantity: number } +/** + * @schema StorePostSwapsReq + * type: object + * required: + * - order_id + * - return_items + * - additional_items + * properties: + * order_id: + * type: string + * description: The ID of the Order to create the Swap for. + * return_items: + * description: "The items to include in the Return." + * type: array + * items: + * required: + * - item_id + * - quantity + * properties: + * item_id: + * description: The ID of the Line Item from the Order. + * type: string + * quantity: + * description: The quantity to swap. + * type: integer + * reason_id: + * description: The ID of the reason of this return. + * type: string + * note: + * description: The note to add to the item being swapped. + * type: string + * return_shipping_option: + * type: string + * description: The ID of the Shipping Option to create the Shipping Method from. + * additional_items: + * description: "The items to exchange the returned items to." + * type: array + * items: + * required: + * - variant_id + * - quantity + * properties: + * variant_id: + * description: The ID of the Product Variant to send. + * type: string + * quantity: + * description: The quantity to send of the variant. + * type: integer + */ export class StorePostSwapsReq { @IsString() @IsNotEmpty()