Skip to content

Commit ffee4a5

Browse files
committed
resolved some todos
1 parent a9a5764 commit ffee4a5

4 files changed

Lines changed: 7 additions & 8 deletions

File tree

app/helpers/MetaFormats/MetaFormatHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public static function createNameToFieldDefinitionsMap(string $className): array
154154
);
155155
}
156156

157-
///TODO: add base type (PHP type of the field) validators to $requestParamData
158157
$formats[$fieldName] = $requestParamData;
159158
}
160159

app/helpers/MetaFormats/MetaRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function getParameter(string $key): mixed
4343
* Returns a variable provided to the presenter via POST.
4444
* If no key is passed, returns the entire array.
4545
*/
46-
///TODO: how should null be handled?
4746
public function getPost(?string $key = null): mixed
4847
{
4948
if ($key === null) {

app/helpers/MetaFormats/RequestParamData.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function conformsToDefinition(mixed $value)
4444
{
4545
// check if null
4646
if ($value === null) {
47+
// optional parameters can be null
4748
if (!$this->required) {
48-
///TODO: what if a required param can be null? Does that mean that required & null is fine? How to check the required constrains then?
49-
//throw new InvalidArgumentException($this->name, "The parameter is required and cannot be null.");
5049
return true;
5150
}
5251

52+
// required parameters can be null only if explicitly nullable
5353
if (!$this->nullable) {
5454
throw new InvalidArgumentException(
5555
$this->name,
@@ -92,9 +92,10 @@ public function toAnnotationParameterData()
9292
);
9393
}
9494

95-
$swaggerType = "string";
95+
// determine swagger type
9696
$nestedArraySwaggerType = null;
9797
$swaggerType = $this->validators[0]::SWAGGER_TYPE;
98+
// extract array element type
9899
if ($this->validators[0] instanceof VArray) {
99100
$nestedArraySwaggerType = $this->validators[0]->getElementSwaggerType();
100101
}
@@ -105,7 +106,6 @@ public function toAnnotationParameterData()
105106
$exampleValue = $this->validators[0]->getExampleValue();
106107
}
107108

108-
///TODO: does not pass null
109109
return new AnnotationParameterData(
110110
$swaggerType,
111111
$this->name,

app/helpers/Swagger/AnnotationHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Helpers\Swagger;
44

5+
use App\Exceptions\InvalidArgumentException;
56
use App\Helpers\MetaFormats\MetaFormatHelper;
67
use App\V1Module\Router\MethodRoute;
78
use App\V1Module\RouterFactory;
@@ -113,7 +114,7 @@ private static function getSwaggerType(string $annotationType): string
113114
}
114115

115116
if (self::$typeMap[$typename] === null) {
116-
throw new \InvalidArgumentException("Error in getSwaggerType: Unknown typename: {$typename}");
117+
throw new InvalidArgumentException("Error in getSwaggerType: Unknown typename: {$typename}");
117118
}
118119

119120
$type = self::$typeMap[$typename];
@@ -161,7 +162,7 @@ private static function extractStandardAnnotationParams(array $annotations, stri
161162
$swaggerType = self::getSwaggerType($annotationType);
162163
$nullable = self::isDatatypeNullable($annotationType);
163164

164-
///TODO: how to find out the correct query type?
165+
// the array element type cannot be determined from standard @param annotations
165166
$nestedArraySwaggerType = null;
166167

167168
$descriptor = new AnnotationParameterData(

0 commit comments

Comments
 (0)