@@ -226,11 +226,6 @@ private function processParamsLoose(array $paramData)
226
226
{
227
227
// validate each param
228
228
foreach ($ paramData as $ param ) {
229
- ///TODO: path parameters are not checked yet
230
- if ($ param ->type == Type::Path) {
231
- continue ;
232
- }
233
-
234
229
$ paramValue = $ this ->getValueFromParamData ($ param );
235
230
236
231
// this throws when it does not conform
@@ -265,11 +260,6 @@ private function processParamsFormat(string $format, ?array $valueDictionary): M
265
260
$ value = null ;
266
261
// top-level format
267
262
if ($ valueDictionary === null ) {
268
- ///TODO: path parameters are not checked yet
269
- if ($ requestParamData ->type == Type::Path) {
270
- continue ;
271
- }
272
-
273
263
$ value = $ this ->getValueFromParamData ($ requestParamData );
274
264
// nested format
275
265
} else {
@@ -302,7 +292,7 @@ private function processParamsFormat(string $format, ?array $valueDictionary): M
302
292
}
303
293
304
294
/**
305
- * Calls either getPostField or getQueryField based on the provided metadata.
295
+ * Calls either getPostField, getQueryField or getPathField based on the provided metadata.
306
296
* @param \App\Helpers\MetaFormats\RequestParamData $paramData Metadata of the request parameter.
307
297
* @throws \App\Exceptions\InternalServerException Thrown when an unexpected parameter location was set.
308
298
* @return mixed Returns the value from the request.
@@ -314,6 +304,8 @@ private function getValueFromParamData(RequestParamData $paramData): mixed
314
304
return $ this ->getPostField ($ paramData ->name , required: $ paramData ->required );
315
305
case Type::Query:
316
306
return $ this ->getQueryField ($ paramData ->name , required: $ paramData ->required );
307
+ case Type::Path:
308
+ return $ this ->getPathField ($ paramData ->name );
317
309
default :
318
310
throw new InternalServerException ("Unknown parameter type: {$ paramData ->type ->name }" );
319
311
}
@@ -356,6 +348,15 @@ private function getQueryField($param, $required = true)
356
348
return $ value ;
357
349
}
358
350
351
+ private function getPathField ($ param )
352
+ {
353
+ $ value = $ this ->getParameter ($ param );
354
+ if ($ value === null ) {
355
+ throw new BadRequestException ("Missing required path field $ param " );
356
+ }
357
+ return $ value ;
358
+ }
359
+
359
360
protected function logUserAction ($ code = IResponse::S200_OK )
360
361
{
361
362
if ($ this ->getUser ()->isLoggedIn ()) {
0 commit comments