Skip to content

Commit d5653a2

Browse files
Merge pull request #966 from appwrite/fix-swift-double-optional
Fix swift double optional
2 parents 3f12532 + 930bc43 commit d5653a2

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/SDK/Language/Swift.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ protected function getPropertyType(array $property, array $spec, string $generic
526526
$type = $this->getTypeName($property);
527527
}
528528

529-
if (!$property['required']) {
530-
$type .= '?';
531-
}
532-
533529
return $type;
534530
}
535531

templates/swift/Sources/Models/Model.swift.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class {{ definition | modelType(spec) | raw }} {
99

1010
{%~ for property in definition.properties %}
1111
/// {{ property.description }}
12-
public let {{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }}
12+
public let {{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }}{% if not property.required %}?{% endif %}
1313

1414

1515
{%~ endfor %}
@@ -20,7 +20,7 @@ public class {{ definition | modelType(spec) | raw }} {
2020

2121
init(
2222
{%~ for property in definition.properties %}
23-
{{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %}
23+
{{ property.name | escapeSwiftKeyword | removeDollarSign }}: {{ property | propertyType(spec) | raw }}{% if not property.required %}?{% endif %}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %}
2424

2525
{%~ endfor %}
2626
{%~ if definition.additionalProperties %}

0 commit comments

Comments
 (0)