From a25396d3ec8ce09f69f88d354ab38b1ffecf7b4c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 28 Aug 2024 00:05:28 +1200 Subject: [PATCH] Fix nested array types --- src/SDK/Language/CLI.php | 4 ++-- src/SDK/Language/Dart.php | 4 ++-- src/SDK/Language/Deno.php | 4 ++-- src/SDK/Language/DotNet.php | 4 ++-- src/SDK/Language/Go.php | 4 ++-- src/SDK/Language/Kotlin.php | 4 ++-- src/SDK/Language/Node.php | 4 ++-- src/SDK/Language/ReactNative.php | 4 ++-- src/SDK/Language/Swift.php | 4 ++-- src/SDK/Language/Web.php | 4 ++-- templates/swift/Sources/Models/Model.swift.twig | 1 - 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/SDK/Language/CLI.php b/src/SDK/Language/CLI.php index 79b224cf7..fb12bd2d4 100644 --- a/src/SDK/Language/CLI.php +++ b/src/SDK/Language/CLI.php @@ -294,8 +294,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_FILE => 'string', self::TYPE_BOOLEAN => 'boolean', self::TYPE_OBJECT => 'object', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? $this->getTypeName($parameter['array']) . '[]' + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? $this->getTypeName($parameter['items']) . '[]' : 'string[]', default => $parameter['type'], }; diff --git a/src/SDK/Language/Dart.php b/src/SDK/Language/Dart.php index eb0052fb6..519935b66 100644 --- a/src/SDK/Language/Dart.php +++ b/src/SDK/Language/Dart.php @@ -143,8 +143,8 @@ public function getTypeName(array $parameter, array $spec = []): string case self::TYPE_BOOLEAN: return 'bool'; case self::TYPE_ARRAY: - if (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) { - return 'List<' . $this->getTypeName($parameter['array']) . '>'; + if (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) { + return 'List<' . $this->getTypeName($parameter['items']) . '>'; } return 'List'; case self::TYPE_OBJECT: diff --git a/src/SDK/Language/Deno.php b/src/SDK/Language/Deno.php index 787cd7a54..7383eb71e 100644 --- a/src/SDK/Language/Deno.php +++ b/src/SDK/Language/Deno.php @@ -145,8 +145,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_STRING => 'string', self::TYPE_FILE => 'InputFile', self::TYPE_BOOLEAN => 'boolean', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? $this->getTypeName($parameter['array']) . '[]' + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? $this->getTypeName($parameter['items']) . '[]' : 'string[]', self::TYPE_OBJECT => 'object', default => $parameter['type'] diff --git a/src/SDK/Language/DotNet.php b/src/SDK/Language/DotNet.php index a76ef40dd..bb272fc6e 100644 --- a/src/SDK/Language/DotNet.php +++ b/src/SDK/Language/DotNet.php @@ -172,8 +172,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_STRING => 'string', self::TYPE_BOOLEAN => 'bool', self::TYPE_FILE => 'InputFile', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? 'List<' . $this->getTypeName($parameter['array']) . '>' + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? 'List<' . $this->getTypeName($parameter['items']) . '>' : 'List', self::TYPE_OBJECT => 'object', default => $parameter['type'] diff --git a/src/SDK/Language/Go.php b/src/SDK/Language/Go.php index 76c70c96a..ba469e80d 100644 --- a/src/SDK/Language/Go.php +++ b/src/SDK/Language/Go.php @@ -148,8 +148,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_STRING => 'string', self::TYPE_BOOLEAN => 'bool', self::TYPE_OBJECT => 'interface{}', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? '[]' . $this->getTypeName($parameter['array']) + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? '[]' . $this->getTypeName($parameter['items']) : '[]string', default => $parameter['type'], }; diff --git a/src/SDK/Language/Kotlin.php b/src/SDK/Language/Kotlin.php index 53c4a24a2..1bf896ada 100644 --- a/src/SDK/Language/Kotlin.php +++ b/src/SDK/Language/Kotlin.php @@ -118,8 +118,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_STRING => 'String', self::TYPE_FILE => 'InputFile', self::TYPE_BOOLEAN => 'Boolean', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? 'List<' . $this->getTypeName($parameter['array']) . '>' + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? 'List<' . $this->getTypeName($parameter['items']) . '>' : 'List', self::TYPE_OBJECT => 'Any', default => $parameter['type'], diff --git a/src/SDK/Language/Node.php b/src/SDK/Language/Node.php index d6e0a072f..cd6b25494 100644 --- a/src/SDK/Language/Node.php +++ b/src/SDK/Language/Node.php @@ -25,8 +25,8 @@ public function getTypeName(array $parameter, array $method = []): string case self::TYPE_NUMBER: return 'number'; case self::TYPE_ARRAY: - if (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) { - return $this->getTypeName($parameter['array']) . '[]'; + if (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) { + return $this->getTypeName($parameter['items']) . '[]'; } return 'string[]'; case self::TYPE_FILE: diff --git a/src/SDK/Language/ReactNative.php b/src/SDK/Language/ReactNative.php index d0b4cb8f6..70ac47090 100644 --- a/src/SDK/Language/ReactNative.php +++ b/src/SDK/Language/ReactNative.php @@ -141,8 +141,8 @@ public function getTypeName(array $parameter, array $spec = []): string case self::TYPE_NUMBER: return 'number'; case self::TYPE_ARRAY: - if (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) { - return $this->getTypeName($parameter['array']) . '[]'; + if (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) { + return $this->getTypeName($parameter['items']) . '[]'; } return 'string[]'; case self::TYPE_FILE: diff --git a/src/SDK/Language/Swift.php b/src/SDK/Language/Swift.php index 75b3b1f9a..4060f2160 100644 --- a/src/SDK/Language/Swift.php +++ b/src/SDK/Language/Swift.php @@ -313,8 +313,8 @@ public function getTypeName(array $parameter, array $spec = []): string self::TYPE_STRING => 'String', self::TYPE_FILE => 'InputFile', self::TYPE_BOOLEAN => 'Bool', - self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) - ? '[' . $this->getTypeName($parameter['array']) . ']' + self::TYPE_ARRAY => (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) + ? '[' . $this->getTypeName($parameter['items']) . ']' : '[Any]', self::TYPE_OBJECT => 'Any', default => $parameter['type'], diff --git a/src/SDK/Language/Web.php b/src/SDK/Language/Web.php index 968fc1103..330a7fcc6 100644 --- a/src/SDK/Language/Web.php +++ b/src/SDK/Language/Web.php @@ -190,8 +190,8 @@ public function getTypeName(array $parameter, array $method = []): string case self::TYPE_NUMBER: return 'number'; case self::TYPE_ARRAY: - if (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) { - return $this->getTypeName($parameter['array']) . '[]'; + if (!empty(($parameter['items'] ?? [])['type']) && !\is_array($parameter['items']['type'])) { + return $this->getTypeName($parameter['items']) . '[]'; } return 'string[]'; case self::TYPE_FILE: diff --git a/templates/swift/Sources/Models/Model.swift.twig b/templates/swift/Sources/Models/Model.swift.twig index 7b9de98b3..14a57dafb 100644 --- a/templates/swift/Sources/Models/Model.swift.twig +++ b/templates/swift/Sources/Models/Model.swift.twig @@ -11,7 +11,6 @@ public class {{ definition | modelType(spec) | raw }} { /// {{ property.description }} public let {{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }} - {%~ endfor %} {%~ if definition.additionalProperties %} /// Additional properties