Skip to content

Commit 5bab14c

Browse files
committed
[swift6] Don't encode Data as base64 in multipart request
1 parent 08858a9 commit 5bab14c

File tree

28 files changed

+42
-42
lines changed

28 files changed

+42
-42
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import Vapor{{/useVapor}}
5252
guard let value = value else { return nil }
5353
if let value = value as? any RawRepresentable {
5454
return "\(value.rawValue)"
55+
} else if let data = value as? Data {
56+
return data.base64EncodedString(options: Data.Base64EncodingOptions())
5557
} else {
5658
return "\(value)"
5759
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8686
}
8787

8888
extension Data: ParameterConvertible {
89-
func asParameter(codableHelper: CodableHelper) -> any Sendable {
90-
return self.base64EncodedString(options: Data.Base64EncodingOptions())
91-
}
89+
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
9290
}
9391

9492
extension Date: ParameterConvertible {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct APIHelper {
5151
guard let value = value else { return nil }
5252
if let value = value as? any RawRepresentable {
5353
return "\(value.rawValue)"
54+
} else if let data = value as? Data {
55+
return data.base64EncodedString(options: Data.Base64EncodingOptions())
5456
} else {
5557
return "\(value)"
5658
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8484
}
8585

8686
extension Data: ParameterConvertible {
87-
func asParameter(codableHelper: CodableHelper) -> any Sendable {
88-
return self.base64EncodedString(options: Data.Base64EncodingOptions())
89-
}
87+
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
9088
}
9189

9290
extension Date: ParameterConvertible {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct APIHelper {
5151
guard let value = value else { return nil }
5252
if let value = value as? any RawRepresentable {
5353
return "\(value.rawValue)"
54+
} else if let data = value as? Data {
55+
return data.base64EncodedString(options: Data.Base64EncodingOptions())
5456
} else {
5557
return "\(value)"
5658
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8585
}
8686

8787
extension Data: ParameterConvertible {
88-
func asParameter(codableHelper: CodableHelper) -> any Sendable {
89-
return self.base64EncodedString(options: Data.Base64EncodingOptions())
90-
}
88+
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
9189
}
9290

9391
extension Date: ParameterConvertible {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct APIHelper {
5151
guard let value = value else { return nil }
5252
if let value = value as? any RawRepresentable {
5353
return "\(value.rawValue)"
54+
} else if let data = value as? Data {
55+
return data.base64EncodedString(options: Data.Base64EncodingOptions())
5456
} else {
5557
return "\(value)"
5658
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8484
}
8585

8686
extension Data: ParameterConvertible {
87-
func asParameter(codableHelper: CodableHelper) -> any Sendable {
88-
return self.base64EncodedString(options: Data.Base64EncodingOptions())
89-
}
87+
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
9088
}
9189

9290
extension Date: ParameterConvertible {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct APIHelper {
5151
guard let value = value else { return nil }
5252
if let value = value as? any RawRepresentable {
5353
return "\(value.rawValue)"
54+
} else if let data = value as? Data {
55+
return data.base64EncodedString(options: Data.Base64EncodingOptions())
5456
} else {
5557
return "\(value)"
5658
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ extension Dictionary where Key: Sendable, Value: Sendable {
8484
}
8585

8686
extension Data: ParameterConvertible {
87-
func asParameter(codableHelper: CodableHelper) -> any Sendable {
88-
return self.base64EncodedString(options: Data.Base64EncodingOptions())
89-
}
87+
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
9088
}
9189

9290
extension Date: ParameterConvertible {

0 commit comments

Comments
 (0)