apple / apple/swift-openapi-generator
Error when implementing a middleware with SWIFT_APPROACHABLE_CONCURRENCY
- Dominant language
- Swift
- Stars
- 2k
- Forks
- 182
- Avg merge
- 13h 28m
- Merged PRs (30d)
- 5
Description
### 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":
```swift
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
Contributor guide
Research direction
Start at the ClientMiddleware protocol and compare its intercept signature with the provided ApiKeyMiddleware implementation under Xcode 26 beta 5 and SWIFT_APPROACHABLE_CONCURRENCY. Reproduce the candidate mismatch using the example; done means determining whether the protocol, implementation, or Xcode/Swift behavior is responsible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100