From 43235f9929ff1f2880fd4110c4a936745c9c0b88 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Wed, 1 Oct 2025 13:50:31 +0100 Subject: [PATCH 1/8] Drop Swift 5.10 Motivation: Swift 5.10 is no longer supported, we should bump the tools version and remove it from our CI. Modifications: * Bump the Swift tools version to Swift 6.0 * Remove Swift 5.10 jobs where appropriate in main.yml, pull_request.yml Result: Code reflects our support window. --- .github/workflows/main.yml | 1 - .github/workflows/pull_request.yml | 1 - Examples/auth-client-middleware-example/Package.swift | 2 +- Examples/auth-server-middleware-example/Package.swift | 2 +- .../bidirectional-event-streams-client-example/Package.swift | 2 +- .../bidirectional-event-streams-server-example/Package.swift | 2 +- Examples/command-line-client-example/Package.swift | 2 +- Examples/curated-client-library-example/Package.swift | 2 +- Examples/event-streams-client-example/Package.swift | 2 +- Examples/event-streams-server-example/Package.swift | 2 +- Examples/hello-world-async-http-client-example/Package.swift | 2 +- Examples/hello-world-hummingbird-server-example/Package.swift | 2 +- Examples/hello-world-urlsession-client-example/Package.swift | 2 +- Examples/hello-world-vapor-server-example/Package.swift | 2 +- Examples/logging-middleware-oslog-example/Package.swift | 2 +- Examples/logging-middleware-swift-log-example/Package.swift | 2 +- Examples/manual-generation-generator-cli-example/Package.swift | 2 +- Examples/manual-generation-package-plugin-example/Package.swift | 2 +- Examples/metrics-middleware-example/Package.swift | 2 +- Examples/postgres-database-example/Package.swift | 2 +- Examples/retrying-middleware-example/Package.swift | 2 +- Examples/shared-types-client-server-example/Package.swift | 2 +- Examples/streaming-chatgpt-proxy/Package.swift | 2 +- Examples/swagger-ui-endpoint-example/Package.swift | 2 +- Examples/tracing-middleware-example/Package.swift | 2 +- Examples/type-overrides-example/Package.swift | 2 +- Examples/various-content-types-client-example/Package.swift | 2 +- Examples/various-content-types-server-example/Package.swift | 2 +- IntegrationTest/Package.swift | 2 +- Package.swift | 2 +- 30 files changed, 28 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 06d60384..7d2db6fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,6 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: - linux_5_10_arguments_override: "--explicit-target-dependency-import-check error" linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a3b73745..a581f9ce 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,7 +17,6 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: - linux_5_10_arguments_override: "--explicit-target-dependency-import-check error" linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" diff --git a/Examples/auth-client-middleware-example/Package.swift b/Examples/auth-client-middleware-example/Package.swift index 4588b73e..bd094e41 100644 --- a/Examples/auth-client-middleware-example/Package.swift +++ b/Examples/auth-client-middleware-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/auth-server-middleware-example/Package.swift b/Examples/auth-server-middleware-example/Package.swift index c11543df..e1743faa 100644 --- a/Examples/auth-server-middleware-example/Package.swift +++ b/Examples/auth-server-middleware-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/bidirectional-event-streams-client-example/Package.swift b/Examples/bidirectional-event-streams-client-example/Package.swift index c7df6cb9..158460ff 100644 --- a/Examples/bidirectional-event-streams-client-example/Package.swift +++ b/Examples/bidirectional-event-streams-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/bidirectional-event-streams-server-example/Package.swift b/Examples/bidirectional-event-streams-server-example/Package.swift index ba7a6057..42738037 100644 --- a/Examples/bidirectional-event-streams-server-example/Package.swift +++ b/Examples/bidirectional-event-streams-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/command-line-client-example/Package.swift b/Examples/command-line-client-example/Package.swift index 98929847..cfdba7e0 100644 --- a/Examples/command-line-client-example/Package.swift +++ b/Examples/command-line-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/curated-client-library-example/Package.swift b/Examples/curated-client-library-example/Package.swift index 3706ef00..6d8d1dde 100644 --- a/Examples/curated-client-library-example/Package.swift +++ b/Examples/curated-client-library-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/event-streams-client-example/Package.swift b/Examples/event-streams-client-example/Package.swift index b2adcc0e..e97a5a05 100644 --- a/Examples/event-streams-client-example/Package.swift +++ b/Examples/event-streams-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/event-streams-server-example/Package.swift b/Examples/event-streams-server-example/Package.swift index a5d2fb68..e9feb983 100644 --- a/Examples/event-streams-server-example/Package.swift +++ b/Examples/event-streams-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/hello-world-async-http-client-example/Package.swift b/Examples/hello-world-async-http-client-example/Package.swift index 29703d2f..6cf04e79 100644 --- a/Examples/hello-world-async-http-client-example/Package.swift +++ b/Examples/hello-world-async-http-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/hello-world-hummingbird-server-example/Package.swift b/Examples/hello-world-hummingbird-server-example/Package.swift index 2d460717..89619aa3 100644 --- a/Examples/hello-world-hummingbird-server-example/Package.swift +++ b/Examples/hello-world-hummingbird-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/hello-world-urlsession-client-example/Package.swift b/Examples/hello-world-urlsession-client-example/Package.swift index 71d66b2d..1e563b1c 100644 --- a/Examples/hello-world-urlsession-client-example/Package.swift +++ b/Examples/hello-world-urlsession-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/hello-world-vapor-server-example/Package.swift b/Examples/hello-world-vapor-server-example/Package.swift index 05700fe3..d640e40e 100644 --- a/Examples/hello-world-vapor-server-example/Package.swift +++ b/Examples/hello-world-vapor-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/logging-middleware-oslog-example/Package.swift b/Examples/logging-middleware-oslog-example/Package.swift index 3b1507ba..d4ae2483 100644 --- a/Examples/logging-middleware-oslog-example/Package.swift +++ b/Examples/logging-middleware-oslog-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/logging-middleware-swift-log-example/Package.swift b/Examples/logging-middleware-swift-log-example/Package.swift index e8842eda..d7c4a314 100644 --- a/Examples/logging-middleware-swift-log-example/Package.swift +++ b/Examples/logging-middleware-swift-log-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/manual-generation-generator-cli-example/Package.swift b/Examples/manual-generation-generator-cli-example/Package.swift index ae297657..c1049e3e 100644 --- a/Examples/manual-generation-generator-cli-example/Package.swift +++ b/Examples/manual-generation-generator-cli-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/manual-generation-package-plugin-example/Package.swift b/Examples/manual-generation-package-plugin-example/Package.swift index 95c49958..bd689daf 100644 --- a/Examples/manual-generation-package-plugin-example/Package.swift +++ b/Examples/manual-generation-package-plugin-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/metrics-middleware-example/Package.swift b/Examples/metrics-middleware-example/Package.swift index 9b147038..a1d0c889 100644 --- a/Examples/metrics-middleware-example/Package.swift +++ b/Examples/metrics-middleware-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/postgres-database-example/Package.swift b/Examples/postgres-database-example/Package.swift index 07d42b09..8012cd5a 100644 --- a/Examples/postgres-database-example/Package.swift +++ b/Examples/postgres-database-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/retrying-middleware-example/Package.swift b/Examples/retrying-middleware-example/Package.swift index 087e4ee9..642524fe 100644 --- a/Examples/retrying-middleware-example/Package.swift +++ b/Examples/retrying-middleware-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/shared-types-client-server-example/Package.swift b/Examples/shared-types-client-server-example/Package.swift index 49ef04ab..1026ec24 100644 --- a/Examples/shared-types-client-server-example/Package.swift +++ b/Examples/shared-types-client-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/streaming-chatgpt-proxy/Package.swift b/Examples/streaming-chatgpt-proxy/Package.swift index df93487f..1ad87cbe 100644 --- a/Examples/streaming-chatgpt-proxy/Package.swift +++ b/Examples/streaming-chatgpt-proxy/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 import PackageDescription let package = Package( diff --git a/Examples/swagger-ui-endpoint-example/Package.swift b/Examples/swagger-ui-endpoint-example/Package.swift index f0b65a22..6890580f 100644 --- a/Examples/swagger-ui-endpoint-example/Package.swift +++ b/Examples/swagger-ui-endpoint-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/tracing-middleware-example/Package.swift b/Examples/tracing-middleware-example/Package.swift index 9f7bfdf5..2e60f02b 100644 --- a/Examples/tracing-middleware-example/Package.swift +++ b/Examples/tracing-middleware-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/type-overrides-example/Package.swift b/Examples/type-overrides-example/Package.swift index 2751186a..0d397e25 100644 --- a/Examples/type-overrides-example/Package.swift +++ b/Examples/type-overrides-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/various-content-types-client-example/Package.swift b/Examples/various-content-types-client-example/Package.swift index 5c598c1b..165596a6 100644 --- a/Examples/various-content-types-client-example/Package.swift +++ b/Examples/various-content-types-client-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Examples/various-content-types-server-example/Package.swift b/Examples/various-content-types-server-example/Package.swift index e5a529ad..1164b669 100644 --- a/Examples/various-content-types-server-example/Package.swift +++ b/Examples/various-content-types-server-example/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/IntegrationTest/Package.swift b/IntegrationTest/Package.swift index 0875530c..8c5dad8f 100644 --- a/IntegrationTest/Package.swift +++ b/IntegrationTest/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project diff --git a/Package.swift b/Package.swift index 663c6011..932ea4f0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftOpenAPIGenerator open source project From 308db18ac331b7c283873e24fffb228f8075206b Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 10:53:02 +0200 Subject: [PATCH 2/8] Make FileError.Issue Sendable --- Plugins/PluginsShared/PluginError.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/PluginsShared/PluginError.swift b/Plugins/PluginsShared/PluginError.swift index 6341f9af..9707905c 100644 --- a/Plugins/PluginsShared/PluginError.swift +++ b/Plugins/PluginsShared/PluginError.swift @@ -58,7 +58,7 @@ enum PluginError: Swift.Error, Equatable, CustomStringConvertible, LocalizedErro struct FileError: Swift.Error, Equatable, CustomStringConvertible, LocalizedError { /// The kind of the file. - enum Kind: Equatable, CaseIterable { + enum Kind: Equatable, CaseIterable, Sendable { /// Config file. case config /// OpenAPI document file. @@ -73,7 +73,7 @@ struct FileError: Swift.Error, Equatable, CustomStringConvertible, LocalizedErro } /// Encountered issue. - enum Issue: Equatable { + enum Issue: Equatable, Sendable { /// File wasn't found. case noFilesFound /// More than 1 file found. From 98fddc3bec1b30aeafc45cc7c6fdd51114dfb6d3 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 11:01:02 +0200 Subject: [PATCH 3/8] Disable 5.10 actions --- .github/workflows/main.yml | 4 ++++ .github/workflows/pull_request.yml | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d2db6fa..d7896572 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: + linux_5_10_enabled: false linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" @@ -43,6 +44,7 @@ jobs: MATRIX_LINUX_SETUP_COMMAND: apt-get update -y && apt-get install -yq jq && git config --global --add safe.directory /swift-openapi-generator/.git && git config --global --add safe.directory /swift-openapi-generator MATRIX_LINUX_COMMAND: SWIFT_OPENAPI_GENERATOR_REPO_URL=file://${workspace} ./scripts/run-integration-test.sh MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: false + MATRIX_LINUX_5_10_ENABLED: false integration-test: name: Integration test @@ -68,6 +70,7 @@ jobs: MATRIX_LINUX_SETUP_COMMAND: git config --global --add safe.directory /swift-openapi-generator MATRIX_LINUX_COMMAND: ./scripts/test-examples.sh MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: false + MATRIX_LINUX_5_10_ENABLED: false example-packages: name: Example packages @@ -92,6 +95,7 @@ jobs: name: Release builds uses: apple/swift-nio/.github/workflows/release_builds.yml@main with: + linux_5_10_enabled: false windows_6_0_enabled: true windows_6_1_enabled: true windows_6_2_enabled: true diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a581f9ce..0911900a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,6 +17,7 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: + linux_5_10_enabled: false linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" @@ -68,6 +69,7 @@ jobs: MATRIX_LINUX_SETUP_COMMAND: apt-get update -y && apt-get install -yq jq && git config --global --add safe.directory /swift-openapi-generator/.git && git config --global --add safe.directory /swift-openapi-generator MATRIX_LINUX_COMMAND: SWIFT_OPENAPI_GENERATOR_REPO_URL=file://${workspace} ./scripts/run-integration-test.sh MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: false + MATRIX_LINUX_5_10_ENABLED: false integration-test: name: Integration test @@ -93,6 +95,7 @@ jobs: MATRIX_LINUX_SETUP_COMMAND: git config --global --add safe.directory /swift-openapi-generator MATRIX_LINUX_COMMAND: ./scripts/test-examples.sh MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: false + MATRIX_LINUX_5_10_ENABLED: false example-packages: name: Example packages @@ -102,7 +105,6 @@ jobs: name: "Example packages" matrix_string: '${{ needs.construct-example-packages-matrix.outputs.example-packages-matrix }}' - macos-tests: name: macOS tests uses: apple/swift-nio/.github/workflows/macos_tests.yml@main @@ -118,6 +120,7 @@ jobs: name: Release builds uses: apple/swift-nio/.github/workflows/release_builds.yml@main with: + linux_5_10_enabled: false windows_6_0_enabled: true windows_6_1_enabled: true windows_6_2_enabled: true From 42836706ce01727dbe958840a74c891efa244952 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 11:08:26 +0200 Subject: [PATCH 4/8] More Swift 6 mode fixes --- Plugins/PluginsShared/PluginError.swift | 4 ++-- Plugins/PluginsShared/PluginUtils.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/PluginsShared/PluginError.swift b/Plugins/PluginsShared/PluginError.swift index 9707905c..df27592d 100644 --- a/Plugins/PluginsShared/PluginError.swift +++ b/Plugins/PluginsShared/PluginError.swift @@ -77,7 +77,7 @@ struct FileError: Swift.Error, Equatable, CustomStringConvertible, LocalizedErro /// File wasn't found. case noFilesFound /// More than 1 file found. - case multipleFilesFound(files: [Path]) + case multipleFilesFound(files: [String]) /// The error is definitely due to misconfiguration of a target. var isMisconfigurationError: Bool { @@ -101,7 +101,7 @@ struct FileError: Swift.Error, Equatable, CustomStringConvertible, LocalizedErro "No config file found in the target named '\(targetName)'. Add a file called 'openapi-generator-config.yaml' or 'openapi-generator-config.yml' to the target's source directory. See documentation for details." case .multipleFilesFound(let files): return - "Multiple config files found in the target named '\(targetName)', but exactly one is expected. Found \(files.map(\.description).joined(separator: " "))." + "Multiple config files found in the target named '\(targetName)', but exactly one is expected. Found \(files.joined(separator: " "))." } case .document: switch issue { diff --git a/Plugins/PluginsShared/PluginUtils.swift b/Plugins/PluginsShared/PluginUtils.swift index 11bf2cc0..16f002ff 100644 --- a/Plugins/PluginsShared/PluginUtils.swift +++ b/Plugins/PluginsShared/PluginUtils.swift @@ -71,7 +71,7 @@ enum PluginUtils { } guard matchedConfigs.count == 1 else { return .failure( - FileError(targetName: targetName, fileKind: .config, issue: .multipleFilesFound(files: matchedConfigs)) + FileError(targetName: targetName, fileKind: .config, issue: .multipleFilesFound(files: matchedConfigs.map(\.description))) ) } return .success(matchedConfigs[0]) @@ -85,7 +85,7 @@ enum PluginUtils { } guard matchedDocs.count == 1 else { return .failure( - FileError(targetName: targetName, fileKind: .document, issue: .multipleFilesFound(files: matchedDocs)) + FileError(targetName: targetName, fileKind: .document, issue: .multipleFilesFound(files: matchedDocs.map(\.description))) ) } return .success(matchedDocs[0]) From e73bb6d899fb75750dfa475633fc5a422d4df084 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 11:10:14 +0200 Subject: [PATCH 5/8] Fix format --- .../LoggingMiddleware/LoggingMiddleware.swift | 3 ++- .../LoggingMiddleware/LoggingMiddleware.swift | 3 ++- .../Sources/MockTransportServer/Server.swift | 6 +++--- Plugins/PluginsShared/PluginUtils.swift | 12 ++++++++++-- .../TestClientTransport.swift | 5 ++--- .../TestServerTransport.swift | 12 ++++++------ Tests/PetstoreConsumerTests/TestClient.swift | 16 ++++++++-------- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Examples/logging-middleware-oslog-example/Sources/LoggingMiddleware/LoggingMiddleware.swift b/Examples/logging-middleware-oslog-example/Sources/LoggingMiddleware/LoggingMiddleware.swift index 0cf93378..860d9b03 100644 --- a/Examples/logging-middleware-oslog-example/Sources/LoggingMiddleware/LoggingMiddleware.swift +++ b/Examples/logging-middleware-oslog-example/Sources/LoggingMiddleware/LoggingMiddleware.swift @@ -59,7 +59,8 @@ extension LoggingMiddleware: ServerMiddleware { body: OpenAPIRuntime.HTTPBody?, metadata: OpenAPIRuntime.ServerRequestMetadata, operationID: String, - next: @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) + next: + @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) { let (requestBodyToLog, requestBodyForNext) = try await bodyLoggingPolicy.process(body) diff --git a/Examples/logging-middleware-swift-log-example/Sources/LoggingMiddleware/LoggingMiddleware.swift b/Examples/logging-middleware-swift-log-example/Sources/LoggingMiddleware/LoggingMiddleware.swift index a95752a3..04500c4e 100644 --- a/Examples/logging-middleware-swift-log-example/Sources/LoggingMiddleware/LoggingMiddleware.swift +++ b/Examples/logging-middleware-swift-log-example/Sources/LoggingMiddleware/LoggingMiddleware.swift @@ -56,7 +56,8 @@ extension LoggingMiddleware: ServerMiddleware { body: OpenAPIRuntime.HTTPBody?, metadata: OpenAPIRuntime.ServerRequestMetadata, operationID: String, - next: @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) + next: + @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) { let (requestBodyToLog, requestBodyForNext) = try await bodyLoggingPolicy.process(body) diff --git a/IntegrationTest/Sources/MockTransportServer/Server.swift b/IntegrationTest/Sources/MockTransportServer/Server.swift index 0f3fe556..4c8494a4 100644 --- a/IntegrationTest/Sources/MockTransportServer/Server.swift +++ b/IntegrationTest/Sources/MockTransportServer/Server.swift @@ -24,9 +24,9 @@ actor SimpleAPIImpl: APIProtocol { } class MockServerTransport: ServerTransport { - typealias Handler = @Sendable ( - HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata - ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) + typealias Handler = + @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) async throws + -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) func register(_ handler: @escaping Handler, method: HTTPTypes.HTTPRequest.Method, path: String) throws { // noop. diff --git a/Plugins/PluginsShared/PluginUtils.swift b/Plugins/PluginsShared/PluginUtils.swift index 16f002ff..8e121478 100644 --- a/Plugins/PluginsShared/PluginUtils.swift +++ b/Plugins/PluginsShared/PluginUtils.swift @@ -71,7 +71,11 @@ enum PluginUtils { } guard matchedConfigs.count == 1 else { return .failure( - FileError(targetName: targetName, fileKind: .config, issue: .multipleFilesFound(files: matchedConfigs.map(\.description))) + FileError( + targetName: targetName, + fileKind: .config, + issue: .multipleFilesFound(files: matchedConfigs.map(\.description)) + ) ) } return .success(matchedConfigs[0]) @@ -85,7 +89,11 @@ enum PluginUtils { } guard matchedDocs.count == 1 else { return .failure( - FileError(targetName: targetName, fileKind: .document, issue: .multipleFilesFound(files: matchedDocs.map(\.description))) + FileError( + targetName: targetName, + fileKind: .document, + issue: .multipleFilesFound(files: matchedDocs.map(\.description)) + ) ) } return .success(matchedDocs[0]) diff --git a/Sources/PetstoreConsumerTestCore/TestClientTransport.swift b/Sources/PetstoreConsumerTestCore/TestClientTransport.swift index e982569c..111a400a 100644 --- a/Sources/PetstoreConsumerTestCore/TestClientTransport.swift +++ b/Sources/PetstoreConsumerTestCore/TestClientTransport.swift @@ -33,9 +33,8 @@ import HTTPTypes public struct TestClientTransport: ClientTransport { /// A typealias representing a call handler closure for processing client requests. - public typealias CallHandler = @Sendable (HTTPRequest, HTTPBody?, URL, String) async throws -> ( - HTTPResponse, HTTPBody? - ) + public typealias CallHandler = + @Sendable (HTTPRequest, HTTPBody?, URL, String) async throws -> (HTTPResponse, HTTPBody?) /// The call handler responsible for processing client requests. public let callHandler: CallHandler diff --git a/Sources/PetstoreConsumerTestCore/TestServerTransport.swift b/Sources/PetstoreConsumerTestCore/TestServerTransport.swift index 7c7aee72..c4b3d68f 100644 --- a/Sources/PetstoreConsumerTestCore/TestServerTransport.swift +++ b/Sources/PetstoreConsumerTestCore/TestServerTransport.swift @@ -50,9 +50,8 @@ public final class TestServerTransport: ServerTransport { } /// A typealias representing a handler closure for processing server requests. - public typealias Handler = @Sendable (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> ( - HTTPResponse, HTTPBody? - ) + public typealias Handler = + @Sendable (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> (HTTPResponse, HTTPBody?) /// Represents an operation with its inputs and associated handler. public struct Operation { @@ -86,9 +85,10 @@ public final class TestServerTransport: ServerTransport { /// - path: The path components of the operation. /// - Throws: An error if there's an issue registering the operation. public func register( - _ handler: @Sendable @escaping (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> ( - HTTPResponse, HTTPBody? - ), + _ handler: + @Sendable @escaping (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> ( + HTTPResponse, HTTPBody? + ), method: HTTPRequest.Method, path: String ) throws { registered.append(Operation(inputs: .init(method: method, path: path), closure: handler)) } diff --git a/Tests/PetstoreConsumerTests/TestClient.swift b/Tests/PetstoreConsumerTests/TestClient.swift index 140d108d..399c11f8 100644 --- a/Tests/PetstoreConsumerTests/TestClient.swift +++ b/Tests/PetstoreConsumerTests/TestClient.swift @@ -29,8 +29,8 @@ struct TestClient: APIProtocol { return try await block(input) } - typealias CreatePetWithFormSignature = @Sendable (Operations.CreatePetWithForm.Input) async throws -> - Operations.CreatePetWithForm.Output + typealias CreatePetWithFormSignature = + @Sendable (Operations.CreatePetWithForm.Input) async throws -> Operations.CreatePetWithForm.Output var createPetWithFormBlock: CreatePetWithFormSignature? func createPetWithForm(_ input: Operations.CreatePetWithForm.Input) async throws -> Operations.CreatePetWithForm.Output @@ -67,8 +67,8 @@ struct TestClient: APIProtocol { return try await block(input) } - typealias UploadAvatarForPetSignature = @Sendable (Operations.UploadAvatarForPet.Input) async throws -> - Operations.UploadAvatarForPet.Output + typealias UploadAvatarForPetSignature = + @Sendable (Operations.UploadAvatarForPet.Input) async throws -> Operations.UploadAvatarForPet.Output var uploadAvatarForPetBlock: UploadAvatarForPetSignature? func uploadAvatarForPet(_ input: Operations.UploadAvatarForPet.Input) async throws -> Operations.UploadAvatarForPet.Output @@ -76,8 +76,8 @@ struct TestClient: APIProtocol { guard let block = uploadAvatarForPetBlock else { throw UnspecifiedBlockError() } return try await block(input) } - typealias MultipartDownloadTypedSignature = @Sendable (Operations.MultipartDownloadTyped.Input) async throws -> - Operations.MultipartDownloadTyped.Output + typealias MultipartDownloadTypedSignature = + @Sendable (Operations.MultipartDownloadTyped.Input) async throws -> Operations.MultipartDownloadTyped.Output var multipartDownloadTypedBlock: MultipartDownloadTypedSignature? func multipartDownloadTyped(_ input: Operations.MultipartDownloadTyped.Input) async throws -> Operations.MultipartDownloadTyped.Output @@ -85,8 +85,8 @@ struct TestClient: APIProtocol { guard let block = multipartDownloadTypedBlock else { throw UnspecifiedBlockError() } return try await block(input) } - typealias MultipartUploadTypedSignature = @Sendable (Operations.MultipartUploadTyped.Input) async throws -> - Operations.MultipartUploadTyped.Output + typealias MultipartUploadTypedSignature = + @Sendable (Operations.MultipartUploadTyped.Input) async throws -> Operations.MultipartUploadTyped.Output var multipartUploadTypedBlock: MultipartUploadTypedSignature? func multipartUploadTyped(_ input: Operations.MultipartUploadTyped.Input) async throws -> Operations.MultipartUploadTyped.Output From 7d0cc1738ef30b0ccd69e82d287614f7700db558 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 12:00:50 +0200 Subject: [PATCH 6/8] Fix up an example for bidi streaming --- .../Package.swift | 2 +- .../BidirectionalEventStreamsServer.swift | 2 +- .../GreetingStream.swift | 45 ++++++++++++------- Package.swift | 3 ++ 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Examples/bidirectional-event-streams-server-example/Package.swift b/Examples/bidirectional-event-streams-server-example/Package.swift index 42738037..9a4c7e1c 100644 --- a/Examples/bidirectional-event-streams-server-example/Package.swift +++ b/Examples/bidirectional-event-streams-server-example/Package.swift @@ -16,7 +16,7 @@ import PackageDescription let package = Package( name: "bidirectional-event-streams-server-example", - platforms: [.macOS(.v14)], + platforms: [.macOS(.v15)], dependencies: [ .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"), .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"), diff --git a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift index 8433143b..50529d7d 100644 --- a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift +++ b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift @@ -21,7 +21,7 @@ struct Handler: APIProtocol { func getGreetingsStream(_ input: Operations.GetGreetingsStream.Input) async throws -> Operations.GetGreetingsStream.Output { - let eventStream = await self.storage.makeStream(input: input) + let eventStream = self.storage.makeStream(input: input) /// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams. /// For SSE and JSON Sequences cases please check `event-streams-server-example`. let responseBody = Operations.GetGreetingsStream.Output.Ok.Body.applicationJsonl( diff --git a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift index 88d115e7..bd1422a9 100644 --- a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift +++ b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift @@ -13,35 +13,46 @@ //===----------------------------------------------------------------------===// import Foundation +import Synchronization -actor StreamStorage: Sendable { +final class StreamStorage: Sendable { private typealias StreamType = AsyncStream - private var streams: [String: Task] = [:] - init() {} + private let streams: Mutex<[String: Task]> + init() { self.streams = .init([:]) } private func finishedStream(id: String) { - guard self.streams[id] != nil else { return } - self.streams.removeValue(forKey: id) + self.streams.withLock { streams in + guard streams[id] != nil else { return } + streams.removeValue(forKey: id) + } } private func cancelStream(id: String) { - guard let task = self.streams[id] else { return } - self.streams.removeValue(forKey: id) + let task: Task? = self.streams.withLock { streams in + guard let task = streams[id] else { return nil } + streams.removeValue(forKey: id) + return task + } + guard let task else { return } task.cancel() print("Canceled stream \(id)") } + + private func handleTermination( + _ termination: AsyncStream.Continuation.Termination, + id: String + ) { + switch termination { + case .cancelled: self.cancelStream(id: id) + case .finished: self.finishedStream(id: id) + @unknown default: self.finishedStream(id: id) + } + } + func makeStream(input: Operations.GetGreetingsStream.Input) -> AsyncStream { let name = input.query.name ?? "Stranger" let id = UUID().uuidString print("Creating stream \(id) for name: \(name)") let (stream, continuation) = StreamType.makeStream() - continuation.onTermination = { termination in - Task { [weak self] in - switch termination { - case .cancelled: await self?.cancelStream(id: id) - case .finished: await self?.finishedStream(id: id) - @unknown default: await self?.finishedStream(id: id) - } - } - } + continuation.onTermination = { termination in self.handleTermination(termination, id: id) } let inputStream = switch input.body { case .applicationJsonl(let body): body.asDecodedJSONLines(of: Components.Schemas.Greeting.self) @@ -56,7 +67,7 @@ actor StreamStorage: Sendable { } continuation.finish() } - self.streams[id] = task + self.streams.withLock { streams in streams[id] = task } return stream } } diff --git a/Package.swift b/Package.swift index 932ea4f0..ccd76a6b 100644 --- a/Package.swift +++ b/Package.swift @@ -20,6 +20,9 @@ var swiftSettings: [SwiftSetting] = [ // https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md // Require `any` for existential types. .enableUpcomingFeature("ExistentialAny"), .enableExperimentalFeature("StrictConcurrency=complete"), + + // Use Swift 5 language mode until Swift 6.1 tools are the minimum version. + .swiftLanguageMode(.v5), ] let package = Package( From 07090e6ebf781c663fdfee4dacb6953b5d98b09d Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 12:27:21 +0200 Subject: [PATCH 7/8] Fix another example for Swift 6 mode --- .../Sources/CommandLineClient/CommandLineClient.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/command-line-client-example/Sources/CommandLineClient/CommandLineClient.swift b/Examples/command-line-client-example/Sources/CommandLineClient/CommandLineClient.swift index 471bb6df..bed0203f 100644 --- a/Examples/command-line-client-example/Sources/CommandLineClient/CommandLineClient.swift +++ b/Examples/command-line-client-example/Sources/CommandLineClient/CommandLineClient.swift @@ -17,7 +17,7 @@ import Foundation import ArgumentParser @main struct CommandLineClient: AsyncParsableCommand { - static var configuration: CommandConfiguration = .init( + static let configuration: CommandConfiguration = .init( commandName: "CommandLineClient", subcommands: [GreetCommand.self] ) @@ -25,7 +25,7 @@ import ArgumentParser struct GreetCommand: AsyncParsableCommand { - static var configuration: CommandConfiguration = .init(commandName: "greet") + static let configuration: CommandConfiguration = .init(commandName: "greet") @Option var name: String From 67ca047c51f15d80168cc985e20c665dc02ee54f Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Mon, 6 Oct 2025 13:10:35 +0200 Subject: [PATCH 8/8] Fix another Swift 6 error --- .../streaming-chatgpt-proxy/Sources/ClientCLI/main.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Examples/streaming-chatgpt-proxy/Sources/ClientCLI/main.swift b/Examples/streaming-chatgpt-proxy/Sources/ClientCLI/main.swift index b1d69fec..d646d644 100644 --- a/Examples/streaming-chatgpt-proxy/Sources/ClientCLI/main.swift +++ b/Examples/streaming-chatgpt-proxy/Sources/ClientCLI/main.swift @@ -11,6 +11,11 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// + +// https://github.com/swiftlang/swift/issues/77866 +#if canImport(Glibc) +@preconcurrency import Glibc +#endif import OpenAPIRuntime import OpenAPIURLSession import Foundation