Skip to content

Commit 0768ddc

Browse files
authored
[swift] support content type application json variants (#18539)
* [swift] support content type application json variants * [swift] support content type application json variants
1 parent a4cf255 commit 0768ddc

19 files changed

Lines changed: 19 additions & 19 deletions

File tree

modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private var managerStore = SynchronizedDictionary<String, Alamofire.Session>()
9696
case .options, .post, .put, .patch, .delete, .trace, .connect:
9797
let contentType = headers["Content-Type"] ?? "application/json"
9898
99-
if contentType.hasPrefix("application/json") {
99+
if contentType.hasPrefix("application/") && contentType.contains("json") {
100100
encoding = JSONDataEncoding()
101101
} else if contentType.hasPrefix("multipart/form-data") {
102102
encoding = nil

modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136
137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
9696
case .options, .post, .put, .patch, .delete, .trace, .connect:
9797
let contentType = headers["Content-Type"] ?? "application/json"
9898

99-
if contentType.hasPrefix("application/json") {
99+
if contentType.hasPrefix("application/") && contentType.contains("json") {
100100
encoding = JSONDataEncoding()
101101
} else if contentType.hasPrefix("multipart/form-data") {
102102
encoding = nil

samples/client/petstore/swift5/anycodableLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
134134
case .options, .post, .put, .patch, .delete, .trace, .connect:
135135
let contentType = headers["Content-Type"] ?? "application/json"
136136

137-
if contentType.hasPrefix("application/json") {
137+
if contentType.hasPrefix("application/") && contentType.contains("json") {
138138
encoding = JSONDataEncoding()
139139
} else if contentType.hasPrefix("multipart/form-data") {
140140
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

0 commit comments

Comments
 (0)