Skip to content

Commit

Permalink
Merge pull request #2090 from nextcloud/fix/openapi/array-syntax
Browse files Browse the repository at this point in the history
fix(OpenAPI): Fix array syntaxes
  • Loading branch information
nickvergessen authored Nov 4, 2024
2 parents f000069 + 033b5d6 commit d4fdfa1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Capabilities implements ICapability {
*
* @return array{
* notifications: array{
* ocs-endpoints: string[],
* push: string[],
* admin-notifications: string[],
* ocs-endpoints: list<string>,
* push: list<string>,
* admin-notifications: list<string>,
* },
* }
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
* @param string $userId ID of the user
* @param string $shortMessage Subject of the notification
* @param string $longMessage Message of the notification
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, null, array{}>
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, null, array{}>
* @deprecated 30.0.0
*
* 200: Notification generated successfully
Expand Down
14 changes: 7 additions & 7 deletions lib/Controller/EndpointController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
* Get all notifications
*
* @param string $apiVersion Version of the API to use
* @return DataResponse<Http::STATUS_OK, NotificationsNotification[], array{'X-Nextcloud-User-Status': string}>|DataResponse<Http::STATUS_NO_CONTENT, null, array{X-Nextcloud-User-Status: string}>
* @return DataResponse<Http::STATUS_OK, list<NotificationsNotification>, array{'X-Nextcloud-User-Status': string}>|DataResponse<Http::STATUS_NO_CONTENT, null, array{X-Nextcloud-User-Status: string}>
*
* 200: Notifications returned
* 204: No app uses notifications
Expand Down Expand Up @@ -175,8 +175,8 @@ public function getNotification(string $apiVersion, int $id): DataResponse {
* Check if notification IDs exist
*
* @param string $apiVersion Version of the API to use
* @param int[] $ids IDs of the notifications to check
* @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, int[], array{}>
* @param list<int> $ids IDs of the notifications to check
* @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, list<int>, array{}>
*
* 200: Existing notification IDs returned
* 400: Too many notification IDs requested
Expand All @@ -195,10 +195,10 @@ public function confirmIdsForUser(string $apiVersion, array $ids): DataResponse
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$ids = array_unique(array_filter(array_map(
$ids = array_values(array_unique(array_filter(array_map(
static fn ($id) => is_numeric($id) ? (int)$id : 0,
$ids
)));
))));

$existingIds = $this->handler->confirmIdsForUser($this->getCurrentUser(), $ids);
return new DataResponse($existingIds, Http::STATUS_OK);
Expand All @@ -208,7 +208,7 @@ public function confirmIdsForUser(string $apiVersion, array $ids): DataResponse
* Delete a notification
*
* @param int $id ID of the notification
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, null, array{}>
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, null, array{}>
*
* 200: Notification deleted successfully
* 403: Deleting notification for impersonated user is not allowed
Expand Down Expand Up @@ -240,7 +240,7 @@ public function deleteNotification(int $id): DataResponse {
/**
* Delete all notifications
*
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, null, array{}>
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, null, array{}>
*
* 200: All notifications deleted successfully
* 403: Deleting notification for impersonated user is not allowed
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/PushController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
* @param string $pushTokenHash Hash of the push token
* @param string $devicePublicKey Public key of the device
* @param string $proxyServer Proxy server to be used
* @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED, NotificationsPushDevice, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED, NotificationsPushDevice, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, list<empty>, array{}>
*
* 200: Device was already registered
* 201: Device registered successfully
Expand Down Expand Up @@ -131,7 +131,7 @@ public function registerDevice(string $pushTokenHash, string $devicePublicKey, s
/**
* Remove a device from push notifications
*
* @return DataResponse<Http::STATUS_OK|Http::STATUS_ACCEPTED|Http::STATUS_UNAUTHORIZED, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_ACCEPTED|Http::STATUS_UNAUTHORIZED, list<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>
*
* 200: No device registered
* 202: Device removed successfully
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
* @param int $batchSetting How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4)
* @param string $soundNotification Enable sound for notifications ('yes' or 'no')
* @param string $soundTalk Enable sound for Talk notifications ('yes' or 'no')
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
*
* 200: Personal settings updated
*/
Expand All @@ -57,7 +57,7 @@ public function personal(int $batchSetting, string $soundNotification, string $s
* @param int $batchSetting How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4)
* @param string $soundNotification Enable sound for notifications ('yes' or 'no')
* @param string $soundTalk Enable sound for Talk notifications ('yes' or 'no')
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
*
* 200: Admin settings updated
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public function getById(int $id, string $user): INotification {
/**
* Confirm that the notification ids still exist for the user
*
* @param int[] $ids
* @return int[]
* @param list<int> $ids
* @return list<int>
*/
public function confirmIdsForUser(string $user, array $ids): array {
$query = $this->connection->getQueryBuilder();
Expand Down
2 changes: 1 addition & 1 deletion lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* subject: string,
* message: string,
* link: string,
* actions: NotificationsNotificationAction[],
* actions: list<NotificationsNotificationAction>,
* subjectRich?: string,
* subjectRichParameters?: array<string, NotificationsRichObjectParameter>,
* messageRich?: string,
Expand Down

0 comments on commit d4fdfa1

Please sign in to comment.