Skip to content

Commit 10e6c21

Browse files
[swift6] Add nonisolatedModels option for default MainActor isolation (#25004)
* [swift6] Add nonisolatedModels option for default MainActor isolation Adds a `nonisolatedModels` boolean option (default: false) to the swift6 generator. When enabled, generated model structs/classes/enums, the extensions emitted alongside them, and the supporting protocols and helper types they conform to or store (ParameterConvertible, CaseIterableDefaultsLast, UnknownCaseCheckable, NullEncodable, JSONValue, OpenAPIDateWithoutTime, the validation rule structs, CodableHelper, OpenAPIMutex, OpenISO8601DateFormatter, and the ParameterConvertible, CodingKey and Codable container extensions in Extensions.swift) are marked `nonisolated`. This lets the generated sources be vendored into a module built with Swift 6.2 default MainActor isolation (SE-0466) while keeping models decodable and usable off the main actor. Requires a Swift 6.1+ toolchain when enabled; output is unchanged when the option is off. Enabled in the swift6 validation sample. Fixes #24903 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [swift6] nonisolatedModels: cover objcCompatible models and enum tests Review flagged that objcCompatible model classes were left MainActor-isolated while their Identifiable/UnknownCaseCheckable extensions were marked nonisolated, which fails to compile under default MainActor isolation. Mark the objcCompatible class declaration nonisolated too (verified to build with 0 errors), and add tests for top-level, nested and oneOf enums and objcCompatible. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [swift6] tests: reuse generateSwift6 helper in nonisolatedModels tests Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 9d0828b commit 10e6c21

26 files changed

Lines changed: 212 additions & 109 deletions

‎bin/configs/swift6-validation.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ templateDir: modules/openapi-generator/src/main/resources/swift6
55
generateAliasAsModel: true
66
additionalProperties:
77
useSPMFileStructure: false
8+
nonisolatedModels: true
89
podAuthors: ""
910
podSummary: PetstoreClient
1011
projectName: PetstoreClient

‎docs/generators/swift6.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3636
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd><dt>**vapor**</dt><dd>HTTP client: Vapor</dd></dl>|urlsession|
3737
|mapFileBinaryToData|Map File and Binary to Data (default: false)| |false|
3838
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
39+
|nonisolatedModels|Mark generated models, and the supporting protocols, extensions and helper types they rely on, as nonisolated so they stay usable off the main actor in modules built with default MainActor isolation (SE-0466). Requires a Swift 6.1+ toolchain (default: false)| |false|
3940
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
4041
|oneOfUnknownDefaultCase|Add unknownDefault case to oneOf enum (default: false)| |false|
4142
|podAuthors|Authors used for Podspec| |null|

‎modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
7979
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES = "generateModelAdditionalProperties";
8080
public static final String HASHABLE_MODELS = "hashableModels";
8181
public static final String IDENTIFIABLE_MODELS = "identifiableModels";
82+
public static final String NONISOLATED_MODELS = "nonisolatedModels";
8283
public static final String USE_PARAMETER_CONVERTIBLE = "useParameterConvertible";
8384
public static final String MAP_FILE_BINARY_TO_DATA = "mapFileBinaryToData";
8485
public static final String USE_CUSTOM_DATE_WITHOUT_TIME = "useCustomDateWithoutTime";
@@ -125,6 +126,8 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
125126
@Setter
126127
protected boolean identifiableModels = true;
127128
@Setter
129+
protected boolean nonisolatedModels = false;
130+
@Setter
128131
protected boolean useParameterConvertible = true;
129132
@Getter
130133
@Setter
@@ -379,6 +382,12 @@ public Swift6ClientCodegen() {
379382
"Make models conform to Identifiable when an id is present (default: true)")
380383
.defaultValue(Boolean.TRUE.toString()));
381384

385+
cliOptions.add(new CliOption(NONISOLATED_MODELS,
386+
"Mark generated models, and the supporting protocols, extensions and helper types they rely on, "
387+
+ "as nonisolated so they stay usable off the main actor in modules built with default MainActor isolation (SE-0466). "
388+
+ "Requires a Swift 6.1+ toolchain (default: false)")
389+
.defaultValue(Boolean.FALSE.toString()));
390+
382391
cliOptions.add(new CliOption(USE_PARAMETER_CONVERTIBLE,
383392
"Make models conform to ParameterConvertible protocol (default: true)")
384393
.defaultValue(Boolean.TRUE.toString()));
@@ -619,6 +628,11 @@ public void processOpts() {
619628
}
620629
additionalProperties.put(IDENTIFIABLE_MODELS, identifiableModels);
621630

631+
if (additionalProperties.containsKey(NONISOLATED_MODELS)) {
632+
setNonisolatedModels(convertPropertyToBooleanAndWriteBack(NONISOLATED_MODELS));
633+
}
634+
additionalProperties.put(NONISOLATED_MODELS, nonisolatedModels);
635+
622636
if (additionalProperties.containsKey(USE_PARAMETER_CONVERTIBLE)) {
623637
setUseParameterConvertible(convertPropertyToBooleanAndWriteBack(USE_PARAMETER_CONVERTIBLE));
624638
}

‎modules/openapi-generator/src/main/resources/swift6/CodableHelper.mustache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class CodableHelper: @unchecked Sendable {
10+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}class CodableHelper: @unchecked Sendable {
1111
1212
// MARK: - Private state
1313

‎modules/openapi-generator/src/main/resources/swift6/Extensions.mustache‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,73 +11,73 @@ import FoundationNetworking
1111
@preconcurrency import PromiseKit{{/usePromiseKit}}{{#useVapor}}
1212
import Vapor{{/useVapor}}{{^useVapor}}
1313

14-
extension Bool: ParameterConvertible {
14+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Bool: ParameterConvertible {
1515
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
1616
}
1717

18-
extension Float: ParameterConvertible {
18+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Float: ParameterConvertible {
1919
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
2020
}
2121

22-
extension Int: ParameterConvertible {
22+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Int: ParameterConvertible {
2323
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
2424
}
2525

26-
extension Int32: ParameterConvertible {
26+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Int32: ParameterConvertible {
2727
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
2828
}
2929

30-
extension Int64: ParameterConvertible {
30+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Int64: ParameterConvertible {
3131
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
3232
}
3333

34-
extension Double: ParameterConvertible {
34+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Double: ParameterConvertible {
3535
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
3636
}
3737

38-
extension Decimal: ParameterConvertible {
38+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Decimal: ParameterConvertible {
3939
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
4040
}
4141

42-
extension String: ParameterConvertible {
42+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension String: ParameterConvertible {
4343
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
4444
}
4545

46-
extension URL: ParameterConvertible {
46+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension URL: ParameterConvertible {
4747
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
4848
}
4949

50-
extension UUID: ParameterConvertible {
50+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension UUID: ParameterConvertible {
5151
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
5252
}
5353

54-
extension RawRepresentable where RawValue: ParameterConvertible {
54+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension RawRepresentable where RawValue: ParameterConvertible {
5555
func asParameter(codableHelper: CodableHelper) -> any Sendable {
5656
rawValue.asParameter(codableHelper: codableHelper)
5757
}
5858
}
5959

60-
private func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
60+
private {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
6161
if let encodableObject = object as? ParameterConvertible {
6262
return encodableObject.asParameter(codableHelper: codableHelper)
6363
} else {
6464
return object
6565
}
6666
}
6767

68-
extension Array where Element: Sendable {
68+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Array where Element: Sendable {
6969
func asParameter(codableHelper: CodableHelper) -> any Sendable {
7070
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
7171
}
7272
}
7373

74-
extension Set where Element: Sendable {
74+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Set where Element: Sendable {
7575
func asParameter(codableHelper: CodableHelper) -> any Sendable {
7676
return Array(self).asParameter(codableHelper: codableHelper)
7777
}
7878
}
7979

80-
extension Dictionary where Key: Sendable, Value: Sendable {
80+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Dictionary where Key: Sendable, Value: Sendable {
8181
func asParameter(codableHelper: CodableHelper) -> any Sendable {
8282
var dictionary = [Key: any Sendable]()
8383
for (key, value) in self {
@@ -87,19 +87,19 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8787
}
8888
}
8989

90-
extension Data: ParameterConvertible {
90+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Data: ParameterConvertible {
9191
func asParameter(codableHelper: CodableHelper) -> any Sendable {
9292
return self.base64EncodedString(options: Data.Base64EncodingOptions())
9393
}
9494
}
9595

96-
extension Date: ParameterConvertible {
96+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension Date: ParameterConvertible {
9797
func asParameter(codableHelper: CodableHelper) -> any Sendable {
9898
return codableHelper.dateFormatter.string(from: self)
9999
}
100100
}{{/useVapor}}{{#generateModelAdditionalProperties}}
101101

102-
extension String: @retroactive CodingKey {
102+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension String: @retroactive CodingKey {
103103
104104
public var stringValue: String {
105105
return self
@@ -119,7 +119,7 @@ extension String: @retroactive CodingKey {
119119

120120
}
121121

122-
extension KeyedEncodingContainerProtocol {
122+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension KeyedEncodingContainerProtocol {
123123
124124
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T: Encodable {
125125
var arrayContainer = nestedUnkeyedContainer(forKey: key)
@@ -161,7 +161,7 @@ extension KeyedEncodingContainerProtocol {
161161
}
162162
}
163163

164-
extension KeyedDecodingContainerProtocol {
164+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension KeyedDecodingContainerProtocol {
165165
166166
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T: Decodable {
167167
var tmpArray = [T]()
@@ -281,4 +281,4 @@ extension Set: @retroactive AsyncRequestDecodable where Element: Content {
281281

282282
extension Set: @retroactive Content where Element: Content { }
283283

284-
extension JSONValue: Content {}{{/useVapor}}
284+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: Content {}{{/useVapor}}

‎modules/openapi-generator/src/main/resources/swift6/JSONValue.mustache‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum JSONValue: Sendable, Codable, Hashable {
10+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}enum JSONValue: Sendable, Codable, Hashable {
1111
case string(String)
1212
case int(Int)
1313
case double(Double)
@@ -62,7 +62,7 @@ import Foundation
6262
}
6363
}
6464

65-
extension JSONValue {
65+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue {
6666
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(_ value: String) {
6767
self = .string(value)
6868
}
@@ -97,7 +97,7 @@ extension JSONValue {
9797
}
9898
}
9999

100-
extension JSONValue {
100+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue {
101101
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var isString: Bool {
102102
if case .string = self { return true }
103103
return false
@@ -134,7 +134,7 @@ extension JSONValue {
134134

135135
}
136136

137-
extension JSONValue {
137+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue {
138138
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var stringValue: String? {
139139
switch self {
140140
case .string(let value):
@@ -186,7 +186,7 @@ extension JSONValue {
186186
}
187187
}
188188

189-
extension JSONValue {
189+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue {
190190
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} subscript(key: String) -> JSONValue? {
191191
return dictionaryValue?[key]
192192
}
@@ -199,38 +199,38 @@ extension JSONValue {
199199
}
200200
}
201201

202-
extension JSONValue: ExpressibleByStringLiteral, ExpressibleByStringInterpolation {
202+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByStringLiteral, ExpressibleByStringInterpolation {
203203
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(stringLiteral value: StringLiteralType) {
204204
self = .string(value)
205205
}
206206
}
207207

208-
extension JSONValue: ExpressibleByIntegerLiteral {
208+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByIntegerLiteral {
209209
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(integerLiteral value: IntegerLiteralType) {
210210
self = .int(value)
211211
}
212212
}
213213

214-
extension JSONValue: ExpressibleByFloatLiteral {
214+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByFloatLiteral {
215215
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(floatLiteral value: FloatLiteralType) {
216216
self = .double(value)
217217
}
218218
}
219219

220220

221-
extension JSONValue: ExpressibleByBooleanLiteral {
221+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByBooleanLiteral {
222222
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(booleanLiteral value: BooleanLiteralType) {
223223
self = .bool(value)
224224
}
225225
}
226226

227-
extension JSONValue: ExpressibleByArrayLiteral {
227+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByArrayLiteral {
228228
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(arrayLiteral elements: JSONValue...) {
229229
self = .array(elements)
230230
}
231231
}
232232

233-
extension JSONValue: ExpressibleByDictionaryLiteral {
233+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByDictionaryLiteral {
234234
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(dictionaryLiteral elements: (String, JSONValue)...) {
235235
var dict: [String: JSONValue] = [:]
236236
for (key, value) in elements {
@@ -240,7 +240,7 @@ extension JSONValue: ExpressibleByDictionaryLiteral {
240240
}
241241
}
242242

243-
extension JSONValue: ExpressibleByNilLiteral {
243+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension JSONValue: ExpressibleByNilLiteral {
244244
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(nilLiteral: ()) {
245245
self = .null
246246
}

‎modules/openapi-generator/src/main/resources/swift6/Models.mustache‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import FoundationNetworking
1010
#endif{{#useAlamofire}}
1111
import Alamofire{{/useAlamofire}}
1212

13-
protocol ParameterConvertible {
13+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}protocol ParameterConvertible {
1414
func asParameter(codableHelper: CodableHelper) -> any Sendable
1515
}
1616

1717
/// An enum where the last case value can be used as a default catch-all.
18-
protocol CaseIterableDefaultsLast: Decodable & CaseIterable & RawRepresentable
18+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}protocol CaseIterableDefaultsLast: Decodable & CaseIterable & RawRepresentable
1919
where RawValue: Decodable, AllCases: BidirectionalCollection {}
2020

21-
extension CaseIterableDefaultsLast {
21+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension CaseIterableDefaultsLast {
2222
/// Initializes an enum such that if a known raw value is found, then it is decoded.
2323
/// Otherwise the last case is used.
2424
/// - Parameter decoder: A decoder.
@@ -40,28 +40,28 @@ extension CaseIterableDefaultsLast {
4040
/// Protocol for types used as oneOf variants, allowing the oneOf decoder to reject
4141
/// a variant that only decoded successfully because CaseIterableDefaultsLast
4242
/// silently accepted an unknown enum value.
43-
protocol UnknownCaseCheckable {
43+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}protocol UnknownCaseCheckable {
4444
var containsUnknownDefaultOpenApiCase: Bool { get }
4545
}
4646

47-
extension UnknownCaseCheckable {
47+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension UnknownCaseCheckable {
4848
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var containsUnknownDefaultOpenApiCase: Bool { false }
4949
}
5050

5151
{{/enumUnknownDefaultCase}}
5252
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
5353
/// or not encoded (`.encodeNothing`). Intended for request payloads.
54-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum NullEncodable<Wrapped> {
54+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}enum NullEncodable<Wrapped> {
5555
case encodeNothing
5656
case encodeNull
5757
case encodeValue(Wrapped)
5858
}
5959

60-
extension NullEncodable: Equatable where Wrapped: Equatable {}
61-
extension NullEncodable: Hashable where Wrapped: Hashable {}
62-
extension NullEncodable: Sendable where Wrapped: Sendable {}
60+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension NullEncodable: Equatable where Wrapped: Equatable {}
61+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension NullEncodable: Hashable where Wrapped: Hashable {}
62+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension NullEncodable: Sendable where Wrapped: Sendable {}
6363

64-
extension NullEncodable: Codable where Wrapped: Codable {
64+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension NullEncodable: Codable where Wrapped: Codable {
6565
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(from decoder: Decoder) throws {
6666
let container = try decoder.singleValueContainer()
6767
if let value = try? container.decode(Wrapped.self) {

‎modules/openapi-generator/src/main/resources/swift6/OpenAPIDateWithoutTime.mustache‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601.
1616
/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate
1717
/// can be used safely.
18-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct OpenAPIDateWithoutTime: Sendable, Codable, Hashable, Equatable {
18+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}struct OpenAPIDateWithoutTime: Sendable, Codable, Hashable, Equatable {
1919
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let wrappedDate: Date
2020
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let timezone: TimeZone
2121

@@ -76,13 +76,13 @@ import Foundation
7676
}
7777
}
7878

79-
extension OpenAPIDateWithoutTime: ParameterConvertible {
79+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension OpenAPIDateWithoutTime: ParameterConvertible {
8080
func asParameter(codableHelper: CodableHelper) -> any Sendable {
8181
return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate())
8282
}
8383
}
8484

85-
extension OpenAPIDateWithoutTime: RawRepresentable {
85+
{{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}extension OpenAPIDateWithoutTime: RawRepresentable {
8686
public typealias RawValue = String
8787
public init?(rawValue: String) {
8888
if let date = OpenISO8601DateFormatter.withoutTime.date(from: rawValue) {

‎modules/openapi-generator/src/main/resources/swift6/OpenAPIMutex.mustache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import Foundation
88

9-
internal final class OpenAPIMutex<Value>: @unchecked Sendable {
9+
internal {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}final class OpenAPIMutex<Value>: @unchecked Sendable {
1010
1111
private var _value: Value
1212
private let lock = NSRecursiveLock()

‎modules/openapi-generator/src/main/resources/swift6/OpenISO8601DateFormatter.mustache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
// https://stackoverflow.com/a/50281094/976628
11-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class OpenISO8601DateFormatter: DateFormatter, @unchecked Sendable {
11+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#nonisolatedModels}}nonisolated {{/nonisolatedModels}}class OpenISO8601DateFormatter: DateFormatter, @unchecked Sendable {
1212
static let withoutSeconds: DateFormatter = {
1313
let formatter = DateFormatter()
1414
formatter.calendar = Calendar(identifier: .iso8601)

0 commit comments

Comments
 (0)