From 5d769ccad29486a285fa4818d8f0ccf2de30715e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 12 Jan 2023 21:35:13 +0200 Subject: [PATCH] chore(oas): fixed oas for product category endpoints and model (#3014) --- .../product-categories/create-product-category.ts | 14 +------------- .../product-categories/delete-product-category.ts | 10 ---------- .../product-categories/get-product-category.ts | 14 ++------------ .../product-categories/list-product-categories.ts | 14 ++------------ .../product-categories/update-product-category.ts | 14 +------------- packages/medusa/src/models/product-category.ts | 4 ++++ 6 files changed, 10 insertions(+), 60 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/product-categories/create-product-category.ts b/packages/medusa/src/api/routes/admin/product-categories/create-product-category.ts index de9860f994..22048a68b8 100644 --- a/packages/medusa/src/api/routes/admin/product-categories/create-product-category.ts +++ b/packages/medusa/src/api/routes/admin/product-categories/create-product-category.ts @@ -21,18 +21,6 @@ import { FindParams } from "../../../../types/common" * schema: * $ref: "#/components/schemas/AdminPostProductCategoriesReq" * x-codeSamples: - * - lang: JavaScript - * label: JS Client - * source: | - * import Medusa from "@medusajs/medusa-js" - * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * // must be previously logged in or use api token - * medusa.admin.productCategories.create({ - * name: 'Jeans', - * }) - * .then(({ productCategory }) => { - * console.log(productCategory.id); - * }); * - lang: Shell * label: cURL * source: | @@ -55,7 +43,7 @@ import { FindParams } from "../../../../types/common" * schema: * type: object * properties: - * productCategory: + * product_category: * $ref: "#/components/schemas/ProductCategory" * "400": * $ref: "#/components/responses/400_error" diff --git a/packages/medusa/src/api/routes/admin/product-categories/delete-product-category.ts b/packages/medusa/src/api/routes/admin/product-categories/delete-product-category.ts index 4ddf1521bf..3f0d5a9387 100644 --- a/packages/medusa/src/api/routes/admin/product-categories/delete-product-category.ts +++ b/packages/medusa/src/api/routes/admin/product-categories/delete-product-category.ts @@ -12,16 +12,6 @@ import { ProductCategoryService } from "../../../../services" * parameters: * - (path) id=* {string} The ID of the Product Category * x-codeSamples: - * - lang: JavaScript - * label: JS Client - * source: | - * import Medusa from "@medusajs/medusa-js" - * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * // must be previously logged in or use api token - * medusa.admin.productCategories.delete(product_category_id) - * .then(({ id, object, deleted }) => { - * console.log(id); - * }); * - lang: Shell * label: cURL * source: | diff --git a/packages/medusa/src/api/routes/admin/product-categories/get-product-category.ts b/packages/medusa/src/api/routes/admin/product-categories/get-product-category.ts index 07d54c908f..92fa17da4b 100644 --- a/packages/medusa/src/api/routes/admin/product-categories/get-product-category.ts +++ b/packages/medusa/src/api/routes/admin/product-categories/get-product-category.ts @@ -13,16 +13,6 @@ import { defaultAdminProductCategoryRelations } from "." * parameters: * - (path) id=* {string} The ID of the Product Category * x-codeSamples: - * - lang: JavaScript - * label: JS Client - * source: | - * import Medusa from "@medusajs/medusa-js" - * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * // must be previously logged in or use api token - * medusa.admin.productCategories.retrieve("pcat-id") - * .then(({ productCategory }) => { - * console.log(productCategory.id); - * }); * - lang: Shell * label: cURL * source: | @@ -32,7 +22,7 @@ import { defaultAdminProductCategoryRelations } from "." * - api_token: [] * - cookie_auth: [] * tags: - * - Category + * - Product Category * responses: * "200": * description: OK @@ -41,7 +31,7 @@ import { defaultAdminProductCategoryRelations } from "." * schema: * type: object * properties: - * productCategory: + * product_category: * $ref: "#/components/schemas/ProductCategory" * "400": * $ref: "#/components/responses/400_error" diff --git a/packages/medusa/src/api/routes/admin/product-categories/list-product-categories.ts b/packages/medusa/src/api/routes/admin/product-categories/list-product-categories.ts index bee1511fba..641448e00b 100644 --- a/packages/medusa/src/api/routes/admin/product-categories/list-product-categories.ts +++ b/packages/medusa/src/api/routes/admin/product-categories/list-product-categories.ts @@ -19,16 +19,6 @@ import { extendedFindParamsMixin } from "../../../../types/common" * - (query) offset=0 {integer} How many product categories to skip in the result. * - (query) limit=100 {integer} Limit the number of product categories returned. * x-codeSamples: - * - lang: JavaScript - * label: JS Client - * source: | - * import Medusa from "@medusajs/medusa-js" - * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * // must be previously logged in or use api token - * medusa.admin.productCategories.list() - * .then(({ product_category, limit, offset, count }) => { - * console.log(product_category.length); - * }); * - lang: Shell * label: cURL * source: | @@ -38,7 +28,7 @@ import { extendedFindParamsMixin } from "../../../../types/common" * - api_token: [] * - cookie_auth: [] * tags: - * - Product Categories + * - Product Category * responses: * 200: * description: OK @@ -47,7 +37,7 @@ import { extendedFindParamsMixin } from "../../../../types/common" * schema: * type: object * properties: - * product_category: + * product_categories: * type: array * items: * $ref: "#/components/schemas/ProductCategory" diff --git a/packages/medusa/src/api/routes/admin/product-categories/update-product-category.ts b/packages/medusa/src/api/routes/admin/product-categories/update-product-category.ts index 3a1ae2aa91..b3218fb7ce 100644 --- a/packages/medusa/src/api/routes/admin/product-categories/update-product-category.ts +++ b/packages/medusa/src/api/routes/admin/product-categories/update-product-category.ts @@ -21,18 +21,6 @@ import { FindParams } from "../../../../types/common" * schema: * $ref: "#/components/schemas/AdminPostProductCategoriesCategoryReq" * x-codeSamples: - * - lang: JavaScript - * label: JS Client - * source: | - * import Medusa from "@medusajs/medusa-js" - * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * // must be previously logged in or use api token - * medusa.admin.productCategories.update(categoryId, { - * name: 'Skinny Jeans' - * }) - * .then(({ productCategory }) => { - * console.log(productCategory.id); - * }); * - lang: Shell * label: cURL * source: | @@ -55,7 +43,7 @@ import { FindParams } from "../../../../types/common" * schema: * type: object * properties: - * productCategory: + * product_category: * $ref: "#/components/schemas/ProductCategory" * "400": * $ref: "#/components/responses/400_error" diff --git a/packages/medusa/src/models/product-category.ts b/packages/medusa/src/models/product-category.ts index 3155f2c768..f7a32129d8 100644 --- a/packages/medusa/src/models/product-category.ts +++ b/packages/medusa/src/models/product-category.ts @@ -96,6 +96,10 @@ export class ProductCategory extends SoftDeletableEntity { * items: * type: object * description: A product category object. + * parent_category_id: + * description: The ID of the parent category. + * type: string + * default: null * parent_category: * description: A product category object. Available if the relation `parent_category` is expanded. * type: object