Skip to content

Commit

Permalink
add missing status descriptions
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hartmann <[email protected]>
  • Loading branch information
Chartman123 committed Oct 28, 2024
1 parent c0299b4 commit cfcde6b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 29 deletions.
46 changes: 44 additions & 2 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public function preflightedCors() {
* - `shared`: Forms shared with the user.
* @return DataResponse<Http::STATUS_OK, array<FormsPartialForm>, array{}>
* @throws OCSBadRequestException wrong form type supplied
*
* 200: Array containing the partial owned or shared forms
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -158,6 +160,8 @@ public function getForms(string $type = 'owned'): DataResponse {
* @param ?int $fromId (optional) Id of the form that should be cloned
* @return DataResponse<Http::STATUS_CREATED, FormsForm, array{}>
* @throws OCSForbiddenException The user is not allowed to create forms
*
* 201: the created form
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -234,6 +238,8 @@ public function newForm(?int $fromId = null): DataResponse {
* @return DataResponse<Http::STATUS_OK, array<FormsForm>, array{}>
* @throws OCSBadRequestException Could not find form
* @throws OCSForbiddenException User has no permissions to get this form
*
* 200: the requested form
*/
#[CORS()]
#[NoAdminRequired()]
Expand All @@ -259,12 +265,14 @@ public function getForm(int $formId): DataResponse {
*
* @param int $formId FormId of form to update
* @param array<string, mixed> $keyValuePairs Array of key=>value pairs to update.
* @return DataResponse<Http::STATUS_OK, int, array{}>
* @return DataResponse<Http::STATUS_OK, int|string, array{}>
* @throws OCSBadRequestException Could not find new form owner
* @throws OCSForbiddenException Empty keyValuePairs provided
* @throws OCSForbiddenException Not allowed to update id, hash, created, fileId or lastUpdated. OwnerId only allowed if no other key provided.
* @throws OCSForbiddenException User is not allowed to modify the form
* @throws OCSNotFoundException Form not found
*
* 200: the id of the updated form
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -324,7 +332,7 @@ public function updateForm(int $formId, array $keyValuePairs): DataResponse {
}

// Process file unlinking
if (key_exists('fileId', $keyValuePairs) && key_exists('fileFormat', $keyValuePairs) && !isset($keyValuePairs['fileId']) && !isset($keyValuePairs['fileFormat'])) {
if (key_exists('fileId', $keyValuePairs) && key_exists('fileFormat', $keyValuePairs) && !isset($keyValuePairs['fileFormat'])) {

Check warning on line 335 in lib/Controller/ApiController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/ApiController.php#L335

Added line #L335 was not covered by tests
$form->setFileId(null);
$form->setFileFormat(null);
}
Expand Down Expand Up @@ -352,6 +360,8 @@ public function updateForm(int $formId, array $keyValuePairs): DataResponse {
* @return DataResponse<Http::STATUS_OK, int, array{}>
* @throws OCSForbiddenException User is not allowed to delete the form
* @throws OCSNotFoundException Form not found
*
* 200: the id of the deleted form
*/
#[CORS()]
#[NoAdminRequired()]
Expand All @@ -375,6 +385,8 @@ public function deleteForm(int $formId): DataResponse {
* @return DataResponse<Http::STATUS_OK, array<FormsQuestion>, array{}>
* @throws OCSForbiddenException User has no permissions to get this form
* @throws OCSNotFoundException Could not find form
*
* 200: the questions of the given form
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -406,6 +418,8 @@ public function getQuestions(int $formId): DataResponse {
* @throws OCSBadRequestException Question doesn\'t belong to given Form
* @throws OCSForbiddenException User has no permissions to get this form
* @throws OCSNotFoundException Could not find form
*
* 200: the requested question
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -446,6 +460,8 @@ public function getQuestion(int $formId, int $questionId): DataResponse {
* @throws OCSForbiddenException This form is archived and can not be modified
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 201: the created question
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -559,6 +575,8 @@ public function newQuestion(int $formId, ?string $type = null, string $text = ''
* @throws OCSForbiddenException User has no permissions to get this form
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 200: the id of the updated question
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -631,6 +649,8 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
* @throws OCSForbiddenException User has no permissions to get this form
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 200: the id of the deleted question
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -693,6 +713,8 @@ public function deleteQuestion(int $formId, int $questionId): DataResponse {
* @throws OCSForbiddenException User has no permissions to get this form
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 200: the question ids of the given form in the new order
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -788,6 +810,8 @@ public function reorderQuestions(int $formId, array $newOrder): DataResponse {
* @throws OCSForbiddenException Current user has no permission to edit
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 201: the created option
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -866,6 +890,8 @@ public function newOption(int $formId, int $questionId, array $optionTexts): Dat
* @throws OCSForbiddenException Not allowed to update id or questionId
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find option or question
*
* 200: the id of the updated option
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -933,6 +959,8 @@ public function updateOption(int $formId, int $questionId, int $optionId, array
* @throws OCSForbiddenException Current user has no permission to edit
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question or option
*
* 200: the id of the deleted option
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -990,6 +1018,8 @@ public function deleteOption(int $formId, int $questionId, int $optionId): DataR
* @throws OCSForbiddenException Current user has no permission to edit
* @throws OCSNotFoundException Could not find form
* @throws OCSNotFoundException Could not find question
*
* 200: the options of the question in the new order
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1085,6 +1115,8 @@ public function reorderOptions(int $formId, int $questionId, array $newOrder) {
* @return DataResponse<Http::STATUS_OK, FormsSubmissions, array{}>|DataDownloadResponse<Http::STATUS_OK, 'text/csv'|'application/vnd.oasis.opendocument.spreadsheet'|'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', array{}>
* @throws OCSNotFoundException Could not find form
* @throws OCSForbiddenException The current user has no permission to get the results for this form
*
* 200: the submissions of the form
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1146,6 +1178,8 @@ public function getSubmissions(int $formId, ?string $fileFormat = null): DataRes
* @return DataResponse<Http::STATUS_OK, int, array{}>
* @throws OCSNotFoundException Could not find form
* @throws OCSForbiddenException This form is not owned by the current user and user has no `results_delete` permission
*
* 200: the form id of the deleted submission
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1188,6 +1222,8 @@ public function deleteAllSubmissions(int $formId): DataResponse {
* @throws OCSForbiddenException This form is no longer taking answers
* @throws OCSForbiddenException This form is not owned by the current user and user has no `results_delete` permission
* @throws OCSNotFoundException Could not find form
*
* 201: empty response
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1284,6 +1320,8 @@ public function newSubmission(int $formId, array $answers, string $shareHash = '
* @throws OCSBadRequestException Submission doesn't belong to given form
* @throws OCSNotFoundException Could not find form or submission
* @throws OCSForbiddenException This form is not owned by the current user and user has no `results_delete` permission
*
* 200: the id of the deleted submission
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1328,6 +1366,8 @@ public function deleteSubmission(int $formId, int $submissionId): DataResponse {
* @return DataResponse<Http::STATUS_OK, string, array{}>
* @throws OCSForbiddenException The current user has no permission to get the results for this form
* @throws OCSNotFoundException Could not find form
*
* 200: the file name used for storing the submissions
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -1365,6 +1405,8 @@ public function exportSubmissionsToCloud(int $formId, string $path, string $file
* @throws OCSBadRequestException File type is not allowed
* @throws OCSForbiddenException Already submitted
* @throws OCSNotFoundException Could not find question
*
* 200: the file id and name of the uploaded file
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down
6 changes: 6 additions & 0 deletions lib/Controller/ShareApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public function __construct(
* @throws OCSForbiddenException Link share not allowed
* @throws OCSForbiddenException This form is not owned by the current user
* @throws OCSNotFoundException Could not find form
*
* 201: the created share
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -237,6 +239,8 @@ public function newShare(int $formId, int $shareType, string $shareWith = '', ar
* @throws OCSForbiddenException Empty keyValuePairs, will not update
* @throws OCSForbiddenException Not allowed to update other properties than permissions
* @throws OCSNotFoundException Could not find share
*
* 200: the id of the updated share
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down Expand Up @@ -329,6 +333,8 @@ public function updateShare(int $formId, int $shareId, array $keyValuePairs): Da
* @throws OCSBadRequestException Share doesn't belong to given Form
* @throws OCSForbiddenException This form is not owned by the current user
* @throws OCSNotFoundException Could not find share
*
* 200: the id of the deleted share
*/
#[CORS()]
#[NoAdminRequired()]
Expand Down
2 changes: 1 addition & 1 deletion lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
* submitMultiple: bool,
* showExpiration: bool,
* canSubmit: bool,
* permissions: array<string>,
* permissions: string[],
* questions: array<FormsQuestion>,
* state: int,
* shares: string[],
Expand Down
Loading

0 comments on commit cfcde6b

Please sign in to comment.