diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache index 36b4e80c06c..9ef5937ccc3 100644 --- a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache @@ -96,7 +96,7 @@ private var managerStore = SynchronizedDictionary() case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = nil 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 a17db02e689..eda23b2f65b 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 @@ -134,7 +134,7 @@ private var credentialStore = SynchronizedDictionary() case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 3ed8fe080f3..0d0e06ee91b 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -96,7 +96,7 @@ open class AlamofireRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = nil diff --git a/samples/client/petstore/swift5/anycodableLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/anycodableLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/anycodableLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/anycodableLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index 6d67c0361f6..ede5a95feba 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ internal class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) 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 f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/validation/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) diff --git a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index f05a1808744..e7bbc538c18 100644 --- a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -134,7 +134,7 @@ open class URLSessionRequestBuilder: RequestBuilder { case .options, .post, .put, .patch, .delete, .trace, .connect: let contentType = headers["Content-Type"] ?? "application/json" - if contentType.hasPrefix("application/json") { + if contentType.hasPrefix("application/") && contentType.contains("json") { encoding = JSONDataEncoding() } else if contentType.hasPrefix("multipart/form-data") { encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))