Skip to content

Commit

Permalink
API: Updated docs with consistent types, fixed users response example
Browse files Browse the repository at this point in the history
For #5178 and #5183
  • Loading branch information
ssddanbrown committed Aug 27, 2024
1 parent 9f68ca5 commit 1f25062
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/Uploads/Controllers/AttachmentApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ protected function rules(): array
{
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'],
],
];
}
Expand Down
13 changes: 7 additions & 6 deletions app/Users/Controllers/UserApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,28 @@ protected function rules(int $userId = null): array
{
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'],
],
Expand Down
2 changes: 0 additions & 2 deletions dev/api/responses/users-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 1f25062

Please sign in to comment.