Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model array subtypes #1003

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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