Skip to content

Commit ddb3837

Browse files
Merge pull request #15141 from nextcloud/bugfix/noid/more-accurtate-lists
fix(openapi): Be more accurate for non-empty-lists
2 parents 7b152e6 + 4d8660c commit ddb3837

13 files changed

+99
-36
lines changed

lib/Controller/SignalingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private function getFederationSettings(?Room $room): ?array {
274274
*
275275
* @param int $serverId ID of the signaling server
276276
* @psalm-param non-negative-int $serverId
277-
* @return DataResponse<Http::STATUS_OK, array<string, mixed>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{error: string, version?: string}, array{}>
277+
* @return DataResponse<Http::STATUS_OK, array{version: string, warning?: string, features?: non-empty-list<string>}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{error: string, version?: string}, array{}>
278278
*
279279
* 200: Welcome message returned
280280
* 404: Signaling server not found

lib/ResponseDefinitions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@
445445
* }
446446
*
447447
* @psalm-type TalkCapabilities = array{
448-
* features: list<string>,
449-
* features-local: list<string>,
448+
* features: non-empty-list<string>,
449+
* features-local: non-empty-list<string>,
450450
* config: array{
451451
* attachments: array{
452452
* allowed: bool,
@@ -502,7 +502,7 @@
502502
* hello-v2-token-key?: string,
503503
* },
504504
* },
505-
* config-local: array<string, list<string>>,
505+
* config-local: array<string, non-empty-list<string>>,
506506
* version: string,
507507
* }
508508
*/

lib/Signaling/Manager.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141

4242
/**
4343
* @param int $serverId
44-
* @return array{status: Http::STATUS_OK, data: array<string, mixed>}|array{status: Http::STATUS_INTERNAL_SERVER_ERROR, data: array{error: string, version?: string}}
44+
* @return array{status: Http::STATUS_OK, data: array{version: string, warning?: string, features?: non-empty-list<string>}}|array{status: Http::STATUS_INTERNAL_SERVER_ERROR, data: array{error: string, version?: string}}
4545
* @throws \OutOfBoundsException When the serverId is not found
4646
*/
4747
public function checkServerCompatibility(int $serverId): array {
@@ -144,7 +144,9 @@ public function checkServerCompatibility(int $serverId): array {
144144

145145
return [
146146
'status' => Http::STATUS_OK,
147-
'data' => $data,
147+
'data' => [
148+
'version' => $data['version'],
149+
],
148150
];
149151
} catch (ConnectException) {
150152
return [
@@ -175,6 +177,9 @@ public function isCompatibleSignalingServer(IResponse $response): bool {
175177
&& in_array('switchto', $features, true);
176178
}
177179

180+
/**
181+
* @return list<string>
182+
*/
178183
public function getSignalingServerMissingFeatures(IResponse $response): array {
179184
$featureHeader = $response->getHeader(self::FEATURE_HEADER);
180185
$features = explode(',', $featureHeader);

openapi-administration.json

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@
101101
"type": "array",
102102
"items": {
103103
"type": "string"
104-
}
104+
},
105+
"minItems": 1
105106
},
106107
"features-local": {
107108
"type": "array",
108109
"items": {
109110
"type": "string"
110-
}
111+
},
112+
"minItems": 1
111113
},
112114
"config": {
113115
"type": "object",
@@ -356,7 +358,8 @@
356358
"type": "array",
357359
"items": {
358360
"type": "string"
359-
}
361+
},
362+
"minItems": 1
360363
}
361364
},
362365
"version": {
@@ -1494,8 +1497,23 @@
14941497
},
14951498
"data": {
14961499
"type": "object",
1497-
"additionalProperties": {
1498-
"type": "object"
1500+
"required": [
1501+
"version"
1502+
],
1503+
"properties": {
1504+
"version": {
1505+
"type": "string"
1506+
},
1507+
"warning": {
1508+
"type": "string"
1509+
},
1510+
"features": {
1511+
"type": "array",
1512+
"items": {
1513+
"type": "string"
1514+
},
1515+
"minItems": 1
1516+
}
14991517
}
15001518
}
15011519
}

openapi-backend-recording.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
"type": "array",
3535
"items": {
3636
"type": "string"
37-
}
37+
},
38+
"minItems": 1
3839
},
3940
"features-local": {
4041
"type": "array",
4142
"items": {
4243
"type": "string"
43-
}
44+
},
45+
"minItems": 1
4446
},
4547
"config": {
4648
"type": "object",
@@ -289,7 +291,8 @@
289291
"type": "array",
290292
"items": {
291293
"type": "string"
292-
}
294+
},
295+
"minItems": 1
293296
}
294297
},
295298
"version": {

openapi-backend-signaling.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
"type": "array",
3535
"items": {
3636
"type": "string"
37-
}
37+
},
38+
"minItems": 1
3839
},
3940
"features-local": {
4041
"type": "array",
4142
"items": {
4243
"type": "string"
43-
}
44+
},
45+
"minItems": 1
4446
},
4547
"config": {
4648
"type": "object",
@@ -289,7 +291,8 @@
289291
"type": "array",
290292
"items": {
291293
"type": "string"
292-
}
294+
},
295+
"minItems": 1
293296
}
294297
},
295298
"version": {

openapi-backend-sipbridge.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@
7777
"type": "array",
7878
"items": {
7979
"type": "string"
80-
}
80+
},
81+
"minItems": 1
8182
},
8283
"features-local": {
8384
"type": "array",
8485
"items": {
8586
"type": "string"
86-
}
87+
},
88+
"minItems": 1
8789
},
8890
"config": {
8991
"type": "object",
@@ -332,7 +334,8 @@
332334
"type": "array",
333335
"items": {
334336
"type": "string"
335-
}
337+
},
338+
"minItems": 1
336339
}
337340
},
338341
"version": {

openapi-bots.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
"type": "array",
3535
"items": {
3636
"type": "string"
37-
}
37+
},
38+
"minItems": 1
3839
},
3940
"features-local": {
4041
"type": "array",
4142
"items": {
4243
"type": "string"
43-
}
44+
},
45+
"minItems": 1
4446
},
4547
"config": {
4648
"type": "object",
@@ -289,7 +291,8 @@
289291
"type": "array",
290292
"items": {
291293
"type": "string"
292-
}
294+
},
295+
"minItems": 1
293296
}
294297
},
295298
"version": {

openapi-federation.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@
7777
"type": "array",
7878
"items": {
7979
"type": "string"
80-
}
80+
},
81+
"minItems": 1
8182
},
8283
"features-local": {
8384
"type": "array",
8485
"items": {
8586
"type": "string"
86-
}
87+
},
88+
"minItems": 1
8789
},
8890
"config": {
8991
"type": "object",
@@ -332,7 +334,8 @@
332334
"type": "array",
333335
"items": {
334336
"type": "string"
335-
}
337+
},
338+
"minItems": 1
336339
}
337340
},
338341
"version": {

openapi-full.json

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,15 @@
235235
"type": "array",
236236
"items": {
237237
"type": "string"
238-
}
238+
},
239+
"minItems": 1
239240
},
240241
"features-local": {
241242
"type": "array",
242243
"items": {
243244
"type": "string"
244-
}
245+
},
246+
"minItems": 1
245247
},
246248
"config": {
247249
"type": "object",
@@ -490,7 +492,8 @@
490492
"type": "array",
491493
"items": {
492494
"type": "string"
493-
}
495+
},
496+
"minItems": 1
494497
}
495498
},
496499
"version": {
@@ -23185,8 +23188,23 @@
2318523188
},
2318623189
"data": {
2318723190
"type": "object",
23188-
"additionalProperties": {
23189-
"type": "object"
23191+
"required": [
23192+
"version"
23193+
],
23194+
"properties": {
23195+
"version": {
23196+
"type": "string"
23197+
},
23198+
"warning": {
23199+
"type": "string"
23200+
},
23201+
"features": {
23202+
"type": "array",
23203+
"items": {
23204+
"type": "string"
23205+
},
23206+
"minItems": 1
23207+
}
2319023208
}
2319123209
}
2319223210
}

0 commit comments

Comments
 (0)