diff --git a/www/utils/generated/oas-output/schemas/AdminOrderChange.ts b/www/utils/generated/oas-output/schemas/AdminOrderChange.ts new file mode 100644 index 0000000000..0f7e52cb6d --- /dev/null +++ b/www/utils/generated/oas-output/schemas/AdminOrderChange.ts @@ -0,0 +1,154 @@ +/** + * @schema AdminOrderChange + * type: object + * description: The order preview's order change. + * x-schemaName: AdminOrderChange + * required: + * - order + * - claim + * - return + * - exchange + * - id + * - version + * - order_id + * - return_id + * - exchange_id + * - claim_id + * - return_order + * - actions + * - status + * - requested_by + * - requested_at + * - confirmed_by + * - confirmed_at + * - declined_by + * - declined_reason + * - metadata + * - declined_at + * - canceled_by + * - canceled_at + * - created_at + * - updated_at + * properties: + * id: + * type: string + * title: id + * description: The order change's ID. + * order_id: + * type: string + * title: order_id + * description: The order change's order id. + * actions: + * type: array + * description: The order change's actions. + * items: + * $ref: "#/components/schemas/BaseOrderChangeAction" + * status: + * type: string + * title: status + * description: The order change's status. + * requested_by: + * type: string + * title: requested_by + * description: The order change's requested by. + * 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 + * confirmed_by: + * type: string + * title: confirmed_by + * description: The order change's confirmed by. + * 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 + * declined_by: + * type: string + * title: declined_by + * description: The order change's declined by. + * declined_reason: + * type: string + * title: declined_reason + * description: The order change's declined reason. + * metadata: + * type: object + * description: The order change's metadata. + * 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 + * canceled_by: + * type: string + * title: canceled_by + * description: The order change's canceled by. + * 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 + * created_at: + * type: string + * format: date-time + * title: created_at + * description: The order change's created at. + * updated_at: + * type: string + * format: date-time + * title: updated_at + * description: The order change's updated at. + * version: + * type: number + * title: version + * description: The order change's version. + * change_type: + * type: string + * description: The order change's change type. + * enum: + * - return + * - exchange + * - claim + * - edit + * - return_request + * return_id: + * type: string + * title: return_id + * description: The order change's return id. + * exchange_id: + * type: string + * title: exchange_id + * description: The order change's exchange id. + * claim_id: + * type: string + * title: claim_id + * description: The order change's claim id. + * order: + * $ref: "#/components/schemas/AdminOrder" + * return_order: + * $ref: "#/components/schemas/AdminReturn" + * exchange: + * $ref: "#/components/schemas/AdminExchange" + * claim: + * $ref: "#/components/schemas/AdminClaim" + * +*/ + diff --git a/www/utils/generated/oas-output/schemas/AdminOrderChangeAction.ts b/www/utils/generated/oas-output/schemas/AdminOrderChangeAction.ts new file mode 100644 index 0000000000..568529b6a8 --- /dev/null +++ b/www/utils/generated/oas-output/schemas/AdminOrderChangeAction.ts @@ -0,0 +1,90 @@ +/** + * @schema AdminOrderChangeAction + * type: object + * description: The action's details. + * x-schemaName: AdminOrderChangeAction + * properties: + * order_change: + * $ref: "#/components/schemas/AdminOrderChange" + * 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 this action belongs to. + * order_id: + * type: string + * title: order_id + * description: The ID of the associated 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 + * title: action + * description: The applied action. + * details: + * type: object + * description: The action's details. + * example: + * reference_id: 123 + * quantity: 1 + * internal_note: + * type: string + * title: internal_note + * description: A note viewed only by admin users. + * created_at: + * type: string + * format: date-time + * title: created_at + * description: The date the order change action was created. + * updated_at: + * type: string + * format: date-time + * title: updated_at + * description: The date the order change action was updated. + * 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/BaseOrder" + * required: + * - order_change + * - id + * - order_change_id + * - order_id + * - reference + * - reference_id + * - action + * - details + * - internal_note + * - created_at + * - updated_at + * - return_id + * - claim_id + * - exchange_id + * - order + * +*/ + diff --git a/www/utils/generated/oas-output/schemas/AdminOrderFulfillment.ts b/www/utils/generated/oas-output/schemas/AdminOrderFulfillment.ts new file mode 100644 index 0000000000..ed6b2051a9 --- /dev/null +++ b/www/utils/generated/oas-output/schemas/AdminOrderFulfillment.ts @@ -0,0 +1,76 @@ +/** + * @schema AdminOrderFulfillment + * type: object + * description: The fulfillment's details. + * x-schemaName: AdminOrderFulfillment + * required: + * - id + * - location_id + * - packed_at + * - shipped_at + * - delivered_at + * - canceled_at + * - data + * - provider_id + * - shipping_option_id + * - metadata + * - created_at + * - updated_at + * properties: + * id: + * type: string + * title: id + * description: The fulfillment's ID. + * location_id: + * type: string + * title: location_id + * description: The ID of the location the items are fulfilled from. + * packed_at: + * type: string + * title: packed_at + * description: The date the items were packed. + * format: date-time + * shipped_at: + * type: string + * title: shipped_at + * description: The date the items were shipped. + * format: date-time + * delivered_at: + * type: string + * title: delivered_at + * description: The date the items were delivered. + * format: date-time + * canceled_at: + * type: string + * title: canceled_at + * description: The date the items were canceled. + * format: date-time + * data: + * type: object + * description: Data useful for the fulfillment provider handling it. This is taken from the associated shipping option. + * externalDocs: + * url: https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment/shipping-option#data-property + * provider_id: + * type: string + * title: provider_id + * description: The ID of the fulfillment provider used to handle the fulfillment. + * shipping_option_id: + * type: string + * title: shipping_option_id + * description: The ID of the associated shipping option. + * metadata: + * type: object + * description: The fulfillment's metadata, can hold custom key-value pairs. + * created_at: + * type: string + * format: date-time + * title: created_at + * description: The date the fulfillment was created. + * updated_at: + * type: string + * format: date-time + * title: updated_at + * description: The date the fulfillment was updated. + * +*/ + diff --git a/www/utils/generated/oas-output/schemas/AdminOrderLineItem.ts b/www/utils/generated/oas-output/schemas/AdminOrderLineItem.ts new file mode 100644 index 0000000000..33887ec101 --- /dev/null +++ b/www/utils/generated/oas-output/schemas/AdminOrderLineItem.ts @@ -0,0 +1,218 @@ +/** + * @schema AdminOrderLineItem + * type: object + * description: The item's details. + * x-schemaName: AdminOrderLineItem + * required: + * - id + * - title + * - subtitle + * - thumbnail + * - variant_id + * - product_id + * - product_title + * - product_description + * - product_subtitle + * - product_type + * - product_collection + * - product_handle + * - variant_sku + * - variant_barcode + * - variant_title + * - variant_option_values + * - requires_shipping + * - is_discountable + * - is_tax_inclusive + * - unit_price + * - quantity + * - detail + * - created_at + * - updated_at + * - metadata + * - 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 + * 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 URL of the item's thumbnail. + * variant: + * $ref: "#/components/schemas/AdminProductVariant" + * variant_id: + * type: string + * title: variant_id + * description: The ID of the associated variant. + * product: + * $ref: "#/components/schemas/BaseProduct" + * 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 item's product type. + * product_collection: + * type: string + * title: product_collection + * description: The ID of the collection the item's product belongs to. + * 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 values of the item variant's options. + * example: + * Color: Blue + * 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 is tax inclusive. + * compare_at_unit_price: + * type: number + * title: compare_at_unit_price + * description: The original price of the item before a promotion or sale. + * unit_price: + * type: number + * title: unit_price + * description: The item's unit price. + * quantity: + * type: number + * title: quantity + * description: The item's quantity. + * tax_lines: + * type: array + * description: The item's tax lines. + * items: + * $ref: "#/components/schemas/BaseOrderLineItemTaxLine" + * adjustments: + * type: array + * description: The item's adjustments. + * items: + * $ref: "#/components/schemas/BaseOrderLineItemAdjustment" + * detail: + * $ref: "#/components/schemas/BaseOrderItemDetail" + * 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, excluding 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 total taxes of the item, including promotions. + * item_subtotal: + * type: number + * title: item_subtotal + * description: The item's total excluding taxes, including promotions. + * item_tax_total: + * type: number + * title: item_tax_total + * description: The total taxes 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 subtotal excluding taxes, including promotions. + * tax_total: + * type: number + * title: tax_total + * description: The tax total of the item including promotions. + * discount_total: + * type: number + * title: discount_total + * description: The total discount amount of the item. + * discount_tax_total: + * type: number + * title: discount_tax_total + * description: The total taxes applied on the discounted amount. + * refundable_total: + * type: number + * title: refundable_total + * description: The total refundable amount of the item's total. + * refundable_total_per_unit: + * type: number + * title: refundable_total_per_unit + * description: The total refundable amount of the item's total for a single quantity. + * +*/ + diff --git a/www/utils/generated/oas-output/schemas/BaseExchangeItem.ts b/www/utils/generated/oas-output/schemas/BaseExchangeItem.ts index c52fdb7733..6d0e609ec9 100644 --- a/www/utils/generated/oas-output/schemas/BaseExchangeItem.ts +++ b/www/utils/generated/oas-output/schemas/BaseExchangeItem.ts @@ -1,7 +1,7 @@ /** * @schema BaseExchangeItem * type: object - * description: The additional item's additional items. + * description: The item's details. * x-schemaName: BaseExchangeItem * required: * - id @@ -15,36 +15,36 @@ * id: * type: string * title: id - * description: The additional item's ID. + * description: The item's ID. * exchange_id: * type: string * title: exchange_id - * description: The additional item's exchange id. + * description: The ID of the exchange this item belongs to. * order_id: * type: string * title: order_id - * description: The additional item's order id. + * description: The ID of the order this item belongs to. * item_id: * type: string * title: item_id - * description: The additional item's item id. + * description: The ID of the item in the order. * quantity: * type: number * title: quantity - * description: The additional item's quantity. + * description: The item's quantity. * metadata: * type: object - * description: The additional item's metadata. + * description: The item's metadata, can hold custom key-value pairs. * created_at: * type: string * format: date-time * title: created_at - * description: The additional item's created at. + * description: The date the item was created. * updated_at: * type: string * format: date-time * title: updated_at - * description: The additional item's updated at. + * description: The date the item was updated. * */ diff --git a/www/utils/generated/oas-output/schemas/BaseFulfillmentProvider.ts b/www/utils/generated/oas-output/schemas/BaseFulfillmentProvider.ts index 3c7947dbe0..ea0e7972f0 100644 --- a/www/utils/generated/oas-output/schemas/BaseFulfillmentProvider.ts +++ b/www/utils/generated/oas-output/schemas/BaseFulfillmentProvider.ts @@ -1,7 +1,7 @@ /** * @schema BaseFulfillmentProvider * type: object - * description: The shipping option's provider. + * description: The fulfillment provider's details. * x-schemaName: BaseFulfillmentProvider * required: * - id @@ -14,7 +14,7 @@ * is_enabled: * type: boolean * title: is_enabled - * description: The provider's is enabled. + * description: Whether the provider is enabled. * */ diff --git a/www/utils/generated/oas-output/schemas/BaseLineItemAdjustment.ts b/www/utils/generated/oas-output/schemas/BaseLineItemAdjustment.ts index cb086343d2..59d0210c73 100644 --- a/www/utils/generated/oas-output/schemas/BaseLineItemAdjustment.ts +++ b/www/utils/generated/oas-output/schemas/BaseLineItemAdjustment.ts @@ -1,8 +1,61 @@ /** * @schema BaseLineItemAdjustment * type: object - * description: The adjustment's adjustments. + * description: The adjustment's details. * x-schemaName: BaseLineItemAdjustment + * properties: + * item: + * $ref: "#/components/schemas/BaseCartLineItem" + * item_id: + * type: string + * title: item_id + * description: The ID of the item this adjustment applies on. + * 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. + * cart_id: + * type: string + * title: cart_id + * description: The ID of the cart this adjustment belongs to. + * 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. + * required: + * - item + * - item_id + * - id + * - amount + * - cart_id + * - created_at + * - updated_at * */ diff --git a/www/utils/generated/oas-output/schemas/BaseLineItemTaxLine.ts b/www/utils/generated/oas-output/schemas/BaseLineItemTaxLine.ts index 98593da5be..2c55637222 100644 --- a/www/utils/generated/oas-output/schemas/BaseLineItemTaxLine.ts +++ b/www/utils/generated/oas-output/schemas/BaseLineItemTaxLine.ts @@ -1,8 +1,67 @@ /** * @schema BaseLineItemTaxLine * type: object - * description: The tax line's tax lines. + * description: The tax line's details * x-schemaName: BaseLineItemTaxLine + * properties: + * item: + * $ref: "#/components/schemas/BaseCartLineItem" + * item_id: + * type: string + * title: item_id + * description: The ID of the item the tax line applies on. + * total: + * type: number + * title: total + * description: The item's total, including taxes and promotions. + * subtotal: + * type: number + * title: subtotal + * description: The item's subtotal excluding taxes, including promotions. + * 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 associated tax rate. + * code: + * type: string + * title: code + * description: The code 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. + * 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. + * required: + * - item + * - item_id + * - total + * - subtotal + * - id + * - code + * - rate + * - created_at + * - updated_at * */ diff --git a/www/utils/generated/oas-output/schemas/BaseOrder.ts b/www/utils/generated/oas-output/schemas/BaseOrder.ts index f2070c41b6..d23be983f7 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrder.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrder.ts @@ -1,8 +1,242 @@ /** * @schema BaseOrder * type: object - * description: The order change's order. + * description: The order's details. * x-schemaName: BaseOrder + * required: + * - payment_collections + * - id + * - version + * - region_id + * - customer_id + * - sales_channel_id + * - email + * - currency_code + * - items + * - 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: + * payment_collections: + * type: array + * description: The order's payment collections. + * items: + * $ref: "#/components/schemas/AdminPaymentCollection" + * fulfillments: + * type: array + * description: The order's fulfillments. + * items: + * $ref: "#/components/schemas/BaseOrderFulfillment" + * sales_channel: + * $ref: "#/components/schemas/AdminSalesChannel" + * customer: + * $ref: "#/components/schemas/AdminCustomer" + * shipping_address: + * $ref: "#/components/schemas/AdminOrderAddress" + * billing_address: + * $ref: "#/components/schemas/AdminOrderAddress" + * id: + * type: string + * title: id + * description: The order's ID. + * version: + * type: number + * title: version + * description: The order's version. + * region_id: + * type: string + * title: region_id + * description: The ID of the region associated with the order. + * 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 is 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. + * display_id: + * type: number + * title: display_id + * description: The order's display ID. + * items: + * type: array + * description: The order's items. + * items: + * $ref: "#/components/schemas/BaseOrderLineItem" + * shipping_methods: + * type: array + * description: The order's shipping methods. + * items: + * $ref: "#/components/schemas/BaseOrderShippingMethod" + * payment_status: + * type: string + * description: The order's payment status. + * enum: + * - canceled + * - not_paid + * - awaiting + * - authorized + * - partially_authorized + * - captured + * - partially_captured + * - partially_refunded + * - refunded + * - requires_action + * fulfillment_status: + * type: string + * description: The order's fulfillment status. + * enum: + * - canceled + * - not_fulfilled + * - partially_fulfilled + * - fulfilled + * - partially_shipped + * - shipped + * - partially_delivered + * - delivered + * transactions: + * type: array + * description: The order's transactions. + * items: + * $ref: "#/components/schemas/BaseOrderTransaction" + * summary: + * $ref: "#/components/schemas/BaseOrderSummary" + * metadata: + * type: object + * description: The order's metadata, can hold custom key-value pairs. + * 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 total of the order's items including taxes, excluding promotions. + * original_item_subtotal: + * type: number + * title: original_item_subtotal + * description: The total of the order's items excluding taxes, including promotions. + * original_item_tax_total: + * type: number + * title: original_item_tax_total + * description: The tax total of the order's items excluding promotions. + * item_total: + * type: number + * title: item_total + * description: The total of the order's items including taxes and promotions. + * item_subtotal: + * type: number + * title: item_subtotal + * description: The total of the order's items excluding taxes, including promotions. + * item_tax_total: + * type: number + * title: item_tax_total + * description: The tax total of the order's items including promotions. + * original_total: + * type: number + * title: original_total + * description: The order's total excluding promotions, including taxes. + * 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 order's tax total, 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 total excluding taxes, including promotions. + * tax_total: + * type: number + * title: tax_total + * description: The order's tax total including promotions. + * discount_total: + * type: number + * title: discount_total + * description: The order's discount or promotions total. + * discount_tax_total: + * type: number + * title: discount_tax_total + * description: The tax total of order's discount or promotion. + * 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 tax total of the order's gift card. + * 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 tax total of the order's shipping. + * 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 tax total of the order's shipping excluding promotions. * -*/ - +*/ \ No newline at end of file diff --git a/www/utils/generated/oas-output/schemas/BaseOrderAddress.ts b/www/utils/generated/oas-output/schemas/BaseOrderAddress.ts index bd04252f47..5a99652682 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderAddress.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderAddress.ts @@ -1,7 +1,7 @@ /** * @schema BaseOrderAddress * type: object - * description: The exchange's billing address. + * description: An order address * x-schemaName: BaseOrderAddress * required: * - id @@ -12,64 +12,67 @@ * 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 this 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 + * country: + * $ref: "#/components/schemas/AdminRegionCountry" * 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. * */ diff --git a/www/utils/generated/oas-output/schemas/BaseOrderChange.ts b/www/utils/generated/oas-output/schemas/BaseOrderChange.ts index aaeb705b11..5453a675b1 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderChange.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderChange.ts @@ -4,8 +4,17 @@ * description: The order preview's order change. * x-schemaName: BaseOrderChange * required: + * - order + * - claim + * - return + * - exchange * - id + * - version * - order_id + * - return_id + * - exchange_id + * - claim_id + * - return_order * - actions * - status * - requested_by @@ -20,14 +29,6 @@ * - canceled_at * - created_at * - updated_at - * - version - * - return_id - * - exchange_id - * - claim_id - * - order - * - return_order - * - exchange - * - claim * properties: * id: * type: string @@ -141,11 +142,13 @@ * title: claim_id * description: The order change's claim id. * order: - * $ref: "#/components/schemas/BaseOrder" - * return_order: {} - * exchange: {} + * $ref: "#/components/schemas/AdminOrder" + * return_order: + * $ref: "#/components/schemas/AdminReturn" + * exchange: + * $ref: "#/components/schemas/AdminExchange" * claim: - * $ref: "#/components/schemas/BaseClaim" + * $ref: "#/components/schemas/AdminClaim" * */ diff --git a/www/utils/generated/oas-output/schemas/BaseOrderChangeAction.ts b/www/utils/generated/oas-output/schemas/BaseOrderChangeAction.ts index af71235e5c..e39982ab09 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderChangeAction.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderChangeAction.ts @@ -3,6 +3,87 @@ * type: object * description: The action's actions. * x-schemaName: BaseOrderChangeAction + * properties: + * order_change: + * $ref: "#/components/schemas/AdminOrderChange" + * 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 this action belongs to. + * order_id: + * type: string + * title: order_id + * description: The ID of the associated 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 + * title: action + * description: The applied action. + * details: + * type: object + * description: The action's details. + * example: + * reference_id: 123 + * quantity: 1 + * internal_note: + * type: string + * title: internal_note + * description: A note viewed only by admin users. + * created_at: + * type: string + * format: date-time + * title: created_at + * description: The date the order change action was created. + * updated_at: + * type: string + * format: date-time + * title: updated_at + * description: The date the order change action was updated. + * 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/BaseOrder" + * required: + * - order_change + * - id + * - order_change_id + * - order_id + * - reference + * - reference_id + * - action + * - details + * - internal_note + * - created_at + * - updated_at + * - return_id + * - claim_id + * - exchange_id + * - order * */ - diff --git a/www/utils/generated/oas-output/schemas/BaseOrderFulfillment.ts b/www/utils/generated/oas-output/schemas/BaseOrderFulfillment.ts index cabb570a06..bffc83d43b 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderFulfillment.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderFulfillment.ts @@ -24,51 +24,52 @@ * location_id: * type: string * title: location_id - * description: The fulfillment's location id. + * description: The ID of the location the items are fulfilled from. * packed_at: * type: string * title: packed_at - * description: The fulfillment's packed at. + * description: The date the items were packed. * format: date-time * shipped_at: * type: string * title: shipped_at - * description: The fulfillment's shipped at. + * description: The date the items were shipped. * format: date-time * delivered_at: * type: string * title: delivered_at - * description: The fulfillment's delivered at. + * description: The date the items were delivered. * format: date-time * canceled_at: * type: string * title: canceled_at - * description: The fulfillment's canceled at. + * description: The date the items were canceled. * format: date-time * data: * type: object - * description: The fulfillment's data. + * description: Data useful for the fulfillment provider handling it. This is taken from the associated shipping option. + * externalDocs: + * url: https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment/shipping-option#data-property * provider_id: * type: string * title: provider_id - * description: The fulfillment's provider id. + * description: The ID of the fulfillment provider used to handle the fulfillment. * shipping_option_id: * type: string * title: shipping_option_id - * description: The fulfillment's shipping option id. + * description: The ID of the associated shipping option. * metadata: * type: object - * description: The fulfillment's metadata. + * description: The fulfillment's metadata, can hold custom key-value pairs. * created_at: * type: string * format: date-time * title: created_at - * description: The fulfillment's created at. + * description: The date the fulfillment was created. * updated_at: * type: string * format: date-time * title: updated_at - * description: The fulfillment's updated at. + * description: The date the fulfillment was updated. * */ - diff --git a/www/utils/generated/oas-output/schemas/BaseOrderItemDetail.ts b/www/utils/generated/oas-output/schemas/BaseOrderItemDetail.ts index 8d577d9ddd..b9eb897f52 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderItemDetail.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderItemDetail.ts @@ -3,6 +3,76 @@ * type: object * description: The item's detail. * x-schemaName: BaseOrderItemDetail - * + * required: + * - id + * - item_id + * - quantity + * - fulfilled_quantity + * - delivered_quantity + * - shipped_quantity + * - return_requested_quantity + * - return_received_quantity + * - return_dismissed_quantity + * - written_off_quantity + * - metadata + * - created_at + * - updated_at + * properties: + * id: + * type: string + * title: id + * description: the detail's ID. + * item_id: + * type: string + * title: id + * description: the ID of the associated line item. + * item: + * $ref: "#/components/schemas/AdminOrderLineItem" + * quantity: + * type: number + * title: quantity + * description: The item's quantity. + * fulfilled_quantity: + * type: number + * title: fulfilled_quantity + * description: The item's fulfilled quantity. + * delivered_quantity: + * type: number + * title: fulfilled_quantity + * description: The item's delivered quantity. + * shipped_quantity: + * type: number + * title: shipped_quantity + * description: The item's shipped quantity. + * return_requested_quantity: + * type: number + * title: return_requested_quantity + * description: The item's quantity that's requested to be returned. + * return_received_quantity: + * type: number + * title: return_received_quantity + * description: The item's quantity that's returned and added to the underlying variant's stocked quantity. + * return_dismissed_quantity: + * type: number + * title: return_dismissed_quantity + * description: The item's quantity that's returned but damaged. So, it's not added to the underlying variant's stocked quantity. + * written_off_quantity: + * type: number + * title: written_off_quantity + * description: The item's quantity that's removed from the order. + * metadata: + * type: object + * title: metadata + * 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 detail was created. + * updated_at: + * type: string + * format: date-time + * title: updated_at + * description: The date the detail was updated. */ diff --git a/www/utils/generated/oas-output/schemas/BaseOrderLineItem.ts b/www/utils/generated/oas-output/schemas/BaseOrderLineItem.ts index 6f578ebd35..34b103c121 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderLineItem.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderLineItem.ts @@ -58,19 +58,19 @@ * thumbnail: * type: string * title: thumbnail - * description: The item's thumbnail. + * description: The URL of the item's thumbnail. * variant: - * $ref: "#/components/schemas/BaseProductVariant" + * $ref: "#/components/schemas/AdminProductVariant" * variant_id: * type: string * title: variant_id - * description: The item's variant id. + * description: The ID of the associated variant. * product: * $ref: "#/components/schemas/BaseProduct" * product_id: * type: string * title: product_id - * description: The item's product id. + * description: The ID of the associated product. * product_title: * type: string * title: product_title @@ -90,7 +90,7 @@ * product_collection: * type: string * title: product_collection - * description: The item's product collection. + * description: The ID of the collection the item's product belongs to. * product_handle: * type: string * title: product_handle @@ -98,7 +98,7 @@ * variant_sku: * type: string * title: variant_sku - * description: The item's variant sku. + * description: The item's variant SKU. * variant_barcode: * type: string * title: variant_barcode @@ -109,23 +109,25 @@ * description: The item's variant title. * variant_option_values: * type: object - * description: The item's variant option values. + * description: The values of the item variant's options. + * example: + * Color: Blue * requires_shipping: * type: boolean * title: requires_shipping - * description: The item's requires shipping. + * description: Whether the item requires shipping. * is_discountable: * type: boolean * title: is_discountable - * description: The item's is discountable. + * description: Whether the item is discountable. * is_tax_inclusive: * type: boolean * title: is_tax_inclusive - * description: The item's is tax inclusive. + * description: Whether the item is tax inclusive. * compare_at_unit_price: * type: number * title: compare_at_unit_price - * description: The item's compare at unit price. + * description: The original price of the item before a promotion or sale. * unit_price: * type: number * title: unit_price @@ -150,67 +152,66 @@ * type: string * format: date-time * title: created_at - * description: The item's created at. + * description: The date the item was created. * updated_at: * type: string * format: date-time * title: updated_at - * description: The item's updated at. + * description: The date the item was updated. * metadata: * type: object - * description: The item's metadata. + * description: The item's metadata, can hold custom key-value pairs. * original_total: * type: number * title: original_total - * description: The item's original total. + * description: The item's total including taxes, excluding promotions. * original_subtotal: * type: number * title: original_subtotal - * description: The item's original subtotal. + * description: The item's total excluding taxes, including promotions. * original_tax_total: * type: number * title: original_tax_total - * description: The item's original tax total. + * description: The total taxes of the item, excluding promotions. * item_total: * type: number * title: item_total - * description: The item's item total. + * description: The total taxes of the item, including promotions. * item_subtotal: * type: number * title: item_subtotal - * description: The item's item subtotal. + * description: The item's total excluding taxes, including promotions. * item_tax_total: * type: number * title: item_tax_total - * description: The item's item tax total. + * description: The total taxes of the item, including promotions. * total: * type: number * title: total - * description: The item's total. + * description: The item's total, including taxes and promotions. * subtotal: * type: number * title: subtotal - * description: The item's subtotal. + * description: The item's subtotal excluding taxes, including promotions. * tax_total: * type: number * title: tax_total - * description: The item's tax total. + * description: The tax total of the item including promotions. * discount_total: * type: number * title: discount_total - * description: The item's discount total. + * description: The total discount amount of the item. * discount_tax_total: * type: number * title: discount_tax_total - * description: The item's discount tax total. + * description: The total taxes applied on the discounted amount. * refundable_total: * type: number * title: refundable_total - * description: The item's refundable total. + * description: The total refundable amount of the item's total. * refundable_total_per_unit: * type: number * title: refundable_total_per_unit - * description: The item's refundable total per unit. + * description: The total refundable amount of the item's total for a single quantity. * */ - diff --git a/www/utils/generated/oas-output/schemas/BaseOrderLineItemAdjustment.ts b/www/utils/generated/oas-output/schemas/BaseOrderLineItemAdjustment.ts index 0cd2c7aa8a..d2deef5fdb 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderLineItemAdjustment.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderLineItemAdjustment.ts @@ -1,8 +1,61 @@ /** * @schema BaseOrderLineItemAdjustment * type: object - * description: The adjustment's adjustments. + * description: The adjustment's details. * x-schemaName: BaseOrderLineItemAdjustment + * properties: + * item: + * $ref: "#/components/schemas/BaseOrderLineItem" + * item_id: + * type: string + * title: item_id + * description: The ID of the item this adjustment applies to. + * 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 that this applies on the order's item. + * 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. + * required: + * - item + * - item_id + * - id + * - amount + * - order_id + * - created_at + * - updated_at * */ diff --git a/www/utils/generated/oas-output/schemas/BaseOrderLineItemTaxLine.ts b/www/utils/generated/oas-output/schemas/BaseOrderLineItemTaxLine.ts index 1fe4ae2ee4..52f3f1786d 100644 --- a/www/utils/generated/oas-output/schemas/BaseOrderLineItemTaxLine.ts +++ b/www/utils/generated/oas-output/schemas/BaseOrderLineItemTaxLine.ts @@ -3,6 +3,65 @@ * type: object * description: The tax line's tax lines. * x-schemaName: BaseOrderLineItemTaxLine + * properties: + * item: + * $ref: "#/components/schemas/BaseOrderLineItem" + * item_id: + * type: string + * title: item_id + * description: The ID of the associated line item. + * total: + * type: number + * title: total + * description: The tax line's total including promotions. + * subtotal: + * type: number + * title: subtotal + * description: The tax line's subtotal excluding promotions. + * 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 line. + * 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. + * required: + * - item + * - item_id + * - total + * - subtotal + * - id + * - code + * - rate + * - created_at + * - updated_at * */ diff --git a/www/utils/packages/docs-generator/src/classes/helpers/oas-schema.ts b/www/utils/packages/docs-generator/src/classes/helpers/oas-schema.ts index 3a32f7ed48..67b4446628 100644 --- a/www/utils/packages/docs-generator/src/classes/helpers/oas-schema.ts +++ b/www/utils/packages/docs-generator/src/classes/helpers/oas-schema.ts @@ -10,6 +10,10 @@ import formatOas from "../../utils/format-oas.js" import pluralize from "pluralize" import { capitalize, wordsToPascal } from "utils" import { OasArea } from "../kinds/oas.js" +import { + isLevelExceeded, + maybeIncrementLevel, +} from "../../utils/level-utils.js" export type ParsedSchema = { schema: OpenApiSchema @@ -27,7 +31,7 @@ class OasSchemaHelper { private schemas: Map protected schemaRefPrefix = "#/components/schemas/" protected formatter: Formatter - private MAX_LEVEL = 4 + private MAX_LEVEL = 5 /** * The path to the directory holding the base YAML files. */ @@ -56,9 +60,9 @@ class OasSchemaHelper { */ namedSchemaToReference( schema: OpenApiSchema, - level = 0 + level = 1 ): OpenAPIV3.ReferenceObject | undefined { - if (level > this.MAX_LEVEL) { + if (isLevelExceeded(level, this.MAX_LEVEL)) { return } @@ -91,8 +95,10 @@ class OasSchemaHelper { !("$ref" in propertySchema.items) ) { propertySchema.items = - this.namedSchemaToReference(propertySchema.items, level + 1) || - propertySchema.items + this.namedSchemaToReference( + propertySchema.items, + maybeIncrementLevel(level, "array") + ) || propertySchema.items } else if ( propertySchema.oneOf || propertySchema.allOf || @@ -108,14 +114,17 @@ class OasSchemaHelper { } schemaTarget![index] = - this.namedSchemaToReference(item, level + 1) || item + this.namedSchemaToReference( + item, + maybeIncrementLevel(level, "allOf") + ) || item }) } properties![property] = this.namedSchemaToReference( propertySchema as OpenApiSchema, - level + 1 + maybeIncrementLevel(level, "object") ) || propertySchema }) } @@ -129,8 +138,8 @@ class OasSchemaHelper { } } - schemaChildrenToRefs(schema: OpenApiSchema, level = 0): OpenApiSchema { - if (level > this.MAX_LEVEL) { + schemaChildrenToRefs(schema: OpenApiSchema, level = 1): OpenApiSchema { + if (isLevelExceeded(level, this.MAX_LEVEL)) { return schema } @@ -142,7 +151,10 @@ class OasSchemaHelper { return item } - const transformChildItems = this.schemaChildrenToRefs(item, level + 1) + const transformChildItems = this.schemaChildrenToRefs( + item, + maybeIncrementLevel(level, "allOf") + ) return ( this.namedSchemaToReference(transformChildItems) || transformChildItems @@ -154,7 +166,10 @@ class OasSchemaHelper { return item } - const transformChildItems = this.schemaChildrenToRefs(item, level + 1) + const transformChildItems = this.schemaChildrenToRefs( + item, + maybeIncrementLevel(level, "oneOf") + ) return ( this.namedSchemaToReference(transformChildItems) || transformChildItems @@ -166,7 +181,7 @@ class OasSchemaHelper { ) { const transformedChildItems = this.schemaChildrenToRefs( clonedSchema.items, - level + maybeIncrementLevel(level, "array") ) clonedSchema.items = this.namedSchemaToReference(transformedChildItems) || @@ -179,7 +194,7 @@ class OasSchemaHelper { const transformedProperty = this.schemaChildrenToRefs( property, - level + 1 + maybeIncrementLevel(level, "object") ) schema.properties![key] = this.namedSchemaToReference(transformedProperty) || @@ -200,7 +215,7 @@ class OasSchemaHelper { const transformedProperty = this.schemaChildrenToRefs( property, - level + 1 + maybeIncrementLevel(level, "object") ) additionalProps.properties![key] = this.namedSchemaToReference(transformedProperty) || @@ -272,13 +287,14 @@ class OasSchemaHelper { */ getSchemaByName( name: string, - shouldNormalizeName = true + shouldNormalizeName = true, + isUpdating = false ): ParsedSchema | undefined { const schemaName = shouldNormalizeName ? this.normalizeSchemaName(name) : name // check if it already exists in the schemas map - if (this.schemas.has(schemaName)) { + if (this.schemas.has(schemaName) && !isUpdating) { return { schema: JSON.parse(JSON.stringify(this.schemas.get(schemaName)!)), schemaPrefix: `@schema ${schemaName}`, diff --git a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts index df50612cbb..f4a51240a0 100644 --- a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts +++ b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts @@ -26,6 +26,10 @@ import FunctionKindGenerator, { VariableNode, } from "./function.js" import { API_ROUTE_PARAM_REGEX } from "../../constants.js" +import { + isLevelExceeded, + maybeIncrementLevel, +} from "../../utils/level-utils.js" const RES_STATUS_REGEX = /^res[\s\S]*\.status\((\d+)\)/ @@ -55,7 +59,7 @@ type AuthRequests = { class OasKindGenerator extends FunctionKindGenerator { public name = "oas" protected allowedKinds: SyntaxKind[] = [ts.SyntaxKind.FunctionDeclaration] - private MAX_LEVEL = 5 + private MAX_LEVEL = 7 readonly REQUEST_TYPE_NAMES = [ "MedusaRequest", "RequestWithContext", @@ -1251,7 +1255,7 @@ class OasKindGenerator extends FunctionKindGenerator { */ saveSchema?: boolean }): OpenApiSchema { - if (level > this.MAX_LEVEL) { + if (isLevelExceeded(level, this.MAX_LEVEL)) { return {} } @@ -1364,9 +1368,7 @@ class OasKindGenerator extends FunctionKindGenerator { itemType: this.checker.getTypeArguments( itemType as ts.TypeReference )[0], - // can't increment level because - // array must have items in it - level, + level: maybeIncrementLevel(level, "array"), title, descriptionOptions: descriptionOptions || title @@ -1400,10 +1402,7 @@ class OasKindGenerator extends FunctionKindGenerator { ).map((unionType) => this.typeToSchema({ itemType: unionType, - // not incrementing considering the - // current schema isn't actually a - // schema - level, + level: maybeIncrementLevel(level, "oneOf"), title, descriptionOptions, saveSchema, @@ -1424,10 +1423,7 @@ class OasKindGenerator extends FunctionKindGenerator { ).map((intersectionType) => { return this.typeToSchema({ itemType: intersectionType, - // not incrementing considering the - // current schema isn't actually a - // schema - level, + level: maybeIncrementLevel(level, "allOf"), title, descriptionOptions, saveSchema, @@ -1537,7 +1533,7 @@ class OasKindGenerator extends FunctionKindGenerator { > = {} let isAdditionalProperties = false - if (level + 1 <= this.MAX_LEVEL) { + if (!isLevelExceeded(level + 1, this.MAX_LEVEL)) { let itemProperties = itemType.getProperties() if ( @@ -1545,9 +1541,18 @@ class OasKindGenerator extends FunctionKindGenerator { itemType.aliasTypeArguments?.length === 2 && itemType.aliasTypeArguments[0].flags === ts.TypeFlags.String ) { - // object has dynamic keys, so put the properties under additionalProperties - itemProperties = itemType.aliasTypeArguments[1].getProperties() - isAdditionalProperties = true + const isValueObj = + itemType.aliasTypeArguments[1].isClassOrInterface() || + itemType.aliasTypeArguments[1].isTypeParameter() || + ((itemType.aliasTypeArguments[1] as ts.Type).flags === + ts.TypeFlags.Object && + !this.checker.isArrayType(itemType.aliasTypeArguments[1])) + + if (isValueObj) { + // object has dynamic keys, so put the properties under additionalProperties + itemProperties = itemType.aliasTypeArguments[1].getProperties() + isAdditionalProperties = true + } } itemProperties.forEach((property) => { @@ -1610,7 +1615,7 @@ class OasKindGenerator extends FunctionKindGenerator { properties[property.name] = this.typeToSchema({ itemType: propertyType, - level: level + 1, + level: maybeIncrementLevel(level, "object"), title: property.name, descriptionOptions: { ...descriptionOptions, @@ -1717,7 +1722,7 @@ class OasKindGenerator extends FunctionKindGenerator { * @param level - The current recursion level to avoid max-stack error * @returns Whether the symbol is required. */ - isRequired(symbol: ts.Symbol, level = 0): boolean { + isRequired(symbol: ts.Symbol, level = 1): boolean { let isRequired = true const checkNode = (node: ts.Node) => { switch (node.kind) { @@ -1749,11 +1754,11 @@ class OasKindGenerator extends FunctionKindGenerator { !symbol.valueDeclaration && symbol.declarations?.length && "symbol" in symbol.declarations[0] && - level < this.MAX_LEVEL + !isLevelExceeded(level, this.MAX_LEVEL) ) { return this.isRequired( symbol.declarations[0].symbol as ts.Symbol, - level + 1 + maybeIncrementLevel(level, "object") ) } @@ -1956,13 +1961,14 @@ class OasKindGenerator extends FunctionKindGenerator { */ level?: number }): OpenApiSchema | undefined { - if (level > this.MAX_LEVEL) { + if (isLevelExceeded(level, this.MAX_LEVEL)) { return } let oldSchemaObj = ( oldSchema && "$ref" in oldSchema - ? this.oasSchemaHelper.getSchemaByName(oldSchema.$ref)?.schema + ? this.oasSchemaHelper.getSchemaByName(oldSchema.$ref, true, true) + ?.schema : oldSchema ) as OpenApiSchema | undefined const newSchemaObj = ( @@ -1973,7 +1979,7 @@ class OasKindGenerator extends FunctionKindGenerator { if (!oldSchemaObj && newSchemaObj) { return newSchemaObj - } else if (!newSchemaObj) { + } else if (!newSchemaObj || !Object.keys(newSchemaObj)) { return undefined } @@ -1984,6 +1990,7 @@ class OasKindGenerator extends FunctionKindGenerator { oldSchemaObj = { ...newSchemaObj, description: oldSchemaObj?.description, + example: oldSchemaObj?.example || newSchemaObj.example, } } else if ( oldSchemaObj?.allOf && @@ -2025,7 +2032,7 @@ class OasKindGenerator extends FunctionKindGenerator { this.updateSchema({ oldSchema: oldSchemaObj!.additionalProperties, newSchema: newSchemaObj.additionalProperties, - level: level + 1, + level: maybeIncrementLevel(level, "object"), }) || oldSchemaObj!.additionalProperties } } else { @@ -2047,7 +2054,7 @@ class OasKindGenerator extends FunctionKindGenerator { newSchema: newSchemaObj!.properties![ propertyName ] as OpenApiSchema, - level: level + 1, + level: maybeIncrementLevel(level, "object"), }) || propertySchema } ) @@ -2070,7 +2077,7 @@ class OasKindGenerator extends FunctionKindGenerator { this.updateSchema({ oldSchema: oldSchemaObj.items as OpenApiSchema, newSchema: newSchemaObj!.items as OpenApiSchema, - level: level + 1, + level: maybeIncrementLevel(level, "array"), }) || oldSchemaObj.items } diff --git a/www/utils/packages/docs-generator/src/utils/level-utils.ts b/www/utils/packages/docs-generator/src/utils/level-utils.ts new file mode 100644 index 0000000000..94855d6a10 --- /dev/null +++ b/www/utils/packages/docs-generator/src/utils/level-utils.ts @@ -0,0 +1,16 @@ +type IncrementType = "array" | "allOf" | "anyOf" | "oneOf" | "object" + +export function maybeIncrementLevel( + level: number, + type: IncrementType +): number { + if (type !== "object") { + return level + } + + return level + 1 +} + +export function isLevelExceeded(level: number, maxLevel: number) { + return level > maxLevel +}