Skip to content

Commit

Permalink
unannotated path params are now handled properly
Browse files Browse the repository at this point in the history
  • Loading branch information
eceltov committed Jan 24, 2025
1 parent 5dd69c4 commit 8763ca0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/helpers/Swagger/AnnotationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ private static function extractStandardAnnotationParams(array $annotations, stri
{
$routeParams = self::getRoutePathParamNames($route);

///TODO: there can be unannotated query params as well

$params = [];
foreach ($annotations as $annotation) {
// assumed that all query parameters have a @param annotation
Expand All @@ -144,6 +146,9 @@ private static function extractStandardAnnotationParams(array $annotations, stri
if (in_array($name, $routeParams)) {
$location = 'path';
$isPathParam = true;
// remove the path param from the path param list to detect parameters left behind
// (this happens when the path param does not have an annotation line)
unset($routeParams[array_search($name, $routeParams)]);
}

$swaggerType = self::getSwaggerType($annotationType);
Expand All @@ -164,6 +169,21 @@ private static function extractStandardAnnotationParams(array $annotations, stri
$params[] = $descriptor;
}
}

// handle path params without annotations
foreach ($routeParams as $pathParam) {
$descriptor = new AnnotationParameterData(
// some type needs to be assigned and string seems reasonable for a param without any info
"string",
$pathParam,
null,
"path",
true,
false,
);
$params[] = $descriptor;
}

return $params;
}

Expand Down

0 comments on commit 8763ca0

Please sign in to comment.