mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 00:27:07 +00:00
[Swift 4] Add createURLRequest method (#1727)
* add create URL Request method * add comment
This commit is contained in:
committed by
William Cheng
parent
902a4b4099
commit
c2273a651a
@@ -64,6 +64,15 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
return Alamofire.SessionManager(configuration: configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to custom request constructor.
|
||||
*/
|
||||
open func createURLRequest() -> URLRequest? {
|
||||
let encoding: ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
|
||||
guard let originalRequest = try? URLRequest(url: URLString, method: HTTPMethod(rawValue: method)!, headers: buildHeaders()) else { return nil }
|
||||
return try? encoding.encode(originalRequest, with: parameters)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the Content-Type
|
||||
that is given to an uploaded form part.
|
||||
|
||||
Reference in New Issue
Block a user