Skip to content

Commit 7156e50

Browse files
Generate the server variable enums as Sendable
1 parent d875fe4 commit 7156e50

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ enum Constants {
6262

6363
/// The prefix of the namespace that contains server specific variables.
6464
static let serverNamespacePrefix: String = "Server"
65+
66+
/// Constants related to the OpenAPI server variable object.
67+
enum Variable {
68+
69+
/// The types that the protocol conforms to.
70+
static let conformances: [String] = [TypeName.string.fullyQualifiedSwiftName, "Sendable"]
71+
}
6572
}
6673

6774
/// Constants related to the configuration type, which is used by both

Sources/_OpenAPIGeneratorCore/Translator/TypesTranslator/translateServersVariables.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ extension TypesFileTranslator {
192192
isFrozen: true,
193193
accessModifier: accessModifier,
194194
name: enumName,
195-
conformances: [
196-
TypeName.string.fullyQualifiedSwiftName,
197-
],
195+
conformances: Constants.ServerURL.Variable.conformances,
198196
members: enumValues.map(translateVariableCase)
199197
)
200198
)

Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public enum Servers {
189189
/// A custom domain.
190190
public enum Server3 {
191191
/// The "port" variable defined in the OpenAPI document. The default value is "443".
192-
@frozen public enum Port: Swift.String {
192+
@frozen public enum Port: Swift.String, Sendable {
193193
case _443 = "443"
194194
case _8443 = "8443"
195195
}

Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5267,7 +5267,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
52675267
"""
52685268
public enum Servers {
52695269
public enum Server1 {
5270-
@frozen public enum Environment: Swift.String {
5270+
@frozen public enum Environment: Swift.String, Sendable {
52715271
case production
52725272
case sandbox
52735273
}
@@ -5349,7 +5349,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
53495349
"""
53505350
public enum Servers {
53515351
public enum Server1 {
5352-
@frozen public enum Environment: Swift.String {
5352+
@frozen public enum Environment: Swift.String, Sendable {
53535353
case production
53545354
case sandbox
53555355
}
@@ -5396,7 +5396,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
53965396
)
53975397
}
53985398
public enum Server2 {
5399-
@frozen public enum Environment: Swift.String {
5399+
@frozen public enum Environment: Swift.String, Sendable {
54005400
case sandbox
54015401
case develop
54025402
}

0 commit comments

Comments
 (0)