Skip to content

Commit c8d7c14

Browse files
committed
fixup! refactor: enhance form update method with validation and permission checks
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent 82d69d4 commit c8d7c14

2 files changed

Lines changed: 10 additions & 48 deletions

File tree

lib/Controller/ApiController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ public function getForm(int $formId): DataResponse {
245245
}
246246

247247
/**
248-
* Updates a form with the given key-value pairs.
249-
* Handles validation, permission checks, and special cases (lock, unlock, owner transfer).
248+
* Updates a form with the given key-value pairs and handles validation,
249+
* permission checks, and special cases (lock, unlock, owner transfer)
250250
*
251251
* @param int $formId The ID of the form to update.
252252
* @param array<string, mixed> $keyValuePairs Key-value pairs to update on the form.
@@ -255,7 +255,7 @@ public function getForm(int $formId): DataResponse {
255255
* @throws OCSForbiddenException If the input is empty, forbidden keys are present, or the user is not allowed to modify the form.
256256
* @throws OCSNotFoundException If the form is not found.
257257
*
258-
* 200: Returns the ID of the updated form.
258+
* 200: Returns the ID of the updated form
259259
*/
260260
#[CORS()]
261261
#[NoAdminRequired()]
@@ -1651,7 +1651,7 @@ public function uploadFiles(int $formId, int $questionId, string $shareHash = ''
16511651
// private functions
16521652

16531653
/**
1654-
* Asserts that the given array of key-value pairs is not empty.
1654+
* Asserts that the given array of key-value pairs is not empty
16551655
*
16561656
* @param array $keyValuePairs The array of key-value pairs to check.
16571657
* @throws OCSForbiddenException If the array is empty.

openapi.json

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@
984984
},
985985
"patch": {
986986
"operationId": "api-update-form",
987-
"summary": "Writes the given key-value pairs into Database",
987+
"summary": "Updates a form with the given key-value pairs and handles validation, permission checks, and special cases (lock, unlock, owner transfer)",
988988
"description": "This endpoint allows CORS requests",
989989
"tags": [
990990
"api"
@@ -1006,7 +1006,7 @@
10061006
"properties": {
10071007
"keyValuePairs": {
10081008
"type": "object",
1009-
"description": "Array of key=>value pairs to update.",
1009+
"description": "Key-value pairs to update on the form.",
10101010
"additionalProperties": {
10111011
"type": "object"
10121012
}
@@ -1020,7 +1020,7 @@
10201020
{
10211021
"name": "formId",
10221022
"in": "path",
1023-
"description": "FormId of form to update",
1023+
"description": "The ID of the form to update.",
10241024
"required": true,
10251025
"schema": {
10261026
"type": "integer",
@@ -1039,46 +1039,8 @@
10391039
}
10401040
],
10411041
"responses": {
1042-
"200": {
1043-
"description": "the id of the updated form",
1044-
"content": {
1045-
"application/json": {
1046-
"schema": {
1047-
"type": "object",
1048-
"required": [
1049-
"ocs"
1050-
],
1051-
"properties": {
1052-
"ocs": {
1053-
"type": "object",
1054-
"required": [
1055-
"meta",
1056-
"data"
1057-
],
1058-
"properties": {
1059-
"meta": {
1060-
"$ref": "#/components/schemas/OCSMeta"
1061-
},
1062-
"data": {
1063-
"oneOf": [
1064-
{
1065-
"type": "integer",
1066-
"format": "int64"
1067-
},
1068-
{
1069-
"type": "string"
1070-
}
1071-
]
1072-
}
1073-
}
1074-
}
1075-
}
1076-
}
1077-
}
1078-
}
1079-
},
10801042
"400": {
1081-
"description": "Could not find new form owner",
1043+
"description": "If the new form owner cannot be found.",
10821044
"content": {
10831045
"application/json": {
10841046
"schema": {
@@ -1106,7 +1068,7 @@
11061068
}
11071069
},
11081070
"403": {
1109-
"description": "User is not allowed to modify the form",
1071+
"description": "If the input is empty, forbidden keys are present, or the user is not allowed to modify the form.",
11101072
"content": {
11111073
"application/json": {
11121074
"schema": {
@@ -1134,7 +1096,7 @@
11341096
}
11351097
},
11361098
"404": {
1137-
"description": "Form not found",
1099+
"description": "If the form is not found.",
11381100
"content": {
11391101
"application/json": {
11401102
"schema": {

0 commit comments

Comments
 (0)