[swift6][client] Remove unnecessary Combine checks#22810
[swift6][client] Remove unnecessary Combine checks#228104brunu merged 1 commit intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
1 issue found across 19 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="modules/openapi-generator/src/main/resources/swift6/api.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/swift6/api.mustache:11">
P2: Unconditional `import Combine` will fail to compile on non‑Apple platforms where the Combine module isn’t available. Keep the `#if canImport(Combine)` guard (and guard Combine-specific methods) to avoid breaking Swift builds outside Apple platforms.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| #if canImport(Combine) | ||
| import Combine | ||
| #endif{{/useCombine}}{{#useVapor}} | ||
| import Combine{{/useCombine}}{{#useVapor}} |
There was a problem hiding this comment.
P2: Unconditional import Combine will fail to compile on non‑Apple platforms where the Combine module isn’t available. Keep the #if canImport(Combine) guard (and guard Combine-specific methods) to avoid breaking Swift builds outside Apple platforms.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/swift6/api.mustache, line 11:
<comment>Unconditional `import Combine` will fail to compile on non‑Apple platforms where the Combine module isn’t available. Keep the `#if canImport(Combine)` guard (and guard Combine-specific methods) to avoid breaking Swift builds outside Apple platforms.</comment>
<file context>
@@ -8,9 +8,7 @@
-#if canImport(Combine)
-import Combine
-#endif{{/useCombine}}{{#useVapor}}
+import Combine{{/useCombine}}{{#useVapor}}
import Vapor{{/useVapor}}{{#swiftUseApiNamespace}}
</file context>
There was a problem hiding this comment.
This is fine, since combine is optional, can be added or removed with configurations, and we don't support Linux right now, at least not intentionally.
There was a problem hiding this comment.
Thanks for the feedback! I've saved this as a new learning to improve future reviews.
|
CI failure is not related to this PR. |
[swift6][client] Remove unnecessary Combine checks
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)@jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) @dydus0x14 (2023/06)
Summary by cubic
Removed redundant #if canImport(Combine) checks in the Swift 6 client generator and samples, always importing Combine when useCombine is enabled. This simplifies the code and ensures Combine publisher APIs are consistently available.
Written for commit 7b9979c. Summary will update on new commits.