From 300b8d46f9bcbc6785703bf5ebd5328dc1784d70 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 24 Oct 2024 00:13:06 +1300 Subject: [PATCH] Fix model array subtypes --- src/SDK/Language/CLI.php | 4 ++++ src/SDK/Language/Dart.php | 4 ++++ src/SDK/Language/Deno.php | 3 +++ src/SDK/Language/DotNet.php | 4 ++++ src/SDK/Language/Go.php | 4 ++++ src/SDK/Language/JS.php | 4 ++++ src/SDK/Language/Kotlin.php | 3 +++ src/SDK/Language/Node.php | 4 ++++ src/SDK/Language/ReactNative.php | 4 ++++ src/SDK/Language/Swift.php | 4 ++++ src/SDK/Language/Web.php | 4 ++++ 11 files changed, 42 insertions(+) diff --git a/src/SDK/Language/CLI.php b/src/SDK/Language/CLI.php index 79b224cf7..d22c12e70 100644 --- a/src/SDK/Language/CLI.php +++ b/src/SDK/Language/CLI.php @@ -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', diff --git a/src/SDK/Language/Dart.php b/src/SDK/Language/Dart.php index eb0052fb6..ca9356906 100644 --- a/src/SDK/Language/Dart.php +++ b/src/SDK/Language/Dart.php @@ -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'; diff --git a/src/SDK/Language/Deno.php b/src/SDK/Language/Deno.php index 787cd7a54..10d8a5fe9 100644 --- a/src/SDK/Language/Deno.php +++ b/src/SDK/Language/Deno.php @@ -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', diff --git a/src/SDK/Language/DotNet.php b/src/SDK/Language/DotNet.php index a76ef40dd..ff9432a3b 100644 --- a/src/SDK/Language/DotNet.php +++ b/src/SDK/Language/DotNet.php @@ -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', diff --git a/src/SDK/Language/Go.php b/src/SDK/Language/Go.php index 76c70c96a..9c26e0dd1 100644 --- a/src/SDK/Language/Go.php +++ b/src/SDK/Language/Go.php @@ -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', diff --git a/src/SDK/Language/JS.php b/src/SDK/Language/JS.php index 14d50b8ad..7541e478d 100644 --- a/src/SDK/Language/JS.php +++ b/src/SDK/Language/JS.php @@ -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: diff --git a/src/SDK/Language/Kotlin.php b/src/SDK/Language/Kotlin.php index 53c4a24a2..764949528 100644 --- a/src/SDK/Language/Kotlin.php +++ b/src/SDK/Language/Kotlin.php @@ -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', diff --git a/src/SDK/Language/Node.php b/src/SDK/Language/Node.php index d6e0a072f..f7e819150 100644 --- a/src/SDK/Language/Node.php +++ b/src/SDK/Language/Node.php @@ -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: diff --git a/src/SDK/Language/ReactNative.php b/src/SDK/Language/ReactNative.php index d0b4cb8f6..6b00033f0 100644 --- a/src/SDK/Language/ReactNative.php +++ b/src/SDK/Language/ReactNative.php @@ -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: diff --git a/src/SDK/Language/Swift.php b/src/SDK/Language/Swift.php index 39b8dd85e..4487b8f4b 100644 --- a/src/SDK/Language/Swift.php +++ b/src/SDK/Language/Swift.php @@ -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', diff --git a/src/SDK/Language/Web.php b/src/SDK/Language/Web.php index 968fc1103..94b48343d 100644 --- a/src/SDK/Language/Web.php +++ b/src/SDK/Language/Web.php @@ -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: