From 1f2506221ad7207b37bd093ca3233347d6d76ca1 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 27 Aug 2024 12:23:36 +0100 Subject: [PATCH] API: Updated docs with consistent types, fixed users response example For #5178 and #5183 --- app/Uploads/Controllers/AttachmentApiController.php | 8 ++++---- app/Users/Controllers/UserApiController.php | 13 +++++++------ dev/api/responses/users-list.json | 2 -- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Uploads/Controllers/AttachmentApiController.php b/app/Uploads/Controllers/AttachmentApiController.php index 9040ba6d3..87e00257c 100644 --- a/app/Uploads/Controllers/AttachmentApiController.php +++ b/app/Uploads/Controllers/AttachmentApiController.php @@ -171,16 +171,16 @@ class AttachmentApiController extends ApiController { return [ 'create' => [ - 'name' => ['required', 'min:1', 'max:255', 'string'], + 'name' => ['required', 'string', 'min:1', 'max:255'], 'uploaded_to' => ['required', 'integer', 'exists:pages,id'], 'file' => array_merge(['required_without:link'], $this->attachmentService->getFileValidationRules()), - 'link' => ['required_without:file', 'min:1', 'max:2000', 'safe_url'], + 'link' => ['required_without:file', 'string', 'min:1', 'max:2000', 'safe_url'], ], 'update' => [ - 'name' => ['min:1', 'max:255', 'string'], + 'name' => ['string', 'min:1', 'max:255'], 'uploaded_to' => ['integer', 'exists:pages,id'], 'file' => $this->attachmentService->getFileValidationRules(), - 'link' => ['min:1', 'max:2000', 'safe_url'], + 'link' => ['string', 'min:1', 'max:2000', 'safe_url'], ], ]; } diff --git a/app/Users/Controllers/UserApiController.php b/app/Users/Controllers/UserApiController.php index 1ccfecd73..6ee8f16d1 100644 --- a/app/Users/Controllers/UserApiController.php +++ b/app/Users/Controllers/UserApiController.php @@ -37,27 +37,28 @@ class UserApiController extends ApiController { return [ 'create' => [ - 'name' => ['required', 'min:2', 'max:100'], + 'name' => ['required', 'string', 'min:2', 'max:100'], 'email' => [ - 'required', 'min:2', 'email', new Unique('users', 'email'), + 'required', 'string', 'email', 'min:2', new Unique('users', 'email'), ], 'external_auth_id' => ['string'], 'language' => ['string', 'max:15', 'alpha_dash'], - 'password' => [Password::default()], + 'password' => ['string', Password::default()], 'roles' => ['array'], 'roles.*' => ['integer'], 'send_invite' => ['boolean'], ], 'update' => [ - 'name' => ['min:2', 'max:100'], + 'name' => ['string', 'min:2', 'max:100'], 'email' => [ - 'min:2', + 'string', 'email', + 'min:2', (new Unique('users', 'email'))->ignore($userId ?? null), ], 'external_auth_id' => ['string'], 'language' => ['string', 'max:15', 'alpha_dash'], - 'password' => [Password::default()], + 'password' => ['string', Password::default()], 'roles' => ['array'], 'roles.*' => ['integer'], ], diff --git a/dev/api/responses/users-list.json b/dev/api/responses/users-list.json index cbc7fb104..9cc2517b7 100644 --- a/dev/api/responses/users-list.json +++ b/dev/api/responses/users-list.json @@ -8,7 +8,6 @@ "updated_at": "2022-02-03T16:27:55.000000Z", "external_auth_id": "abc123456", "slug": "dan-brown", - "user_id": 1, "last_activity_at": "2022-02-03T16:27:55.000000Z", "profile_url": "https://docs.example.com/user/dan-brown", "edit_url": "https://docs.example.com/settings/users/1", @@ -22,7 +21,6 @@ "updated_at": "2021-11-18T17:10:58.000000Z", "external_auth_id": "", "slug": "benny", - "user_id": 2, "last_activity_at": "2022-01-31T20:39:24.000000Z", "profile_url": "https://docs.example.com/user/benny", "edit_url": "https://docs.example.com/settings/users/2",