forked from loafle/openapi-generator-original
[swift] support content type application json variants (#18539)
* [swift] support content type application json variants * [swift] support content type application json variants
This commit is contained in:
parent
a4cf255dce
commit
0768ddcd7c
@ -96,7 +96,7 @@ private var managerStore = SynchronizedDictionary<String, Alamofire.Session>()
|
||||
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
|
||||
|
@ -134,7 +134,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
|
||||
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:))
|
||||
|
@ -96,7 +96,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
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
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
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:))
|
||||
|
Loading…
x
Reference in New Issue
Block a user