diff --git a/modules/openapi-generator/src/main/resources/swift4/APIs.mustache b/modules/openapi-generator/src/main/resources/swift4/APIs.mustache index fb2a7791e713..6ed1abe5694c 100644 --- a/modules/openapi-generator/src/main/resources/swift4/APIs.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/APIs.mustache @@ -7,10 +7,10 @@ import Foundation open class {{projectName}}API { - open static var basePath = "{{{basePath}}}" - open static var credential: URLCredential? - open static var customHeaders: [String:String] = [:] - open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() + public static var basePath = "{{{basePath}}}" + public static var credential: URLCredential? + public static var customHeaders: [String:String] = [:] + public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() } open class RequestBuilder { diff --git a/modules/openapi-generator/src/main/resources/swift4/AlamofireImplementations.mustache b/modules/openapi-generator/src/main/resources/swift4/AlamofireImplementations.mustache index 2ade78f5a616..ac14f72c7d0e 100644 --- a/modules/openapi-generator/src/main/resources/swift4/AlamofireImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/AlamofireImplementations.mustache @@ -154,7 +154,7 @@ open class AlamofireRequestBuilder: RequestBuilder { if stringResponse.result.isFailure { completion( nil, - ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!) + ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!) ) return } @@ -356,7 +356,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilde if stringResponse.result.isFailure { completion( nil, - ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!) + ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!) ) return } diff --git a/modules/openapi-generator/src/main/resources/swift4/CodableHelper.mustache b/modules/openapi-generator/src/main/resources/swift4/CodableHelper.mustache index bd72d81846d2..e9d28accdf4c 100644 --- a/modules/openapi-generator/src/main/resources/swift4/CodableHelper.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/CodableHelper.mustache @@ -11,7 +11,7 @@ public typealias EncodeResult = (data: Data?, error: Error?) open class CodableHelper { - open static var dateformatter: DateFormatter? + public static var dateformatter: DateFormatter? open class func decode(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable { var returnedDecodable: T? = nil diff --git a/modules/openapi-generator/src/main/resources/swift4/Configuration.mustache b/modules/openapi-generator/src/main/resources/swift4/Configuration.mustache index f8180752b67b..516590da5d9e 100644 --- a/modules/openapi-generator/src/main/resources/swift4/Configuration.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/Configuration.mustache @@ -10,6 +10,6 @@ open class Configuration { // This value is used to configure the date formatter that is used to serialize dates into JSON format. // You must set it prior to encoding any dates, and it will only be read once. - open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/swift4/Models.mustache b/modules/openapi-generator/src/main/resources/swift4/Models.mustache index 42f8186ae4af..408563890359 100644 --- a/modules/openapi-generator/src/main/resources/swift4/Models.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/Models.mustache @@ -15,9 +15,9 @@ public enum ErrorResponse : Error { } open class Response { - open let statusCode: Int - open let header: [String: String] - open let body: T? + public let statusCode: Int + public let header: [String: String] + public let body: T? public init(statusCode: Int, header: [String: String], body: T?) { self.statusCode = statusCode diff --git a/samples/client/petstore/swift4/default/.openapi-generator/VERSION b/samples/client/petstore/swift4/default/.openapi-generator/VERSION index 6d94c9c2e12a..e24c1f857e01 100644 --- a/samples/client/petstore/swift4/default/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.0-SNAPSHOT \ No newline at end of file +3.3.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIHelper.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIHelper.swift index 5c99a37d5840..3c7b53f81496 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIHelper.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIHelper.swift @@ -7,8 +7,8 @@ import Foundation public struct APIHelper { - public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? { - let destination = source.reduce(into: [String: Any]()) { result, item in + public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? { + let destination = source.reduce(into: [String: Any]()) { (result, item) in if let value = item.value { result[item.key] = value } @@ -20,22 +20,22 @@ public struct APIHelper { return destination } - public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { - return source.reduce(into: [String: String]()) { result, item in + public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] { + return source.reduce(into: [String: String]()) { (result, item) in if let collection = item.value as? Array { - result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",") + result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",") } else if let value: Any = item.value { result[item.key] = "\(value)" } } } - public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? { + public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? { guard let source = source else { return nil } - return source.reduce(into: [String: Any](), { result, item in + return source.reduce(into: [String: Any](), { (result, item) in switch item.value { case let x as Bool: result[item.key] = x.description @@ -45,10 +45,11 @@ public struct APIHelper { }) } - public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? { - let destination = source.filter({ $0.value != nil }).reduce(into: [URLQueryItem]()) { result, item in + + 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? Array { - let value = collection.filter({ $0 != nil }).map({ "\($0!)" }).joined(separator: ",") + let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",") result.append(URLQueryItem(name: item.key, value: value)) } else if let value = item.value { result.append(URLQueryItem(name: item.key, value: "\(value)")) @@ -61,3 +62,4 @@ public struct APIHelper { return destination } } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs.swift index e07b556f393e..2890bffa2747 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs.swift @@ -7,24 +7,24 @@ import Foundation open class PetstoreClientAPI { - open static var basePath = "http://petstore.swagger.io:80/v2" - open static var credential: URLCredential? - open static var customHeaders: [String: String] = [:] - open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() + public static var basePath = "http://petstore.swagger.io:80/v2" + public static var credential: URLCredential? + public static var customHeaders: [String:String] = [:] + public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() } open class RequestBuilder { var credential: URLCredential? - var headers: [String: String] - public let parameters: [String: Any]? + var headers: [String:String] + public let parameters: [String:Any]? public let isBody: Bool public let method: String public let URLString: String /// Optional block to obtain a reference to the request's progress instance when available. - public var onProgressReady: ((Progress) -> Void)? + public var onProgressReady: ((Progress) -> ())? - public required init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) { + required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) { self.method = method self.URLString = URLString self.parameters = parameters @@ -34,13 +34,13 @@ open class RequestBuilder { addHeaders(PetstoreClientAPI.customHeaders) } - open func addHeaders(_ aHeaders: [String: String]) { + open func addHeaders(_ aHeaders:[String:String]) { for (header, value) in aHeaders { headers[header] = value } } - open func execute(_: @escaping (_ response: Response?, _ error: Error?) -> Void) {} + open func execute(_ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { } public func addHeader(name: String, value: String) -> Self { if !value.isEmpty { @@ -50,12 +50,12 @@ open class RequestBuilder { } open func addCredential() -> Self { - credential = PetstoreClientAPI.credential + self.credential = PetstoreClientAPI.credential return self } } public protocol RequestBuilderFactory { func getNonDecodableBuilder() -> RequestBuilder.Type - func getBuilder() -> RequestBuilder.Type + func getBuilder() -> RequestBuilder.Type } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/AnotherFakeAPI.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/AnotherFakeAPI.swift index 34a378977c87..a31864437b12 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/AnotherFakeAPI.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/AnotherFakeAPI.swift @@ -5,28 +5,31 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class AnotherFakeAPI { /** To test special tags - - - parameter client: (body) client model + + - parameter client: (body) client model - parameter completion: completion handler to receive the data and the error objects */ - open class func call123testSpecialTags(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) { + open class func call123testSpecialTags(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) { call123testSpecialTagsWithRequestBuilder(client: client).execute { (response, error) -> Void in completion(response?.body, error) } } + /** To test special tags - PATCH /another-fake/dummy - To test special tags and operation ID starting with number - - parameter client: (body) client model - - returns: RequestBuilder + - parameter client: (body) client model + - returns: RequestBuilder */ open class func call123testSpecialTagsWithRequestBuilder(client: Client) -> RequestBuilder { let path = "/another-fake/dummy" @@ -39,4 +42,5 @@ open class AnotherFakeAPI { return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeAPI.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeAPI.swift index 6ee99636ce79..02b129d41efc 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeAPI.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeAPI.swift @@ -5,8 +5,10 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class FakeAPI { /** @@ -14,17 +16,18 @@ open class FakeAPI { - parameter body: (body) Input boolean as post body (optional) - parameter completion: completion handler to receive the data and the error objects */ - open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?, _ error: Error?) -> Void)) { + open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) { fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(response?.body, error) } } + /** - POST /fake/outer/boolean - Test serialization of outer boolean types - parameter body: (body) Input boolean as post body (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil) -> RequestBuilder { let path = "/fake/outer/boolean" @@ -43,17 +46,18 @@ open class FakeAPI { - parameter outerComposite: (body) Input composite as post body (optional) - parameter completion: completion handler to receive the data and the error objects */ - open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: Error?) -> Void)) { + open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) { fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: outerComposite).execute { (response, error) -> Void in completion(response?.body, error) } } + /** - POST /fake/outer/composite - Test serialization of object with outer number type - parameter outerComposite: (body) Input composite as post body (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: OuterComposite? = nil) -> RequestBuilder { let path = "/fake/outer/composite" @@ -72,17 +76,18 @@ open class FakeAPI { - parameter body: (body) Input number as post body (optional) - parameter completion: completion handler to receive the data and the error objects */ - open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?, _ error: Error?) -> Void)) { + open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) { fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(response?.body, error) } } + /** - POST /fake/outer/number - Test serialization of outer number types - parameter body: (body) Input number as post body (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil) -> RequestBuilder { let path = "/fake/outer/number" @@ -101,17 +106,18 @@ open class FakeAPI { - parameter body: (body) Input string as post body (optional) - parameter completion: completion handler to receive the data and the error objects */ - open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) { + open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) { fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(response?.body, error) } } + /** - POST /fake/outer/string - Test serialization of outer string types - parameter body: (body) Input string as post body (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil) -> RequestBuilder { let path = "/fake/outer/string" @@ -127,11 +133,11 @@ open class FakeAPI { /** - - parameter fileSchemaTestClass: (body) + - parameter fileSchemaTestClass: (body) - parameter completion: completion handler to receive the data and the error objects */ - open class func testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: fileSchemaTestClass).execute { (_, error) -> Void in + open class func testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: fileSchemaTestClass).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -140,11 +146,12 @@ open class FakeAPI { } } + /** - PUT /fake/body-with-file-schema - For this test, the body for this request much reference a schema named `File`. - - parameter fileSchemaTestClass: (body) - - returns: RequestBuilder + - parameter fileSchemaTestClass: (body) + - returns: RequestBuilder */ open class func testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: FileSchemaTestClass) -> RequestBuilder { let path = "/fake/body-with-file-schema" @@ -160,12 +167,12 @@ open class FakeAPI { /** - - parameter query: (query) - - parameter user: (body) + - parameter query: (query) + - parameter user: (body) - parameter completion: completion handler to receive the data and the error objects */ - open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (_, error) -> Void in + open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -174,11 +181,12 @@ open class FakeAPI { } } + /** - PUT /fake/body-with-query-params - - parameter query: (query) - - parameter user: (body) - - returns: RequestBuilder + - parameter query: (query) + - parameter user: (body) + - returns: RequestBuilder */ open class func testBodyWithQueryParamsWithRequestBuilder(query: String, user: User) -> RequestBuilder { let path = "/fake/body-with-query-params" @@ -187,7 +195,7 @@ open class FakeAPI { var url = URLComponents(string: URLString) url?.queryItems = APIHelper.mapValuesToQueryItems([ - "query": query, + "query": query ]) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -197,22 +205,23 @@ open class FakeAPI { /** To test \"client\" model - - - parameter client: (body) client model + + - parameter client: (body) client model - parameter completion: completion handler to receive the data and the error objects */ - open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) { + open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) { testClientModelWithRequestBuilder(client: client).execute { (response, error) -> Void in completion(response?.body, error) } } + /** To test \"client\" model - PATCH /fake - To test \"client\" model - - parameter client: (body) client model - - returns: RequestBuilder + - parameter client: (body) client model + - returns: RequestBuilder */ open class func testClientModelWithRequestBuilder(client: Client) -> RequestBuilder { let path = "/fake" @@ -227,12 +236,12 @@ open class FakeAPI { } /** - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - - - parameter number: (form) None - - parameter double: (form) None - - parameter patternWithoutDelimiter: (form) None - - parameter byte: (form) None + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + + - 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) @@ -245,8 +254,8 @@ open class FakeAPI { - parameter callback: (form) None (optional) - parameter completion: completion handler to receive the data and the error objects */ - 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, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - 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 { (_, error) -> Void in + 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, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + 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 { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -255,17 +264,18 @@ open class FakeAPI { } } + /** - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - POST /fake - - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - BASIC: - - type: http - - name: http_basic_test - - parameter number: (form) None - - parameter double: (form) None - - parameter patternWithoutDelimiter: (form) None - - parameter byte: (form) None + - 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) @@ -276,12 +286,12 @@ open class FakeAPI { - parameter dateTime: (form) None (optional) - parameter password: (form) None (optional) - parameter callback: (form) None (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ 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 { let path = "/fake" let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "integer": integer?.encodeToJSON(), "int32": int32?.encodeToJSON(), "int64": int64?.encodeToJSON(), @@ -295,12 +305,12 @@ open class FakeAPI { "date": date?.encodeToJSON(), "dateTime": dateTime?.encodeToJSON(), "password": password, - "callback": callback, + "callback": callback ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -377,7 +387,7 @@ open class FakeAPI { /** 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) @@ -388,8 +398,8 @@ open class FakeAPI { - parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg) - parameter completion: completion handler to receive the data and the error objects */ - open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (_, error) -> Void in + open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -398,6 +408,7 @@ open class FakeAPI { } } + /** To test enum parameters - GET /fake @@ -410,29 +421,29 @@ open class FakeAPI { - parameter enumQueryDouble: (query) Query parameter enum test (double) (optional) - parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$) - parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder { let path = "/fake" let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "enum_form_string_array": enumFormStringArray, - "enum_form_string": enumFormString?.rawValue, + "enum_form_string": enumFormString?.rawValue ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + var url = URLComponents(string: URLString) url?.queryItems = APIHelper.mapValuesToQueryItems([ - "enum_query_string_array": enumQueryStringArray, - "enum_query_string": enumQueryString?.rawValue, - "enum_query_integer": enumQueryInteger?.rawValue, - "enum_query_double": enumQueryDouble?.rawValue, + "enum_query_string_array": enumQueryStringArray, + "enum_query_string": enumQueryString?.rawValue, + "enum_query_integer": enumQueryInteger?.rawValue, + "enum_query_double": enumQueryDouble?.rawValue ]) let nillableHeaders: [String: Any?] = [ "enum_header_string_array": enumHeaderStringArray, - "enum_header_string": enumHeaderString?.rawValue, + "enum_header_string": enumHeaderString?.rawValue ] let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders) @@ -442,13 +453,61 @@ open class FakeAPI { } /** - test inline additionalProperties + Fake endpoint to test group parameters (optional) + + - 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 completion: completion handler to receive the data and the error objects + */ + open class func testGroupParameters(stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testGroupParametersWithRequestBuilder(stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { (response, error) -> Void in + if error == nil { + completion((), error) + } else { + completion(nil, error) + } + } + } - - parameter requestBody: (body) request body + + /** + Fake endpoint to test group parameters (optional) + - DELETE /fake + - Fake endpoint to test group parameters (optional) + - parameter stringGroup: (query) String in group parameters (optional) + - parameter booleanGroup: (header) Boolean in group parameters (optional) + - parameter int64Group: (query) Integer in group parameters (optional) + - returns: RequestBuilder + */ + open class func testGroupParametersWithRequestBuilder(stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> RequestBuilder { + let path = "/fake" + let URLString = PetstoreClientAPI.basePath + path + let parameters: [String:Any]? = nil + + var url = URLComponents(string: URLString) + url?.queryItems = APIHelper.mapValuesToQueryItems([ + "string_group": stringGroup?.encodeToJSON(), + "int64_group": int64Group?.encodeToJSON() + ]) + let nillableHeaders: [String: Any?] = [ + "boolean_group": booleanGroup + ] + let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() + + return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters) + } + + /** + test inline additionalProperties + + - parameter requestBody: (body) request body - parameter completion: completion handler to receive the data and the error objects */ - open class func testInlineAdditionalProperties(requestBody: [String: String], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (_, error) -> Void in + open class func testInlineAdditionalProperties(requestBody: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -457,13 +516,14 @@ open class FakeAPI { } } + /** test inline additionalProperties - POST /fake/inline-additionalProperties - - parameter requestBody: (body) request body - - returns: RequestBuilder + - parameter requestBody: (body) request body + - returns: RequestBuilder */ - open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String: String]) -> RequestBuilder { + open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String:String]) -> RequestBuilder { let path = "/fake/inline-additionalProperties" let URLString = PetstoreClientAPI.basePath + path let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: requestBody) @@ -477,13 +537,13 @@ open class FakeAPI { /** test json serialization of form data - - - parameter param: (form) field1 - - parameter param2: (form) field2 + + - parameter param: (form) field1 + - parameter param2: (form) field2 - parameter completion: completion handler to receive the data and the error objects */ - open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (_, error) -> Void in + open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -492,28 +552,30 @@ open class FakeAPI { } } + /** test json serialization of form data - GET /fake/jsonFormData - - parameter param: (form) field1 - - parameter param2: (form) field2 - - returns: RequestBuilder + - parameter param: (form) field1 + - parameter param2: (form) field2 + - returns: RequestBuilder */ open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder { let path = "/fake/jsonFormData" let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "param": param, - "param2": param2, + "param2": param2 ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeClassnameTags123API.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeClassnameTags123API.swift index 43fb8dec5181..8bb79ddd28f0 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeClassnameTags123API.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/FakeClassnameTags123API.swift @@ -5,31 +5,34 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class FakeClassnameTags123API { /** To test class name in snake case - - - parameter client: (body) client model + + - parameter client: (body) client model - parameter completion: completion handler to receive the data and the error objects */ - open class func testClassname(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) { + open class func testClassname(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) { testClassnameWithRequestBuilder(client: client).execute { (response, error) -> Void in completion(response?.body, error) } } + /** To test class name in snake case - PATCH /fake_classname_test - To test class name in snake case - API Key: - - type: apiKey api_key_query (QUERY) - - name: api_key_query - - parameter client: (body) client model - - returns: RequestBuilder + - type: apiKey api_key_query (QUERY) + - name: api_key_query + - parameter client: (body) client model + - returns: RequestBuilder */ open class func testClassnameWithRequestBuilder(client: Client) -> RequestBuilder { let path = "/fake_classname_test" @@ -42,4 +45,5 @@ open class FakeClassnameTags123API { return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/PetAPI.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/PetAPI.swift index b975c79c1b6c..266ac7c402b3 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/PetAPI.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/PetAPI.swift @@ -5,18 +5,20 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class PetAPI { /** Add a new pet to the store - - - parameter pet: (body) Pet object that needs to be added to the store + + - parameter pet: (body) Pet object that needs to be added to the store - parameter completion: completion handler to receive the data and the error objects */ - open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - addPetWithRequestBuilder(pet: pet).execute { (_, error) -> Void in + open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + addPetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -25,14 +27,15 @@ open class PetAPI { } } + /** Add a new pet to the store - POST /pet - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter pet: (body) Pet object that needs to be added to the store - - returns: RequestBuilder + - type: oauth2 + - name: petstore_auth + - parameter pet: (body) Pet object that needs to be added to the store + - returns: RequestBuilder */ open class func addPetWithRequestBuilder(pet: Pet) -> RequestBuilder { let path = "/pet" @@ -48,13 +51,13 @@ open class PetAPI { /** Deletes a pet - - - parameter petId: (path) Pet id to delete + + - parameter petId: (path) Pet id to delete - parameter apiKey: (header) (optional) - parameter completion: completion handler to receive the data and the error objects */ - open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (_, error) -> Void in + open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -63,15 +66,16 @@ open class PetAPI { } } + /** Deletes a pet - DELETE /pet/{petId} - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter petId: (path) Pet id to delete + - type: oauth2 + - name: petstore_auth + - parameter petId: (path) Pet id to delete - parameter apiKey: (header) (optional) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder { var path = "/pet/{petId}" @@ -79,11 +83,11 @@ open class PetAPI { let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let nillableHeaders: [String: Any?] = [ - "api_key": apiKey, + "api_key": apiKey ] let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders) @@ -96,41 +100,42 @@ open class PetAPI { * enum for parameter status */ public enum Status_findPetsByStatus: String { - case available - case pending - case sold + case available = "available" + case pending = "pending" + case sold = "sold" } /** Finds Pets by status - - - parameter status: (query) Status values that need to be considered for filter + + - parameter status: (query) Status values that need to be considered for filter - parameter completion: completion handler to receive the data and the error objects */ - open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) { + open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) { findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Finds Pets by status - GET /pet/findByStatus - Multiple status values can be provided with comma separated strings - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter status: (query) Status values that need to be considered for filter - - returns: RequestBuilder<[Pet]> + - type: oauth2 + - name: petstore_auth + - parameter status: (query) Status values that need to be considered for filter + - returns: RequestBuilder<[Pet]> */ open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> { let path = "/pet/findByStatus" let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + var url = URLComponents(string: URLString) url?.queryItems = APIHelper.mapValuesToQueryItems([ - "status": status, + "status": status ]) let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -140,34 +145,35 @@ open class PetAPI { /** Finds Pets by tags - - - parameter tags: (query) Tags to filter by + + - parameter tags: (query) Tags to filter by - parameter completion: completion handler to receive the data and the error objects */ - open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) { + open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) { findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Finds Pets by tags - GET /pet/findByTags - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter tags: (query) Tags to filter by - - returns: RequestBuilder<[Pet]> + - type: oauth2 + - name: petstore_auth + - parameter tags: (query) Tags to filter by + - returns: RequestBuilder<[Pet]> */ open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> { let path = "/pet/findByTags" let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + var url = URLComponents(string: URLString) url?.queryItems = APIHelper.mapValuesToQueryItems([ - "tags": tags, + "tags": tags ]) let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -177,25 +183,26 @@ open class PetAPI { /** Find pet by ID - - - parameter petId: (path) ID of pet to return + + - parameter petId: (path) ID of pet to return - parameter completion: completion handler to receive the data and the error objects */ - open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: Error?) -> Void)) { + open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) { getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Find pet by ID - GET /pet/{petId} - Returns a single pet - API Key: - - type: apiKey api_key - - name: api_key - - parameter petId: (path) ID of pet to return - - returns: RequestBuilder + - type: apiKey api_key + - name: api_key + - parameter petId: (path) ID of pet to return + - returns: RequestBuilder */ open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder { var path = "/pet/{petId}" @@ -203,8 +210,8 @@ open class PetAPI { let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -214,12 +221,12 @@ open class PetAPI { /** Update an existing pet - - - parameter pet: (body) Pet object that needs to be added to the store + + - parameter pet: (body) Pet object that needs to be added to the store - parameter completion: completion handler to receive the data and the error objects */ - open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - updatePetWithRequestBuilder(pet: pet).execute { (_, error) -> Void in + open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + updatePetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -228,14 +235,15 @@ open class PetAPI { } } + /** Update an existing pet - PUT /pet - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter pet: (body) Pet object that needs to be added to the store - - returns: RequestBuilder + - type: oauth2 + - name: petstore_auth + - parameter pet: (body) Pet object that needs to be added to the store + - returns: RequestBuilder */ open class func updatePetWithRequestBuilder(pet: Pet) -> RequestBuilder { let path = "/pet" @@ -251,14 +259,14 @@ open class PetAPI { /** Updates a pet in the store with form data - - - parameter petId: (path) ID of pet that needs to be updated + + - 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 completion: completion handler to receive the data and the error objects */ - open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (_, error) -> Void in + open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -267,16 +275,17 @@ open class PetAPI { } } + /** Updates a pet in the store with form data - POST /pet/{petId} - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter petId: (path) ID of pet that needs to be updated + - 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) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder { var path = "/pet/{petId}" @@ -284,14 +293,14 @@ open class PetAPI { let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "name": name, - "status": status, + "status": status ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -301,28 +310,29 @@ open class PetAPI { /** uploads an image - - - parameter petId: (path) ID of pet to update + + - 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 completion: completion handler to receive the data and the error objects */ - open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) { + open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) { uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in completion(response?.body, error) } } + /** uploads an image - POST /pet/{petId}/uploadImage - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter petId: (path) ID of pet to update + - 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) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder { var path = "/pet/{petId}/uploadImage" @@ -330,14 +340,14 @@ open class PetAPI { let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "additionalMetadata": additionalMetadata, - "file": file, + "file": file ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -347,28 +357,29 @@ open class PetAPI { /** uploads an image (required) - - - parameter petId: (path) ID of pet to update - - parameter requiredFile: (form) file to upload + + - 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 completion: completion handler to receive the data and the error objects */ - open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) { + open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) { uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { (response, error) -> Void in completion(response?.body, error) } } + /** uploads an image (required) - POST /fake/{petId}/uploadImageWithRequiredFile - OAuth: - - type: oauth2 - - name: petstore_auth - - parameter petId: (path) ID of pet to update - - parameter requiredFile: (form) file to upload + - 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) - - returns: RequestBuilder + - returns: RequestBuilder */ open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> RequestBuilder { var path = "/fake/{petId}/uploadImageWithRequiredFile" @@ -376,18 +387,19 @@ open class PetAPI { let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let formParams: [String: Any?] = [ + let formParams: [String:Any?] = [ "additionalMetadata": additionalMetadata, - "requiredFile": requiredFile, + "requiredFile": requiredFile ] let nonNullParameters = APIHelper.rejectNil(formParams) let parameters = APIHelper.convertBoolToString(nonNullParameters) - + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift index 8e749634af32..920eff9816bd 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift @@ -5,18 +5,20 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class StoreAPI { /** Delete purchase order by ID - - - parameter orderId: (path) ID of the order that needs to be deleted + + - parameter orderId: (path) ID of the order that needs to be deleted - parameter completion: completion handler to receive the data and the error objects */ - open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - deleteOrderWithRequestBuilder(orderId: orderId).execute { (_, error) -> Void in + open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -25,12 +27,13 @@ open class StoreAPI { } } + /** Delete purchase order by ID - 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 - - returns: RequestBuilder + - parameter orderId: (path) ID of the order that needs to be deleted + - returns: RequestBuilder */ open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder { var path = "/store/order/{order_id}" @@ -38,8 +41,8 @@ open class StoreAPI { let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -49,54 +52,56 @@ open class StoreAPI { /** Returns pet inventories by status - + - parameter completion: completion handler to receive the data and the error objects */ - open class func getInventory(completion: @escaping ((_ data: [String: Int]?, _ error: Error?) -> Void)) { + open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) { getInventoryWithRequestBuilder().execute { (response, error) -> Void in completion(response?.body, error) } } + /** Returns pet inventories by status - GET /store/inventory - Returns a map of status codes to quantities - API Key: - - type: apiKey api_key - - name: api_key - - returns: RequestBuilder<[String:Int]> + - type: apiKey api_key + - name: api_key + - returns: RequestBuilder<[String:Int]> */ - open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String: Int]> { + open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> { let path = "/store/inventory" let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) - let requestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false) } /** Find purchase order by ID - - - parameter orderId: (path) ID of pet that needs to be fetched + + - parameter orderId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) { + open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) { getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Find purchase order by ID - GET /store/order/{order_id} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - parameter orderId: (path) ID of pet that needs to be fetched - - returns: RequestBuilder + - parameter orderId: (path) ID of pet that needs to be fetched + - returns: RequestBuilder */ open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder { var path = "/store/order/{order_id}" @@ -104,8 +109,8 @@ open class StoreAPI { let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -115,21 +120,22 @@ open class StoreAPI { /** Place an order for a pet - - - parameter order: (body) order placed for purchasing the pet + + - parameter order: (body) order placed for purchasing the pet - parameter completion: completion handler to receive the data and the error objects */ - open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) { + open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) { placeOrderWithRequestBuilder(order: order).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Place an order for a pet - POST /store/order - - parameter order: (body) order placed for purchasing the pet - - returns: RequestBuilder + - parameter order: (body) order placed for purchasing the pet + - returns: RequestBuilder */ open class func placeOrderWithRequestBuilder(order: Order) -> RequestBuilder { let path = "/store/order" @@ -142,4 +148,5 @@ open class StoreAPI { return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift index 7a629ee75a2c..e9457fc88a62 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift @@ -5,18 +5,20 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire + + open class UserAPI { /** Create user - - - parameter user: (body) Created user object + + - parameter user: (body) Created user object - parameter completion: completion handler to receive the data and the error objects */ - open class func createUser(user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - createUserWithRequestBuilder(user: user).execute { (_, error) -> Void in + open class func createUser(user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + createUserWithRequestBuilder(user: user).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -25,12 +27,13 @@ open class UserAPI { } } + /** Create user - POST /user - This can only be done by the logged in user. - - parameter user: (body) Created user object - - returns: RequestBuilder + - parameter user: (body) Created user object + - returns: RequestBuilder */ open class func createUserWithRequestBuilder(user: User) -> RequestBuilder { let path = "/user" @@ -46,12 +49,12 @@ open class UserAPI { /** Creates list of users with given input array - - - parameter user: (body) List of user object + + - parameter user: (body) List of user object - parameter completion: completion handler to receive the data and the error objects */ - open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - createUsersWithArrayInputWithRequestBuilder(user: user).execute { (_, error) -> Void in + open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + createUsersWithArrayInputWithRequestBuilder(user: user).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -60,11 +63,12 @@ open class UserAPI { } } + /** Creates list of users with given input array - POST /user/createWithArray - - parameter user: (body) List of user object - - returns: RequestBuilder + - parameter user: (body) List of user object + - returns: RequestBuilder */ open class func createUsersWithArrayInputWithRequestBuilder(user: [User]) -> RequestBuilder { let path = "/user/createWithArray" @@ -80,12 +84,12 @@ open class UserAPI { /** Creates list of users with given input array - - - parameter user: (body) List of user object + + - parameter user: (body) List of user object - parameter completion: completion handler to receive the data and the error objects */ - open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - createUsersWithListInputWithRequestBuilder(user: user).execute { (_, error) -> Void in + open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + createUsersWithListInputWithRequestBuilder(user: user).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -94,11 +98,12 @@ open class UserAPI { } } + /** Creates list of users with given input array - POST /user/createWithList - - parameter user: (body) List of user object - - returns: RequestBuilder + - parameter user: (body) List of user object + - returns: RequestBuilder */ open class func createUsersWithListInputWithRequestBuilder(user: [User]) -> RequestBuilder { let path = "/user/createWithList" @@ -114,12 +119,12 @@ open class UserAPI { /** Delete user - - - parameter username: (path) The name that needs to be deleted + + - parameter username: (path) The name that needs to be deleted - parameter completion: completion handler to receive the data and the error objects */ - open class func deleteUser(username: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - deleteUserWithRequestBuilder(username: username).execute { (_, error) -> Void in + open class func deleteUser(username: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -128,12 +133,13 @@ open class UserAPI { } } + /** Delete user - DELETE /user/{username} - This can only be done by the logged in user. - - parameter username: (path) The name that needs to be deleted - - returns: RequestBuilder + - parameter username: (path) The name that needs to be deleted + - returns: RequestBuilder */ open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder { var path = "/user/{username}" @@ -141,8 +147,8 @@ open class UserAPI { let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -152,21 +158,22 @@ open class UserAPI { /** Get user by user name - - - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. - parameter completion: completion handler to receive the data and the error objects */ - open class func getUserByName(username: String, completion: @escaping ((_ data: User?, _ error: Error?) -> Void)) { + open class func getUserByName(username: String, completion: @escaping ((_ data: User?,_ error: Error?) -> Void)) { getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Get user by user name - GET /user/{username} - - parameter username: (path) The name that needs to be fetched. Use user1 for testing. - - returns: RequestBuilder + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - returns: RequestBuilder */ open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder { var path = "/user/{username}" @@ -174,8 +181,8 @@ open class UserAPI { let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil) let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -185,34 +192,35 @@ open class UserAPI { /** Logs user into the system - - - parameter username: (query) The user name for login - - parameter password: (query) The password for login in clear text + + - parameter username: (query) The user name for login + - parameter password: (query) The password for login in clear text - parameter completion: completion handler to receive the data and the error objects */ - open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) { + open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) { loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in completion(response?.body, error) } } + /** Logs user into the system - 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 - - returns: RequestBuilder + - parameter username: (query) The user name for login + - parameter password: (query) The password for login in clear text + - returns: RequestBuilder */ open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder { let path = "/user/login" let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + var url = URLComponents(string: URLString) url?.queryItems = APIHelper.mapValuesToQueryItems([ - "username": username, - "password": password, + "username": username, + "password": password ]) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() @@ -222,11 +230,11 @@ open class UserAPI { /** Logs out current logged in user session - + - parameter completion: completion handler to receive the data and the error objects */ - open class func logoutUser(completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - logoutUserWithRequestBuilder().execute { (_, error) -> Void in + open class func logoutUser(completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + logoutUserWithRequestBuilder().execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -235,16 +243,17 @@ open class UserAPI { } } + /** Logs out current logged in user session - GET /user/logout - - returns: RequestBuilder + - returns: RequestBuilder */ open class func logoutUserWithRequestBuilder() -> RequestBuilder { let path = "/user/logout" let URLString = PetstoreClientAPI.basePath + path - let parameters: [String: Any]? = nil - + let parameters: [String:Any]? = nil + let url = URLComponents(string: URLString) let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder() @@ -254,13 +263,13 @@ open class UserAPI { /** Updated user - - - parameter username: (path) name that need to be deleted - - parameter user: (body) Updated user object + + - parameter username: (path) name that need to be deleted + - parameter user: (body) Updated user object - parameter completion: completion handler to receive the data and the error objects */ - open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) { - updateUserWithRequestBuilder(username: username, user: user).execute { (_, error) -> Void in + open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) { + updateUserWithRequestBuilder(username: username, user: user).execute { (response, error) -> Void in if error == nil { completion((), error) } else { @@ -269,13 +278,14 @@ open class UserAPI { } } + /** Updated user - PUT /user/{username} - This can only be done by the logged in user. - - parameter username: (path) name that need to be deleted - - parameter user: (body) Updated user object - - returns: RequestBuilder + - parameter username: (path) name that need to be deleted + - parameter user: (body) Updated user object + - returns: RequestBuilder */ open class func updateUserWithRequestBuilder(username: String, user: User) -> RequestBuilder { var path = "/user/{username}" @@ -291,4 +301,5 @@ open class UserAPI { return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 9ac32d699a1a..ac14f72c7d0e 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -4,52 +4,53 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire class AlamofireRequestBuilderFactory: RequestBuilderFactory { func getNonDecodableBuilder() -> RequestBuilder.Type { return AlamofireRequestBuilder.self } - func getBuilder() -> RequestBuilder.Type { + func getBuilder() -> RequestBuilder.Type { return AlamofireDecodableRequestBuilder.self } } private struct SynchronizedDictionary { - private var dictionary = [K: V]() - private let queue = DispatchQueue( - label: "SynchronizedDictionary", - qos: DispatchQoS.userInitiated, - attributes: [DispatchQueue.Attributes.concurrent], - autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, - target: nil - ) - - public subscript(key: K) -> V? { - get { - var value: V? - - queue.sync { - value = self.dictionary[key] - } - return value - } - set { - queue.sync(flags: DispatchWorkItemFlags.barrier) { - self.dictionary[key] = newValue - } - } - } -} + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + } // Store manager to retain its reference private var managerStore = SynchronizedDictionary() open class AlamofireRequestBuilder: RequestBuilder { - public required init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) { + required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers) } @@ -70,7 +71,7 @@ open class AlamofireRequestBuilder: RequestBuilder { Return nil to use the default behavior (inferring the Content-Type from the file extension). Return the desired Content-Type otherwise. */ - open func contentTypeForFormPart(fileURL _: URL) -> String? { + open func contentTypeForFormPart(fileURL: URL) -> String? { return nil } @@ -78,21 +79,21 @@ open class AlamofireRequestBuilder: RequestBuilder { May be overridden by a subclass if you want to control the request configuration (e.g. to override the cache policy). */ - open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) -> DataRequest { + open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest { return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers) } - open override func execute(_ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { - let managerId: String = UUID().uuidString + override open func execute(_ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { + let managerId:String = UUID().uuidString // Create a new manager for each request to customize its request header let manager = createSessionManager() managerStore[managerId] = manager - let encoding: ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding() + let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding() let xMethod = Alamofire.HTTPMethod(rawValue: method) let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL } - .map { $0.0 } + .map { $0.0 } if fileKeys.count > 0 { manager.upload(multipartFormData: { mpForm in @@ -101,7 +102,8 @@ open class AlamofireRequestBuilder: RequestBuilder { case let fileURL as URL: if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) { mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType) - } else { + } + else { mpForm.append(fileURL, withName: k) } case let string as String: @@ -112,14 +114,14 @@ open class AlamofireRequestBuilder: RequestBuilder { fatalError("Unprocessable value \(v) with key \(k)") } } - }, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in + }, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): if let onProgressReady = self.onProgressReady { onProgressReady(upload.uploadProgress) } self.processRequest(request: upload, managerId, completion) - case let .failure(encodingError): + case .failure(let encodingError): completion(nil, ErrorResponse.error(415, nil, encodingError)) } }) @@ -130,6 +132,7 @@ open class AlamofireRequestBuilder: RequestBuilder { } processRequest(request: request, managerId, completion) } + } fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { @@ -145,13 +148,13 @@ open class AlamofireRequestBuilder: RequestBuilder { switch T.self { case is String.Type: - validatedRequest.responseString(completionHandler: { stringResponse in + validatedRequest.responseString(completionHandler: { (stringResponse) in cleanupRequest() if stringResponse.result.isFailure { completion( nil, - ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!) + ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!) ) return } @@ -165,10 +168,11 @@ open class AlamofireRequestBuilder: RequestBuilder { ) }) case is URL.Type: - validatedRequest.responseData(completionHandler: { dataResponse in + validatedRequest.responseData(completionHandler: { (dataResponse) in cleanupRequest() do { + guard !dataResponse.result.isFailure else { throw DownloadException.responseFailed } @@ -214,7 +218,7 @@ open class AlamofireRequestBuilder: RequestBuilder { return }) case is Void.Type: - validatedRequest.responseData(completionHandler: { voidResponse in + validatedRequest.responseData(completionHandler: { (voidResponse) in cleanupRequest() if voidResponse.result.isFailure { @@ -228,13 +232,12 @@ open class AlamofireRequestBuilder: RequestBuilder { completion( Response( response: voidResponse.response!, - body: nil - ), + body: nil), nil ) }) default: - validatedRequest.responseData(completionHandler: { dataResponse in + validatedRequest.responseData(completionHandler: { (dataResponse) in cleanupRequest() if dataResponse.result.isFailure { @@ -258,22 +261,24 @@ open class AlamofireRequestBuilder: RequestBuilder { open func buildHeaders() -> [String: String] { var httpHeaders = SessionManager.defaultHTTPHeaders - for (key, value) in headers { + for (key, value) in self.headers { httpHeaders[key] = value } return httpHeaders } - fileprivate func getFileName(fromContentDisposition contentDisposition: String?) -> String? { + fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? { + guard let contentDisposition = contentDisposition else { return nil } let items = contentDisposition.components(separatedBy: ";") - var filename: String? + var filename : String? = nil for contentItem in items { + let filenameKey = "filename=" guard let range = contentItem.range(of: filenameKey) else { break @@ -281,15 +286,17 @@ open class AlamofireRequestBuilder: RequestBuilder { filename = contentItem return filename? - .replacingCharacters(in: range, with: "") + .replacingCharacters(in: range, with:"") .replacingOccurrences(of: "\"", with: "") .trimmingCharacters(in: .whitespacesAndNewlines) } return filename + } - fileprivate func getPath(from url: URL) throws -> String { + fileprivate func getPath(from url : URL) throws -> String { + guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else { throw DownloadException.requestMissingPath } @@ -299,18 +306,21 @@ open class AlamofireRequestBuilder: RequestBuilder { } return path + } - fileprivate func getURL(from urlRequest: URLRequest) throws -> URL { + fileprivate func getURL(from urlRequest : URLRequest) throws -> URL { + guard let url = urlRequest.url else { throw DownloadException.requestMissingURL } return url } + } -fileprivate enum DownloadException: Error { +fileprivate enum DownloadException : Error { case responseDataMissing case responseFailed case requestMissing @@ -325,8 +335,9 @@ public enum AlamofireDecodableRequestBuilderError: Error { case generalError(Error) } -open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilder { - fileprivate override func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { +open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilder { + + override fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response?, _ error: Error?) -> Void) { if let credential = self.credential { request.authenticate(usingCredential: credential) } @@ -339,13 +350,13 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild switch T.self { case is String.Type: - validatedRequest.responseString(completionHandler: { stringResponse in + validatedRequest.responseString(completionHandler: { (stringResponse) in cleanupRequest() if stringResponse.result.isFailure { completion( nil, - ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!) + ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!) ) return } @@ -359,7 +370,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild ) }) case is Void.Type: - validatedRequest.responseData(completionHandler: { voidResponse in + validatedRequest.responseData(completionHandler: { (voidResponse) in cleanupRequest() if voidResponse.result.isFailure { @@ -373,13 +384,12 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild completion( Response( response: voidResponse.response!, - body: nil - ), + body: nil), nil ) }) case is Data.Type: - validatedRequest.responseData(completionHandler: { dataResponse in + validatedRequest.responseData(completionHandler: { (dataResponse) in cleanupRequest() if dataResponse.result.isFailure { @@ -417,7 +427,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild return } - var responseObj: Response? + var responseObj: Response? = nil let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data) if decodeResult.error == nil { @@ -428,4 +438,5 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild }) } } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/CodableHelper.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/CodableHelper.swift index 7585573b8a93..e9d28accdf4c 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/CodableHelper.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/CodableHelper.swift @@ -10,9 +10,10 @@ import Foundation public typealias EncodeResult = (data: Data?, error: Error?) open class CodableHelper { - open static var dateformatter: DateFormatter? - open class func decode(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T: Decodable { + public static var dateformatter: DateFormatter? + + open class func decode(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable { var returnedDecodable: T? = nil var returnedError: Error? = nil @@ -38,9 +39,9 @@ open class CodableHelper { return (returnedDecodable, returnedError) } - open class func encode(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T: Encodable { + open class func encode(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable { var returnedData: Data? - var returnedError: Error? + var returnedError: Error? = nil let encoder = JSONEncoder() if prettyPrint { @@ -66,4 +67,5 @@ open class CodableHelper { return (returnedData, returnedError) } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 81fd74f67481..516590da5d9e 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -7,7 +7,9 @@ import Foundation open class Configuration { - // This value is used to configure the date formatter that is used to serialize dates into JSON format. - // You must set it prior to encoding any dates, and it will only be read once. - open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" -} + + // This value is used to configure the date formatter that is used to serialize dates into JSON format. + // You must set it prior to encoding any dates, and it will only be read once. + public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + +} \ No newline at end of file diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift index e2f17a6cb86c..abe218b4e7ac 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -4,8 +4,8 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire extension Bool: JSONEncodable { func encodeToJSON() -> Any { return self as Any } @@ -45,7 +45,7 @@ private func encodeIfPossible(_ object: T) -> Any { extension Array: JSONEncodable { func encodeToJSON() -> Any { - return map(encodeIfPossible) + return self.map(encodeIfPossible) } } @@ -61,7 +61,7 @@ extension Dictionary: JSONEncodable { extension Data: JSONEncodable { func encodeToJSON() -> Any { - return base64EncodedString(options: Data.Base64EncodingOptions()) + return self.base64EncodedString(options: Data.Base64EncodingOptions()) } } @@ -80,11 +80,12 @@ extension Date: JSONEncodable { extension UUID: JSONEncodable { func encodeToJSON() -> Any { - return uuidString + return self.uuidString } } extension String: CodingKey { + public var stringValue: String { return self } @@ -97,38 +98,42 @@ extension String: CodingKey { return nil } - public init?(intValue _: Int) { + public init?(intValue: Int) { return nil } + } extension KeyedEncodingContainerProtocol { - public mutating func encodeArray(_ values: [T], forKey key: Self.Key) throws where T: Encodable { + + public mutating func encodeArray(_ values: [T], forKey key: Self.Key) throws where T : Encodable { var arrayContainer = nestedUnkeyedContainer(forKey: key) try arrayContainer.encode(contentsOf: values) } - public mutating func encodeArrayIfPresent(_ values: [T]?, forKey key: Self.Key) throws where T: Encodable { + public mutating func encodeArrayIfPresent(_ values: [T]?, forKey key: Self.Key) throws where T : Encodable { if let values = values { try encodeArray(values, forKey: key) } } - public mutating func encodeMap(_ pairs: [Self.Key: T]) throws where T: Encodable { + public mutating func encodeMap(_ pairs: [Self.Key: T]) throws where T : Encodable { for (key, value) in pairs { try encode(value, forKey: key) } } - public mutating func encodeMapIfPresent(_ pairs: [Self.Key: T]?) throws where T: Encodable { + public mutating func encodeMapIfPresent(_ pairs: [Self.Key: T]?) throws where T : Encodable { if let pairs = pairs { try encodeMap(pairs) } } + } extension KeyedDecodingContainerProtocol { - public func decodeArray(_: T.Type, forKey key: Self.Key) throws -> [T] where T: Decodable { + + public func decodeArray(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T : Decodable { var tmpArray = [T]() var nestedContainer = try nestedUnkeyedContainer(forKey: key) @@ -140,7 +145,7 @@ extension KeyedDecodingContainerProtocol { return tmpArray } - public func decodeArrayIfPresent(_: T.Type, forKey key: Self.Key) throws -> [T]? where T: Decodable { + public func decodeArrayIfPresent(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable { var tmpArray: [T]? = nil if contains(key) { @@ -150,8 +155,8 @@ extension KeyedDecodingContainerProtocol { return tmpArray } - public func decodeMap(_: T.Type, excludedKeys: Set) throws -> [Self.Key: T] where T: Decodable { - var map: [Self.Key: T] = [:] + public func decodeMap(_ type: T.Type, excludedKeys: Set) throws -> [Self.Key: T] where T : Decodable { + var map: [Self.Key : T] = [:] for key in allKeys { if !excludedKeys.contains(key) { @@ -162,4 +167,7 @@ extension KeyedDecodingContainerProtocol { return map } + } + + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodableEncoding.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodableEncoding.swift index 9d59bd8b7647..ca05906d4206 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodableEncoding.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodableEncoding.swift @@ -5,10 +5,11 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire public struct JSONDataEncoding: ParameterEncoding { + // MARK: Properties private static let jsonDataKey = "jsonData" @@ -41,7 +42,7 @@ public struct JSONDataEncoding: ParameterEncoding { } public static func encodingParameters(jsonData: Data?) -> Parameters? { - var returnedParams: Parameters? + var returnedParams: Parameters? = nil if let jsonData = jsonData, !jsonData.isEmpty { var params = Parameters() params[jsonDataKey] = jsonData @@ -49,4 +50,5 @@ public struct JSONDataEncoding: ParameterEncoding { } return returnedParams } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift index 7a9c6a338033..70449515842d 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -5,12 +5,13 @@ // https://openapi-generator.tech // -import Alamofire import Foundation +import Alamofire open class JSONEncodingHelper { - open class func encodingParameters(forEncodableObject encodableObj: T?) -> Parameters? { - var params: Parameters? + + open class func encodingParameters(forEncodableObject encodableObj: T?) -> Parameters? { + var params: Parameters? = nil // Encode the Encodable object if let encodableObj = encodableObj { @@ -24,7 +25,7 @@ open class JSONEncodingHelper { } open class func encodingParameters(forEncodableObject encodableObj: Any?) -> Parameters? { - var params: Parameters? + var params: Parameters? = nil if let encodableObj = encodableObj { do { @@ -38,4 +39,5 @@ open class JSONEncodingHelper { return params } + } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models.swift index 9d4101c3cd40..408563890359 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models.swift @@ -10,14 +10,14 @@ protocol JSONEncodable { func encodeToJSON() -> Any } -public enum ErrorResponse: Error { +public enum ErrorResponse : Error { case error(Int, Data?, Error) } open class Response { - open let statusCode: Int - open let header: [String: String] - open let body: T? + public let statusCode: Int + public let header: [String: String] + public let body: T? public init(statusCode: Int, header: [String: String], body: T?) { self.statusCode = statusCode @@ -27,7 +27,7 @@ open class Response { public convenience init(response: HTTPURLResponse, body: T?) { let rawHeader = response.allHeaderFields - var header = [String: String]() + var header = [String:String]() for case let (key, value) as (String, String) in rawHeader { header[key] = value } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AdditionalPropertiesClass.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AdditionalPropertiesClass.swift index 7e770e93db19..4e018486ad73 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AdditionalPropertiesClass.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AdditionalPropertiesClass.swift @@ -7,17 +7,23 @@ import Foundation + + public struct AdditionalPropertiesClass: Codable { - public var mapProperty: [String: String]? - public var mapOfMapProperty: [String: [String: String]]? - public init(mapProperty: [String: String]?, mapOfMapProperty: [String: [String: String]]?) { + public var mapProperty: [String:String]? + public var mapOfMapProperty: [String:[String:String]]? + + public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) { self.mapProperty = mapProperty self.mapOfMapProperty = mapOfMapProperty } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case mapProperty = "map_property" case mapOfMapProperty = "map_of_map_property" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Animal.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Animal.swift index 7512bbb43cf6..7221a1be099d 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Animal.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Animal.swift @@ -7,7 +7,10 @@ import Foundation + + public struct Animal: Codable { + public var className: String public var color: String? = "red" @@ -15,4 +18,7 @@ public struct Animal: Codable { self.className = className self.color = color } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AnimalFarm.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AnimalFarm.swift index e09b0e9efdc8..e7bea63f8ed2 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AnimalFarm.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/AnimalFarm.swift @@ -7,4 +7,5 @@ import Foundation + public typealias AnimalFarm = [Animal] diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ApiResponse.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ApiResponse.swift index 0b3b089649e7..a22e9aaebbb0 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ApiResponse.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ApiResponse.swift @@ -7,7 +7,10 @@ import Foundation + + public struct ApiResponse: Codable { + public var code: Int? public var type: String? public var message: String? @@ -17,4 +20,7 @@ public struct ApiResponse: Codable { self.type = type self.message = message } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfArrayOfNumberOnly.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfArrayOfNumberOnly.swift index e495772674ad..4e5a5ca1445d 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfArrayOfNumberOnly.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfArrayOfNumberOnly.swift @@ -7,14 +7,20 @@ import Foundation + + public struct ArrayOfArrayOfNumberOnly: Codable { + public var arrayArrayNumber: [[Double]]? public init(arrayArrayNumber: [[Double]]?) { self.arrayArrayNumber = arrayArrayNumber } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case arrayArrayNumber = "ArrayArrayNumber" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfNumberOnly.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfNumberOnly.swift index 2621da38aa0b..7d059d368339 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfNumberOnly.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayOfNumberOnly.swift @@ -7,14 +7,20 @@ import Foundation + + public struct ArrayOfNumberOnly: Codable { + public var arrayNumber: [Double]? public init(arrayNumber: [Double]?) { self.arrayNumber = arrayNumber } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case arrayNumber = "ArrayNumber" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayTest.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayTest.swift index f185b9dc3e31..9c56fed50c2e 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayTest.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ArrayTest.swift @@ -7,7 +7,10 @@ import Foundation + + public struct ArrayTest: Codable { + public var arrayOfString: [String]? public var arrayArrayOfInteger: [[Int64]]? public var arrayArrayOfModel: [[ReadOnlyFirst]]? @@ -18,9 +21,12 @@ public struct ArrayTest: Codable { self.arrayArrayOfModel = arrayArrayOfModel } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case arrayOfString = "array_of_string" case arrayArrayOfInteger = "array_array_of_integer" case arrayArrayOfModel = "array_array_of_model" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Capitalization.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Capitalization.swift index b56ad4556685..98cda23dac9e 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Capitalization.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Capitalization.swift @@ -7,7 +7,10 @@ import Foundation + + public struct Capitalization: Codable { + public var smallCamel: String? public var capitalCamel: String? public var smallSnake: String? @@ -25,7 +28,7 @@ public struct Capitalization: Codable { self.ATT_NAME = ATT_NAME } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case smallCamel case capitalCamel = "CapitalCamel" case smallSnake = "small_Snake" @@ -33,4 +36,7 @@ public struct Capitalization: Codable { case sCAETHFlowPoints = "SCA_ETH_Flow_Points" case ATT_NAME } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Cat.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Cat.swift index df496298f0cf..a116d964ea84 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Cat.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Cat.swift @@ -7,7 +7,10 @@ import Foundation + + public struct Cat: Codable { + public var className: String public var color: String? = "red" public var declawed: Bool? @@ -17,4 +20,7 @@ public struct Cat: Codable { self.color = color self.declawed = declawed } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Category.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Category.swift index 7a5bc6d6c1c1..afdc89b6dd06 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Category.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Category.swift @@ -7,17 +7,23 @@ import Foundation + + public struct Category: Codable { + public var _id: Int64? - public var name: String? + public var name: String = "default-name" - public init(_id: Int64?, name: String?) { + public init(_id: Int64?, name: String) { self._id = _id self.name = name } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _id = "id" case name } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ClassModel.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ClassModel.swift index 48c4a01e5975..f673ed127cd8 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ClassModel.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ClassModel.swift @@ -7,12 +7,17 @@ import Foundation + /** Model for testing model with \"_class\" property */ public struct ClassModel: Codable { + public var _class: String? public init(_class: String?) { self._class = _class } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Client.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Client.swift index 07d1e7155af4..51390b6c4eac 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Client.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Client.swift @@ -7,10 +7,16 @@ import Foundation + + public struct Client: Codable { + public var client: String? public init(client: String?) { self.client = client } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Dog.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Dog.swift index e92c098dcc70..239ce74dcc21 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Dog.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Dog.swift @@ -7,7 +7,10 @@ import Foundation + + public struct Dog: Codable { + public var className: String public var color: String? = "red" public var breed: String? @@ -17,4 +20,7 @@ public struct Dog: Codable { self.color = color self.breed = breed } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumArrays.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumArrays.swift index 975174f10c2b..8713961520e1 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumArrays.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumArrays.swift @@ -7,17 +7,18 @@ import Foundation + + public struct EnumArrays: Codable { + public enum JustSymbol: String, Codable { case greaterThanOrEqualTo = ">=" case dollar = "$" } - public enum ArrayEnum: String, Codable { - case fish - case crab + case fish = "fish" + case crab = "crab" } - public var justSymbol: JustSymbol? public var arrayEnum: [ArrayEnum]? @@ -26,8 +27,11 @@ public struct EnumArrays: Codable { self.arrayEnum = arrayEnum } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case justSymbol = "just_symbol" case arrayEnum = "array_enum" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumClass.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumClass.swift index 3c1dfcac577d..7280a621fec7 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumClass.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumClass.swift @@ -7,6 +7,7 @@ import Foundation + public enum EnumClass: String, Codable { case abc = "_abc" case efg = "-efg" diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumTest.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumTest.swift index e594b59d0f00..0f546c76a218 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumTest.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/EnumTest.swift @@ -7,29 +7,28 @@ import Foundation + + public struct EnumTest: Codable { + public enum EnumString: String, Codable { case upper = "UPPER" - case lower + case lower = "lower" case empty = "" } - public enum EnumStringRequired: String, Codable { case upper = "UPPER" - case lower + case lower = "lower" case empty = "" } - public enum EnumInteger: Int, Codable { case _1 = 1 case number1 = -1 } - public enum EnumNumber: Double, Codable { case _11 = 1.1 case number12 = -1.2 } - public var enumString: EnumString? public var enumStringRequired: EnumStringRequired public var enumInteger: EnumInteger? @@ -44,11 +43,14 @@ public struct EnumTest: Codable { self.outerEnum = outerEnum } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case enumString = "enum_string" case enumStringRequired = "enum_string_required" case enumInteger = "enum_integer" case enumNumber = "enum_number" case outerEnum } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/File.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/File.swift index af7980371e0e..c8bd1f19589b 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/File.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/File.swift @@ -7,13 +7,18 @@ import Foundation + /** Must be named `File` for test. */ public struct File: Codable { + /** Test capitalization */ public var sourceURI: String? public init(sourceURI: String?) { self.sourceURI = sourceURI } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FileSchemaTestClass.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FileSchemaTestClass.swift index 582bc0c9052d..64d025068027 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FileSchemaTestClass.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FileSchemaTestClass.swift @@ -7,7 +7,10 @@ import Foundation + + public struct FileSchemaTestClass: Codable { + public var file: File? public var files: [File]? @@ -15,4 +18,7 @@ public struct FileSchemaTestClass: Codable { self.file = file self.files = files } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FormatTest.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FormatTest.swift index 50e1d1d08cc1..faa091b0658c 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FormatTest.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/FormatTest.swift @@ -7,7 +7,10 @@ import Foundation + + public struct FormatTest: Codable { + public var integer: Int? public var int32: Int? public var int64: Int64? @@ -37,4 +40,7 @@ public struct FormatTest: Codable { self.uuid = uuid self.password = password } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/HasOnlyReadOnly.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/HasOnlyReadOnly.swift index f25c80210384..554aee1081aa 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/HasOnlyReadOnly.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/HasOnlyReadOnly.swift @@ -7,7 +7,10 @@ import Foundation + + public struct HasOnlyReadOnly: Codable { + public var bar: String? public var foo: String? @@ -15,4 +18,7 @@ public struct HasOnlyReadOnly: Codable { self.bar = bar self.foo = foo } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/List.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/List.swift index 9170bca2710d..8997340ff4be 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/List.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/List.swift @@ -7,14 +7,20 @@ import Foundation + + public struct List: Codable { + public var _123list: String? public init(_123list: String?) { self._123list = _123list } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _123list = "123-list" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MapTest.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MapTest.swift index 9fe75f50c484..392c1e443839 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MapTest.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MapTest.swift @@ -7,28 +7,33 @@ import Foundation + + public struct MapTest: Codable { + public enum MapOfEnumString: String, Codable { case upper = "UPPER" - case lower + case lower = "lower" } + public var mapMapOfString: [String:[String:String]]? + public var mapOfEnumString: [String:String]? + public var directMap: [String:Bool]? + public var indirectMap: [String:Bool]? - public var mapMapOfString: [String: [String: String]]? - public var mapOfEnumString: [String: String]? - public var directMap: [String: Bool]? - public var indirectMap: StringBooleanMap? - - public init(mapMapOfString: [String: [String: String]]?, mapOfEnumString: [String: String]?, directMap: [String: Bool]?, indirectMap: StringBooleanMap?) { + public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?, directMap: [String:Bool]?, indirectMap: [String:Bool]?) { self.mapMapOfString = mapMapOfString self.mapOfEnumString = mapOfEnumString self.directMap = directMap self.indirectMap = indirectMap } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case mapMapOfString = "map_map_of_string" case mapOfEnumString = "map_of_enum_string" case directMap = "direct_map" case indirectMap = "indirect_map" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MixedPropertiesAndAdditionalPropertiesClass.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MixedPropertiesAndAdditionalPropertiesClass.swift index cd66f2e25236..7116108fd7a3 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MixedPropertiesAndAdditionalPropertiesClass.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/MixedPropertiesAndAdditionalPropertiesClass.swift @@ -7,14 +7,20 @@ import Foundation + + public struct MixedPropertiesAndAdditionalPropertiesClass: Codable { + public var uuid: UUID? public var dateTime: Date? - public var map: [String: Animal]? + public var map: [String:Animal]? - public init(uuid: UUID?, dateTime: Date?, map: [String: Animal]?) { + public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) { self.uuid = uuid self.dateTime = dateTime self.map = map } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Model200Response.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Model200Response.swift index 71a645984031..fc1d0606b7ba 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Model200Response.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Model200Response.swift @@ -7,9 +7,11 @@ import Foundation + /** Model for testing model name starting with number */ public struct Model200Response: Codable { + public var name: Int? public var _class: String? @@ -18,8 +20,11 @@ public struct Model200Response: Codable { self._class = _class } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case name case _class = "class" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Name.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Name.swift index 2e763d9cec4e..cc165d767d91 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Name.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Name.swift @@ -7,9 +7,11 @@ import Foundation + /** Model for testing model name same as property name */ public struct Name: Codable { + public var name: Int public var snakeCase: Int? public var property: String? @@ -22,10 +24,13 @@ public struct Name: Codable { self._123number = _123number } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case name case snakeCase = "snake_case" case property case _123number = "123Number" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/NumberOnly.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/NumberOnly.swift index e17f7f837a93..e6fb206093aa 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/NumberOnly.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/NumberOnly.swift @@ -7,14 +7,20 @@ import Foundation + + public struct NumberOnly: Codable { + public var justNumber: Double? public init(justNumber: Double?) { self.justNumber = justNumber } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case justNumber = "JustNumber" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Order.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Order.swift index 5c0470d50ebf..5cad29458b75 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Order.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Order.swift @@ -7,13 +7,15 @@ import Foundation + + public struct Order: Codable { + public enum Status: String, Codable { - case placed - case approved - case delivered + case placed = "placed" + case approved = "approved" + case delivered = "delivered" } - public var _id: Int64? public var petId: Int64? public var quantity: Int? @@ -31,7 +33,7 @@ public struct Order: Codable { self.complete = complete } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _id = "id" case petId case quantity @@ -39,4 +41,7 @@ public struct Order: Codable { case status case complete } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterComposite.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterComposite.swift index 7313180b1304..edc4523d9f00 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterComposite.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterComposite.swift @@ -7,7 +7,10 @@ import Foundation + + public struct OuterComposite: Codable { + public var myNumber: Double? public var myString: String? public var myBoolean: Bool? @@ -18,9 +21,12 @@ public struct OuterComposite: Codable { self.myBoolean = myBoolean } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case myNumber = "my_number" case myString = "my_string" case myBoolean = "my_boolean" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterEnum.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterEnum.swift index f96a41a000af..bd1643d279ed 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterEnum.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/OuterEnum.swift @@ -7,8 +7,9 @@ import Foundation + public enum OuterEnum: String, Codable { - case placed - case approved - case delivered + case placed = "placed" + case approved = "approved" + case delivered = "delivered" } diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Pet.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Pet.swift index a81c4de439af..3773bf53317e 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Pet.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Pet.swift @@ -7,13 +7,15 @@ import Foundation + + public struct Pet: Codable { + public enum Status: String, Codable { - case available - case pending - case sold + case available = "available" + case pending = "pending" + case sold = "sold" } - public var _id: Int64? public var category: Category? public var name: String @@ -31,7 +33,7 @@ public struct Pet: Codable { self.status = status } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _id = "id" case category case name @@ -39,4 +41,7 @@ public struct Pet: Codable { case tags case status } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ReadOnlyFirst.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ReadOnlyFirst.swift index 79e89c2daa6b..48b655a5b0aa 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ReadOnlyFirst.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/ReadOnlyFirst.swift @@ -7,7 +7,10 @@ import Foundation + + public struct ReadOnlyFirst: Codable { + public var bar: String? public var baz: String? @@ -15,4 +18,7 @@ public struct ReadOnlyFirst: Codable { self.bar = bar self.baz = baz } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Return.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Return.swift index 1a645d269676..de4b218999b7 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Return.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Return.swift @@ -7,16 +7,21 @@ import Foundation + /** Model for testing reserved words */ public struct Return: Codable { + public var _return: Int? public init(_return: Int?) { self._return = _return } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _return = "return" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/SpecialModelName.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/SpecialModelName.swift index ff2460d20191..213d896ba988 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/SpecialModelName.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/SpecialModelName.swift @@ -7,14 +7,20 @@ import Foundation + + public struct SpecialModelName: Codable { + public var specialPropertyName: Int64? public init(specialPropertyName: Int64?) { self.specialPropertyName = specialPropertyName } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case specialPropertyName = "$special[property.name]" } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/StringBooleanMap.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/StringBooleanMap.swift index 581899343a18..ae15e87d94bb 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/StringBooleanMap.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/StringBooleanMap.swift @@ -7,8 +7,12 @@ import Foundation + + public struct StringBooleanMap: Codable { - public var additionalProperties: [String: Bool] = [:] + + + public var additionalProperties: [String:Bool] = [:] public subscript(key: String) -> Bool? { get { @@ -26,6 +30,7 @@ public struct StringBooleanMap: Codable { // Encodable protocol methods public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: String.self) try container.encodeMap(additionalProperties) @@ -39,4 +44,8 @@ public struct StringBooleanMap: Codable { var nonAdditionalPropertyKeys = Set() additionalProperties = try container.decodeMap(Bool.self, excludedKeys: nonAdditionalPropertyKeys) } + + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Tag.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Tag.swift index 063ee1ddc3c6..20f50efd3ac0 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Tag.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/Tag.swift @@ -7,7 +7,10 @@ import Foundation + + public struct Tag: Codable { + public var _id: Int64? public var name: String? @@ -16,8 +19,11 @@ public struct Tag: Codable { self.name = name } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _id = "id" case name } + + } + diff --git a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/User.swift b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/User.swift index aba2f35accc3..d9c564d2a1fe 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/User.swift +++ b/samples/client/petstore/swift4/default/PetstoreClient/Classes/OpenAPIs/Models/User.swift @@ -7,7 +7,10 @@ import Foundation + + public struct User: Codable { + public var _id: Int64? public var username: String? public var firstName: String? @@ -29,7 +32,7 @@ public struct User: Codable { self.userStatus = userStatus } - public enum CodingKeys: String, CodingKey { + public enum CodingKeys: String, CodingKey { case _id = "id" case username case firstName @@ -39,4 +42,7 @@ public struct User: Codable { case phone case userStatus } + + } +