diff --git a/.changeset/two-cats-stare.md b/.changeset/two-cats-stare.md new file mode 100644 index 0000000000..3154db4d51 --- /dev/null +++ b/.changeset/two-cats-stare.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): make prices optional param when updating a variant diff --git a/integration-tests/api/__tests__/admin/product.js b/integration-tests/api/__tests__/admin/product.js index ecf115a234..cec69f5992 100644 --- a/integration-tests/api/__tests__/admin/product.js +++ b/integration-tests/api/__tests__/admin/product.js @@ -2374,6 +2374,48 @@ describe("/admin/products", () => { }) }) + describe("POST /admin/products/:id/variants/:id", () => { + beforeEach(async () => { + await adminSeeder(dbConnection) + + await simpleProductFactory(dbConnection, { + id: "test-product-to-update", + variants: [ + { + id: "test-variant-to-update", + }, + ], + }) + }) + + afterEach(async () => { + const db = useDb() + await db.teardown() + }) + + it("successfully updates variant without prices", async () => { + const api = useApi() + + const res = await api + .post( + "/admin/products/test-product-to-update/variants/test-variant-to-update", + { + inventory_quantity: 10, + }, + { + headers: { + Authorization: "Bearer test_token", + }, + } + ) + .catch((err) => { + console.log(err) + }) + + expect(res.status).toEqual(200) + }) + }) + describe("GET /admin/products/tag-usage", () => { beforeEach(async () => { await productSeeder(dbConnection) diff --git a/packages/medusa/src/api/routes/admin/products/update-variant.ts b/packages/medusa/src/api/routes/admin/products/update-variant.ts index aec9018fff..221e6bbaff 100644 --- a/packages/medusa/src/api/routes/admin/products/update-variant.ts +++ b/packages/medusa/src/api/routes/admin/products/update-variant.ts @@ -310,6 +310,7 @@ export class AdminPostProductsProductVariantsVariantReq { metadata?: object @IsArray() + @IsOptional() @ValidateNested({ each: true }) @Type(() => ProductVariantPricesUpdateReq) prices: ProductVariantPricesUpdateReq[]