u
This commit is contained in:
@@ -56,15 +56,8 @@ export function register(app, basePath = '') {
|
||||
* The attributename id used for the article's variants. Omitting it while
|
||||
* enabling parent mode returns 400. Must be omitted when `isParent` is `false`.
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Updated article
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* article:
|
||||
* $ref: '#/components/schemas/Article'
|
||||
* 204:
|
||||
* description: Updated
|
||||
* 400:
|
||||
* description: |
|
||||
* Invalid input — `attributeNameId` missing while `isParent` is true, article still
|
||||
@@ -89,13 +82,13 @@ export function register(app, basePath = '') {
|
||||
const attributeNameId = req.body?.attributeNameId;
|
||||
|
||||
try {
|
||||
const result = await db.toggleParent(req.user.id, parsed.sku, {
|
||||
await db.toggleParent(req.user.id, parsed.sku, {
|
||||
isParent,
|
||||
attributeNameId,
|
||||
});
|
||||
emitArticleSignal(req, parsed.sku);
|
||||
emitArticlesSignal(req);
|
||||
res.status(200).json(result);
|
||||
res.status(204).end();
|
||||
} catch (error) {
|
||||
const status = articleErrorStatus(error);
|
||||
if (status === 500) console.error('Toggle parent failed:', error);
|
||||
@@ -196,8 +189,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* article:
|
||||
* $ref: '#/components/schemas/Article'
|
||||
* sku:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: Parent not configured as parent, missing value, duplicate variant, or sku was provided in body
|
||||
* put:
|
||||
@@ -237,14 +230,12 @@ export function register(app, basePath = '') {
|
||||
* description: Whether to allow re-parenting if child already belongs to another parent
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Attached child article and list of children
|
||||
* description: List of children after attaching
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* article:
|
||||
* $ref: '#/components/schemas/Article'
|
||||
* children:
|
||||
* type: array
|
||||
* items:
|
||||
@@ -275,7 +266,7 @@ export function register(app, basePath = '') {
|
||||
emitArticleSignal(req, result.article.sku);
|
||||
}
|
||||
emitArticlesSignal(req);
|
||||
res.status(201).json(result);
|
||||
res.status(201).json({ sku: result.article.sku });
|
||||
} catch (error) {
|
||||
const status = articleErrorStatus(error);
|
||||
if (status === 500) console.error('Add child failed:', error);
|
||||
@@ -303,7 +294,7 @@ export function register(app, basePath = '') {
|
||||
emitArticleSignal(req, parsed.sku);
|
||||
emitArticleSignal(req, childSku);
|
||||
emitArticlesSignal(req);
|
||||
res.status(200).json(result);
|
||||
res.status(200).json({ children: result.children });
|
||||
} catch (error) {
|
||||
const status = articleErrorStatus(error);
|
||||
if (status === 500) console.error('Attach child failed:', error);
|
||||
|
||||
Reference in New Issue
Block a user