From 884b853e1f21815b3e1f39691e634c08354c3642 Mon Sep 17 00:00:00 2001 From: Tomek Cejner Date: Mon, 2 Nov 2015 14:20:15 +0100 Subject: [PATCH] Custom headers in Swift; base URL is nor modifyable --- .../src/main/resources/swift/APIs.mustache | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/APIs.mustache b/modules/swagger-codegen/src/main/resources/swift/APIs.mustache index 495752f624da..dbe41eb9c0a3 100644 --- a/modules/swagger-codegen/src/main/resources/swift/APIs.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/APIs.mustache @@ -7,8 +7,9 @@ import Foundation public class {{projectName}}API { - static let basePath = "{{basePath}}" - static var credential: NSURLCredential? + public static var basePath = "{{basePath}}" + public static var credential: NSURLCredential? + public static var customHeaders: [String:String] = [:] static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() } @@ -41,6 +42,14 @@ public class RequestBuilder { self.URLString = URLString self.parameters = parameters self.isBody = isBody + + addHeaders({{projectName}}API.customHeaders) + } + + public func addHeaders(aHeaders:[String:String]) { + for (header, value) in aHeaders { + headers[header] = value + } } public func execute(completion: (response: Response?, erorr: ErrorType?) -> Void) { }