diff --git a/docs/api/openapi.json b/docs/api/openapi.json index 2913b12..f8d3df5 100644 --- a/docs/api/openapi.json +++ b/docs/api/openapi.json @@ -14479,7 +14479,7 @@ "/article/{sku}/father": { "post": { "summary": "Toggle father mode for an article", - "description": "Enables or disables father article status. Enabling requires specifying an attributeNameId; disabling requires the article to have zero children.", + "description": "Enables or disables father article status. Enabling requires specifying an\nattributeNameId; disabling requires the article to have zero children.\n\n`attributeNameId` is **conditionally required**: it is optional in the schema\nbecause it is only required when `isFather` is `true`. Omitting it (or passing\n`0`/a negative value) together with `isFather: true` returns `400`\n`attributeNameId is required to become a father article`. It must not be sent\nwhen `isFather` is `false`.\n", "tags": [ "Article" ], @@ -14515,7 +14515,7 @@ }, "attributeNameId": { "type": "integer", - "description": "Required when isFather is true. The attributename id for variants." + "description": "**Conditionally required when `isFather` is `true`** (required iff isFather=true).\nThe attributename id used for the article's variants. Omitting it while\nenabling father mode returns 400. Must be omitted when `isFather` is `false`.\n" } } } @@ -14539,7 +14539,7 @@ } }, "400": { - "description": "Invalid input or article still has children" + "description": "Invalid input, `attributeNameId` missing while `isFather` is true, article still\nhas children, article has stock/suppliers/a Stückliste/options, or the attribute is\nalready used by an ancestor father article.\n" }, "404": { "description": "Article or attribute name not found" diff --git a/docs/api/routes/article/_sku/father.md b/docs/api/routes/article/_sku/father.md index 27820f5..4de2268 100644 --- a/docs/api/routes/article/_sku/father.md +++ b/docs/api/routes/article/_sku/father.md @@ -4,7 +4,15 @@ Protected. Requires a valid session cookie (`credentials: 'include'`). Toggle father mode for an article -Enables or disables father article status. Enabling requires specifying an attributeNameId; disabling requires the article to have zero children. +Enables or disables father article status. Enabling requires specifying an +attributeNameId; disabling requires the article to have zero children. + +`attributeNameId` is **conditionally required**: it is optional in the schema +because it is only required when `isFather` is `true`. Omitting it (or passing +`0`/a negative value) together with `isFather: true` returns `400` +`attributeNameId is required to become a father article`. It must not be sent +when `isFather` is `false`. + ## Path parameters @@ -17,7 +25,7 @@ Enables or disables father article status. Enabling requires specifying an attri | Field | Required | Type | Description | |-------|----------|------|-------------| | `isFather` | yes | boolean | True to make article a father, false to revert to regular article | -| `attributeNameId` | no | integer | Required when isFather is true. The attributename id for variants. | +| `attributeNameId` | no | integer | **Conditionally required when `isFather` is `true`** (required iff isFather=true). The attributename id used for the article's variants. Omitting it while enabling father mode returns 400. Must be omitted when `isFather` is `false`. | ```json { @@ -46,7 +54,10 @@ Updated article | Status | Description | |--------|-------------| -| 400 | Invalid input or article still has children | +| 400 | Invalid input, `attributeNameId` missing while `isFather` is true, article still +has children, article has stock/suppliers/a Stückliste/options, or the attribute is +already used by an ancestor father article. + | | 404 | Article or attribute name not found | --- diff --git a/src/api/routes/article.js b/src/api/routes/article.js index 3059ff8..8e11565 100644 --- a/src/api/routes/article.js +++ b/src/api/routes/article.js @@ -1806,7 +1806,15 @@ export function register(app, basePath = '') { * /article/{sku}/father: * post: * summary: Toggle father mode for an article - * description: Enables or disables father article status. Enabling requires specifying an attributeNameId; disabling requires the article to have zero children. + * description: | + * Enables or disables father article status. Enabling requires specifying an + * attributeNameId; disabling requires the article to have zero children. + * + * `attributeNameId` is **conditionally required**: it is optional in the schema + * because it is only required when `isFather` is `true`. Omitting it (or passing + * `0`/a negative value) together with `isFather: true` returns `400` + * `attributeNameId is required to become a father article`. It must not be sent + * when `isFather` is `false`. * tags: * - Article * security: @@ -1831,7 +1839,10 @@ export function register(app, basePath = '') { * description: True to make article a father, false to revert to regular article * attributeNameId: * type: integer - * description: Required when isFather is true. The attributename id for variants. + * description: | + * **Conditionally required when `isFather` is `true`** (required iff isFather=true). + * The attributename id used for the article's variants. Omitting it while + * enabling father mode returns 400. Must be omitted when `isFather` is `false`. * responses: * 200: * description: Updated article @@ -1843,7 +1854,10 @@ export function register(app, basePath = '') { * article: * $ref: '#/components/schemas/Article' * 400: - * description: Invalid input or article still has children + * description: | + * Invalid input, `attributeNameId` missing while `isFather` is true, article still + * has children, article has stock/suppliers/a Stückliste/options, or the attribute is + * already used by an ancestor father article. * 404: * description: Article or attribute name not found */