Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import Foundation{{#usePromiseKit}}
@preconcurrency import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
@preconcurrency import RxSwift{{/useRxSwift}}{{#useCombine}}
#if canImport(Combine)
import Combine
#endif{{/useCombine}}{{#useVapor}}
import Combine{{/useCombine}}{{#useVapor}}
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 26, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the feedback! I've saved this as a new learning to improve future reviews.

import Vapor{{/useVapor}}{{#swiftUseApiNamespace}}

extension {{projectName}}API {
Expand Down Expand Up @@ -161,7 +159,6 @@ extension {{projectName}}API {
- parameter apiConfiguration: The configuration for the http request.{{/apiStaticMethod}}
- returns: AnyPublisher<{{{returnType}}}{{#returnType}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}{{^returnType}}Void{{/returnType}}, Error>
*/
#if canImport(Combine)
{{#isDeprecated}}
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
Expand Down Expand Up @@ -194,7 +191,6 @@ extension {{projectName}}API {
.eraseToAnyPublisher()
{{/combineDeferred}}
}
#endif
{{/useCombine}}
{{#useAsyncAwait}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import Foundation
@preconcurrency import PromiseKit
@preconcurrency import RxSwift
#if canImport(Combine)
import Combine
#endif

open class AnotherFakeAPI {
public let apiConfiguration: PetstoreClientAPIConfiguration
Expand Down Expand Up @@ -86,7 +84,6 @@ open class AnotherFakeAPI {
- parameter body: (body) client model
- returns: AnyPublisher<Client, Error>
*/
#if canImport(Combine)
open func call123testSpecialTags(body: Client) -> AnyPublisher<Client, Error> {
let requestBuilder = call123testSpecialTagsWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -108,7 +105,6 @@ open class AnotherFakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
To test special tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import Foundation
@preconcurrency import PromiseKit
@preconcurrency import RxSwift
#if canImport(Combine)
import Combine
#endif

open class FakeAPI {
public let apiConfiguration: PetstoreClientAPIConfiguration
Expand Down Expand Up @@ -82,7 +80,6 @@ open class FakeAPI {
- parameter body: (body) Input boolean as post body (optional)
- returns: AnyPublisher<Bool, Error>
*/
#if canImport(Combine)
open func fakeOuterBooleanSerialize(body: Bool? = nil) -> AnyPublisher<Bool, Error> {
let requestBuilder = fakeOuterBooleanSerializeWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -104,7 +101,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -220,7 +216,6 @@ open class FakeAPI {
- parameter body: (body) Input composite as post body (optional)
- returns: AnyPublisher<OuterComposite, Error>
*/
#if canImport(Combine)
open func fakeOuterCompositeSerialize(body: OuterComposite? = nil) -> AnyPublisher<OuterComposite, Error> {
let requestBuilder = fakeOuterCompositeSerializeWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -242,7 +237,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -358,7 +352,6 @@ open class FakeAPI {
- parameter body: (body) Input number as post body (optional)
- returns: AnyPublisher<Double, Error>
*/
#if canImport(Combine)
open func fakeOuterNumberSerialize(body: Double? = nil) -> AnyPublisher<Double, Error> {
let requestBuilder = fakeOuterNumberSerializeWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -380,7 +373,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -496,7 +488,6 @@ open class FakeAPI {
- parameter body: (body) Input string as post body (optional)
- returns: AnyPublisher<String, Error>
*/
#if canImport(Combine)
open func fakeOuterStringSerialize(body: String? = nil) -> AnyPublisher<String, Error> {
let requestBuilder = fakeOuterStringSerializeWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -518,7 +509,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -634,7 +624,6 @@ open class FakeAPI {
- parameter body: (body)
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testBodyWithFileSchema(body: FileSchemaTestClass) -> AnyPublisher<Void, Error> {
let requestBuilder = testBodyWithFileSchemaWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -656,7 +645,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -776,7 +764,6 @@ open class FakeAPI {
- parameter body: (body)
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testBodyWithQueryParams(query: String, body: User) -> AnyPublisher<Void, Error> {
let requestBuilder = testBodyWithQueryParamsWithRequestBuilder(query: query, body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -798,7 +785,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**

Expand Down Expand Up @@ -923,7 +909,6 @@ open class FakeAPI {
- parameter body: (body) client model
- returns: AnyPublisher<Client, Error>
*/
#if canImport(Combine)
open func testClientModel(body: Client) -> AnyPublisher<Client, Error> {
let requestBuilder = testClientModelWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -945,7 +930,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
To test \"client\" model
Expand Down Expand Up @@ -1120,7 +1104,6 @@ open class FakeAPI {
- parameter callback: (form) None (optional)
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> AnyPublisher<Void, Error> {
let requestBuilder = testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback)
let requestTask = requestBuilder.requestTask
Expand All @@ -1142,7 +1125,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Expand Down Expand Up @@ -1420,7 +1402,6 @@ open class FakeAPI {
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .efg)
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testEnumParameters(enumHeaderStringArray: [EnumHeaderStringArray_testEnumParameters]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [EnumQueryStringArray_testEnumParameters]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [EnumFormStringArray_testEnumParameters]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> AnyPublisher<Void, Error> {
let requestBuilder = testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString)
let requestTask = requestBuilder.requestTask
Expand All @@ -1442,7 +1423,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
To test enum parameters
Expand Down Expand Up @@ -1620,7 +1600,6 @@ open class FakeAPI {
- parameter int64Group: (query) Integer in group parameters (optional)
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> AnyPublisher<Void, Error> {
let requestBuilder = testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group)
let requestTask = requestBuilder.requestTask
Expand All @@ -1642,7 +1621,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
Fake endpoint to test group parameters (optional)
Expand Down Expand Up @@ -1787,7 +1765,6 @@ open class FakeAPI {
- parameter param: (body) request body
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testInlineAdditionalProperties(param: [String: String]) -> AnyPublisher<Void, Error> {
let requestBuilder = testInlineAdditionalPropertiesWithRequestBuilder(param: param)
let requestTask = requestBuilder.requestTask
Expand All @@ -1809,7 +1786,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
test inline additionalProperties
Expand Down Expand Up @@ -1935,7 +1911,6 @@ open class FakeAPI {
- parameter param2: (form) field2
- returns: AnyPublisher<Void, Error>
*/
#if canImport(Combine)
open func testJsonFormData(param: String, param2: String) -> AnyPublisher<Void, Error> {
let requestBuilder = testJsonFormDataWithRequestBuilder(param: param, param2: param2)
let requestTask = requestBuilder.requestTask
Expand All @@ -1957,7 +1932,6 @@ open class FakeAPI {
}
.eraseToAnyPublisher()
}
#endif

/**
test json serialization of form data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import Foundation
@preconcurrency import PromiseKit
@preconcurrency import RxSwift
#if canImport(Combine)
import Combine
#endif

open class FakeClassnameTags123API {
public let apiConfiguration: PetstoreClientAPIConfiguration
Expand Down Expand Up @@ -86,7 +84,6 @@ open class FakeClassnameTags123API {
- parameter body: (body) client model
- returns: AnyPublisher<Client, Error>
*/
#if canImport(Combine)
open func testClassname(body: Client) -> AnyPublisher<Client, Error> {
let requestBuilder = testClassnameWithRequestBuilder(body: body)
let requestTask = requestBuilder.requestTask
Expand All @@ -108,7 +105,6 @@ open class FakeClassnameTags123API {
}
.eraseToAnyPublisher()
}
#endif

/**
To test class name in snake case
Expand Down
Loading
Loading