Skip to content

Commit

Permalink
Merge pull request #1003 from appwrite/fix-nested-types
Browse files Browse the repository at this point in the history
Fix model array subtypes
  • Loading branch information
abnegate authored Nov 6, 2024
2 parents ff4a0cc + 300b8d4 commit 42d8d99
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SDK/Language/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER,
self::TYPE_NUMBER => 'number',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return 'enums.' . \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
switch ($parameter['type'] ?? '') {
case self::TYPE_INTEGER:
return 'int';
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Language/Deno.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER => 'number',
self::TYPE_STRING => 'string',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return 'Appwrite.Enums.' . \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER => 'long',
self::TYPE_NUMBER => 'double',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/Go.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (str_contains($parameter['description'] ?? '', 'Collection attributes') || str_contains($parameter['description'] ?? '', 'List of attributes')) {
return '[]map[string]any';
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER => 'int',
self::TYPE_NUMBER => 'float64',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
switch ($parameter['type']) {
case self::TYPE_INTEGER:
case self::TYPE_NUMBER:
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Language/Kotlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return 'io.appwrite.enums.' . \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER => 'Long',
self::TYPE_NUMBER => 'Double',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public function getTypeName(array $parameter, array $method = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
switch ($parameter['type']) {
case self::TYPE_INTEGER:
case self::TYPE_NUMBER:
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/ReactNative.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
switch ($parameter['type']) {
case self::TYPE_INTEGER:
case self::TYPE_NUMBER:
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public function getTypeName(array $parameter, array $spec = []): string
if (!empty($parameter['enumValues'])) {
return ($spec['title'] ?? '') . 'Enums.' . \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
return match ($parameter['type']) {
self::TYPE_INTEGER => 'Int',
self::TYPE_NUMBER => 'Double',
Expand Down
4 changes: 4 additions & 0 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ public function getTypeName(array $parameter, array $method = []): string
if (!empty($parameter['enumValues'])) {
return \ucfirst($parameter['name']);
}
if (isset($parameter['items'])) {
// Map definition nested type to parameter nested type
$parameter['array'] = $parameter['items'];
}
switch ($parameter['type']) {
case self::TYPE_INTEGER:
case self::TYPE_NUMBER:
Expand Down

0 comments on commit 42d8d99

Please sign in to comment.