Skip to content

Commit fe30201

Browse files
committed
Add has generic type filter
1 parent ed8d3da commit fe30201

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/SDK/Language/Kotlin.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Appwrite\SDK\Language;
44

55
use Appwrite\SDK\Language;
6+
use Twig\TwigFilter;
67

78
class Kotlin extends Language {
89

@@ -439,5 +440,37 @@ public function getFiles()
439440
],
440441
];
441442
}
443+
444+
public function getFilters(): array
445+
{
446+
return [
447+
new TwigFilter('hasGenericType', function (string $model, array $spec) {
448+
return $this->hasGenericType($model, $spec);
449+
}),
450+
];
451+
}
452+
453+
protected function hasGenericType(?string $model, array $spec): string
454+
{
455+
if (empty($model)) {
456+
return false;
457+
}
458+
459+
$model = $spec['definitions'][$model];
460+
461+
if ($model['additionalProperties']) {
462+
return true;
463+
}
464+
465+
foreach ($model['properties'] as $property) {
466+
if (!\array_key_exists('sub_schema', $property) || !$property['sub_schema']) {
467+
continue;
468+
}
469+
470+
return $this->hasGenericType($property['sub_schema'], $spec);
471+
}
472+
473+
return false;
474+
}
442475
}
443476

0 commit comments

Comments
 (0)