Skip to content

Commit

Permalink
Merge pull request #966 from appwrite/fix-swift-double-optional
Browse files Browse the repository at this point in the history
Fix swift double optional
  • Loading branch information
christyjacob4 authored Aug 30, 2024
2 parents 3f12532 + 930bc43 commit d5653a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/SDK/Language/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,6 @@ protected function getPropertyType(array $property, array $spec, string $generic
$type = $this->getTypeName($property);
}

if (!$property['required']) {
$type .= '?';
}

return $type;
}

Expand Down
4 changes: 2 additions & 2 deletions templates/swift/Sources/Models/Model.swift.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class {{ definition | modelType(spec) | raw }} {

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


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

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

{%~ endfor %}
{%~ if definition.additionalProperties %}
Expand Down

0 comments on commit d5653a2

Please sign in to comment.