[Swift] Add public initializer for modelObject. (#7652)

* Add public initializer for modelObject.

* Update samples.

* Use allVars instead of vars.

* Fix code format.
This commit is contained in:
Yukio Ejiri 2018-03-16 01:56:00 +09:00 committed by William Cheng
parent b5eb0e7de8
commit e22faf4cd3
159 changed files with 938 additions and 53 deletions

View File

@ -22,6 +22,14 @@ public struct {{classname}}: Codable {
{{/isEnum}}
{{/allVars}}
{{#hasVars}}
public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
{{#allVars}}
self.{{name}} = {{name}}
{{/allVars}}
}
{{/hasVars}}
{{#additionalPropertiesType}}
public var additionalProperties: [String:{{{additionalPropertiesType}}}] = [:]

View File

@ -157,7 +157,7 @@ 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)) {
@ -210,7 +210,7 @@ open class UserAPI {
"username" : "username"
}}]
- 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.
- returns: RequestBuilder<User>
*/

View File

@ -14,6 +14,11 @@ public struct AdditionalPropertiesClass: Codable {
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 {
case mapProperty = "map_property"

View File

@ -14,6 +14,11 @@ public struct Animal: Codable {
public var className: String
public var color: String?
public init(className: String, color: String?) {
self.className = className
self.color = color
}
}

View File

@ -15,6 +15,12 @@ public struct ApiResponse: Codable {
public var type: String?
public var message: String?
public init(code: Int?, type: String?, message: String?) {
self.code = code
self.type = type
self.message = message
}
}

View File

@ -13,6 +13,10 @@ public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]?
public init(arrayArrayNumber: [[Double]]?) {
self.arrayArrayNumber = arrayArrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayArrayNumber = "ArrayArrayNumber"

View File

@ -13,6 +13,10 @@ public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]?
public init(arrayNumber: [Double]?) {
self.arrayNumber = arrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayNumber = "ArrayNumber"

View File

@ -15,6 +15,12 @@ public struct ArrayTest: Codable {
public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
self.arrayOfString = arrayOfString
self.arrayArrayOfInteger = arrayArrayOfInteger
self.arrayArrayOfModel = arrayArrayOfModel
}
public enum CodingKeys: String, CodingKey {
case arrayOfString = "array_of_string"

View File

@ -19,6 +19,15 @@ public struct Capitalization: Codable {
/** Name of the pet */
public var ATT_NAME: String?
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
self.smallCamel = smallCamel
self.capitalCamel = capitalCamel
self.smallSnake = smallSnake
self.capitalSnake = capitalSnake
self.sCAETHFlowPoints = sCAETHFlowPoints
self.ATT_NAME = ATT_NAME
}
public enum CodingKeys: String, CodingKey {
case smallCamel

View File

@ -15,6 +15,12 @@ public struct Cat: Codable {
public var color: String?
public var declawed: Bool?
public init(className: String, color: String?, declawed: Bool?) {
self.className = className
self.color = color
self.declawed = declawed
}
}

View File

@ -14,6 +14,11 @@ public struct Category: Codable {
public var _id: Int64?
public var name: String?
public init(_id: Int64?, name: String?) {
self._id = _id
self.name = name
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,6 +14,10 @@ public struct ClassModel: Codable {
public var _class: String?
public init(_class: String?) {
self._class = _class
}
}

View File

@ -13,6 +13,10 @@ public struct Client: Codable {
public var client: String?
public init(client: String?) {
self.client = client
}
}

View File

@ -15,6 +15,12 @@ public struct Dog: Codable {
public var color: String?
public var breed: String?
public init(className: String, color: String?, breed: String?) {
self.className = className
self.color = color
self.breed = breed
}
}

View File

@ -22,6 +22,11 @@ public struct EnumArrays: Codable {
public var justSymbol: JustSymbol?
public var arrayEnum: [ArrayEnum]?
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
self.justSymbol = justSymbol
self.arrayEnum = arrayEnum
}
public enum CodingKeys: String, CodingKey {
case justSymbol = "just_symbol"

View File

@ -29,6 +29,13 @@ public struct EnumTest: Codable {
public var enumNumber: EnumNumber?
public var outerEnum: OuterEnum?
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
self.enumString = enumString
self.enumInteger = enumInteger
self.enumNumber = enumNumber
self.outerEnum = outerEnum
}
public enum CodingKeys: String, CodingKey {
case enumString = "enum_string"

View File

@ -25,6 +25,22 @@ public struct FormatTest: Codable {
public var uuid: UUID?
public var password: String
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
self.number = number
self.float = float
self.double = double
self.string = string
self.byte = byte
self.binary = binary
self.date = date
self.dateTime = dateTime
self.uuid = uuid
self.password = password
}
}

View File

@ -14,6 +14,11 @@ public struct HasOnlyReadOnly: Codable {
public var bar: String?
public var foo: String?
public init(bar: String?, foo: String?) {
self.bar = bar
self.foo = foo
}
}

View File

@ -13,6 +13,10 @@ public struct List: Codable {
public var _123List: String?
public init(_123List: String?) {
self._123List = _123List
}
public enum CodingKeys: String, CodingKey {
case _123List = "123-list"

View File

@ -18,6 +18,11 @@ public struct MapTest: Codable {
public var mapMapOfString: [String:[String:String]]?
public var mapOfEnumString: [String:String]?
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
self.mapMapOfString = mapMapOfString
self.mapOfEnumString = mapOfEnumString
}
public enum CodingKeys: String, CodingKey {
case mapMapOfString = "map_map_of_string"

View File

@ -15,6 +15,12 @@ public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var dateTime: Date?
public var map: [String:Animal]?
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
self.uuid = uuid
self.dateTime = dateTime
self.map = map
}
}

View File

@ -15,6 +15,11 @@ public struct Model200Response: Codable {
public var name: Int?
public var _class: String?
public init(name: Int?, _class: String?) {
self.name = name
self._class = _class
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -17,6 +17,13 @@ public struct Name: Codable {
public var property: String?
public var _123Number: Int?
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
self.name = name
self.snakeCase = snakeCase
self.property = property
self._123Number = _123Number
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -13,6 +13,10 @@ public struct NumberOnly: Codable {
public var justNumber: Double?
public init(justNumber: Double?) {
self.justNumber = justNumber
}
public enum CodingKeys: String, CodingKey {
case justNumber = "JustNumber"

View File

@ -24,6 +24,15 @@ public struct Order: Codable {
public var status: Status?
public var complete: Bool?
public init(_id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
self._id = _id
self.petId = petId
self.quantity = quantity
self.shipDate = shipDate
self.status = status
self.complete = complete
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,5 +14,6 @@ public struct OuterBoolean: Codable {
}

View File

@ -15,6 +15,12 @@ public struct OuterComposite: Codable {
public var myString: OuterString?
public var myBoolean: OuterBoolean?
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) {
self.myNumber = myNumber
self.myString = myString
self.myBoolean = myBoolean
}
public enum CodingKeys: String, CodingKey {
case myNumber = "my_number"

View File

@ -14,5 +14,6 @@ public struct OuterNumber: Codable {
}

View File

@ -14,5 +14,6 @@ public struct OuterString: Codable {
}

View File

@ -24,6 +24,15 @@ public struct Pet: Codable {
/** pet status in the store */
public var status: Status?
public init(_id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
self._id = _id
self.category = category
self.name = name
self.photoUrls = photoUrls
self.tags = tags
self.status = status
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,6 +14,11 @@ public struct ReadOnlyFirst: Codable {
public var bar: String?
public var baz: String?
public init(bar: String?, baz: String?) {
self.bar = bar
self.baz = baz
}
}

View File

@ -14,6 +14,10 @@ public struct Return: Codable {
public var _return: Int?
public init(_return: Int?) {
self._return = _return
}
public enum CodingKeys: String, CodingKey {
case _return = "return"

View File

@ -13,6 +13,10 @@ public struct SpecialModelName: Codable {
public var specialPropertyName: Int64?
public init(specialPropertyName: Int64?) {
self.specialPropertyName = specialPropertyName
}
public enum CodingKeys: String, CodingKey {
case specialPropertyName = "$special[property.name]"

View File

@ -14,6 +14,11 @@ public struct Tag: Codable {
public var _id: Int64?
public var name: String?
public init(_id: Int64?, name: String?) {
self._id = _id
self.name = name
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -21,6 +21,17 @@ public struct User: Codable {
/** User Status */
public var userStatus: Int?
public init(_id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
self._id = _id
self.username = username
self.firstName = firstName
self.lastName = lastName
self.email = email
self.password = password
self.phone = phone
self.userStatus = userStatus
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -16,10 +16,10 @@ open class PetstoreClientAPI {
open class RequestBuilder<T> {
var credential: URLCredential?
var headers: [String:String]
let parameters: [String:Any]?
let isBody: Bool
let method: String
let URLString: 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) -> ())?

View File

@ -78,7 +78,9 @@ open class PetAPI {
*/
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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
@ -432,7 +434,9 @@ open class PetAPI {
*/
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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
@ -513,7 +517,9 @@ open class PetAPI {
*/
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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?] = [
"name": name,
@ -567,7 +573,9 @@ open class PetAPI {
*/
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
var path = "/pet/{petId}/uploadImage"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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?] = [
"additionalMetadata": additionalMetadata,

View File

@ -35,7 +35,9 @@ open class StoreAPI {
*/
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{order_id}"
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let orderIdPreEscape = "\(orderId)"
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
@ -139,7 +141,9 @@ open class StoreAPI {
*/
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{order_id}"
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let orderIdPreEscape = "\(orderId)"
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

View File

@ -140,7 +140,9 @@ open class UserAPI {
*/
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
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
@ -155,7 +157,7 @@ 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)) {
@ -208,13 +210,15 @@ open class UserAPI {
"username" : "username"
}}]
- 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.
- returns: RequestBuilder<User>
*/
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
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
@ -329,7 +333,9 @@ open class UserAPI {
*/
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)

View File

@ -14,6 +14,11 @@ public struct AdditionalPropertiesClass: Codable {
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 {
case mapProperty = "map_property"

View File

@ -14,6 +14,11 @@ public struct Animal: Codable {
public var className: String
public var color: String?
public init(className: String, color: String?) {
self.className = className
self.color = color
}
}

View File

@ -20,6 +20,12 @@ public struct ApiResponse: Codable {
public var type: String?
public var message: String?
public init(code: Int?, type: String?, message: String?) {
self.code = code
self.type = type
self.message = message
}
}

View File

@ -13,6 +13,10 @@ public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]?
public init(arrayArrayNumber: [[Double]]?) {
self.arrayArrayNumber = arrayArrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayArrayNumber = "ArrayArrayNumber"

View File

@ -13,6 +13,10 @@ public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]?
public init(arrayNumber: [Double]?) {
self.arrayNumber = arrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayNumber = "ArrayNumber"

View File

@ -15,6 +15,12 @@ public struct ArrayTest: Codable {
public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
self.arrayOfString = arrayOfString
self.arrayArrayOfInteger = arrayArrayOfInteger
self.arrayArrayOfModel = arrayArrayOfModel
}
public enum CodingKeys: String, CodingKey {
case arrayOfString = "array_of_string"

View File

@ -19,6 +19,15 @@ public struct Capitalization: Codable {
/** Name of the pet */
public var ATT_NAME: String?
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
self.smallCamel = smallCamel
self.capitalCamel = capitalCamel
self.smallSnake = smallSnake
self.capitalSnake = capitalSnake
self.sCAETHFlowPoints = sCAETHFlowPoints
self.ATT_NAME = ATT_NAME
}
public enum CodingKeys: String, CodingKey {
case smallCamel

View File

@ -20,6 +20,12 @@ public struct Cat: Codable {
}
}
public init(className: String, color: String?, declawed: Bool?) {
self.className = className
self.color = color
self.declawed = declawed
}
}

View File

@ -19,6 +19,11 @@ public struct Category: Codable {
}
public var name: String?
public init(_id: Int64?, name: String?) {
self._id = _id
self.name = name
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,6 +14,10 @@ public struct ClassModel: Codable {
public var _class: String?
public init(_class: String?) {
self._class = _class
}
}

View File

@ -13,6 +13,10 @@ public struct Client: Codable {
public var client: String?
public init(client: String?) {
self.client = client
}
}

View File

@ -15,6 +15,12 @@ public struct Dog: Codable {
public var color: String?
public var breed: String?
public init(className: String, color: String?, breed: String?) {
self.className = className
self.color = color
self.breed = breed
}
}

View File

@ -22,6 +22,11 @@ public struct EnumArrays: Codable {
public var justSymbol: JustSymbol?
public var arrayEnum: [ArrayEnum]?
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
self.justSymbol = justSymbol
self.arrayEnum = arrayEnum
}
public enum CodingKeys: String, CodingKey {
case justSymbol = "just_symbol"

View File

@ -29,6 +29,13 @@ public struct EnumTest: Codable {
public var enumNumber: EnumNumber?
public var outerEnum: OuterEnum?
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
self.enumString = enumString
self.enumInteger = enumInteger
self.enumNumber = enumNumber
self.outerEnum = outerEnum
}
public enum CodingKeys: String, CodingKey {
case enumString = "enum_string"

View File

@ -50,6 +50,22 @@ public struct FormatTest: Codable {
public var uuid: UUID?
public var password: String
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
self.number = number
self.float = float
self.double = double
self.string = string
self.byte = byte
self.binary = binary
self.date = date
self.dateTime = dateTime
self.uuid = uuid
self.password = password
}
}

View File

@ -14,6 +14,11 @@ public struct HasOnlyReadOnly: Codable {
public var bar: String?
public var foo: String?
public init(bar: String?, foo: String?) {
self.bar = bar
self.foo = foo
}
}

View File

@ -13,6 +13,10 @@ public struct List: Codable {
public var _123List: String?
public init(_123List: String?) {
self._123List = _123List
}
public enum CodingKeys: String, CodingKey {
case _123List = "123-list"

View File

@ -18,6 +18,11 @@ public struct MapTest: Codable {
public var mapMapOfString: [String:[String:String]]?
public var mapOfEnumString: [String:String]?
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
self.mapMapOfString = mapMapOfString
self.mapOfEnumString = mapOfEnumString
}
public enum CodingKeys: String, CodingKey {
case mapMapOfString = "map_map_of_string"

View File

@ -15,6 +15,12 @@ public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var dateTime: Date?
public var map: [String:Animal]?
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
self.uuid = uuid
self.dateTime = dateTime
self.map = map
}
}

View File

@ -20,6 +20,11 @@ public struct Model200Response: Codable {
}
public var _class: String?
public init(name: Int?, _class: String?) {
self.name = name
self._class = _class
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -32,6 +32,13 @@ public struct Name: Codable {
}
}
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
self.name = name
self.snakeCase = snakeCase
self.property = property
self._123Number = _123Number
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -13,6 +13,10 @@ public struct NumberOnly: Codable {
public var justNumber: Double?
public init(justNumber: Double?) {
self.justNumber = justNumber
}
public enum CodingKeys: String, CodingKey {
case justNumber = "JustNumber"

View File

@ -44,6 +44,15 @@ public struct Order: Codable {
}
}
public init(_id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
self._id = _id
self.petId = petId
self.quantity = quantity
self.shipDate = shipDate
self.status = status
self.complete = complete
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,5 +14,6 @@ public struct OuterBoolean: Codable {
}

View File

@ -15,6 +15,12 @@ public struct OuterComposite: Codable {
public var myString: OuterString?
public var myBoolean: OuterBoolean?
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) {
self.myNumber = myNumber
self.myString = myString
self.myBoolean = myBoolean
}
public enum CodingKeys: String, CodingKey {
case myNumber = "my_number"

View File

@ -14,5 +14,6 @@ public struct OuterNumber: Codable {
}

View File

@ -14,5 +14,6 @@ public struct OuterString: Codable {
}

View File

@ -29,6 +29,15 @@ public struct Pet: Codable {
/** pet status in the store */
public var status: Status?
public init(_id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
self._id = _id
self.category = category
self.name = name
self.photoUrls = photoUrls
self.tags = tags
self.status = status
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,6 +14,11 @@ public struct ReadOnlyFirst: Codable {
public var bar: String?
public var baz: String?
public init(bar: String?, baz: String?) {
self.bar = bar
self.baz = baz
}
}

View File

@ -19,6 +19,10 @@ public struct Return: Codable {
}
}
public init(_return: Int?) {
self._return = _return
}
public enum CodingKeys: String, CodingKey {
case _return = "return"

View File

@ -18,6 +18,10 @@ public struct SpecialModelName: Codable {
}
}
public init(specialPropertyName: Int64?) {
self.specialPropertyName = specialPropertyName
}
public enum CodingKeys: String, CodingKey {
case specialPropertyName = "$special[property.name]"

View File

@ -19,6 +19,11 @@ public struct Tag: Codable {
}
public var name: String?
public init(_id: Int64?, name: String?) {
self._id = _id
self.name = name
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -31,6 +31,17 @@ public struct User: Codable {
}
}
public init(_id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
self._id = _id
self.username = username
self.firstName = firstName
self.lastName = lastName
self.email = email
self.password = password
self.phone = phone
self.userStatus = userStatus
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -16,10 +16,10 @@ open class PetstoreClientAPI {
open class RequestBuilder<T> {
var credential: URLCredential?
var headers: [String:String]
let parameters: [String:Any]?
let isBody: Bool
let method: String
let URLString: 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) -> ())?

View File

@ -114,7 +114,9 @@ open class PetAPI {
*/
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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
@ -519,7 +521,9 @@ open class PetAPI {
*/
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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
@ -636,7 +640,9 @@ open class PetAPI {
*/
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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?] = [
"name": name,
@ -709,7 +715,9 @@ open class PetAPI {
*/
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
var path = "/pet/{petId}/uploadImage"
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
let petIdPreEscape = "\(petId)"
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?] = [
"additionalMetadata": additionalMetadata,

View File

@ -53,7 +53,9 @@ open class StoreAPI {
*/
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{order_id}"
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let orderIdPreEscape = "\(orderId)"
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
@ -190,7 +192,9 @@ open class StoreAPI {
*/
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{order_id}"
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let orderIdPreEscape = "\(orderId)"
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

View File

@ -209,7 +209,9 @@ open class UserAPI {
*/
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
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
@ -224,7 +226,7 @@ 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)) {
@ -236,7 +238,7 @@ 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.
- returns: Promise<User>
*/
open class func getUserByName( username: String) -> Promise<User> {
@ -294,13 +296,15 @@ open class UserAPI {
"username" : "username"
}}]
- 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.
- returns: RequestBuilder<User>
*/
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
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
@ -467,7 +471,9 @@ open class UserAPI {
*/
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
var path = "/user/{username}"
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
let usernamePreEscape = "\(username)"
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)

View File

@ -14,6 +14,11 @@ public struct AdditionalPropertiesClass: Codable {
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 {
case mapProperty = "map_property"

View File

@ -14,6 +14,11 @@ public struct Animal: Codable {
public var className: String
public var color: String?
public init(className: String, color: String?) {
self.className = className
self.color = color
}
}

View File

@ -15,6 +15,12 @@ public struct ApiResponse: Codable {
public var type: String?
public var message: String?
public init(code: Int?, type: String?, message: String?) {
self.code = code
self.type = type
self.message = message
}
}

View File

@ -13,6 +13,10 @@ public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]?
public init(arrayArrayNumber: [[Double]]?) {
self.arrayArrayNumber = arrayArrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayArrayNumber = "ArrayArrayNumber"

View File

@ -13,6 +13,10 @@ public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]?
public init(arrayNumber: [Double]?) {
self.arrayNumber = arrayNumber
}
public enum CodingKeys: String, CodingKey {
case arrayNumber = "ArrayNumber"

View File

@ -15,6 +15,12 @@ public struct ArrayTest: Codable {
public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
self.arrayOfString = arrayOfString
self.arrayArrayOfInteger = arrayArrayOfInteger
self.arrayArrayOfModel = arrayArrayOfModel
}
public enum CodingKeys: String, CodingKey {
case arrayOfString = "array_of_string"

View File

@ -19,6 +19,15 @@ public struct Capitalization: Codable {
/** Name of the pet */
public var ATT_NAME: String?
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
self.smallCamel = smallCamel
self.capitalCamel = capitalCamel
self.smallSnake = smallSnake
self.capitalSnake = capitalSnake
self.sCAETHFlowPoints = sCAETHFlowPoints
self.ATT_NAME = ATT_NAME
}
public enum CodingKeys: String, CodingKey {
case smallCamel

View File

@ -15,6 +15,12 @@ public struct Cat: Codable {
public var color: String?
public var declawed: Bool?
public init(className: String, color: String?, declawed: Bool?) {
self.className = className
self.color = color
self.declawed = declawed
}
}

View File

@ -14,6 +14,11 @@ public struct Category: Codable {
public var _id: Int64?
public var name: String?
public init(_id: Int64?, name: String?) {
self._id = _id
self.name = name
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,6 +14,10 @@ public struct ClassModel: Codable {
public var _class: String?
public init(_class: String?) {
self._class = _class
}
}

View File

@ -13,6 +13,10 @@ public struct Client: Codable {
public var client: String?
public init(client: String?) {
self.client = client
}
}

View File

@ -15,6 +15,12 @@ public struct Dog: Codable {
public var color: String?
public var breed: String?
public init(className: String, color: String?, breed: String?) {
self.className = className
self.color = color
self.breed = breed
}
}

View File

@ -22,6 +22,11 @@ public struct EnumArrays: Codable {
public var justSymbol: JustSymbol?
public var arrayEnum: [ArrayEnum]?
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
self.justSymbol = justSymbol
self.arrayEnum = arrayEnum
}
public enum CodingKeys: String, CodingKey {
case justSymbol = "just_symbol"

View File

@ -29,6 +29,13 @@ public struct EnumTest: Codable {
public var enumNumber: EnumNumber?
public var outerEnum: OuterEnum?
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
self.enumString = enumString
self.enumInteger = enumInteger
self.enumNumber = enumNumber
self.outerEnum = outerEnum
}
public enum CodingKeys: String, CodingKey {
case enumString = "enum_string"

View File

@ -25,6 +25,22 @@ public struct FormatTest: Codable {
public var uuid: UUID?
public var password: String
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
self.number = number
self.float = float
self.double = double
self.string = string
self.byte = byte
self.binary = binary
self.date = date
self.dateTime = dateTime
self.uuid = uuid
self.password = password
}
}

View File

@ -14,6 +14,11 @@ public struct HasOnlyReadOnly: Codable {
public var bar: String?
public var foo: String?
public init(bar: String?, foo: String?) {
self.bar = bar
self.foo = foo
}
}

View File

@ -13,6 +13,10 @@ public struct List: Codable {
public var _123List: String?
public init(_123List: String?) {
self._123List = _123List
}
public enum CodingKeys: String, CodingKey {
case _123List = "123-list"

View File

@ -18,6 +18,11 @@ public struct MapTest: Codable {
public var mapMapOfString: [String:[String:String]]?
public var mapOfEnumString: [String:String]?
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
self.mapMapOfString = mapMapOfString
self.mapOfEnumString = mapOfEnumString
}
public enum CodingKeys: String, CodingKey {
case mapMapOfString = "map_map_of_string"

View File

@ -15,6 +15,12 @@ public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var dateTime: Date?
public var map: [String:Animal]?
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
self.uuid = uuid
self.dateTime = dateTime
self.map = map
}
}

View File

@ -15,6 +15,11 @@ public struct Model200Response: Codable {
public var name: Int?
public var _class: String?
public init(name: Int?, _class: String?) {
self.name = name
self._class = _class
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -17,6 +17,13 @@ public struct Name: Codable {
public var property: String?
public var _123Number: Int?
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
self.name = name
self.snakeCase = snakeCase
self.property = property
self._123Number = _123Number
}
public enum CodingKeys: String, CodingKey {
case name

View File

@ -13,6 +13,10 @@ public struct NumberOnly: Codable {
public var justNumber: Double?
public init(justNumber: Double?) {
self.justNumber = justNumber
}
public enum CodingKeys: String, CodingKey {
case justNumber = "JustNumber"

View File

@ -24,6 +24,15 @@ public struct Order: Codable {
public var status: Status?
public var complete: Bool?
public init(_id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
self._id = _id
self.petId = petId
self.quantity = quantity
self.shipDate = shipDate
self.status = status
self.complete = complete
}
public enum CodingKeys: String, CodingKey {
case _id = "id"

View File

@ -14,5 +14,6 @@ public struct OuterBoolean: Codable {
}

Some files were not shown because too many files have changed in this diff Show More