From 4d3210bfbb84877d951f7319d2e87c1acbdd6aad Mon Sep 17 00:00:00 2001 From: Patrick <116003638+patrick-medusajs@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:00:37 -0500 Subject: [PATCH] feat(oas) - accurate model OAS representation - A to D (#3203) ### Scope Models A to D ### What Refactor OAS for models to accurately represent their shape in API responses. ### Why About 33% of model fields are not accurately represented in the OAS. Most of the issues are: - fields that can not be omitted in the response are not declared as `required` - fields that could return `null` as their value are not declared as `nullable: true` When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client. ### How #### nullable Fields meeting at least one of the following condition will be represented as `nullable: true` in OAS: * The field is decorated with `@Column({ nullable: true })` * The field is decorated with `@OneToOne`, `@ManyToOne` * The field is decorated with `@DeleteDateColumn` #### optional Fields meeting at least one of the following conditions will never be listed as `required` in OAS and will be considered optional and could be omitted in the response: * The field is decorated with `@OneToOne`, `@ManyToOne`, `@OneToMany`, `@ManyToMany` * The field is decorated with `@FeatureFlagColumn` * The field is decorated with `@Column({select: false})` * The field is representing dynamic values not persisted in the database Fields not meeting any of the conditions above will be declared as `required` and are expected to be present in the response. ### Test * Ran OAS validator. * Ran docs build script. Expect OAS changes to be reflected in the API documentation. --- .changeset/young-beers-beg.md | 5 + packages/medusa/src/models/address.ts | 65 ++++++--- packages/medusa/src/models/batch-job.ts | 127 +++++++++++------- packages/medusa/src/models/cart.ts | 117 +++++++++++----- packages/medusa/src/models/claim-image.ts | 28 ++-- packages/medusa/src/models/claim-item.ts | 42 +++--- packages/medusa/src/models/claim-order.ts | 64 ++++++--- packages/medusa/src/models/claim-tag.ts | 19 ++- packages/medusa/src/models/country.ts | 24 ++-- packages/medusa/src/models/currency.ts | 11 +- .../src/models/custom-shipping-option.ts | 34 +++-- packages/medusa/src/models/customer-group.ts | 26 ++-- packages/medusa/src/models/customer.ts | 42 ++++-- .../discount-condition-customer-group.ts | 18 ++- .../discount-condition-product-collection.ts | 18 ++- .../models/discount-condition-product-tag.ts | 18 ++- .../models/discount-condition-product-type.ts | 18 ++- .../src/models/discount-condition-product.ts | 18 ++- .../medusa/src/models/discount-condition.ts | 47 ++++--- packages/medusa/src/models/discount-rule.ts | 32 +++-- packages/medusa/src/models/discount.ts | 55 +++++--- packages/medusa/src/models/draft-order.ts | 54 +++++--- 22 files changed, 578 insertions(+), 304 deletions(-) create mode 100644 .changeset/young-beers-beg.md diff --git a/.changeset/young-beers-beg.md b/.changeset/young-beers-beg.md new file mode 100644 index 000000000000..9631fbf1602c --- /dev/null +++ b/.changeset/young-beers-beg.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +feat(oas) - accurate model OAS representation - A to D diff --git a/packages/medusa/src/models/address.ts b/packages/medusa/src/models/address.ts index 7e360c916943..333fd2e51067 100644 --- a/packages/medusa/src/models/address.ts +++ b/packages/medusa/src/models/address.ts @@ -126,66 +126,93 @@ export class Address extends SoftDeletableEntity { * title: "Address" * description: "An address." * type: object + * required: + * - address_1 + * - address_2 + * - city + * - company + * - country_code + * - created_at + * - customer_id + * - deleted_at + * - first_name + * - id + * - last_name + * - metadata + * - phone + * - postal_code + * - province + * - updated_at * properties: * id: * type: string * description: ID of the address * example: addr_01G8ZC9VS1XVE149MGH2J7QSSH * customer_id: - * type: string * description: ID of the customer this address belongs to + * nullable: true + * type: string * example: cus_01G2SG30J8C85S4A5CHM2S1NS2 * customer: * description: Available if the relation `customer` is expanded. - * type: array - * items: - * type: object - * description: A customer object. + * nullable: true + * $ref: "#/components/schemas/Customer" * company: - * type: string * description: Company name + * nullable: true + * type: string * example: Acme * first_name: - * type: string * description: First name + * nullable: true + * type: string * example: Arno * last_name: - * type: string * description: Last name + * nullable: true + * type: string * example: Willms * address_1: - * type: string * description: Address line 1 + * nullable: true + * type: string * example: 14433 Kemmer Court * address_2: - * type: string * description: Address line 2 + * nullable: true + * type: string * example: Suite 369 * city: - * type: string * description: City + * nullable: true + * type: string * example: South Geoffreyview * country_code: - * type: string * description: The 2 character ISO code of the country in lower case + * nullable: true + * type: string * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements * description: See a list of codes. * example: st * country: * description: A country object. Available if the relation `country` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Country" * province: - * type: string * description: Province + * nullable: true + * type: string * example: Kentucky * postal_code: - * type: string * description: Postal Code + * nullable: true + * type: string * example: 72093 * phone: - * type: string * description: Phone Number + * nullable: true + * type: string * example: 16128234334802 * created_at: * type: string @@ -196,11 +223,13 @@ export class Address extends SoftDeletableEntity { * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/batch-job.ts b/packages/medusa/src/models/batch-job.ts index 6ba068701120..07e8d6f64dee 100644 --- a/packages/medusa/src/models/batch-job.ts +++ b/packages/medusa/src/models/batch-job.ts @@ -108,21 +108,36 @@ export class BatchJob extends SoftDeletableEntity { * description: "A Batch Job." * type: object * required: + * - canceled_at + * - completed_at + * - confirmed_at + * - context + * - created_at + * - created_by + * - deleted_at + * - dry_run + * - failed_at + * - id + * - pre_processed_at + * - processing_at + * - result + * - status * - type + * - updated_at * properties: * id: + * description: The unique identifier for the batch job. * type: string - * description: "The unique identifier for the batch job." * example: batch_01G8T782965PYFG0751G0Z38B4 * type: + * description: The type of batch job. * type: string - * description: "The type of batch job." * enum: * - product-import * - product-export * status: + * description: The status of the batch job. * type: string - * description: "The status of the batch job." * enum: * - created * - pre_processed @@ -133,15 +148,18 @@ export class BatchJob extends SoftDeletableEntity { * - failed * default: created * created_by: + * description: The unique identifier of the user that created the batch job. + * nullable: true * type: string - * description: "The unique identifier of the user that created the batch job." * example: usr_01G1G5V26F5TB3GPAPNJ8X1S3V * created_by_user: * description: A user object. Available if the relation `created_by_user` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/User" * context: + * description: The context of the batch job, the type of the batch job determines what the context should contain. + * nullable: true * type: object - * description: "The context of the batch job, the type of the batch job determines what the context should contain." * example: * shape: * prices: @@ -159,43 +177,47 @@ export class BatchJob extends SoftDeletableEntity { * - variant.prices * - images * dry_run: + * description: Specify if the job must apply the modifications or not. * type: boolean - * description: "Specify if the job must apply the modifications or not." * default: false * result: - * type: object - * description: "The result of the batch job." - * properties: - * count: - * type: number - * advancement_count: - * type: number - * progress: - * type: number - * errors: - * type: object - * properties: - * message: - * type: string - * code: - * oneOf: - * - type: string - * - type: number - * err: - * type: array - * stat_descriptors: - * type: object - * properties: - * key: - * type: string - * name: - * type: string - * message: - * type: string - * file_key: - * type: string - * file_size: - * type: number + * description: The result of the batch job. + * nullable: true + * allOf: + * - type: object + * example: {} + * - type: object + * properties: + * count: + * type: number + * advancement_count: + * type: number + * progress: + * type: number + * errors: + * type: object + * properties: + * message: + * type: string + * code: + * oneOf: + * - type: string + * - type: number + * err: + * type: array + * stat_descriptors: + * type: object + * properties: + * key: + * type: string + * name: + * type: string + * message: + * type: string + * file_key: + * type: string + * file_size: + * type: number * example: * errors: * - err: [] @@ -206,39 +228,46 @@ export class BatchJob extends SoftDeletableEntity { * name: "Product count to export" * message: "There will be 8 products exported by this action" * pre_processed_at: + * description: The date from which the job has been pre-processed. + * nullable: true * type: string - * description: "The date from which the job has been pre processed." * format: date-time * processing_at: + * description: The date the job is processing at. + * nullable: true * type: string - * description: "The date the job is processing at." * format: date-time * confirmed_at: + * description: The date when the confirmation has been done. + * nullable: true * type: string - * description: "The date when the confirmation has been done." * format: date-time * completed_at: + * description: The date of the completion. + * nullable: true * type: string - * description: "The date of the completion." * format: date-time * canceled_at: + * description: The date of the concellation. + * nullable: true * type: string - * description: "The date of the concellation." * format: date-time * failed_at: + * description: The date when the job failed. + * nullable: true * type: string - * description: "The date when the job failed." * format: date-time * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was last updated. * type: string - * description: "The date with timezone at which the resource was last updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time */ diff --git a/packages/medusa/src/models/cart.ts b/packages/medusa/src/models/cart.ts index 5c46f04712a7..026d820c96f9 100644 --- a/packages/medusa/src/models/cart.ts +++ b/packages/medusa/src/models/cart.ts @@ -3,28 +3,51 @@ * title: "Cart" * description: "Represents a user cart" * type: object + * required: + * - billing_address_id + * - completed_at + * - context + * - created_at + * - customer_id + * - deleted_at + * - email + * - id + * - idempotency_key + * - metadata + * - payment_authorized_at + * - payment_id + * - payment_session + * - region_id + * - shipping_address_id + * - type + * - updated_at * properties: * id: - * type: string * description: The cart's ID + * type: string * example: cart_01G8ZH853Y6TFXWPG5EYE81X63 * email: - * type: string * description: The email associated with the cart + * nullable: true + * type: string * format: email * billing_address_id: - * type: string * description: The billing address's ID + * nullable: true + * type: string * example: addr_01G8ZH853YPY9B94857DY91YGW * billing_address: * description: Available if the relation `billing_address` is expanded. + * nullable: true * $ref: "#/components/schemas/Address" * shipping_address_id: - * type: string * description: The shipping address's ID + * nullable: true + * type: string * example: addr_01G8ZH853YPY9B94857DY91YGW * shipping_address: * description: Available if the relation `shipping_address` is expanded. + * nullable: true * $ref: "#/components/schemas/Address" * items: * description: Available if the relation `items` is expanded. @@ -32,54 +55,58 @@ * items: * $ref: "#/components/schemas/LineItem" * region_id: - * type: string * description: The region's ID + * type: string * example: reg_01G1G5V26T9H8Y0M4JNE3YGA4G * region: * description: A region object. Available if the relation `region` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Region" * discounts: - * type: array * description: Available if the relation `discounts` is expanded. + * type: array * items: - * type: object - * description: A discount object. + * $ref: "#/components/schemas/Discount" * gift_cards: - * type: array * description: Available if the relation `gift_cards` is expanded. + * type: array * items: - * type: object - * description: A gift card object. + * $ref: "#/components/schemas/GiftCard" * customer_id: - * type: string * description: The customer's ID + * nullable: true + * type: string * example: cus_01G2SG30J8C85S4A5CHM2S1NS2 * customer: * description: A customer object. Available if the relation `customer` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Customer" * payment_session: * description: The selected payment session in the cart. + * nullable: true * $ref: "#/components/schemas/PaymentSession" * payment_sessions: - * type: array * description: The payment sessions created on the cart. + * type: array * items: * $ref: "#/components/schemas/PaymentSession" * payment_id: - * type: string * description: The payment's ID if available + * nullable: true + * type: string * example: pay_01G8ZCC5W42ZNY842124G7P5R9 * payment: * description: Available if the relation `payment` is expanded. + * nullable: true * $ref: "#/components/schemas/Payment" * shipping_methods: - * type: array * description: The shipping methods added to the cart. + * type: array * items: * $ref: "#/components/schemas/ShippingMethod" * type: - * type: string * description: The cart's type. + * type: string * enum: * - default * - swap @@ -88,83 +115,99 @@ * - claim * default: default * completed_at: + * description: The date with timezone at which the cart was completed. + * nullable: true * type: string - * description: "The date with timezone at which the cart was completed." * format: date-time * payment_authorized_at: + * description: The date with timezone at which the payment was authorized. + * nullable: true * type: string - * description: "The date with timezone at which the payment was authorized." * format: date-time * idempotency_key: - * type: string * description: Randomly generated key used to continue the completion of a cart in case of failure. + * nullable: true + * type: string * externalDocs: * url: https://docs.medusajs.com/advanced/backend/payment/overview#idempotency-key * description: Learn more how to use the idempotency key. * context: - * type: object * description: "The context of the cart which can include info like IP or user agent." + * nullable: true + * type: object * example: * ip: "::1" * user_agent: "PostmanRuntime/7.29.2" * sales_channel_id: - * type: string * description: The sales channel ID the cart is associated with. + * nullable: true + * type: string * example: null * sales_channel: * description: A sales channel object. Available if the relation `sales_channel` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/SalesChannel" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} * shipping_total: - * type: integer * description: The total of shipping + * type: integer * example: 1000 * discount_total: - * type: integer * description: The total of discount + * type: integer * example: 800 - * tax_total: + * item_tax_total: + * description: The total of items with taxes * type: integer + * example: 8000 + * shipping_tax_total: + * description: The total of shipping with taxes + * type: integer + * example: 1000 + * tax_total: * description: The total of tax + * type: integer * example: 0 * refunded_total: - * type: integer * description: The total amount refunded if the order associated with this cart is returned. + * type: integer * example: 0 * total: - * type: integer * description: The total amount of the cart + * type: integer * example: 8200 * subtotal: - * type: integer * description: The subtotal of the cart + * type: integer * example: 8000 * refundable_amount: - * type: integer * description: The amount that can be refunded + * type: integer * example: 8200 * gift_card_total: - * type: integer * description: The total of gift cards + * type: integer * example: 0 * gift_card_tax_total: - * type: integer * description: The total of gift cards with taxes + * type: integer * example: 0 */ diff --git a/packages/medusa/src/models/claim-image.ts b/packages/medusa/src/models/claim-image.ts index d8d20da1d397..a9ed58c86ac4 100644 --- a/packages/medusa/src/models/claim-image.ts +++ b/packages/medusa/src/models/claim-image.ts @@ -40,37 +40,45 @@ export class ClaimImage extends SoftDeletableEntity { * description: "Represents photo documentation of a claim." * type: object * required: - * - claim_item_id - * - url + * - claim_item_id + * - created_at + * - deleted_at + * - id + * - metadata + * - updated_at + * - url * properties: * id: - * type: string * description: The claim image's ID + * type: string * example: cimg_01G8ZH853Y6TFXWPG5EYE81X63 * claim_item_id: - * type: string * description: The ID of the claim item associated with the image + * type: string * claim_item: * description: A claim item object. Available if the relation `claim_item` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/ClaimItem" * url: - * type: string * description: The URL of the image + * type: string * format: uri * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/claim-item.ts b/packages/medusa/src/models/claim-item.ts index cb7fe27e41c4..d783197b50ef 100644 --- a/packages/medusa/src/models/claim-item.ts +++ b/packages/medusa/src/models/claim-item.ts @@ -96,18 +96,24 @@ export class ClaimItem extends SoftDeletableEntity { * type: object * required: * - claim_order_id + * - created_at + * - deleted_at + * - id * - item_id - * - variant_id - * - reason + * - metadata + * - note * - quantity + * - reason + * - updated_at + * - variant_id * properties: * id: - * type: string * description: The claim item's ID + * type: string * example: citm_01G8ZH853Y6TFXWPG5EYE81X63 * images: - * type: array * description: Available if the relation `images` is expanded. + * type: array * items: * $ref: "#/components/schemas/ClaimImage" * claim_order_id: @@ -115,23 +121,26 @@ export class ClaimItem extends SoftDeletableEntity { * type: string * claim_order: * description: A claim order object. Available if the relation `claim_order` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/ClaimOrder" * item_id: * description: The ID of the line item that the claim item refers to. * type: string * example: item_01G8ZM25TN49YV9EQBE2NC27KC * item: * description: Available if the relation `item` is expanded. + * nullable: true * $ref: "#/components/schemas/LineItem" * variant_id: - * description: "The ID of the product variant that is claimed." + * description: The ID of the product variant that is claimed. * type: string * example: variant_01G1G5V2MRX2V3PVSR2WXYPFB6 * variant: * description: A variant object. Available if the relation `variant` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/ProductVariant" * reason: - * description: "The reason for the claim" + * description: The reason for the claim * type: string * enum: * - missing_item @@ -139,32 +148,35 @@ export class ClaimItem extends SoftDeletableEntity { * - production_failure * - other * note: - * description: "An optional note about the claim, for additional information" + * description: An optional note about the claim, for additional information + * nullable: true * type: string * example: "I don't like it." * quantity: - * description: "The quantity of the item that is being claimed; must be less than or equal to the amount purchased in the original order." + * description: The quantity of the item that is being claimed; must be less than or equal to the amount purchased in the original order. * type: integer * example: 1 * tags: - * description: "User defined tags for easy filtering and grouping. Available if the relation 'tags' is expanded." + * description: User defined tags for easy filtering and grouping. Available if the relation 'tags' is expanded. * type: array * items: * $ref: "#/components/schemas/ClaimTag" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 0efc509079d6..eee8a3c05e3c 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -136,27 +136,41 @@ export class ClaimOrder extends SoftDeletableEntity { * description: "Claim Orders represent a group of faulty or missing items. Each claim order consists of a subset of items associated with an original order, and can contain additional information about fulfillments and returns." * type: object * required: - * - type + * - canceled_at + * - created_at + * - deleted_at + * - fulfillment_status + * - id + * - idempotency_key + * - metadata + * - no_notification * - order_id + * - payment_status + * - refund_amount + * - shipping_address_id + * - type + * - updated_at * properties: * id: - * type: string * description: The claim's ID + * type: string * example: claim_01G8ZH853Y6TFXWPG5EYE81X63 * type: + * description: The claim's type * type: string * enum: * - refund * - replace * payment_status: - * type: string * description: The status of the claim's payment + * type: string * enum: * - na * - not_refunded * - refunded * default: na * fulfillment_status: + * description: The claim's fulfillment status * type: string * enum: * - not_fulfilled @@ -170,73 +184,83 @@ export class ClaimOrder extends SoftDeletableEntity { * - requires_action * default: not_fulfilled * claim_items: - * description: "The items that have been claimed" + * description: The items that have been claimed * type: array * items: * $ref: "#/components/schemas/ClaimItem" * additional_items: - * description: "Refers to the new items to be shipped when the claim order has the type `replace`" + * description: Refers to the new items to be shipped when the claim order has the type `replace` * type: array * items: * $ref: "#/components/schemas/LineItem" * order_id: - * description: "The ID of the order that the claim comes from." + * description: The ID of the order that the claim comes from. * type: string * example: order_01G8TJSYT9M6AVS5N4EMNFS1EK * order: * description: An order object. Available if the relation `order` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Order" * return_order: - * description: "A return object. Holds information about the return if the claim is to be returned. Available if the relation 'return_order' is expanded" - * type: object + * description: A return object. Holds information about the return if the claim is to be returned. Available if the relation 'return_order' is expanded + * nullable: true + * $ref: "#/components/schemas/Return" * shipping_address_id: - * description: "The ID of the address that the new items should be shipped to" + * description: The ID of the address that the new items should be shipped to + * nullable: true * type: string * example: addr_01G8ZH853YPY9B94857DY91YGW * shipping_address: * description: Available if the relation `shipping_address` is expanded. + * nullable: true * $ref: "#/components/schemas/Address" * shipping_methods: - * description: "The shipping methods that the claim order will be shipped with." + * description: The shipping methods that the claim order will be shipped with. * type: array * items: * $ref: "#/components/schemas/ShippingMethod" * fulfillments: - * description: "The fulfillments of the new items to be shipped" + * description: The fulfillments of the new items to be shipped * type: array * items: * $ref: "#/components/schemas/Fulfillment" * refund_amount: - * description: "The amount that will be refunded in conjunction with the claim" + * description: The amount that will be refunded in conjunction with the claim + * nullable: true * type: integer * example: 1000 * canceled_at: - * description: "The date with timezone at which the claim was canceled." + * description: The date with timezone at which the claim was canceled. + * nullable: true * type: string * format: date-time * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} * no_notification: - * description: "Flag for describing whether or not notifications related to this should be send." + * description: Flag for describing whether or not notifications related to this should be send. + * nullable: true * type: boolean * example: false * idempotency_key: - * type: string * description: Randomly generated key used to continue the completion of the cart associated with the claim in case of failure. + * nullable: true + * type: string * externalDocs: * url: https://docs.medusajs.com/advanced/backend/payment/overview#idempotency-key * description: Learn more how to use the idempotency key. diff --git a/packages/medusa/src/models/claim-tag.ts b/packages/medusa/src/models/claim-tag.ts index e2e7ae604518..471e77f9b7c5 100644 --- a/packages/medusa/src/models/claim-tag.ts +++ b/packages/medusa/src/models/claim-tag.ts @@ -25,30 +25,37 @@ export class ClaimTag extends SoftDeletableEntity { * description: "Claim Tags are user defined tags that can be assigned to claim items for easy filtering and grouping." * type: object * required: + * - created_at + * - deleted_at + * - id + * - metadata + * - updated_at * - value * properties: * id: - * type: string * description: The claim tag's ID + * type: string * example: ctag_01G8ZCC5Y63B95V6B5SHBZ91S4 * value: - * description: "The value that the claim tag holds" + * description: The value that the claim tag holds * type: string * example: Damaged * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/country.ts b/packages/medusa/src/models/country.ts index 4b6861d09e3b..ddcded302d90 100644 --- a/packages/medusa/src/models/country.ts +++ b/packages/medusa/src/models/country.ts @@ -45,50 +45,54 @@ export class Country { * description: "Country details" * type: object * required: + * - display_name + * - id * - iso_2 * - iso_3 - * - num_code * - name - * - display_name + * - num_code + * - region_id * properties: * id: - * type: string * description: The country's ID + * type: string * example: 109 * iso_2: - * type: string * description: The 2 character ISO code of the country in lower case + * type: string * example: it * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements * description: See a list of codes. * iso_3: - * type: string * description: The 2 character ISO code of the country in lower case + * type: string * example: ita * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3#Officially_assigned_code_elements * description: See a list of codes. * num_code: - * description: "The numerical ISO code for the country." + * description: The numerical ISO code for the country. * type: string * example: 380 * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_3166-1_numeric#Officially_assigned_code_elements * description: See a list of codes. * name: - * description: "The normalized country name in upper case." + * description: The normalized country name in upper case. * type: string * example: ITALY * display_name: - * description: "The country name appropriate for display." + * description: The country name appropriate for display. * type: string * example: Italy * region_id: - * type: string * description: The region ID this country is associated with. + * nullable: true + * type: string * example: reg_01G1G5V26T9H8Y0M4JNE3YGA4G * region: * description: A region object. Available if the relation `region` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Region" */ diff --git a/packages/medusa/src/models/currency.ts b/packages/medusa/src/models/currency.ts index 564a193a4c45..d7ac5dc857ba 100644 --- a/packages/medusa/src/models/currency.ts +++ b/packages/medusa/src/models/currency.ts @@ -27,30 +27,31 @@ export class Currency { * type: object * required: * - code + * - name * - symbol * - symbol_native - * - name * properties: * code: - * description: "The 3 character ISO code for the currency." + * description: The 3 character ISO code for the currency. * type: string * example: usd * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes * description: See a list of codes. * symbol: - * description: "The symbol used to indicate the currency." + * description: The symbol used to indicate the currency. * type: string * example: $ * symbol_native: - * description: "The native symbol used to indicate the currency." + * description: The native symbol used to indicate the currency. * type: string * example: $ * name: - * description: "The written name of the currency" + * description: The written name of the currency * type: string * example: US Dollar * includes_tax: * description: "[EXPERIMENTAL] Does the currency prices include tax" * type: boolean + * default: false */ diff --git a/packages/medusa/src/models/custom-shipping-option.ts b/packages/medusa/src/models/custom-shipping-option.ts index b5c6d3ae7706..9e7e3bb5da98 100644 --- a/packages/medusa/src/models/custom-shipping-option.ts +++ b/packages/medusa/src/models/custom-shipping-option.ts @@ -51,48 +51,56 @@ export class CustomShippingOption extends SoftDeletableEntity { * description: "Custom Shipping Options are 'overriden' Shipping Options. Store managers can attach a Custom Shipping Option to a cart in order to set a custom price for a particular Shipping Option" * type: object * required: + * - cart_id + * - created_at + * - deleted_at + * - id + * - metadata * - price * - shipping_option_id + * - updated_at * properties: * id: - * type: string * description: The custom shipping option's ID + * type: string * example: cso_01G8X99XNB77DMFBJFWX6DN9V9 * price: - * description: "The custom price set that will override the shipping option's original price" + * description: The custom price set that will override the shipping option's original price * type: integer * example: 1000 * shipping_option_id: - * description: "The ID of the Shipping Option that the custom shipping option overrides" + * description: The ID of the Shipping Option that the custom shipping option overrides * type: string * example: so_01G1G5V27GYX4QXNARRQCW1N8T * shipping_option: * description: A shipping option object. Available if the relation `shipping_option` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/ShippingOption" * cart_id: - * description: "The ID of the Cart that the custom shipping option is attached to" + * description: The ID of the Cart that the custom shipping option is attached to + * nullable: true * type: string * example: cart_01G8ZH853Y6TFXWPG5EYE81X63 * cart: * description: A cart object. Available if the relation `cart` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Cart" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} - * includes_tax: - * description: "[EXPERIMENTAL] Indicates if the custom shipping option price include tax" - * type: boolean */ diff --git a/packages/medusa/src/models/customer-group.ts b/packages/medusa/src/models/customer-group.ts index 7a197b78f2f2..d41a3a405be4 100644 --- a/packages/medusa/src/models/customer-group.ts +++ b/packages/medusa/src/models/customer-group.ts @@ -37,41 +37,47 @@ export class CustomerGroup extends SoftDeletableEntity { * description: "Represents a customer group" * type: object * required: + * - created_at + * - deleted_at + * - id + * - metadata * - name + * - updated_at * properties: * id: - * type: string * description: The customer group's ID + * type: string * example: cgrp_01G8ZH853Y6TFXWPG5EYE81X63 * name: - * type: string * description: The name of the customer group + * type: string * example: VIP * customers: - * type: array * description: The customers that belong to the customer group. Available if the relation `customers` is expanded. + * type: array * items: - * type: object - * description: A customer object. + * $ref: "#/components/schemas/Customer" * price_lists: - * type: array * description: The price lists that are associated with the customer group. Available if the relation `price_lists` is expanded. + * type: array * items: * $ref: "#/components/schemas/PriceList" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/customer.ts b/packages/medusa/src/models/customer.ts index b64147a7e166..593c50f6609a 100644 --- a/packages/medusa/src/models/customer.ts +++ b/packages/medusa/src/models/customer.ts @@ -85,30 +85,44 @@ export class Customer extends SoftDeletableEntity { * description: "Represents a customer" * type: object * required: + * - billing_address_id + * - created_at + * - deleted_at * - email + * - first_name + * - has_account + * - id + * - last_name + * - metadata + * - phone + * - updated_at * properties: * id: - * type: string * description: The customer's ID + * type: string * example: cus_01G2SG30J8C85S4A5CHM2S1NS2 * email: - * type: string * description: The customer's email + * type: string * format: email * first_name: - * type: string * description: The customer's first name + * nullable: true + * type: string * example: Arno * last_name: - * type: string * description: The customer's last name + * nullable: true + * type: string * example: Willms * billing_address_id: - * type: string * description: The customer's billing address ID + * nullable: true + * type: string * example: addr_01G8ZH853YPY9B94857DY91YGW * billing_address: * description: Available if the relation `billing_address` is expanded. + * nullable: true * $ref: "#/components/schemas/Address" * shipping_addresses: * description: Available if the relation `shipping_addresses` is expanded. @@ -116,38 +130,40 @@ export class Customer extends SoftDeletableEntity { * items: * $ref: "#/components/schemas/Address" * phone: - * type: string * description: The customer's phone number + * nullable: true + * type: string * example: 16128234334802 * has_account: - * type: boolean * description: Whether the customer has an account or not + * type: boolean * default: false * orders: * description: Available if the relation `orders` is expanded. * type: array * items: - * type: object - * description: An order object. + * $ref: "#/components/schemas/Order" * groups: * description: The customer groups the customer belongs to. Available if the relation `groups` is expanded. * type: array * items: * $ref: "#/components/schemas/CustomerGroup" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition-customer-group.ts b/packages/medusa/src/models/discount-condition-customer-group.ts index b0e23b260946..0874e3f66721 100644 --- a/packages/medusa/src/models/discount-condition-customer-group.ts +++ b/packages/medusa/src/models/discount-condition-customer-group.ts @@ -43,33 +43,39 @@ export class DiscountConditionCustomerGroup { * description: "Associates a discount condition with a customer group" * type: object * required: - * - customer_group_id * - condition_id + * - created_at + * - customer_group_id + * - metadata + * - updated_at * properties: * customer_group_id: - * description: "The ID of the Product Tag" + * description: The ID of the Product Tag * type: string * example: cgrp_01G8ZH853Y6TFXWPG5EYE81X63 * condition_id: - * description: "The ID of the Discount Condition" + * description: The ID of the Discount Condition * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * customer_group: * description: Available if the relation `customer_group` is expanded. + * nullable: true * $ref: "#/components/schemas/CustomerGroup" * discount_condition: * description: Available if the relation `discount_condition` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition-product-collection.ts b/packages/medusa/src/models/discount-condition-product-collection.ts index ad1f7c72ff75..fe069ba33dea 100644 --- a/packages/medusa/src/models/discount-condition-product-collection.ts +++ b/packages/medusa/src/models/discount-condition-product-collection.ts @@ -43,33 +43,39 @@ export class DiscountConditionProductCollection { * description: "Associates a discount condition with a product collection" * type: object * required: - * - product_collection_id * - condition_id + * - created_at + * - metadata + * - product_collection_id + * - updated_at * properties: * product_collection_id: - * description: "The ID of the Product Collection" + * description: The ID of the Product Collection * type: string * example: pcol_01F0YESBFAZ0DV6V831JXWH0BG * condition_id: - * description: "The ID of the Discount Condition" + * description: The ID of the Discount Condition * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * product_collection: * description: Available if the relation `product_collection` is expanded. + * nullable: true * $ref: "#/components/schemas/ProductCollection" * discount_condition: * description: Available if the relation `discount_condition` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition-product-tag.ts b/packages/medusa/src/models/discount-condition-product-tag.ts index 87af09659b30..c09065e54fe2 100644 --- a/packages/medusa/src/models/discount-condition-product-tag.ts +++ b/packages/medusa/src/models/discount-condition-product-tag.ts @@ -43,33 +43,39 @@ export class DiscountConditionProductTag { * description: "Associates a discount condition with a product tag" * type: object * required: - * - product_tag_id * - condition_id + * - created_at + * - metadata + * - product_tag_id + * - updated_at * properties: * product_tag_id: - * description: "The ID of the Product Tag" + * description: The ID of the Product Tag * type: string * example: ptag_01F0YESHPZYY3H4SJ3A5918SBN * condition_id: - * description: "The ID of the Discount Condition" + * description: The ID of the Discount Condition * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * product_tag: * description: Available if the relation `product_tag` is expanded. + * nullable: true * $ref: "#/components/schemas/ProductTag" * discount_condition: * description: Available if the relation `discount_condition` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition-product-type.ts b/packages/medusa/src/models/discount-condition-product-type.ts index 57c5ebdb932d..2bbc438859f3 100644 --- a/packages/medusa/src/models/discount-condition-product-type.ts +++ b/packages/medusa/src/models/discount-condition-product-type.ts @@ -43,33 +43,39 @@ export class DiscountConditionProductType { * description: "Associates a discount condition with a product type" * type: object * required: - * - product_type_id * - condition_id + * - created_at + * - metadata + * - product_type_id + * - updated_at * properties: * product_type_id: - * description: "The ID of the Product Tag" + * description: The ID of the Product Tag * type: string * example: ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A * condition_id: - * description: "The ID of the Discount Condition" + * description: The ID of the Discount Condition * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * product_type: * description: Available if the relation `product_type` is expanded. + * nullable: true * $ref: "#/components/schemas/ProductType" * discount_condition: * description: Available if the relation `discount_condition` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition-product.ts b/packages/medusa/src/models/discount-condition-product.ts index 579874c323b4..89d929b753d1 100644 --- a/packages/medusa/src/models/discount-condition-product.ts +++ b/packages/medusa/src/models/discount-condition-product.ts @@ -43,33 +43,39 @@ export class DiscountConditionProduct { * description: "Associates a discount condition with a product" * type: object * required: - * - product_id * - condition_id + * - created_at + * - metadata + * - product_id + * - updated_at * properties: * product_id: - * description: "The ID of the Product Tag" + * description: The ID of the Product Tag * type: string * example: prod_01G1G5V2MBA328390B5AXJ610F * condition_id: - * description: "The ID of the Discount Condition" + * description: The ID of the Discount Condition * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * product: * description: Available if the relation `product` is expanded. + * nullable: true * $ref: "#/components/schemas/Product" * discount_condition: * description: Available if the relation `discount_condition` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-condition.ts b/packages/medusa/src/models/discount-condition.ts index 21f066a48216..4ff8ac243488 100644 --- a/packages/medusa/src/models/discount-condition.ts +++ b/packages/medusa/src/models/discount-condition.ts @@ -141,13 +141,18 @@ export class DiscountCondition extends SoftDeletableEntity { * description: "Holds rule conditions for when a discount is applicable" * type: object * required: - * - type - * - operator + * - created_at + * - deleted_at * - discount_rule_id + * - id + * - metadata + * - operator + * - type + * - updated_at * properties: * id: - * type: string * description: The discount condition's ID + * type: string * example: discon_01G8X9A7ESKAJXG2H0E6F1MW7A * type: * description: "The type of the Condition" @@ -165,56 +170,54 @@ export class DiscountCondition extends SoftDeletableEntity { * - in * - not_in * discount_rule_id: - * type: string * description: The ID of the discount rule associated with the condition + * type: string * example: dru_01F0YESMVK96HVX7N419E3CJ7C * discount_rule: * description: Available if the relation `discount_rule` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountRule" * products: * description: products associated with this condition if type = products. Available if the relation `products` is expanded. * type: array * items: - * type: object - * description: A product object. + * $ref: "#/components/schemas/Product" * product_types: - * description: product types associated with this condition if type = product_types. Available if the relation `product_types` is expanded. + * description: Product types associated with this condition if type = product_types. Available if the relation `product_types` is expanded. * type: array * items: - * type: object - * description: A product type object. + * $ref: "#/components/schemas/ProductType" * product_tags: - * description: product tags associated with this condition if type = product_tags. Available if the relation `product_tags` is expanded. + * description: Product tags associated with this condition if type = product_tags. Available if the relation `product_tags` is expanded. * type: array * items: - * type: object - * description: A product tag object. + * $ref: "#/components/schemas/ProductTag" * product_collections: - * description: product collections associated with this condition if type = product_collections. Available if the relation `product_collections` is expanded. + * description: Product collections associated with this condition if type = product_collections. Available if the relation `product_collections` is expanded. * type: array * items: - * type: object - * description: A product collection object. + * $ref: "#/components/schemas/ProductCollection" * customer_groups: - * description: customer groups associated with this condition if type = customer_groups. Available if the relation `customer_groups` is expanded. + * description: Customer groups associated with this condition if type = customer_groups. Available if the relation `customer_groups` is expanded. * type: array * items: - * type: object - * description: A customer group object. + * $ref: "#/components/schemas/CustomerGroup" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount-rule.ts b/packages/medusa/src/models/discount-rule.ts index 314db3839c9d..326838abdaae 100644 --- a/packages/medusa/src/models/discount-rule.ts +++ b/packages/medusa/src/models/discount-rule.ts @@ -55,15 +55,22 @@ export class DiscountRule extends SoftDeletableEntity { * description: "Holds the rules that governs how a Discount is calculated when applied to a Cart." * type: object * required: + * - allocation + * - created_at + * - deleted_at + * - description + * - id + * - metadata * - type + * - updated_at * - value * properties: * id: - * type: string * description: The discount rule's ID + * type: string * example: dru_01F0YESMVK96HVX7N419E3CJ7C * type: - * 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." + * 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. * type: string * enum: * - fixed @@ -71,15 +78,17 @@ export class DiscountRule extends SoftDeletableEntity { * - free_shipping * example: percentage * description: - * description: "A short description of the discount" + * description: A short description of the discount + * nullable: true * type: string * example: 10 Percent * value: - * description: "The value that the discount represents; this will depend on the type of the discount" + * description: The value that the discount represents; this will depend on the type of the discount * type: integer * example: 10 * allocation: - * description: "The scope that the discount should apply to." + * description: The scope that the discount should apply to. + * nullable: true * type: string * enum: * - total @@ -89,22 +98,23 @@ export class DiscountRule extends SoftDeletableEntity { * description: A set of conditions that can be used to limit when the discount can be used. Available if the relation `conditions` is expanded. * type: array * items: - * type: object - * description: A discount condition object. + * $ref: "#/components/schemas/DiscountCondition" * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/discount.ts b/packages/medusa/src/models/discount.ts index 1898c1e8e522..a4eec23526b6 100644 --- a/packages/medusa/src/models/discount.ts +++ b/packages/medusa/src/models/discount.ts @@ -95,79 +95,100 @@ export class Discount extends SoftDeletableEntity { * type: object * required: * - code + * - created_at + * - deleted_at + * - ends_at + * - id + * - is_disabled * - is_dynamic + * - metadata + * - parent_discount_id + * - rule_id + * - starts_at + * - updated_at + * - usage_count + * - usage_limit + * - valid_duration * properties: * id: - * type: string * description: The discount's ID + * type: string * example: disc_01F0YESMW10MGHWJKZSDDMN0VN * code: - * description: "A unique code for the discount - this will be used by the customer to apply the discount" + * description: A unique code for the discount - this will be used by the customer to apply the discount * type: string * example: 10DISC * is_dynamic: - * description: "A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts" + * description: A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts * type: boolean * example: false * rule_id: + * description: The Discount Rule that governs the behaviour of the Discount + * nullable: true * type: string - * description: "The Discount Rule that governs the behaviour of the Discount" * example: dru_01F0YESMVK96HVX7N419E3CJ7C * rule: * description: Available if the relation `rule` is expanded. + * nullable: true * $ref: "#/components/schemas/DiscountRule" * is_disabled: - * description: "Whether the Discount has been disabled. Disabled discounts cannot be applied to carts" + * description: Whether the Discount has been disabled. Disabled discounts cannot be applied to carts * type: boolean * example: false * parent_discount_id: + * description: The Discount that the discount was created from. This will always be a dynamic discount + * nullable: true * type: string - * description: "The Discount that the discount was created from. This will always be a dynamic discount" * example: disc_01G8ZH853YPY9B94857DY91YGW * parent_discount: * description: Available if the relation `parent_discount` is expanded. + * nullable: true * $ref: "#/components/schemas/Discount" * starts_at: - * description: "The time at which the discount can be used." + * description: The time at which the discount can be used. * type: string * format: date-time * ends_at: - * description: "The time at which the discount can no longer be used." + * description: The time at which the discount can no longer be used. + * nullable: true * type: string * format: date-time * valid_duration: - * type: string * description: Duration the discount runs between + * nullable: true + * type: string * example: P3Y6M4DT12H30M5S * regions: * description: The Regions in which the Discount can be used. Available if the relation `regions` is expanded. * type: array * items: - * type: object - * description: A region object. + * $ref: "#/components/schemas/Region" * usage_limit: - * description: "The maximum number of times that a discount can be used." + * description: The maximum number of times that a discount can be used. + * nullable: true * type: integer * example: 100 * usage_count: - * description: "The number of times a discount has been used." + * description: The number of times a discount has been used. * type: integer * example: 50 * default: 0 * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." * format: date-time * deleted_at: + * description: The date with timezone at which the resource was deleted. + * nullable: true * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */ diff --git a/packages/medusa/src/models/draft-order.ts b/packages/medusa/src/models/draft-order.ts index cf5ee6911a35..106027d60633 100644 --- a/packages/medusa/src/models/draft-order.ts +++ b/packages/medusa/src/models/draft-order.ts @@ -84,68 +84,86 @@ export class DraftOrder extends BaseEntity { * title: "DraftOrder" * description: "Represents a draft order" * type: object + * required: + * - canceled_at + * - cart_id + * - completed_at + * - created_at + * - display_id + * - id + * - idempotency_key + * - metadata + * - no_notification_order + * - order_id + * - status + * - updated_at * properties: * id: - * type: string * description: The draft order's ID + * type: string * example: dorder_01G8TJFKBG38YYFQ035MSVG03C * status: - * type: string * description: The status of the draft order + * type: string * enum: * - open * - completed * default: open * display_id: - * type: string * description: The draft order's display ID + * type: string * example: 2 * cart_id: + * description: The ID of the cart associated with the draft order. + * nullable: true * type: string - * description: "The ID of the cart associated with the draft order." * example: cart_01G8ZH853Y6TFXWPG5EYE81X63 * cart: * description: A cart object. Available if the relation `cart` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Cart" * order_id: + * description: The ID of the order associated with the draft order. + * nullable: true * type: string - * description: "The ID of the order associated with the draft order." * example: order_01G8TJSYT9M6AVS5N4EMNFS1EK * order: * description: An order object. Available if the relation `order` is expanded. - * type: object + * nullable: true + * $ref: "#/components/schemas/Order" * canceled_at: - * type: string * description: The date the draft order was canceled at. + * nullable: true + * type: string * format: date-time * completed_at: - * type: string * description: The date the draft order was completed at. + * nullable: true + * type: string * format: date-time * no_notification_order: - * type: boolean * description: Whether to send the customer notifications regarding order updates. + * nullable: true + * type: boolean * example: false * idempotency_key: - * type: string * description: Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure. + * nullable: true + * type: string * externalDocs: * url: https://docs.medusajs.com/advanced/backend/payment/overview#idempotency-key * description: Learn more how to use the idempotency key. * created_at: + * description: The date with timezone at which the resource was created. * type: string - * description: "The date with timezone at which the resource was created." * format: date-time * updated_at: + * description: The date with timezone at which the resource was updated. * type: string - * description: "The date with timezone at which the resource was updated." - * format: date-time - * deleted_at: - * type: string - * description: "The date with timezone at which the resource was deleted." * format: date-time * metadata: - * type: object * description: An optional key-value map with additional details + * nullable: true + * type: object * example: {car: "white"} */