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 nested array types #962

Closed
wants to merge 2 commits into from
Closed
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: 2 additions & 2 deletions src/SDK/Language/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
};
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Deno.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<object>',
self::TYPE_OBJECT => 'object',
default => $parameter['type']
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Go.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
};
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Kotlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any>',
self::TYPE_OBJECT => 'Any',
default => $parameter['type'],
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/ReactNative.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion templates/swift/Sources/Models/Model.swift.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class {{ definition | modelType(spec) | raw }} {
/// {{ property.description }}
public let {{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }}{% if not property.required %}?{% endif %}


{%~ endfor %}
{%~ if definition.additionalProperties %}
/// Additional properties
Expand Down
Loading