Skip to content

Make the input HTTPClient required #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all 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
10 changes: 8 additions & 2 deletions Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ import protocol Foundation.LocalizedError
///
/// Instantiate the transport:
///
/// let transport = AsyncHTTPClientTransport()
/// let httpClient = HTTPClient()
/// defer {
/// try! httpClient.syncShutdown()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'd use that too, but in this example I need to shut down from a defer, and I don't think I can call async functions from there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't see the full example in the unexpanded diff. Yeah, its annoying but that's probably the way to go for this example.

/// }
/// let transport = AsyncHTTPClientTransport(
/// configuration: .init(client: httpClient)
/// )
///
/// Create the base URL of the server to call using your client. If the server
/// URL was defined in the OpenAPI document, you find a generated method for it
Expand Down Expand Up @@ -75,7 +81,7 @@ public struct AsyncHTTPClientTransport: ClientTransport {
/// - Parameters:
/// - client: The underlying client used to perform HTTP operations.
/// - timeout: The request timeout, defaults to 1 minute.
public init(client: HTTPClient = .init(), timeout: TimeAmount = .minutes(1)) {
public init(client: HTTPClient, timeout: TimeAmount = .minutes(1)) {
self.client = client
self.timeout = timeout
}
Expand Down