Skip to content

Error when implementing a middleware with SWIFT_APPROACHABLE_CONCURRENCY #804

@joaocolaco

Description

@joaocolaco

Question

Since Xcode 26 beta 5 i cannot comply with the ClientMiddleware protocol of swift-openapi-runtime. The error that I got is Candidate has non-matching type '(HTTPRequest, HTTPBody?, URL, String, nonisolated(nonsending) @Sendable (HTTPRequest, HTTPBody?, URL) async throws -> (HTTPResponse, HTTPBody?)) async throws -> (HTTPResponse, HTTPBody?)' for a structure that seems (and was) to be well "made":

public struct ApiKeyMiddleware: ClientMiddleware {

   //The API key to login
    private let apiKey: String
    
    
    public init(apiKey: String) { self.apiKey = apiKey }

    public func intercept(
        _ request: HTTPRequest,
        body: HTTPBody?,
        baseURL: URL,
        operationID: String,
        next:  @Sendable (HTTPRequest, HTTPBody?, URL) async throws -> (
            HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?
        )
    ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
        var request = request
        request.headerFields[.init("x-goog-api-key")!] = self.apiKey
        return try await next(request, body, baseURL)
    }
}

Is this an Xcode/Swift bug or is there something that I'm missing?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportAdopter support requests.status/triageCollecting information required to triage the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions