Skip to content

Commit 9ed1b5e

Browse files
Merge pull request #328 from nextcloud/feat/response-list-no-limit
2 parents 2117d95 + 00e61c4 commit 9ed1b5e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

generate-spec.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,14 @@
545545
continue;
546546
}
547547

548+
$hasLimitParameter = false;
548549
foreach ($controllerMethod->parameters as $parameter) {
549550
if ($parameter->name !== 'limit') {
550551
continue;
551552
}
552553

554+
$hasLimitParameter = true;
555+
553556
if ($parameter->type->type !== 'integer') {
554557
Logger::debug($routeName . ': @param: ' . $parameter->name, 'Type was not an integer: ' . $parameter->type->type);
555558
continue;
@@ -560,6 +563,19 @@
560563
}
561564
}
562565

566+
foreach ($controllerMethod->responses as $response) {
567+
if ($response->type === null) {
568+
continue;
569+
}
570+
571+
// maxItems=0 is list<empty> which is just for the legacy [] empty response.
572+
if ($response->type->type === 'array' && $response->type->maxItems !== 0 && !$hasLimitParameter) {
573+
Logger::warning($routeName, 'The endpoint returns a list, but has no parameter to limit the number of items.');
574+
// Only show the warning once, even if multiple responses contain lists.
575+
break;
576+
}
577+
}
578+
563579
$operationId = [
564580
$tagName,
565581
...Helpers::splitOnUppercaseFollowedByNonUppercase($methodName)

0 commit comments

Comments
 (0)