From 5da020af80b186ec5345e0c847b4b5e58f04395a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 30 Aug 2024 15:58:08 +1200 Subject: [PATCH 1/3] Revert "Fix swift double optional" This reverts commit 9e3496ee717bfe0d62ac26c72a6bd9ffc9a88e3e. --- templates/swift/Sources/Models/Model.swift.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/swift/Sources/Models/Model.swift.twig b/templates/swift/Sources/Models/Model.swift.twig index 7b9de98b3..bff420c4f 100644 --- a/templates/swift/Sources/Models/Model.swift.twig +++ b/templates/swift/Sources/Models/Model.swift.twig @@ -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 %} From 9fe113b7aba438f787ac37693dc7fada2310b40d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 30 Aug 2024 15:58:13 +1200 Subject: [PATCH 2/3] Revert "Fix double optional in init" This reverts commit 378e607c719686fd3f5d6828e61b3992f587771b. --- templates/swift/Sources/Models/Model.swift.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/swift/Sources/Models/Model.swift.twig b/templates/swift/Sources/Models/Model.swift.twig index bff420c4f..cc3fbe6be 100644 --- a/templates/swift/Sources/Models/Model.swift.twig +++ b/templates/swift/Sources/Models/Model.swift.twig @@ -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 %} From 930bc436621d357ee86b23118ac4b99f5a01e469 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 30 Aug 2024 16:23:44 +1200 Subject: [PATCH 3/3] Remove optional added in getType to account for some contexts not needing it --- src/SDK/Language/Swift.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/SDK/Language/Swift.php b/src/SDK/Language/Swift.php index 75b3b1f9a..39b8dd85e 100644 --- a/src/SDK/Language/Swift.php +++ b/src/SDK/Language/Swift.php @@ -526,10 +526,6 @@ protected function getPropertyType(array $property, array $spec, string $generic $type = $this->getTypeName($property); } - if (!$property['required']) { - $type .= '?'; - } - return $type; }