Skip to content

Commit 8763ca0

Browse files
committed
unannotated path params are now handled properly
1 parent 5dd69c4 commit 8763ca0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

app/helpers/Swagger/AnnotationHelper.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ private static function extractStandardAnnotationParams(array $annotations, stri
126126
{
127127
$routeParams = self::getRoutePathParamNames($route);
128128

129+
///TODO: there can be unannotated query params as well
130+
129131
$params = [];
130132
foreach ($annotations as $annotation) {
131133
// assumed that all query parameters have a @param annotation
@@ -144,6 +146,9 @@ private static function extractStandardAnnotationParams(array $annotations, stri
144146
if (in_array($name, $routeParams)) {
145147
$location = 'path';
146148
$isPathParam = true;
149+
// remove the path param from the path param list to detect parameters left behind
150+
// (this happens when the path param does not have an annotation line)
151+
unset($routeParams[array_search($name, $routeParams)]);
147152
}
148153

149154
$swaggerType = self::getSwaggerType($annotationType);
@@ -164,6 +169,21 @@ private static function extractStandardAnnotationParams(array $annotations, stri
164169
$params[] = $descriptor;
165170
}
166171
}
172+
173+
// handle path params without annotations
174+
foreach ($routeParams as $pathParam) {
175+
$descriptor = new AnnotationParameterData(
176+
// some type needs to be assigned and string seems reasonable for a param without any info
177+
"string",
178+
$pathParam,
179+
null,
180+
"path",
181+
true,
182+
false,
183+
);
184+
$params[] = $descriptor;
185+
}
186+
167187
return $params;
168188
}
169189

0 commit comments

Comments
 (0)