chore(oas): [19/n] improve oas schemas (#9317)

- Improve OAS schemas [19/n]
- docs-generator: combine `Date | string` type to just `Date`.
This commit is contained in:
Shahed Nasser
2024-09-26 16:44:57 +03:00
committed by GitHub
parent 5390c8a845
commit af34bf6c0c
18 changed files with 2472 additions and 171 deletions

View File

@@ -1,8 +1,301 @@
/**
* @schema Order
* type: object
* description: The transaction's order.
* description: The order change's order.
* x-schemaName: Order
* required:
* - id
* - version
* - status
* - currency_code
* - created_at
* - updated_at
* - original_item_total
* - original_item_subtotal
* - original_item_tax_total
* - item_total
* - item_subtotal
* - item_tax_total
* - original_total
* - original_subtotal
* - original_tax_total
* - total
* - subtotal
* - tax_total
* - discount_subtotal
* - discount_total
* - discount_tax_total
* - gift_card_total
* - gift_card_tax_total
* - shipping_total
* - shipping_subtotal
* - shipping_tax_total
* - original_shipping_total
* - original_shipping_subtotal
* - original_shipping_tax_total
* - raw_original_item_total
* - raw_original_item_subtotal
* - raw_original_item_tax_total
* - raw_item_total
* - raw_item_subtotal
* - raw_item_tax_total
* - raw_original_total
* - raw_original_subtotal
* - raw_original_tax_total
* - raw_total
* - raw_subtotal
* - raw_tax_total
* - raw_discount_total
* - raw_discount_tax_total
* - raw_gift_card_total
* - raw_gift_card_tax_total
* - raw_shipping_total
* - raw_shipping_subtotal
* - raw_shipping_tax_total
* - raw_original_shipping_total
* - raw_original_shipping_subtotal
* - raw_original_shipping_tax_total
* properties:
* id:
* type: string
* title: id
* description: The order's ID.
* version:
* type: number
* title: version
* description: The order's version.
* order_change:
* $ref: "#/components/schemas/OrderChange"
* status:
* type: string
* description: The order's status.
* enum:
* - canceled
* - requires_action
* - pending
* - completed
* - draft
* - archived
* region_id:
* type: string
* title: region_id
* description: The ID of the region the order belongs to.
* customer_id:
* type: string
* title: customer_id
* description: The ID of the customer that placed the order.
* sales_channel_id:
* type: string
* title: sales_channel_id
* description: The ID of the sales channel the order was placed in.
* email:
* type: string
* title: email
* description: The email of the customer that placed the order.
* format: email
* currency_code:
* type: string
* title: currency_code
* description: The order's currency code.
* example: usd
* shipping_address:
* $ref: "#/components/schemas/OrderAddress"
* billing_address:
* $ref: "#/components/schemas/OrderAddress"
* items:
* type: array
* description: The order's items.
* items:
* $ref: "#/components/schemas/OrderLineItem"
* shipping_methods:
* type: array
* description: The order's shipping methods.
* items:
* $ref: "#/components/schemas/OrderShippingMethod"
* transactions:
* type: array
* description: The order's transactions.
* items:
* $ref: "#/components/schemas/OrderTransaction"
* summary:
* type: object
* description: The order's summary.
* metadata:
* type: object
* description: The order's metadata, can hold custom key-value pairs.
* canceled_at:
* type: string
* format: date-time
* title: canceled_at
* description: The date the order was canceled.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the order was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the order was updated.
* original_item_total:
* type: number
* title: original_item_total
* description: The order items' total including taxes, excluding promotions.
* original_item_subtotal:
* type: number
* title: original_item_subtotal
* description: The order items' total excluding taxes, including promotions.
* original_item_tax_total:
* type: number
* title: original_item_tax_total
* description: The taxes total for order items, excluding promotions.
* item_total:
* type: number
* title: item_total
* description: The order items' total including taxes and promotions.
* item_subtotal:
* type: number
* title: item_subtotal
* description: The order items' total excluding taxes, including promotions.
* item_tax_total:
* type: number
* title: item_tax_total
* description: The tax total of the order items including promotions.
* original_total:
* type: number
* title: original_total
* description: The order's total including taxes, excluding promotions.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The order's total excluding taxes, including promotions.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The tax total of the order excluding promotions.
* total:
* type: number
* title: total
* description: The order's total including taxes and promotions.
* subtotal:
* type: number
* title: subtotal
* description: The order's subtotal excluding taxes, including promotions.
* tax_total:
* type: number
* title: tax_total
* description: The tax total of the order including promotions.
* discount_subtotal:
* type: number
* title: discount_subtotal
* description: The total discount excluding taxes.
* discount_total:
* type: number
* title: discount_total
* description: The total discount including taxes.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The tax total applied on the discount.
* gift_card_total:
* type: number
* title: gift_card_total
* description: The order's gift card total.
* gift_card_tax_total:
* type: number
* title: gift_card_tax_total
* description: The order's gift card tax total.
* shipping_total:
* type: number
* title: shipping_total
* description: The order's shipping total including taxes and promotions.
* shipping_subtotal:
* type: number
* title: shipping_subtotal
* description: The order's shipping total excluding taxes, including promotions.
* shipping_tax_total:
* type: number
* title: shipping_tax_total
* description: The total taxes of the order's shipping including taxes.
* original_shipping_total:
* type: number
* title: original_shipping_total
* description: The order's shipping total including taxes, excluding promotions.
* original_shipping_subtotal:
* type: number
* title: original_shipping_subtotal
* description: The order's shipping total excluding taxes, including promotions.
* original_shipping_tax_total:
* type: number
* title: original_shipping_tax_total
* description: The total taxes of the order's shipping excluding promotions.
* raw_original_item_total:
* type: object
* description: The order's raw original item total.
* raw_original_item_subtotal:
* type: object
* description: The order's raw original item subtotal.
* raw_original_item_tax_total:
* type: object
* description: The order's raw original item tax total.
* raw_item_total:
* type: object
* description: The order's raw item total.
* raw_item_subtotal:
* type: object
* description: The order's raw item subtotal.
* raw_item_tax_total:
* type: object
* description: The order's raw item tax total.
* raw_original_total:
* type: object
* description: The order's raw original total.
* raw_original_subtotal:
* type: object
* description: The order's raw original subtotal.
* raw_original_tax_total:
* type: object
* description: The order's raw original tax total.
* raw_total:
* type: object
* description: The order's raw total.
* raw_subtotal:
* type: object
* description: The order's raw subtotal.
* raw_tax_total:
* type: object
* description: The order's raw tax total.
* raw_discount_total:
* type: object
* description: The order's raw discount total.
* raw_discount_tax_total:
* type: object
* description: The order's raw discount tax total.
* raw_gift_card_total:
* type: object
* description: The order's raw gift card total.
* raw_gift_card_tax_total:
* type: object
* description: The order's raw gift card tax total.
* raw_shipping_total:
* type: object
* description: The order's raw shipping total.
* raw_shipping_subtotal:
* type: object
* description: The order's raw shipping subtotal.
* raw_shipping_tax_total:
* type: object
* description: The order's raw shipping tax total.
* raw_original_shipping_total:
* type: object
* description: The order's raw original shipping total.
* raw_original_shipping_subtotal:
* type: object
* description: The order's raw original shipping subtotal.
* raw_original_shipping_tax_total:
* type: object
* description: The order's raw original shipping tax total.
*
*/

View File

@@ -1,7 +1,7 @@
/**
* @schema OrderAddress
* type: object
* description: The order preview's billing address.
* description: The address's details.
* x-schemaName: OrderAddress
* required:
* - id
@@ -11,64 +11,65 @@
* id:
* type: string
* title: id
* description: The billing address's ID.
* description: The address's ID.
* customer_id:
* type: string
* title: customer_id
* description: The billing address's customer id.
* description: The ID of the customer the address belongs to.
* first_name:
* type: string
* title: first_name
* description: The billing address's first name.
* description: The address's first name.
* last_name:
* type: string
* title: last_name
* description: The billing address's last name.
* description: The address's last name.
* phone:
* type: string
* title: phone
* description: The billing address's phone.
* description: The address's phone.
* company:
* type: string
* title: company
* description: The billing address's company.
* description: The address's company.
* address_1:
* type: string
* title: address_1
* description: The billing address's address 1.
* description: The address's first line.
* address_2:
* type: string
* title: address_2
* description: The billing address's address 2.
* description: The address's second line.
* city:
* type: string
* title: city
* description: The billing address's city.
* description: The address's city.
* country_code:
* type: string
* title: country_code
* description: The billing address's country code.
* description: The address's country code.
* example: us
* province:
* type: string
* title: province
* description: The billing address's province.
* description: The address's province.
* postal_code:
* type: string
* title: postal_code
* description: The billing address's postal code.
* description: The address's postal code.
* metadata:
* type: object
* description: The billing address's metadata.
* description: The address's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The billing address's created at.
* description: The date the address was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The billing address's updated at.
* description: The date the address was updated.
*
*/

View File

@@ -1,7 +1,7 @@
/**
* @schema OrderChange
* type: object
* description: The order preview's order change.
* description: The order change's details.
* x-schemaName: OrderChange
* required:
* - id
@@ -36,10 +36,10 @@
* version:
* type: number
* title: version
* description: The order change's version.
* description: The order change's version. This will be the order's version when the change is applied.
* change_type:
* type: string
* description: The order change's change type.
* description: The order change's type.
* enum:
* - return
* - exchange
@@ -48,19 +48,19 @@
* order_id:
* type: string
* title: order_id
* description: The order change's order id.
* description: The ID of the order this change applies on.
* return_id:
* type: string
* title: return_id
* description: The order change's return id.
* description: The ID of the associated return.
* exchange_id:
* type: string
* title: exchange_id
* description: The order change's exchange id.
* description: The ID of the associated exchange.
* claim_id:
* type: string
* title: claim_id
* description: The order change's claim id.
* description: The ID of the associated claim.
* order:
* $ref: "#/components/schemas/Order"
* return_order:
@@ -76,77 +76,66 @@
* $ref: "#/components/schemas/OrderChangeAction"
* status:
* type: string
* title: status
* description: The order change's status.
* enum:
* - canceled
* - requested
* - pending
* - confirmed
* - declined
* requested_by:
* type: string
* title: requested_by
* description: The order change's requested by.
* description: The ID of the user that requested the change.
* requested_at:
* oneOf:
* - type: string
* title: requested_at
* description: The order change's requested at.
* - type: string
* title: requested_at
* description: The order change's requested at.
* format: date-time
* type: string
* title: requested_at
* description: The date the order change was requested.
* format: date-time
* confirmed_by:
* type: string
* title: confirmed_by
* description: The order change's confirmed by.
* description: The ID of the user that confirmed the order change.
* confirmed_at:
* oneOf:
* - type: string
* title: confirmed_at
* description: The order change's confirmed at.
* - type: string
* title: confirmed_at
* description: The order change's confirmed at.
* format: date-time
* type: string
* title: confirmed_at
* description: The date the order change was confirmed.
* format: date-time
* declined_by:
* type: string
* title: declined_by
* description: The order change's declined by.
* description: The ID of the user that declined the order change.
* declined_reason:
* type: string
* title: declined_reason
* description: The order change's declined reason.
* description: The reason the order change was declined.
* metadata:
* type: object
* description: The order change's metadata.
* description: The order change's metadata, can hold custom key-value pairs.
* declined_at:
* oneOf:
* - type: string
* title: declined_at
* description: The order change's declined at.
* - type: string
* title: declined_at
* description: The order change's declined at.
* format: date-time
* type: string
* title: declined_at
* description: The date the order change was declined.
* format: date-time
* canceled_by:
* type: string
* title: canceled_by
* description: The order change's canceled by.
* description: The ID of the user that canceled the order change.
* canceled_at:
* oneOf:
* - type: string
* title: canceled_at
* description: The order change's canceled at.
* - type: string
* title: canceled_at
* description: The order change's canceled at.
* format: date-time
* type: string
* title: canceled_at
* description: The date the order change was canceled.
* format: date-time
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The order change's created at.
* description: The date the order change was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The order change's updated at.
* description: The date the order change was updated.
*
*/

View File

@@ -1,8 +1,105 @@
/**
* @schema OrderChangeAction
* type: object
* description: The action's actions.
* description: The order change action's details.
* x-schemaName: OrderChangeAction
* required:
* - id
* - order_change_id
* - order_change
* - order_id
* - return_id
* - claim_id
* - exchange_id
* - order
* - reference
* - reference_id
* - action
* - details
* - internal_note
* - created_at
* - updated_at
* properties:
* id:
* type: string
* title: id
* description: The action's ID.
* order_change_id:
* type: string
* title: order_change_id
* description: The ID of the order change that the action belongs to.
* order_change:
* $ref: "#/components/schemas/OrderChange"
* order_id:
* type: string
* title: order_id
* description: The ID of the order the associated change is for.
* return_id:
* type: string
* title: return_id
* description: The ID of the associated return.
* claim_id:
* type: string
* title: claim_id
* description: The ID of the associated claim.
* exchange_id:
* type: string
* title: exchange_id
* description: The ID of the associated exchange.
* order:
* $ref: "#/components/schemas/Order"
* reference:
* type: string
* title: reference
* description: The name of the table this action applies on.
* enum:
* - claim
* - exchange
* - return
* - order_shipping_method
* reference_id:
* type: string
* title: reference_id
* description: The ID of the record in the referenced table.
* action:
* type: string
* description: The applied action.
* enum:
* - CANCEL_RETURN_ITEM
* - FULFILL_ITEM
* - DELIVER_ITEM
* - CANCEL_ITEM_FULFILLMENT
* - ITEM_ADD
* - ITEM_REMOVE
* - ITEM_UPDATE
* - RECEIVE_DAMAGED_RETURN_ITEM
* - RECEIVE_RETURN_ITEM
* - RETURN_ITEM
* - SHIPPING_ADD
* - SHIPPING_REMOVE
* - SHIP_ITEM
* - WRITE_OFF_ITEM
* - REINSTATE_ITEM
* details:
* type: object
* description: The action's details.
* example:
* reference_id: 123
* quantity: 1
* internal_note:
* type: string
* title: internal_note
* description: A note that's viewed only by admin users.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the action was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the action was updated.
*
*/

View File

@@ -3,6 +3,259 @@
* type: object
* description: The order change's claim.
* x-schemaName: OrderClaim
* required:
* - order_id
* - claim_items
* - additional_items
* - currency_code
* - id
* - region_id
* - customer_id
* - sales_channel_id
* - email
* - shipping_methods
* - payment_status
* - fulfillment_status
* - summary
* - metadata
* - created_at
* - updated_at
* - original_item_total
* - original_item_subtotal
* - original_item_tax_total
* - item_total
* - item_subtotal
* - item_tax_total
* - original_total
* - original_subtotal
* - original_tax_total
* - total
* - subtotal
* - tax_total
* - discount_total
* - discount_tax_total
* - gift_card_total
* - gift_card_tax_total
* - shipping_total
* - shipping_subtotal
* - shipping_tax_total
* - original_shipping_total
* - original_shipping_subtotal
* - original_shipping_tax_total
* properties:
* id:
* type: string
* title: id
* description: The claim's ID.
* order_id:
* type: string
* title: order_id
* description: The ID of the order associated with the claim.
* claim_items:
* type: array
* description: The order items targetted by the claim.
* items:
* $ref: "#/components/schemas/BaseClaimItem"
* additional_items:
* type: array
* description: The outbound or new items of the claim.
* items:
* $ref: "#/components/schemas/BaseClaimItem"
* return:
* $ref: "#/components/schemas/Return"
* return_id:
* type: string
* title: return_id
* description: The ID of the associated return.
* no_notification:
* type: boolean
* title: no_notification
* description: Whether the customer should be notified about changes in the claim.
* refund_amount:
* type: number
* title: refund_amount
* description: The amount to be refunded.
* currency_code:
* type: string
* title: currency_code
* description: The claim's currency code.
* region_id:
* type: string
* title: region_id
* description: The ID of the region associated with the claim.
* customer_id:
* type: string
* title: customer_id
* description: The ID of the customer associated with the claim's order.
* sales_channel_id:
* type: string
* title: sales_channel_id
* description: The ID of the sales channel the claim's order is created in.
* email:
* type: string
* title: email
* description: The email associated with the claim's order.
* format: email
* display_id:
* type: number
* title: display_id
* description: The claim's display ID.
* shipping_address:
* $ref: "#/components/schemas/BaseOrderAddress"
* billing_address:
* $ref: "#/components/schemas/BaseOrderAddress"
* shipping_methods:
* type: array
* description: The claim's shipping methods.
* items:
* $ref: "#/components/schemas/BaseOrderShippingMethod"
* payment_collections:
* type: array
* description: The claim's payment collections.
* items:
* $ref: "#/components/schemas/BasePaymentCollection"
* payment_status:
* type: string
* description: The claim's payment status.
* enum:
* - canceled
* - not_paid
* - awaiting
* - authorized
* - partially_authorized
* - captured
* - partially_captured
* - partially_refunded
* - refunded
* - requires_action
* fulfillments:
* type: array
* description: The claim's fulfillments.
* items:
* $ref: "#/components/schemas/BaseOrderFulfillment"
* fulfillment_status:
* type: string
* description: The claim's fulfillment status.
* enum:
* - canceled
* - not_fulfilled
* - partially_fulfilled
* - fulfilled
* - partially_shipped
* - shipped
* - partially_delivered
* - delivered
* transactions:
* type: array
* description: The claim's transactions.
* externalDocs:
* url: https://docs.medusajs.com/v2/resources/commerce-modules/order/transactions
* description: Learn more about transactions of orders and associated models.
* items:
* $ref: "#/components/schemas/BaseOrderTransaction"
* summary:
* $ref: "#/components/schemas/BaseOrderSummary"
* metadata:
* type: object
* description: The claim's metadata, used to store custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The claim's creation date.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The claim's update date.
* original_item_total:
* type: number
* title: original_item_total
* description: The total of the original items in the associated order.
* original_item_subtotal:
* type: number
* title: original_item_subtotal
* description: The subtotal of the original items in the associated order.
* original_item_tax_total:
* type: number
* title: original_item_tax_total
* description: The tax total of the original items in the associated order.
* item_total:
* type: number
* title: item_total
* description: The total of the claim's items.
* item_subtotal:
* type: number
* title: item_subtotal
* description: The subtotal of the claim's items.
* item_tax_total:
* type: number
* title: item_tax_total
* description: The tax total of the claim's items.
* original_total:
* type: number
* title: original_total
* description: The associated order's original total.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The associated order's original subtotal.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The associated order's original tax total.
* total:
* type: number
* title: total
* description: The associated order's total.
* subtotal:
* type: number
* title: subtotal
* description: The claim's subtotal.
* tax_total:
* type: number
* title: tax_total
* description: The claim's tax total.
* discount_total:
* type: number
* title: discount_total
* description: The claim's discount total.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The claim's discount tax total.
* gift_card_total:
* type: number
* title: gift_card_total
* description: The claim's gift card total.
* gift_card_tax_total:
* type: number
* title: gift_card_tax_total
* description: The claim's gift card tax total.
* shipping_total:
* type: number
* title: shipping_total
* description: The claim's shipping total.
* shipping_subtotal:
* type: number
* title: shipping_subtotal
* description: The claim's shipping subtotal.
* shipping_tax_total:
* type: number
* title: shipping_tax_total
* description: The claim's shipping tax total.
* original_shipping_total:
* type: number
* title: original_shipping_total
* description: The associated order's original shipping total.
* original_shipping_subtotal:
* type: number
* title: original_shipping_subtotal
* description: The associated order's original shipping subtotal.
* original_shipping_tax_total:
* type: number
* title: original_shipping_tax_total
* description: The associated order's original shipping tax total.
*
*/

View File

@@ -3,6 +3,262 @@
* type: object
* description: The order change's exchange.
* x-schemaName: OrderExchange
* required:
* - order_id
* - return_items
* - additional_items
* - currency_code
* - id
* - region_id
* - customer_id
* - sales_channel_id
* - email
* - shipping_methods
* - payment_status
* - fulfillment_status
* - summary
* - metadata
* - created_at
* - updated_at
* - original_item_total
* - original_item_subtotal
* - original_item_tax_total
* - item_total
* - item_subtotal
* - item_tax_total
* - original_total
* - original_subtotal
* - original_tax_total
* - total
* - subtotal
* - tax_total
* - discount_total
* - discount_tax_total
* - gift_card_total
* - gift_card_tax_total
* - shipping_total
* - shipping_subtotal
* - shipping_tax_total
* - original_shipping_total
* - original_shipping_subtotal
* - original_shipping_tax_total
* properties:
* order_id:
* type: string
* title: order_id
* description: The ID of the order the exchange is created for.
* return_items:
* type: array
* description: The items returned (inbound) by the exchange.
* items:
* $ref: "#/components/schemas/AdminReturnItem"
* additional_items:
* type: array
* description: The new items (outbound) sent by the exchange.
* items:
* $ref: "#/components/schemas/BaseExchangeItem"
* no_notification:
* type: boolean
* title: no_notification
* description: Whether to send the customer notifications when the exchange is updated.
* difference_due:
* type: number
* title: difference_due
* description: The amount to be exchanged or refunded. If the amount is negative, it must be refunded. If positive, additional payment is required from the customer.
* return:
* description: the return associated with the exchange.
* $ref: "#/components/schemas/AdminReturn"
* return_id:
* type: string
* title: return_id
* description: The ID of the associated exchange.
* currency_code:
* type: string
* title: currency_code
* description: The exchange's currency code.
* id:
* type: string
* title: id
* description: The exchange's ID.
* region_id:
* type: string
* title: region_id
* description: The ID of the associated order's region.
* customer_id:
* type: string
* title: customer_id
* description: The ID of the customer that placed the order.
* sales_channel_id:
* type: string
* title: sales_channel_id
* description: The ID of the sales channel the associated order belongs to.
* email:
* type: string
* title: email
* description: The email used when placing the order.
* format: email
* display_id:
* type: number
* title: display_id
* description: The exchange's display ID.
* shipping_address:
* description: The shipping address to send new items to.
* $ref: "#/components/schemas/BaseOrderAddress"
* billing_address:
* description: The customer's billing address.
* $ref: "#/components/schemas/BaseOrderAddress"
* shipping_methods:
* type: array
* description: The shipping methods used to send the new (outbound) items.
* items:
* $ref: "#/components/schemas/BaseOrderShippingMethod"
* payment_collections:
* type: array
* description: The exchange's payment collections.
* items:
* $ref: "#/components/schemas/BasePaymentCollection"
* payment_status:
* type: string
* description: The exchange's payment status.
* enum:
* - canceled
* - not_paid
* - awaiting
* - authorized
* - partially_authorized
* - captured
* - partially_captured
* - partially_refunded
* - refunded
* - requires_action
* fulfillments:
* type: array
* description: The exchange's fulfillments of new (outbound) items.
* items:
* $ref: "#/components/schemas/BaseOrderFulfillment"
* fulfillment_status:
* type: string
* description: The exchange's fulfillment status.
* enum:
* - canceled
* - not_fulfilled
* - partially_fulfilled
* - fulfilled
* - partially_shipped
* - shipped
* - partially_delivered
* - delivered
* transactions:
* type: array
* description: The exchange's transactions.
* externalDocs:
* url: https://docs.medusajs.com/v2/resources/commerce-modules/order/transactions
* items:
* $ref: "#/components/schemas/BaseOrderTransaction"
* summary:
* description: The totals summary of the exchange.
* $ref: "#/components/schemas/BaseOrderSummary"
* metadata:
* type: object
* description: The exchange's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date that the exchange was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date that the exchange was updated.
* original_item_total:
* type: number
* title: original_item_total
* description: The total of the original items in the order.
* original_item_subtotal:
* type: number
* title: original_item_subtotal
* description: The subtotal of the original items in the order.
* original_item_tax_total:
* type: number
* title: original_item_tax_total
* description: The total tax of the original items in the order.
* item_total:
* type: number
* title: item_total
* description: The total of the exchange's new items.
* item_subtotal:
* type: number
* title: item_subtotal
* description: The subtotal of the exchange's new items.
* item_tax_total:
* type: number
* title: item_tax_total
* description: The tax total of the exchange's new items.
* original_total:
* type: number
* title: original_total
* description: The total of the order.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The subtotal of the order.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The tax total of the order.
* total:
* type: number
* title: total
* description: The total of the exchange.
* subtotal:
* type: number
* title: subtotal
* description: The subtotal of the exchange.
* tax_total:
* type: number
* title: tax_total
* description: The tax total of the exchange.
* discount_total:
* type: number
* title: discount_total
* description: The discount total of the exchange.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The total taxes on discount of the exchange.
* gift_card_total:
* type: number
* title: gift_card_total
* description: The gift cards total of the exchange.
* gift_card_tax_total:
* type: number
* title: gift_card_tax_total
* description: The total taxes on the gift card of the exchange.
* shipping_total:
* type: number
* title: shipping_total
* description: The exchange's shipping total.
* shipping_subtotal:
* type: number
* title: shipping_subtotal
* description: The exchange's shipping subtotal.
* shipping_tax_total:
* type: number
* title: shipping_tax_total
* description: The exchange's shipping tax total.
* original_shipping_total:
* type: number
* title: original_shipping_total
* description: The order's shipping total.
* original_shipping_subtotal:
* type: number
* title: original_shipping_subtotal
* description: The order's shipping subtotal.
* original_shipping_tax_total:
* type: number
* title: original_shipping_tax_total
* description: The order's shipping tax total.
*
*/

View File

@@ -1,8 +1,111 @@
/**
* @schema OrderItem
* type: object
* description: The item's detail.
* description: The order item's detail.
* x-schemaName: OrderItem
* required:
* - id
* - item_id
* - item
* - quantity
* - raw_quantity
* - fulfilled_quantity
* - raw_fulfilled_quantity
* - delivered_quantity
* - raw_delivered_quantity
* - shipped_quantity
* - raw_shipped_quantity
* - return_requested_quantity
* - raw_return_requested_quantity
* - return_received_quantity
* - raw_return_received_quantity
* - return_dismissed_quantity
* - raw_return_dismissed_quantity
* - written_off_quantity
* - raw_written_off_quantity
* - metadata
* - created_at
* - updated_at
* properties:
* id:
* type: string
* title: id
* description: The item's ID.
* item_id:
* type: string
* title: item_id
* description: The ID of the associated line item.
* item:
* $ref: "#/components/schemas/OrderLineItem"
* quantity:
* type: number
* title: quantity
* description: The item's quantity.
* raw_quantity:
* type: object
* description: The item's raw quantity.
* fulfilled_quantity:
* type: number
* title: fulfilled_quantity
* description: The item's fulfilled quantity.
* raw_fulfilled_quantity:
* type: object
* description: The item's raw fulfilled quantity.
* delivered_quantity:
* type: number
* title: delivered_quantity
* description: The item's delivered quantity.
* raw_delivered_quantity:
* type: object
* description: The item's raw delivered quantity.
* shipped_quantity:
* type: number
* title: shipped_quantity
* description: The item's shipped quantity.
* raw_shipped_quantity:
* type: object
* description: The item's raw shipped quantity.
* return_requested_quantity:
* type: number
* title: return_requested_quantity
* description: The item's quantity that's requested to be returned.
* raw_return_requested_quantity:
* type: object
* description: The item's raw return requested quantity.
* return_received_quantity:
* type: number
* title: return_received_quantity
* description: The item's quantity that's received through a return.
* raw_return_received_quantity:
* type: object
* description: The item's raw return received quantity.
* return_dismissed_quantity:
* type: number
* title: return_dismissed_quantity
* description: The item's quantity that's returned but dismissed because it's damaged.
* raw_return_dismissed_quantity:
* type: object
* description: The item's raw return dismissed quantity.
* written_off_quantity:
* type: number
* title: written_off_quantity
* description: The item's quantity that's removed due to an order change.
* raw_written_off_quantity:
* type: object
* description: The item's raw written off quantity.
* metadata:
* type: object
* description: The item's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the item was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the item was updated.
*
*/

View File

@@ -0,0 +1,438 @@
/**
* @schema OrderLineItem
* type: object
* description: The order line item's details.
* x-schemaName: OrderLineItem
* required:
* - id
* - title
* - requires_shipping
* - is_discountable
* - is_tax_inclusive
* - unit_price
* - raw_unit_price
* - quantity
* - raw_quantity
* - detail
* - created_at
* - updated_at
* - original_total
* - original_subtotal
* - original_tax_total
* - item_total
* - item_subtotal
* - item_tax_total
* - total
* - subtotal
* - tax_total
* - discount_total
* - discount_tax_total
* - refundable_total
* - refundable_total_per_unit
* - raw_original_total
* - raw_original_subtotal
* - raw_original_tax_total
* - raw_item_total
* - raw_item_subtotal
* - raw_item_tax_total
* - raw_total
* - raw_subtotal
* - raw_tax_total
* - raw_discount_total
* - raw_discount_tax_total
* - raw_refundable_total
* - raw_refundable_total_per_unit
* properties:
* id:
* type: string
* title: id
* description: The item's ID.
* title:
* type: string
* title: title
* description: The item's title.
* subtitle:
* type: string
* title: subtitle
* description: The item's subtitle.
* thumbnail:
* type: string
* title: thumbnail
* description: The item's thumbnail URL.
* variant_id:
* type: string
* title: variant_id
* description: The ID of the associated variant.
* product_id:
* type: string
* title: product_id
* description: The ID of the associated product.
* product_title:
* type: string
* title: product_title
* description: The item's product title.
* product_description:
* type: string
* title: product_description
* description: The item's product description.
* product_subtitle:
* type: string
* title: product_subtitle
* description: The item's product subtitle.
* product_type:
* type: string
* title: product_type
* description: The ID of the associated product's type.
* product_collection:
* type: string
* title: product_collection
* description: The ID of the associated product's collection.
* product_handle:
* type: string
* title: product_handle
* description: The item's product handle.
* variant_sku:
* type: string
* title: variant_sku
* description: The item's variant SKU.
* variant_barcode:
* type: string
* title: variant_barcode
* description: The item's variant barcode.
* variant_title:
* type: string
* title: variant_title
* description: The item's variant title.
* variant_option_values:
* type: object
* description: The associated variant's values for the associated product's options.
* example:
* Color: Red
* requires_shipping:
* type: boolean
* title: requires_shipping
* description: Whether the item requires shipping.
* is_discountable:
* type: boolean
* title: is_discountable
* description: Whether the item is discountable.
* is_tax_inclusive:
* type: boolean
* title: is_tax_inclusive
* description: Whether the item's price includes taxes.
* compare_at_unit_price:
* type: number
* title: compare_at_unit_price
* description: The original price of the item before a promotion or sale.
* raw_compare_at_unit_price:
* type: object
* description: The item's raw compare at unit price.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw compare at unit price's value.
* - type: number
* title: value
* description: The raw compare at unit price's value.
* unit_price:
* type: number
* title: unit_price
* description: The item's price for a single quantity.
* raw_unit_price:
* type: object
* description: The item's raw unit price.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw unit price's value.
* - type: number
* title: value
* description: The raw unit price's value.
* quantity:
* type: number
* title: quantity
* description: The item's quantity.
* raw_quantity:
* type: object
* description: The item's raw quantity.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw quantity's value.
* - type: number
* title: value
* description: The raw quantity's value.
* tax_lines:
* type: array
* description: The item's tax lines.
* items:
* $ref: "#/components/schemas/OrderLineItemTaxLine"
* adjustments:
* type: array
* description: The item's adjustments.
* items:
* $ref: "#/components/schemas/OrderLineItemAdjustment"
* detail:
* $ref: "#/components/schemas/OrderItem"
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the item was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the item was updated.
* metadata:
* type: object
* description: The item's metadata, can hold custom key-value pairs.
* original_total:
* type: number
* title: original_total
* description: The item's total including taxes and promotions.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The item's total excluding taxes, including promotions.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The total taxes of the item excluding promotions.
* item_total:
* type: number
* title: item_total
* description: The item's total for a single quantity, including taxes and promotions.
* item_subtotal:
* type: number
* title: item_subtotal
* description: The item's total for a single quantity, excluding taxes and including promotions.
* item_tax_total:
* type: number
* title: item_tax_total
* description: The total taxes of a single quantity of the item, including promotions.
* total:
* type: number
* title: total
* description: The item's total including taxes and promotions.
* subtotal:
* type: number
* title: subtotal
* description: The item's total excluding taxes, including promotions.
* tax_total:
* type: number
* title: tax_total
* description: The total taxes of the item, including promotions.
* discount_total:
* type: number
* title: discount_total
* description: The item's discount total.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The total taxes on the discounted amount.
* refundable_total:
* type: number
* title: refundable_total
* description: The total amount of the item that can be refunded.
* refundable_total_per_unit:
* type: number
* title: refundable_total_per_unit
* description: The total amount that can be refunded of a single quantity of the item.
* raw_original_total:
* type: object
* description: The item's raw original total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original total's value.
* - type: number
* title: value
* description: The raw original total's value.
* raw_original_subtotal:
* type: object
* description: The item's raw original subtotal.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original subtotal's value.
* - type: number
* title: value
* description: The raw original subtotal's value.
* raw_original_tax_total:
* type: object
* description: The item's raw original tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original tax total's value.
* - type: number
* title: value
* description: The raw original tax total's value.
* raw_item_total:
* type: object
* description: The item's raw item total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw item total's value.
* - type: number
* title: value
* description: The raw item total's value.
* raw_item_subtotal:
* type: object
* description: The item's raw item subtotal.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw item subtotal's value.
* - type: number
* title: value
* description: The raw item subtotal's value.
* raw_item_tax_total:
* type: object
* description: The item's raw item tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw item tax total's value.
* - type: number
* title: value
* description: The raw item tax total's value.
* raw_total:
* type: object
* description: The item's raw total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw total's value.
* - type: number
* title: value
* description: The raw total's value.
* raw_subtotal:
* type: object
* description: The item's raw subtotal.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw subtotal's value.
* - type: number
* title: value
* description: The raw subtotal's value.
* raw_tax_total:
* type: object
* description: The item's raw tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw tax total's value.
* - type: number
* title: value
* description: The raw tax total's value.
* raw_discount_total:
* type: object
* description: The item's raw discount total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw discount total's value.
* - type: number
* title: value
* description: The raw discount total's value.
* raw_discount_tax_total:
* type: object
* description: The item's raw discount tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw discount tax total's value.
* - type: number
* title: value
* description: The raw discount tax total's value.
* raw_refundable_total:
* type: object
* description: The item's raw refundable total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw refundable total's value.
* - type: number
* title: value
* description: The raw refundable total's value.
* raw_refundable_total_per_unit:
* type: object
* description: The item's raw refundable total per unit.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw refundable total per unit's value.
* - type: number
* title: value
* description: The raw refundable total per unit's value.
*
*/

View File

@@ -1,8 +1,61 @@
/**
* @schema OrderLineItemAdjustment
* type: object
* description: The adjustment's adjustments.
* description: The line item adjustment's details.
* x-schemaName: OrderLineItemAdjustment
* required:
* - item
* - item_id
* - id
* - amount
* - order_id
* - created_at
* - updated_at
* properties:
* item:
* $ref: "#/components/schemas/OrderLineItem"
* item_id:
* type: string
* title: item_id
* description: The ID of the item this adjustment is for.
* id:
* type: string
* title: id
* description: The adjustment's ID.
* code:
* type: string
* title: code
* description: The adjustment's code.
* amount:
* type: number
* title: amount
* description: The adjustment's amount.
* order_id:
* type: string
* title: order_id
* description: The ID of the associated order.
* description:
* type: string
* title: description
* description: The adjustment's description.
* promotion_id:
* type: string
* title: promotion_id
* description: The ID of the promotion applied by this adjustment.
* provider_id:
* type: string
* title: provider_id
* description: The adjustment's provider ID.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the adjustment was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the adjustment was updated.
*
*/

View File

@@ -1,8 +1,75 @@
/**
* @schema OrderLineItemTaxLine
* type: object
* description: The tax line's tax lines.
* description: The line item tax line's details.
* x-schemaName: OrderLineItemTaxLine
* required:
* - item
* - item_id
* - total
* - subtotal
* - raw_total
* - raw_subtotal
* - id
* - code
* - rate
* - created_at
* - updated_at
* properties:
* item:
* $ref: "#/components/schemas/OrderLineItem"
* item_id:
* type: string
* title: item_id
* description: The ID of the line item that the tax line belongs to.
* total:
* type: number
* title: total
* description: The item's total including taxes and promotions.
* subtotal:
* type: number
* title: subtotal
* description: The item's total excluding taxes, including promotions.
* raw_total:
* type: object
* description: The tax line's raw total.
* raw_subtotal:
* type: object
* description: The tax line's raw subtotal.
* id:
* type: string
* title: id
* description: The tax line's ID.
* description:
* type: string
* title: description
* description: The tax line's description.
* tax_rate_id:
* type: string
* title: tax_rate_id
* description: The ID of the applied tax rate.
* code:
* type: string
* title: code
* description: The code that the tax rate is identified by.
* rate:
* type: number
* title: rate
* description: The rate to charge.
* provider_id:
* type: string
* title: provider_id
* description: The ID of the tax provider used to calculate the tax lines.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the tax line was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the tax line was updated.
*
*/

View File

@@ -0,0 +1,51 @@
/**
* @schema OrderReturnItem
* type: object
* description: The item's items.
* x-schemaName: OrderReturnItem
* required:
* - id
* - quantity
* - received_quantity
* - damaged_quantity
* - item_id
* - return_id
* properties:
* id:
* type: string
* title: id
* description: The return item's ID.
* quantity:
* type: number
* title: quantity
* description: The return item's quantity.
* received_quantity:
* type: number
* title: received_quantity
* description: The received quantity of the item. This quantity is added to the stocked inventory quantity of the item.
* damaged_quantity:
* type: number
* title: damaged_quantity
* description: The received damaged quantity of the item, which isn't added to the stocked inventory quantity of the item.
* reason_id:
* type: string
* title: reason_id
* description: The ID of the return reason associated with the item.
* note:
* type: string
* title: note
* description: A note about why the item was returned.
* item_id:
* type: string
* title: item_id
* description: The ID of the associated order item.
* return_id:
* type: string
* title: return_id
* description: The ID of the return this return item belongs to.
* metadata:
* type: object
* description: The return item's metadata, can hold custom key-value pairs.
*
*/

View File

@@ -0,0 +1,248 @@
/**
* @schema OrderShippingMethod
* type: object
* description: The shipping method's details.
* x-schemaName: OrderShippingMethod
* required:
* - id
* - order_id
* - name
* - amount
* - raw_amount
* - is_tax_inclusive
* - created_at
* - updated_at
* - original_total
* - original_subtotal
* - original_tax_total
* - total
* - subtotal
* - tax_total
* - discount_total
* - discount_tax_total
* - raw_original_total
* - raw_original_subtotal
* - raw_original_tax_total
* - raw_total
* - raw_subtotal
* - raw_tax_total
* - raw_discount_total
* - raw_discount_tax_total
* properties:
* id:
* type: string
* title: id
* description: The shipping method's ID.
* order_id:
* type: string
* title: order_id
* description: The ID of the order that the shipping method belongs to.
* name:
* type: string
* title: name
* description: The shipping method's name.
* description:
* type: string
* title: description
* description: The shipping method's description.
* amount:
* type: number
* title: amount
* description: The shipping method's amount.
* raw_amount:
* type: object
* description: The shipping method's raw amount.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw amount's value.
* - type: number
* title: value
* description: The raw amount's value.
* is_tax_inclusive:
* type: boolean
* title: is_tax_inclusive
* description: Whether the shipping method's amount includes taxes.
* shipping_option_id:
* type: string
* title: shipping_option_id
* description: The ID of the shipping option this method was created from.
* data:
* type: object
* description: The shipping method's data, useful for the fulfillment provider handling the fulfillment.
* externalDocs:
* url: https://docs.medusajs.com/v2/resources/commerce-modules/order/concepts#data-property
* metadata:
* type: object
* description: The shipping method's metadata, can hold custom key-value pairs.
* tax_lines:
* type: array
* description: The shipping method's tax lines.
* items:
* $ref: "#/components/schemas/OrderShippingMethodTaxLine"
* adjustments:
* type: array
* description: The shipping method's adjustments.
* items:
* $ref: "#/components/schemas/OrderShippingMethodAdjustment"
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the shipping method was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the shipping method was updated.
* original_total:
* type: number
* title: original_total
* description: The shipping method's total including taxes, excluding promotions.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The shipping method's subtotal excluding taxes, including promotions.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The total taxes of the shipping method excluding promotions.
* total:
* type: number
* title: total
* description: The shipping method's total including taxes and promotions.
* subtotal:
* type: number
* title: subtotal
* description: The shipping method's total excluding taxes, including promotions.
* tax_total:
* type: number
* title: tax_total
* description: The total taxes of the shipping method, including promotions.
* discount_total:
* type: number
* title: discount_total
* description: The shipping method's discount total.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The total taxes of the discount amount.
* raw_original_total:
* type: object
* description: The shipping method's raw original total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original total's value.
* - type: number
* title: value
* description: The raw original total's value.
* raw_original_subtotal:
* type: object
* description: The shipping method's raw original subtotal.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original subtotal's value.
* - type: number
* title: value
* description: The raw original subtotal's value.
* raw_original_tax_total:
* type: object
* description: The shipping method's raw original tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw original tax total's value.
* - type: number
* title: value
* description: The raw original tax total's value.
* raw_total:
* type: object
* description: The shipping method's raw total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw total's value.
* - type: number
* title: value
* description: The raw total's value.
* raw_subtotal:
* type: object
* description: The shipping method's raw subtotal.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw subtotal's value.
* - type: number
* title: value
* description: The raw subtotal's value.
* raw_tax_total:
* type: object
* description: The shipping method's raw tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw tax total's value.
* - type: number
* title: value
* description: The raw tax total's value.
* raw_discount_total:
* type: object
* description: The shipping method's raw discount total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw discount total's value.
* - type: number
* title: value
* description: The raw discount total's value.
* raw_discount_tax_total:
* type: object
* description: The shipping method's raw discount tax total.
* required:
* - value
* properties:
* value:
* oneOf:
* - type: string
* title: value
* description: The raw discount tax total's value.
* - type: number
* title: value
* description: The raw discount tax total's value.
*
*/

View File

@@ -1,8 +1,61 @@
/**
* @schema OrderShippingMethodAdjustment
* type: object
* description: The adjustment's adjustments.
* description: The shipping method adjustment's details.
* x-schemaName: OrderShippingMethodAdjustment
* required:
* - shipping_method
* - shipping_method_id
* - id
* - amount
* - order_id
* - created_at
* - updated_at
* properties:
* shipping_method:
* $ref: "#/components/schemas/OrderShippingMethod"
* shipping_method_id:
* type: string
* title: shipping_method_id
* description: The ID of the shipping method this adjustment is for.
* id:
* type: string
* title: id
* description: The adjustment's ID.
* code:
* type: string
* title: code
* description: The adjustment's code.
* amount:
* type: number
* title: amount
* description: The adjustment's amount.
* order_id:
* type: string
* title: order_id
* description: The ID of the associated order.
* description:
* type: string
* title: description
* description: The adjustment's description.
* promotion_id:
* type: string
* title: promotion_id
* description: The ID of the promotion this adjustment applies.
* provider_id:
* type: string
* title: provider_id
* description: The adjustment's provider ID.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the adjustment was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the adjustment was updated.
*
*/

View File

@@ -1,8 +1,75 @@
/**
* @schema OrderShippingMethodTaxLine
* type: object
* description: The tax line's tax lines.
* description: The shipping method tax line's details.
* x-schemaName: OrderShippingMethodTaxLine
* required:
* - shipping_method
* - shipping_method_id
* - total
* - subtotal
* - raw_total
* - raw_subtotal
* - id
* - code
* - rate
* - created_at
* - updated_at
* properties:
* shipping_method:
* $ref: "#/components/schemas/OrderShippingMethod"
* shipping_method_id:
* type: string
* title: shipping_method_id
* description: The ID of the shipping method that this tax line is for.
* total:
* type: number
* title: total
* description: The shipping method's total including taxes and promotions.
* subtotal:
* type: number
* title: subtotal
* description: The shipping method's total excluding taxes, including promotions.
* raw_total:
* type: object
* description: The tax line's raw total.
* raw_subtotal:
* type: object
* description: The tax line's raw subtotal.
* id:
* type: string
* title: id
* description: The tax line's ID.
* description:
* type: string
* title: description
* description: The tax line's description.
* tax_rate_id:
* type: string
* title: tax_rate_id
* description: The ID of the applied tax rate.
* code:
* type: string
* title: code
* description: The code that the tax rate is identified by.
* rate:
* type: number
* title: rate
* description: The rate to charge.
* provider_id:
* type: string
* title: provider_id
* description: The ID of the tax provider used to calculate taxes.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the tax line was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the tax line was updated.
*
*/

View File

@@ -1,20 +1,18 @@
/**
* @schema OrderTransaction
* type: object
* description: The transaction's transactions.
* description: The transaction's details.
* x-schemaName: OrderTransaction
* required:
* - id
* - order_id
* - order
* - amount
* - raw_amount
* - currency_code
* - reference
* - reference_id
* - metadata
* - created_at
* - updated_at
* - metadata
* properties:
* id:
* type: string
@@ -23,49 +21,39 @@
* order_id:
* type: string
* title: order_id
* description: The transaction's order id.
* order:
* $ref: "#/components/schemas/Order"
* description: The ID of the order this transaction belongs to.
* amount:
* oneOf:
* - type: string
* title: amount
* description: The transaction's amount.
* - type: number
* title: amount
* description: The transaction's amount.
* - type: string
* title: amount
* description: The transaction's amount.
* - $ref: "#/components/schemas/IBigNumber"
* raw_amount:
* type: object
* description: The transaction's raw amount.
* type: number
* title: amount
* description: The transaction's amount.
* currency_code:
* type: string
* title: currency_code
* description: The transaction's currency code.
* example: usd
* reference:
* type: string
* title: reference
* description: The transaction's reference.
* description: The name of a table that this transaction references. If this transaction is for captured payment, its value is `capture`. If this transaction is for refunded payment, its value is `refund`.
* enum:
* - capture
* - refund
* reference_id:
* type: string
* title: reference_id
* description: The transaction's reference id.
* description: The ID of the referenced record in the referenced table.
* metadata:
* type: object
* description: The transaction's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The transaction's created at.
* description: The date that the transaction was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The transaction's updated at.
* metadata:
* type: object
* description: The transaction's metadata.
* description: The date that the transaction was updated.
*
*/
*/

View File

@@ -1,8 +1,304 @@
/**
* @schema Return
* type: object
* description: The order change's return order.
* description: The return's details.
* x-schemaName: Return
* required:
* - id
* - status
* - order_id
* - items
* - currency_code
* - created_at
* - updated_at
* - original_item_total
* - original_item_subtotal
* - original_item_tax_total
* - item_total
* - item_subtotal
* - item_tax_total
* - original_total
* - original_subtotal
* - original_tax_total
* - total
* - subtotal
* - tax_total
* - discount_total
* - discount_tax_total
* - gift_card_total
* - gift_card_tax_total
* - shipping_total
* - shipping_subtotal
* - shipping_tax_total
* - original_shipping_total
* - original_shipping_subtotal
* - original_shipping_tax_total
* - discount_subtotal
* - raw_original_item_total
* - raw_original_item_subtotal
* - raw_original_item_tax_total
* - raw_item_total
* - raw_item_subtotal
* - raw_item_tax_total
* - raw_original_total
* - raw_original_subtotal
* - raw_original_tax_total
* - raw_total
* - raw_subtotal
* - raw_tax_total
* - raw_discount_total
* - raw_discount_tax_total
* - raw_gift_card_total
* - raw_gift_card_tax_total
* - raw_shipping_total
* - raw_shipping_subtotal
* - raw_shipping_tax_total
* - raw_original_shipping_total
* - raw_original_shipping_subtotal
* - raw_original_shipping_tax_total
* properties:
* id:
* type: string
* title: id
* description: The return's ID.
* status:
* type: string
* description: The return's status.
* enum:
* - canceled
* - requested
* - received
* - partially_received
* refund_amount:
* type: number
* title: refund_amount
* description: The amount refunded by this return.
* order_id:
* type: string
* title: order_id
* description: The ID of the associated order.
* items:
* type: array
* description: The return's items.
* items:
* $ref: "#/components/schemas/OrderReturnItem"
* region_id:
* type: string
* title: region_id
* description: The ID of the region this return belongs to.
* customer_id:
* type: string
* title: customer_id
* description: The ID of the customer that placed the order.
* sales_channel_id:
* type: string
* title: sales_channel_id
* description: The ID of the associated order's sales channel.
* email:
* type: string
* title: email
* description: The email of the customer that placed the order.
* format: email
* currency_code:
* type: string
* title: currency_code
* description: The return's currency code.
* example: usd
* shipping_address:
* $ref: "#/components/schemas/OrderAddress"
* billing_address:
* $ref: "#/components/schemas/OrderAddress"
* shipping_methods:
* type: array
* description: The return's shipping methods.
* items:
* $ref: "#/components/schemas/OrderShippingMethod"
* transactions:
* type: array
* description: The return's transactions.
* items:
* $ref: "#/components/schemas/OrderTransaction"
* summary:
* type: object
* description: The return's summary.
* metadata:
* type: object
* description: The return's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the return was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the return was updated.
* original_item_total:
* type: number
* title: original_item_total
* description: The return's original item total.
* original_item_subtotal:
* type: number
* title: original_item_subtotal
* description: The return's original item subtotal.
* original_item_tax_total:
* type: number
* title: original_item_tax_total
* description: The return's original item tax total.
* item_total:
* type: number
* title: item_total
* description: The return's item total.
* item_subtotal:
* type: number
* title: item_subtotal
* description: The return's item subtotal.
* item_tax_total:
* type: number
* title: item_tax_total
* description: The return's item tax total.
* original_total:
* type: number
* title: original_total
* description: The return's original total.
* original_subtotal:
* type: number
* title: original_subtotal
* description: The return's original subtotal.
* original_tax_total:
* type: number
* title: original_tax_total
* description: The return's original tax total.
* total:
* type: number
* title: total
* description: The return's total.
* subtotal:
* type: number
* title: subtotal
* description: The return's subtotal.
* tax_total:
* type: number
* title: tax_total
* description: The return's tax total.
* discount_total:
* type: number
* title: discount_total
* description: The return's discount total.
* discount_tax_total:
* type: number
* title: discount_tax_total
* description: The return's discount tax total.
* gift_card_total:
* type: number
* title: gift_card_total
* description: The return's gift card total.
* gift_card_tax_total:
* type: number
* title: gift_card_tax_total
* description: The return's gift card tax total.
* shipping_total:
* type: number
* title: shipping_total
* description: The return's shipping total.
* shipping_subtotal:
* type: number
* title: shipping_subtotal
* description: The return's shipping subtotal.
* shipping_tax_total:
* type: number
* title: shipping_tax_total
* description: The return's shipping tax total.
* original_shipping_total:
* type: number
* title: original_shipping_total
* description: The return's original shipping total.
* original_shipping_subtotal:
* type: number
* title: original_shipping_subtotal
* description: The return's original shipping subtotal.
* original_shipping_tax_total:
* type: number
* title: original_shipping_tax_total
* description: The return's original shipping tax total.
* order_change:
* $ref: "#/components/schemas/OrderChange"
* canceled_at:
* type: string
* title: canceled_at
* description: The date the return was canceled.
* format: date-time
* discount_subtotal:
* type: number
* title: discount_subtotal
* description: The return's discount subtotal.
* raw_original_item_total:
* type: object
* description: The return's raw original item total.
* raw_original_item_subtotal:
* type: object
* description: The return's raw original item subtotal.
* raw_original_item_tax_total:
* type: object
* description: The return's raw original item tax total.
* raw_item_total:
* type: object
* description: The return's raw item total.
* raw_item_subtotal:
* type: object
* description: The return's raw item subtotal.
* raw_item_tax_total:
* type: object
* description: The return's raw item tax total.
* raw_original_total:
* type: object
* description: The return's raw original total.
* raw_original_subtotal:
* type: object
* description: The return's raw original subtotal.
* raw_original_tax_total:
* type: object
* description: The return's raw original tax total.
* raw_total:
* type: object
* description: The return's raw total.
* raw_subtotal:
* type: object
* description: The return's raw subtotal.
* raw_tax_total:
* type: object
* description: The return's raw tax total.
* raw_discount_total:
* type: object
* description: The return's raw discount total.
* raw_discount_tax_total:
* type: object
* description: The return's raw discount tax total.
* raw_gift_card_total:
* type: object
* description: The return's raw gift card total.
* raw_gift_card_tax_total:
* type: object
* description: The return's raw gift card tax total.
* raw_shipping_total:
* type: object
* description: The return's raw shipping total.
* raw_shipping_subtotal:
* type: object
* description: The return's raw shipping subtotal.
* raw_shipping_tax_total:
* type: object
* description: The return's raw shipping tax total.
* raw_original_shipping_total:
* type: object
* description: The return's raw original shipping total.
* raw_original_shipping_subtotal:
* type: object
* description: The return's raw original shipping subtotal.
* raw_original_shipping_tax_total:
* type: object
* description: The return's raw original shipping tax total.
*
*/

View File

@@ -0,0 +1,83 @@
import ts from "typescript"
type ConstructorParams = {
checker: ts.TypeChecker
}
export default class TypesHelper {
private checker: ts.TypeChecker
constructor({ checker }: ConstructorParams) {
this.checker = checker
}
areTypesEqual(type1: ts.Type, type2: ts.Type): boolean {
return "id" in type1 && "id" in type2 && type1.id === type2.id
}
/**
* Retrieve the name of a type. This is useful when retrieving allowed/disallowed
* properties in an Omit/Pick type.
*
* @param itemType - The type to retrieve its name.
* @returns The type's name.
*/
getTypeName(itemType: ts.Type): string {
if (itemType.symbol || itemType.aliasSymbol) {
return (itemType.aliasSymbol || itemType.symbol).name
}
if (itemType.isLiteral()) {
return itemType.value.toString()
}
return this.checker.typeToString(itemType)
}
cleanUpTypes(types: ts.Type[]): ts.Type[] {
let cleanedUpTypes = this.removeStringRegExpTypeOverlaps(types)
cleanedUpTypes = this.joinDateAndString(cleanedUpTypes)
return cleanedUpTypes
}
private removeStringRegExpTypeOverlaps(types: ts.Type[]): ts.Type[] {
return types.filter((itemType) => {
// remove overlapping string / regexp types
if (this.checker.typeToString(itemType) === "RegExp") {
const hasString = types.some((t) => {
return (
t.flags === ts.TypeFlags.String ||
t.flags === ts.TypeFlags.StringLiteral
)
})
return !hasString
}
return true
})
}
private joinDateAndString(types: ts.Type[]): ts.Type[] {
if (types.length !== 2) {
return types
}
let dateType: ts.Type | undefined
let hasStringType = false
types.forEach((tsType) => {
if (
tsType.flags === ts.TypeFlags.String ||
tsType.flags === ts.TypeFlags.StringLiteral
) {
hasStringType = true
} else if (this.getTypeName(tsType) === "Date") {
dateType = tsType
}
})
return dateType && hasStringType ? [dateType] : types
}
}

View File

@@ -26,6 +26,7 @@ import FunctionKindGenerator, {
VariableNode,
} from "./function.js"
import { API_ROUTE_PARAM_REGEX } from "../../constants.js"
import TypesHelper from "../helpers/types.js"
import {
isLevelExceeded,
maybeIncrementLevel,
@@ -93,6 +94,7 @@ class OasKindGenerator extends FunctionKindGenerator {
protected oasExamplesGenerator: OasExamplesGenerator
protected oasSchemaHelper: OasSchemaHelper
protected schemaFactory: SchemaFactory
protected typesHelper: TypesHelper
constructor(options: GeneratorOptions) {
super(options)
@@ -103,6 +105,9 @@ class OasKindGenerator extends FunctionKindGenerator {
this.tags = new Map()
this.oasSchemaHelper = new OasSchemaHelper()
this.schemaFactory = new SchemaFactory()
this.typesHelper = new TypesHelper({
checker: this.checker,
})
this.init()
this.generatorEventManager.listen(
@@ -1397,18 +1402,18 @@ class OasKindGenerator extends FunctionKindGenerator {
}
}
const oneOfItems = this.removeStringRegExpTypeOverlaps(
(itemType as ts.UnionType).types
).map((unionType) =>
this.typeToSchema({
itemType: unionType,
level: maybeIncrementLevel(level, "oneOf"),
title,
descriptionOptions,
saveSchema,
...rest,
})
)
const oneOfItems = this.typesHelper
.cleanUpTypes((itemType as ts.UnionType).types)
.map((unionType) =>
this.typeToSchema({
itemType: unionType,
level: maybeIncrementLevel(level, "oneOf"),
title,
descriptionOptions,
saveSchema,
...rest,
})
)
if (oneOfItems.length === 1) {
return oneOfItems[0]
@@ -1418,18 +1423,18 @@ class OasKindGenerator extends FunctionKindGenerator {
oneOf: oneOfItems,
}
case itemType.isIntersection():
const allOfItems = this.removeStringRegExpTypeOverlaps(
(itemType as ts.IntersectionType).types
).map((intersectionType) => {
return this.typeToSchema({
itemType: intersectionType,
level: maybeIncrementLevel(level, "allOf"),
title,
descriptionOptions,
saveSchema,
...rest,
const allOfItems = this.typesHelper
.cleanUpTypes((itemType as ts.IntersectionType).types)
.map((intersectionType) => {
return this.typeToSchema({
itemType: intersectionType,
level: maybeIncrementLevel(level, "allOf"),
title,
descriptionOptions,
saveSchema,
...rest,
})
})
})
if (allOfItems.length === 1) {
return allOfItems[0]
@@ -1448,9 +1453,9 @@ class OasKindGenerator extends FunctionKindGenerator {
}
const pickedProperties = pickTypeArgs[1].isUnion()
? pickTypeArgs[1].types.map((unionType) =>
this.getTypeName(unionType)
this.typesHelper.getTypeName(unionType)
)
: [this.getTypeName(pickTypeArgs[1])]
: [this.typesHelper.getTypeName(pickTypeArgs[1])]
return this.typeToSchema({
itemType: pickTypeArgs[0],
title,
@@ -1470,9 +1475,9 @@ class OasKindGenerator extends FunctionKindGenerator {
}
const omitProperties = omitTypeArgs[1].isUnion()
? omitTypeArgs[1].types.map((unionType) =>
this.getTypeName(unionType)
this.typesHelper.getTypeName(unionType)
)
: [this.getTypeName(omitTypeArgs[1])]
: [this.typesHelper.getTypeName(omitTypeArgs[1])]
return this.typeToSchema({
itemType: omitTypeArgs[0],
title,
@@ -1581,7 +1586,7 @@ class OasKindGenerator extends FunctionKindGenerator {
const arrHasParentType =
rest.context !== "query" &&
this.checker.isArrayType(propertyType) &&
this.areTypesEqual(
this.typesHelper.areTypesEqual(
itemType,
this.checker.getTypeArguments(
propertyType as ts.TypeReference
@@ -1589,7 +1594,7 @@ class OasKindGenerator extends FunctionKindGenerator {
)
const isParentType =
rest.context !== "query" &&
this.areTypesEqual(itemType, propertyType)
this.typesHelper.areTypesEqual(itemType, propertyType)
if (isParentType && objSchema["x-schemaName"]) {
properties[property.name] = {
@@ -1792,25 +1797,6 @@ class OasKindGenerator extends FunctionKindGenerator {
}
}
/**
* Retrieve the name of a type. This is useful when retrieving allowed/disallowed
* properties in an Omit/Pick type.
*
* @param itemType - The type to retrieve its name.
* @returns The type's name.
*/
getTypeName(itemType: ts.Type): string {
if (itemType.symbol || itemType.aliasSymbol) {
return (itemType.aliasSymbol || itemType.symbol).name
}
if (itemType.isLiteral()) {
return itemType.value.toString()
}
return this.checker.typeToString(itemType)
}
/**
* Initialize the {@link tags} property.
*/
@@ -2299,27 +2285,6 @@ class OasKindGenerator extends FunctionKindGenerator {
fnText.includes(responseType)
)
}
private removeStringRegExpTypeOverlaps(types: ts.Type[]): ts.Type[] {
return types.filter((itemType) => {
// remove overlapping string / regexp types
if (this.checker.typeToString(itemType) === "RegExp") {
const hasString = types.some((t) => {
return (
t.flags === ts.TypeFlags.String ||
t.flags === ts.TypeFlags.StringLiteral
)
})
return !hasString
}
return true
})
}
private areTypesEqual(type1: ts.Type, type2: ts.Type): boolean {
return "id" in type1 && "id" in type2 && type1.id === type2.id
}
}
export default OasKindGenerator