From 4d8660cddc9932c71f645c516e379897f3cf7f5d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 19 May 2025 12:27:33 +0200 Subject: [PATCH] fix(openapi): Be more accurate for non-empty-lists Signed-off-by: Joas Schilling --- lib/Controller/SignalingController.php | 2 +- lib/ResponseDefinitions.php | 6 ++--- lib/Signaling/Manager.php | 9 +++++-- openapi-administration.json | 28 +++++++++++++++++---- openapi-backend-recording.json | 9 ++++--- openapi-backend-signaling.json | 9 ++++--- openapi-backend-sipbridge.json | 9 ++++--- openapi-bots.json | 9 ++++--- openapi-federation.json | 9 ++++--- openapi-full.json | 28 +++++++++++++++++---- openapi.json | 9 ++++--- src/types/openapi/openapi-administration.ts | 4 ++- src/types/openapi/openapi-full.ts | 4 ++- 13 files changed, 99 insertions(+), 36 deletions(-) diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 9e2c14b8e7e..07f14d760d0 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -274,7 +274,7 @@ private function getFederationSettings(?Room $room): ?array { * * @param int $serverId ID of the signaling server * @psalm-param non-negative-int $serverId - * @return DataResponse, array{}>|DataResponse|DataResponse + * @return DataResponse}, array{}>|DataResponse|DataResponse * * 200: Welcome message returned * 404: Signaling server not found diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 432feab143c..fcdb7a5b676 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -445,8 +445,8 @@ * } * * @psalm-type TalkCapabilities = array{ - * features: list, - * features-local: list, + * features: non-empty-list, + * features-local: non-empty-list, * config: array{ * attachments: array{ * allowed: bool, @@ -502,7 +502,7 @@ * hello-v2-token-key?: string, * }, * }, - * config-local: array>, + * config-local: array>, * version: string, * } */ diff --git a/lib/Signaling/Manager.php b/lib/Signaling/Manager.php index 61e36cce656..4482723cd49 100644 --- a/lib/Signaling/Manager.php +++ b/lib/Signaling/Manager.php @@ -41,7 +41,7 @@ public function __construct( /** * @param int $serverId - * @return array{status: Http::STATUS_OK, data: array}|array{status: Http::STATUS_INTERNAL_SERVER_ERROR, data: array{error: string, version?: string}} + * @return array{status: Http::STATUS_OK, data: array{version: string, warning?: string, features?: non-empty-list}}|array{status: Http::STATUS_INTERNAL_SERVER_ERROR, data: array{error: string, version?: string}} * @throws \OutOfBoundsException When the serverId is not found */ public function checkServerCompatibility(int $serverId): array { @@ -144,7 +144,9 @@ public function checkServerCompatibility(int $serverId): array { return [ 'status' => Http::STATUS_OK, - 'data' => $data, + 'data' => [ + 'version' => $data['version'], + ], ]; } catch (ConnectException) { return [ @@ -175,6 +177,9 @@ public function isCompatibleSignalingServer(IResponse $response): bool { && in_array('switchto', $features, true); } + /** + * @return list + */ public function getSignalingServerMissingFeatures(IResponse $response): array { $featureHeader = $response->getHeader(self::FEATURE_HEADER); $features = explode(',', $featureHeader); diff --git a/openapi-administration.json b/openapi-administration.json index 296501409c5..a15b611f13b 100644 --- a/openapi-administration.json +++ b/openapi-administration.json @@ -101,13 +101,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -356,7 +358,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { @@ -1494,8 +1497,23 @@ }, "data": { "type": "object", - "additionalProperties": { - "type": "object" + "required": [ + "version" + ], + "properties": { + "version": { + "type": "string" + }, + "warning": { + "type": "string" + }, + "features": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } } } } diff --git a/openapi-backend-recording.json b/openapi-backend-recording.json index cd97ffcfa1b..4a87c1fc612 100644 --- a/openapi-backend-recording.json +++ b/openapi-backend-recording.json @@ -34,13 +34,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -289,7 +291,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/openapi-backend-signaling.json b/openapi-backend-signaling.json index fb36d826425..cb0fdc30804 100644 --- a/openapi-backend-signaling.json +++ b/openapi-backend-signaling.json @@ -34,13 +34,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -289,7 +291,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/openapi-backend-sipbridge.json b/openapi-backend-sipbridge.json index 0f2820ca682..01317cbe0a9 100644 --- a/openapi-backend-sipbridge.json +++ b/openapi-backend-sipbridge.json @@ -77,13 +77,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -332,7 +334,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/openapi-bots.json b/openapi-bots.json index ffe940004c1..5f9062ebfdf 100644 --- a/openapi-bots.json +++ b/openapi-bots.json @@ -34,13 +34,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -289,7 +291,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/openapi-federation.json b/openapi-federation.json index 9c0cff9cd3a..0d744bceddf 100644 --- a/openapi-federation.json +++ b/openapi-federation.json @@ -77,13 +77,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -332,7 +334,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/openapi-full.json b/openapi-full.json index 264084bc4ca..d71f04436b4 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -235,13 +235,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -490,7 +492,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { @@ -23185,8 +23188,23 @@ }, "data": { "type": "object", - "additionalProperties": { - "type": "object" + "required": [ + "version" + ], + "properties": { + "version": { + "type": "string" + }, + "warning": { + "type": "string" + }, + "features": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } } } } diff --git a/openapi.json b/openapi.json index e8f1656c36d..da970682675 100644 --- a/openapi.json +++ b/openapi.json @@ -194,13 +194,15 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "features-local": { "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 }, "config": { "type": "object", @@ -449,7 +451,8 @@ "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 } }, "version": { diff --git a/src/types/openapi/openapi-administration.ts b/src/types/openapi/openapi-administration.ts index b3bd5849f2b..f07945cba82 100644 --- a/src/types/openapi/openapi-administration.ts +++ b/src/types/openapi/openapi-administration.ts @@ -751,7 +751,9 @@ export interface operations { ocs: { meta: components["schemas"]["OCSMeta"]; data: { - [key: string]: Record; + version: string; + warning?: string; + features?: string[]; }; }; }; diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index 0a59b481371..dcc88be685d 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -11164,7 +11164,9 @@ export interface operations { ocs: { meta: components["schemas"]["OCSMeta"]; data: { - [key: string]: Record; + version: string; + warning?: string; + features?: string[]; }; }; };