Skip to content

Commit 72c8605

Browse files
authored
Merge branch 'main' into hd-windows-ci
2 parents 70bdb47 + e8bc5ed commit 72c8605

File tree

14 files changed

+138
-22
lines changed

14 files changed

+138
-22
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
1515
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
1616
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
17-
linux_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
17+
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
1818
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
1919
windows_6_0_enabled: true
2020
windows_nightly_6_1_enabled: true
@@ -29,3 +29,14 @@ jobs:
2929
with:
3030
name: "Integration test"
3131
matrix_linux_command: "apt-get update -yq && apt-get install -yq jq && ./scripts/run-integration-test.sh"
32+
33+
static-sdk:
34+
name: Static SDK
35+
# Workaround https://github.com/nektos/act/issues/1875
36+
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
37+
38+
macos-tests:
39+
name: macOS tests
40+
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
41+
with:
42+
build_scheme: swift-openapi-runtime

.github/workflows/pull_request.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
1919
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
2020
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
21-
linux_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
21+
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
2222
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
2323
windows_6_0_enabled: true
2424
windows_nightly_6_1_enabled: true
@@ -34,3 +34,8 @@ jobs:
3434
name: "Integration test"
3535
matrix_linux_command: "apt-get update -yq && apt-get install -yq jq && ./scripts/run-integration-test.sh"
3636
matrix_linux_nightly_main_enabled: false
37+
38+
static-sdk:
39+
name: Static SDK
40+
# Workaround https://github.com/nektos/act/issues/1875
41+
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main

Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ let package = Package(
5353

5454
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
5555
for target in package.targets {
56-
if target.type != .plugin {
56+
switch target.type {
57+
case .regular, .test, .executable:
5758
var settings = target.swiftSettings ?? []
5859
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
5960
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
6061
target.swiftSettings = settings
62+
case .macro, .plugin, .system, .binary: () // not applicable
63+
@unknown default: () // we don't know what to do here, do nothing
6164
}
6265
}
6366
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //

Sources/OpenAPIRuntime/Conversion/ErrorExtensions.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@ struct MultiError: Swift.Error, LocalizedError, CustomStringConvertible {
114114
var description: String {
115115
let combinedDescription =
116116
errors.map { error in
117-
guard let error = error as? (any PrettyStringConvertible) else { return error.localizedDescription }
117+
guard let error = error as? (any PrettyStringConvertible) else { return "\(error)" }
118118
return error.prettyDescription
119119
}
120120
.enumerated().map { ($0.offset + 1, $0.element) }.map { "Error \($0.0): [\($0.1)]" }.joined(separator: ", ")
121121
return "MultiError (contains \(errors.count) error\(errors.count == 1 ? "" : "s")): \(combinedDescription)"
122122
}
123123

124-
var errorDescription: String? { description }
124+
var errorDescription: String? {
125+
if let first = errors.first {
126+
return "Mutliple errors encountered, first one: \(first.localizedDescription)."
127+
} else {
128+
return "No errors"
129+
}
130+
}
125131
}

Sources/OpenAPIRuntime/Errors/ClientError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ public struct ClientError: Error {
109109
// MARK: Private
110110

111111
fileprivate var underlyingErrorDescription: String {
112-
guard let prettyError = underlyingError as? (any PrettyStringConvertible) else {
113-
return underlyingError.localizedDescription
114-
}
112+
guard let prettyError = underlyingError as? (any PrettyStringConvertible) else { return "\(underlyingError)" }
115113
return prettyError.prettyDescription
116114
}
117115
}
@@ -133,5 +131,7 @@ extension ClientError: LocalizedError {
133131
/// This computed property provides a localized human-readable description of the client error, which is suitable for displaying to users.
134132
///
135133
/// - Returns: A localized string describing the client error.
136-
public var errorDescription: String? { description }
134+
public var errorDescription: String? {
135+
"Client encountered an error invoking the operation \"\(operationID)\", caused by \"\(causeDescription)\", underlying error: \(underlyingError.localizedDescription)."
136+
}
137137
}

Sources/OpenAPIRuntime/Errors/CodingErrors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension DecodingError: PrettyStringConvertible {
2121
case .keyNotFound(let key, let context): output = "keyNotFound \(key) - \(context.prettyDescription)"
2222
case .typeMismatch(let type, let context): output = "typeMismatch \(type) - \(context.prettyDescription)"
2323
case .valueNotFound(let type, let context): output = "valueNotFound \(type) - \(context.prettyDescription)"
24-
@unknown default: output = "unknown: \(localizedDescription)"
24+
@unknown default: output = "unknown: \(self)"
2525
}
2626
return "DecodingError: \(output)"
2727
}
@@ -30,7 +30,7 @@ extension DecodingError: PrettyStringConvertible {
3030
extension DecodingError.Context: PrettyStringConvertible {
3131
var prettyDescription: String {
3232
let path = codingPath.map(\.description).joined(separator: "/")
33-
return "at \(path): \(debugDescription) (underlying error: \(underlyingError?.localizedDescription ?? "<nil>"))"
33+
return "at \(path): \(debugDescription) (underlying error: \(underlyingError.map { "\($0)" } ?? "<nil>"))"
3434
}
3535
}
3636

@@ -39,7 +39,7 @@ extension EncodingError: PrettyStringConvertible {
3939
let output: String
4040
switch self {
4141
case .invalidValue(let value, let context): output = "invalidValue \(value) - \(context.prettyDescription)"
42-
@unknown default: output = "unknown: \(localizedDescription)"
42+
@unknown default: output = "unknown: \(self)"
4343
}
4444
return "EncodingError: \(output)"
4545
}
@@ -48,6 +48,6 @@ extension EncodingError: PrettyStringConvertible {
4848
extension EncodingError.Context: PrettyStringConvertible {
4949
var prettyDescription: String {
5050
let path = codingPath.map(\.description).joined(separator: "/")
51-
return "at \(path): \(debugDescription) (underlying error: \(underlyingError?.localizedDescription ?? "<nil>"))"
51+
return "at \(path): \(debugDescription) (underlying error: \(underlyingError.map { "\($0)" } ?? "<nil>"))"
5252
}
5353
}

Sources/OpenAPIRuntime/Errors/RuntimeError.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ internal enum RuntimeError: Error, CustomStringConvertible, LocalizedError, Pret
121121
return "Unexpected response body, expected content type: \(expectedContentType), body: \(body)"
122122
}
123123
}
124+
125+
// MARK: - LocalizedError
126+
127+
var errorDescription: String? { description }
124128
}
125129

126130
/// Throws an error to indicate an unexpected HTTP response status.

Sources/OpenAPIRuntime/Errors/ServerError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public struct ServerError: Error {
8282
// MARK: Private
8383

8484
fileprivate var underlyingErrorDescription: String {
85-
guard let prettyError = underlyingError as? (any PrettyStringConvertible) else {
86-
return underlyingError.localizedDescription
87-
}
85+
guard let prettyError = underlyingError as? (any PrettyStringConvertible) else { return "\(underlyingError)" }
8886
return prettyError.prettyDescription
8987
}
9088
}
@@ -106,5 +104,7 @@ extension ServerError: LocalizedError {
106104
/// This computed property provides a localized human-readable description of the server error, which is suitable for displaying to users.
107105
///
108106
/// - Returns: A localized string describing the server error.
109-
public var errorDescription: String? { description }
107+
public var errorDescription: String? {
108+
"Server encountered an error handling the operation \"\(operationID)\", caused by \"\(causeDescription)\", underlying error: \(underlyingError.localizedDescription)."
109+
}
110110
}

Sources/OpenAPIRuntime/Interface/ServerTransport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public protocol ServerTransport {
197197
/// print("<<<: \(response.status.code)")
198198
/// return (response, responseBody)
199199
/// } catch {
200-
/// print("!!!: \(error.localizedDescription)")
200+
/// print("!!!: \(error)")
201201
/// throw error
202202
/// }
203203
/// }

Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,5 +285,5 @@ public func XCTAssertEqualStringifiedData(
285285
do {
286286
let actualString = String(decoding: try expression1(), as: UTF8.self)
287287
XCTAssertEqual(actualString, try expression2(), file: file, line: line)
288-
} catch { XCTFail(error.localizedDescription, file: file, line: line) }
288+
} catch { XCTFail("\(error)", file: file, line: line) }
289289
}

0 commit comments

Comments
 (0)