mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 08:02:43 +00:00
Merge remote-tracking branch 'origin/6.3.x' into 7.0.x
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
.gitignore
|
||||
.swiftformat
|
||||
Cartfile
|
||||
Package.swift
|
||||
PetstoreClient.podspec
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# This file is auto-generated by OpenAPI Generator: https://openapi-generator.tech/
|
||||
#
|
||||
# For rules on SwiftFormat, please refer to https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md
|
||||
#
|
||||
# file options
|
||||
|
||||
# uncomment below to exclude files, folders
|
||||
#--exclude path/to/test1.swift,Snapshots,Build
|
||||
|
||||
# format options
|
||||
|
||||
--allman false
|
||||
--binarygrouping 4,8
|
||||
--commas always
|
||||
--comments indent
|
||||
--decimalgrouping 3,6
|
||||
--elseposition same-line
|
||||
--empty void
|
||||
--exponentcase lowercase
|
||||
--exponentgrouping disabled
|
||||
--fractiongrouping disabled
|
||||
--header ignore
|
||||
--hexgrouping 4,8
|
||||
--hexliteralcase uppercase
|
||||
--ifdef indent
|
||||
--indent 4
|
||||
--indentcase false
|
||||
--importgrouping testable-bottom
|
||||
--linebreaks lf
|
||||
--maxwidth none
|
||||
--octalgrouping 4,8
|
||||
--operatorfunc spaced
|
||||
--patternlet hoist
|
||||
--ranges spaced
|
||||
--self remove
|
||||
--semicolons inline
|
||||
--stripunusedargs always
|
||||
--swiftversion 5.4
|
||||
--trimwhitespace always
|
||||
--wraparguments preserve
|
||||
--wrapcollections preserve
|
||||
|
||||
# rules
|
||||
|
||||
--enable isEmpty
|
||||
@@ -62,6 +62,41 @@ public struct APIHelper {
|
||||
return source
|
||||
}
|
||||
|
||||
/// maps all values from source to query parameters
|
||||
///
|
||||
/// explode attribute is respected: collection values might be either joined or split up into seperate key value pairs
|
||||
public static func mapValuesToQueryItems(_ source: [String: (wrappedValue: Any?, isExplode: Bool)]) -> [URLQueryItem]? {
|
||||
let destination = source.filter { $0.value.wrappedValue != nil }.reduce(into: [URLQueryItem]()) { result, item in
|
||||
if let collection = item.value.wrappedValue as? [Any?] {
|
||||
|
||||
let collectionValues: [String] = collection.compactMap { value in
|
||||
guard let value = value else { return nil }
|
||||
return "\(value)"
|
||||
}
|
||||
|
||||
if !item.value.isExplode {
|
||||
result.append(URLQueryItem(name: item.key, value: collectionValues.joined(separator: ",")))
|
||||
} else {
|
||||
collectionValues
|
||||
.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
}
|
||||
|
||||
} else if let value = item.value.wrappedValue {
|
||||
result.append(URLQueryItem(name: item.key, value: "\(value)"))
|
||||
}
|
||||
}
|
||||
|
||||
if destination.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/// maps all values from source to query parameters
|
||||
///
|
||||
/// collection values are always exploded
|
||||
public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? {
|
||||
let destination = source.filter { $0.value != nil }.reduce(into: [URLQueryItem]()) { result, item in
|
||||
if let collection = item.value as? [Any?] {
|
||||
@@ -73,6 +108,7 @@ public struct APIHelper {
|
||||
.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
|
||||
} else if let value = item.value {
|
||||
result.append(URLQueryItem(name: item.key, value: "\(value)"))
|
||||
}
|
||||
|
||||
@@ -28,17 +28,19 @@ open class RequestBuilder<T> {
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
public let requestTask: RequestTask = RequestTask()
|
||||
public let requiresAuthentication: Bool
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
/// With the URLSession http client the request's progress only works on iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0.
|
||||
/// If you need to get the request's progress in older OS versions, please use Alamofire http client.
|
||||
public var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:]) {
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
self.headers = headers
|
||||
self.requiresAuthentication = requiresAuthentication
|
||||
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ open class AnotherFakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func call123testSpecialTags(body: Client) async throws -> Client {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = call123testSpecialTagsWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -29,7 +30,7 @@ open class AnotherFakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = call123testSpecialTagsWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -38,8 +39,8 @@ open class AnotherFakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +66,6 @@ open class AnotherFakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil) async throws -> Bool {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = fakeOuterBooleanSerializeWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -28,7 +29,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -37,8 +38,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Bool>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +74,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil) async throws -> OuterComposite {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = fakeOuterCompositeSerializeWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -82,7 +84,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -91,8 +93,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +119,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +129,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil) async throws -> Double {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = fakeOuterNumberSerializeWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -136,7 +139,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -145,8 +148,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +174,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Double>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +184,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func fakeOuterStringSerialize(body: String? = nil) async throws -> String {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = fakeOuterStringSerializeWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -190,7 +194,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = fakeOuterStringSerializeWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -199,8 +203,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +229,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +239,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testBodyWithFileSchemaWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -244,7 +249,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testBodyWithFileSchemaWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -253,8 +258,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +284,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +295,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testBodyWithQueryParams(query: String, body: User) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testBodyWithQueryParamsWithRequestBuilder(query: query, body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -299,7 +305,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -308,8 +314,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +332,7 @@ open class FakeAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"query": query.encodeToJSON(),
|
||||
"query": (wrappedValue: query.encodeToJSON(), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -337,7 +343,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +354,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testClientModel(body: Client) async throws -> Client {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testClientModelWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -357,7 +364,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testClientModelWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -366,8 +373,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +400,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +424,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
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) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = 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)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -426,7 +434,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = 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
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -435,8 +443,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,7 +504,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -581,7 +589,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
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) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -590,7 +599,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -599,8 +608,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,10 +640,10 @@ open class FakeAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray?.encodeToJSON(),
|
||||
"enum_query_string": enumQueryString?.encodeToJSON(),
|
||||
"enum_query_integer": enumQueryInteger?.encodeToJSON(),
|
||||
"enum_query_double": enumQueryDouble?.encodeToJSON(),
|
||||
"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),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -647,7 +656,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,7 +672,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -672,7 +682,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -681,8 +691,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,10 +715,10 @@ open class FakeAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"int64_group": int64Group?.encodeToJSON(),
|
||||
"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),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -720,7 +730,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,7 +741,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testInlineAdditionalProperties(param: [String: String]) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testInlineAdditionalPropertiesWithRequestBuilder(param: param)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -740,7 +751,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -749,8 +760,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,7 +786,7 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -787,7 +798,8 @@ open class FakeAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testJsonFormData(param: String, param2: String) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testJsonFormDataWithRequestBuilder(param: param, param2: param2)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -796,7 +808,7 @@ open class FakeAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -805,8 +817,8 @@ open class FakeAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -838,6 +850,6 @@ open class FakeAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ open class FakeClassnameTags123API {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func testClassname(body: Client) async throws -> Client {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = testClassnameWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -29,7 +30,7 @@ open class FakeClassnameTags123API {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = testClassnameWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -38,8 +39,8 @@ open class FakeClassnameTags123API {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +69,6 @@ open class FakeClassnameTags123API {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func addPet(body: Pet) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = addPetWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -29,7 +30,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = addPetWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -38,14 +39,17 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add a new pet to the store
|
||||
- POST /pet
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
@@ -67,7 +71,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +83,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = deletePetWithRequestBuilder(petId: petId, apiKey: apiKey)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -88,7 +93,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -97,8 +102,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +135,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +155,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func findPetsByStatus(status: [Status_findPetsByStatus]) async throws -> [Pet] {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = findPetsByStatusWithRequestBuilder(status: status)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -159,7 +165,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = findPetsByStatusWithRequestBuilder(status: status).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -168,8 +174,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +196,7 @@ open class PetAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status.encodeToJSON(),
|
||||
"status": (wrappedValue: status.encodeToJSON(), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -201,7 +207,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +219,8 @@ open class PetAPI {
|
||||
@available(*, deprecated, message: "This operation is deprecated.")
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func findPetsByTags(tags: [String]) async throws -> [Pet] {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = findPetsByTagsWithRequestBuilder(tags: tags)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -222,7 +229,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = findPetsByTagsWithRequestBuilder(tags: tags).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -231,8 +238,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +261,7 @@ open class PetAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags.encodeToJSON(),
|
||||
"tags": (wrappedValue: tags.encodeToJSON(), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -265,7 +272,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +283,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func getPetById(petId: Int64) async throws -> Pet {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = getPetByIdWithRequestBuilder(petId: petId)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -285,7 +293,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = getPetByIdWithRequestBuilder(petId: petId).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -294,8 +302,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +335,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +346,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func updatePet(body: Pet) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = updatePetWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -347,7 +356,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = updatePetWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -356,8 +365,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +394,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +407,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -407,7 +417,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -416,8 +426,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +466,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,7 +479,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) async throws -> ApiResponse {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -478,7 +489,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -487,8 +498,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +538,7 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +551,8 @@ open class PetAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) async throws -> ApiResponse {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -549,7 +561,7 @@ open class PetAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -558,8 +570,8 @@ open class PetAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,6 +610,6 @@ open class PetAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ open class StoreAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func deleteOrder(orderId: String) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = deleteOrderWithRequestBuilder(orderId: orderId)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -29,7 +30,7 @@ open class StoreAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = deleteOrderWithRequestBuilder(orderId: orderId).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -38,8 +39,8 @@ open class StoreAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ open class StoreAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,8 @@ open class StoreAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func getInventory() async throws -> [String: Int] {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = getInventoryWithRequestBuilder()
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -87,7 +89,7 @@ open class StoreAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = getInventoryWithRequestBuilder().execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -96,8 +98,8 @@ open class StoreAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +127,7 @@ open class StoreAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +138,8 @@ open class StoreAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func getOrderById(orderId: Int64) async throws -> Order {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = getOrderByIdWithRequestBuilder(orderId: orderId)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -145,7 +148,7 @@ open class StoreAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = getOrderByIdWithRequestBuilder(orderId: orderId).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -154,8 +157,8 @@ open class StoreAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +187,7 @@ open class StoreAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +198,8 @@ open class StoreAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func placeOrder(body: Order) async throws -> Order {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = placeOrderWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -204,7 +208,7 @@ open class StoreAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = placeOrderWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -213,8 +217,8 @@ open class StoreAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +243,6 @@ open class StoreAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func createUser(body: User) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = createUserWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -29,7 +30,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = createUserWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -38,8 +39,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func createUsersWithArrayInput(body: [User]) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = createUsersWithArrayInputWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -85,7 +87,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = createUsersWithArrayInputWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -94,8 +96,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +133,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func createUsersWithListInput(body: [User]) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = createUsersWithListInputWithRequestBuilder(body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -140,7 +143,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = createUsersWithListInputWithRequestBuilder(body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -149,8 +152,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +189,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func deleteUser(username: String) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = deleteUserWithRequestBuilder(username: username)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -195,7 +199,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = deleteUserWithRequestBuilder(username: username).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -204,8 +208,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +238,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +249,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func getUserByName(username: String) async throws -> User {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = getUserByNameWithRequestBuilder(username: username)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -254,7 +259,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = getUserByNameWithRequestBuilder(username: username).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -263,8 +268,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +297,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +309,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func loginUser(username: String, password: String) async throws -> String {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = loginUserWithRequestBuilder(username: username, password: password)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -313,7 +319,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = loginUserWithRequestBuilder(username: username, password: password).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
continuation.resume(returning: response.body)
|
||||
@@ -322,8 +328,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,8 +348,8 @@ open class UserAPI {
|
||||
|
||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": username.encodeToJSON(),
|
||||
"password": password.encodeToJSON(),
|
||||
"username": (wrappedValue: username.encodeToJSON(), isExplode: false),
|
||||
"password": (wrappedValue: password.encodeToJSON(), isExplode: false),
|
||||
])
|
||||
|
||||
let localVariableNillableHeaders: [String: Any?] = [
|
||||
@@ -354,7 +360,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,7 +370,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func logoutUser() async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = logoutUserWithRequestBuilder()
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -373,7 +380,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = logoutUserWithRequestBuilder().execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -382,8 +389,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +414,7 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,7 +426,8 @@ open class UserAPI {
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open class func updateUser(username: String, body: User) async throws {
|
||||
var requestTask: RequestTask?
|
||||
let requestBuilder = updateUserWithRequestBuilder(username: username, body: body)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return try await withTaskCancellationHandler {
|
||||
try Task.checkCancellation()
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -428,7 +436,7 @@ open class UserAPI {
|
||||
return
|
||||
}
|
||||
|
||||
requestTask = updateUserWithRequestBuilder(username: username, body: body).execute { result in
|
||||
requestBuilder.execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume(returning: ())
|
||||
@@ -437,8 +445,8 @@ open class UserAPI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} onCancel: { [requestTask] in
|
||||
requestTask?.cancel()
|
||||
} onCancel: {
|
||||
requestTask.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +476,6 @@ open class UserAPI {
|
||||
|
||||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
|
||||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,8 @@ open class Configuration {
|
||||
// You must set it prior to encoding any dates, and it will only be read once.
|
||||
@available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.")
|
||||
public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
/// 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 static var successfulStatusCodeRange: Range = 200..<300
|
||||
}
|
||||
|
||||
@@ -145,6 +145,17 @@ extension KeyedEncodingContainerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
|
||||
var mutableValue = value
|
||||
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
|
||||
try encode(stringValue, forKey: key)
|
||||
}
|
||||
|
||||
public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
|
||||
if let value = value {
|
||||
try encode(value, forKey: key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension KeyedDecodingContainerProtocol {
|
||||
@@ -184,10 +195,32 @@ extension KeyedDecodingContainerProtocol {
|
||||
return map
|
||||
}
|
||||
|
||||
public func decode(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal {
|
||||
let stringValue = try decode(String.self, forKey: key)
|
||||
guard let decimalValue = Decimal(string: stringValue) else {
|
||||
let context = DecodingError.Context(codingPath: [key], debugDescription: "The key \(key) couldn't be converted to a Decimal value")
|
||||
throw DecodingError.typeMismatch(type, context)
|
||||
}
|
||||
|
||||
return decimalValue
|
||||
}
|
||||
|
||||
public func decodeIfPresent(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal? {
|
||||
guard let stringValue = try decodeIfPresent(String.self, forKey: key) else {
|
||||
return nil
|
||||
}
|
||||
guard let decimalValue = Decimal(string: stringValue) else {
|
||||
let context = DecodingError.Context(codingPath: [key], debugDescription: "The key \(key) couldn't be converted to a Decimal value")
|
||||
throw DecodingError.typeMismatch(type, context)
|
||||
}
|
||||
|
||||
return decimalValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension HTTPURLResponse {
|
||||
var isStatusCodeSuccessful: Bool {
|
||||
return (200 ..< 300).contains(statusCode)
|
||||
return Configuration.successfulStatusCodeRange.contains(statusCode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,14 +105,19 @@ open class Response<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public final class RequestTask {
|
||||
public final class RequestTask: @unchecked Sendable {
|
||||
private var lock = NSRecursiveLock()
|
||||
private var task: URLSessionTask?
|
||||
|
||||
internal func set(task: URLSessionTask) {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
self.task = task
|
||||
}
|
||||
|
||||
public func cancel() {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
task?.cancel()
|
||||
task = nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,15 @@ public class OpenISO8601DateFormatter: DateFormatter {
|
||||
return formatter
|
||||
}()
|
||||
|
||||
static let withoutTime: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd"
|
||||
return formatter
|
||||
}()
|
||||
|
||||
private func setup() {
|
||||
calendar = Calendar(identifier: .iso8601)
|
||||
locale = Locale(identifier: "en_US_POSIX")
|
||||
@@ -38,7 +47,10 @@ public class OpenISO8601DateFormatter: DateFormatter {
|
||||
override public func date(from string: String) -> Date? {
|
||||
if let result = super.date(from: string) {
|
||||
return result
|
||||
} else if let result = OpenISO8601DateFormatter.withoutSeconds.date(from: string) {
|
||||
return result
|
||||
}
|
||||
return OpenISO8601DateFormatter.withoutSeconds.date(from: string)
|
||||
|
||||
return OpenISO8601DateFormatter.withoutTime.date(from: string)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:]) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, headers: headers)
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,8 +353,8 @@ open class URLSessionDecodableRequestBuilder<T: Decodable>: URLSessionRequestBui
|
||||
default:
|
||||
|
||||
guard let data = data, !data.isEmpty else {
|
||||
if T.self is ExpressibleByNilLiteral.Type {
|
||||
completion(.success(Response(response: httpResponse, body: Optional<T>.none as! T)))
|
||||
if let E = T.self as? ExpressibleByNilLiteral.Type {
|
||||
completion(.success(Response(response: httpResponse, body: E.init(nilLiteral: ()) as! T)))
|
||||
} else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse)))
|
||||
}
|
||||
@@ -455,49 +455,62 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
urlRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
for (key, value) in parameters {
|
||||
switch value {
|
||||
case let fileURL as URL:
|
||||
for value in (value as? Array ?? [value]) {
|
||||
switch value {
|
||||
case let fileURL as URL:
|
||||
|
||||
urlRequest = try configureFileUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
fileURL: fileURL
|
||||
)
|
||||
urlRequest = try configureFileUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
fileURL: fileURL
|
||||
)
|
||||
|
||||
case let string as String:
|
||||
case let string as String:
|
||||
|
||||
if let data = string.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
case let number as NSNumber:
|
||||
|
||||
if let data = number.stringValue.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
case let data as Data:
|
||||
|
||||
if let data = string.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
|
||||
case let uuid as UUID:
|
||||
|
||||
if let data = uuid.uuidString.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
default:
|
||||
fatalError("Unprocessable value \(value) with key \(key)")
|
||||
}
|
||||
|
||||
case let number as NSNumber:
|
||||
|
||||
if let data = number.stringValue.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
case let data as Data:
|
||||
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
|
||||
default:
|
||||
fatalError("Unprocessable value \(value) with key \(key)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ Void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
[api_key_query](../README.md#api_key_query), [petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user