Skip to content

Commit 2e68464

Browse files
committed
Implementing more test cases
1 parent 8769bd2 commit 2e68464

4 files changed

Lines changed: 84 additions & 20 deletions

File tree

Annotations/AnnotationGenerator.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,12 +1561,13 @@ public function wrapStringWithQuotes(string $string, string $type, string $quote
15611561
*/
15621562
public function shouldIncludeDefault(string $type, string $default = NoDefaultValue::class): bool
15631563
{
1564-
if ($default === NoDefaultValue::class) {
1565-
return false;
1566-
}
1567-
1568-
// Don't use true or false for default if it's not a boolean type
1569-
if ($type !== 'boolean' && in_array(strtolower($default), ['false', 'true'])) {
1564+
if (
1565+
$default === NoDefaultValue::class
1566+
|| ($type === 'number' && !is_numeric($default))
1567+
|| ($type === 'integer' && !\ctype_digit($default))
1568+
|| ($type !== 'string' && $default === '')
1569+
|| ($type !== 'boolean' && in_array(strtolower($default), ['false', 'true']))
1570+
) {
15701571
return false;
15711572
}
15721573

OpenApiDocs.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class OpenApiDocs extends \Piwik\Plugin
1515
public const GENERATED_ANNOTATIONS_PATH = '/tmp/annotations/';
1616
public const EXAMPLE_RESPONSES_PATH = '/tmp/responses/';
1717
public const GENERATED_SPECS_PATH = '/tmp/specs/';
18+
public const AVAILABLE_PROPERTY_TYPES = ['string', 'number', 'integer', 'boolean', 'array', 'object', 'null'];
1819

1920
public function registerEvents()
2021
{

0 commit comments

Comments
 (0)