diff --git a/Package.swift b/Package.swift index c1d69ba..21c12ed 100644 --- a/Package.swift +++ b/Package.swift @@ -35,7 +35,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-nio", from: "2.58.0"), - .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.19.0"), + .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"), .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), .package(url: "https://github.com/apple/swift-http-types", from: "1.0.0"), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), diff --git a/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift b/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift index d16220e..39b79d3 100644 --- a/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift +++ b/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift @@ -62,26 +62,27 @@ public struct AsyncHTTPClientTransport: ClientTransport { /// The HTTP client used for performing HTTP calls. public var client: HTTPClient - /// The default shared HTTP client. - /// - /// This is a workaround for the lack of a shared client - /// in AsyncHTTPClient. Do not use this value directly, outside of - /// the `Configuration.init(client:timeout:)` initializer, as it will - /// likely be removed in the future. - private static let sharedClient: HTTPClient = .init() - /// The default request timeout. public var timeout: TimeAmount /// Creates a new configuration with the specified client and timeout. /// - Parameters: /// - client: The underlying client used to perform HTTP operations. - /// Provide nil to use the shared internal client. /// - timeout: The request timeout, defaults to 1 minute. - public init(client: HTTPClient? = nil, timeout: TimeAmount = .minutes(1)) { - self.client = client ?? Self.sharedClient + public init(client: HTTPClient = .shared, timeout: TimeAmount = .minutes(1)) { + self.client = client self.timeout = timeout } + + /// Creates a new configuration with the specified client and timeout. + /// - Parameters: + /// - client: The underlying client used to perform HTTP operations. + /// Provide nil to use the shared client. + /// - timeout: The request timeout, defaults to 1 minute. + @available(*, deprecated, message: "Use the initializer with a non-optional client parameter.") + @_disfavoredOverload public init(client: HTTPClient? = nil, timeout: TimeAmount = .minutes(1)) { + self.init(client: client ?? .shared, timeout: timeout) + } } /// A request to be sent by the transport. @@ -174,8 +175,7 @@ public struct AsyncHTTPClientTransport: ClientTransport { let length: HTTPClientRequest.Body.Length switch body.length { case .unknown: length = .unknown - case .known(let count): - if let intValue = Int(exactly: count) { length = .known(intValue) } else { length = .unknown } + case .known(let count): length = .known(count) } clientRequest.body = .stream(body.map { .init(bytes: $0) }, length: length) } diff --git a/docker/docker-compose.2204.main.yaml b/docker/docker-compose.2204.main.yaml index b1443e6..323b063 100644 --- a/docker/docker-compose.2204.main.yaml +++ b/docker/docker-compose.2204.main.yaml @@ -10,7 +10,7 @@ services: test: image: *image environment: - - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors + # - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete