From 82bb5a024174c1dd8df06237a5a73f18d1cec772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20B=C3=B8geskov?= Date: Wed, 11 Dec 2024 11:37:26 +0100 Subject: [PATCH] HeaderProvider is async (#152) --- Sources/SwaggerSwiftCore/API Factory/APIFactory.swift | 2 +- .../API Request Factory/Models/APIRequest+Swiftable.swift | 2 +- Sources/SwaggerSwiftCore/Static Files/APIInitializeFile.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwaggerSwiftCore/API Factory/APIFactory.swift b/Sources/SwaggerSwiftCore/API Factory/APIFactory.swift index 82b5653..feec11e 100644 --- a/Sources/SwaggerSwiftCore/API Factory/APIFactory.swift +++ b/Sources/SwaggerSwiftCore/API Factory/APIFactory.swift @@ -207,7 +207,7 @@ struct APIFactory { if hasGlobalHeaders { fields.append(APIDefinitionField(name: "headerProvider", description: "a block provider for the set of globally defined headers", - typeName: "() -> any GlobalHeaders", + typeName: "() async -> any GlobalHeaders", isRequired: true, typeIsAutoclosure: false, typeIsBlock: true, diff --git a/Sources/SwaggerSwiftCore/API Request Factory/Models/APIRequest+Swiftable.swift b/Sources/SwaggerSwiftCore/API Request Factory/Models/APIRequest+Swiftable.swift index 82eb142..1a2fec7 100644 --- a/Sources/SwaggerSwiftCore/API Request Factory/Models/APIRequest+Swiftable.swift +++ b/Sources/SwaggerSwiftCore/API Request Factory/Models/APIRequest+Swiftable.swift @@ -35,7 +35,7 @@ extension APIRequest { var globalHeaders = [String]() if swaggerFile.globalHeaders.count > 0 { - globalHeaders.append("let globalHeaders = self.headerProvider()") + globalHeaders.append("let globalHeaders = await self.headerProvider()") globalHeaders.append("globalHeaders.add(to: &request)") } diff --git a/Sources/SwaggerSwiftCore/Static Files/APIInitializeFile.swift b/Sources/SwaggerSwiftCore/Static Files/APIInitializeFile.swift index 6be33e3..7972bd6 100644 --- a/Sources/SwaggerSwiftCore/Static Files/APIInitializeFile.swift +++ b/Sources/SwaggerSwiftCore/Static Files/APIInitializeFile.swift @@ -5,7 +5,7 @@ import Foundation public protocol APIInitialize { init(urlSession: @escaping () -> URLSession, baseUrlProvider: @escaping () -> URL, - headerProvider: @escaping () -> any GlobalHeaders, + headerProvider: @escaping () async -> any GlobalHeaders, interceptor: (any NetworkInterceptor)? ) }