From f9098d5a89034b57c101704c49bb547e3624d5fc Mon Sep 17 00:00:00 2001 From: Jonas Reichert <75073818+Jonas1893@users.noreply.github.com> Date: Tue, 15 Jul 2025 10:25:34 +0200 Subject: [PATCH] [swift] [urlsession] Fixes crash for uploads with content-type "image/" (#21544) * Fix image upload for content-type image * update samples * add test case in spec and update samples * update bitrise stack so we get xcpretty 0.4.1 * Revert "add test case in spec and update samples" This reverts commit 92202dd8506b2482cda69fe1d95a61d5a51881e3. --- bitrise.yml | 2 +- .../libraries/urlsession/URLSessionImplementations.mustache | 2 +- .../libraries/urlsession/URLSessionImplementations.mustache | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Sources/PetstoreClient/URLSessionImplementations.swift | 2 +- .../Classes/OpenAPIs/URLSessionImplementations.swift | 2 +- .../Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- .../Infrastructure/URLSessionImplementations.swift | 2 +- .../Infrastructure/URLSessionImplementations.swift | 2 +- .../Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- .../Infrastructure/URLSessionImplementations.swift | 2 +- .../OpenAPIs/Infrastructure/URLSessionImplementations.swift | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/bitrise.yml b/bitrise.yml index 69390c39ae6..b4af0773410 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -48,4 +48,4 @@ workflows: meta: bitrise.io: - stack: osx-xcode-16.0.x + stack: osx-xcode-16.3.x diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache index 3f60f35560e..d305f167903 100644 --- a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache @@ -140,7 +140,7 @@ private var credentialStore = SynchronizedDictionary() encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/modules/openapi-generator/src/main/resources/swift6/libraries/urlsession/URLSessionImplementations.mustache b/modules/openapi-generator/src/main/resources/swift6/libraries/urlsession/URLSessionImplementations.mustache index af45cadbeb5..191545c3d70 100644 --- a/modules/openapi-generator/src/main/resources/swift6/libraries/urlsession/URLSessionImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift6/libraries/urlsession/URLSessionImplementations.mustache @@ -140,7 +140,7 @@ fileprivate class URLSessionRequestBuilderConfiguration: @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index 8d45a2bbb69..7525c158b9a 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ internal class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index aa6558b927b..6f10c3cae31 100644 --- a/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index d787d429b31..06b39a40120 100644 --- a/samples/client/petstore/swift6/resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ internal class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendab encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/urlsessionLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/urlsessionLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/urlsessionLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/urlsessionLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)") diff --git a/samples/client/petstore/swift6/validation/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift b/samples/client/petstore/swift6/validation/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift index 802e927474b..93bcea293c6 100644 --- a/samples/client/petstore/swift6/validation/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift +++ b/samples/client/petstore/swift6/validation/PetstoreClient/Classes/OpenAPIs/Infrastructure/URLSessionImplementations.swift @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder: RequestBuilder, @unchecked Sendable { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) } else if contentType.hasPrefix("application/x-www-form-urlencoded") { encoding = FormURLEncoding() - } else if contentType.hasPrefix("application/octet-stream"){ + } else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") { encoding = OctetStreamEncoding() } else { fatalError("Unsupported Media Type - \(contentType)")