chore(oas): replace response with $ref class JSDoc (Admin O-PRI) (#3018)

### Scope

Admin routes directories O to PRI.

### What

Move inline OAS response schema declaration under their respective class declarations in order to expose them through  `#/components/schemas`. Replace inline OAS response schema with a `$ref` reference pointing to the newly declared schema.

### Why

Having response declared as its own "named" schema will allow OAS code generators to output typed entities/DTO that can be consumed without having to reference the route/operation.

### How

Declare a new @schema JSDoc for each "Res" class used to parse and validate request body. Move the current inline requestBody to the new @schema.

### Test

- Ran OAS validator.
- Ran docs build script.

Expect no visible changes to the documentation.
This commit is contained in:
Patrick
2023-01-13 09:40:15 -05:00
committed by GitHub
parent 9dbccd9ca7
commit cdcbc064b7
59 changed files with 303 additions and 343 deletions
@@ -53,10 +53,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -3,7 +3,7 @@ import { EntityManager } from "typeorm"
import { OrderEditService } from "../../../../services"
import {
defaultOrderEditFields,
defaultOrderEditRelations
defaultOrderEditRelations,
} from "../../../../types/order-edit"
/**
@@ -41,10 +41,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -3,7 +3,7 @@ import { EntityManager } from "typeorm"
import { OrderEditService } from "../../../../services"
import {
defaultOrderEditFields,
defaultOrderEditRelations
defaultOrderEditRelations,
} from "../../../../types/order-edit"
/**
@@ -41,10 +41,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -4,7 +4,7 @@ import { EntityManager } from "typeorm"
import { OrderEditService } from "../../../../services"
import {
defaultOrderEditFields,
defaultOrderEditRelations
defaultOrderEditRelations,
} from "../../../../types/order-edit"
/**
@@ -47,10 +47,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -42,10 +42,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -37,19 +37,7 @@ import { OrderEditService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Order Edit Item Change.
* object:
* type: string
* description: The type of the object that was deleted.
* format: item_change
* deleted:
* type: boolean
* description: Whether or not the Order Edit Item Change was deleted.
* default: true
* $ref: "#/components/schemas/AdminOrderEditItemChangeDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
*/
@@ -36,19 +36,7 @@ import { OrderEditService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Order Edit.
* object:
* type: string
* description: The type of the object that was deleted.
* format: order_edit
* deleted:
* type: boolean
* description: Whether or not the Order Edit was deleted.
* default: true
* $ref: "#/components/schemas/AdminOrderEditDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
*/
@@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -98,13 +98,73 @@ export default (app) => {
return app
}
/**
* @schema AdminOrderEditsRes
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
*/
export type AdminOrderEditsRes = {
order_edit: OrderEdit
}
/**
* @schema AdminOrderEditsListRes
* type: object
* properties:
* order_edits:
* type: array
* items:
* $ref: "#/components/schemas/OrderEdit"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
*/
export type AdminOrderEditsListRes = PaginatedResponse & {
order_edits: OrderEdit[]
}
/**
* @schema AdminOrderEditDeleteRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Order Edit.
* object:
* type: string
* description: The type of the object that was deleted.
* default: order_edit
* deleted:
* type: boolean
* description: Whether or not the Order Edit was deleted.
* default: true
*/
export type AdminOrderEditDeleteRes = DeleteResponse
/**
* @schema AdminOrderEditItemChangeDeleteRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Order Edit Item Change.
* object:
* type: string
* description: The type of the object that was deleted.
* default: item_change
* deleted:
* type: boolean
* description: Whether or not the Order Edit Item Change was deleted.
* default: true
*/
export type AdminOrderEditItemChangeDeleteRes = {
id: string
object: "item_change"
@@ -43,20 +43,7 @@ import { IsOptional, IsString } from "class-validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edits:
* type: array
* $ref: "#/components/schemas/OrderEdit"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminOrderEditsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -4,11 +4,11 @@ import { PaymentCollectionType } from "../../../../models"
import {
OrderEditService,
OrderService,
PaymentCollectionService
PaymentCollectionService,
} from "../../../../services"
import {
defaultOrderEditFields,
defaultOrderEditRelations
defaultOrderEditRelations,
} from "../../../../types/order-edit"
/**
@@ -46,10 +46,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -52,10 +52,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -54,10 +54,7 @@ import {
* content:
* application/json:
* schema:
* type: object
* properties:
* order_edit:
* $ref: "#/components/schemas/OrderEdit"
* $ref: "#/components/schemas/AdminOrderEditsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -57,10 +57,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -36,10 +36,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -40,10 +40,7 @@ import { MedusaError } from "medusa-core-utils"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -45,10 +45,7 @@ import { MedusaError } from "medusa-core-utils"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -45,10 +45,7 @@ import { MedusaError } from "medusa-core-utils"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -45,10 +45,7 @@ import { Fulfillment } from "../../../../models"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -38,10 +38,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -40,10 +40,7 @@ import { MedusaError } from "medusa-core-utils"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -38,10 +38,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -36,10 +36,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -52,10 +52,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -77,10 +77,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -76,10 +76,7 @@ import { Fulfillment, LineItem } from "../../../../models"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -58,10 +58,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -58,10 +58,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -79,10 +79,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -46,10 +46,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -46,10 +46,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -35,10 +35,7 @@ import { OrderService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -1,11 +1,7 @@
import { Router } from "express"
import "reflect-metadata"
import { Order } from "../../../.."
import {
DeleteResponse,
FindParams,
PaginatedResponse
} from "../../../../types/common"
import { FindParams, PaginatedResponse } from "../../../../types/common"
import { FlagRouter } from "../../../../utils/flag-router"
import middlewares, { transformQuery } from "../../../middlewares"
import { AdminGetOrdersParams } from "./list-orders"
@@ -230,12 +226,35 @@ export default (app, featureFlagRouter: FlagRouter) => {
return app
}
/**
* @schema AdminOrdersRes
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
*/
export type AdminOrdersRes = {
order: Order
}
export type AdminDeleteRes = DeleteResponse
/**
* @schema AdminOrdersListRes
* type: object
* properties:
* orders:
* type: array
* items:
* $ref: "#/components/schemas/Order"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
*/
export type AdminOrdersListRes = PaginatedResponse & {
orders: Order[]
}
@@ -361,4 +380,3 @@ export * from "./refund-payment"
export * from "./request-return"
export * from "./update-claim"
export * from "./update-order"
@@ -180,21 +180,7 @@ import { pick } from "lodash"
* content:
* application/json:
* schema:
* type: object
* properties:
* orders:
* type: array
* items:
* $ref: "#/components/schemas/Order"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminOrdersListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -39,10 +39,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -59,10 +59,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -77,10 +77,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -62,10 +62,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -62,10 +62,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* order:
* $ref: "#/components/schemas/Order"
* $ref: "#/components/schemas/AdminOrdersRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -35,19 +35,7 @@ import { PaymentCollectionService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Payment Collection.
* object:
* type: string
* description: The type of the object that was deleted.
* format: payment_collection
* deleted:
* type: boolean
* description: Whether or not the Payment Collection was deleted.
* default: true
* $ref: "#/components/schemas/AdminPaymentCollectionDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -38,10 +38,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* payment_collection:
* $ref: "#/components/schemas/PaymentCollection"
* $ref: "#/components/schemas/AdminPaymentCollectionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -62,9 +62,33 @@ export const defaulPaymentCollectionRelations = [
"payments",
]
/**
* @schema AdminPaymentCollectionsRes
* type: object
* properties:
* payment_collection:
* $ref: "#/components/schemas/PaymentCollection"
*/
export type AdminPaymentCollectionsRes = {
payment_collection: PaymentCollection
}
/**
* @schema AdminPaymentCollectionDeleteRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Payment Collection.
* object:
* type: string
* description: The type of the object that was deleted.
* default: payment_collection
* deleted:
* type: boolean
* description: Whether or not the Payment Collection was deleted.
* default: true
*/
export type AdminPaymentCollectionDeleteRes = {
id: string
object: "payment_collection"
@@ -36,10 +36,7 @@ import { PaymentCollectionService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* payment_collection:
* $ref: "#/components/schemas/PaymentCollection"
* $ref: "#/components/schemas/AdminPaymentCollectionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -49,10 +49,7 @@ import { PaymentCollectionService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* payment_collection:
* $ref: "#/components/schemas/PaymentCollection"
* $ref: "#/components/schemas/AdminPaymentCollectionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -35,10 +35,7 @@ import { PaymentService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* payment:
* $ref: "#/components/schemas/Payment"
* $ref: "#/components/schemas/AdminPaymentRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -36,10 +36,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* payment:
* $ref: "#/components/schemas/Payment"
* $ref: "#/components/schemas/AdminPaymentRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -52,10 +52,24 @@ export const defaultPaymentFields = [
"metadata",
]
/**
* @schema AdminPaymentRes
* type: object
* properties:
* payment:
* $ref: "#/components/schemas/Payment"
*/
export type AdminPaymentRes = {
payment: Payment
}
/**
* @schema AdminRefundRes
* type: object
* properties:
* refund:
* $ref: "#/components/schemas/Refund"
*/
export type AdminRefundRes = {
refund: Refund
}
@@ -59,10 +59,7 @@ import { PaymentService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* refund:
* $ref: "#/components/schemas/Refund"
* $ref: "#/components/schemas/AdminRefundRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -66,10 +66,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* price_list:
* $ref: "#/components/schemas/PriceList"
* $ref: "#/components/schemas/AdminPriceListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -83,10 +83,7 @@ import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators
* content:
* application/json:
* schema:
* type: object
* properties:
* price_list:
* $ref: "#/components/schemas/PriceList"
* $ref: "#/components/schemas/AdminPriceListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -36,19 +36,7 @@ import PriceListService from "../../../../services/price-list"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Price List.
* object:
* type: string
* description: The type of the object that was deleted.
* default: price-list
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminPriceListDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -54,21 +54,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* ids:
* type: array
* items:
* type: string
* description: The IDs of the deleted Money Amounts (Prices).
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminPriceListDeleteBatchRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -37,21 +37,7 @@ import PriceListService from "../../../../services/price-list"
* content:
* application/json:
* schema:
* type: object
* properties:
* ids:
* type: array
* description: The price ids that have been deleted.
* items:
* type: string
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminPriceListDeleteProductPricesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -37,21 +37,7 @@ import PriceListService from "../../../../services/price-list"
* content:
* application/json:
* schema:
* type: object
* properties:
* ids:
* type: array
* description: The price ids that have been deleted.
* items:
* type: string
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminPriceListDeleteVariantPricesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -38,10 +38,7 @@ import PriceListService from "../../../../services/price-list"
* content:
* application/json:
* schema:
* type: object
* properties:
* price_list:
* $ref: "#/components/schemas/PriceList"
* $ref: "#/components/schemas/AdminPriceListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -1,10 +1,10 @@
import { Router } from "express"
import "reflect-metadata"
import { PriceList } from "../../../.."
import { PriceList, Product } from "../../../.."
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
import middlewares, {
transformQuery,
transformBody,
transformQuery,
} from "../../../middlewares"
import { AdminGetPriceListPaginationParams } from "./list-price-lists"
import { AdminGetPriceListsPriceListProductsParams } from "./list-price-list-products"
@@ -93,25 +93,143 @@ export const defaultAdminPriceListFields = [
export const defaultAdminPriceListRelations = ["prices", "customer_groups"]
/**
* @schema AdminPriceListRes
* type: object
* properties:
* price_list:
* $ref: "#/components/schemas/PriceList"
*/
export type AdminPriceListRes = {
price_list: PriceList
}
/**
* @schema AdminPriceListDeleteBatchRes
* type: object
* properties:
* ids:
* type: array
* items:
* type: string
* description: The IDs of the deleted Money Amounts (Prices).
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminPriceListDeleteBatchRes = {
ids: string[]
deleted: boolean
object: string
}
/**
* @schema AdminPriceListDeleteProductPricesRes
* type: object
* properties:
* ids:
* type: array
* description: The price ids that have been deleted.
* items:
* type: string
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminPriceListDeleteProductPricesRes = AdminPriceListDeleteBatchRes
/**
* @schema AdminPriceListDeleteVariantPricesRes
* type: object
* properties:
* ids:
* type: array
* description: The price ids that have been deleted.
* items:
* type: string
* object:
* type: string
* description: The type of the object that was deleted.
* default: money-amount
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminPriceListDeleteVariantPricesRes = AdminPriceListDeleteBatchRes
/**
* @schema AdminPriceListDeleteRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Price List.
* object:
* type: string
* description: The type of the object that was deleted.
* default: price-list
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminPriceListDeleteRes = DeleteResponse
/**
* @schema AdminPriceListsListRes
* type: object
* properties:
* price_lists:
* type: array
* items:
* $ref: "#/components/schemas/PriceList"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
*/
export type AdminPriceListsListRes = PaginatedResponse & {
price_lists: PriceList[]
}
/**
* @schema AdminPriceListsProductsListRes
* type: object
* properties:
* products:
* type: array
* items:
* $ref: "#/components/schemas/Product"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
*/
export type AdminPriceListsProductsListRes = PaginatedResponse & {
products: Product[]
}
export * from "./add-prices-batch"
export * from "./create-price-list"
export * from "./delete-price-list"
@@ -160,21 +160,7 @@ import { isDefined } from "medusa-core-utils"
* content:
* application/json:
* schema:
* type: object
* properties:
* products:
* type: array
* items:
* $ref: "#/components/schemas/Product"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminPriceListsProductsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -141,21 +141,7 @@ import { Type } from "class-transformer"
* content:
* application/json:
* schema:
* type: object
* properties:
* price_lists:
* type: array
* items:
* $ref: "#/components/schemas/PriceList"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminPriceListsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
@@ -67,10 +67,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* price_list:
* $ref: "#/components/schemas/PriceList"
* $ref: "#/components/schemas/AdminPriceListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":