From 86ebddc6b8adff948d8e0aa3fef74eaca02931ba Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 24 Oct 2024 02:11:54 +1300 Subject: [PATCH] Fix optional wrapping --- templates/apple/Sources/Client.swift.twig | 2 +- templates/swift/Sources/Client.swift.twig | 2 +- templates/swift/Sources/Enums/Enum.swift.twig | 7 +------ tests/Base.php | 17 +++++------------ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/templates/apple/Sources/Client.swift.twig b/templates/apple/Sources/Client.swift.twig index 1f11f898d..baa7adbcb 100644 --- a/templates/apple/Sources/Client.swift.twig +++ b/templates/apple/Sources/Client.swift.twig @@ -444,7 +444,7 @@ open class Client { encodedParams[key] = param } else if let encodable = param as? Encodable { encodedParams[key] = try encodable.toJson() - } else { + } else if let param = param { encodedParams[key] = String(describing: param) } } diff --git a/templates/swift/Sources/Client.swift.twig b/templates/swift/Sources/Client.swift.twig index c91d8314e..6cd23d78b 100644 --- a/templates/swift/Sources/Client.swift.twig +++ b/templates/swift/Sources/Client.swift.twig @@ -480,7 +480,7 @@ open class Client { encodedParams[key] = param } else if let encodable = param as? Encodable { encodedParams[key] = try encodable.toJson() - } else { + } else if let param = param { encodedParams[key] = String(describing: param) } } diff --git a/templates/swift/Sources/Enums/Enum.swift.twig b/templates/swift/Sources/Enums/Enum.swift.twig index 2f19e23c1..861905af8 100644 --- a/templates/swift/Sources/Enums/Enum.swift.twig +++ b/templates/swift/Sources/Enums/Enum.swift.twig @@ -1,6 +1,6 @@ import Foundation -public enum {{ enum.name | caseUcfirst | overrideIdentifier }}: String, CustomStringConvertible, Codable { +public enum {{ enum.name | caseUcfirst | overrideIdentifier }}: String, CustomStringConvertible { {%~ for value in enum.enum %} {%~ set key = enum.keys is empty ? value : enum.keys[loop.index0] %} case {{ key | caseEnumKey | escapeSwiftKeyword }} = "{{ value }}" @@ -9,9 +9,4 @@ public enum {{ enum.name | caseUcfirst | overrideIdentifier }}: String, CustomSt public var description: String { return rawValue } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) - } } diff --git a/tests/Base.php b/tests/Base.php index a731cd673..86422c7b2 100644 --- a/tests/Base.php +++ b/tests/Base.php @@ -139,18 +139,11 @@ public function setUp(): void $this->expectedOutput[] = $headers; - // Figure out if mock-server is running - $isMockAPIRunning = \strlen(\exec('docker ps | grep mock-server')) > 0; - - if (!$isMockAPIRunning) { - echo "Starting Mock API Server"; - - \exec(' - cd ./mock-server && \ - docker compose build && \ - docker compose up -d --force-recreate - '); - } + \exec(' + cd ./mock-server && \ + docker compose build && \ + docker compose up -d --force-recreate + '); } public function tearDown(): void