Skip to content

Commit bca8e0e

Browse files
committed
Added missing required examples and fixed default logic
1 parent ab120dd commit bca8e0e

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

Annotations/AnnotationGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ public function buildParameterAnnotationData(string $methodName, string $paramNa
520520
$description = $this->normaliseDescriptionText($description);
521521

522522
$default = $paramMetadata['default'] ?? null;
523-
if (!is_string($default)) {
523+
if ($default === null) {
524+
$default = NoDefaultValue::class;
525+
} elseif (!is_string($default)) {
524526
$default = json_encode($default);
525527
}
526528

config/ParameterExamples.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'idSite:int|string|int[]' => 1,
55
'period:\'day\'|\'week\'|\'month\'|\'year\'|\'range\'' => 'day',
66
'period:"day"|"week"|"month"|"year"|"range"' => 'day',
7-
'date:string' => '2026-05-01',
7+
'date:string' => 'yesterday',
88
'idSite:int|string' => 1,
99
'apiModule:string' => 'VisitsSummary',
1010
'apiAction:string' => 'get',
@@ -146,9 +146,12 @@
146146
'verificationCode:string' => '123456',
147147
'delegatedManagement:bool' => true,
148148
'isEnabled:bool|int|string' => true,
149-
'clientId:string' => 'analytics-dashboard',
149+
'memberOf:string' => 'cn=matomo-users,ou=groups,dc=example,dc=org',
150+
'filter:string' => '(objectClass=person)',
151+
'initialIdSite:int' => 1,
152+
'clientId:string' => '0123456789abcdef0123456789abcdef',
150153
'grantTypes:string[]' => ['authorization_code'],
151-
'scope:string' => 'read:reports',
154+
'scope:string' => 'matomo:read',
152155
'active:string' => '1',
153156
'plugin:string' => 'HeatmapSessionRecording',
154157
'format:string' => 'html',
@@ -167,6 +170,14 @@
167170
1,
168171
2,
169172
],
173+
'sourceIdSites:integer|(integer|array<string>)' => [
174+
1,
175+
2,
176+
],
177+
'sourceIdSites:integer | (integer | array<string>)' => [
178+
1,
179+
2,
180+
],
170181
'timezone:string' => 'Pacific/Auckland',
171182
'currency:string' => 'NZD',
172183
'period:\'day\'|\'week\'|\'month\'|\'never\'' => 'never',

tests/Unit/AnnotationGeneratorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,16 @@ public function getTestDataForBuildParameterAnnotationData(): iterable
544544
'default' => 'false',
545545
'example' => '',
546546
]];
547+
yield 'should not include null as a default value' => ['someParam', [
548+
'default' => null,
549+
], [], [
550+
'name' => 'someParam',
551+
'types' => ['string' => null],
552+
'description' => '',
553+
'required' => 'false',
554+
'default' => 'Piwik\API\NoDefaultValue',
555+
'example' => '',
556+
]];
547557
yield 'should still count empty string as a default value' => ['someParam', [
548558
'default' => '',
549559
], [], [

0 commit comments

Comments
 (0)