Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import PackageDescription
let package = Package(
name: "swift-openapi-urlsession",
platforms: [
.macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9),
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6),
],
products: [
.library(
Expand Down
16 changes: 12 additions & 4 deletions Sources/OpenAPIURLSession/URLSessionTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,18 @@ public struct URLSessionTransport: ClientTransport {
}

private func invokeSession(_ urlRequest: URLRequest) async throws -> (Data, URLResponse) {
#if canImport(FoundationNetworking)
#if canImport(FoundationNetworking)
return try await performDataTask(with: urlRequest)
#else
if #available(iOS 15.0, *) {
return try await configuration.session.data(for: urlRequest)
} else {
return try await performDataTask(with: urlRequest)
}
#endif
}

private func performDataTask(with urlRequest: URLRequest) async throws -> (Data, URLResponse) {
return try await withCheckedThrowingContinuation { continuation in
configuration.session
.dataTask(with: urlRequest) { data, response, error in
Expand All @@ -104,9 +115,6 @@ public struct URLSessionTransport: ClientTransport {
}
.resume()
}
#else
return try await configuration.session.data(for: urlRequest)
#endif
}
}

Expand Down