Skip to content

Commit 55f02e9

Browse files
authored
[swift6] Change Response to struct (#20185)
1 parent af89ed8 commit 55f02e9

File tree

14 files changed

+43
-29
lines changed
  • modules/openapi-generator/src/main/resources/swift6
  • samples/client/petstore/swift6
    • alamofireLibrary/Sources/PetstoreClient/Infrastructure
    • apiNonStaticMethod/Sources/PetstoreClient/Infrastructure
    • asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure
    • combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • combineLibrary/Sources/CombineLibrary/Infrastructure
    • default/Sources/PetstoreClient/Infrastructure
    • objcCompatible/Sources/PetstoreClient/Infrastructure
    • oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • urlsessionLibrary/Sources/PetstoreClient/Infrastructure
    • validation/PetstoreClient/Classes/OpenAPIs/Infrastructure

14 files changed

+43
-29
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension NullEncodable: Codable where Wrapped: Codable {
9090
case generalError(Error)
9191
}
9292

93-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class Response<T> {
93+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct Response<T> {
9494
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let statusCode: Int
9595
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let header: [String: String]
9696
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let body: T
@@ -103,7 +103,7 @@ extension NullEncodable: Codable where Wrapped: Codable {
103103
self.bodyData = bodyData
104104
}
105105

106-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(response: HTTPURLResponse, body: T, bodyData: Data?) {
107107
let rawHeader = response.allHeaderFields
108108
var responseHeader = [String: String]()
109109
for (key, value) in rawHeader {
@@ -113,7 +113,8 @@ extension NullEncodable: Codable where Wrapped: Codable {
113113
}
114114
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
115115
}
116-
}{{#useAlamofire}}
116+
}
117+
extension Response : Sendable where T : Sendable {}{{#useAlamofire}}
117118

118119
/// Type-erased ResponseSerializer
119120
///

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public enum DecodableRequestBuilderError: Error {
9090
case generalError(Error)
9191
}
9292

93-
open class Response<T> {
93+
public struct Response<T> {
9494
public let statusCode: Int
9595
public let header: [String: String]
9696
public let body: T
@@ -103,7 +103,7 @@ open class Response<T> {
103103
self.bodyData = bodyData
104104
}
105105

106-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
107107
let rawHeader = response.allHeaderFields
108108
var responseHeader = [String: String]()
109109
for (key, value) in rawHeader {
@@ -114,6 +114,7 @@ open class Response<T> {
114114
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
115115
}
116116
}
117+
extension Response : Sendable where T : Sendable {}
117118

118119
/// Type-erased ResponseSerializer
119120
///

samples/client/petstore/swift6/apiNonStaticMethod/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public enum DecodableRequestBuilderError: Error {
9090
case generalError(Error)
9191
}
9292

93-
open class Response<T> {
93+
public struct Response<T> {
9494
public let statusCode: Int
9595
public let header: [String: String]
9696
public let body: T
@@ -103,7 +103,7 @@ open class Response<T> {
103103
self.bodyData = bodyData
104104
}
105105

106-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
107107
let rawHeader = response.allHeaderFields
108108
var responseHeader = [String: String]()
109109
for (key, value) in rawHeader {
@@ -114,6 +114,7 @@ open class Response<T> {
114114
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
115115
}
116116
}
117+
extension Response : Sendable where T : Sendable {}
117118

118119
/// Type-erased ResponseSerializer
119120
///

samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
internal class Response<T> {
92+
internal struct Response<T> {
9393
internal let statusCode: Int
9494
internal let header: [String: String]
9595
internal let body: T
@@ -102,7 +102,7 @@ internal class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
internal convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
internal init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ internal class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
internal final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/urlsessionLibrary/Sources/PetstoreClient/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

samples/client/petstore/swift6/validation/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public enum DecodableRequestBuilderError: Error {
8989
case generalError(Error)
9090
}
9191

92-
open class Response<T> {
92+
public struct Response<T> {
9393
public let statusCode: Int
9494
public let header: [String: String]
9595
public let body: T
@@ -102,7 +102,7 @@ open class Response<T> {
102102
self.bodyData = bodyData
103103
}
104104

105-
public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) {
105+
public init(response: HTTPURLResponse, body: T, bodyData: Data?) {
106106
let rawHeader = response.allHeaderFields
107107
var responseHeader = [String: String]()
108108
for (key, value) in rawHeader {
@@ -113,6 +113,7 @@ open class Response<T> {
113113
self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData)
114114
}
115115
}
116+
extension Response : Sendable where T : Sendable {}
116117

117118
public final class RequestTask: @unchecked Sendable {
118119
private let lock = NSRecursiveLock()

0 commit comments

Comments
 (0)