mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 21:07:05 +00:00
[Swift6] better configuration (#19732)
* [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements * [swift6] general improvements
This commit is contained in:
@@ -9,41 +9,62 @@ import Foundation
|
||||
import FoundationNetworking
|
||||
#endif
|
||||
|
||||
open class PetstoreClientAPI: @unchecked Sendable {
|
||||
private init() {}
|
||||
public static let shared = PetstoreClientAPI()
|
||||
|
||||
public var basePath = "http://petstore.swagger.io:80/v2"
|
||||
public var customHeaders: [String: String] = [:]
|
||||
open class OpenAPIClient: @unchecked Sendable {
|
||||
public var basePath: String
|
||||
public var customHeaders: [String: String]
|
||||
public var credential: URLCredential?
|
||||
public var requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory()
|
||||
public var apiResponseQueue: DispatchQueue = .main
|
||||
public var requestBuilderFactory: RequestBuilderFactory
|
||||
public var apiResponseQueue: DispatchQueue
|
||||
public var codableHelper: CodableHelper
|
||||
|
||||
/// Configures the range of HTTP status codes that will result in a successful response
|
||||
///
|
||||
/// If a HTTP status code is outside of this range the response will be interpreted as failed.
|
||||
public var successfulStatusCodeRange: Range = 200..<300
|
||||
public var successfulStatusCodeRange: Range<Int>
|
||||
|
||||
public init(
|
||||
basePath: String = "http://petstore.swagger.io:80/v2",
|
||||
customHeaders: [String: String] = [:],
|
||||
credential: URLCredential? = nil,
|
||||
requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory(),
|
||||
apiResponseQueue: DispatchQueue = .main,
|
||||
codableHelper: CodableHelper = CodableHelper(),
|
||||
successfulStatusCodeRange: Range<Int> = 200..<300
|
||||
) {
|
||||
self.basePath = basePath
|
||||
self.customHeaders = customHeaders
|
||||
self.credential = credential
|
||||
self.requestBuilderFactory = requestBuilderFactory
|
||||
self.apiResponseQueue = apiResponseQueue
|
||||
self.codableHelper = codableHelper
|
||||
self.successfulStatusCodeRange = successfulStatusCodeRange
|
||||
}
|
||||
|
||||
public static let shared = OpenAPIClient()
|
||||
}
|
||||
|
||||
open class RequestBuilder<T>: @unchecked Sendable {
|
||||
var credential: URLCredential?
|
||||
var headers: [String: String]
|
||||
public var credential: URLCredential?
|
||||
public var headers: [String: String]
|
||||
public let parameters: [String: Any]?
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
public let requestTask: RequestTask = RequestTask()
|
||||
public let requiresAuthentication: Bool
|
||||
public let openAPIClient: OpenAPIClient
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
public var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool) {
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool, openAPIClient: OpenAPIClient = OpenAPIClient.shared) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
self.headers = headers
|
||||
self.requiresAuthentication = requiresAuthentication
|
||||
self.openAPIClient = openAPIClient
|
||||
|
||||
addHeaders(PetstoreClientAPI.shared.customHeaders)
|
||||
addHeaders(openAPIClient.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders: [String: String]) {
|
||||
@@ -53,7 +74,7 @@ open class RequestBuilder<T>: @unchecked Sendable {
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
open func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.shared.apiResponseQueue, _ completion: @Sendable @escaping (_ result: Swift.Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
open func execute(completion: @Sendable @escaping (_ result: Swift.Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
return requestTask
|
||||
}
|
||||
|
||||
@@ -65,7 +86,7 @@ open class RequestBuilder<T>: @unchecked Sendable {
|
||||
}
|
||||
|
||||
open func addCredential() -> Self {
|
||||
credential = PetstoreClientAPI.shared.credential
|
||||
credential = openAPIClient.credential
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ open class AnotherFakeAPI {
|
||||
To test special tags
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func call123testSpecialTags( body: Client) -> Promise<Client> {
|
||||
open class func call123testSpecialTags(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
call123testSpecialTagsWithRequestBuilder(body: body).execute { result in
|
||||
call123testSpecialTagsWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -37,12 +38,14 @@ open class AnotherFakeAPI {
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags and operation ID starting with number
|
||||
- parameter body: (body) client model
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func call123testSpecialTagsWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
open class func call123testSpecialTagsWithRequestBuilder(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Client> {
|
||||
let localVariablePath = "/another-fake/dummy"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -52,8 +55,8 @@ open class AnotherFakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ open class FakeAPI {
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Bool>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize( body: Bool? = nil) -> Promise<Bool> {
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Bool> {
|
||||
let deferred = Promise<Bool>.pending()
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { result in
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -35,12 +36,14 @@ open class FakeAPI {
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil) -> RequestBuilder<Bool> {
|
||||
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Bool> {
|
||||
let localVariablePath = "/fake/outer/boolean"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -50,19 +53,20 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Bool>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Bool>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize( body: OuterComposite? = nil) -> Promise<OuterComposite> {
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<OuterComposite> {
|
||||
let deferred = Promise<OuterComposite>.pending()
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { result in
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -77,12 +81,14 @@ open class FakeAPI {
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||
open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<OuterComposite> {
|
||||
let localVariablePath = "/fake/outer/composite"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -92,19 +98,20 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<OuterComposite>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Double>
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize( body: Double? = nil) -> Promise<Double> {
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Double> {
|
||||
let deferred = Promise<Double>.pending()
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { result in
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -119,12 +126,14 @@ open class FakeAPI {
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil) -> RequestBuilder<Double> {
|
||||
open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Double> {
|
||||
let localVariablePath = "/fake/outer/number"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -134,19 +143,20 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Double>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Double>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
open class func fakeOuterStringSerialize( body: String? = nil) -> Promise<String> {
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<String> {
|
||||
let deferred = Promise<String>.pending()
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { result in
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -161,12 +171,14 @@ open class FakeAPI {
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil) -> RequestBuilder<String> {
|
||||
open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<String> {
|
||||
let localVariablePath = "/fake/outer/string"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -176,19 +188,20 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testBodyWithFileSchema( body: FileSchemaTestClass) -> Promise<Void> {
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute { result in
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -203,12 +216,14 @@ open class FakeAPI {
|
||||
- PUT /fake/body-with-file-schema
|
||||
- For this test, the body for this request much reference a schema named `File`.
|
||||
- parameter body: (body)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithFileSchemaWithRequestBuilder(body: FileSchemaTestClass) -> RequestBuilder<Void> {
|
||||
open class func testBodyWithFileSchemaWithRequestBuilder(body: FileSchemaTestClass, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake/body-with-file-schema"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -218,20 +233,21 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter query: (query)
|
||||
- parameter body: (body)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParams( query: String, body: User) -> Promise<Void> {
|
||||
open class func testBodyWithQueryParams(query: String, body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { result in
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -245,17 +261,19 @@ open class FakeAPI {
|
||||
/**
|
||||
- PUT /fake/body-with-query-params
|
||||
- parameter query: (query)
|
||||
- parameter body: (body)
|
||||
- parameter body: (body)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, body: User) -> RequestBuilder<Void> {
|
||||
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake/body-with-query-params"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"query": (wrappedValue: query.encodeToJSON(), isExplode: false),
|
||||
"query": (wrappedValue: query.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -264,20 +282,21 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func testClientModel( body: Client) -> Promise<Client> {
|
||||
open class func testClientModel(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
testClientModelWithRequestBuilder(body: body).execute { result in
|
||||
testClientModelWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -293,12 +312,14 @@ open class FakeAPI {
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- parameter body: (body) client model
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClientModelWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
open class func testClientModelWithRequestBuilder(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Client> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -308,9 +329,9 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,11 +351,12 @@ open class FakeAPI {
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testEndpointParameters( number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void> {
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { result in
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -353,39 +375,41 @@ open class FakeAPI {
|
||||
- type: http
|
||||
- name: http_basic_test
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"integer": integer?.encodeToJSON(),
|
||||
"int32": int32?.encodeToJSON(),
|
||||
"int64": int64?.encodeToJSON(),
|
||||
"number": number.encodeToJSON(),
|
||||
"float": float?.encodeToJSON(),
|
||||
"double": double.encodeToJSON(),
|
||||
"string": string?.encodeToJSON(),
|
||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToJSON(),
|
||||
"byte": byte.encodeToJSON(),
|
||||
"binary": binary?.encodeToJSON(),
|
||||
"date": date?.encodeToJSON(),
|
||||
"dateTime": dateTime?.encodeToJSON(),
|
||||
"password": password?.encodeToJSON(),
|
||||
"callback": callback?.encodeToJSON(),
|
||||
"integer": integer?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"int32": int32?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"int64": int64?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"number": number.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"float": float?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"double": double.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"string": string?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"byte": byte.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"binary": binary?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"date": date?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"dateTime": dateTime?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"password": password?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"callback": callback?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -399,9 +423,9 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,11 +506,12 @@ open class FakeAPI {
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .dollar)
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .efg)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testEnumParameters( enumHeaderStringArray: [EnumHeaderStringArray_testEnumParameters]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [EnumQueryStringArray_testEnumParameters]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [EnumFormStringArray_testEnumParameters]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> Promise<Void> {
|
||||
open class func testEnumParameters(enumHeaderStringArray: [EnumHeaderStringArray_testEnumParameters]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [EnumQueryStringArray_testEnumParameters]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [EnumFormStringArray_testEnumParameters]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { result in
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -502,21 +527,23 @@ open class FakeAPI {
|
||||
- GET /fake
|
||||
- To test enum parameters
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .efg)
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .efg)
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .dollar)
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .efg)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .efg)
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .efg)
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .dollar)
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .efg)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [EnumHeaderStringArray_testEnumParameters]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [EnumQueryStringArray_testEnumParameters]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [EnumFormStringArray_testEnumParameters]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [EnumHeaderStringArray_testEnumParameters]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [EnumQueryStringArray_testEnumParameters]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [EnumFormStringArray_testEnumParameters]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"enum_form_string_array": enumFormStringArray?.encodeToJSON(),
|
||||
"enum_form_string": enumFormString?.encodeToJSON(),
|
||||
"enum_form_string_array": enumFormStringArray?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"enum_form_string": enumFormString?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -524,23 +551,23 @@ open class FakeAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToJSON(), isExplode: false),
|
||||
"enum_query_string": (wrappedValue: enumQueryString?.encodeToJSON(), isExplode: false),
|
||||
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToJSON(), isExplode: false),
|
||||
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToJSON(), isExplode: false),
|
||||
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"enum_query_string": (wrappedValue: enumQueryString?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"enum_header_string_array": enumHeaderStringArray?.encodeToJSON(),
|
||||
"enum_header_string": enumHeaderString?.encodeToJSON(),
|
||||
"enum_header_string_array": enumHeaderStringArray?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"enum_header_string": enumHeaderString?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -552,11 +579,12 @@ open class FakeAPI {
|
||||
- parameter stringGroup: (query) String in group parameters (optional)
|
||||
- parameter booleanGroup: (header) Boolean in group parameters (optional)
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testGroupParameters( requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> Promise<Void> {
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { result in
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -572,47 +600,50 @@ open class FakeAPI {
|
||||
- DELETE /fake
|
||||
- Fake endpoint to test group parameters (optional)
|
||||
- parameter requiredStringGroup: (query) Required String in group parameters
|
||||
- parameter requiredBooleanGroup: (header) Required Boolean in group parameters
|
||||
- parameter requiredInt64Group: (query) Required Integer in group parameters
|
||||
- parameter stringGroup: (query) String in group parameters (optional)
|
||||
- parameter booleanGroup: (header) Boolean in group parameters (optional)
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- parameter requiredBooleanGroup: (header) Required Boolean in group parameters
|
||||
- parameter requiredInt64Group: (query) Required Integer in group parameters
|
||||
- parameter stringGroup: (query) String in group parameters (optional)
|
||||
- parameter booleanGroup: (header) Boolean in group parameters (optional)
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testGroupParametersWithRequestBuilder(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> RequestBuilder<Void> {
|
||||
open class func testGroupParametersWithRequestBuilder(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"required_string_group": (wrappedValue: requiredStringGroup.encodeToJSON(), isExplode: false),
|
||||
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToJSON(), isExplode: false),
|
||||
"string_group": (wrappedValue: stringGroup?.encodeToJSON(), isExplode: false),
|
||||
"int64_group": (wrappedValue: int64Group?.encodeToJSON(), isExplode: false),
|
||||
"required_string_group": (wrappedValue: requiredStringGroup.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"string_group": (wrappedValue: stringGroup?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"int64_group": (wrappedValue: int64Group?.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
"required_boolean_group": requiredBooleanGroup.encodeToJSON(),
|
||||
"boolean_group": booleanGroup?.encodeToJSON(),
|
||||
"required_boolean_group": requiredBooleanGroup.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"boolean_group": booleanGroup?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
|
||||
- parameter param: (body) request body
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalProperties( param: [String: String]) -> Promise<Void> {
|
||||
open class func testInlineAdditionalProperties(param: [String: String], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { result in
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -627,12 +658,14 @@ open class FakeAPI {
|
||||
test inline additionalProperties
|
||||
- POST /fake/inline-additionalProperties
|
||||
- parameter param: (body) request body
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String: String]) -> RequestBuilder<Void> {
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String: String], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake/inline-additionalProperties"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -642,9 +675,9 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -652,11 +685,12 @@ open class FakeAPI {
|
||||
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testJsonFormData( param: String, param2: String) -> Promise<Void> {
|
||||
open class func testJsonFormData(param: String, param2: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { result in
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -671,15 +705,17 @@ open class FakeAPI {
|
||||
test json serialization of form data
|
||||
- GET /fake/jsonFormData
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- parameter param2: (form) field2
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake/jsonFormData"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"param": param.encodeToJSON(),
|
||||
"param2": param2.encodeToJSON(),
|
||||
"param": param.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"param2": param2.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -693,8 +729,8 @@ open class FakeAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ open class FakeClassnameTags123API {
|
||||
To test class name in snake case
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func testClassname( body: Client) -> Promise<Client> {
|
||||
open class func testClassname(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
testClassnameWithRequestBuilder(body: body).execute { result in
|
||||
testClassnameWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -40,12 +41,14 @@ open class FakeClassnameTags123API {
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- parameter body: (body) client model
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
open class func testClassnameWithRequestBuilder(body: Client, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Client> {
|
||||
let localVariablePath = "/fake_classname_test"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -55,8 +58,8 @@ open class FakeClassnameTags123API {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ open class PetAPI {
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func addPet( body: Pet) -> Promise<Void> {
|
||||
open class func addPet(body: Pet, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
addPetWithRequestBuilder(body: body).execute { result in
|
||||
addPetWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -42,12 +43,14 @@ open class PetAPI {
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func addPetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||
open class func addPetWithRequestBuilder(body: Pet, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/pet"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -57,9 +60,9 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,11 +70,12 @@ open class PetAPI {
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deletePet( petId: Int64, apiKey: String? = nil) -> Promise<Void> {
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { result in
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -89,28 +93,30 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter apiKey: (header) (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
|
||||
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
var localVariablePath = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey?.encodeToJSON(),
|
||||
"api_key": apiKey?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,11 +132,12 @@ open class PetAPI {
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
open class func findPetsByStatus( status: [Status_findPetsByStatus]) -> Promise<[Pet]> {
|
||||
open class func findPetsByStatus(status: [Status_findPetsByStatus], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pending()
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { result in
|
||||
findPetsByStatusWithRequestBuilder(status: status, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -149,16 +156,18 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [Status_findPetsByStatus]) -> RequestBuilder<[Pet]> {
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [Status_findPetsByStatus], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<[Pet]> {
|
||||
let localVariablePath = "/pet/findByStatus"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": (wrappedValue: status.encodeToJSON(), isExplode: false),
|
||||
"status": (wrappedValue: status.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -167,21 +176,22 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
@available(*, deprecated, message: "This operation is deprecated.")
|
||||
open class func findPetsByTags( tags: [String]) -> Promise<[Pet]> {
|
||||
open class func findPetsByTags(tags: [String], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pending()
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { result in
|
||||
findPetsByTagsWithRequestBuilder(tags: tags, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -200,17 +210,19 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter tags: (query) Tags to filter by
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@available(*, deprecated, message: "This operation is deprecated.")
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<[Pet]> {
|
||||
let localVariablePath = "/pet/findByTags"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": (wrappedValue: tags.encodeToJSON(), isExplode: false),
|
||||
"tags": (wrappedValue: tags.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -219,20 +231,21 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Pet>
|
||||
*/
|
||||
open class func getPetById( petId: Int64) -> Promise<Pet> {
|
||||
open class func getPetById(petId: Int64, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Pet> {
|
||||
let deferred = Promise<Pet>.pending()
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { result in
|
||||
getPetByIdWithRequestBuilder(petId: petId, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -251,14 +264,16 @@ open class PetAPI {
|
||||
- type: apiKey api_key (HEADER)
|
||||
- name: api_key
|
||||
- parameter petId: (path) ID of pet to return
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
|
||||
open class func getPetByIdWithRequestBuilder(petId: Int64, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Pet> {
|
||||
var localVariablePath = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -269,20 +284,21 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Pet>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updatePet( body: Pet) -> Promise<Void> {
|
||||
open class func updatePet(body: Pet, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updatePetWithRequestBuilder(body: body).execute { result in
|
||||
updatePetWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -300,12 +316,14 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||
open class func updatePetWithRequestBuilder(body: Pet, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/pet"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -315,9 +333,9 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,11 +344,12 @@ open class PetAPI {
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updatePetWithForm( petId: Int64, name: String? = nil, status: String? = nil) -> Promise<Void> {
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { result in
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -348,19 +367,21 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
|
||||
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
var localVariablePath = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"name": name?.encodeToJSON(),
|
||||
"status": status?.encodeToJSON(),
|
||||
"name": name?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"status": status?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -374,9 +395,9 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,11 +406,12 @@ open class PetAPI {
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<ApiResponse>
|
||||
*/
|
||||
open class func uploadFile( petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Promise<ApiResponse> {
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<ApiResponse> {
|
||||
let deferred = Promise<ApiResponse>.pending()
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -407,19 +429,21 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/pet/{petId}/uploadImage"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata?.encodeToJSON(),
|
||||
"file": file?.encodeToJSON(),
|
||||
"additionalMetadata": additionalMetadata?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"file": file?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -433,9 +457,9 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,11 +468,12 @@ open class PetAPI {
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter requiredFile: (form) file to upload
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequiredFile( petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> Promise<ApiResponse> {
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<ApiResponse> {
|
||||
let deferred = Promise<ApiResponse>.pending()
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -466,19 +491,21 @@ open class PetAPI {
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter requiredFile: (form) file to upload
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter requiredFile: (form) file to upload
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> RequestBuilder<ApiResponse> {
|
||||
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/fake/{petId}/uploadImageWithRequiredFile"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata?.encodeToJSON(),
|
||||
"requiredFile": requiredFile.encodeToJSON(),
|
||||
"additionalMetadata": additionalMetadata?.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
"requiredFile": requiredFile.encodeToJSON(codableHelper: openAPIClient.codableHelper),
|
||||
]
|
||||
|
||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||
@@ -492,8 +519,8 @@ open class PetAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ open class StoreAPI {
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deleteOrder( orderId: String) -> Promise<Void> {
|
||||
open class func deleteOrder(orderId: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { result in
|
||||
deleteOrderWithRequestBuilder(orderId: orderId, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -37,14 +38,16 @@ open class StoreAPI {
|
||||
- DELETE /store/order/{order_id}
|
||||
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
|
||||
open class func deleteOrderWithRequestBuilder(orderId: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
var localVariablePath = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(APIHelper.mapValueToPathItem(orderId))"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -55,19 +58,20 @@ open class StoreAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<[String: Int]>
|
||||
*/
|
||||
open class func getInventory() -> Promise<[String: Int]> {
|
||||
open class func getInventory(openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<[String: Int]> {
|
||||
let deferred = Promise<[String: Int]>.pending()
|
||||
getInventoryWithRequestBuilder().execute { result in
|
||||
getInventoryWithRequestBuilder(openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -85,11 +89,13 @@ open class StoreAPI {
|
||||
- API Key:
|
||||
- type: apiKey api_key (HEADER)
|
||||
- name: api_key
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<[String: Int]>
|
||||
*/
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String: Int]> {
|
||||
open class func getInventoryWithRequestBuilder(openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<[String: Int]> {
|
||||
let localVariablePath = "/store/inventory"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -100,20 +106,21 @@ open class StoreAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<[String: Int]>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
open class func getOrderById( orderId: Int64) -> Promise<Order> {
|
||||
open class func getOrderById(orderId: Int64, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pending()
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { result in
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -129,14 +136,16 @@ open class StoreAPI {
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
|
||||
open class func getOrderByIdWithRequestBuilder(orderId: Int64, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Order> {
|
||||
var localVariablePath = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(APIHelper.mapValueToPathItem(orderId))"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -147,20 +156,21 @@ open class StoreAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
open class func placeOrder( body: Order) -> Promise<Order> {
|
||||
open class func placeOrder(body: Order, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pending()
|
||||
placeOrderWithRequestBuilder(body: body).execute { result in
|
||||
placeOrderWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -175,12 +185,14 @@ open class StoreAPI {
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func placeOrderWithRequestBuilder(body: Order) -> RequestBuilder<Order> {
|
||||
open class func placeOrderWithRequestBuilder(body: Order, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Order> {
|
||||
let localVariablePath = "/store/order"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -190,8 +202,8 @@ open class StoreAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ open class UserAPI {
|
||||
Create user
|
||||
|
||||
- parameter body: (body) Created user object
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUser( body: User) -> Promise<Void> {
|
||||
open class func createUser(body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUserWithRequestBuilder(body: body).execute { result in
|
||||
createUserWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -37,12 +38,14 @@ open class UserAPI {
|
||||
- POST /user
|
||||
- This can only be done by the logged in user.
|
||||
- parameter body: (body) Created user object
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUserWithRequestBuilder(body: User) -> RequestBuilder<Void> {
|
||||
open class func createUserWithRequestBuilder(body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/user"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -52,20 +55,21 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInput( body: [User]) -> Promise<Void> {
|
||||
open class func createUsersWithArrayInput(body: [User], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body).execute { result in
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -80,12 +84,14 @@ open class UserAPI {
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithArray
|
||||
- parameter body: (body) List of user object
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||
open class func createUsersWithArrayInputWithRequestBuilder(body: [User], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/user/createWithArray"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -95,20 +101,21 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUsersWithListInput( body: [User]) -> Promise<Void> {
|
||||
open class func createUsersWithListInput(body: [User], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUsersWithListInputWithRequestBuilder(body: body).execute { result in
|
||||
createUsersWithListInputWithRequestBuilder(body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -123,12 +130,14 @@ open class UserAPI {
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithList
|
||||
- parameter body: (body) List of user object
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithListInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||
open class func createUsersWithListInputWithRequestBuilder(body: [User], openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/user/createWithList"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -138,20 +147,21 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deleteUser( username: String) -> Promise<Void> {
|
||||
open class func deleteUser(username: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deleteUserWithRequestBuilder(username: username).execute { result in
|
||||
deleteUserWithRequestBuilder(username: username, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -167,14 +177,16 @@ open class UserAPI {
|
||||
- DELETE /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
|
||||
open class func deleteUserWithRequestBuilder(username: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
var localVariablePath = "/user/{username}"
|
||||
let usernamePreEscape = "\(APIHelper.mapValueToPathItem(username))"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -185,20 +197,21 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<User>
|
||||
*/
|
||||
open class func getUserByName( username: String) -> Promise<User> {
|
||||
open class func getUserByName(username: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<User> {
|
||||
let deferred = Promise<User>.pending()
|
||||
getUserByNameWithRequestBuilder(username: username).execute { result in
|
||||
getUserByNameWithRequestBuilder(username: username, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -213,14 +226,16 @@ open class UserAPI {
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
|
||||
open class func getUserByNameWithRequestBuilder(username: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<User> {
|
||||
var localVariablePath = "/user/{username}"
|
||||
let usernamePreEscape = "\(APIHelper.mapValueToPathItem(username))"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -231,9 +246,9 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<User>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,11 +256,12 @@ open class UserAPI {
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
open class func loginUser( username: String, password: String) -> Promise<String> {
|
||||
open class func loginUser(username: String, password: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<String> {
|
||||
let deferred = Promise<String>.pending()
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute { result in
|
||||
loginUserWithRequestBuilder(username: username, password: password, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
deferred.resolver.fulfill(response.body)
|
||||
@@ -261,18 +277,20 @@ open class UserAPI {
|
||||
- GET /user/login
|
||||
- responseHeaders: [X-Rate-Limit(Int), X-Expires-After(Date)]
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter password: (query) The password for login in clear text
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
|
||||
open class func loginUserWithRequestBuilder(username: String, password: String, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<String> {
|
||||
let localVariablePath = "/user/login"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": (wrappedValue: username.encodeToJSON(), isExplode: false),
|
||||
"password": (wrappedValue: password.encodeToJSON(), isExplode: false),
|
||||
"username": (wrappedValue: username.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
"password": (wrappedValue: password.encodeToJSON(codableHelper: openAPIClient.codableHelper), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -281,19 +299,20 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = openAPIClient.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func logoutUser() -> Promise<Void> {
|
||||
open class func logoutUser(openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
logoutUserWithRequestBuilder().execute { result in
|
||||
logoutUserWithRequestBuilder(openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -307,11 +326,13 @@ open class UserAPI {
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
- GET /user/logout
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||
open class func logoutUserWithRequestBuilder(openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/user/logout"
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters: [String: Any]? = nil
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
@@ -322,9 +343,9 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,11 +353,12 @@ open class UserAPI {
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter body: (body) Updated user object
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updateUser( username: String, body: User) -> Promise<Void> {
|
||||
open class func updateUser(username: String, body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updateUserWithRequestBuilder(username: username, body: body).execute { result in
|
||||
updateUserWithRequestBuilder(username: username, body: body, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deferred.resolver.fulfill(())
|
||||
@@ -352,16 +374,18 @@ open class UserAPI {
|
||||
- PUT /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter body: (body) Updated user object
|
||||
- parameter body: (body) Updated user object
|
||||
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
|
||||
open class func updateUserWithRequestBuilder(username: String, body: User, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
var localVariablePath = "/user/{username}"
|
||||
let usernamePreEscape = "\(APIHelper.mapValueToPathItem(username))"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let localVariableURLString = PetstoreClientAPI.shared.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body, codableHelper: openAPIClient.codableHelper)
|
||||
|
||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
|
||||
@@ -371,8 +395,8 @@ open class UserAPI {
|
||||
|
||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.shared.requestBuilderFactory.getNonDecodableBuilder()
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = openAPIClient.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false, openAPIClient: openAPIClient)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
open class CodableHelper: @unchecked Sendable {
|
||||
private init() {}
|
||||
public static let shared = CodableHelper()
|
||||
public init() {}
|
||||
|
||||
private var customDateFormatter: DateFormatter?
|
||||
private var defaultDateFormatter: DateFormatter = OpenISO8601DateFormatter()
|
||||
|
||||
@@ -14,97 +14,97 @@ import AnyCodable
|
||||
@preconcurrency import PromiseKit
|
||||
|
||||
extension Bool: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Float: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Int: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Int32: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Int64: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Double: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension Decimal: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension String: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension URL: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension UUID: JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { self }
|
||||
}
|
||||
|
||||
extension RawRepresentable where RawValue: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self.rawValue }
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any { return self.rawValue }
|
||||
}
|
||||
|
||||
private func encodeIfPossible<T>(_ object: T) -> Any {
|
||||
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> Any {
|
||||
if let encodableObject = object as? JSONEncodable {
|
||||
return encodableObject.encodeToJSON()
|
||||
return encodableObject.encodeToJSON(codableHelper: codableHelper)
|
||||
} else {
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
extension Array: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.map(encodeIfPossible)
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
||||
}
|
||||
}
|
||||
|
||||
extension Set: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return Array(self).encodeToJSON()
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
return Array(self).encodeToJSON(codableHelper: codableHelper)
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
var dictionary = [AnyHashable: Any]()
|
||||
for (key, value) in self {
|
||||
dictionary[key] = encodeIfPossible(value)
|
||||
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
||||
}
|
||||
return dictionary
|
||||
}
|
||||
}
|
||||
|
||||
extension Data: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||
}
|
||||
}
|
||||
|
||||
extension Date: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return CodableHelper.shared.dateFormatter.string(from: self)
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
return codableHelper.dateFormatter.string(from: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension JSONEncodable where Self: Encodable {
|
||||
func encodeToJSON() -> Any {
|
||||
guard let data = try? CodableHelper.shared.jsonEncoder.encode(self) else {
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any {
|
||||
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
||||
fatalError("Could not encode to json: \(self)")
|
||||
}
|
||||
return data.encodeToJSON()
|
||||
return data.encodeToJSON(codableHelper: codableHelper)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,12 +230,6 @@ extension KeyedDecodingContainerProtocol {
|
||||
|
||||
}
|
||||
|
||||
extension HTTPURLResponse {
|
||||
var isStatusCodeSuccessful: Bool {
|
||||
return PetstoreClientAPI.shared.successfulStatusCodeRange.contains(statusCode)
|
||||
}
|
||||
}
|
||||
|
||||
extension RequestBuilder {
|
||||
public func execute() -> Promise<Response<T>> {
|
||||
let deferred = Promise<Response<T>>.pending()
|
||||
|
||||
@@ -9,12 +9,12 @@ import Foundation
|
||||
|
||||
open class JSONEncodingHelper {
|
||||
|
||||
open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> [String: Any]? {
|
||||
open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?, codableHelper: CodableHelper) -> [String: Any]? {
|
||||
var params: [String: Any]?
|
||||
|
||||
// Encode the Encodable object
|
||||
if let encodableObj = encodableObj {
|
||||
let encodeResult = CodableHelper.shared.encode(encodableObj)
|
||||
let encodeResult = codableHelper.encode(encodableObj)
|
||||
do {
|
||||
let data = try encodeResult.get()
|
||||
params = JSONDataEncoding.encodingParameters(jsonData: data)
|
||||
@@ -26,7 +26,7 @@ open class JSONEncodingHelper {
|
||||
return params
|
||||
}
|
||||
|
||||
open class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? {
|
||||
open class func encodingParameters(forEncodableObject encodableObj: Any?, codableHelper: CodableHelper) -> [String: Any]? {
|
||||
var params: [String: Any]?
|
||||
|
||||
if let encodableObj = encodableObj {
|
||||
|
||||
@@ -10,7 +10,7 @@ import FoundationNetworking
|
||||
#endif
|
||||
|
||||
protocol JSONEncodable {
|
||||
func encodeToJSON() -> Any
|
||||
func encodeToJSON(codableHelper: CodableHelper) -> Any
|
||||
}
|
||||
|
||||
/// An enum where the last case value can be used as a default catch-all.
|
||||
|
||||
@@ -40,12 +40,14 @@ extension URLSession: URLSessionProtocol {
|
||||
|
||||
extension URLSessionDataTask: URLSessionDataTaskProtocol {}
|
||||
|
||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
public class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||
public init() {}
|
||||
|
||||
public func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
return URLSessionRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
public func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
return URLSessionDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
@@ -79,8 +81,8 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
*/
|
||||
public var taskDidReceiveChallenge: PetstoreClientAPIChallengeHandler?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, headers: headers, requiresAuthentication: requiresAuthentication)
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool, openAPIClient: OpenAPIClient = OpenAPIClient.shared) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, headers: headers, requiresAuthentication: requiresAuthentication, openAPIClient: openAPIClient)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +128,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
override open func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.shared.apiResponseQueue, _ completion: @Sendable @escaping (_ result: Swift.Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
override open func execute(completion: @Sendable @escaping (_ result: Swift.Result<Response<T>, ErrorResponse>) -> Void) -> RequestTask {
|
||||
let urlSession = createURLSession()
|
||||
|
||||
guard let xMethod = HTTPMethod(rawValue: method) else {
|
||||
@@ -159,7 +161,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers)
|
||||
|
||||
let dataTask = urlSession.dataTaskFromProtocol(with: request) { data, response, error in
|
||||
apiResponseQueue.async {
|
||||
self.openAPIClient.apiResponseQueue.async {
|
||||
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
|
||||
self.cleanupRequest()
|
||||
}
|
||||
@@ -174,7 +176,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
|
||||
dataTask.resume()
|
||||
} catch {
|
||||
apiResponseQueue.async {
|
||||
self.openAPIClient.apiResponseQueue.async {
|
||||
completion(.failure(ErrorResponse.error(415, nil, nil, error)))
|
||||
}
|
||||
}
|
||||
@@ -201,7 +203,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
return
|
||||
}
|
||||
|
||||
guard httpResponse.isStatusCodeSuccessful else {
|
||||
guard openAPIClient.successfulStatusCodeRange.contains(httpResponse.statusCode) else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode)))
|
||||
return
|
||||
}
|
||||
@@ -219,7 +221,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
|
||||
|
||||
open func buildHeaders() -> [String: String] {
|
||||
var httpHeaders: [String: String] = [:]
|
||||
for (key, value) in PetstoreClientAPI.shared.customHeaders {
|
||||
for (key, value) in openAPIClient.customHeaders {
|
||||
httpHeaders[key] = value
|
||||
}
|
||||
for (key, value) in headers {
|
||||
@@ -294,7 +296,7 @@ open class URLSessionDecodableRequestBuilder<T: Decodable>: URLSessionRequestBui
|
||||
return
|
||||
}
|
||||
|
||||
guard httpResponse.isStatusCodeSuccessful else {
|
||||
guard openAPIClient.successfulStatusCodeRange.contains(httpResponse.statusCode) else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode)))
|
||||
return
|
||||
}
|
||||
@@ -362,7 +364,7 @@ open class URLSessionDecodableRequestBuilder<T: Decodable>: URLSessionRequestBui
|
||||
return
|
||||
}
|
||||
|
||||
let decodeResult = CodableHelper.shared.decode(T.self, from: unwrappedData)
|
||||
let decodeResult = openAPIClient.codableHelper.decode(T.self, from: unwrappedData)
|
||||
|
||||
switch decodeResult {
|
||||
case let .success(decodableObj):
|
||||
|
||||
Reference in New Issue
Block a user