From 8821f72962c369f4941bcd006437f966972ed53d Mon Sep 17 00:00:00 2001 From: ShihabMehboob Date: Mon, 5 Mar 2018 16:37:39 +0000 Subject: [PATCH] Updates to swift 4.1 (#14) - Resolves Coder.getFieldName(codingPath:) returning erroneous verbose output instead of a simple String value with Swift 4.1 --- .travis.yml | 9 +++++++++ Sources/KituraContracts/CodableQuery/Coder.swift | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b9f4871..fe18bd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,15 @@ matrix: - os: osx osx_image: xcode9.2 sudo: required + env: SWIFT_SNAPSHOT=4.0.3 + - os: linux + dist: trusty + sudo: required + env: SWIFT_SNAPSHOT=swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-06-a + - os: osx + osx_image: xcode9.2 + sudo: required + env: SWIFT_SNAPSHOT=swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-06-a before_install: - git clone https://github.com/IBM-Swift/Package-Builder.git diff --git a/Sources/KituraContracts/CodableQuery/Coder.swift b/Sources/KituraContracts/CodableQuery/Coder.swift index e8a3e47..dfc40cf 100644 --- a/Sources/KituraContracts/CodableQuery/Coder.swift +++ b/Sources/KituraContracts/CodableQuery/Coder.swift @@ -32,6 +32,10 @@ public class Coder { /// Helper method to extract the field name from a CodingKey array public static func getFieldName(from codingPath: [CodingKey]) -> String { - return codingPath.flatMap({"\($0)"}).joined(separator: ".") + #if swift(>=4.1) + return codingPath.compactMap({$0.stringValue}).joined(separator: ".") + #else + return codingPath.flatMap({$0.stringValue}).joined(separator: ".") + #endif } }