Skip to content

Commit f647cc8

Browse files
committed
feat: Warn about limit parameters missing boundaries
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 0723449 commit f647cc8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

generate-spec.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,21 @@
545545
continue;
546546
}
547547

548+
foreach ($controllerMethod->parameters as $parameter) {
549+
if ($parameter->name !== 'limit') {
550+
continue;
551+
}
552+
553+
if ($parameter->type->type !== 'integer') {
554+
Logger::debug($routeName . ': @param: ' . $parameter->name, 'Type was not an integer: ' . $parameter->type->type);
555+
continue;
556+
}
557+
558+
if ($parameter->type->minimum === null || $parameter->type->maximum === null) {
559+
Logger::warning($routeName . ': @param: ' . $parameter->name, 'A parameter to limit the results should have a minimum and maximum.');
560+
}
561+
}
562+
548563
$operationId = [
549564
$tagName,
550565
...Helpers::splitOnUppercaseFollowedByNonUppercase($methodName)

0 commit comments

Comments
 (0)