u
This commit is contained in:
@@ -85,26 +85,11 @@ export function register(app, basePath = '') {
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [attributevalues]
|
||||
* properties:
|
||||
* attributevalues:
|
||||
* type: array
|
||||
* description: Array of attribute value IDs (numbers) or objects with id or attributeValueId
|
||||
* items:
|
||||
* oneOf:
|
||||
* - type: integer
|
||||
* description: Attribute value ID
|
||||
* - type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* description: Attribute value ID
|
||||
* attributeValueId:
|
||||
* type: integer
|
||||
* description: Attribute value ID
|
||||
* sort:
|
||||
* type: integer
|
||||
* type: array
|
||||
* description: Array of attribute value IDs. Array order defines sort.
|
||||
* items:
|
||||
* type: integer
|
||||
* example: [166]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Updated category attribute values
|
||||
@@ -148,13 +133,10 @@ export function register(app, basePath = '') {
|
||||
return res.status(400).json({ error: idParsed.error });
|
||||
}
|
||||
|
||||
const valuesInput = req.body?.attributevalues ?? req.body?.attributeValues ?? req.body?.attribute_values ?? req.body?.values ?? req.body;
|
||||
if (!Array.isArray(valuesInput)) {
|
||||
return res.status(400).json({ error: 'attributevalues array required' });
|
||||
}
|
||||
if (!Array.isArray(req.body)) return res.status(400).json({ error: 'attributevalues array required' });
|
||||
|
||||
try {
|
||||
const attributevalues = await db.setByCategoryId(req.user.id, idParsed.id, valuesInput);
|
||||
const attributevalues = await db.setByCategoryId(req.user.id, idParsed.id, req.body);
|
||||
emitCategorySignal(req);
|
||||
res.json({ attributevalues });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user